1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: navipi.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
34 //------------------------------------------------------------------
37 #include <rangelst.hxx>
38 #include <sfx2/app.hxx>
39 #include <sfx2/bindings.hxx>
40 #include <sfx2/dispatch.hxx>
41 #include <sfx2/event.hxx>
42 #include <sfx2/imgmgr.hxx>
43 #include <sfx2/navigat.hxx>
44 #include <svtools/stritem.hxx>
45 #include <svtools/urlbmk.hxx>
46 #include <vcl/sound.hxx>
47 #include <unotools/charclass.hxx>
50 #include "viewdata.hxx"
51 #include "tabvwsh.hxx"
53 #include "document.hxx"
54 #include "dbcolect.hxx"
55 #include "rangenam.hxx"
56 #include "rangeutl.hxx"
57 #include "popmenu.hxx"
58 #include "scresid.hxx"
60 #include "navicfg.hxx"
61 #include "navcitem.hxx"
64 #include "navsett.hxx"
66 // Timeout, um Notizen zu suchen
67 #define SC_CONTENT_TIMEOUT 1000
69 // Toleranz, wieviel ueber der eingeklappten Groesse noch klein ist
70 #define SCNAV_MINTOL 5
72 // maximum values for UI
73 #define SCNAV_MAXCOL (MAXCOLCOUNT)
74 // macro is sufficient since only used in ctor
75 #define SCNAV_COLDIGITS (static_cast<xub_StrLen>( floor( log10( static_cast<double>(SCNAV_MAXCOL)))) + 1) // 1...256...18278
76 // precomputed constant because it is used in every change of spin button field
77 static const xub_StrLen SCNAV_COLLETTERS
= ::ScColToAlpha(SCNAV_MAXCOL
).Len(); // A...IV...ZZZ
79 #define SCNAV_MAXROW (MAXROWCOUNT)
81 //------------------------------------------------------------------------
84 void ScNavigatorDlg::ReleaseFocus()
86 SfxViewShell
* pCurSh
= SfxViewShell::Current();
90 Window
* pShellWnd
= pCurSh
->GetWindow();
92 pShellWnd
->GrabFocus();
96 //==================================================================
98 //==================================================================
100 ColumnEdit::ColumnEdit( ScNavigatorDlg
* pParent
, const ResId
& rResId
)
101 : SpinField ( pParent
, rResId
),
104 nKeyGroup ( KEYGROUP_ALPHA
)
106 SetMaxTextLen( SCNAV_COLDIGITS
); // 1...256...18278 or A...IV...ZZZ
109 //------------------------------------------------------------------------
111 __EXPORT
ColumnEdit::~ColumnEdit()
115 //------------------------------------------------------------------------
117 long __EXPORT
ColumnEdit::Notify( NotifyEvent
& rNEvt
)
119 long nHandled
= SpinField::Notify( rNEvt
);
121 USHORT nType
= rNEvt
.GetType();
122 if ( nType
== EVENT_KEYINPUT
)
124 const KeyEvent
* pKEvt
= rNEvt
.GetKeyEvent();
125 KeyCode aCode
= pKEvt
->GetKeyCode();
127 if ( !aCode
.IsMod1() && !aCode
.IsMod2() )
129 //! Eingabeueberpruefung (nur Zahlen oder nur Buchstaben, max 2 bzw 3 Stellen)
130 //! war vor VCL per nicht weitergeleitetem KeyInput
131 //! dafuer was neues ausdenken!!!
133 if ( aCode
.GetCode() == KEY_RETURN
)
135 ScNavigatorDlg::ReleaseFocus();
141 else if ( nType
== EVENT_LOSEFOCUS
) // LoseFocus wird bei VCL nicht gerufen
142 EvalText(); // nCol setzen
147 //------------------------------------------------------------------------
149 void __EXPORT
ColumnEdit::LoseFocus()
155 //------------------------------------------------------------------------
157 void __EXPORT
ColumnEdit::Up()
162 if ( nCol
> SCNAV_MAXCOL
)
166 if ( nCol
<= SCNAV_MAXCOL
)
172 //------------------------------------------------------------------------
174 void __EXPORT
ColumnEdit::Down()
180 SetCol( SCNAV_MAXCOL
);
184 //------------------------------------------------------------------------
186 void __EXPORT
ColumnEdit::First()
192 //------------------------------------------------------------------------
194 void __EXPORT
ColumnEdit::Last()
197 nCol
= NumToAlpha( SCNAV_MAXCOL
, aStr
);
202 //------------------------------------------------------------------------
204 void ColumnEdit::EvalText()
206 String aStrCol
= GetText();
208 if ( aStrCol
.Len() > 0 )
210 // nKeyGroup wird bei VCL mangels KeyInput nicht mehr gesetzt
212 if ( CharClass::isAsciiNumeric(aStrCol
) )
213 nCol
= NumStrToAlpha( aStrCol
);
215 nCol
= AlphaToNum( aStrCol
);
221 nKeyGroup
= KEYGROUP_ALPHA
;
224 //------------------------------------------------------------------------
226 void ColumnEdit::ExecuteCol()
228 SCROW nRow
= rDlg
.aEdRow
.GetRow();
230 EvalText(); // setzt nCol
232 if ( (nCol
> 0) && (nRow
> 0) )
233 rDlg
.SetCurrentCell( nCol
-1, nRow
-1 );
236 //------------------------------------------------------------------------
238 void ColumnEdit::SetCol( SCCOL nColNo
)
249 nColNo
= NumToAlpha( nColNo
, aStr
);
255 //------------------------------------------------------------------------
257 SCCOL
ColumnEdit::AlphaToNum( String
& rStr
)
261 if ( CharClass::isAsciiAlpha( rStr
) )
265 if (::AlphaToCol( nColumn
, rStr
))
268 if ( (rStr
.Len() > SCNAV_COLLETTERS
) || (nColumn
> SCNAV_MAXCOL
) )
270 nColumn
= SCNAV_MAXCOL
;
271 NumToAlpha( nColumn
, rStr
);
280 //------------------------------------------------------------------------
282 SCCOL
ColumnEdit::NumStrToAlpha( String
& rStr
)
286 if ( CharClass::isAsciiNumeric(rStr
) )
287 nColumn
= NumToAlpha( (SCCOL
)rStr
.ToInt32(), rStr
);
294 //------------------------------------------------------------------------
296 SCCOL
ColumnEdit::NumToAlpha( SCCOL nColNo
, String
& rStr
)
298 if ( nColNo
> SCNAV_MAXCOL
)
299 nColNo
= SCNAV_MAXCOL
;
300 else if ( nColNo
< 1 )
303 ::ScColToAlpha( rStr
, nColNo
- 1);
308 //==================================================================
310 //==================================================================
312 RowEdit::RowEdit( ScNavigatorDlg
* pParent
, const ResId
& rResId
)
313 : NumericField( pParent
, rResId
),
316 SetMax( SCNAV_MAXROW
);
317 SetLast( SCNAV_MAXROW
);
320 //------------------------------------------------------------------------
322 __EXPORT
RowEdit::~RowEdit()
326 //------------------------------------------------------------------------
328 long __EXPORT
RowEdit::Notify( NotifyEvent
& rNEvt
)
330 long nHandled
= NumericField::Notify( rNEvt
);
332 if ( rNEvt
.GetType() == EVENT_KEYINPUT
)
334 const KeyEvent
* pKEvt
= rNEvt
.GetKeyEvent();
335 KeyCode aCode
= pKEvt
->GetKeyCode();
336 if ( aCode
.GetCode() == KEY_RETURN
&& !aCode
.IsMod1() && !aCode
.IsMod2() )
338 ScNavigatorDlg::ReleaseFocus();
347 //------------------------------------------------------------------------
349 void __EXPORT
RowEdit::LoseFocus()
353 //------------------------------------------------------------------------
355 void RowEdit::ExecuteRow()
357 SCCOL nCol
= rDlg
.aEdCol
.GetCol();
358 SCROW nRow
= (SCROW
)GetValue();
360 if ( (nCol
> 0) && (nRow
> 0) )
361 rDlg
.SetCurrentCell( nCol
-1, nRow
-1 );
364 //==================================================================
365 // class ScDocListBox
366 //==================================================================
368 ScDocListBox::ScDocListBox( ScNavigatorDlg
* pParent
, const ResId
& rResId
)
369 : ListBox ( pParent
, rResId
),
374 //------------------------------------------------------------------------
376 __EXPORT
ScDocListBox::~ScDocListBox()
380 //------------------------------------------------------------------------
382 void __EXPORT
ScDocListBox::Select()
384 ScNavigatorDlg::ReleaseFocus();
386 String aDocName
= GetSelectEntry();
387 rDlg
.aLbEntries
.SelectDoc( aDocName
);
390 //==================================================================
391 // class CommandToolBox
392 //==================================================================
394 CommandToolBox::CommandToolBox( ScNavigatorDlg
* pParent
, const ResId
& rResId
)
395 : ToolBox ( pParent
, rResId
),
398 InitImageList(); // ImageList members of ScNavigatorDlg must be initialized before!
400 SetSizePixel( CalcWindowSizePixel() );
401 SetDropdownClickHdl( LINK(this, CommandToolBox
, ToolBoxDropdownClickHdl
) );
402 SetItemBits( IID_DROPMODE
, GetItemBits( IID_DROPMODE
) | TIB_DROPDOWNONLY
);
403 // EnableItem( IID_UP, FALSE );
404 // EnableItem( IID_DOWN, FALSE );
407 //------------------------------------------------------------------------
409 __EXPORT
CommandToolBox::~CommandToolBox()
413 //------------------------------------------------------------------------
415 void CommandToolBox::Select( USHORT nSelId
)
417 // Modus umschalten ?
419 if ( nSelId
== IID_ZOOMOUT
|| nSelId
== IID_SCENARIOS
)
421 NavListMode eOldMode
= rDlg
.eListMode
;
422 NavListMode eNewMode
= eOldMode
;
424 if ( nSelId
== IID_SCENARIOS
) // auf Szenario
426 if ( eOldMode
== NAV_LMODE_SCENARIOS
)
427 eNewMode
= NAV_LMODE_AREAS
;
429 eNewMode
= NAV_LMODE_SCENARIOS
;
433 if ( eOldMode
== NAV_LMODE_NONE
)
434 eNewMode
= NAV_LMODE_AREAS
;
436 eNewMode
= NAV_LMODE_NONE
;
438 rDlg
.SetListMode( eNewMode
);
448 rDlg
.StartOfDataArea();
451 rDlg
.EndOfDataArea();
453 // IID_DROPMODE ist in Click
455 rDlg
.aLbEntries
.ToggleRoot();
461 void __EXPORT
CommandToolBox::Select()
463 Select( GetCurItemId() );
466 //------------------------------------------------------------------------
468 void __EXPORT
CommandToolBox::Click()
472 //------------------------------------------------------------------------
474 IMPL_LINK( CommandToolBox
, ToolBoxDropdownClickHdl
, ToolBox
*, EMPTYARG
)
476 // Das Popupmenue fuer den Dropmodus muss im Click (Button Down)
477 // statt im Select (Button Up) aufgerufen werden.
479 if ( GetCurItemId() == IID_DROPMODE
)
481 ScPopupMenu
aPop( ScResId( RID_POPUP_DROPMODE
) );
482 aPop
.CheckItem( RID_DROPMODE_URL
+ rDlg
.GetDropMode() );
483 aPop
.Execute( this, GetItemRect(IID_DROPMODE
), POPUPMENU_EXECUTE_DOWN
);
484 USHORT nId
= aPop
.GetSelected();
486 EndSelection(); // vor SetDropMode (SetDropMode ruft SetItemImage)
488 if ( nId
>= RID_DROPMODE_URL
&& nId
<= RID_DROPMODE_COPY
)
489 rDlg
.SetDropMode( nId
- RID_DROPMODE_URL
);
491 // #49956# den gehighlighteten Button aufheben
493 MouseEvent
aLeave( aPoint
, 0, MOUSE_LEAVEWINDOW
| MOUSE_SYNTHETIC
);
500 //------------------------------------------------------------------------
502 void CommandToolBox::UpdateButtons()
504 NavListMode eMode
= rDlg
.eListMode
;
505 CheckItem( IID_SCENARIOS
, eMode
== NAV_LMODE_SCENARIOS
);
506 CheckItem( IID_ZOOMOUT
, eMode
!= NAV_LMODE_NONE
);
508 // Umschalten-Button:
509 if ( eMode
== NAV_LMODE_SCENARIOS
|| eMode
== NAV_LMODE_NONE
)
511 EnableItem( IID_CHANGEROOT
, FALSE
);
512 CheckItem( IID_CHANGEROOT
, FALSE
);
516 EnableItem( IID_CHANGEROOT
, TRUE
);
517 BOOL bRootSet
= rDlg
.aLbEntries
.GetRootType() != SC_CONTENT_ROOT
;
518 CheckItem( IID_CHANGEROOT
, bRootSet
);
521 BOOL bDark
= GetDisplayBackground().GetColor().IsDark();
524 switch ( rDlg
.nDropMode
)
526 case SC_DROPMODE_URL
: nImageId
= bDark
? RID_IMG_H_DROP_URL
: RID_IMG_DROP_URL
; break;
527 case SC_DROPMODE_LINK
: nImageId
= bDark
? RID_IMG_H_DROP_LINK
: RID_IMG_DROP_LINK
; break;
528 case SC_DROPMODE_COPY
: nImageId
= bDark
? RID_IMG_H_DROP_COPY
: RID_IMG_DROP_COPY
; break;
530 SetItemImage( IID_DROPMODE
, Image(ScResId(nImageId
)) );
533 void CommandToolBox::InitImageList()
535 BOOL bDark
= GetDisplayBackground().GetColor().IsDark();
537 ImageList
& rImgLst
= bDark
? rDlg
.aCmdImageListH
: rDlg
.aCmdImageList
;
539 USHORT nCount
= GetItemCount();
540 for (USHORT i
= 0; i
< nCount
; i
++)
542 USHORT nId
= GetItemId(i
);
543 SetItemImage( nId
, rImgLst
.GetImage( nId
) );
547 void CommandToolBox::DataChanged( const DataChangedEvent
& rDCEvt
)
549 if ( rDCEvt
.GetType() == DATACHANGED_SETTINGS
&& (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
551 // update item images
554 UpdateButtons(); // drop mode
557 ToolBox::DataChanged( rDCEvt
);
560 //==================================================================
561 // class ScNavigatorSettings
562 //==================================================================
564 ScNavigatorSettings::ScNavigatorSettings() :
565 maExpandedVec( SC_CONTENT_COUNT
, FALSE
),
566 mnRootSelected( SC_CONTENT_ROOT
),
567 mnChildSelected( SC_CONTENT_NOCHILD
)
571 //==================================================================
572 // class ScNavigatorDlgWrapper
573 //==================================================================
575 SFX_IMPL_CHILDWINDOWCONTEXT( ScNavigatorDialogWrapper
, SID_NAVIGATOR
)
577 #define IS_MODE(bit)(((nFlags)&(bit))==(bit))
579 ScNavigatorDialogWrapper::ScNavigatorDialogWrapper(
583 SfxChildWinInfo
* /* pInfo */ ) :
584 SfxChildWindowContext( nId
)
586 pNavigator
= new ScNavigatorDlg( pBind
, this, pParent
);
587 SetWindow( pNavigator
);
589 // Einstellungen muessen anderswo gemerkt werden,
590 // pInfo geht uns (ausser der Groesse) nichts mehr an
592 Size aInfoSize
= pParent
->GetOutputSizePixel(); // von aussen vorgegebene Groesse
593 Size aNavSize
= pNavigator
->GetOutputSizePixel(); // Default-Groesse
595 aNavSize
.Width() = Max( aInfoSize
.Width(), aNavSize
.Width() );
596 aNavSize
.Height() = Max( aInfoSize
.Height(), aNavSize
.Height() );
597 pNavigator
->nListModeHeight
= Max( aNavSize
.Height(), pNavigator
->nListModeHeight
);
599 // Die Groesse kann in einem anderen Modul geaendert worden sein,
600 // deshalb muessen in Abhaengigkeit von der momentanen Groesse die
601 // Inhalte eingeblendet werden oder nicht
603 BOOL bSmall
= ( aInfoSize
.Height() <= pNavigator
->aInitSize
.Height() + SCNAV_MINTOL
);
604 NavListMode eNavMode
= NAV_LMODE_NONE
;
607 // wenn Szenario aktiv war, wieder einschalten
609 ScNavipiCfg
& rCfg
= SC_MOD()->GetNavipiCfg();
610 NavListMode eLastMode
= (NavListMode
) rCfg
.GetListMode();
611 if ( eLastMode
== NAV_LMODE_SCENARIOS
)
612 eNavMode
= NAV_LMODE_SCENARIOS
;
614 eNavMode
= NAV_LMODE_AREAS
;
617 // Die Groesse des Floats nicht neu setzen (FALSE bei SetListMode), damit der
618 // Navigator nicht aufgeklappt wird, wenn er minimiert war (#38872#).
620 pNavigator
->SetListMode( eNavMode
, FALSE
); // FALSE: Groesse des Float nicht setzen
625 case NAV_LMODE_DOCS
: nCmdId
= IID_DOCS
; break;
626 case NAV_LMODE_AREAS
: nCmdId
= IID_AREAS
; break;
627 case NAV_LMODE_DBAREAS
: nCmdId
= IID_DBAREAS
; break;
628 case NAV_LMODE_SCENARIOS
: nCmdId
= IID_SCENARIOS
; break;
633 pNavigator
->aTbxCmd
.CheckItem( nCmdId
);
634 pNavigator
->DoResize();
637 pNavigator
->bFirstBig
= ( nCmdId
== 0 ); // dann spaeter
640 FloatingWindow* pFloat = GetFloatingWindow();
642 pFloat->SetMinOutputSizePixel( pNavigator->GetMinOutputSizePixel() );
645 //!? pNavigator->Show();
648 void __EXPORT
ScNavigatorDialogWrapper::Resizing( Size
& rSize
)
650 ((ScNavigatorDlg
*)GetWindow())->Resizing(rSize
);
653 //========================================================================
654 // class ScNavigatorPI
655 //========================================================================
659 #define REGISTER_SLOT(i,id) \
660 ppBoundItems[i]=new ScNavigatorControllerItem(id,*this,rBindings);
662 ScNavigatorDlg::ScNavigatorDlg( SfxBindings
* pB
, SfxChildWindowContext
* pCW
, Window
* pParent
) :
663 Window( pParent
, ScResId(RID_SCDLG_NAVIGATOR
) ),
664 rBindings ( *pB
), // is used in CommandToolBox ctor
665 aCmdImageList( ScResId( IL_CMD
) ),
666 aCmdImageListH( ScResId( ILH_CMD
) ),
667 aFtCol ( this, ScResId( FT_COL
) ),
668 aEdCol ( this, ScResId( ED_COL
) ),
669 aFtRow ( this, ScResId( FT_ROW
) ),
670 aEdRow ( this, ScResId( ED_ROW
) ),
671 aTbxCmd ( this, ScResId( TBX_CMD
) ),
672 aLbEntries ( this, ScResId( LB_ENTRIES
) ),
673 aWndScenarios( this,ScResId( STR_QHLP_SCEN_LISTBOX
), ScResId(STR_QHLP_SCEN_COMMENT
)),
674 aLbDocuments( this, ScResId( LB_DOCUMENTS
) ),
675 aStrDragMode ( ScResId( STR_DRAGMODE
) ),
676 aStrDisplay ( ScResId( STR_DISPLAY
) ),
677 aStrActiveWin( ScResId( STR_ACTIVEWIN
) ),
681 nListModeHeight( 0 ),
682 nInitListHeight( 0 ),
683 eListMode ( NAV_LMODE_NONE
),
684 nDropMode ( SC_DROPMODE_URL
),
690 ScNavipiCfg
& rCfg
= SC_MOD()->GetNavipiCfg();
691 nDropMode
= rCfg
.GetDragMode();
692 // eListMode wird von aussen gesetzt, Root weiter unten
694 aLbDocuments
.SetDropDownLineCount(9);
695 String aOpen
= String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM( " (" ));
697 aStrActive
+= String( ScResId( STR_ACTIVE
) );
698 aStrActive
+= ')'; // " (aktiv)"
699 aStrNotActive
= aOpen
;
700 aStrNotActive
+= String( ScResId( STR_NOTACTIVE
) );
701 aStrNotActive
+= ')'; // " (inaktiv)"
703 aStrHidden
+= String( ScResId( STR_HIDDEN
) );
704 aStrHidden
+= ')'; // " (versteckt)"
706 aTitleBase
= GetText();
708 long nListboxYPos
= aTbxCmd
.GetPosPixel().Y() + aTbxCmd
.GetSizePixel().Height() + 4;
709 aLbEntries
.SetPosSizePixel( 0, nListboxYPos
, 0, 0, WINDOW_POSSIZE_Y
);
711 nBorderOffset
= aLbEntries
.GetPosPixel().X();
713 aInitSize
.Width() = aTbxCmd
.GetPosPixel().X()
714 + aTbxCmd
.GetSizePixel().Width()
716 aInitSize
.Height() = aLbEntries
.GetPosPixel().Y();
718 nInitListHeight
= aLbEntries
.GetSizePixel().Height();
719 nListModeHeight
= aInitSize
.Height()
722 // kein Resize, eh der ganze Kontext-Kram initialisiert ist!
723 // SetOutputSizePixel( aInitSize ); //???
724 /*! FloatingWindow* pFloat = pContextWin->GetFloatingWindow();
726 pFloat->SetMinOutputSizePixel( aInitSize );
728 ppBoundItems
= new ScNavigatorControllerItem
* [CTRL_ITEMS
];
730 rBindings
.ENTERREGISTRATIONS();
731 //-----------------------------
732 REGISTER_SLOT( 0, SID_CURRENTCELL
);
733 REGISTER_SLOT( 1, SID_CURRENTTAB
);
734 REGISTER_SLOT( 2, SID_CURRENTDOC
);
735 REGISTER_SLOT( 3, SID_SELECT_SCENARIO
);
736 //-----------------------------
737 rBindings
.LEAVEREGISTRATIONS();
739 StartListening( *(SFX_APP()) );
740 StartListening( rBindings
);
742 aLbDocuments
.Hide(); // bei NAV_LMODE_NONE gibts die nicht
744 aLbEntries
.InitWindowBits(TRUE
);
746 aLbEntries
.SetSpaceBetweenEntries(0);
747 aLbEntries
.SetSelectionMode( SINGLE_SELECTION
);
748 aLbEntries
.SetDragDropMode( SV_DRAGDROP_CTRL_MOVE
|
749 SV_DRAGDROP_CTRL_COPY
|
750 SV_DRAGDROP_ENABLE_TOP
);
752 // war eine Kategorie als Root ausgewaehlt?
753 USHORT nLastRoot
= rCfg
.GetRootType();
755 aLbEntries
.SetRootType( nLastRoot
);
757 aLbEntries
.Refresh();
760 aTbxCmd
.UpdateButtons();
766 aWndScenarios
.Hide();
767 aWndScenarios
.SetPosPixel( aLbEntries
.GetPosPixel() );
769 aContentTimer
.SetTimeoutHdl( LINK( this, ScNavigatorDlg
, TimeHdl
) );
770 aContentTimer
.SetTimeout( SC_CONTENT_TIMEOUT
);
775 //------------------------------------------------------------------------
777 __EXPORT
ScNavigatorDlg::~ScNavigatorDlg()
779 aContentTimer
.Stop();
782 for ( i
=0; i
<CTRL_ITEMS
; i
++ )
783 delete ppBoundItems
[i
];
785 delete [] ppBoundItems
;
788 EndListening( *(SFX_APP()) );
789 EndListening( rBindings
);
792 //------------------------------------------------------------------------
794 void __EXPORT
ScNavigatorDlg::Resizing( Size
& rNewSize
) // Size = Outputsize?
796 FloatingWindow
* pFloat
= pContextWin
->GetFloatingWindow();
799 Size aMinOut
= pFloat
->GetMinOutputSizePixel();
801 if ( rNewSize
.Width() < aMinOut
.Width() )
802 rNewSize
.Width() = aMinOut
.Width();
804 if ( eListMode
== NAV_LMODE_NONE
)
805 rNewSize
.Height() = aInitSize
.Height();
808 if ( rNewSize
.Height() < aMinOut
.Height() )
809 rNewSize
.Height() = aMinOut
.Height();
813 // SfxDockingWindow::Resizing(rNewSize);
818 void ScNavigatorDlg::Paint( const Rectangle
& rRec
)
820 const StyleSettings
& rStyleSettings
= Application::GetSettings().GetStyleSettings();
821 Color aBgColor
= rStyleSettings
.GetFaceColor();
822 Wallpaper
aBack( aBgColor
);
824 SetBackground( aBack
);
825 aFtCol
.SetBackground( aBack
);
826 aFtRow
.SetBackground( aBack
);
828 Window::Paint( rRec
);
831 void ScNavigatorDlg::DataChanged( const DataChangedEvent
& rDCEvt
)
833 if ( rDCEvt
.GetType() == DATACHANGED_SETTINGS
&& (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
835 // toolbox images are exchanged in CommandToolBox::DataChanged
839 Window::DataChanged( rDCEvt
);
842 //------------------------------------------------------------------------
844 void __EXPORT
ScNavigatorDlg::Resize()
849 //------------------------------------------------------------------------
851 void ScNavigatorDlg::DoResize()
853 Size aNewSize
= GetOutputSizePixel();
854 long nTotalHeight
= aNewSize
.Height();
856 // #41403# bei angedocktem Navigator wird das Fenster evtl. erst klein erzeugt,
857 // dann kommt ein Resize auf die wirkliche Groesse -> dann Inhalte einschalten
859 BOOL bSmall
= ( nTotalHeight
<= aInitSize
.Height() + SCNAV_MINTOL
);
860 if ( !bSmall
&& bFirstBig
)
862 // Inhalte laut Config wieder einschalten
865 NavListMode eNavMode
= NAV_LMODE_AREAS
;
866 ScNavipiCfg
& rCfg
= SC_MOD()->GetNavipiCfg();
867 NavListMode eLastMode
= (NavListMode
) rCfg
.GetListMode();
868 if ( eLastMode
== NAV_LMODE_SCENARIOS
)
869 eNavMode
= NAV_LMODE_SCENARIOS
;
870 SetListMode( eNavMode
, FALSE
); // FALSE: Groesse des Float nicht setzen
873 // auch wenn die Inhalte nicht sichtbar sind, die Groessen anpassen,
874 // damit die Breite stimmt
876 //@@ 03.11.97 changes begin
877 Point aEntryPos
= aLbEntries
.GetPosPixel();
878 Point aListPos
= aLbDocuments
.GetPosPixel();
879 aNewSize
.Width() -= 2*nBorderOffset
;
880 Size aDocSize
= aLbDocuments
.GetSizePixel();
881 aDocSize
.Width() = aNewSize
.Width();
886 long nListHeight
= aLbDocuments
.GetSizePixel().Height();
887 aNewSize
.Height() -= ( aEntryPos
.Y() + nListHeight
+ 2*nBorderOffset
);
888 if(aNewSize
.Height()<0) aNewSize
.Height()=0;
890 aListPos
.Y() = aEntryPos
.Y() + aNewSize
.Height() + nBorderOffset
;
892 if(aListPos
.Y() > aLbEntries
.GetPosPixel().Y())
893 aLbDocuments
.SetPosPixel( aListPos
);
896 aLbEntries
.SetSizePixel( aNewSize
);
897 aWndScenarios
.SetSizePixel( aNewSize
);
898 aLbDocuments
.SetSizePixel( aDocSize
);
902 BOOL bListMode
= (eListMode
!= NAV_LMODE_NONE
);
903 FloatingWindow
* pFloat
= pContextWin
->GetFloatingWindow();
904 if ( pFloat
&& bListMode
)
905 nListModeHeight
= nTotalHeight
;
908 //------------------------------------------------------------------------
910 void __EXPORT
ScNavigatorDlg::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
912 if ( rHint
.ISA(SfxSimpleHint
) )
914 ULONG nHintId
= ((SfxSimpleHint
&)rHint
).GetId();
916 if ( nHintId
== SC_HINT_DOCNAME_CHANGED
)
918 aLbEntries
.ActiveDocChanged();
920 else if ( NAV_LMODE_NONE
== eListMode
)
922 // Tabellen hier nicht mehr
928 case SC_HINT_TABLES_CHANGED
:
929 aLbEntries
.Refresh( SC_CONTENT_TABLE
);
932 case SC_HINT_DBAREAS_CHANGED
:
933 aLbEntries
.Refresh( SC_CONTENT_DBAREA
);
936 case SC_HINT_AREAS_CHANGED
:
937 aLbEntries
.Refresh( SC_CONTENT_RANGENAME
);
940 case SC_HINT_DRAW_CHANGED
:
941 aLbEntries
.Refresh( SC_CONTENT_GRAPHIC
);
942 aLbEntries
.Refresh( SC_CONTENT_OLEOBJECT
);
943 aLbEntries
.Refresh( SC_CONTENT_DRAWING
);
946 case SC_HINT_AREALINKS_CHANGED
:
947 aLbEntries
.Refresh( SC_CONTENT_AREALINK
);
950 // SFX_HINT_DOCCHANGED kommt nicht nur bei Dokument-Wechsel
952 case SC_HINT_NAVIGATOR_UPDATEALL
:
956 case FID_DATACHANGED
:
957 case FID_ANYDATACHANGED
:
958 aContentTimer
.Start(); // Notizen nicht sofort suchen
966 else if ( rHint
.ISA(SfxEventHint
) )
968 ULONG nEventId
= ((SfxEventHint
&)rHint
).GetEventId();
969 if ( nEventId
== SFX_EVENT_ACTIVATEDOC
)
971 aLbEntries
.ActiveDocChanged();
977 //------------------------------------------------------------------------
979 IMPL_LINK( ScNavigatorDlg
, TimeHdl
, Timer
*, pTimer
)
981 if ( pTimer
!= &aContentTimer
)
984 aLbEntries
.Refresh( SC_CONTENT_NOTE
);
988 //------------------------------------------------------------------------
990 void ScNavigatorDlg::SetDropMode(USHORT nNew
)
993 aTbxCmd
.UpdateButtons();
995 ScNavipiCfg
& rCfg
= SC_MOD()->GetNavipiCfg();
996 rCfg
.SetDragMode(nDropMode
);
999 //------------------------------------------------------------------------
1001 void ScNavigatorDlg::CursorPosChanged()
1003 //! Eintraege selektieren ???
1005 // if ( GetDBAtCursor( aStrDbName ) )
1006 // if ( GetAreaAtCursor( aStrAreaName ) )
1009 //------------------------------------------------------------------------
1011 void ScNavigatorDlg::SetCurrentCell( SCCOL nColNo
, SCROW nRowNo
)
1013 if ( (nColNo
+1 != nCurCol
) || (nRowNo
+1 != nCurRow
) )
1015 // SID_CURRENTCELL == Item #0 Cache leeren, damit das Setzen der
1016 // aktuellen Zelle auch in zusammengefassten Bereichen funktioniert.
1017 ppBoundItems
[0]->ClearCache();
1019 ScAddress
aScAddress( nColNo
, nRowNo
, 0 );
1021 aScAddress
.Format( aAddr
, SCA_ABS
);
1023 BOOL bUnmark
= FALSE
;
1024 if ( GetViewData() )
1025 bUnmark
= !pViewData
->GetMarkData().IsCellMarked( nColNo
, nRowNo
);
1027 SfxStringItem
aPosItem( SID_CURRENTCELL
, aAddr
);
1028 SfxBoolItem
aUnmarkItem( FN_PARAM_1
, bUnmark
); // ggf. Selektion aufheben
1030 rBindings
.GetDispatcher()->Execute( SID_CURRENTCELL
,
1031 SFX_CALLMODE_SYNCHRON
| SFX_CALLMODE_RECORD
,
1032 &aPosItem
, &aUnmarkItem
, 0L );
1036 void ScNavigatorDlg::SetCurrentCellStr( const String rName
)
1038 ppBoundItems
[0]->ClearCache();
1039 SfxStringItem
aNameItem( SID_CURRENTCELL
, rName
);
1041 rBindings
.GetDispatcher()->Execute( SID_CURRENTCELL
,
1042 SFX_CALLMODE_SYNCHRON
| SFX_CALLMODE_RECORD
,
1046 //------------------------------------------------------------------------
1048 void ScNavigatorDlg::SetCurrentTable( SCTAB nTabNo
)
1050 if ( nTabNo
!= nCurTab
)
1052 // Tabelle fuer Basic ist 1-basiert
1053 SfxUInt16Item
aTabItem( SID_CURRENTTAB
, static_cast<sal_uInt16
>(nTabNo
) + 1 );
1054 rBindings
.GetDispatcher()->Execute( SID_CURRENTTAB
,
1055 SFX_CALLMODE_SYNCHRON
| SFX_CALLMODE_RECORD
,
1060 void ScNavigatorDlg::SetCurrentTableStr( const String rName
)
1062 if (!GetViewData()) return;
1064 ScDocument
* pDoc
= pViewData
->GetDocument();
1065 SCTAB nCount
= pDoc
->GetTableCount();
1068 for ( SCTAB i
=0; i
<nCount
; i
++ )
1070 pDoc
->GetName( i
, aTabName
);
1071 if ( aTabName
== rName
)
1073 SetCurrentTable( i
);
1078 Sound::Beep(); // Tabelle nicht gefunden
1081 //------------------------------------------------------------------------
1083 void ScNavigatorDlg::SetCurrentObject( const String rName
)
1085 SfxStringItem
aNameItem( SID_CURRENTOBJECT
, rName
);
1086 rBindings
.GetDispatcher()->Execute( SID_CURRENTOBJECT
,
1087 SFX_CALLMODE_SYNCHRON
| SFX_CALLMODE_RECORD
,
1091 //------------------------------------------------------------------------
1093 void ScNavigatorDlg::SetCurrentDoc( const String
& rDocName
) // aktivieren
1095 SfxStringItem
aDocItem( SID_CURRENTDOC
, rDocName
);
1096 rBindings
.GetDispatcher()->Execute( SID_CURRENTDOC
,
1097 SFX_CALLMODE_SYNCHRON
| SFX_CALLMODE_RECORD
,
1101 //------------------------------------------------------------------------
1103 ScTabViewShell
* ScNavigatorDlg::GetTabViewShell() const
1105 return PTR_CAST( ScTabViewShell
, SfxViewShell::Current() );
1108 //------------------------------------------------------------------------
1110 ScNavigatorSettings
* ScNavigatorDlg::GetNavigatorSettings()
1112 // #95791# Don't store the settings pointer here, because the settings belong to
1113 // the view, and the view may be closed while the navigator is open (reload).
1114 // If the pointer is cached here again later for performance reasons, it has to
1115 // be forgotten when the view is closed.
1117 ScTabViewShell
* pViewSh
= GetTabViewShell();
1118 return pViewSh
? pViewSh
->GetNavigatorSettings() : NULL
;
1121 //------------------------------------------------------------------------
1123 BOOL
ScNavigatorDlg::GetViewData()
1125 ScTabViewShell
* pViewSh
= GetTabViewShell();
1126 pViewData
= pViewSh
? pViewSh
->GetViewData() : NULL
;
1128 return ( pViewData
!= NULL
);
1131 //------------------------------------------------------------------------
1133 void ScNavigatorDlg::UpdateColumn( const SCCOL
* pCol
)
1137 else if ( GetViewData() )
1138 nCurCol
= pViewData
->GetCurX() + 1;
1140 aEdCol
.SetCol( nCurCol
);
1144 //------------------------------------------------------------------------
1146 void ScNavigatorDlg::UpdateRow( const SCROW
* pRow
)
1150 else if ( GetViewData() )
1151 nCurRow
= pViewData
->GetCurY() + 1;
1153 aEdRow
.SetRow( nCurRow
);
1157 //------------------------------------------------------------------------
1159 void ScNavigatorDlg::UpdateTable( const SCTAB
* pTab
)
1163 else if ( GetViewData() )
1164 nCurTab
= pViewData
->GetTabNo();
1166 // aLbTables.SetTab( nCurTab );
1170 //------------------------------------------------------------------------
1172 void ScNavigatorDlg::UpdateAll()
1174 switch ( eListMode
)
1176 case NAV_LMODE_DOCS
:
1177 case NAV_LMODE_DBAREAS
:
1178 case NAV_LMODE_AREAS
:
1179 aLbEntries
.Refresh();
1182 case NAV_LMODE_NONE
:
1190 aContentTimer
.Stop(); // dann nicht nochmal
1193 //------------------------------------------------------------------------
1195 void ScNavigatorDlg::SetListMode( NavListMode eMode
, BOOL bSetSize
)
1197 if ( eMode
!= eListMode
)
1199 if ( eMode
!= NAV_LMODE_NONE
)
1200 bFirstBig
= FALSE
; // nicht mehr automatisch umschalten
1206 case NAV_LMODE_NONE
:
1207 ShowList( FALSE
, bSetSize
);
1210 case NAV_LMODE_AREAS
:
1211 case NAV_LMODE_DBAREAS
:
1212 case NAV_LMODE_DOCS
:
1213 aLbEntries
.Refresh();
1214 ShowList( TRUE
, bSetSize
);
1217 case NAV_LMODE_SCENARIOS
:
1218 ShowScenarios( TRUE
, bSetSize
);
1222 aTbxCmd
.UpdateButtons();
1224 if ( eMode
!= NAV_LMODE_NONE
)
1226 ScNavipiCfg
& rCfg
= SC_MOD()->GetNavipiCfg();
1227 rCfg
.SetListMode( (USHORT
) eMode
);
1235 //------------------------------------------------------------------------
1237 void ScNavigatorDlg::ShowList( BOOL bShow
, BOOL bSetSize
)
1239 FloatingWindow
* pFloat
= pContextWin
->GetFloatingWindow();
1240 Size aSize
= GetParent()->GetOutputSizePixel();
1244 Size aMinSize
= aInitSize
;
1246 aMinSize
.Height() += nInitListHeight
;
1248 pFloat
->SetMinOutputSizePixel( aMinSize
);
1249 aSize
.Height() = nListModeHeight
;
1251 aLbDocuments
.Show();
1257 pFloat
->SetMinOutputSizePixel( aInitSize
);
1258 nListModeHeight
= aSize
.Height();
1260 aSize
.Height() = aInitSize
.Height();
1262 aLbDocuments
.Hide();
1264 aWndScenarios
.Hide();
1269 pFloat
->SetOutputSizePixel( aSize
);
1273 SfxNavigator
* pNav
= (SfxNavigator
*)GetParent();
1274 Size aFloating
= pNav
->GetFloatingSize();
1275 aFloating
.Height() = aSize
.Height();
1276 pNav
->SetFloatingSize( aFloating
);
1280 //------------------------------------------------------------------------
1282 void ScNavigatorDlg::ShowScenarios( BOOL bShow
, BOOL bSetSize
)
1284 FloatingWindow
* pFloat
= pContextWin
->GetFloatingWindow();
1285 Size aSize
= GetParent()->GetOutputSizePixel();
1289 Size aMinSize
= aInitSize
;
1290 aMinSize
.Height() += nInitListHeight
;
1292 pFloat
->SetMinOutputSizePixel( aMinSize
);
1293 aSize
.Height() = nListModeHeight
;
1295 rBindings
.Invalidate( SID_SELECT_SCENARIO
);
1296 rBindings
.Update( SID_SELECT_SCENARIO
);
1298 aWndScenarios
.Show();
1299 aLbDocuments
.Show();
1305 pFloat
->SetMinOutputSizePixel( aInitSize
);
1306 nListModeHeight
= aSize
.Height();
1308 aSize
.Height() = aInitSize
.Height();
1309 aWndScenarios
.Hide();
1310 aLbDocuments
.Hide();
1317 pFloat
->SetOutputSizePixel( aSize
);
1321 SfxNavigator
* pNav
= (SfxNavigator
*)GetParent();
1322 Size aFloating
= pNav
->GetFloatingSize();
1323 aFloating
.Height() = aSize
.Height();
1324 pNav
->SetFloatingSize( aFloating
);
1329 //------------------------------------------------------------------------
1331 // Dokumente fuer Dropdown-Listbox
1333 //------------------------------------------------------------------------
1335 void ScNavigatorDlg::GetDocNames( const String
* pManualSel
)
1337 aLbDocuments
.Clear();
1338 aLbDocuments
.SetUpdateMode( FALSE
);
1340 ScDocShell
* pCurrentSh
= PTR_CAST( ScDocShell
, SfxObjectShell::Current() );
1343 SfxObjectShell
* pSh
= SfxObjectShell::GetFirst();
1346 if ( pSh
->ISA(ScDocShell
) )
1348 String aName
= pSh
->GetTitle();
1349 String aEntry
= aName
;
1350 if (pSh
== pCurrentSh
)
1351 aEntry
+= aStrActive
;
1353 aEntry
+= aStrNotActive
;
1354 aLbDocuments
.InsertEntry( aEntry
);
1356 if ( pManualSel
? ( aName
== *pManualSel
)
1357 : ( pSh
== pCurrentSh
) )
1358 aSelEntry
= aEntry
; // kompletter Eintrag zum Selektieren
1361 pSh
= SfxObjectShell::GetNext( *pSh
);
1364 aLbDocuments
.InsertEntry( aStrActiveWin
);
1366 String aHidden
= aLbEntries
.GetHiddenTitle();
1369 String aEntry
= aHidden
;
1370 aEntry
+= aStrHidden
;
1371 aLbDocuments
.InsertEntry( aEntry
);
1373 if ( pManualSel
&& aHidden
== *pManualSel
)
1377 aLbDocuments
.SetUpdateMode( TRUE
);
1379 aLbDocuments
.SelectEntry( aSelEntry
);
1382 //------------------------------------------------------------------------
1384 void ScNavigatorDlg::MarkDataArea()
1386 ScTabViewShell
* pViewSh
= GetTabViewShell();
1391 pMarkArea
= new ScArea
;
1393 pViewSh
->MarkDataArea();
1395 pViewSh
->GetViewData()->GetMarkData().GetMarkArea(aMarkRange
);
1396 pMarkArea
->nColStart
= aMarkRange
.aStart
.Col();
1397 pMarkArea
->nRowStart
= aMarkRange
.aStart
.Row();
1398 pMarkArea
->nColEnd
= aMarkRange
.aEnd
.Col();
1399 pMarkArea
->nRowEnd
= aMarkRange
.aEnd
.Row();
1400 pMarkArea
->nTab
= aMarkRange
.aStart
.Tab();
1404 //------------------------------------------------------------------------
1406 void ScNavigatorDlg::UnmarkDataArea()
1408 ScTabViewShell
* pViewSh
= GetTabViewShell();
1413 DELETEZ( pMarkArea
);
1417 //------------------------------------------------------------------------
1419 void ScNavigatorDlg::CheckDataArea()
1421 if ( aTbxCmd
.IsItemChecked( IID_DATA
) && pMarkArea
)
1423 if ( nCurTab
!= pMarkArea
->nTab
1424 || nCurCol
< pMarkArea
->nColStart
+1
1425 || nCurCol
> pMarkArea
->nColEnd
+1
1426 || nCurRow
< pMarkArea
->nRowStart
+1
1427 || nCurRow
> pMarkArea
->nRowEnd
+1 )
1429 aTbxCmd
.SetItemState( IID_DATA
, TriState(STATE_CHECK
) );
1430 aTbxCmd
.Select( IID_DATA
);
1435 //------------------------------------------------------------------------
1437 void ScNavigatorDlg::StartOfDataArea()
1439 // pMarkArea auswerten ???
1441 if ( GetViewData() )
1443 ScMarkData
& rMark
= pViewData
->GetMarkData();
1445 rMark
.GetMarkArea( aMarkRange
);
1447 SCCOL nCol
= aMarkRange
.aStart
.Col();
1448 SCROW nRow
= aMarkRange
.aStart
.Row();
1450 if ( (nCol
+1 != aEdCol
.GetCol()) || (nRow
+1 != aEdRow
.GetRow()) )
1451 SetCurrentCell( nCol
, nRow
);
1455 //------------------------------------------------------------------------
1457 void ScNavigatorDlg::EndOfDataArea()
1459 // pMarkArea auswerten ???
1461 if ( GetViewData() )
1463 ScMarkData
& rMark
= pViewData
->GetMarkData();
1465 rMark
.GetMarkArea( aMarkRange
);
1467 SCCOL nCol
= aMarkRange
.aEnd
.Col();
1468 SCROW nRow
= aMarkRange
.aEnd
.Row();
1470 if ( (nCol
+1 != aEdCol
.GetCol()) || (nRow
+1 != aEdRow
.GetRow()) )
1471 SetCurrentCell( nCol
, nRow
);
1475 //------------------------------------------------------------------------
1477 SfxChildAlignment __EXPORT
ScNavigatorDlg::CheckAlignment(
1478 SfxChildAlignment eActAlign
, SfxChildAlignment eAlign
)
1480 SfxChildAlignment eRetAlign
;
1482 //! kein Andocken, wenn Listbox nicht da ???
1487 case SFX_ALIGN_HIGHESTTOP
:
1488 case SFX_ALIGN_LOWESTTOP
:
1489 case SFX_ALIGN_BOTTOM
:
1490 case SFX_ALIGN_LOWESTBOTTOM
:
1491 case SFX_ALIGN_HIGHESTBOTTOM
:
1492 eRetAlign
= eActAlign
; // nicht erlaubt
1495 case SFX_ALIGN_LEFT
:
1496 case SFX_ALIGN_RIGHT
:
1497 case SFX_ALIGN_FIRSTLEFT
:
1498 case SFX_ALIGN_LASTLEFT
:
1499 case SFX_ALIGN_FIRSTRIGHT
:
1500 case SFX_ALIGN_LASTRIGHT
:
1501 eRetAlign
= eAlign
; // erlaubt
1511 //------------------------------------------------------------------------
1513 // Drop auf den Navigator - andere Datei laden (File oder Bookmark)
1515 //------------------------------------------------------------------------
1518 BOOL __EXPORT
ScNavigatorDlg::Drop( const DropEvent
& rEvt
)
1520 BOOL bReturn
= FALSE
;
1522 if ( !aLbEntries
.IsInDrag() ) // kein Verschieben innerhalb der TreeListBox
1526 SvScDataObjectRef pObject
= SvScDataObject::PasteDragServer(rEvt
);
1528 ULONG nFormat
= INetBookmark::HasFormat(*pObject
);
1529 INetBookmark aBookmark
;
1530 if (aBookmark
.Paste(*pObject
,nFormat
))
1531 aFileName
= aBookmark
.GetURL();
1534 // FORMAT_FILE direkt aus DragServer
1536 USHORT nCount
= DragServer::GetItemCount();
1537 for ( USHORT i
= 0; i
< nCount
&& !aFileName
.Len(); ++i
)
1538 if (DragServer::HasFormat( i
, FORMAT_FILE
))
1539 aFileName
= DragServer::PasteFile( i
);
1542 if ( aFileName
.Len() )
1543 bReturn
= aLbEntries
.LoadFile( aFileName
);
1548 BOOL __EXPORT
ScNavigatorDlg::QueryDrop( DropEvent
& rEvt
)
1550 BOOL bReturn
= FALSE
;
1552 if ( !aLbEntries
.IsInDrag() ) // kein Verschieben innerhalb der TreeListBox
1554 SvScDataObjectRef pObject
= SvScDataObject::PasteDragServer(rEvt
);
1555 if ( pObject
->HasFormat(FORMAT_FILE
)
1556 || INetBookmark::HasFormat(*pObject
) )
1558 rEvt
.SetAction(DROP_COPY
); // Kopier-Cursor anzeigen