1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <rangelst.hxx>
21 #include <sfx2/app.hxx>
22 #include <sfx2/bindings.hxx>
23 #include <sfx2/dispatch.hxx>
24 #include <sfx2/event.hxx>
25 #include <sfx2/imgmgr.hxx>
26 #include <sfx2/navigat.hxx>
27 #include <svl/stritem.hxx>
28 #include <svl/urlbmk.hxx>
29 #include <unotools/charclass.hxx>
32 #include "viewdata.hxx"
33 #include "tabvwsh.hxx"
35 #include "document.hxx"
37 #include "rangenam.hxx"
38 #include "rangeutl.hxx"
39 #include "popmenu.hxx"
40 #include "scresid.hxx"
42 #include "navicfg.hxx"
43 #include "navcitem.hxx"
46 #include "navsett.hxx"
47 #include "markdata.hxx"
51 // Timeout, um Notizen zu suchen
52 #define SC_CONTENT_TIMEOUT 1000
54 // Toleranz, wieviel ueber der eingeklappten Groesse noch klein ist
55 #define SCNAV_MINTOL 5
57 // maximum values for UI
58 #define SCNAV_MAXCOL (MAXCOLCOUNT)
59 // macro is sufficient since only used in ctor
60 #define SCNAV_COLDIGITS (static_cast<xub_StrLen>( floor( log10( static_cast<double>(SCNAV_MAXCOL)))) + 1) // 1...256...18278
61 // precomputed constant because it is used in every change of spin button field
62 static const sal_Int32 SCNAV_COLLETTERS
= ::ScColToAlpha(SCNAV_MAXCOL
).getLength(); // A...IV...ZZZ
64 #define SCNAV_MAXROW (MAXROWCOUNT)
66 //------------------------------------------------------------------------
68 void ScNavigatorDlg::ReleaseFocus()
70 SfxViewShell
* pCurSh
= SfxViewShell::Current();
74 Window
* pShellWnd
= pCurSh
->GetWindow();
76 pShellWnd
->GrabFocus();
80 //==================================================================
82 //==================================================================
84 ColumnEdit::ColumnEdit( ScNavigatorDlg
* pParent
, const ResId
& rResId
)
85 : SpinField ( pParent
, rResId
),
88 nKeyGroup ( KEYGROUP_ALPHA
)
90 SetMaxTextLen( SCNAV_COLDIGITS
); // 1...256...18278 or A...IV...ZZZ
93 //------------------------------------------------------------------------
95 ColumnEdit::~ColumnEdit()
99 //------------------------------------------------------------------------
101 long ColumnEdit::Notify( NotifyEvent
& rNEvt
)
103 long nHandled
= SpinField::Notify( rNEvt
);
105 sal_uInt16 nType
= rNEvt
.GetType();
106 if ( nType
== EVENT_KEYINPUT
)
108 const KeyEvent
* pKEvt
= rNEvt
.GetKeyEvent();
109 KeyCode aCode
= pKEvt
->GetKeyCode();
111 if ( !aCode
.IsMod1() && !aCode
.IsMod2() )
113 //! Eingabeueberpruefung (nur Zahlen oder nur Buchstaben, max 2 bzw 3 Stellen)
114 //! war vor VCL per nicht weitergeleitetem KeyInput
115 //! dafuer was neues ausdenken!!!
117 if ( aCode
.GetCode() == KEY_RETURN
)
119 ScNavigatorDlg::ReleaseFocus();
125 else if ( nType
== EVENT_LOSEFOCUS
) // LoseFocus wird bei VCL nicht gerufen
126 EvalText(); // nCol setzen
131 //------------------------------------------------------------------------
133 void ColumnEdit::LoseFocus()
139 //------------------------------------------------------------------------
141 void ColumnEdit::Up()
145 if ( nCol
<= SCNAV_MAXCOL
)
151 //------------------------------------------------------------------------
153 void ColumnEdit::Down()
159 //------------------------------------------------------------------------
161 void ColumnEdit::First()
164 SetText(OUString('A'));
167 //------------------------------------------------------------------------
169 void ColumnEdit::Last()
172 nCol
= NumToAlpha( SCNAV_MAXCOL
, aStr
);
177 //------------------------------------------------------------------------
179 void ColumnEdit::EvalText()
181 OUString aStrCol
= GetText();
183 if (!aStrCol
.isEmpty())
185 // nKeyGroup wird bei VCL mangels KeyInput nicht mehr gesetzt
187 if ( CharClass::isAsciiNumeric(aStrCol
) )
188 nCol
= NumStrToAlpha( aStrCol
);
190 nCol
= AlphaToNum( aStrCol
);
196 nKeyGroup
= KEYGROUP_ALPHA
;
199 //------------------------------------------------------------------------
201 void ColumnEdit::ExecuteCol()
203 SCROW nRow
= rDlg
.aEdRow
.GetRow();
205 EvalText(); // setzt nCol
207 if ( (nCol
> 0) && (nRow
> 0) )
208 rDlg
.SetCurrentCell( nCol
-1, nRow
-1 );
211 //------------------------------------------------------------------------
213 void ColumnEdit::SetCol( SCCOL nColNo
)
224 nColNo
= NumToAlpha( nColNo
, aStr
);
230 //------------------------------------------------------------------------
232 SCCOL
ColumnEdit::AlphaToNum( OUString
& rStr
)
236 if ( CharClass::isAsciiAlpha( rStr
) )
238 rStr
= rStr
.toAsciiUpperCase();
240 if (::AlphaToCol( nColumn
, rStr
))
243 if ( (rStr
.getLength() > SCNAV_COLLETTERS
) || (nColumn
> SCNAV_MAXCOL
) )
245 nColumn
= SCNAV_MAXCOL
;
246 NumToAlpha( nColumn
, rStr
);
255 //------------------------------------------------------------------------
257 SCCOL
ColumnEdit::NumStrToAlpha( OUString
& rStr
)
261 if ( CharClass::isAsciiNumeric(rStr
) )
262 nColumn
= NumToAlpha( (SCCOL
)rStr
.toInt32(), rStr
);
269 //------------------------------------------------------------------------
271 SCCOL
ColumnEdit::NumToAlpha( SCCOL nColNo
, OUString
& rStr
)
273 if ( nColNo
> SCNAV_MAXCOL
)
274 nColNo
= SCNAV_MAXCOL
;
275 else if ( nColNo
< 1 )
278 ::ScColToAlpha( rStr
, nColNo
- 1);
283 //==================================================================
285 //==================================================================
287 RowEdit::RowEdit( ScNavigatorDlg
* pParent
, const ResId
& rResId
)
288 : NumericField( pParent
, rResId
),
291 SetMax( SCNAV_MAXROW
);
292 SetLast( SCNAV_MAXROW
);
295 //------------------------------------------------------------------------
301 //------------------------------------------------------------------------
303 long RowEdit::Notify( NotifyEvent
& rNEvt
)
305 long nHandled
= NumericField::Notify( rNEvt
);
307 if ( rNEvt
.GetType() == EVENT_KEYINPUT
)
309 const KeyEvent
* pKEvt
= rNEvt
.GetKeyEvent();
310 KeyCode aCode
= pKEvt
->GetKeyCode();
311 if ( aCode
.GetCode() == KEY_RETURN
&& !aCode
.IsMod1() && !aCode
.IsMod2() )
313 ScNavigatorDlg::ReleaseFocus();
322 //------------------------------------------------------------------------
324 void RowEdit::LoseFocus()
328 //------------------------------------------------------------------------
330 void RowEdit::ExecuteRow()
332 SCCOL nCol
= rDlg
.aEdCol
.GetCol();
333 SCROW nRow
= (SCROW
)GetValue();
335 if ( (nCol
> 0) && (nRow
> 0) )
336 rDlg
.SetCurrentCell( nCol
-1, nRow
-1 );
339 //==================================================================
340 // class ScDocListBox
341 //==================================================================
343 ScDocListBox::ScDocListBox( ScNavigatorDlg
* pParent
, const ResId
& rResId
)
344 : ListBox ( pParent
, rResId
),
349 //------------------------------------------------------------------------
351 ScDocListBox::~ScDocListBox()
355 //------------------------------------------------------------------------
357 void ScDocListBox::Select()
359 ScNavigatorDlg::ReleaseFocus();
361 OUString aDocName
= GetSelectEntry();
362 rDlg
.aLbEntries
.SelectDoc( aDocName
);
365 //==================================================================
366 // class CommandToolBox
367 //==================================================================
369 CommandToolBox::CommandToolBox( ScNavigatorDlg
* pParent
, const ResId
& rResId
)
370 : ToolBox ( pParent
, rResId
),
373 InitImageList(); // ImageList members of ScNavigatorDlg must be initialized before!
375 SetSizePixel( CalcWindowSizePixel() );
376 SetDropdownClickHdl( LINK(this, CommandToolBox
, ToolBoxDropdownClickHdl
) );
377 SetItemBits( IID_DROPMODE
, GetItemBits( IID_DROPMODE
) | TIB_DROPDOWNONLY
);
380 //------------------------------------------------------------------------
382 CommandToolBox::~CommandToolBox()
386 //------------------------------------------------------------------------
388 void CommandToolBox::Select( sal_uInt16 nSelId
)
390 // Modus umschalten ?
392 if ( nSelId
== IID_ZOOMOUT
|| nSelId
== IID_SCENARIOS
)
394 NavListMode eOldMode
= rDlg
.eListMode
;
395 NavListMode eNewMode
= eOldMode
;
397 if ( nSelId
== IID_SCENARIOS
) // auf Szenario
399 if ( eOldMode
== NAV_LMODE_SCENARIOS
)
400 eNewMode
= NAV_LMODE_AREAS
;
402 eNewMode
= NAV_LMODE_SCENARIOS
;
406 if ( eOldMode
== NAV_LMODE_NONE
)
407 eNewMode
= NAV_LMODE_AREAS
;
409 eNewMode
= NAV_LMODE_NONE
;
411 rDlg
.SetListMode( eNewMode
);
421 rDlg
.StartOfDataArea();
424 rDlg
.EndOfDataArea();
427 rDlg
.aLbEntries
.ToggleRoot();
433 void CommandToolBox::Select()
435 Select( GetCurItemId() );
438 //------------------------------------------------------------------------
440 void CommandToolBox::Click()
444 //------------------------------------------------------------------------
446 IMPL_LINK_NOARG(CommandToolBox
, ToolBoxDropdownClickHdl
)
448 // Das Popupmenue fuer den Dropmodus muss im Click (Button Down)
449 // statt im Select (Button Up) aufgerufen werden.
451 if ( GetCurItemId() == IID_DROPMODE
)
453 ScPopupMenu
aPop( ScResId( RID_POPUP_DROPMODE
) );
454 aPop
.CheckItem( RID_DROPMODE_URL
+ rDlg
.GetDropMode() );
455 aPop
.Execute( this, GetItemRect(IID_DROPMODE
), POPUPMENU_EXECUTE_DOWN
);
456 sal_uInt16 nId
= aPop
.GetSelected();
458 EndSelection(); // vor SetDropMode (SetDropMode ruft SetItemImage)
460 if ( nId
>= RID_DROPMODE_URL
&& nId
<= RID_DROPMODE_COPY
)
461 rDlg
.SetDropMode( nId
- RID_DROPMODE_URL
);
463 // den gehighlighteten Button aufheben
465 MouseEvent
aLeave( aPoint
, 0, MOUSE_LEAVEWINDOW
| MOUSE_SYNTHETIC
);
472 //------------------------------------------------------------------------
474 void CommandToolBox::UpdateButtons()
476 NavListMode eMode
= rDlg
.eListMode
;
477 CheckItem( IID_SCENARIOS
, eMode
== NAV_LMODE_SCENARIOS
);
478 CheckItem( IID_ZOOMOUT
, eMode
!= NAV_LMODE_NONE
);
480 // Umschalten-Button:
481 if ( eMode
== NAV_LMODE_SCENARIOS
|| eMode
== NAV_LMODE_NONE
)
483 EnableItem( IID_CHANGEROOT
, false );
484 CheckItem( IID_CHANGEROOT
, false );
488 EnableItem( IID_CHANGEROOT
, sal_True
);
489 sal_Bool bRootSet
= rDlg
.aLbEntries
.GetRootType() != SC_CONTENT_ROOT
;
490 CheckItem( IID_CHANGEROOT
, bRootSet
);
493 sal_uInt16 nImageId
= 0;
494 switch ( rDlg
.nDropMode
)
496 case SC_DROPMODE_URL
: nImageId
= RID_IMG_DROP_URL
; break;
497 case SC_DROPMODE_LINK
: nImageId
= RID_IMG_DROP_LINK
; break;
498 case SC_DROPMODE_COPY
: nImageId
= RID_IMG_DROP_COPY
; break;
500 SetItemImage( IID_DROPMODE
, Image(ScResId(nImageId
)) );
503 void CommandToolBox::InitImageList()
505 ImageList
& rImgLst
= rDlg
.aCmdImageList
;
507 sal_uInt16 nCount
= GetItemCount();
508 for (sal_uInt16 i
= 0; i
< nCount
; i
++)
510 sal_uInt16 nId
= GetItemId(i
);
511 SetItemImage( nId
, rImgLst
.GetImage( nId
) );
515 void CommandToolBox::DataChanged( const DataChangedEvent
& rDCEvt
)
517 if ( rDCEvt
.GetType() == DATACHANGED_SETTINGS
&& (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
519 // update item images
522 UpdateButtons(); // drop mode
525 ToolBox::DataChanged( rDCEvt
);
528 //==================================================================
529 // class ScNavigatorSettings
530 //==================================================================
532 ScNavigatorSettings::ScNavigatorSettings() :
533 maExpandedVec( SC_CONTENT_COUNT
, false ),
534 mnRootSelected( SC_CONTENT_ROOT
),
535 mnChildSelected( SC_CONTENT_NOCHILD
)
539 //==================================================================
540 // class ScNavigatorDlgWrapper
541 //==================================================================
543 SFX_IMPL_CHILDWINDOWCONTEXT( ScNavigatorDialogWrapper
, SID_NAVIGATOR
)
545 ScNavigatorDialogWrapper::ScNavigatorDialogWrapper(
549 SfxChildWinInfo
* /* pInfo */ ) :
550 SfxChildWindowContext( nId
)
552 pNavigator
= new ScNavigatorDlg( pBind
, this, pParent
, true );
553 SetWindow( pNavigator
);
555 // Einstellungen muessen anderswo gemerkt werden,
556 // pInfo geht uns (ausser der Groesse) nichts mehr an
558 Size aInfoSize
= pParent
->GetOutputSizePixel(); // von aussen vorgegebene Groesse
559 Size aNavSize
= pNavigator
->GetOutputSizePixel(); // Default-Groesse
561 aNavSize
.Width() = std::max( aInfoSize
.Width(), aNavSize
.Width() );
562 aNavSize
.Height() = std::max( aInfoSize
.Height(), aNavSize
.Height() );
563 pNavigator
->nListModeHeight
= std::max( aNavSize
.Height(), pNavigator
->nListModeHeight
);
565 // Die Groesse kann in einem anderen Modul geaendert worden sein,
566 // deshalb muessen in Abhaengigkeit von der momentanen Groesse die
567 // Inhalte eingeblendet werden oder nicht
569 sal_Bool bSmall
= ( aInfoSize
.Height() <= pNavigator
->aInitSize
.Height() + SCNAV_MINTOL
);
570 NavListMode eNavMode
= NAV_LMODE_NONE
;
573 // wenn Szenario aktiv war, wieder einschalten
575 ScNavipiCfg
& rCfg
= SC_MOD()->GetNavipiCfg();
576 NavListMode eLastMode
= (NavListMode
) rCfg
.GetListMode();
577 if ( eLastMode
== NAV_LMODE_SCENARIOS
)
578 eNavMode
= NAV_LMODE_SCENARIOS
;
580 eNavMode
= NAV_LMODE_AREAS
;
583 // Die Groesse des Floats nicht neu setzen (sal_False bei SetListMode), damit der
584 // Navigator nicht aufgeklappt wird, wenn er minimiert war (#38872#).
586 pNavigator
->SetListMode( eNavMode
, false ); // FALSE: Groesse des Float nicht setzen
591 case NAV_LMODE_DOCS
: nCmdId
= IID_DOCS
; break;
592 case NAV_LMODE_AREAS
: nCmdId
= IID_AREAS
; break;
593 case NAV_LMODE_DBAREAS
: nCmdId
= IID_DBAREAS
; break;
594 case NAV_LMODE_SCENARIOS
: nCmdId
= IID_SCENARIOS
; break;
599 pNavigator
->aTbxCmd
.CheckItem( nCmdId
);
600 pNavigator
->DoResize();
603 pNavigator
->bFirstBig
= ( nCmdId
== 0 ); // dann spaeter
606 void ScNavigatorDialogWrapper::Resizing( Size
& rSize
)
608 ((ScNavigatorDlg
*)GetWindow())->Resizing(rSize
);
611 //========================================================================
612 // class ScNavigatorPI
613 //========================================================================
617 #define REGISTER_SLOT(i,id) \
618 ppBoundItems[i]=new ScNavigatorControllerItem(id,*this,rBindings);
620 ScNavigatorDlg::ScNavigatorDlg( SfxBindings
* pB
, SfxChildWindowContext
* pCW
, Window
* pParent
,
621 const bool bUseStyleSettingsBackground
) :
622 Window( pParent
, ScResId(RID_SCDLG_NAVIGATOR
) ),
623 rBindings ( *pB
), // is used in CommandToolBox ctor
624 aCmdImageList( ScResId( IL_CMD
) ),
625 aFtCol ( this, ScResId( FT_COL
) ),
626 aEdCol ( this, ScResId( ED_COL
) ),
627 aFtRow ( this, ScResId( FT_ROW
) ),
628 aEdRow ( this, ScResId( ED_ROW
) ),
629 aTbxCmd ( this, ScResId( TBX_CMD
) ),
630 aLbEntries ( this, ScResId( LB_ENTRIES
) ),
631 aWndScenarios( this,ScResId( STR_QHLP_SCEN_LISTBOX
), ScResId(STR_QHLP_SCEN_COMMENT
)),
632 aLbDocuments( this, ScResId( LB_DOCUMENTS
) ),
633 aStrDragMode ( ScResId( STR_DRAGMODE
) ),
634 aStrDisplay ( ScResId( STR_DISPLAY
) ),
635 aStrActiveWin( ScResId( STR_ACTIVEWIN
) ),
639 nListModeHeight( 0 ),
640 nInitListHeight( 0 ),
641 eListMode ( NAV_LMODE_NONE
),
642 nDropMode ( SC_DROPMODE_URL
),
647 mbUseStyleSettingsBackground(bUseStyleSettingsBackground
)
649 ScNavipiCfg
& rCfg
= SC_MOD()->GetNavipiCfg();
650 nDropMode
= rCfg
.GetDragMode();
651 // eListMode wird von aussen gesetzt, Root weiter unten
653 aLbDocuments
.SetDropDownLineCount(9);
654 OUString
aOpen(" (");
656 aStrActive
+= OUString( ScResId( STR_ACTIVE
) );
657 aStrActive
+= ")"; // " (aktiv)"
658 aStrNotActive
= aOpen
;
659 aStrNotActive
+= OUString( ScResId( STR_NOTACTIVE
) );
660 aStrNotActive
+= ")"; // " (inaktiv)"
662 aStrHidden
+= OUString( ScResId( STR_HIDDEN
) );
663 aStrHidden
+= ")"; // " (versteckt)"
665 aTitleBase
= GetText();
667 const long nListboxYPos
=
669 (aTbxCmd
.GetPosPixel().Y() + aTbxCmd
.GetSizePixel().Height()),
670 (aEdRow
.GetPosPixel().Y() + aEdRow
.GetSizePixel().Height()) )
672 aLbEntries
.setPosSizePixel( 0, nListboxYPos
, 0, 0, WINDOW_POSSIZE_Y
);
674 nBorderOffset
= aLbEntries
.GetPosPixel().X();
676 aInitSize
.Width() = aTbxCmd
.GetPosPixel().X()
677 + aTbxCmd
.GetSizePixel().Width()
679 aInitSize
.Height() = aLbEntries
.GetPosPixel().Y();
681 nInitListHeight
= aLbEntries
.GetSizePixel().Height();
682 nListModeHeight
= aInitSize
.Height()
685 ppBoundItems
= new ScNavigatorControllerItem
* [CTRL_ITEMS
];
687 rBindings
.ENTERREGISTRATIONS();
688 //-----------------------------
689 REGISTER_SLOT( 0, SID_CURRENTCELL
);
690 REGISTER_SLOT( 1, SID_CURRENTTAB
);
691 REGISTER_SLOT( 2, SID_CURRENTDOC
);
692 REGISTER_SLOT( 3, SID_SELECT_SCENARIO
);
693 //-----------------------------
694 rBindings
.LEAVEREGISTRATIONS();
696 StartListening( *(SFX_APP()) );
697 StartListening( rBindings
);
699 aLbDocuments
.Hide(); // bei NAV_LMODE_NONE gibts die nicht
701 aLbEntries
.InitWindowBits(sal_True
);
703 aLbEntries
.SetSpaceBetweenEntries(0);
704 aLbEntries
.SetSelectionMode( SINGLE_SELECTION
);
705 aLbEntries
.SetDragDropMode( SV_DRAGDROP_CTRL_MOVE
|
706 SV_DRAGDROP_CTRL_COPY
|
707 SV_DRAGDROP_ENABLE_TOP
);
709 // war eine Kategorie als Root ausgewaehlt?
710 sal_uInt16 nLastRoot
= rCfg
.GetRootType();
712 aLbEntries
.SetRootType( nLastRoot
);
714 aLbEntries
.Refresh();
717 aTbxCmd
.UpdateButtons();
723 aWndScenarios
.Hide();
724 aWndScenarios
.SetPosPixel( aLbEntries
.GetPosPixel() );
726 aContentTimer
.SetTimeoutHdl( LINK( this, ScNavigatorDlg
, TimeHdl
) );
727 aContentTimer
.SetTimeout( SC_CONTENT_TIMEOUT
);
731 aLbEntries
.SetAccessibleRelationLabeledBy(&aLbEntries
);
732 aTbxCmd
.SetAccessibleRelationLabeledBy(&aTbxCmd
);
733 aLbDocuments
.SetAccessibleName(aStrActiveWin
);
735 if (pContextWin
== NULL
)
737 // When the context window is missing then the navigator is
738 // displayed in the sidebar and has the whole deck to fill.
739 // Therefore hide the button that hides all controls below the
740 // top two rows of buttons.
741 aTbxCmd
.Select(IID_ZOOMOUT
);
742 aTbxCmd
.RemoveItem(aTbxCmd
.GetItemPos(IID_ZOOMOUT
));
746 //------------------------------------------------------------------------
748 ScNavigatorDlg::~ScNavigatorDlg()
750 aContentTimer
.Stop();
753 for ( i
=0; i
<CTRL_ITEMS
; i
++ )
754 delete ppBoundItems
[i
];
756 delete [] ppBoundItems
;
759 EndListening( *(SFX_APP()) );
760 EndListening( rBindings
);
763 //------------------------------------------------------------------------
765 void ScNavigatorDlg::Resizing( Size
& rNewSize
) // Size = Outputsize?
767 FloatingWindow
* pFloat
= pContextWin
!=NULL
? pContextWin
->GetFloatingWindow() : NULL
;
770 Size aMinOut
= pFloat
->GetMinOutputSizePixel();
772 if ( rNewSize
.Width() < aMinOut
.Width() )
773 rNewSize
.Width() = aMinOut
.Width();
775 if ( eListMode
== NAV_LMODE_NONE
)
776 rNewSize
.Height() = aInitSize
.Height();
779 if ( rNewSize
.Height() < aMinOut
.Height() )
780 rNewSize
.Height() = aMinOut
.Height();
787 void ScNavigatorDlg::Paint( const Rectangle
& rRect
)
789 if (mbUseStyleSettingsBackground
)
791 const StyleSettings
& rStyleSettings
= Application::GetSettings().GetStyleSettings();
792 Color aBgColor
= rStyleSettings
.GetFaceColor();
793 Wallpaper
aBack( aBgColor
);
795 SetBackground( aBack
);
796 aFtCol
.SetBackground( aBack
);
797 aFtRow
.SetBackground( aBack
);
801 aFtCol
.SetBackground(Wallpaper());
802 aFtRow
.SetBackground(Wallpaper());
805 Window::Paint( rRect
);
808 void ScNavigatorDlg::DataChanged( const DataChangedEvent
& rDCEvt
)
810 if ( rDCEvt
.GetType() == DATACHANGED_SETTINGS
&& (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
812 // toolbox images are exchanged in CommandToolBox::DataChanged
816 Window::DataChanged( rDCEvt
);
819 //------------------------------------------------------------------------
821 void ScNavigatorDlg::Resize()
826 //------------------------------------------------------------------------
828 void ScNavigatorDlg::DoResize()
830 Size aNewSize
= GetOutputSizePixel();
831 long nTotalHeight
= aNewSize
.Height();
833 // bei angedocktem Navigator wird das Fenster evtl. erst klein erzeugt,
834 // dann kommt ein Resize auf die wirkliche Groesse -> dann Inhalte einschalten
836 sal_Bool bSmall
= ( nTotalHeight
<= aInitSize
.Height() + SCNAV_MINTOL
);
837 if ( !bSmall
&& bFirstBig
)
839 // Inhalte laut Config wieder einschalten
842 NavListMode eNavMode
= NAV_LMODE_AREAS
;
843 ScNavipiCfg
& rCfg
= SC_MOD()->GetNavipiCfg();
844 NavListMode eLastMode
= (NavListMode
) rCfg
.GetListMode();
845 if ( eLastMode
== NAV_LMODE_SCENARIOS
)
846 eNavMode
= NAV_LMODE_SCENARIOS
;
847 SetListMode( eNavMode
, false ); // FALSE: Groesse des Float nicht setzen
850 // auch wenn die Inhalte nicht sichtbar sind, die Groessen anpassen,
851 // damit die Breite stimmt
853 Point aEntryPos
= aLbEntries
.GetPosPixel();
854 Point aListPos
= aLbDocuments
.GetPosPixel();
855 aNewSize
.Width() -= 2*nBorderOffset
;
856 Size aDocSize
= aLbDocuments
.GetSizePixel();
857 aDocSize
.Width() = aNewSize
.Width();
862 long nListHeight
= aLbDocuments
.GetSizePixel().Height();
863 aNewSize
.Height() -= ( aEntryPos
.Y() + nListHeight
+ 2*nBorderOffset
);
864 if(aNewSize
.Height()<0) aNewSize
.Height()=0;
866 aListPos
.Y() = aEntryPos
.Y() + aNewSize
.Height() + nBorderOffset
;
868 if(aListPos
.Y() > aLbEntries
.GetPosPixel().Y())
869 aLbDocuments
.SetPosPixel( aListPos
);
872 aLbEntries
.SetSizePixel( aNewSize
);
873 aWndScenarios
.SetSizePixel( aNewSize
);
874 aLbDocuments
.SetSizePixel( aDocSize
);
876 sal_Bool bListMode
= (eListMode
!= NAV_LMODE_NONE
);
877 if (pContextWin
!= NULL
)
879 FloatingWindow
* pFloat
= pContextWin
->GetFloatingWindow();
880 if ( pFloat
&& bListMode
)
881 nListModeHeight
= nTotalHeight
;
885 //------------------------------------------------------------------------
887 void ScNavigatorDlg::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
889 if ( rHint
.ISA(SfxSimpleHint
) )
891 sal_uLong nHintId
= ((SfxSimpleHint
&)rHint
).GetId();
893 if ( nHintId
== SC_HINT_DOCNAME_CHANGED
)
895 aLbEntries
.ActiveDocChanged();
897 else if ( NAV_LMODE_NONE
== eListMode
)
899 // Tabellen hier nicht mehr
905 case SC_HINT_TABLES_CHANGED
:
906 aLbEntries
.Refresh( SC_CONTENT_TABLE
);
909 case SC_HINT_DBAREAS_CHANGED
:
910 aLbEntries
.Refresh( SC_CONTENT_DBAREA
);
913 case SC_HINT_AREAS_CHANGED
:
914 aLbEntries
.Refresh( SC_CONTENT_RANGENAME
);
917 case SC_HINT_DRAW_CHANGED
:
918 aLbEntries
.Refresh( SC_CONTENT_GRAPHIC
);
919 aLbEntries
.Refresh( SC_CONTENT_OLEOBJECT
);
920 aLbEntries
.Refresh( SC_CONTENT_DRAWING
);
923 case SC_HINT_AREALINKS_CHANGED
:
924 aLbEntries
.Refresh( SC_CONTENT_AREALINK
);
927 // SFX_HINT_DOCCHANGED kommt nicht nur bei Dokument-Wechsel
929 case SC_HINT_NAVIGATOR_UPDATEALL
:
933 case FID_DATACHANGED
:
934 case FID_ANYDATACHANGED
:
935 aContentTimer
.Start(); // Notizen nicht sofort suchen
943 else if ( rHint
.ISA(SfxEventHint
) )
945 sal_uLong nEventId
= ((SfxEventHint
&)rHint
).GetEventId();
946 if ( nEventId
== SFX_EVENT_ACTIVATEDOC
)
948 aLbEntries
.ActiveDocChanged();
954 //------------------------------------------------------------------------
956 IMPL_LINK( ScNavigatorDlg
, TimeHdl
, Timer
*, pTimer
)
958 if ( pTimer
!= &aContentTimer
)
961 aLbEntries
.Refresh( SC_CONTENT_NOTE
);
965 //------------------------------------------------------------------------
967 void ScNavigatorDlg::SetDropMode(sal_uInt16 nNew
)
970 aTbxCmd
.UpdateButtons();
972 ScNavipiCfg
& rCfg
= SC_MOD()->GetNavipiCfg();
973 rCfg
.SetDragMode(nDropMode
);
976 //------------------------------------------------------------------------
978 void ScNavigatorDlg::CursorPosChanged()
980 //! Eintraege selektieren ???
982 // if ( GetDBAtCursor( aStrDbName ) )
983 // if ( GetAreaAtCursor( aStrAreaName ) )
986 //------------------------------------------------------------------------
988 void ScNavigatorDlg::SetCurrentCell( SCCOL nColNo
, SCROW nRowNo
)
990 if ( (nColNo
+1 != nCurCol
) || (nRowNo
+1 != nCurRow
) )
992 // SID_CURRENTCELL == Item #0 Cache leeren, damit das Setzen der
993 // aktuellen Zelle auch in zusammengefassten Bereichen funktioniert.
994 ppBoundItems
[0]->ClearCache();
996 ScAddress
aScAddress( nColNo
, nRowNo
, 0 );
997 OUString
aAddr(aScAddress
.Format(SCA_ABS
));
999 sal_Bool bUnmark
= false;
1000 if ( GetViewData() )
1001 bUnmark
= !pViewData
->GetMarkData().IsCellMarked( nColNo
, nRowNo
);
1003 SfxStringItem
aPosItem( SID_CURRENTCELL
, aAddr
);
1004 SfxBoolItem
aUnmarkItem( FN_PARAM_1
, bUnmark
); // ggf. Selektion aufheben
1006 rBindings
.GetDispatcher()->Execute( SID_CURRENTCELL
,
1007 SFX_CALLMODE_SYNCHRON
| SFX_CALLMODE_RECORD
,
1008 &aPosItem
, &aUnmarkItem
, 0L );
1012 void ScNavigatorDlg::SetCurrentCellStr( const OUString rName
)
1014 ppBoundItems
[0]->ClearCache();
1015 SfxStringItem
aNameItem( SID_CURRENTCELL
, rName
);
1017 rBindings
.GetDispatcher()->Execute( SID_CURRENTCELL
,
1018 SFX_CALLMODE_SYNCHRON
| SFX_CALLMODE_RECORD
,
1022 //------------------------------------------------------------------------
1024 void ScNavigatorDlg::SetCurrentTable( SCTAB nTabNo
)
1026 if ( nTabNo
!= nCurTab
)
1028 // Tabelle fuer Basic ist 1-basiert
1029 SfxUInt16Item
aTabItem( SID_CURRENTTAB
, static_cast<sal_uInt16
>(nTabNo
) + 1 );
1030 rBindings
.GetDispatcher()->Execute( SID_CURRENTTAB
,
1031 SFX_CALLMODE_SYNCHRON
| SFX_CALLMODE_RECORD
,
1036 void ScNavigatorDlg::SetCurrentTableStr( const OUString
& rName
)
1038 if (!GetViewData()) return;
1040 ScDocument
* pDoc
= pViewData
->GetDocument();
1041 SCTAB nCount
= pDoc
->GetTableCount();
1044 for ( SCTAB i
=0; i
<nCount
; i
++ )
1046 pDoc
->GetName( i
, aTabName
);
1047 if ( aTabName
.equals(rName
) )
1049 SetCurrentTable( i
);
1055 //------------------------------------------------------------------------
1057 void ScNavigatorDlg::SetCurrentObject( const OUString rName
)
1059 SfxStringItem
aNameItem( SID_CURRENTOBJECT
, rName
);
1060 rBindings
.GetDispatcher()->Execute( SID_CURRENTOBJECT
,
1061 SFX_CALLMODE_SYNCHRON
| SFX_CALLMODE_RECORD
,
1065 //------------------------------------------------------------------------
1067 void ScNavigatorDlg::SetCurrentDoc( const OUString
& rDocName
) // aktivieren
1069 SfxStringItem
aDocItem( SID_CURRENTDOC
, rDocName
);
1070 rBindings
.GetDispatcher()->Execute( SID_CURRENTDOC
,
1071 SFX_CALLMODE_SYNCHRON
| SFX_CALLMODE_RECORD
,
1075 //------------------------------------------------------------------------
1077 ScTabViewShell
* ScNavigatorDlg::GetTabViewShell() const
1079 return PTR_CAST( ScTabViewShell
, SfxViewShell::Current() );
1082 //------------------------------------------------------------------------
1084 ScNavigatorSettings
* ScNavigatorDlg::GetNavigatorSettings()
1086 // Don't store the settings pointer here, because the settings belong to
1087 // the view, and the view may be closed while the navigator is open (reload).
1088 // If the pointer is cached here again later for performance reasons, it has to
1089 // be forgotten when the view is closed.
1091 ScTabViewShell
* pViewSh
= GetTabViewShell();
1092 return pViewSh
? pViewSh
->GetNavigatorSettings() : NULL
;
1095 //------------------------------------------------------------------------
1097 sal_Bool
ScNavigatorDlg::GetViewData()
1099 ScTabViewShell
* pViewSh
= GetTabViewShell();
1100 pViewData
= pViewSh
? pViewSh
->GetViewData() : NULL
;
1102 return ( pViewData
!= NULL
);
1105 //------------------------------------------------------------------------
1107 void ScNavigatorDlg::UpdateColumn( const SCCOL
* pCol
)
1111 else if ( GetViewData() )
1112 nCurCol
= pViewData
->GetCurX() + 1;
1114 aEdCol
.SetCol( nCurCol
);
1118 //------------------------------------------------------------------------
1120 void ScNavigatorDlg::UpdateRow( const SCROW
* pRow
)
1124 else if ( GetViewData() )
1125 nCurRow
= pViewData
->GetCurY() + 1;
1127 aEdRow
.SetRow( nCurRow
);
1131 //------------------------------------------------------------------------
1133 void ScNavigatorDlg::UpdateTable( const SCTAB
* pTab
)
1137 else if ( GetViewData() )
1138 nCurTab
= pViewData
->GetTabNo();
1143 //------------------------------------------------------------------------
1145 void ScNavigatorDlg::UpdateAll()
1147 switch ( eListMode
)
1149 case NAV_LMODE_DOCS
:
1150 case NAV_LMODE_DBAREAS
:
1151 case NAV_LMODE_AREAS
:
1152 aLbEntries
.Refresh();
1155 case NAV_LMODE_NONE
:
1163 aContentTimer
.Stop(); // dann nicht nochmal
1166 //------------------------------------------------------------------------
1168 void ScNavigatorDlg::SetListMode( NavListMode eMode
, sal_Bool bSetSize
)
1170 if ( eMode
!= eListMode
)
1172 if ( eMode
!= NAV_LMODE_NONE
)
1173 bFirstBig
= false; // nicht mehr automatisch umschalten
1179 case NAV_LMODE_NONE
:
1180 ShowList( false, bSetSize
);
1183 case NAV_LMODE_AREAS
:
1184 case NAV_LMODE_DBAREAS
:
1185 case NAV_LMODE_DOCS
:
1186 aLbEntries
.Refresh();
1187 ShowList( sal_True
, bSetSize
);
1190 case NAV_LMODE_SCENARIOS
:
1191 ShowScenarios( sal_True
, bSetSize
);
1195 aTbxCmd
.UpdateButtons();
1197 if ( eMode
!= NAV_LMODE_NONE
)
1199 ScNavipiCfg
& rCfg
= SC_MOD()->GetNavipiCfg();
1200 rCfg
.SetListMode( (sal_uInt16
) eMode
);
1208 //------------------------------------------------------------------------
1210 void ScNavigatorDlg::ShowList( sal_Bool bShow
, sal_Bool bSetSize
)
1212 FloatingWindow
* pFloat
= pContextWin
!=NULL
? pContextWin
->GetFloatingWindow() : NULL
;
1213 Size aSize
= GetParent()->GetOutputSizePixel();
1217 Size aMinSize
= aInitSize
;
1219 aMinSize
.Height() += nInitListHeight
;
1221 pFloat
->SetMinOutputSizePixel( aMinSize
);
1222 aSize
.Height() = nListModeHeight
;
1224 aLbDocuments
.Show();
1230 pFloat
->SetMinOutputSizePixel( aInitSize
);
1231 nListModeHeight
= aSize
.Height();
1233 aSize
.Height() = aInitSize
.Height();
1235 aLbDocuments
.Hide();
1237 aWndScenarios
.Hide();
1242 pFloat
->SetOutputSizePixel( aSize
);
1246 SfxNavigator
* pNav
= dynamic_cast<SfxNavigator
*>(GetParent());
1249 Size aFloating
= pNav
->GetFloatingSize();
1250 aFloating
.Height() = aSize
.Height();
1251 pNav
->SetFloatingSize( aFloating
);
1256 //------------------------------------------------------------------------
1258 void ScNavigatorDlg::ShowScenarios( sal_Bool bShow
, sal_Bool bSetSize
)
1260 FloatingWindow
* pFloat
= pContextWin
!=NULL
? pContextWin
->GetFloatingWindow() : NULL
;
1261 Size aSize
= GetParent()->GetOutputSizePixel();
1265 Size aMinSize
= aInitSize
;
1266 aMinSize
.Height() += nInitListHeight
;
1268 pFloat
->SetMinOutputSizePixel( aMinSize
);
1269 aSize
.Height() = nListModeHeight
;
1271 rBindings
.Invalidate( SID_SELECT_SCENARIO
);
1272 rBindings
.Update( SID_SELECT_SCENARIO
);
1274 aWndScenarios
.Show();
1275 aLbDocuments
.Show();
1281 pFloat
->SetMinOutputSizePixel( aInitSize
);
1282 nListModeHeight
= aSize
.Height();
1284 aSize
.Height() = aInitSize
.Height();
1285 aWndScenarios
.Hide();
1286 aLbDocuments
.Hide();
1293 pFloat
->SetOutputSizePixel( aSize
);
1297 SfxNavigator
* pNav
= (SfxNavigator
*)GetParent();
1298 Size aFloating
= pNav
->GetFloatingSize();
1299 aFloating
.Height() = aSize
.Height();
1300 pNav
->SetFloatingSize( aFloating
);
1305 //------------------------------------------------------------------------
1307 // Dokumente fuer Dropdown-Listbox
1309 //------------------------------------------------------------------------
1311 void ScNavigatorDlg::GetDocNames( const OUString
* pManualSel
)
1313 aLbDocuments
.Clear();
1314 aLbDocuments
.SetUpdateMode( false );
1316 ScDocShell
* pCurrentSh
= PTR_CAST( ScDocShell
, SfxObjectShell::Current() );
1319 SfxObjectShell
* pSh
= SfxObjectShell::GetFirst();
1322 if ( pSh
->ISA(ScDocShell
) )
1324 OUString aName
= pSh
->GetTitle();
1325 OUString aEntry
= aName
;
1326 if (pSh
== pCurrentSh
)
1327 aEntry
+= aStrActive
;
1329 aEntry
+= aStrNotActive
;
1330 aLbDocuments
.InsertEntry( aEntry
);
1332 if ( pManualSel
? ( aName
== *pManualSel
)
1333 : ( pSh
== pCurrentSh
) )
1334 aSelEntry
= aEntry
; // kompletter Eintrag zum Selektieren
1337 pSh
= SfxObjectShell::GetNext( *pSh
);
1340 aLbDocuments
.InsertEntry( aStrActiveWin
);
1342 OUString aHidden
= aLbEntries
.GetHiddenTitle();
1343 if (!aHidden
.isEmpty())
1345 OUString aEntry
= aHidden
;
1346 aEntry
+= aStrHidden
;
1347 aLbDocuments
.InsertEntry( aEntry
);
1349 if ( pManualSel
&& aHidden
== *pManualSel
)
1353 aLbDocuments
.SetUpdateMode( sal_True
);
1355 aLbDocuments
.SelectEntry( aSelEntry
);
1358 //------------------------------------------------------------------------
1360 void ScNavigatorDlg::MarkDataArea()
1362 ScTabViewShell
* pViewSh
= GetTabViewShell();
1367 pMarkArea
= new ScArea
;
1369 pViewSh
->MarkDataArea();
1371 pViewSh
->GetViewData()->GetMarkData().GetMarkArea(aMarkRange
);
1372 pMarkArea
->nColStart
= aMarkRange
.aStart
.Col();
1373 pMarkArea
->nRowStart
= aMarkRange
.aStart
.Row();
1374 pMarkArea
->nColEnd
= aMarkRange
.aEnd
.Col();
1375 pMarkArea
->nRowEnd
= aMarkRange
.aEnd
.Row();
1376 pMarkArea
->nTab
= aMarkRange
.aStart
.Tab();
1380 //------------------------------------------------------------------------
1382 void ScNavigatorDlg::UnmarkDataArea()
1384 ScTabViewShell
* pViewSh
= GetTabViewShell();
1389 DELETEZ( pMarkArea
);
1393 //------------------------------------------------------------------------
1395 void ScNavigatorDlg::CheckDataArea()
1397 if ( aTbxCmd
.IsItemChecked( IID_DATA
) && pMarkArea
)
1399 if ( nCurTab
!= pMarkArea
->nTab
1400 || nCurCol
< pMarkArea
->nColStart
+1
1401 || nCurCol
> pMarkArea
->nColEnd
+1
1402 || nCurRow
< pMarkArea
->nRowStart
+1
1403 || nCurRow
> pMarkArea
->nRowEnd
+1 )
1405 aTbxCmd
.SetItemState( IID_DATA
, TriState(STATE_CHECK
) );
1406 aTbxCmd
.Select( IID_DATA
);
1411 //------------------------------------------------------------------------
1413 void ScNavigatorDlg::StartOfDataArea()
1415 // pMarkArea auswerten ???
1417 if ( GetViewData() )
1419 ScMarkData
& rMark
= pViewData
->GetMarkData();
1421 rMark
.GetMarkArea( aMarkRange
);
1423 SCCOL nCol
= aMarkRange
.aStart
.Col();
1424 SCROW nRow
= aMarkRange
.aStart
.Row();
1426 if ( (nCol
+1 != aEdCol
.GetCol()) || (nRow
+1 != aEdRow
.GetRow()) )
1427 SetCurrentCell( nCol
, nRow
);
1431 //------------------------------------------------------------------------
1433 void ScNavigatorDlg::EndOfDataArea()
1435 // pMarkArea auswerten ???
1437 if ( GetViewData() )
1439 ScMarkData
& rMark
= pViewData
->GetMarkData();
1441 rMark
.GetMarkArea( aMarkRange
);
1443 SCCOL nCol
= aMarkRange
.aEnd
.Col();
1444 SCROW nRow
= aMarkRange
.aEnd
.Row();
1446 if ( (nCol
+1 != aEdCol
.GetCol()) || (nRow
+1 != aEdRow
.GetRow()) )
1447 SetCurrentCell( nCol
, nRow
);
1451 //------------------------------------------------------------------------
1453 SfxChildAlignment
ScNavigatorDlg::CheckAlignment(
1454 SfxChildAlignment eActAlign
, SfxChildAlignment eAlign
)
1456 SfxChildAlignment eRetAlign
;
1458 //! kein Andocken, wenn Listbox nicht da ???
1463 case SFX_ALIGN_HIGHESTTOP
:
1464 case SFX_ALIGN_LOWESTTOP
:
1465 case SFX_ALIGN_BOTTOM
:
1466 case SFX_ALIGN_LOWESTBOTTOM
:
1467 case SFX_ALIGN_HIGHESTBOTTOM
:
1468 eRetAlign
= eActAlign
; // nicht erlaubt
1471 case SFX_ALIGN_LEFT
:
1472 case SFX_ALIGN_RIGHT
:
1473 case SFX_ALIGN_FIRSTLEFT
:
1474 case SFX_ALIGN_LASTLEFT
:
1475 case SFX_ALIGN_FIRSTRIGHT
:
1476 case SFX_ALIGN_LASTRIGHT
:
1477 eRetAlign
= eAlign
; // erlaubt
1487 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */