--- orig/chart2/source/controller/dialogs/DataBrowser.cxx 2007-08-27 09:52:26.000000000 +0800 +++ new/chart2/source/controller/dialogs/DataBrowser.cxx 2007-08-29 13:13:36.000000000 +0800 @@ -512,7 +512,8 @@ m_aNumberEditField( & EditBrowseBox::GetDataWindow(), WB_NOBORDER ), m_aTextEditField( & EditBrowseBox::GetDataWindow(), WB_NOBORDER ), m_rNumberEditController( new ::svt::FormattedFieldCellController( & m_aNumberEditField )), - m_rTextEditController( new ::svt::EditCellController( & m_aTextEditField )) + m_rTextEditController( new ::svt::EditCellController( & m_aTextEditField )), + m_bDataValid( true ) { double fNan; ::rtl::math::setNan( & fNan ); @@ -615,10 +616,11 @@ BOOL bLastUpdateMode = GetUpdateMode(); SetUpdateMode( FALSE ); + DeactivateCell(); + if( IsModified() ) SaveModified(); - DeactivateCell(); RemoveColumns(); RowRemoved( 1, GetRowCount() ); @@ -804,8 +806,42 @@ m_aCellModifiedLink = rLink; } +bool DataBrowser::isDataValid() +{ + bool bValid = true; + const sal_Int32 nRow = lcl_getRowInData( GetCurRow()); + const sal_Int32 nCol = lcl_getColumnInData( GetCurColumnId()); + + if( m_apDataBrowserModel->getCellType( nCol, nRow ) == DataBrowserModel::NUMBER ) + { + sal_uInt32 nDummy = 0; + double fDummy = 0.0; + String aText( m_aNumberEditField.GetText()); + + if( aText.Len() > 0 && + m_spNumberFormatterWrapper.get() && + m_spNumberFormatterWrapper->getSvNumberFormatter() && + ! m_spNumberFormatterWrapper->getSvNumberFormatter()->IsNumberFormat( + aText, nDummy, fDummy )) + { + WarningBox( this, WinBits( WB_OK ), + String( SchResId( STR_INVALID_NUMBER ))).Execute(); + bValid = false; + } + } + + return bValid; +} + +bool DataBrowser::isEnableItem() const +{ + return m_bDataValid; +} + void DataBrowser::CellModified() { + m_bDataValid = isDataValid(); + SetDirty(); if( m_aCellModifiedLink.IsSet()) m_aCursorMovedHdlLink.Call( this ); @@ -866,9 +902,7 @@ if( nColIdx >= 0 && m_apDataBrowserModel.get()) { - // save changes made to edit-field - if( IsModified() ) - SaveModified(); + m_bDataValid = true; m_apDataBrowserModel->removeDataSeries( nColIdx ); RenewTable(); @@ -898,9 +932,7 @@ if( nRowIdx >= 0 && m_apDataBrowserModel.get()) { - // save changes made to edit-field - if( IsModified() ) - SaveModified(); + m_bDataValid = true; m_apDataBrowserModel->removeDataPointForAllSeries( nRowIdx ); RenewTable(); @@ -1189,13 +1221,16 @@ return bChangeValid; } -void DataBrowser::EndEditing() +bool DataBrowser::EndEditing() { + bool bModified = true; if( IsModified()) - SaveModified(); + bModified = SaveModified(); // apply changes made to series headers ::std::for_each( m_aSeriesHeaders.begin(), m_aSeriesHeaders.end(), impl::applyChangesFunctor()); + + return bModified; } sal_Int16 DataBrowser::GetFirstVisibleColumNumber() const @@ -1264,12 +1299,14 @@ IMPL_LINK( DataBrowser, SeriesHeaderGotFocus, impl::SeriesHeaderEdit*, pEdit ) { - if( pEdit ) + if( pEdit && m_bDataValid ) { - DeactivateCell(); + //DeactivateCell(); MakeFieldVisible( GetCurRow(), static_cast< sal_uInt16 >( pEdit->getStartColumn()), true /* bComplete */ ); m_aCursorMovedHdlLink.Call( this ); } + else + GoToRow( 0 ); return 0; } --- orig/chart2/source/controller/dialogs/DataBrowser.hxx 2007-08-27 09:52:26.000000000 +0800 +++ new/chart2/source/controller/dialogs/DataBrowser.hxx 2007-08-29 11:49:56.000000000 +0800 @@ -164,7 +164,7 @@ void SetCellModifiedHdl( const Link& rLink ); /// confirms all pending changes to be ready to be closed - void EndEditing(); + bool EndEditing(); // calls the protected inline-function BrowseBox::GetFirstVisibleColNumber() sal_Int16 GetFirstVisibleColumNumber() const; @@ -175,6 +175,9 @@ sal_uInt32 GetNumberFormatKey( sal_Int32 nRow, sal_uInt16 nCol ) const; + bool isDataValid(); + bool isEnableItem() const; + private: ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > m_xChartDoc; @@ -190,6 +193,7 @@ bool m_bIsReadOnly; bool m_bIsDirty; bool m_bLiveUpdate; + bool m_bDataValid; FormattedField m_aNumberEditField; Edit m_aTextEditField; --- orig/chart2/source/controller/dialogs/dlg_DataEditor.cxx 2007-08-27 09:52:26.000000000 +0800 +++ new/chart2/source/controller/dialogs/dlg_DataEditor.cxx 2007-08-29 11:51:22.000000000 +0800 @@ -204,13 +204,23 @@ if( m_bReadOnly ) return 0; - m_aTbxData.EnableItem( TBI_DATA_INSERT_ROW, m_apBrwData->MayInsertRow() ); - m_aTbxData.EnableItem( TBI_DATA_INSERT_COL, m_apBrwData->MayInsertColumn() ); - m_aTbxData.EnableItem( TBI_DATA_DELETE_ROW, m_apBrwData->MayDeleteRow() ); - m_aTbxData.EnableItem( TBI_DATA_DELETE_COL, m_apBrwData->MayDeleteColumn() ); + if( m_apBrwData->isEnableItem() ) + { + m_aTbxData.EnableItem( TBI_DATA_INSERT_ROW, m_apBrwData->MayInsertRow() ); + m_aTbxData.EnableItem( TBI_DATA_INSERT_COL, m_apBrwData->MayInsertColumn() ); + m_aTbxData.EnableItem( TBI_DATA_DELETE_ROW, m_apBrwData->MayDeleteRow() ); + m_aTbxData.EnableItem( TBI_DATA_DELETE_COL, m_apBrwData->MayDeleteColumn() ); - m_aTbxData.EnableItem( TBI_DATA_SWAP_COL, m_apBrwData->MaySwapColumns() ); - m_aTbxData.EnableItem( TBI_DATA_SWAP_ROW, m_apBrwData->MaySwapRows() ); + m_aTbxData.EnableItem( TBI_DATA_SWAP_COL, m_apBrwData->MaySwapColumns() ); + m_aTbxData.EnableItem( TBI_DATA_SWAP_ROW, m_apBrwData->MaySwapRows() ); + } + else + { + m_aTbxData.EnableItem( TBI_DATA_INSERT_ROW, FALSE ); + m_aTbxData.EnableItem( TBI_DATA_INSERT_COL, FALSE ); + m_aTbxData.EnableItem( TBI_DATA_SWAP_COL, FALSE ); + m_aTbxData.EnableItem( TBI_DATA_SWAP_ROW, FALSE ); + } // m_aTbxData.EnableItem( TBI_DATA_SORT_COL, m_apBrwData->MaySortColumn() ); // m_aTbxData.EnableItem( TBI_DATA_SORT_ROW, m_apBrwData->MaySortRow() ); @@ -353,13 +363,13 @@ BOOL DataEditor::Close() { - ApplyChangesToModel(); - return ModalDialog::Close(); + if( ApplyChangesToModel() ) + return ModalDialog::Close(); } -void DataEditor::ApplyChangesToModel() +bool DataEditor::ApplyChangesToModel() { - m_apBrwData->EndEditing(); + return m_apBrwData->EndEditing(); } // sets the correct toolbar icons depending on the current mode (e.g. high contrast) --- orig/chart2/source/controller/inc/dlg_DataEditor.hxx 2007-08-27 09:52:32.000000000 +0800 +++ new/chart2/source/controller/inc/dlg_DataEditor.hxx 2007-08-29 11:51:40.000000000 +0800 @@ -86,7 +86,7 @@ virtual BOOL Close(); void SetReadOnly( bool bReadOnly ); - void ApplyChangesToModel(); + bool ApplyChangesToModel(); private: bool m_bReadOnly; --- orig/svtools/source/brwbox/brwbox2.cxx 2006-10-12 23:06:12.000000000 +0800 +++ new/svtools/source/brwbox/brwbox2.cxx 2007-08-29 13:22:26.000000000 +0800 @@ -1771,12 +1771,15 @@ } } - // select directly - SetNoSelection(); - GoToRow( rEvt.GetRow() ); - SelectRow( rEvt.GetRow(), TRUE ); - aSelRange = Range( rEvt.GetRow(), rEvt.GetRow() ); - bSelect = TRUE; + // select directly + SetNoSelection(); + BOOL bDone = GoToRow( rEvt.GetRow() ); + if( bDone ) + { + SelectRow( rEvt.GetRow(), TRUE ); + aSelRange = Range( rEvt.GetRow(), rEvt.GetRow() ); + bSelect = TRUE; + } } else // Column/Field-Selection { --- orig/svtools/source/brwbox/editbrowsebox.cxx 2006-10-12 23:06:52.000000000 +0800 +++ new/svtools/source/brwbox/editbrowsebox.cxx 2007-08-29 13:23:18.000000000 +0800 @@ -569,13 +569,13 @@ LINK( this, EditBrowseBox, CellModifiedHdl ).Call( NULL ); } - if (0 == rEvt.GetColumnId()) - { // it was the handle column. save the current cell content if necessary - // (clicking on the handle column results in selecting the current row) - // 23.01.2001 - 82797 - FS - if (IsEditing() && aController->IsModified()) - SaveModified(); - } + //if (0 == rEvt.GetColumnId()) + //{ // it was the handle column. save the current cell content if necessary + // (clicking on the handle column results in selecting the current row) + // 23.01.2001 - 82797 - FS + //if (IsEditing() && aController->IsModified()) + //SaveModified(); + //} aMouseEvent.Set(&rEvt,sal_True); BrowseBox::MouseButtonDown(rEvt);