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 <vcl/settings.hxx>
30 #include <unotools/charclass.hxx>
33 #include "viewdata.hxx"
34 #include "tabvwsh.hxx"
36 #include "document.hxx"
38 #include "rangenam.hxx"
39 #include "rangeutl.hxx"
40 #include "popmenu.hxx"
41 #include "scresid.hxx"
43 #include "navicfg.hxx"
44 #include "navcitem.hxx"
47 #include "navsett.hxx"
48 #include "markdata.hxx"
52 // toleance, how much spac above the folded size is still small
53 #define SCNAV_MINTOL 5
55 // maximum values for UI
56 #define SCNAV_MAXCOL (MAXCOLCOUNT)
57 // macro is sufficient since only used in ctor
58 #define SCNAV_COLDIGITS (static_cast<sal_Int32>( floor( log10( static_cast<double>(SCNAV_MAXCOL)))) + 1) // 1...256...18278
59 // precomputed constant because it is used in every change of spin button field
60 static const sal_Int32 SCNAV_COLLETTERS
= ::ScColToAlpha(SCNAV_MAXCOL
).getLength(); // A...IV...ZZZ
62 #define SCNAV_MAXROW (MAXROWCOUNT)
64 void ScNavigatorDlg::ReleaseFocus()
66 SfxViewShell
* pCurSh
= SfxViewShell::Current();
70 vcl::Window
* pShellWnd
= pCurSh
->GetWindow();
72 pShellWnd
->GrabFocus();
78 ColumnEdit::ColumnEdit( ScNavigatorDlg
* pParent
, const ResId
& rResId
)
79 : SpinField ( pParent
, rResId
),
82 nKeyGroup ( KEYGROUP_ALPHA
)
84 SetMaxTextLen( SCNAV_COLDIGITS
); // 1...256...18278 or A...IV...ZZZ
87 ColumnEdit::~ColumnEdit()
91 bool ColumnEdit::Notify( NotifyEvent
& rNEvt
)
93 bool nHandled
= SpinField::Notify( rNEvt
);
95 MouseNotifyEvent nType
= rNEvt
.GetType();
96 if ( nType
== MouseNotifyEvent::KEYINPUT
)
98 const KeyEvent
* pKEvt
= rNEvt
.GetKeyEvent();
99 vcl::KeyCode aCode
= pKEvt
->GetKeyCode();
101 if ( !aCode
.IsMod1() && !aCode
.IsMod2() )
103 //! Input Validation (only alphanumerics, max 2-3 digits)
104 //! was before VCL not forwarded keyinput
107 if ( aCode
.GetCode() == KEY_RETURN
)
109 ScNavigatorDlg::ReleaseFocus();
115 else if ( nType
== MouseNotifyEvent::LOSEFOCUS
) // LoseFocus not called at VCL
116 EvalText(); // nCol set
121 void ColumnEdit::LoseFocus()
126 void ColumnEdit::Up()
130 if ( nCol
<= SCNAV_MAXCOL
)
136 void ColumnEdit::Down()
142 void ColumnEdit::First()
145 SetText(OUString('A'));
148 void ColumnEdit::Last()
151 nCol
= NumToAlpha( SCNAV_MAXCOL
, aStr
);
155 void ColumnEdit::EvalText()
157 OUString aStrCol
= GetText();
159 if (!aStrCol
.isEmpty())
161 // nKeyGroup is no longer set at VCL, in cause of lack of keyinput
163 if ( CharClass::isAsciiNumeric(aStrCol
) )
164 nCol
= NumStrToAlpha( aStrCol
);
166 nCol
= AlphaToNum( aStrCol
);
172 nKeyGroup
= KEYGROUP_ALPHA
;
175 void ColumnEdit::ExecuteCol()
177 SCROW nRow
= rDlg
.aEdRow
->GetRow();
179 EvalText(); // setzt nCol
181 if ( (nCol
> 0) && (nRow
> 0) )
182 rDlg
.SetCurrentCell( nCol
-1, nRow
-1 );
185 void ColumnEdit::SetCol( SCCOL nColNo
)
196 nColNo
= NumToAlpha( nColNo
, aStr
);
202 SCCOL
ColumnEdit::AlphaToNum( OUString
& rStr
)
206 if ( CharClass::isAsciiAlpha( rStr
) )
208 rStr
= rStr
.toAsciiUpperCase();
210 if (::AlphaToCol( nColumn
, rStr
))
213 if ( (rStr
.getLength() > SCNAV_COLLETTERS
) || (nColumn
> SCNAV_MAXCOL
) )
215 nColumn
= SCNAV_MAXCOL
;
216 NumToAlpha( nColumn
, rStr
);
225 SCCOL
ColumnEdit::NumStrToAlpha( OUString
& rStr
)
229 if ( CharClass::isAsciiNumeric(rStr
) )
230 nColumn
= NumToAlpha( (SCCOL
)rStr
.toInt32(), rStr
);
237 SCCOL
ColumnEdit::NumToAlpha( SCCOL nColNo
, OUString
& rStr
)
239 if ( nColNo
> SCNAV_MAXCOL
)
240 nColNo
= SCNAV_MAXCOL
;
241 else if ( nColNo
< 1 )
244 ::ScColToAlpha( rStr
, nColNo
- 1);
251 RowEdit::RowEdit( ScNavigatorDlg
* pParent
, const ResId
& rResId
)
252 : NumericField( pParent
, rResId
),
255 SetMax( SCNAV_MAXROW
);
256 SetLast( SCNAV_MAXROW
);
263 bool RowEdit::Notify( NotifyEvent
& rNEvt
)
265 bool nHandled
= NumericField::Notify( rNEvt
);
267 if ( rNEvt
.GetType() == MouseNotifyEvent::KEYINPUT
)
269 const KeyEvent
* pKEvt
= rNEvt
.GetKeyEvent();
270 vcl::KeyCode aCode
= pKEvt
->GetKeyCode();
271 if ( aCode
.GetCode() == KEY_RETURN
&& !aCode
.IsMod1() && !aCode
.IsMod2() )
273 ScNavigatorDlg::ReleaseFocus();
282 void RowEdit::LoseFocus()
286 void RowEdit::ExecuteRow()
288 SCCOL nCol
= rDlg
.aEdCol
->GetCol();
289 SCROW nRow
= (SCROW
)GetValue();
291 if ( (nCol
> 0) && (nRow
> 0) )
292 rDlg
.SetCurrentCell( nCol
-1, nRow
-1 );
295 // class ScDocListBox
297 ScDocListBox::ScDocListBox( ScNavigatorDlg
* pParent
, const ResId
& rResId
)
298 : ListBox ( pParent
, rResId
),
303 ScDocListBox::~ScDocListBox()
307 void ScDocListBox::Select()
309 ScNavigatorDlg::ReleaseFocus();
311 OUString aDocName
= GetSelectEntry();
312 rDlg
.aLbEntries
->SelectDoc( aDocName
);
315 // class CommandToolBox
317 CommandToolBox::CommandToolBox( ScNavigatorDlg
* pParent
, const ResId
& rResId
)
318 : ToolBox ( pParent
, rResId
),
321 InitImageList(); // ImageList members of ScNavigatorDlg must be initialized before!
323 SetSizePixel( CalcWindowSizePixel() );
324 SetDropdownClickHdl( LINK(this, CommandToolBox
, ToolBoxDropdownClickHdl
) );
325 SetItemBits( IID_DROPMODE
, GetItemBits( IID_DROPMODE
) | ToolBoxItemBits::DROPDOWNONLY
);
328 CommandToolBox::~CommandToolBox()
332 void CommandToolBox::Select( sal_uInt16 nSelId
)
334 // Modus umschalten ?
336 if ( nSelId
== IID_ZOOMOUT
|| nSelId
== IID_SCENARIOS
)
338 NavListMode eOldMode
= rDlg
.eListMode
;
339 NavListMode eNewMode
= eOldMode
;
341 if ( nSelId
== IID_SCENARIOS
)
343 if ( eOldMode
== NAV_LMODE_SCENARIOS
)
344 eNewMode
= NAV_LMODE_AREAS
;
346 eNewMode
= NAV_LMODE_SCENARIOS
;
350 if ( eOldMode
== NAV_LMODE_NONE
)
351 eNewMode
= NAV_LMODE_AREAS
;
353 eNewMode
= NAV_LMODE_NONE
;
355 rDlg
.SetListMode( eNewMode
);
365 rDlg
.StartOfDataArea();
368 rDlg
.EndOfDataArea();
371 rDlg
.aLbEntries
->ToggleRoot();
377 void CommandToolBox::Select()
379 Select( GetCurItemId() );
382 void CommandToolBox::Click()
386 IMPL_LINK_NOARG_TYPED(CommandToolBox
, ToolBoxDropdownClickHdl
, ToolBox
*, void)
388 // the popup menue of the drop modus has to be called in the
389 // click (button down) and not in the select (button up)
391 if ( GetCurItemId() == IID_DROPMODE
)
393 ScPopupMenu
aPop( ScResId( RID_POPUP_DROPMODE
) );
394 aPop
.CheckItem( RID_DROPMODE_URL
+ rDlg
.GetDropMode() );
395 aPop
.Execute( this, GetItemRect(IID_DROPMODE
), PopupMenuFlags::ExecuteDown
);
396 sal_uInt16 nId
= aPop
.GetSelected();
398 EndSelection(); // bevore SetDropMode (SetDropMode calls SetItemImage)
400 if ( nId
>= RID_DROPMODE_URL
&& nId
<= RID_DROPMODE_COPY
)
401 rDlg
.SetDropMode( nId
- RID_DROPMODE_URL
);
403 // reset the highlighted button
405 MouseEvent
aLeave( aPoint
, 0, MouseEventModifiers::LEAVEWINDOW
| MouseEventModifiers::SYNTHETIC
);
410 void CommandToolBox::UpdateButtons()
412 NavListMode eMode
= rDlg
.eListMode
;
413 CheckItem( IID_SCENARIOS
, eMode
== NAV_LMODE_SCENARIOS
);
414 CheckItem( IID_ZOOMOUT
, eMode
!= NAV_LMODE_NONE
);
416 // Umschalten-Button:
417 if ( eMode
== NAV_LMODE_SCENARIOS
|| eMode
== NAV_LMODE_NONE
)
419 EnableItem( IID_CHANGEROOT
, false );
420 CheckItem( IID_CHANGEROOT
, false );
424 EnableItem( IID_CHANGEROOT
, true );
425 bool bRootSet
= rDlg
.aLbEntries
->GetRootType() != SC_CONTENT_ROOT
;
426 CheckItem( IID_CHANGEROOT
, bRootSet
);
429 sal_uInt16 nImageId
= 0;
430 switch ( rDlg
.nDropMode
)
432 case SC_DROPMODE_URL
: nImageId
= RID_IMG_DROP_URL
; break;
433 case SC_DROPMODE_LINK
: nImageId
= RID_IMG_DROP_LINK
; break;
434 case SC_DROPMODE_COPY
: nImageId
= RID_IMG_DROP_COPY
; break;
436 SetItemImage( IID_DROPMODE
, Image(ScResId(nImageId
)) );
439 void CommandToolBox::InitImageList()
441 ImageList
& rImgLst
= rDlg
.aCmdImageList
;
443 sal_uInt16 nCount
= GetItemCount();
444 for (sal_uInt16 i
= 0; i
< nCount
; i
++)
446 sal_uInt16 nId
= GetItemId(i
);
447 SetItemImage( nId
, rImgLst
.GetImage( nId
) );
451 void CommandToolBox::DataChanged( const DataChangedEvent
& rDCEvt
)
453 if ( rDCEvt
.GetType() == DataChangedEventType::SETTINGS
&& (rDCEvt
.GetFlags() & AllSettingsFlags::STYLE
) )
455 // update item images
458 UpdateButtons(); // drop mode
461 ToolBox::DataChanged( rDCEvt
);
464 // class ScNavigatorSettings
466 ScNavigatorSettings::ScNavigatorSettings() :
467 maExpandedVec( SC_CONTENT_COUNT
, false ),
468 mnRootSelected( SC_CONTENT_ROOT
),
469 mnChildSelected( SC_CONTENT_NOCHILD
)
473 // class ScNavigatorDlgWrapper
475 SFX_IMPL_CHILDWINDOWCONTEXT( ScNavigatorDialogWrapper
, SID_NAVIGATOR
)
477 ScNavigatorDialogWrapper::ScNavigatorDialogWrapper(
478 vcl::Window
* pParent
,
481 SfxChildWinInfo
* /* pInfo */ ) :
482 SfxChildWindowContext( nId
)
484 pNavigator
= VclPtr
<ScNavigatorDlg
>::Create( pBind
, this, pParent
, true );
485 SetWindow( pNavigator
);
487 // handle configurations elsewhere,
488 // only size of pInfo matters now
490 Size aInfoSize
= pParent
->GetOutputSizePixel(); // outside defined size
491 Size aNavSize
= pNavigator
->GetOutputSizePixel(); // Default-Size
493 aNavSize
.Width() = std::max( aInfoSize
.Width(), aNavSize
.Width() );
494 aNavSize
.Height() = std::max( aInfoSize
.Height(), aNavSize
.Height() );
495 pNavigator
->nListModeHeight
= std::max( aNavSize
.Height(), pNavigator
->nListModeHeight
);
497 // The size could be changed in another module,
498 // therefore we have to or have not to display the content
499 // in dependence of the current size
501 bool bSmall
= ( aInfoSize
.Height() <= pNavigator
->aInitSize
.Height() + SCNAV_MINTOL
);
502 NavListMode eNavMode
= NAV_LMODE_NONE
;
505 // if scenario was active, switch on
507 ScNavipiCfg
& rCfg
= SC_MOD()->GetNavipiCfg();
508 NavListMode eLastMode
= (NavListMode
) rCfg
.GetListMode();
509 if ( eLastMode
== NAV_LMODE_SCENARIOS
)
510 eNavMode
= NAV_LMODE_SCENARIOS
;
512 eNavMode
= NAV_LMODE_AREAS
;
515 // Do not set the size of the float again (sal_False at SetListMode), so that the
516 // navigator is not expanded, if it was minimized (#38872#).
518 pNavigator
->SetListMode( eNavMode
, false ); // FALSE: do not set the Float size
523 case NAV_LMODE_SCENARIOS
: nCmdId
= IID_SCENARIOS
; break;
524 case NAV_LMODE_AREAS
: nCmdId
= IID_AREAS
; break;
525 // The following case can never be reach due to how eNavMode is set-up
526 // case NAV_LMODE_DOCS: nCmdId = IID_DOCS; break;
527 // case NAV_LMODE_DBAREAS: nCmdId = IID_DBAREAS; break;
532 pNavigator
->aTbxCmd
->CheckItem( nCmdId
);
533 pNavigator
->DoResize();
536 pNavigator
->bFirstBig
= ( nCmdId
== 0 ); // later
539 void ScNavigatorDialogWrapper::Resizing( Size
& rSize
)
541 static_cast<ScNavigatorDlg
*>(GetWindow())->Resizing(rSize
);
544 // class ScNavigatorPI
548 #define REGISTER_SLOT(i,id) \
549 ppBoundItems[i]=new ScNavigatorControllerItem(id,*this,rBindings);
551 ScNavigatorDlg::ScNavigatorDlg( SfxBindings
* pB
, SfxChildWindowContext
* pCW
, vcl::Window
* pParent
,
552 const bool bUseStyleSettingsBackground
) :
553 Window( pParent
, ScResId(RID_SCDLG_NAVIGATOR
) ),
554 rBindings ( *pB
), // is used in CommandToolBox ctor
555 aCmdImageList( ScResId( IL_CMD
) ),
556 aFtCol ( VclPtr
<FixedInfo
>::Create( this, ScResId( FT_COL
) ) ),
557 aEdCol ( VclPtr
<ColumnEdit
>::Create( this, ScResId( ED_COL
) ) ),
558 aFtRow ( VclPtr
<FixedInfo
>::Create( this, ScResId( FT_ROW
) ) ),
559 aEdRow ( VclPtr
<RowEdit
>::Create( this, ScResId( ED_ROW
) ) ),
560 aTbxCmd ( VclPtr
<CommandToolBox
>::Create( this, ScResId( TBX_CMD
) ) ),
561 aLbEntries ( VclPtr
<ScContentTree
>::Create( this, ScResId( LB_ENTRIES
) ) ),
562 aWndScenarios( VclPtr
<ScScenarioWindow
>::Create( this,ScResId( STR_QHLP_SCEN_LISTBOX
), ScResId(STR_QHLP_SCEN_COMMENT
)) ),
563 aLbDocuments( VclPtr
<ScDocListBox
>::Create( this, ScResId( LB_DOCUMENTS
) ) ),
564 aStrDragMode ( ScResId( STR_DRAGMODE
) ),
565 aStrDisplay ( ScResId( STR_DISPLAY
) ),
566 aStrActiveWin( ScResId( STR_ACTIVEWIN
) ),
570 nListModeHeight( 0 ),
571 nInitListHeight( 0 ),
572 eListMode ( NAV_LMODE_NONE
),
573 nDropMode ( SC_DROPMODE_URL
),
578 mbUseStyleSettingsBackground(bUseStyleSettingsBackground
)
580 ScNavipiCfg
& rCfg
= SC_MOD()->GetNavipiCfg();
581 nDropMode
= rCfg
.GetDragMode();
582 // eListMode is set from outside, Root further below
584 aLbDocuments
->SetDropDownLineCount(9);
585 OUString
aOpen(" (");
587 aStrActive
+= OUString( ScResId( STR_ACTIVE
) );
588 aStrActive
+= ")"; // " (active)"
589 aStrNotActive
= aOpen
;
590 aStrNotActive
+= OUString( ScResId( STR_NOTACTIVE
) );
591 aStrNotActive
+= ")"; // " (not active)"
593 aStrHidden
+= OUString( ScResId( STR_HIDDEN
) );
594 aStrHidden
+= ")"; // " (hidden)"
596 aTitleBase
= GetText();
598 const long nListboxYPos
=
600 (aTbxCmd
->GetPosPixel().Y() + aTbxCmd
->GetSizePixel().Height()),
601 (aEdRow
->GetPosPixel().Y() + aEdRow
->GetSizePixel().Height()) )
603 aLbEntries
->setPosSizePixel( 0, nListboxYPos
, 0, 0, PosSizeFlags::Y
);
605 nBorderOffset
= aLbEntries
->GetPosPixel().X();
607 aInitSize
.Width() = aTbxCmd
->GetPosPixel().X()
608 + aTbxCmd
->GetSizePixel().Width()
610 aInitSize
.Height() = aLbEntries
->GetPosPixel().Y();
612 nInitListHeight
= aLbEntries
->GetSizePixel().Height();
613 nListModeHeight
= aInitSize
.Height()
616 ppBoundItems
= new ScNavigatorControllerItem
* [CTRL_ITEMS
];
618 rBindings
.ENTERREGISTRATIONS();
620 REGISTER_SLOT( 0, SID_CURRENTCELL
);
621 REGISTER_SLOT( 1, SID_CURRENTTAB
);
622 REGISTER_SLOT( 2, SID_CURRENTDOC
);
623 REGISTER_SLOT( 3, SID_SELECT_SCENARIO
);
625 rBindings
.LEAVEREGISTRATIONS();
627 StartListening( *(SfxGetpApp()) );
628 StartListening( rBindings
);
630 aLbDocuments
->Hide(); // does not exist at NAV_LMODE_NONE
632 aLbEntries
->InitWindowBits(true);
634 aLbEntries
->SetSpaceBetweenEntries(0);
635 aLbEntries
->SetSelectionMode( SINGLE_SELECTION
);
636 aLbEntries
->SetDragDropMode( DragDropMode::CTRL_MOVE
|
637 DragDropMode::CTRL_COPY
|
638 DragDropMode::ENABLE_TOP
);
640 // was a category chosen as root?
641 sal_uInt16 nLastRoot
= rCfg
.GetRootType();
643 aLbEntries
->SetRootType( nLastRoot
);
645 aLbEntries
->Refresh();
648 aTbxCmd
->UpdateButtons();
654 aWndScenarios
->Hide();
655 aWndScenarios
->SetPosPixel( aLbEntries
->GetPosPixel() );
657 aContentIdle
.SetIdleHdl( LINK( this, ScNavigatorDlg
, TimeHdl
) );
658 aContentIdle
.SetPriority( SchedulerPriority::LOWEST
);
662 aLbEntries
->SetAccessibleRelationLabeledBy(aLbEntries
.get());
663 aTbxCmd
->SetAccessibleRelationLabeledBy(aTbxCmd
.get());
664 aLbDocuments
->SetAccessibleName(aStrActiveWin
);
666 if (pContextWin
== NULL
)
668 // When the context window is missing then the navigator is
669 // displayed in the sidebar and has the whole deck to fill.
670 // Therefore hide the button that hides all controls below the
671 // top two rows of buttons.
672 aTbxCmd
->Select(IID_ZOOMOUT
);
673 aTbxCmd
->RemoveItem(aTbxCmd
->GetItemPos(IID_ZOOMOUT
));
675 aLbEntries
->SetNavigatorDlgFlag(true);
678 ScNavigatorDlg::~ScNavigatorDlg()
683 void ScNavigatorDlg::dispose()
688 for ( i
=0; i
<CTRL_ITEMS
; i
++ )
689 delete ppBoundItems
[i
];
691 delete [] ppBoundItems
;
694 EndListening( *(SfxGetpApp()) );
695 EndListening( rBindings
);
697 aFtCol
.disposeAndClear();
698 aEdCol
.disposeAndClear();
699 aFtRow
.disposeAndClear();
700 aEdRow
.disposeAndClear();
701 aTbxCmd
.disposeAndClear();
702 aLbEntries
.disposeAndClear();
703 aWndScenarios
.disposeAndClear();
704 aLbDocuments
.disposeAndClear();
705 vcl::Window::dispose();
708 void ScNavigatorDlg::Resizing( Size
& rNewSize
) // Size = Outputsize?
710 FloatingWindow
* pFloat
= pContextWin
!=NULL
? pContextWin
->GetFloatingWindow() : NULL
;
713 Size aMinOut
= pFloat
->GetMinOutputSizePixel();
715 if ( rNewSize
.Width() < aMinOut
.Width() )
716 rNewSize
.Width() = aMinOut
.Width();
718 if ( eListMode
== NAV_LMODE_NONE
)
719 rNewSize
.Height() = aInitSize
.Height();
722 if ( rNewSize
.Height() < aMinOut
.Height() )
723 rNewSize
.Height() = aMinOut
.Height();
728 void ScNavigatorDlg::Paint( vcl::RenderContext
& rRenderContext
, const Rectangle
& rRect
)
730 if (mbUseStyleSettingsBackground
)
732 const StyleSettings
& rStyleSettings
= Application::GetSettings().GetStyleSettings();
733 Color aBgColor
= rStyleSettings
.GetFaceColor();
734 Wallpaper
aBack( aBgColor
);
736 SetBackground( aBack
);
737 aFtCol
->SetBackground( aBack
);
738 aFtRow
->SetBackground( aBack
);
742 aFtCol
->SetBackground(Wallpaper());
743 aFtRow
->SetBackground(Wallpaper());
746 Window::Paint(rRenderContext
, rRect
);
749 void ScNavigatorDlg::DataChanged( const DataChangedEvent
& rDCEvt
)
751 if ( rDCEvt
.GetType() == DataChangedEventType::SETTINGS
&& (rDCEvt
.GetFlags() & AllSettingsFlags::STYLE
) )
753 // toolbox images are exchanged in CommandToolBox::DataChanged
757 Window::DataChanged( rDCEvt
);
760 void ScNavigatorDlg::Resize()
765 void ScNavigatorDlg::DoResize()
767 Size aNewSize
= GetOutputSizePixel();
768 long nTotalHeight
= aNewSize
.Height();
770 // if the navigator is docked, the window is probably at first small generated,
771 // then there is a resize to the actual size -> switch on content
773 bool bSmall
= ( nTotalHeight
<= aInitSize
.Height() + SCNAV_MINTOL
);
774 if ( !bSmall
&& bFirstBig
)
776 // Switch on content again as described in the config
779 NavListMode eNavMode
= NAV_LMODE_AREAS
;
780 ScNavipiCfg
& rCfg
= SC_MOD()->GetNavipiCfg();
781 NavListMode eLastMode
= (NavListMode
) rCfg
.GetListMode();
782 if ( eLastMode
== NAV_LMODE_SCENARIOS
)
783 eNavMode
= NAV_LMODE_SCENARIOS
;
784 SetListMode( eNavMode
, false ); // FALSE: do not set the Float size
787 // even if the content is not visible, adapt the size,
790 Point aEntryPos
= aLbEntries
->GetPosPixel();
791 Point aListPos
= aLbDocuments
->GetPosPixel();
792 aNewSize
.Width() -= 2*nBorderOffset
;
793 Size aDocSize
= aLbDocuments
->GetSizePixel();
794 aDocSize
.Width() = aNewSize
.Width();
799 long nListHeight
= aLbDocuments
->GetSizePixel().Height();
800 aNewSize
.Height() -= ( aEntryPos
.Y() + nListHeight
+ 2*nBorderOffset
);
801 if(aNewSize
.Height()<0) aNewSize
.Height()=0;
803 aListPos
.Y() = aEntryPos
.Y() + aNewSize
.Height() + nBorderOffset
;
805 if(aListPos
.Y() > aLbEntries
->GetPosPixel().Y())
806 aLbDocuments
->SetPosPixel( aListPos
);
809 aLbEntries
->SetSizePixel( aNewSize
);
810 aWndScenarios
->SetSizePixel( aNewSize
);
811 aLbDocuments
->SetSizePixel( aDocSize
);
813 bool bListMode
= (eListMode
!= NAV_LMODE_NONE
);
814 if (pContextWin
!= NULL
)
816 FloatingWindow
* pFloat
= pContextWin
->GetFloatingWindow();
817 if ( pFloat
&& bListMode
)
818 nListModeHeight
= nTotalHeight
;
822 void ScNavigatorDlg::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
824 const SfxSimpleHint
* pSimpleHint
= dynamic_cast<const SfxSimpleHint
*>( &rHint
);
827 sal_uLong nHintId
= pSimpleHint
->GetId();
829 if ( nHintId
== SC_HINT_DOCNAME_CHANGED
)
831 aLbEntries
->ActiveDocChanged();
833 else if ( NAV_LMODE_NONE
== eListMode
)
835 // Table not any more
841 case SC_HINT_TABLES_CHANGED
:
842 aLbEntries
->Refresh( SC_CONTENT_TABLE
);
845 case SC_HINT_DBAREAS_CHANGED
:
846 aLbEntries
->Refresh( SC_CONTENT_DBAREA
);
849 case SC_HINT_AREAS_CHANGED
:
850 aLbEntries
->Refresh( SC_CONTENT_RANGENAME
);
853 case SC_HINT_DRAW_CHANGED
:
854 aLbEntries
->Refresh( SC_CONTENT_GRAPHIC
);
855 aLbEntries
->Refresh( SC_CONTENT_OLEOBJECT
);
856 aLbEntries
->Refresh( SC_CONTENT_DRAWING
);
859 case SC_HINT_AREALINKS_CHANGED
:
860 aLbEntries
->Refresh( SC_CONTENT_AREALINK
);
863 // SFX_HINT_DOCCHANGED not only at document change
865 case SC_HINT_NAVIGATOR_UPDATEALL
:
869 case FID_DATACHANGED
:
870 case FID_ANYDATACHANGED
:
871 aContentIdle
.Start(); // Do not search notes immediately
873 case FID_KILLEDITVIEW
:
874 aLbEntries
->ObjectFresh( SC_CONTENT_OLEOBJECT
);
875 aLbEntries
->ObjectFresh( SC_CONTENT_DRAWING
);
876 aLbEntries
->ObjectFresh( SC_CONTENT_GRAPHIC
);
883 else if ( dynamic_cast<const SfxEventHint
*>(&rHint
) )
885 sal_uLong nEventId
= static_cast<const SfxEventHint
&>(rHint
).GetEventId();
886 if ( nEventId
== SFX_EVENT_ACTIVATEDOC
)
888 aLbEntries
->ActiveDocChanged();
894 IMPL_LINK_TYPED( ScNavigatorDlg
, TimeHdl
, Idle
*, pIdle
, void )
896 if ( pIdle
!= &aContentIdle
)
899 aLbEntries
->Refresh( SC_CONTENT_NOTE
);
902 void ScNavigatorDlg::SetDropMode(sal_uInt16 nNew
)
905 aTbxCmd
->UpdateButtons();
907 ScNavipiCfg
& rCfg
= SC_MOD()->GetNavipiCfg();
908 rCfg
.SetDragMode(nDropMode
);
911 void ScNavigatorDlg::SetCurrentCell( SCCOL nColNo
, SCROW nRowNo
)
913 if ( (nColNo
+1 != nCurCol
) || (nRowNo
+1 != nCurRow
) )
915 // SID_CURRENTCELL == Item #0 clear cache, so it's possible
916 // setting the current cell even in combined areas
917 ppBoundItems
[0]->ClearCache();
919 ScAddress
aScAddress( nColNo
, nRowNo
, 0 );
920 OUString
aAddr(aScAddress
.Format(SCA_ABS
));
922 bool bUnmark
= false;
924 bUnmark
= !pViewData
->GetMarkData().IsCellMarked( nColNo
, nRowNo
);
926 SfxStringItem
aPosItem( SID_CURRENTCELL
, aAddr
);
927 SfxBoolItem
aUnmarkItem( FN_PARAM_1
, bUnmark
); // cancel selektion
929 rBindings
.GetDispatcher()->Execute( SID_CURRENTCELL
,
930 SfxCallMode::SYNCHRON
| SfxCallMode::RECORD
,
931 &aPosItem
, &aUnmarkItem
, 0L );
935 void ScNavigatorDlg::SetCurrentCellStr( const OUString
& rName
)
937 ppBoundItems
[0]->ClearCache();
938 SfxStringItem
aNameItem( SID_CURRENTCELL
, rName
);
940 rBindings
.GetDispatcher()->Execute( SID_CURRENTCELL
,
941 SfxCallMode::SYNCHRON
| SfxCallMode::RECORD
,
945 void ScNavigatorDlg::SetCurrentTable( SCTAB nTabNo
)
947 if ( nTabNo
!= nCurTab
)
949 // Table for basic is base-1
950 SfxUInt16Item
aTabItem( SID_CURRENTTAB
, static_cast<sal_uInt16
>(nTabNo
) + 1 );
951 rBindings
.GetDispatcher()->Execute( SID_CURRENTTAB
,
952 SfxCallMode::SYNCHRON
| SfxCallMode::RECORD
,
957 void ScNavigatorDlg::SetCurrentTableStr( const OUString
& rName
)
959 if (!GetViewData()) return;
961 ScDocument
* pDoc
= pViewData
->GetDocument();
962 SCTAB nCount
= pDoc
->GetTableCount();
965 for ( SCTAB i
=0; i
<nCount
; i
++ )
967 pDoc
->GetName( i
, aTabName
);
968 if ( aTabName
.equals(rName
) )
970 SetCurrentTable( i
);
976 void ScNavigatorDlg::SetCurrentObject( const OUString
& rName
)
978 SfxStringItem
aNameItem( SID_CURRENTOBJECT
, rName
);
979 rBindings
.GetDispatcher()->Execute( SID_CURRENTOBJECT
,
980 SfxCallMode::SYNCHRON
| SfxCallMode::RECORD
,
984 void ScNavigatorDlg::SetCurrentDoc( const OUString
& rDocName
) // activate
986 SfxStringItem
aDocItem( SID_CURRENTDOC
, rDocName
);
987 rBindings
.GetDispatcher()->Execute( SID_CURRENTDOC
,
988 SfxCallMode::SYNCHRON
| SfxCallMode::RECORD
,
992 ScTabViewShell
* ScNavigatorDlg::GetTabViewShell()
994 return PTR_CAST( ScTabViewShell
, SfxViewShell::Current() );
997 ScNavigatorSettings
* ScNavigatorDlg::GetNavigatorSettings()
999 // Don't store the settings pointer here, because the settings belong to
1000 // the view, and the view may be closed while the navigator is open (reload).
1001 // If the pointer is cached here again later for performance reasons, it has to
1002 // be forgotten when the view is closed.
1004 ScTabViewShell
* pViewSh
= GetTabViewShell();
1005 return pViewSh
? pViewSh
->GetNavigatorSettings() : NULL
;
1008 bool ScNavigatorDlg::GetViewData()
1010 ScTabViewShell
* pViewSh
= GetTabViewShell();
1011 pViewData
= pViewSh
? &pViewSh
->GetViewData() : NULL
;
1013 return ( pViewData
!= NULL
);
1016 void ScNavigatorDlg::UpdateColumn( const SCCOL
* pCol
)
1020 else if ( GetViewData() )
1021 nCurCol
= pViewData
->GetCurX() + 1;
1023 aEdCol
->SetCol( nCurCol
);
1027 void ScNavigatorDlg::UpdateRow( const SCROW
* pRow
)
1031 else if ( GetViewData() )
1032 nCurRow
= pViewData
->GetCurY() + 1;
1034 aEdRow
->SetRow( nCurRow
);
1038 void ScNavigatorDlg::UpdateTable( const SCTAB
* pTab
)
1042 else if ( GetViewData() )
1043 nCurTab
= pViewData
->GetTabNo();
1048 void ScNavigatorDlg::UpdateAll()
1050 switch ( eListMode
)
1052 case NAV_LMODE_DOCS
:
1053 case NAV_LMODE_DBAREAS
:
1054 case NAV_LMODE_AREAS
:
1055 aLbEntries
->Refresh();
1058 case NAV_LMODE_NONE
:
1066 aContentIdle
.Stop(); // not again
1069 void ScNavigatorDlg::SetListMode( NavListMode eMode
, bool bSetSize
)
1071 if ( eMode
!= eListMode
)
1073 if ( eMode
!= NAV_LMODE_NONE
)
1074 bFirstBig
= false; // do not switch automatically any more
1080 case NAV_LMODE_NONE
:
1081 ShowList( false, bSetSize
);
1084 case NAV_LMODE_AREAS
:
1085 case NAV_LMODE_DBAREAS
:
1086 case NAV_LMODE_DOCS
:
1087 aLbEntries
->Refresh();
1088 ShowList( true, bSetSize
);
1091 case NAV_LMODE_SCENARIOS
:
1092 ShowScenarios( true, bSetSize
);
1096 aTbxCmd
->UpdateButtons();
1098 if ( eMode
!= NAV_LMODE_NONE
)
1100 ScNavipiCfg
& rCfg
= SC_MOD()->GetNavipiCfg();
1101 rCfg
.SetListMode( (sal_uInt16
) eMode
);
1109 void ScNavigatorDlg::ShowList( bool bShow
, bool bSetSize
)
1111 FloatingWindow
* pFloat
= pContextWin
!=NULL
? pContextWin
->GetFloatingWindow() : NULL
;
1112 Size aSize
= GetParent()->GetOutputSizePixel();
1116 Size aMinSize
= aInitSize
;
1118 aMinSize
.Height() += nInitListHeight
;
1120 pFloat
->SetMinOutputSizePixel( aMinSize
);
1121 aSize
.Height() = nListModeHeight
;
1123 aLbDocuments
->Show();
1129 pFloat
->SetMinOutputSizePixel( aInitSize
);
1130 nListModeHeight
= aSize
.Height();
1132 aSize
.Height() = aInitSize
.Height();
1134 aLbDocuments
->Hide();
1136 aWndScenarios
->Hide();
1141 pFloat
->SetOutputSizePixel( aSize
);
1145 SfxNavigator
* pNav
= dynamic_cast<SfxNavigator
*>(GetParent());
1148 Size aFloating
= pNav
->GetFloatingSize();
1149 aFloating
.Height() = aSize
.Height();
1150 pNav
->SetFloatingSize( aFloating
);
1155 void ScNavigatorDlg::ShowScenarios( bool bShow
, bool bSetSize
)
1157 FloatingWindow
* pFloat
= pContextWin
!=NULL
? pContextWin
->GetFloatingWindow() : NULL
;
1158 Size aSize
= GetParent()->GetOutputSizePixel();
1162 Size aMinSize
= aInitSize
;
1163 aMinSize
.Height() += nInitListHeight
;
1165 pFloat
->SetMinOutputSizePixel( aMinSize
);
1166 aSize
.Height() = nListModeHeight
;
1168 rBindings
.Invalidate( SID_SELECT_SCENARIO
);
1169 rBindings
.Update( SID_SELECT_SCENARIO
);
1171 aWndScenarios
->Show();
1172 aLbDocuments
->Show();
1178 pFloat
->SetMinOutputSizePixel( aInitSize
);
1179 nListModeHeight
= aSize
.Height();
1181 aSize
.Height() = aInitSize
.Height();
1182 aWndScenarios
->Hide();
1183 aLbDocuments
->Hide();
1190 pFloat
->SetOutputSizePixel( aSize
);
1194 SfxNavigator
* pNav
= static_cast<SfxNavigator
*>(GetParent());
1195 Size aFloating
= pNav
->GetFloatingSize();
1196 aFloating
.Height() = aSize
.Height();
1197 pNav
->SetFloatingSize( aFloating
);
1201 // documents for Dropdown-Listbox
1203 void ScNavigatorDlg::GetDocNames( const OUString
* pManualSel
)
1205 aLbDocuments
->Clear();
1206 aLbDocuments
->SetUpdateMode( false );
1208 ScDocShell
* pCurrentSh
= PTR_CAST( ScDocShell
, SfxObjectShell::Current() );
1211 SfxObjectShell
* pSh
= SfxObjectShell::GetFirst();
1214 if ( pSh
->ISA(ScDocShell
) )
1216 OUString aName
= pSh
->GetTitle();
1217 OUString aEntry
= aName
;
1218 if (pSh
== pCurrentSh
)
1219 aEntry
+= aStrActive
;
1221 aEntry
+= aStrNotActive
;
1222 aLbDocuments
->InsertEntry( aEntry
);
1224 if ( pManualSel
? ( aName
== *pManualSel
)
1225 : ( pSh
== pCurrentSh
) )
1226 aSelEntry
= aEntry
; // compelte entry for selection
1229 pSh
= SfxObjectShell::GetNext( *pSh
);
1232 aLbDocuments
->InsertEntry( aStrActiveWin
);
1234 OUString aHidden
= aLbEntries
->GetHiddenTitle();
1235 if (!aHidden
.isEmpty())
1237 OUString aEntry
= aHidden
;
1238 aEntry
+= aStrHidden
;
1239 aLbDocuments
->InsertEntry( aEntry
);
1241 if ( pManualSel
&& aHidden
== *pManualSel
)
1245 aLbDocuments
->SetUpdateMode( true );
1247 aLbDocuments
->SelectEntry( aSelEntry
);
1250 void ScNavigatorDlg::MarkDataArea()
1252 ScTabViewShell
* pViewSh
= GetTabViewShell();
1257 pMarkArea
= new ScArea
;
1259 pViewSh
->MarkDataArea();
1261 pViewSh
->GetViewData().GetMarkData().GetMarkArea(aMarkRange
);
1262 pMarkArea
->nColStart
= aMarkRange
.aStart
.Col();
1263 pMarkArea
->nRowStart
= aMarkRange
.aStart
.Row();
1264 pMarkArea
->nColEnd
= aMarkRange
.aEnd
.Col();
1265 pMarkArea
->nRowEnd
= aMarkRange
.aEnd
.Row();
1266 pMarkArea
->nTab
= aMarkRange
.aStart
.Tab();
1270 void ScNavigatorDlg::UnmarkDataArea()
1272 ScTabViewShell
* pViewSh
= GetTabViewShell();
1277 DELETEZ( pMarkArea
);
1281 void ScNavigatorDlg::CheckDataArea()
1283 if ( aTbxCmd
->IsItemChecked( IID_DATA
) && pMarkArea
)
1285 if ( nCurTab
!= pMarkArea
->nTab
1286 || nCurCol
< pMarkArea
->nColStart
+1
1287 || nCurCol
> pMarkArea
->nColEnd
+1
1288 || nCurRow
< pMarkArea
->nRowStart
+1
1289 || nCurRow
> pMarkArea
->nRowEnd
+1 )
1291 aTbxCmd
->SetItemState( IID_DATA
, TriState(TRISTATE_TRUE
) );
1292 aTbxCmd
->Select( IID_DATA
);
1297 void ScNavigatorDlg::StartOfDataArea()
1299 // pMarkArea evaluate ???
1301 if ( GetViewData() )
1303 ScMarkData
& rMark
= pViewData
->GetMarkData();
1305 rMark
.GetMarkArea( aMarkRange
);
1307 SCCOL nCol
= aMarkRange
.aStart
.Col();
1308 SCROW nRow
= aMarkRange
.aStart
.Row();
1310 if ( (nCol
+1 != aEdCol
->GetCol()) || (nRow
+1 != aEdRow
->GetRow()) )
1311 SetCurrentCell( nCol
, nRow
);
1315 void ScNavigatorDlg::EndOfDataArea()
1317 // pMarkArea evaluate ???
1319 if ( GetViewData() )
1321 ScMarkData
& rMark
= pViewData
->GetMarkData();
1323 rMark
.GetMarkArea( aMarkRange
);
1325 SCCOL nCol
= aMarkRange
.aEnd
.Col();
1326 SCROW nRow
= aMarkRange
.aEnd
.Row();
1328 if ( (nCol
+1 != aEdCol
->GetCol()) || (nRow
+1 != aEdRow
->GetRow()) )
1329 SetCurrentCell( nCol
, nRow
);
1333 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */