*** orig/chart2/source/controller/dialogs/DataBrowser.cxx Wed Jul 25 16:30:12 2007 --- new/chart2/source/controller/dialogs/DataBrowser.cxx Tue Nov 27 10:16:03 2007 *************** *** 161,177 **** public: SeriesHeaderEdit( Window * pParent ); virtual ~SeriesHeaderEdit(); void setStartColumn( sal_Int32 nStartColumn ); sal_Int32 getStartColumn() const; private: sal_Int32 m_nStartColumn; }; SeriesHeaderEdit::SeriesHeaderEdit( Window * pParent ) : Edit( pParent ), ! m_nStartColumn( 0 ) {} SeriesHeaderEdit::~SeriesHeaderEdit() {} --- 161,181 ---- public: SeriesHeaderEdit( Window * pParent ); virtual ~SeriesHeaderEdit(); + virtual void MouseButtonDown( const MouseEvent& rMEvt ); void setStartColumn( sal_Int32 nStartColumn ); sal_Int32 getStartColumn() const; + bool bShowWarningBox; + private: sal_Int32 m_nStartColumn; }; SeriesHeaderEdit::SeriesHeaderEdit( Window * pParent ) : Edit( pParent ), ! m_nStartColumn( 0 ), ! bShowWarningBox( false ) {} SeriesHeaderEdit::~SeriesHeaderEdit() {} *************** *** 185,190 **** --- 189,202 ---- { return m_nStartColumn; } + void SeriesHeaderEdit::MouseButtonDown( const MouseEvent& rMEvt ) + { + Edit::MouseButtonDown( rMEvt ); + + if( bShowWarningBox ) + WarningBox( this, WinBits( WB_OK ), + String( SchResId( STR_INVALID_NUMBER ))).Execute(); + } class SeriesHeader { *************** *** 527,533 **** 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 )) { double fNan; ::rtl::math::setNan( & fNan ); --- 539,546 ---- 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_bDataValid( true ) { double fNan; ::rtl::math::setNan( & fNan ); *************** *** 814,821 **** --- 827,879 ---- m_aCellModifiedLink = rLink; } + void DataBrowser::MouseButtonDown( const BrowserMouseEvent& rEvt ) + { + if( !m_bDataValid ) + ShowWarningBox(); + else + EditBrowseBox::MouseButtonDown( rEvt ); + } + + void DataBrowser::ShowWarningBox() + { + WarningBox( this, WinBits( WB_OK ), + String( SchResId( STR_INVALID_NUMBER ))).Execute(); + } + + 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 )) + { + bValid = false; + } + } + + return bValid; + } + + bool DataBrowser::IsEnableItem() + { + return m_bDataValid; + } + void DataBrowser::CellModified() { + m_bDataValid = IsDataValid(); SetDirty(); if( m_aCellModifiedLink.IsSet()) m_aCursorMovedHdlLink.Call( this ); *************** *** 880,885 **** --- 938,944 ---- if( IsModified() ) SaveModified(); + m_bDataValid = true; m_apDataBrowserModel->removeDataSeries( nColIdx ); RenewTable(); } *************** *** 912,917 **** --- 971,977 ---- if( IsModified() ) SaveModified(); + m_bDataValid = true; m_apDataBrowserModel->removeDataPointForAllSeries( nRowIdx ); RenewTable(); } *************** *** 1081,1086 **** --- 1141,1152 ---- ? GetRowCount() - 1 : 0; + if( !m_bDataValid ) + { + const_cast< DataBrowser* >( this )->ShowWarningBox(); + return sal_False; + } + return ( nRow != nBadRow || nCol != nBadCol ); } *************** *** 1167,1174 **** ! m_spNumberFormatterWrapper->getSvNumberFormatter()->IsNumberFormat( aText, nDummy, fDummy )) { ! WarningBox( this, WinBits( WB_OK ), ! String( SchResId( STR_INVALID_NUMBER ))).Execute(); bChangeValid = sal_False; } else --- 1233,1240 ---- ! m_spNumberFormatterWrapper->getSvNumberFormatter()->IsNumberFormat( aText, nDummy, fDummy )) { ! //WarningBox( this, WinBits( WB_OK ), ! //String( SchResId( STR_INVALID_NUMBER ))).Execute(); bChangeValid = sal_False; } else *************** *** 1199,1211 **** return bChangeValid; } ! void DataBrowser::EndEditing() { if( IsModified()) SaveModified(); // apply changes made to series headers ::std::for_each( m_aSeriesHeaders.begin(), m_aSeriesHeaders.end(), impl::applyChangesFunctor()); } sal_Int16 DataBrowser::GetFirstVisibleColumNumber() const --- 1265,1279 ---- return bChangeValid; } ! bool DataBrowser::EndEditing() { if( IsModified()) SaveModified(); // apply changes made to series headers ::std::for_each( m_aSeriesHeaders.begin(), m_aSeriesHeaders.end(), impl::applyChangesFunctor()); + + return m_bDataValid ; } sal_Int16 DataBrowser::GetFirstVisibleColumNumber() const *************** *** 1239,1245 **** { sal_uInt16 nColCount = this->GetColumnCount(); sal_uInt32 nCurrentPos = this->GetPosPixel().getX(); ! sal_uInt32 nMaxPos = nCurrentPos + this->GetOutputSizePixel().getWidth(); sal_uInt32 nStartPos = nCurrentPos; // width of header column --- 1307,1313 ---- { sal_uInt16 nColCount = this->GetColumnCount(); sal_uInt32 nCurrentPos = this->GetPosPixel().getX(); ! sal_uInt32 nMaxPos = nCurrentPos + this->GetOutputSizePixel().getWidth() - 88; sal_uInt32 nStartPos = nCurrentPos; // width of header column *************** *** 1261,1272 **** { (*aIt)->SetPixelPosX( nStartPos + 2 ); (*aIt)->SetPixelWidth( nCurrentPos - nStartPos - 3 ); ! // (*aIt)->Show(); } else ! // do not hide, to get focus events. Move outside the dialog for "hiding" (*aIt)->SetPixelPosX( nMaxPos + 42 ); ! // (*aIt)->Hide(); ++aIt; } } --- 1329,1341 ---- { (*aIt)->SetPixelPosX( nStartPos + 2 ); (*aIt)->SetPixelWidth( nCurrentPos - nStartPos - 3 ); ! (*aIt)->Show(); } else ! { (*aIt)->SetPixelPosX( nMaxPos + 42 ); ! (*aIt)->Hide(); ! } ++aIt; } } *************** *** 1276,1285 **** { if( pEdit ) { ! DeactivateCell(); ! MakeFieldVisible( GetCurRow(), static_cast< sal_uInt16 >( pEdit->getStartColumn()), true /* bComplete */ ); ! ActivateCell(); ! m_aCursorMovedHdlLink.Call( this ); } return 0; } --- 1345,1361 ---- { if( pEdit ) { ! pEdit->bShowWarningBox = !m_bDataValid; ! ! if( !m_bDataValid ) ! GoToCell( 0, 0 ); ! else ! { ! //DeactivateCell(); ! MakeFieldVisible( GetCurRow(), static_cast< sal_uInt16 >( pEdit->getStartColumn()), true /* bComplete */ ); ! ActivateCell(); ! m_aCursorMovedHdlLink.Call( this ); ! } } return 0; } *** orig/chart2/source/controller/dialogs/DataBrowser.hxx Tue Sep 18 22:53:14 2007 --- new/chart2/source/controller/dialogs/DataBrowser.hxx Tue Nov 27 10:05:23 2007 *************** *** 87,92 **** --- 87,93 ---- virtual void CellModified(); virtual void ColumnResized( USHORT nColId ); virtual void EndScroll(); + virtual void MouseButtonDown( const BrowserMouseEvent& rEvt ); void SetDirty(); *************** *** 149,154 **** --- 150,156 ---- void RemoveColumn(); using BrowseBox::RemoveColumn; + using BrowseBox::MouseButtonDown; void SwapRow(); void SwapColumn(); *************** *** 166,172 **** void SetCellModifiedHdl( const Link& rLink ); /// confirms all pending changes to be ready to be closed ! void EndEditing(); // calls the protected inline-function BrowseBox::GetFirstVisibleColNumber() sal_Int16 GetFirstVisibleColumNumber() const; --- 168,174 ---- void SetCellModifiedHdl( const Link& rLink ); /// confirms all pending changes to be ready to be closed ! bool EndEditing(); // calls the protected inline-function BrowseBox::GetFirstVisibleColNumber() sal_Int16 GetFirstVisibleColumNumber() const; *************** *** 177,182 **** --- 179,188 ---- sal_uInt32 GetNumberFormatKey( sal_Int32 nRow, sal_uInt16 nCol ) const; + bool IsEnableItem(); + bool IsDataValid(); + void ShowWarningBox(); + private: ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > m_xChartDoc; *************** *** 192,197 **** --- 198,204 ---- 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 Wed May 23 01:32:56 2007 --- new/chart2/source/controller/dialogs/dlg_DataEditor.cxx Tue Nov 27 10:12:11 2007 *************** *** 93,99 **** m_xChartDoc( xChartDoc ), m_xContext( xContext ), m_aToolboxImageList( SchResId( IL_DIAGRAM_DATA )), ! m_aToolboxImageListHighContrast( SchResId( IL_HC_DIAGRAM_DATA )) { FreeResource(); --- 93,101 ---- m_xChartDoc( xChartDoc ), m_xContext( xContext ), m_aToolboxImageList( SchResId( IL_DIAGRAM_DATA )), ! m_aToolboxImageListHighContrast( SchResId( IL_HC_DIAGRAM_DATA )), ! aBtnOK( this, SchResId( BTN_OK )), ! aBtnCancel( this, SchResId( BTN_CANCEL )) { FreeResource(); *************** *** 138,143 **** --- 140,146 ---- aWinSize.setWidth( nWindowWidth ); SetOutputSizePixel( aWinSize ); AdaptBrowseBoxSize(); + AdaptButtonPosition(); // ImplAdjustHeaderControls( false /* bRefreshFromModel */ ); *************** *** 204,217 **** 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() ); ! ! 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_SORT_COL, m_apBrwData->MaySortColumn() ); // m_aTbxData.EnableItem( TBI_DATA_SORT_ROW, m_apBrwData->MaySortRow() ); // m_aTbxData.EnableItem( TBI_DATA_SORT_TABLE_COL, m_apBrwData->MaySortColumn() ); --- 207,231 ---- if( m_bReadOnly ) return 0; ! 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() ); ! aBtnOK.Enable(); ! } ! 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 ); ! aBtnOK.Disable(); ! } // m_aTbxData.EnableItem( TBI_DATA_SORT_COL, m_apBrwData->MaySortColumn() ); // m_aTbxData.EnableItem( TBI_DATA_SORT_ROW, m_apBrwData->MaySortRow() ); // m_aTbxData.EnableItem( TBI_DATA_SORT_TABLE_COL, m_apBrwData->MaySortColumn() ); *************** *** 338,365 **** Size aSize( PixelToLogic( GetResizeOutputSizePixel(), MAP_APPFONT )); Size aDataSize; ! aDataSize.setWidth( aSize.getWidth() - 12 ); aDataSize.setHeight( aSize.getHeight() - 31 -24 ); m_apBrwData->SetSizePixel( LogicToPixel( aDataSize, MAP_APPFONT )); } void DataEditor::Resize() { Dialog::Resize(); AdaptBrowseBoxSize(); // ImplAdjustHeaderControls( false /* bRefreshFromModel */ ); } ! BOOL DataEditor::Close() ! { ! ApplyChangesToModel(); ! return ModalDialog::Close(); ! } ! ! void DataEditor::ApplyChangesToModel() { ! m_apBrwData->EndEditing(); } // sets the correct toolbar icons depending on the current mode (e.g. high contrast) --- 352,388 ---- Size aSize( PixelToLogic( GetResizeOutputSizePixel(), MAP_APPFONT )); Size aDataSize; ! aDataSize.setWidth( aSize.getWidth() - 70 ); aDataSize.setHeight( aSize.getHeight() - 31 -24 ); m_apBrwData->SetSizePixel( LogicToPixel( aDataSize, MAP_APPFONT )); } + void DataEditor::AdaptButtonPosition() + { + Size aSize( PixelToLogic( GetResizeOutputSizePixel(), MAP_APPFONT )); + + Point aBtnOKPos, aBtnCancelPos; + aBtnOKPos.setX( aSize.getWidth() - 56 ); + aBtnOKPos.setY( 6 ); + aBtnCancelPos.setX( aBtnOKPos.getX() ); + aBtnCancelPos.setY( aBtnOKPos.getY() + 18 ); + + aBtnOK.SetPosPixel( LogicToPixel( aBtnOKPos, MAP_APPFONT ) ); + aBtnCancel.SetPosPixel( LogicToPixel( aBtnCancelPos, MAP_APPFONT ) ); + } + void DataEditor::Resize() { Dialog::Resize(); AdaptBrowseBoxSize(); + AdaptButtonPosition(); // ImplAdjustHeaderControls( false /* bRefreshFromModel */ ); } ! bool DataEditor::ApplyChangesToModel() { ! return m_apBrwData->EndEditing(); } // sets the correct toolbar icons depending on the current mode (e.g. high contrast) *** orig/chart2/source/controller/dialogs/dlg_DataEditor.hrc Wed May 23 01:33:06 2007 --- new/chart2/source/controller/dialogs/dlg_DataEditor.hrc Tue Nov 27 10:07:30 2007 *************** *** 58,60 **** --- 58,64 ---- // image lists (normal and high-contrast) for toolbox #define IL_DIAGRAM_DATA 1 #define IL_HC_DIAGRAM_DATA 2 + + #define BTN_OK 1 + #define BTN_CANCEL 2 + #define BTN_HELP 3 *** orig/chart2/source/controller/dialogs/dlg_DataEditor.src Wed May 23 01:33:16 2007 --- new/chart2/source/controller/dialogs/dlg_DataEditor.src Tue Nov 27 10:07:42 2007 *************** *** 36,41 **** --- 36,42 ---- #include "dlg_DataEditor.hrc" #include "SchSlotIds.hxx" #include "HelpIds.hrc" + #include "CommonResources.hrc" // Mask Color for standard images #define IMAGE_BUTTON_STD_MASK_COLOR Color { Red = 0xff00; Green = 0x0000; Blue = 0xff00; } *************** *** 51,57 **** Hide = TRUE ; SVLook = TRUE ; Pos = MAP_APPFONT ( 0 , 0 ) ; ! Size = MAP_APPFONT ( 244 , 152 ) ; Text [ en-US ] = "Data Table"; --- 52,60 ---- Hide = TRUE ; SVLook = TRUE ; Pos = MAP_APPFONT ( 0 , 0 ) ; ! Size = MAP_APPFONT ( 300 , 152 ) ; ! ! BUTTONS_OK_CANCEL_HELP_STACKED( 244 ) Text [ en-US ] = "Data Table"; *** orig/chart2/source/controller/inc/dlg_DataEditor.hxx Wed May 23 01:58:22 2007 --- new/chart2/source/controller/inc/dlg_DataEditor.hxx Tue Nov 27 10:08:10 2007 *************** *** 51,56 **** --- 51,59 ---- #ifndef _SV_DIALOG_HXX #include #endif + #ifndef _SV_BUTTON_HXX + #include + #endif #ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_ #include *************** *** 82,92 **** // Window virtual void Resize(); - // Dialog - virtual BOOL Close(); - void SetReadOnly( bool bReadOnly ); ! void ApplyChangesToModel(); private: bool m_bReadOnly; --- 85,92 ---- // Window virtual void Resize(); void SetReadOnly( bool bReadOnly ); ! bool ApplyChangesToModel(); private: bool m_bReadOnly; *************** *** 135,140 **** --- 135,145 ---- ::comphelper::mem_fun1_t< TaskPaneList, Window* > rMemFunc ); void AdaptBrowseBoxSize(); + + void AdaptButtonPosition(); + + OKButton aBtnOK; + CancelButton aBtnCancel; }; } // namespace chart *** orig/chart2/source/controller/main/ChartController_EditData.cxx Fri Nov 16 14:44:49 2007 --- new/chart2/source/controller/main/ChartController_EditData.cxx Tue Nov 27 10:11:56 2007 *************** *** 79,97 **** Reference< ::com::sun::star::chart2::data::XDataProvider > xDataProvider( xChartDoc->getDataProvider()); { // /-- ! ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); ! // using assignment for broken gcc 3.3 ! UndoLiveUpdateGuardWithData aUndoGuard = UndoLiveUpdateGuardWithData( ! ::rtl::OUString( String( SchResId( STR_ACTION_EDIT_CHART_DATA ))), ! m_xUndoManager, m_aModel->getModel()); DataEditor aDataEditorDialog( pParent, xChartDoc, m_xCC ); ! // the dialog has no OK/Cancel ! aDataEditorDialog.Execute(); ! aUndoGuard.commitAction(); // \-- } } } --- 79,106 ---- Reference< ::com::sun::star::chart2::data::XDataProvider > xDataProvider( xChartDoc->getDataProvider()); + // using assignment for broken gcc 3.3 + UndoLiveUpdateGuardWithData aUndoGuard = UndoLiveUpdateGuardWithData( + ::rtl::OUString( String( SchResId( STR_ACTION_EDIT_CHART_DATA ))), + m_xUndoManager, m_aModel->getModel()); + + try { // /-- ! ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); DataEditor aDataEditorDialog( pParent, xChartDoc, m_xCC ); ! if( aDataEditorDialog.Execute() == RET_OK ) ! { ! bool bChanged = aDataEditorDialog.ApplyChangesToModel(); ! if( bChanged ) ! aUndoGuard.commitAction(); ! } // \-- } + catch( uno::RuntimeException& e) + { + ASSERT_EXCEPTION( e ); + } } }