LibreOffice Module sc (master)  1
navcitem.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include <svl/intitem.hxx>
21 #include <svl/stritem.hxx>
22 #include <osl/diagnose.h>
23 
24 #include <navcitem.hxx>
25 #include <navipi.hxx>
26 #include <viewdata.hxx>
27 #include <sc.hrc>
28 
30  ScNavigatorDlg& rDlg,
31  SfxBindings& rBindings )
32  : SfxControllerItem ( nIdP, rBindings ),
33  rNavigatorDlg ( rDlg )
34 {
35 }
36 
37 void ScNavigatorControllerItem::StateChanged( sal_uInt16 /* nSID */, SfxItemState /* eState */,
38  const SfxPoolItem* pItem )
39 {
40  switch( GetId() )
41  {
42  case SID_CURRENTCELL:
43  if ( pItem )
44  {
45  ScViewData* pViewData = rNavigatorDlg.GetViewData();
46  const SfxStringItem* pCellPosItem = dynamic_cast<const SfxStringItem*>( pItem );
47 
48  OSL_ENSURE( pCellPosItem, "SfxStringItem expected!" );
49 
50  if (pCellPosItem && pViewData)
51  {
52  const OUString& aAddress( pCellPosItem->GetValue() );
53  ScAddress aScAddress;
54  aScAddress.Parse(aAddress, pViewData->GetDocument());
55 
56  SCCOL nCol = aScAddress.Col()+1;
57  SCROW nRow = aScAddress.Row()+1;
58 
59  rNavigatorDlg.UpdateColumn( &nCol );
60  rNavigatorDlg.UpdateRow ( &nRow );
61  }
62  }
63  break;
64 
65  case SID_CURRENTTAB:
66  if ( pItem )
67  {
68  const SfxUInt16Item* pTabItem = dynamic_cast< const SfxUInt16Item *>( pItem );
69 
70  OSL_ENSURE( pTabItem, "SfxUInt16Item expected!" );
71 
72  // table for Basic is 1-based
73  if ( pTabItem && pTabItem->GetValue() )
74  {
75  SCTAB nTab = pTabItem->GetValue() - 1;
76 
77  rNavigatorDlg.UpdateTable( &nTab );
80  }
81  }
82  break;
83 
84  case SID_CURRENTDOC:
85 
86  // nothing is done via SfxHintId::DocChanged
87 
88  break;
89 
90  case SID_SELECT_SCENARIO:
91  rNavigatorDlg.m_xWndScenarios->NotifyState(pItem);
92  break;
93 
94  default:
95  break;
96  }
97 }
98 
99 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void UpdateTable(const SCTAB *pTab)
Definition: navipi.cxx:734
sal_uInt16 GetValue() const
ScDocument & GetDocument() const
Definition: viewdata.hxx:380
std::unique_ptr< ScScenarioWindow > m_xWndScenarios
Definition: navipi.hxx:104
sal_Int16 SCCOL
Definition: types.hxx:22
const OUString & GetValue() const
void UpdateRow(const SCROW *pRow=nullptr)
Definition: navipi.cxx:724
ScNavigatorDlg & rNavigatorDlg
Definition: navcitem.hxx:38
sal_uInt16 GetId() const
sal_Int32 SCROW
Definition: types.hxx:18
SfxItemState
ScNavigatorControllerItem(sal_uInt16 nId, ScNavigatorDlg &rDlg, SfxBindings &rBindings)
Definition: navcitem.cxx:29
virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pItem) override
Definition: navcitem.cxx:37
SC_DLLPUBLIC ScRefFlags Parse(const OUString &, const ScDocument &, const Details &rDetails=detailsOOOa1, ExternalInfo *pExtInfo=nullptr, const css::uno::Sequence< css::sheet::ExternalLinkInfo > *pExternalLinks=nullptr, sal_Int32 *pSheetEndPos=nullptr, const OUString *pErrRef=nullptr)
Definition: address.cxx:1539
ScViewData * GetViewData()
Definition: navipi.cxx:707
void UpdateColumn(const SCCOL *pCol=nullptr)
Definition: navipi.cxx:714
sal_Int16 SCTAB
Definition: types.hxx:23