summaryrefslogtreecommitdiff
path: root/svx/source/fmcomp/gridcell.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'svx/source/fmcomp/gridcell.cxx')
-rw-r--r--svx/source/fmcomp/gridcell.cxx294
1 files changed, 195 insertions, 99 deletions
diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx
index 67a17de94699..fd2b83fe9040 100644
--- a/svx/source/fmcomp/gridcell.cxx
+++ b/svx/source/fmcomp/gridcell.cxx
@@ -802,16 +802,12 @@ void DbCellControl::implAdjustReadOnly( const Reference< XPropertySet >& _rxMode
if ( !(m_pWindow && _rxModel.is()) )
return;
- ControlBase* pEditWindow = dynamic_cast<ControlBase*>(m_pWindow.get());
- if ( pEditWindow )
+ bool bReadOnly = m_rColumn.IsReadOnly();
+ if ( !bReadOnly )
{
- bool bReadOnly = m_rColumn.IsReadOnly();
- if ( !bReadOnly )
- {
- _rxModel->getPropertyValue( i_bReadOnly ? OUString(FM_PROP_READONLY) : OUString(FM_PROP_ISREADONLY)) >>= bReadOnly;
- }
- pEditWindow->SetEditableReadOnly(bReadOnly);
+ _rxModel->getPropertyValue( i_bReadOnly ? OUString(FM_PROP_READONLY) : OUString(FM_PROP_ISREADONLY)) >>= bReadOnly;
}
+ m_pWindow->SetEditableReadOnly(bReadOnly);
}
void DbCellControl::implAdjustEnabled( const Reference< XPropertySet >& _rxModel )
@@ -1685,7 +1681,23 @@ void DbCheckBox::PaintFieldToCell(OutputDevice& rDev, const tools::Rectangle& rR
CheckBoxControl* pControl = static_cast<CheckBoxControl*>(m_pPainter.get());
lcl_setCheckBoxState( _rxField, pControl );
- Size aBoxSize = pControl->GetBox().get_preferred_size();
+ Size aBoxSize;
+
+ switch (rDev.GetOutDevType())
+ {
+ case OUTDEV_WINDOW:
+ case OUTDEV_VIRDEV:
+ aBoxSize = pControl->GetBox().get_preferred_size();
+ break;
+ case OUTDEV_PRINTER:
+ case OUTDEV_PDF:
+ {
+ auto nSize = std::min(rRect.GetWidth(), rRect.GetHeight());
+ aBoxSize = Size(nSize, nSize);
+ break;
+ }
+ }
+
tools::Rectangle aRect(Point(rRect.Left() + ((rRect.GetWidth() - aBoxSize.Width()) / 2),
rRect.Top() + ((rRect.GetHeight() - aBoxSize.Height()) / 2)),
aBoxSize);
@@ -1693,6 +1705,91 @@ void DbCheckBox::PaintFieldToCell(OutputDevice& rDev, const tools::Rectangle& rR
DbCellControl::PaintFieldToCell(rDev, aRect, _rxField, xFormatter);
}
+void DbCheckBox::PaintCell(OutputDevice& rDev, const tools::Rectangle& rRect)
+{
+ switch (rDev.GetOutDevType())
+ {
+ case OUTDEV_WINDOW:
+ case OUTDEV_VIRDEV:
+ DbCellControl::PaintCell(rDev, rRect);
+ break;
+ case OUTDEV_PRINTER:
+ case OUTDEV_PDF:
+ {
+ TriState eState = static_cast<CheckBoxControl*>(m_pWindow.get())->GetState();
+
+ MapMode aResMapMode(MapUnit::Map100thMM);
+ Size aImageSize = rDev.LogicToPixel(Size(300, 300), aResMapMode);
+ Size aBrd1Size = rDev.LogicToPixel(Size(20, 20), aResMapMode);
+ Size aBrd2Size = rDev.LogicToPixel(Size(30, 30), aResMapMode);
+ int nCheckWidth = rDev.LogicToPixel(Size(20, 20), aResMapMode).Width();
+
+ tools::Rectangle aStateRect;
+ aStateRect.SetLeft(rRect.Left() + ((rRect.GetWidth() - aImageSize.Width()) / 2));
+ aStateRect.SetTop(rRect.Top() + ((rRect.GetHeight() - aImageSize.Height()) / 2));
+ aStateRect.SetRight(aStateRect.Left() + aImageSize.Width() - 1);
+ aStateRect.SetBottom(aStateRect.Top() + aImageSize.Height() - 1);
+
+ rDev.Push();
+ rDev.SetMapMode();
+
+ rDev.SetLineColor();
+ rDev.SetFillColor(COL_BLACK);
+ rDev.DrawRect(aStateRect);
+ aStateRect.AdjustLeft(aBrd1Size.Width());
+ aStateRect.AdjustTop(aBrd1Size.Height());
+ aStateRect.AdjustRight(-aBrd1Size.Width());
+ aStateRect.AdjustBottom(-aBrd1Size.Height());
+ if (eState == TRISTATE_INDET)
+ rDev.SetFillColor(COL_LIGHTGRAY);
+ else
+ rDev.SetFillColor(COL_WHITE);
+ rDev.DrawRect(aStateRect);
+
+ if (eState == TRISTATE_TRUE)
+ {
+ aStateRect.AdjustLeft(aBrd2Size.Width());
+ aStateRect.AdjustTop(aBrd2Size.Height());
+ aStateRect.AdjustRight(-aBrd2Size.Width());
+ aStateRect.AdjustBottom(-aBrd2Size.Height());
+ Point aPos11(aStateRect.TopLeft());
+ Point aPos12(aStateRect.BottomRight());
+ Point aPos21(aStateRect.TopRight());
+ Point aPos22(aStateRect.BottomLeft());
+ Point aTempPos11(aPos11);
+ Point aTempPos12(aPos12);
+ Point aTempPos21(aPos21);
+ Point aTempPos22(aPos22);
+ rDev.SetLineColor(COL_BLACK);
+ int nDX = 0;
+ for (int i = 0; i < nCheckWidth; i++)
+ {
+ if ( !(i % 2) )
+ {
+ aTempPos11.setX(aPos11.X() + nDX);
+ aTempPos12.setX(aPos12.X() + nDX);
+ aTempPos21.setX(aPos21.X() + nDX);
+ aTempPos22.setX(aPos22.X() + nDX);
+ }
+ else
+ {
+ nDX++;
+ aTempPos11.setX(aPos11.X() - nDX);
+ aTempPos12.setX(aPos12.X() - nDX);
+ aTempPos21.setX(aPos21.X() - nDX);
+ aTempPos22.setX(aPos22.X() - nDX);
+ }
+ rDev.DrawLine(aTempPos11, aTempPos12);
+ rDev.DrawLine(aTempPos21, aTempPos22);
+ }
+ }
+
+ rDev.Pop();
+ break;
+ }
+ }
+}
+
void DbCheckBox::updateFromModel( Reference< XPropertySet > _rxModel )
{
OSL_ENSURE( _rxModel.is() && m_pWindow, "DbCheckBox::updateFromModel: invalid call!" );
@@ -1921,7 +2018,7 @@ void DbNumericField::implAdjustGenericFieldSetting( const Reference< XPropertySe
rPaintFormatter.SetFormat( sFormatString, aAppLanguage );
}
-VclPtr<Control> DbNumericField::createField(BrowserDataWin* pParent, bool bSpinButton, const Reference<XPropertySet>& /*rxModel*/)
+VclPtr<svt::ControlBase> DbNumericField::createField(BrowserDataWin* pParent, bool bSpinButton, const Reference<XPropertySet>& /*rxModel*/)
{
return VclPtr<DoubleNumericControl>::Create(pParent, bSpinButton);
}
@@ -2041,7 +2138,7 @@ void DbCurrencyField::implAdjustGenericFieldSetting( const Reference< XPropertyS
rPaintCurrencyFormatter.SetCurrencySymbol(aStr);
}
-VclPtr<Control> DbCurrencyField::createField(BrowserDataWin* pParent, bool bSpinButton, const Reference< XPropertySet >& /*rxModel*/)
+VclPtr<svt::ControlBase> DbCurrencyField::createField(BrowserDataWin* pParent, bool bSpinButton, const Reference< XPropertySet >& /*rxModel*/)
{
return VclPtr<LongCurrencyControl>::Create(pParent, bSpinButton);
}
@@ -2124,7 +2221,7 @@ DbDateField::DbDateField( DbGridColumn& _rColumn )
doPropertyListening( FM_PROP_DATE_SHOW_CENTURY );
}
-VclPtr<Control> DbDateField::createField(BrowserDataWin* pParent, bool bSpinButton, const Reference< XPropertySet >& rxModel)
+VclPtr<svt::ControlBase> DbDateField::createField(BrowserDataWin* pParent, bool bSpinButton, const Reference< XPropertySet >& rxModel)
{
// check if there is a DropDown property set to TRUE
bool bDropDown = !hasProperty( FM_PROP_DROPDOWN, rxModel )
@@ -2250,7 +2347,7 @@ DbTimeField::DbTimeField( DbGridColumn& _rColumn )
doPropertyListening( FM_PROP_STRICTFORMAT );
}
-VclPtr<Control> DbTimeField::createField(BrowserDataWin* pParent, bool bSpinButton, const Reference< XPropertySet >& /*rxModel*/ )
+VclPtr<svt::ControlBase> DbTimeField::createField(BrowserDataWin* pParent, bool bSpinButton, const Reference< XPropertySet >& /*rxModel*/ )
{
return VclPtr<TimeControl>::Create(pParent, bSpinButton);
}
@@ -2446,8 +2543,13 @@ void DbComboBox::updateFromModel( Reference< XPropertySet > _rxModel )
ComboBoxControl* pControl = static_cast<ComboBoxControl*>(m_pWindow.get());
weld::ComboBox& rComboBox = pControl->get_widget();
+
+ OUString sOldActive = rComboBox.get_active_text();
rComboBox.set_entry_text(sText);
rComboBox.select_entry_region(0, -1);
+
+ if (sOldActive != rComboBox.get_active_text())
+ pControl->TriggerAuxModify();
}
bool DbComboBox::commitControl()
@@ -2578,12 +2680,17 @@ void DbListBox::updateFromModel( Reference< XPropertySet > _rxModel )
if ( aSelection.hasElements() )
nSelection = aSelection[ 0 ];
- weld::ComboBox& rComboBox = static_cast<ListBoxControl*>(m_pWindow.get())->get_widget();
+ ListBoxControl* pControl = static_cast<ListBoxControl*>(m_pWindow.get());
+ weld::ComboBox& rComboBox = pControl->get_widget();
+ int nOldActive = rComboBox.get_active();
if (nSelection >= 0 && nSelection < rComboBox.get_count())
rComboBox.set_active(nSelection);
else
rComboBox.set_active(-1);
+
+ if (nOldActive != rComboBox.get_active())
+ pControl->TriggerAuxModify();
}
bool DbListBox::commitControl()
@@ -2753,9 +2860,8 @@ void DbFilterField::Init(BrowserDataWin& rParent, const Reference< XRowSet >& xC
DbCellControl::Init( rParent, xCursor );
// filter cells are never readonly
- ControlBase* pAsEdit = dynamic_cast<ControlBase*>(m_pWindow.get());
- if (pAsEdit)
- pAsEdit->SetEditableReadOnly(false);
+ if (m_pWindow)
+ m_pWindow->SetEditableReadOnly(false);
}
CellControllerRef DbFilterField::CreateController() const
@@ -2785,7 +2891,7 @@ void DbFilterField::updateFromModel( Reference< XPropertySet > _rxModel )
{
OSL_ENSURE( _rxModel.is() && m_pWindow, "DbFilterField::updateFromModel: invalid call!" );
- OSL_FAIL( "DbListBox::updateFromModel: not implemented yet (how the hell did you reach this?)!" );
+ OSL_FAIL( "DbFilterField::updateFromModel: not implemented yet (how the hell did you reach this?)!" );
// TODO: implement this.
// remember: updateFromModel should be some kind of opposite of commitControl
}
@@ -3079,7 +3185,6 @@ IMPL_LINK_NOARG(DbFilterField, OnClick, weld::Button&, void)
}
}
-
FmXGridCell::FmXGridCell( DbGridColumn* pColumn, std::unique_ptr<DbCellControl> _pControl )
:OComponentHelper(m_aMutex)
,m_pColumn(pColumn)
@@ -3092,23 +3197,27 @@ FmXGridCell::FmXGridCell( DbGridColumn* pColumn, std::unique_ptr<DbCellControl>
{
}
-
void FmXGridCell::init()
{
- vcl::Window* pEventWindow( getEventWindow() );
+ svt::ControlBase* pEventWindow( getEventWindow() );
if ( pEventWindow )
+ {
pEventWindow->AddEventListener( LINK( this, FmXGridCell, OnWindowEvent ) );
+ pEventWindow->SetFocusInHdl(LINK( this, FmXGridCell, OnFocusGained));
+ pEventWindow->SetFocusOutHdl(LINK( this, FmXGridCell, OnFocusLost));
+ pEventWindow->SetMousePressHdl(LINK( this, FmXGridCell, OnMousePress));
+ pEventWindow->SetMouseReleaseHdl(LINK( this, FmXGridCell, OnMouseRelease));
+ pEventWindow->SetMouseMoveHdl(LINK( this, FmXGridCell, OnMouseMove));
+ }
}
-
-vcl::Window* FmXGridCell::getEventWindow() const
+svt::ControlBase* FmXGridCell::getEventWindow() const
{
if ( m_pCellControl )
return &m_pCellControl->GetWindow();
return nullptr;
}
-
FmXGridCell::~FmXGridCell()
{
if (!OComponentHelper::rBHelper.bDisposed)
@@ -3119,14 +3228,12 @@ FmXGridCell::~FmXGridCell()
}
-
void FmXGridCell::SetTextLineColor()
{
if (m_pCellControl)
m_pCellControl->SetTextLineColor();
}
-
void FmXGridCell::SetTextLineColor(const Color& _rColor)
{
if (m_pCellControl)
@@ -3322,113 +3429,102 @@ void SAL_CALL FmXGridCell::removeMouseMotionListener( const Reference< awt::XMou
m_aMouseMotionListeners.removeInterface( _rxListener );
}
-
void SAL_CALL FmXGridCell::addPaintListener( const Reference< awt::XPaintListener >& )
{
OSL_FAIL( "FmXGridCell::addPaintListener: not implemented" );
}
-
void SAL_CALL FmXGridCell::removePaintListener( const Reference< awt::XPaintListener >& )
{
OSL_FAIL( "FmXGridCell::removePaintListener: not implemented" );
}
-
IMPL_LINK( FmXGridCell, OnWindowEvent, VclWindowEvent&, _rEvent, void )
{
ENSURE_OR_THROW( _rEvent.GetWindow(), "illegal window" );
- onWindowEvent( _rEvent.GetId(), *_rEvent.GetWindow(), _rEvent.GetData() );
+ onWindowEvent(_rEvent.GetId(), _rEvent.GetData());
}
-
void FmXGridCell::onFocusGained( const awt::FocusEvent& _rEvent )
{
checkDisposed(OComponentHelper::rBHelper.bDisposed);
m_aFocusListeners.notifyEach( &awt::XFocusListener::focusGained, _rEvent );
}
-
void FmXGridCell::onFocusLost( const awt::FocusEvent& _rEvent )
{
checkDisposed(OComponentHelper::rBHelper.bDisposed);
m_aFocusListeners.notifyEach( &awt::XFocusListener::focusLost, _rEvent );
}
+IMPL_LINK_NOARG(FmXGridCell, OnFocusGained, LinkParamNone*, void)
+{
+ if (!m_aFocusListeners.getLength())
+ return;
+
+ awt::FocusEvent aEvent;
+ aEvent.Source = *this;
+ aEvent.Temporary = false;
+
+ onFocusGained(aEvent);
+}
-void FmXGridCell::onWindowEvent( const VclEventId _nEventId, const vcl::Window& _rWindow, const void* _pEventData )
+IMPL_LINK_NOARG(FmXGridCell, OnFocusLost, LinkParamNone*, void)
{
- switch ( _nEventId )
- {
- case VclEventId::ControlGetFocus:
- case VclEventId::WindowGetFocus:
- case VclEventId::ControlLoseFocus:
- case VclEventId::WindowLoseFocus:
- {
- if ( ( _rWindow.IsCompoundControl()
- && ( _nEventId == VclEventId::ControlGetFocus
- || _nEventId == VclEventId::ControlLoseFocus
- )
- )
- || ( !_rWindow.IsCompoundControl()
- && ( _nEventId == VclEventId::WindowGetFocus
- || _nEventId == VclEventId::WindowLoseFocus
- )
- )
- )
- {
- if ( !m_aFocusListeners.getLength() )
- break;
+ if (!m_aFocusListeners.getLength())
+ return;
- bool bFocusGained = ( _nEventId == VclEventId::ControlGetFocus ) || ( _nEventId == VclEventId::WindowGetFocus );
+ awt::FocusEvent aEvent;
+ aEvent.Source = *this;
+ aEvent.Temporary = false;
- awt::FocusEvent aEvent;
- aEvent.Source = *this;
- aEvent.FocusFlags = static_cast<sal_Int16>(_rWindow.GetGetFocusFlags());
- aEvent.Temporary = false;
+ onFocusLost(aEvent);
+}
- if ( bFocusGained )
- onFocusGained( aEvent );
- else
- onFocusLost( aEvent );
- }
- }
- break;
- case VclEventId::WindowMouseButtonDown:
- case VclEventId::WindowMouseButtonUp:
- {
- if ( !m_aMouseListeners.getLength() )
- break;
+IMPL_LINK(FmXGridCell, OnMousePress, const MouseEvent&, rEventData, void)
+{
+ if (!m_aMouseListeners.getLength())
+ return;
- const bool bButtonDown = ( _nEventId == VclEventId::WindowMouseButtonDown );
+ awt::MouseEvent aEvent(VCLUnoHelper::createMouseEvent(rEventData, *this));
+ m_aMouseListeners.notifyEach(&awt::XMouseListener::mousePressed, aEvent);
+}
- awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( *static_cast< const ::MouseEvent* >( _pEventData ), *this ) );
- m_aMouseListeners.notifyEach( bButtonDown ? &awt::XMouseListener::mousePressed : &awt::XMouseListener::mouseReleased, aEvent );
- }
- break;
- case VclEventId::WindowMouseMove:
+IMPL_LINK(FmXGridCell, OnMouseRelease, const MouseEvent&, rEventData, void)
+{
+ if (!m_aMouseListeners.getLength())
+ return;
+
+ awt::MouseEvent aEvent(VCLUnoHelper::createMouseEvent(rEventData, *this));
+ m_aMouseListeners.notifyEach(&awt::XMouseListener::mouseReleased, aEvent);
+}
+
+IMPL_LINK(FmXGridCell, OnMouseMove, const MouseEvent&, rMouseEvent, void)
+{
+ if ( rMouseEvent.IsEnterWindow() || rMouseEvent.IsLeaveWindow() )
{
- const MouseEvent& rMouseEvent = *static_cast< const ::MouseEvent* >( _pEventData );
- if ( rMouseEvent.IsEnterWindow() || rMouseEvent.IsLeaveWindow() )
+ if ( m_aMouseListeners.getLength() != 0 )
{
- if ( m_aMouseListeners.getLength() != 0 )
- {
- awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( rMouseEvent, *this ) );
- m_aMouseListeners.notifyEach( rMouseEvent.IsEnterWindow() ? &awt::XMouseListener::mouseEntered: &awt::XMouseListener::mouseExited, aEvent );
- }
+ awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( rMouseEvent, *this ) );
+ m_aMouseListeners.notifyEach( rMouseEvent.IsEnterWindow() ? &awt::XMouseListener::mouseEntered: &awt::XMouseListener::mouseExited, aEvent );
}
- else if ( !rMouseEvent.IsEnterWindow() && !rMouseEvent.IsLeaveWindow() )
+ }
+ else if ( !rMouseEvent.IsEnterWindow() && !rMouseEvent.IsLeaveWindow() )
+ {
+ if ( m_aMouseMotionListeners.getLength() != 0 )
{
- if ( m_aMouseMotionListeners.getLength() != 0 )
- {
- awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( rMouseEvent, *this ) );
- aEvent.ClickCount = 0;
- const bool bSimpleMove = bool( rMouseEvent.GetMode() & MouseEventModifiers::SIMPLEMOVE );
- m_aMouseMotionListeners.notifyEach( bSimpleMove ? &awt::XMouseMotionListener::mouseMoved: &awt::XMouseMotionListener::mouseDragged, aEvent );
- }
+ awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( rMouseEvent, *this ) );
+ aEvent.ClickCount = 0;
+ const bool bSimpleMove = bool( rMouseEvent.GetMode() & MouseEventModifiers::SIMPLEMOVE );
+ m_aMouseMotionListeners.notifyEach( bSimpleMove ? &awt::XMouseMotionListener::mouseMoved: &awt::XMouseMotionListener::mouseDragged, aEvent );
}
}
- break;
+}
+
+void FmXGridCell::onWindowEvent(const VclEventId _nEventId, const void* _pEventData)
+{
+ switch ( _nEventId )
+ {
case VclEventId::WindowKeyInput:
case VclEventId::WindowKeyUp:
{
@@ -3917,7 +4013,7 @@ void FmXListBoxCell::disposing()
m_aItemListeners.disposeAndClear(aEvt);
m_aActionListeners.disposeAndClear(aEvt);
- m_pBox->SetAuxModifyHdl(Link<LinkParamNone*,void>());
+ m_pBox->SetAuxModifyHdl(Link<bool,void>());
m_pBox = nullptr;
FmXTextCell::disposing();
@@ -4185,14 +4281,14 @@ void SAL_CALL FmXListBoxCell::makeVisible(sal_Int16 /*nEntry*/)
{
}
-IMPL_LINK_NOARG(FmXListBoxCell, ChangedHdl, LinkParamNone*, void)
+IMPL_LINK(FmXListBoxCell, ChangedHdl, bool, bInteractive, void)
{
if (!m_pBox)
return;
weld::ComboBox& rBox = m_pBox->get_widget();
- if (!rBox.changed_by_direct_pick())
+ if (bInteractive && !rBox.changed_by_direct_pick())
return;
OnDoubleClick();
@@ -4247,7 +4343,7 @@ void FmXComboBoxCell::disposing()
m_aItemListeners.disposeAndClear(aEvt);
m_aActionListeners.disposeAndClear(aEvt);
- m_pComboBox->SetAuxModifyHdl(Link<LinkParamNone*,void>());
+ m_pComboBox->SetAuxModifyHdl(Link<bool,void>());
m_pComboBox = nullptr;
FmXTextCell::disposing();
@@ -4375,14 +4471,14 @@ void SAL_CALL FmXComboBoxCell::setDropDownLineCount(sal_Int16 nLines)
m_nLines = nLines; // just store it to return it
}
-IMPL_LINK_NOARG(FmXComboBoxCell, ChangedHdl, LinkParamNone*, void)
+IMPL_LINK(FmXComboBoxCell, ChangedHdl, bool, bInteractive, void)
{
if (!m_pComboBox)
return;
weld::ComboBox& rComboBox = m_pComboBox->get_widget();
- if (!rComboBox.changed_by_direct_pick())
+ if (bInteractive && !rComboBox.changed_by_direct_pick())
return;
awt::ItemEvent aEvent;