LibreOffice Module svx (master) 1
gridcell.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
21#include <memory>
22#include <sal/log.hxx>
23#include <fmprop.hxx>
24#include <svx/strings.hrc>
25#include <svx/fmtools.hxx>
26#include <gridcell.hxx>
27#include <gridcols.hxx>
28#include <sdbdatacolumn.hxx>
29
30#include <com/sun/star/awt/LineEndFormat.hpp>
31#include <com/sun/star/awt/MouseWheelBehavior.hpp>
32#include <com/sun/star/awt/VisualEffect.hpp>
33#include <com/sun/star/container/XChild.hpp>
34#include <com/sun/star/container/XIndexAccess.hpp>
35#include <com/sun/star/form/FormComponentType.hpp>
36#include <com/sun/star/form/XBoundComponent.hpp>
37#include <com/sun/star/script/XEventAttacherManager.hpp>
38#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
39#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
40#include <com/sun/star/sdbc/DataType.hpp>
41#include <com/sun/star/sdbc/SQLException.hpp>
42#include <com/sun/star/sdbc/XRowSet.hpp>
43#include <com/sun/star/sdbc/XStatement.hpp>
44#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
45#include <com/sun/star/util/XNumberFormatter.hpp>
46#include <com/sun/star/util/Time.hpp>
47#include <com/sun/star/util/Date.hpp>
48
52#include <comphelper/string.hxx>
53#include <comphelper/types.hxx>
55#include <i18nlangtag/lang.h>
56#include <o3tl/safeint.hxx>
57#include <svl/numformat.hxx>
58#include <svl/numuno.hxx>
59#include <svx/dialmgr.hxx>
62#include <tools/debug.hxx>
63#include <tools/fract.hxx>
65#include <vcl/settings.hxx>
66#include <vcl/svapp.hxx>
70
71using namespace ::connectivity;
72using namespace ::svxform;
73using namespace ::comphelper;
74using namespace ::svt;
75using namespace ::com::sun::star;
76using namespace ::com::sun::star::uno;
77using namespace ::com::sun::star::sdbc;
78using namespace ::com::sun::star::sdbcx;
79using namespace ::com::sun::star::sdb;
80using namespace ::com::sun::star::beans;
81using namespace ::com::sun::star::form;
82using namespace ::dbtools::DBTypeConversion;
83using namespace ::dbtools;
84
85using ::com::sun::star::util::XNumberFormatter;
86
87constexpr OUStringLiteral INVALIDTEXT = u"###";
88constexpr OUStringLiteral OBJECTTEXT = u"<OBJECT>";
89
90
91//= helper
92
93namespace
94{
95 LineEnd getModelLineEndSetting( const Reference< XPropertySet >& _rxModel )
96 {
97 LineEnd eFormat = LINEEND_LF;
98
99 try
100 {
101 sal_Int16 nLineEndFormat = awt::LineEndFormat::LINE_FEED;
102
103 Reference< XPropertySetInfo > xPSI;
104 if ( _rxModel.is() )
105 xPSI = _rxModel->getPropertySetInfo();
106
107 OSL_ENSURE( xPSI.is(), "getModelLineEndSetting: invalid column model!" );
108 if ( xPSI.is() && xPSI->hasPropertyByName( FM_PROP_LINEENDFORMAT ) )
109 {
110 OSL_VERIFY( _rxModel->getPropertyValue( FM_PROP_LINEENDFORMAT ) >>= nLineEndFormat );
111
112 switch ( nLineEndFormat )
113 {
114 case awt::LineEndFormat::CARRIAGE_RETURN: eFormat = LINEEND_CR; break;
115 case awt::LineEndFormat::LINE_FEED: eFormat = LINEEND_LF; break;
116 case awt::LineEndFormat::CARRIAGE_RETURN_LINE_FEED: eFormat = LINEEND_CRLF; break;
117 default:
118 OSL_FAIL( "getModelLineEndSetting: what's this?" );
119 }
120 }
121 }
122 catch( const Exception& )
123 {
124 TOOLS_WARN_EXCEPTION( "svx", "getModelLineEndSetting" );
125 }
126 return eFormat;
127 }
128}
129
130
131//= DbGridColumn
132
133
135
136
137void DbGridColumn::CreateControl(sal_Int32 _nFieldPos, const Reference< css::beans::XPropertySet >& xField, sal_Int32 nTypeId)
138{
139 Clear();
140
141 m_nTypeId = static_cast<sal_Int16>(nTypeId);
142 if (xField != m_xField)
143 {
144 // initial setting
145 m_xField = xField;
146 xField->getPropertyValue(FM_PROP_FORMATKEY) >>= m_nFormatKey;
147 m_nFieldPos = static_cast<sal_Int16>(_nFieldPos);
148 m_bReadOnly = ::comphelper::getBOOL(xField->getPropertyValue(FM_PROP_ISREADONLY));
149 m_bAutoValue = ::comphelper::getBOOL(xField->getPropertyValue(FM_PROP_AUTOINCREMENT));
150 m_nFieldType = static_cast<sal_Int16>(::comphelper::getINT32(xField->getPropertyValue(FM_PROP_FIELDTYPE)));
151
152 switch (m_nFieldType)
153 {
154 case DataType::DATE:
155 case DataType::TIME:
156 case DataType::TIMESTAMP:
157 case DataType::BIT:
158 case DataType::BOOLEAN:
159 case DataType::TINYINT:
160 case DataType::SMALLINT:
161 case DataType::INTEGER:
162 case DataType::BIGINT:
163 case DataType::FLOAT:
164 case DataType::REAL:
165 case DataType::DOUBLE:
166 case DataType::NUMERIC:
167 case DataType::DECIMAL:
168 m_nAlign = css::awt::TextAlign::RIGHT;
169 m_bNumeric = true;
170 break;
171 default:
172 m_nAlign = css::awt::TextAlign::LEFT;
173 break;
174 }
175 }
176
177 std::unique_ptr<DbCellControl> pCellControl;
179 {
180 pCellControl.reset(new DbFilterField(m_rParent.getContext(),*this));
181 }
182 else
183 {
184
185 switch (nTypeId)
186 {
187 case TYPE_CHECKBOX: pCellControl.reset(new DbCheckBox(*this)); break;
188 case TYPE_COMBOBOX: pCellControl.reset(new DbComboBox(*this)); break;
189 case TYPE_CURRENCYFIELD: pCellControl.reset(new DbCurrencyField(*this)); break;
190 case TYPE_DATEFIELD: pCellControl.reset(new DbDateField(*this)); break;
191 case TYPE_LISTBOX: pCellControl.reset(new DbListBox(*this)); break;
192 case TYPE_NUMERICFIELD: pCellControl.reset(new DbNumericField(*this)); break;
193 case TYPE_PATTERNFIELD: pCellControl.reset(new DbPatternField( *this, m_rParent.getContext() )); break;
194 case TYPE_TEXTFIELD: pCellControl.reset(new DbTextField(*this)); break;
195 case TYPE_TIMEFIELD: pCellControl.reset(new DbTimeField(*this)); break;
196 case TYPE_FORMATTEDFIELD: pCellControl.reset(new DbFormattedField(*this)); break;
197 default:
198 OSL_FAIL("DbGridColumn::CreateControl: Unknown Column");
199 return;
200 }
201
202 }
203 Reference< XRowSet > xCur;
205 xCur.set(Reference< XInterface >(*m_rParent.getDataSource()), UNO_QUERY);
206 // TODO : the cursor wrapper should use an XRowSet interface, too
207
208 pCellControl->Init( m_rParent.GetDataWindow(), xCur );
209
210 // now create the control wrapper
211 auto pTempCellControl = pCellControl.get();
213 m_pCell = new FmXFilterCell(this, std::unique_ptr<DbFilterField>(static_cast<DbFilterField*>(pCellControl.release())));
214 else
215 {
216 switch (nTypeId)
217 {
218 case TYPE_CHECKBOX: m_pCell = new FmXCheckBoxCell( this, std::move(pCellControl) ); break;
219 case TYPE_LISTBOX: m_pCell = new FmXListBoxCell( this, std::move(pCellControl) ); break;
220 case TYPE_COMBOBOX: m_pCell = new FmXComboBoxCell( this, std::move(pCellControl) ); break;
221 default:
222 m_pCell = new FmXEditCell( this, std::move(pCellControl) );
223 }
224 }
225 m_pCell->init();
226
228
229 // only if we use have a bound field, we use a controller for displaying the
230 // window in the grid
231 if (m_xField.is())
232 m_xController = pTempCellControl->CreateController();
233}
234
235
237{
238 try
239 {
240 Reference< container::XChild > xChild( m_xModel, UNO_QUERY_THROW );
241 Reference< script::XEventAttacherManager > xManager( xChild->getParent(), UNO_QUERY_THROW );
242 Reference< container::XIndexAccess > xContainer( xChild->getParent(), UNO_QUERY_THROW );
243
244 sal_Int32 nIndexInParent( getElementPos( xContainer, m_xModel ) );
245
246 Reference< XInterface > xCellInterface( *m_pCell, UNO_QUERY );
247 if ( _bAttach )
248 xManager->attach( nIndexInParent, xCellInterface, Any( xCellInterface ) );
249 else
250 xManager->detach( nIndexInParent, xCellInterface );
251 }
252 catch( const Exception& )
253 {
255 }
256}
257
258void DbGridColumn::UpdateFromField(const DbGridRow* pRow, const Reference< XNumberFormatter >& xFormatter)
259{
260 if (FmXFilterCell* pCell = dynamic_cast<FmXFilterCell*>(m_pCell.get()))
261 pCell->Update();
262 else if (pRow && pRow->IsValid() && m_nFieldPos >= 0 && m_pCell.is() && pRow->HasField(m_nFieldPos))
263 {
264 dynamic_cast<FmXDataCell&>(*m_pCell).UpdateFromField( pRow->GetField( m_nFieldPos ).getColumn(), xFormatter );
265 }
266}
267
269{
270 bool bResult = true;
271 if (!m_bInSave && m_pCell.is())
272 {
273 m_bInSave = true;
274 bResult = m_pCell->Commit();
275
276 // store the data into the model
277 FmXDataCell* pDataCell = dynamic_cast<FmXDataCell*>( m_pCell.get() );
278 if (bResult && pDataCell)
279 {
280 Reference< css::form::XBoundComponent > xComp(m_xModel, UNO_QUERY);
281 if (xComp.is())
282 bResult = xComp->commit();
283 }
284 m_bInSave = false;
285 }
286 return bResult;
287}
288
290{
291 Clear();
292}
293
294void DbGridColumn::setModel(const css::uno::Reference< css::beans::XPropertySet >& _xModel)
295{
296 if ( m_pCell.is() )
298
299 m_xModel = _xModel;
300
301 if ( m_pCell.is() )
303}
304
305
307{
308 if ( m_pCell.is() )
309 {
311
312 m_pCell->dispose();
313 m_pCell.clear();
314 }
315
316 m_xController = nullptr;
317 m_xField = nullptr;
318
319 m_nFormatKey = 0;
320 m_nFieldPos = -1;
321 m_bReadOnly = true;
322 m_bAutoValue = false;
323 m_nFieldType = DataType::OTHER;
324}
325
326
327sal_Int16 DbGridColumn::SetAlignment(sal_Int16 _nAlign)
328{
329 if (_nAlign == -1)
330 { // 'Standard'
331 if (m_xField.is())
332 {
333 sal_Int32 nType = 0;
334 m_xField->getPropertyValue(FM_PROP_FIELDTYPE) >>= nType;
335
336 switch (nType)
337 {
338 case DataType::NUMERIC:
339 case DataType::DECIMAL:
340 case DataType::DOUBLE:
341 case DataType::REAL:
342 case DataType::BIGINT:
343 case DataType::INTEGER:
344 case DataType::SMALLINT:
345 case DataType::TINYINT:
346 case DataType::DATE:
347 case DataType::TIME:
348 case DataType::TIMESTAMP:
349 _nAlign = css::awt::TextAlign::RIGHT;
350 break;
351 case DataType::BIT:
352 case DataType::BOOLEAN:
353 _nAlign = css::awt::TextAlign::CENTER;
354 break;
355 default:
356 _nAlign = css::awt::TextAlign::LEFT;
357 break;
358 }
359 }
360 else
361 _nAlign = css::awt::TextAlign::LEFT;
362 }
363
364 m_nAlign = _nAlign;
365 if (m_pCell.is() && m_pCell->isAlignedController())
366 m_pCell->AlignControl(m_nAlign);
367
368 return m_nAlign;
369}
370
371
372sal_Int16 DbGridColumn::SetAlignmentFromModel(sal_Int16 nStandardAlign)
373{
374 Any aAlign( m_xModel->getPropertyValue(FM_PROP_ALIGN));
375 if (aAlign.hasValue())
376 {
377 sal_Int16 nTest = sal_Int16();
378 if (aAlign >>= nTest)
379 nStandardAlign = nTest;
380 }
381 return SetAlignment(nStandardAlign);
382}
383
384
385void DbGridColumn::setLock(bool _bLock)
386{
387 if (m_bLocked == _bLock)
388 return;
389 m_bLocked = _bLock;
390
391 // is the column we represent active ?
392 if (m_bHidden)
393 return; // no, it isn't (or at least it shouldn't be ...)
394
396 {
399 }
400}
401
402
403OUString DbGridColumn::GetCellText(const DbGridRow* pRow, const Reference< XNumberFormatter >& xFormatter) const
404{
405 OUString aText;
406 if (m_pCell.is() && dynamic_cast<const FmXFilterCell*>( m_pCell.get() ) != nullptr)
407 return aText;
408
409 if (!pRow || !pRow->IsValid())
410 aText = INVALIDTEXT;
411 else if (pRow->HasField(m_nFieldPos))
412 {
413 aText = GetCellText( pRow->GetField( m_nFieldPos ).getColumn(), xFormatter );
414 }
415 return aText;
416}
417
418OUString DbGridColumn::GetCellText(const Reference< css::sdb::XColumn >& xField, const Reference< XNumberFormatter >& xFormatter) const
419{
420 OUString aText;
421 if (xField.is())
422 {
423 FmXTextCell* pTextCell = dynamic_cast<FmXTextCell*>( m_pCell.get() );
424 if (pTextCell)
425 aText = pTextCell->GetText(xField, xFormatter);
426 else if (m_bObject)
427 aText = OBJECTTEXT;
428 }
429 return aText;
430}
431
432Reference< css::sdb::XColumn > DbGridColumn::GetCurrentFieldValue() const
433{
434 Reference< css::sdb::XColumn > xField;
435 const DbGridRowRef xRow = m_rParent.GetCurrentRow();
436 if (xRow.is() && xRow->HasField(m_nFieldPos))
437 {
438 xField = xRow->GetField(m_nFieldPos).getColumn();
439 }
440 return xField;
441}
442
443
445 const tools::Rectangle& rRect,
446 const DbGridRow* pRow,
447 const Reference< XNumberFormatter >& xFormatter)
448{
449 bool bEnabled = ( rDev.GetOutDevType() != OUTDEV_WINDOW )
450 || ( rDev.GetOwnerWindow()->IsEnabled() );
451
452 FmXDataCell* pDataCell = dynamic_cast<FmXDataCell*>( m_pCell.get() );
453 if (pDataCell)
454 {
455 if (!pRow || !pRow->IsValid())
456 {
457 DrawTextFlags nStyle = DrawTextFlags::Clip | DrawTextFlags::Center;
458 if ( !bEnabled )
459 nStyle |= DrawTextFlags::Disable;
460
461 rDev.DrawText(rRect, OUString(INVALIDTEXT), nStyle);
462 }
463 else if (m_bAutoValue && pRow->IsNew())
464 {
465 DrawTextFlags nStyle = DrawTextFlags::Clip | DrawTextFlags::VCenter;
466 if ( !bEnabled )
467 nStyle |= DrawTextFlags::Disable;
468
469 switch (GetAlignment())
470 {
471 case css::awt::TextAlign::RIGHT:
472 nStyle |= DrawTextFlags::Right;
473 break;
474 case css::awt::TextAlign::CENTER:
475 nStyle |= DrawTextFlags::Center;
476 break;
477 default:
478 nStyle |= DrawTextFlags::Left;
479 }
480
481 rDev.DrawText(rRect, SvxResId(RID_STR_AUTOFIELD), nStyle);
482 }
483 else if (pRow->HasField(m_nFieldPos))
484 {
485 pDataCell->PaintFieldToCell(rDev, rRect, pRow->GetField( m_nFieldPos ).getColumn(), xFormatter);
486 }
487 }
488 else if (!m_pCell.is())
489 {
490 if (!pRow || !pRow->IsValid())
491 {
492 DrawTextFlags nStyle = DrawTextFlags::Clip | DrawTextFlags::Center;
493 if ( !bEnabled )
494 nStyle |= DrawTextFlags::Disable;
495
496 rDev.DrawText(rRect, OUString(INVALIDTEXT), nStyle);
497 }
498 else if (pRow->HasField(m_nFieldPos) && m_bObject)
499 {
500 DrawTextFlags nStyle = DrawTextFlags::Clip | DrawTextFlags::Center;
501 if ( !bEnabled )
502 nStyle |= DrawTextFlags::Disable;
503 rDev.DrawText(rRect, OUString(OBJECTTEXT), nStyle);
504 }
505 }
506 else if ( auto pFilterCell = dynamic_cast<FmXFilterCell*>( m_pCell.get() ) )
507 pFilterCell->PaintCell( rDev, rRect );
508}
509
510
511void DbGridColumn::ImplInitWindow( vcl::Window const & rParent, const InitWindowFacet _eInitWhat )
512{
513 if ( m_pCell.is() )
514 m_pCell->ImplInitWindow( rParent, _eInitWhat );
515}
516
517
518//= cell controls
519
520
522 :OPropertyChangeListener(m_aMutex)
523 ,m_bTransparent( false )
524 ,m_bAlignedController( true )
525 ,m_bAccessingValueProperty( false )
526 ,m_rColumn( _rColumn )
527 ,m_pPainter( nullptr )
528 ,m_pWindow( nullptr )
529{
530 Reference< XPropertySet > xColModelProps = _rColumn.getModel();
531 if ( !xColModelProps.is() )
532 return;
533
534 // if our model's format key changes we want to propagate the new value to our windows
535 m_pModelChangeBroadcaster = new ::comphelper::OPropertyChangeMultiplexer(this, _rColumn.getModel());
536
537 // be listener for some common properties
540
541 // add as listener for all known "value" properties
549
550 // be listener at the bound field as well
551 try
552 {
553 Reference< XPropertySetInfo > xPSI( xColModelProps->getPropertySetInfo(), UNO_SET_THROW );
554 if ( xPSI->hasPropertyByName( FM_PROP_BOUNDFIELD ) )
555 {
556 Reference< XPropertySet > xField;
557 xColModelProps->getPropertyValue( FM_PROP_BOUNDFIELD ) >>= xField;
558 if ( xField.is() )
559 {
560 m_pFieldChangeBroadcaster = new ::comphelper::OPropertyChangeMultiplexer(this, xField);
562 }
563 }
564 }
565 catch( const Exception& )
566 {
567 TOOLS_WARN_EXCEPTION( "svx", "DbCellControl::doPropertyListening" );
568 }
569}
570
571
572void DbCellControl::implDoPropertyListening(const OUString& _rPropertyName, bool _bWarnIfNotExistent)
573{
574 try
575 {
576 Reference< XPropertySet > xColModelProps = m_rColumn.getModel();
577 Reference< XPropertySetInfo > xPSI;
578 if ( xColModelProps.is() )
579 xPSI = xColModelProps->getPropertySetInfo();
580
581 DBG_ASSERT( !_bWarnIfNotExistent || ( xPSI.is() && xPSI->hasPropertyByName( _rPropertyName ) ),
582 "DbCellControl::doPropertyListening: no property set info or non-existent property!" );
583
584 if ( xPSI.is() && xPSI->hasPropertyByName( _rPropertyName ) )
585 m_pModelChangeBroadcaster->addProperty( _rPropertyName );
586 }
587 catch( const Exception& )
588 {
589 TOOLS_WARN_EXCEPTION( "svx", "DbCellControl::doPropertyListening" );
590 }
591}
592
593
594void DbCellControl::doPropertyListening(const OUString& _rPropertyName)
595{
596 implDoPropertyListening( _rPropertyName, true );
597}
598
600{
601 if ( _pBroadcaster.is() )
602 {
603 _pBroadcaster->dispose();
604 _pBroadcaster.clear();
605 // no delete, this is done implicitly
606 }
607}
608
610{
613
616}
617
619{
620 OSL_ENSURE( !isValuePropertyLocked(),
621 "DbCellControl::implValuePropertyChanged: not to be called with the value property locked!" );
622
623 if ( m_pWindow )
624 {
625 if ( m_rColumn.getModel().is() )
627 }
628}
629
630
631void DbCellControl::implAdjustGenericFieldSetting( const Reference< XPropertySet >& /*_rxModel*/ )
632{
633 // nothing to do here
634}
635
636
637void DbCellControl::_propertyChanged(const PropertyChangeEvent& _rEvent)
638{
639 SolarMutexGuard aGuard;
640
641 Reference< XPropertySet > xSourceProps( _rEvent.Source, UNO_QUERY );
642
643 if ( _rEvent.PropertyName == FM_PROP_VALUE
644 || _rEvent.PropertyName == FM_PROP_STATE
645 || _rEvent.PropertyName == FM_PROP_TEXT
646 || _rEvent.PropertyName == FM_PROP_EFFECTIVE_VALUE
647 || _rEvent.PropertyName == FM_PROP_SELECT_SEQ
648 || _rEvent.PropertyName == FM_PROP_DATE
649 || _rEvent.PropertyName == FM_PROP_TIME
650 )
651 { // it was one of the known "value" properties
652 if ( !isValuePropertyLocked() )
653 {
655 }
656 }
657 else if ( _rEvent.PropertyName == FM_PROP_READONLY )
658 {
659 implAdjustReadOnly( xSourceProps, true);
660 }
661 else if ( _rEvent.PropertyName == FM_PROP_ISREADONLY )
662 {
663 bool bReadOnly = true;
664 _rEvent.NewValue >>= bReadOnly;
666 implAdjustReadOnly( xSourceProps, false);
667 }
668 else if ( _rEvent.PropertyName == FM_PROP_ENABLED )
669 {
670 implAdjustEnabled( xSourceProps );
671 }
672 else
673 implAdjustGenericFieldSetting( xSourceProps );
674}
675
677{
678 // lock the listening for value property changes
680 // commit the content of the control into the model's value property
681 bool bReturn = false;
682 try
683 {
684 bReturn = commitControl();
685 }
686 catch( const Exception& )
687 {
689 }
690 // unlock the listening for value property changes
692 // outta here
693 return bReturn;
694}
695
696void DbCellControl::ImplInitWindow( vcl::Window const & rParent, const InitWindowFacet _eInitWhat )
697{
698 svt::ControlBase* pWindows[] = { m_pPainter, m_pWindow };
699
700 if (_eInitWhat & InitWindowFacet::WritingMode)
701 {
702 for (svt::ControlBase* pWindow : pWindows)
703 {
704 if (pWindow)
705 pWindow->EnableRTL(rParent.IsRTLEnabled());
706 }
707 }
708
709 if (_eInitWhat & InitWindowFacet::Font)
710 {
711 const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
712 const Fraction& rZoom = rParent.GetZoom();
713
714 for (svt::ControlBase* pWindow : pWindows)
715 {
716 if (!pWindow)
717 continue;
718
719 vcl::Font aFont = rStyleSettings.GetFieldFont();
721
722 if (rParent.IsControlFont())
723 aFont.Merge(rParent.GetControlFont());
724
725 if (rZoom.GetNumerator() != rZoom.GetDenominator())
726 {
727 Size aSize = aFont.GetFontSize();
728 aSize.setWidth(std::round(double(aSize.Width() * rZoom)));
729 aSize.setHeight(std::round(double(aSize.Height() * rZoom)));
730 aFont.SetFontSize(aSize);
731 }
732
733 pWindow->SetPointFont(aFont);
734 }
735 }
736
737 if ((_eInitWhat & InitWindowFacet::Font) || (_eInitWhat & InitWindowFacet::Foreground))
738 {
739 Color aTextColor(rParent.IsControlForeground() ? rParent.GetControlForeground() : rParent.GetTextColor());
740
741 bool bTextLineColor = rParent.IsTextLineColor();
742 Color aTextLineColor(rParent.GetTextLineColor());
743
744 for (svt::ControlBase* pWindow : pWindows)
745 {
746 if (pWindow)
747 {
748 pWindow->SetTextColor(aTextColor);
749 if (rParent.IsControlForeground())
750 pWindow->SetControlForeground(aTextColor);
751
752 if (bTextLineColor)
753 pWindow->SetTextLineColor();
754 else
755 pWindow->SetTextLineColor(aTextLineColor);
756 }
757 }
758 }
759
760 if (!(_eInitWhat & InitWindowFacet::Background))
761 return;
762
763 if (rParent.IsControlBackground())
764 {
765 Color aColor(rParent.GetControlBackground());
766 for (svt::ControlBase* pWindow : pWindows)
767 {
768 if (pWindow)
769 {
770 if (isTransparent())
771 pWindow->SetBackground();
772 else
773 {
774 pWindow->SetBackground(aColor);
775 pWindow->SetControlBackground(aColor);
776 }
777 pWindow->GetOutDev()->SetFillColor(aColor);
778 }
779 }
780 }
781 else
782 {
783 if (m_pPainter)
784 {
785 if (isTransparent())
786 m_pPainter->SetBackground();
787 else
788 m_pPainter->SetBackground(rParent.GetBackground());
789 m_pPainter->GetOutDev()->SetFillColor(rParent.GetOutDev()->GetFillColor());
790 }
791
792 if (m_pWindow)
793 {
794 if (isTransparent())
795 m_pWindow->SetBackground(rParent.GetBackground());
796 else
797 m_pWindow->GetOutDev()->SetFillColor(rParent.GetOutDev()->GetFillColor());
798 }
799 }
800}
801
802void DbCellControl::implAdjustReadOnly( const Reference< XPropertySet >& _rxModel,bool i_bReadOnly )
803{
804 DBG_ASSERT( m_pWindow, "DbCellControl::implAdjustReadOnly: not to be called without window!" );
805 DBG_ASSERT( _rxModel.is(), "DbCellControl::implAdjustReadOnly: invalid model!" );
806 if ( !(m_pWindow && _rxModel.is()) )
807 return;
808
810 if ( !bReadOnly )
811 {
812 _rxModel->getPropertyValue( i_bReadOnly ? OUString(FM_PROP_READONLY) : OUString(FM_PROP_ISREADONLY)) >>= bReadOnly;
813 }
814 m_pWindow->SetEditableReadOnly(bReadOnly);
815}
816
817void DbCellControl::implAdjustEnabled( const Reference< XPropertySet >& _rxModel )
818{
819 DBG_ASSERT( m_pWindow, "DbCellControl::implAdjustEnabled: not to be called without window!" );
820 DBG_ASSERT( _rxModel.is(), "DbCellControl::implAdjustEnabled: invalid model!" );
821 if ( m_pWindow && _rxModel.is() )
822 {
823 bool bEnable = true;
824 _rxModel->getPropertyValue( FM_PROP_ENABLED ) >>= bEnable;
825 m_pWindow->Enable( bEnable );
826 }
827}
828
829void DbCellControl::Init(BrowserDataWin& rParent, const Reference< XRowSet >& _rxCursor)
830{
832
833 if ( m_pWindow )
834 {
835 // align the control
836 if ( isAlignedController() )
838
839 try
840 {
841 // some other common properties
842 Reference< XPropertySet > xModel( m_rColumn.getModel(), UNO_SET_THROW );
843 Reference< XPropertySetInfo > xModelPSI( xModel->getPropertySetInfo(), UNO_SET_THROW );
844
845 if ( xModelPSI->hasPropertyByName( FM_PROP_READONLY ) )
846 {
848 }
849
850 if ( xModelPSI->hasPropertyByName( FM_PROP_ENABLED ) )
851 {
853 }
854
855 if ( xModelPSI->hasPropertyByName( FM_PROP_MOUSE_WHEEL_BEHAVIOR ) )
856 {
857 sal_Int16 nWheelBehavior = css::awt::MouseWheelBehavior::SCROLL_FOCUS_ONLY;
858 OSL_VERIFY( xModel->getPropertyValue( FM_PROP_MOUSE_WHEEL_BEHAVIOR ) >>= nWheelBehavior );
859 MouseWheelBehaviour nVclSetting = MouseWheelBehaviour::FocusOnly;
860 switch ( nWheelBehavior )
861 {
862 case css::awt::MouseWheelBehavior::SCROLL_DISABLED: nVclSetting = MouseWheelBehaviour::Disable; break;
863 case css::awt::MouseWheelBehavior::SCROLL_FOCUS_ONLY: nVclSetting = MouseWheelBehaviour::FocusOnly; break;
864 case css::awt::MouseWheelBehavior::SCROLL_ALWAYS: nVclSetting = MouseWheelBehaviour::ALWAYS; break;
865 default:
866 OSL_FAIL( "DbCellControl::Init: invalid MouseWheelBehavior!" );
867 break;
868 }
869
870 AllSettings aSettings = m_pWindow->GetSettings();
871 MouseSettings aMouseSettings = aSettings.GetMouseSettings();
872 aMouseSettings.SetWheelBehavior( nVclSetting );
873 aSettings.SetMouseSettings( aMouseSettings );
874 m_pWindow->SetSettings( aSettings, true );
875 }
876 }
877 catch( const Exception& )
878 {
880 }
881 }
882 m_xCursor = _rxCursor;
883 if ( m_rColumn.getModel().is() )
885}
886
887
889{
890 if (m_pWindow)
891 m_pWindow->SetTextLineColor();
892 if (m_pPainter)
893 m_pPainter->SetTextLineColor();
894}
895
896
898{
899 if (m_pWindow)
900 m_pWindow->SetTextLineColor(_rColor);
901 if (m_pPainter)
902 m_pPainter->SetTextLineColor(_rColor);
903}
904
905namespace
906{
907 void lcl_implAlign( vcl::Window* _pWindow, WinBits _nAlignmentBit )
908 {
909 if (EditControlBase* pControl = dynamic_cast<EditControlBase*>(_pWindow))
910 {
911 switch (_nAlignmentBit)
912 {
913 case WB_LEFT:
914 pControl->get_widget().set_alignment(TxtAlign::Left);
915 break;
916 case WB_CENTER:
917 pControl->get_widget().set_alignment(TxtAlign::Center);
918 break;
919 case WB_RIGHT:
920 pControl->get_widget().set_alignment(TxtAlign::Right);
921 break;
922 }
923 return;
924 }
925
926 WinBits nStyle = _pWindow->GetStyle();
927 nStyle &= ~(WB_LEFT | WB_RIGHT | WB_CENTER);
928 _pWindow->SetStyle( nStyle | _nAlignmentBit );
929 }
930}
931
932void DbCellControl::AlignControl(sal_Int16 nAlignment)
933{
934 WinBits nAlignmentBit = 0;
935 switch (nAlignment)
936 {
937 case css::awt::TextAlign::RIGHT:
938 nAlignmentBit = WB_RIGHT;
939 break;
940 case css::awt::TextAlign::CENTER:
941 nAlignmentBit = WB_CENTER;
942 break;
943 default:
944 nAlignmentBit = WB_LEFT;
945 break;
946 }
947 lcl_implAlign( m_pWindow, nAlignmentBit );
948 if ( m_pPainter )
949 lcl_implAlign( m_pPainter, nAlignmentBit );
950}
951
953{
954 m_pPainter->SetSizePixel(rRect.GetSize());
955 m_pPainter->Draw(&rDev, rRect.TopLeft(), SystemTextColorFlags::NONE);
956}
957
958void DbCellControl::PaintFieldToCell( OutputDevice& _rDev, const tools::Rectangle& _rRect, const Reference< XColumn >& _rxField, const Reference< XNumberFormatter >& _rxFormatter )
959{
960 m_pPainter->SetText( GetFormatText( _rxField, _rxFormatter ) );
961 PaintCell( _rDev, _rRect );
962}
963
964double DbCellControl::GetValue(const Reference< css::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& xFormatter) const
965{
966 double fValue = 0;
967 if (m_rColumn.IsNumeric())
968 {
969 try
970 {
971 fValue = _rxField->getDouble();
972 }
973 catch(const Exception&) { }
974 }
975 else
976 {
977 bool bSuccess = false;
978 try
979 {
980 fValue = _rxField->getDouble();
981 bSuccess = true;
982 }
983 catch(const Exception&) { }
984 if (!bSuccess)
985 {
986 try
987 {
988 fValue = xFormatter->convertStringToNumber(m_rColumn.GetKey(), _rxField->getString());
989 }
990 catch(const Exception&) { }
991 }
992 }
993 return fValue;
994}
995
997{
999}
1000
1001// CellModels
1002
1004 :DbCellControl( _rColumn )
1005{
1007}
1008
1009
1010void DbLimitedLengthField::implAdjustGenericFieldSetting( const Reference< XPropertySet >& _rxModel )
1011{
1012 DBG_ASSERT( m_pWindow, "DbLimitedLengthField::implAdjustGenericFieldSetting: not to be called without window!" );
1013 DBG_ASSERT( _rxModel.is(), "DbLimitedLengthField::implAdjustGenericFieldSetting: invalid model!" );
1014 if ( m_pWindow && _rxModel.is() )
1015 {
1016 sal_Int16 nMaxLen = 0;
1017 _rxModel->getPropertyValue( FM_PROP_MAXTEXTLEN ) >>= nMaxLen;
1018 implSetMaxTextLen( nMaxLen );
1019 }
1020}
1021
1023{
1024 dynamic_cast<EditControlBase&>(*m_pWindow).get_widget().set_max_length(nMaxLen);
1025 if (m_pPainter)
1026 dynamic_cast<EditControlBase&>(*m_pPainter).get_widget().set_max_length(nMaxLen);
1027}
1028
1030 :DbLimitedLengthField(_rColumn)
1031 ,m_bIsMultiLineEdit(false)
1032{
1033}
1034
1036{
1038 m_pEdit.reset();
1039}
1040
1041void DbTextField::Init(BrowserDataWin& rParent, const Reference< XRowSet >& xCursor)
1042{
1043 sal_Int16 nAlignment = m_rColumn.SetAlignmentFromModel(-1);
1044
1045 Reference< XPropertySet > xModel( m_rColumn.getModel() );
1046
1047 bool bLeftAlign = true;
1048
1049 // is this a multi-line field?
1050 bool bIsMultiLine = false;
1051 try
1052 {
1053 if ( xModel.is() )
1054 {
1055 OSL_VERIFY( xModel->getPropertyValue( FM_PROP_MULTILINE ) >>= bIsMultiLine );
1056 }
1057 }
1058 catch( const Exception& )
1059 {
1061 "caught an exception while determining the multi-line capabilities!");
1062 }
1063
1064 m_bIsMultiLineEdit = bIsMultiLine;
1065 if ( bIsMultiLine )
1066 {
1067 auto xEditControl = VclPtr<MultiLineTextCell>::Create(&rParent);
1068 auto xEditPainter = VclPtr<MultiLineTextCell>::Create(&rParent);
1069
1070 switch (nAlignment)
1071 {
1072 case awt::TextAlign::RIGHT:
1073 xEditControl->get_widget().set_alignment(TxtAlign::Right);
1074 xEditPainter->get_widget().set_alignment(TxtAlign::Right);
1075 bLeftAlign = false;
1076 break;
1077 case awt::TextAlign::CENTER:
1078 xEditControl->get_widget().set_alignment(TxtAlign::Center);
1079 xEditPainter->get_widget().set_alignment(TxtAlign::Center);
1080 bLeftAlign = false;
1081 break;
1082 }
1083
1084 m_pWindow = xEditControl;
1085 m_pEdit.reset(new MultiLineEditImplementation(*xEditControl));
1086
1087 m_pPainter = xEditPainter;
1088 m_pPainterImplementation.reset(new MultiLineEditImplementation(*xEditPainter));
1089 }
1090 else
1091 {
1092 auto xEditControl = VclPtr<EditControl>::Create(&rParent);
1093 auto xEditPainter = VclPtr<EditControl>::Create(&rParent);
1094
1095 switch (nAlignment)
1096 {
1097 case awt::TextAlign::RIGHT:
1098 xEditControl->get_widget().set_alignment(TxtAlign::Right);
1099 xEditPainter->get_widget().set_alignment(TxtAlign::Right);
1100 bLeftAlign = false;
1101 break;
1102 case awt::TextAlign::CENTER:
1103 xEditControl->get_widget().set_alignment(TxtAlign::Center);
1104 xEditPainter->get_widget().set_alignment(TxtAlign::Center);
1105 bLeftAlign = false;
1106 break;
1107 }
1108
1109 m_pWindow = xEditControl;
1110 m_pEdit.reset(new EntryImplementation(*xEditControl));
1111
1112 m_pPainter = xEditPainter;
1113 m_pPainterImplementation.reset(new EntryImplementation(*xEditPainter));
1114 }
1115
1116 if (bLeftAlign)
1117 {
1118 // this is so that when getting the focus, the selection is oriented left-to-right
1119 AllSettings aSettings = m_pWindow->GetSettings();
1120 StyleSettings aStyleSettings = aSettings.GetStyleSettings();
1121 aStyleSettings.SetSelectionOptions(
1122 aStyleSettings.GetSelectionOptions() | SelectionOptions::ShowFirst);
1123 aSettings.SetStyleSettings(aStyleSettings);
1124 m_pWindow->SetSettings(aSettings);
1125 }
1126
1128
1129 DbLimitedLengthField::Init( rParent, xCursor );
1130}
1131
1133{
1134 return new EditCellController( m_pEdit.get() );
1135}
1136
1137void DbTextField::PaintFieldToCell( OutputDevice& _rDev, const tools::Rectangle& _rRect, const Reference< XColumn >& _rxField, const Reference< XNumberFormatter >& _rxFormatter )
1138{
1140 m_pPainterImplementation->SetText( GetFormatText( _rxField, _rxFormatter ) );
1141
1142 DbLimitedLengthField::PaintFieldToCell( _rDev, _rRect, _rxField, _rxFormatter );
1143}
1144
1145OUString DbTextField::GetFormatText(const Reference< XColumn >& _rxField, const Reference< XNumberFormatter >& xFormatter, const Color** /*ppColor*/)
1146{
1147 if (!_rxField.is())
1148 return OUString();
1149
1150 const css::uno::Reference<css::beans::XPropertySet> xPS(_rxField, UNO_QUERY);
1151 FormattedColumnValue fmter( xFormatter, xPS );
1152
1153 try
1154 {
1155 return fmter.getFormattedValue();
1156 }
1157 catch( const Exception& )
1158 {
1160 }
1161 return OUString();
1162
1163}
1164
1165void DbTextField::UpdateFromField(const Reference< css::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& xFormatter)
1166{
1167 m_pEdit->SetText( GetFormatText( _rxField, xFormatter ) );
1168 m_pEdit->SetSelection( Selection( SELECTION_MAX, SELECTION_MIN ) );
1169}
1170
1171void DbTextField::updateFromModel( Reference< XPropertySet > _rxModel )
1172{
1173 OSL_ENSURE( _rxModel.is() && m_pWindow, "DbTextField::updateFromModel: invalid call!" );
1174
1175 OUString sText;
1176 _rxModel->getPropertyValue( FM_PROP_TEXT ) >>= sText;
1177
1178 sal_Int32 nMaxTextLen = m_pEdit->GetMaxTextLen();
1179 if (nMaxTextLen > 0 && sText.getLength() > nMaxTextLen)
1180 {
1181 sal_Int32 nDiff = sText.getLength() - nMaxTextLen;
1182 sText = sText.replaceAt(sText.getLength() - nDiff,nDiff, u"");
1183 }
1184
1185 m_pEdit->SetText( sText );
1186 m_pEdit->SetSelection( Selection( SELECTION_MAX, SELECTION_MIN ) );
1187}
1188
1190{
1191 OUString aText( m_pEdit->GetText( getModelLineEndSetting( m_rColumn.getModel() ) ) );
1192 // we have to check if the length before we can decide if the value was modified
1193 sal_Int32 nMaxTextLen = m_pEdit->GetMaxTextLen();
1194 if (nMaxTextLen > 0)
1195 {
1196 OUString sOldValue;
1197 m_rColumn.getModel()->getPropertyValue( FM_PROP_TEXT ) >>= sOldValue;
1198 // if the new value didn't change we must set the old long value again
1199 if ( sOldValue.getLength() > nMaxTextLen && sOldValue.compareTo(aText,nMaxTextLen) == 0 )
1200 aText = sOldValue;
1201 }
1202 m_rColumn.getModel()->setPropertyValue( FM_PROP_TEXT, Any( aText ) );
1203 return true;
1204}
1205
1207{
1208 if ( m_pEdit )
1209 m_pEdit->SetMaxTextLen( _nMaxLen );
1211 m_pPainterImplementation->SetMaxTextLen( _nMaxLen );
1212}
1213
1215 :DbLimitedLengthField(_rColumn)
1216{
1217 // if our model's format key changes we want to propagate the new value to our windows
1219}
1220
1222{
1223}
1224
1225void DbFormattedField::Init( BrowserDataWin& rParent, const Reference< XRowSet >& xCursor)
1226{
1227 sal_Int16 nAlignment = m_rColumn.SetAlignmentFromModel(-1);
1228
1229 Reference< css::beans::XPropertySet > xUnoModel = m_rColumn.getModel();
1230
1231 auto xEditControl = VclPtr<FormattedControl>::Create(&rParent, false);
1232 auto xEditPainter = VclPtr<FormattedControl>::Create(&rParent, false);
1233
1234 weld::EntryFormatter& rControlFormatter = xEditControl->get_formatter();
1235 weld::EntryFormatter& rPainterFormatter = xEditPainter->get_formatter();
1236
1237 m_pWindow = xEditControl.get();
1238 m_pPainter = xEditPainter.get();
1239
1240 switch (nAlignment)
1241 {
1242 case awt::TextAlign::RIGHT:
1243 xEditControl->get_widget().set_alignment(TxtAlign::Right);
1244 xEditPainter->get_widget().set_alignment(TxtAlign::Right);
1245 break;
1246 case awt::TextAlign::CENTER:
1247 xEditControl->get_widget().set_alignment(TxtAlign::Center);
1248 xEditPainter->get_widget().set_alignment(TxtAlign::Center);
1249 break;
1250 default:
1251 {
1252 // Everything just so that the selection goes from right to left when getting focus
1253 SelectionOptions eOptions = rControlFormatter.GetEntrySelectionOptions();
1254 rControlFormatter.SetEntrySelectionOptions(eOptions | SelectionOptions::ShowFirst);
1255 break;
1256 }
1257 }
1258
1259 implAdjustGenericFieldSetting( xUnoModel );
1260
1261 rControlFormatter.SetStrictFormat(false);
1262 rPainterFormatter.SetStrictFormat(false);
1263 // if one allows any formatting, one cannot make an entry check anyway
1264 // (the FormattedField does not support that anyway, only derived classes)
1265
1266 // get the formatter from the uno model
1267 // (I could theoretically also go via the css::util::NumberFormatter, which the cursor would
1268 // surely give me. The problem is that I can not really rely on the fact that the two
1269 // formatters are the same. Clean is the whole thing if I go via the UNO model.)
1270 sal_Int32 nFormatKey = -1;
1271
1272 // let's see if the model has one ...
1273 DBG_ASSERT(::comphelper::hasProperty(FM_PROP_FORMATSSUPPLIER, xUnoModel), "DbFormattedField::Init : invalid UNO model !");
1274 Any aSupplier( xUnoModel->getPropertyValue(FM_PROP_FORMATSSUPPLIER));
1275 if (aSupplier.hasValue())
1276 {
1277 m_xSupplier.set(aSupplier, css::uno::UNO_QUERY);
1278 if (m_xSupplier.is())
1279 {
1280 // if we take the supplier from the model, then also the key
1281 Any aFmtKey( xUnoModel->getPropertyValue(FM_PROP_FORMATKEY));
1282 if (aFmtKey.hasValue())
1283 {
1284 DBG_ASSERT(aFmtKey.getValueType().getTypeClass() == TypeClass_LONG, "DbFormattedField::Init : invalid format key property (no sal_Int32) !");
1285 nFormatKey = ::comphelper::getINT32(aFmtKey);
1286 }
1287 else
1288 {
1289 SAL_INFO("svx.fmcomp", "DbFormattedField::Init : my uno-model has no format-key, but a formats supplier !");
1290 // the OFormattedModel which we usually are working with ensures that the model has a format key
1291 // as soon as the form is loaded. Unfortunally this method here is called from within loaded, too.
1292 // So if our LoadListener is called before the LoadListener of the model, this "else case" is
1293 // allowed.
1294 // Of course our property listener for the FormatKey property will notify us if the prop is changed,
1295 // so this here isn't really bad...
1296 nFormatKey = 0;
1297 }
1298 }
1299 }
1300
1301 // No? Maybe the css::form::component::Form behind the cursor?
1302 if (!m_xSupplier.is())
1303 {
1304 if (xCursor.is())
1305 { // If we take the formatter from the cursor, then also the key from the field to which we are bound
1307
1308 if (m_rColumn.GetField().is())
1309 nFormatKey = ::comphelper::getINT32(m_rColumn.GetField()->getPropertyValue(FM_PROP_FORMATKEY));
1310 }
1311 }
1312
1313 SvNumberFormatter* pFormatterUsed = nullptr;
1314 if (m_xSupplier.is())
1315 {
1316 SvNumberFormatsSupplierObj* pImplementation = comphelper::getFromUnoTunnel<SvNumberFormatsSupplierObj>(m_xSupplier);
1317 if (pImplementation)
1318 pFormatterUsed = pImplementation->GetNumberFormatter();
1319 else
1320 // Everything is invalid: the supplier is of the wrong type, then we can not
1321 // rely on a standard formatter to know the (possibly non-standard) key.
1322 nFormatKey = -1;
1323 }
1324
1325 // a standard formatter ...
1326 if (pFormatterUsed == nullptr)
1327 {
1328 pFormatterUsed = rControlFormatter.StandardFormatter();
1329 DBG_ASSERT(pFormatterUsed != nullptr, "DbFormattedField::Init : no standard formatter given by the numeric field !");
1330 }
1331 // ... and a standard key
1332 if (nFormatKey == -1)
1333 nFormatKey = 0;
1334
1335 rControlFormatter.SetFormatter(pFormatterUsed);
1336 rPainterFormatter.SetFormatter(pFormatterUsed);
1337
1338 rControlFormatter.SetFormatKey(nFormatKey);
1339 rPainterFormatter.SetFormatKey(nFormatKey);
1340
1341 rControlFormatter.TreatAsNumber(m_rColumn.IsNumeric());
1342 rPainterFormatter.TreatAsNumber(m_rColumn.IsNumeric());
1343
1344 // min and max values
1345 if (m_rColumn.IsNumeric())
1346 {
1347 bool bClearMin = true;
1348 if (::comphelper::hasProperty(FM_PROP_EFFECTIVE_MIN, xUnoModel))
1349 {
1350 Any aMin( xUnoModel->getPropertyValue(FM_PROP_EFFECTIVE_MIN));
1351 if (aMin.getValueType().getTypeClass() != TypeClass_VOID)
1352 {
1353 DBG_ASSERT(aMin.getValueType().getTypeClass() == TypeClass_DOUBLE, "DbFormattedField::Init : the model has an invalid min value !");
1354 double dMin = ::comphelper::getDouble(aMin);
1355 rControlFormatter.SetMinValue(dMin);
1356 rPainterFormatter.SetMinValue(dMin);
1357 bClearMin = false;
1358 }
1359 }
1360 if (bClearMin)
1361 {
1362 rControlFormatter.ClearMinValue();
1363 rPainterFormatter.ClearMinValue();
1364 }
1365 bool bClearMax = true;
1366 if (::comphelper::hasProperty(FM_PROP_EFFECTIVE_MAX, xUnoModel))
1367 {
1368 Any aMax(xUnoModel->getPropertyValue(FM_PROP_EFFECTIVE_MAX));
1369 if (aMax.getValueType().getTypeClass() != TypeClass_VOID)
1370 {
1371 DBG_ASSERT(aMax.getValueType().getTypeClass() == TypeClass_DOUBLE, "DbFormattedField::Init : the model has an invalid max value !");
1372 double dMax = ::comphelper::getDouble(aMax);
1373 rControlFormatter.SetMaxValue(dMax);
1374 rPainterFormatter.SetMaxValue(dMax);
1375 bClearMax = false;
1376 }
1377 }
1378 if (bClearMax)
1379 {
1380 rControlFormatter.ClearMaxValue();
1381 rPainterFormatter.ClearMaxValue();
1382 }
1383 }
1384
1385 // the default value
1386 Any aDefault( xUnoModel->getPropertyValue(FM_PROP_EFFECTIVE_DEFAULT));
1387 if (aDefault.hasValue())
1388 { // the thing can be a double or a string
1389 switch (aDefault.getValueType().getTypeClass())
1390 {
1391 case TypeClass_DOUBLE:
1392 if (m_rColumn.IsNumeric())
1393 {
1394 rControlFormatter.SetDefaultValue(::comphelper::getDouble(aDefault));
1395 rPainterFormatter.SetDefaultValue(::comphelper::getDouble(aDefault));
1396 }
1397 else
1398 {
1399 OUString sConverted;
1400 const Color* pDummy;
1401 pFormatterUsed->GetOutputString(::comphelper::getDouble(aDefault), 0, sConverted, &pDummy);
1402 rControlFormatter.SetDefaultText(sConverted);
1403 rPainterFormatter.SetDefaultText(sConverted);
1404 }
1405 break;
1406 case TypeClass_STRING:
1407 {
1408 OUString sDefault( ::comphelper::getString(aDefault) );
1409 if (m_rColumn.IsNumeric())
1410 {
1411 double dVal;
1412 sal_uInt32 nTestFormat(0);
1413 if (pFormatterUsed->IsNumberFormat(sDefault, nTestFormat, dVal))
1414 {
1415 rControlFormatter.SetDefaultValue(dVal);
1416 rPainterFormatter.SetDefaultValue(dVal);
1417 }
1418 }
1419 else
1420 {
1421 rControlFormatter.SetDefaultText(sDefault);
1422 rPainterFormatter.SetDefaultText(sDefault);
1423 }
1424 }
1425 break;
1426 default:
1427 OSL_FAIL( "DbFormattedField::Init: unexpected value type!" );
1428 break;
1429 }
1430 }
1431 DbLimitedLengthField::Init( rParent, xCursor );
1432}
1433
1435{
1436 return new ::svt::FormattedFieldCellController(static_cast<FormattedControlBase*>(m_pWindow.get()));
1437}
1438
1439void DbFormattedField::_propertyChanged( const PropertyChangeEvent& _rEvent )
1440{
1441 if (_rEvent.PropertyName == FM_PROP_FORMATKEY )
1442 {
1443 sal_Int32 nNewKey = _rEvent.NewValue.hasValue() ? ::comphelper::getINT32(_rEvent.NewValue) : 0;
1444
1445 DBG_ASSERT(m_pWindow && m_pPainter, "DbFormattedField::_propertyChanged : where are my windows ?");
1446 if (m_pWindow)
1447 static_cast<FormattedControlBase*>(m_pWindow.get())->get_formatter().SetFormatKey(nNewKey);
1448 if (m_pPainter)
1449 static_cast<FormattedControlBase*>(m_pPainter.get())->get_formatter().SetFormatKey(nNewKey);
1450 }
1451 else
1452 {
1454 }
1455}
1456
1457OUString DbFormattedField::GetFormatText(const Reference< css::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& /*xFormatter*/, const Color** ppColor)
1458{
1459 // no color specification by default
1460 if (ppColor != nullptr)
1461 *ppColor = nullptr;
1462
1463 // NULL value -> empty text
1464 if (!_rxField.is())
1465 return OUString();
1466
1467 FormattedControlBase* pControl = static_cast<FormattedControlBase*>(m_pPainter.get());
1468 weld::EntryFormatter& rPainterFormatter = pControl->get_formatter();
1469
1470 OUString aText;
1471 try
1472 {
1473 if (m_rColumn.IsNumeric())
1474 {
1475 // The IsNumeric at the column says nothing about the class of the used format, but
1476 // about the class of the field bound to the column. So when you bind a FormattedField
1477 // column to a double field and format it as text, m_rColumn.IsNumeric() returns
1478 // sal_True. So that simply means that I can query the contents of the variant using
1479 // getDouble, and then I can leave the rest (the formatting) to the FormattedField.
1480 double dValue = getValue( _rxField, m_rColumn.GetParent().getNullDate() );
1481 if (_rxField->wasNull())
1482 return aText;
1483 rPainterFormatter.SetValue(dValue);
1484 }
1485 else
1486 {
1487 // Here I can not work with a double, since the field can not provide it to me.
1488 // So simply bind the text from the css::util::NumberFormatter to the correct css::form::component::Form.
1489 aText = _rxField->getString();
1490 if (_rxField->wasNull())
1491 return aText;
1492 rPainterFormatter.SetTextFormatted(aText);
1493 }
1494 }
1495 catch( const Exception& )
1496 {
1498 }
1499
1500 aText = pControl->get_widget().get_text();
1501 if (ppColor != nullptr)
1502 *ppColor = rPainterFormatter.GetLastOutputColor();
1503
1504 return aText;
1505}
1506
1507void DbFormattedField::UpdateFromField(const Reference< css::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& /*xFormatter*/)
1508{
1509 try
1510 {
1511 FormattedControlBase* pEditControl = static_cast<FormattedControlBase*>(m_pWindow.get());
1512 weld::Entry& rEntry = pEditControl->get_widget();
1513 weld::EntryFormatter& rEditFormatter = pEditControl->get_formatter();
1514
1515 if (!_rxField.is())
1516 {
1517 // NULL value -> empty text
1518 rEntry.set_text(OUString());
1519 }
1520 else if (m_rColumn.IsNumeric())
1521 {
1522 // The IsNumeric at the column says nothing about the class of the used format, but
1523 // about the class of the field bound to the column. So when you bind a FormattedField
1524 // column to a double field and format it as text, m_rColumn.IsNumeric() returns
1525 // sal_True. So that simply means that I can query the contents of the variant using
1526 // getDouble, and then I can leave the rest (the formatting) to the FormattedField.
1527 double dValue = getValue( _rxField, m_rColumn.GetParent().getNullDate() );
1528 if (_rxField->wasNull())
1529 rEntry.set_text(OUString());
1530 else
1531 rEditFormatter.SetValue(dValue);
1532 }
1533 else
1534 {
1535 // Here I can not work with a double, since the field can not provide it to me.
1536 // So simply bind the text from the css::util::NumberFormatter to the correct css::form::component::Form.
1537 OUString sText( _rxField->getString());
1538
1539 rEditFormatter.SetTextFormatted( sText );
1540 rEntry.select_region(0, -1);
1541 }
1542 }
1543 catch( const Exception& )
1544 {
1546 }
1547}
1548
1549void DbFormattedField::updateFromModel( Reference< XPropertySet > _rxModel )
1550{
1551 OSL_ENSURE( _rxModel.is() && m_pWindow, "DbFormattedField::updateFromModel: invalid call!" );
1552
1553 FormattedControlBase* pEditControl = static_cast<FormattedControlBase*>(m_pWindow.get());
1554 weld::Entry& rEntry = pEditControl->get_widget();
1555 weld::EntryFormatter& rEditFormatter = pEditControl->get_formatter();
1556
1557 OUString sText;
1558 Any aValue = _rxModel->getPropertyValue( FM_PROP_EFFECTIVE_VALUE );
1559 if ( !aValue.hasValue() || (aValue >>= sText) )
1560 {
1561 // our effective value is transferred as string
1562 rEditFormatter.SetTextFormatted( sText );
1563 rEntry.select_region(0, -1);
1564 }
1565 else
1566 {
1567 double dValue = 0;
1568 aValue >>= dValue;
1569 rEditFormatter.SetValue(dValue);
1570 }
1571}
1572
1574{
1575 Any aNewVal;
1576
1577 FormattedControlBase* pEditControl = static_cast<FormattedControlBase*>(m_pWindow.get());
1578 weld::Entry& rEntry = pEditControl->get_widget();
1579 weld::EntryFormatter& rEditFormatter = pEditControl->get_formatter();
1580
1581 if (m_rColumn.IsNumeric())
1582 {
1583 if (!rEntry.get_text().isEmpty())
1584 aNewVal <<= rEditFormatter.GetValue();
1585 // an empty string is passed on as void by default, to start with
1586 }
1587 else
1588 aNewVal <<= rEditFormatter.GetTextValue();
1589
1590 m_rColumn.getModel()->setPropertyValue(FM_PROP_EFFECTIVE_VALUE, aNewVal);
1591 return true;
1592}
1593
1595 :DbCellControl( _rColumn )
1596{
1597 setAlignedController( false );
1598}
1599
1600namespace
1601{
1602 void setCheckBoxStyle( vcl::Window* _pWindow, bool bMono )
1603 {
1604 AllSettings aSettings = _pWindow->GetSettings();
1605 StyleSettings aStyleSettings = aSettings.GetStyleSettings();
1606 if( bMono )
1607 aStyleSettings.SetOptions( aStyleSettings.GetOptions() | StyleSettingsOptions::Mono );
1608 else
1609 aStyleSettings.SetOptions( aStyleSettings.GetOptions() & (~StyleSettingsOptions::Mono) );
1610 aSettings.SetStyleSettings( aStyleSettings );
1611 _pWindow->SetSettings( aSettings );
1612 }
1613}
1614
1615void DbCheckBox::Init(BrowserDataWin& rParent, const Reference< XRowSet >& xCursor)
1616{
1617 setTransparent( true );
1618
1621
1622 m_pWindow->SetPaintTransparent( true );
1623 m_pPainter->SetPaintTransparent( true );
1624
1625 m_pPainter->SetBackground();
1626
1627 try
1628 {
1629 Reference< XPropertySet > xModel( m_rColumn.getModel(), UNO_SET_THROW );
1630
1631 sal_Int16 nStyle = awt::VisualEffect::LOOK3D;
1632 OSL_VERIFY( xModel->getPropertyValue( FM_PROP_VISUALEFFECT ) >>= nStyle );
1633
1634 setCheckBoxStyle( m_pWindow, nStyle == awt::VisualEffect::FLAT );
1635 setCheckBoxStyle( m_pPainter, nStyle == awt::VisualEffect::FLAT );
1636
1637 bool bTristate = true;
1638 OSL_VERIFY( xModel->getPropertyValue( FM_PROP_TRISTATE ) >>= bTristate );
1639 static_cast< CheckBoxControl* >( m_pWindow.get() )->EnableTriState( bTristate );
1640 static_cast< CheckBoxControl* >( m_pPainter.get() )->EnableTriState( bTristate );
1641 }
1642 catch( const Exception& )
1643 {
1645 }
1646
1647 DbCellControl::Init( rParent, xCursor );
1648}
1649
1651{
1652 return new CheckBoxCellController(static_cast<CheckBoxControl*>(m_pWindow.get()));
1653}
1654
1655static void lcl_setCheckBoxState( const Reference< css::sdb::XColumn >& _rxField,
1656 CheckBoxControl* _pCheckBoxControl )
1657{
1658 TriState eState = TRISTATE_INDET;
1659 if (_rxField.is())
1660 {
1661 try
1662 {
1663 bool bValue = _rxField->getBoolean();
1664 if (!_rxField->wasNull())
1665 eState = bValue ? TRISTATE_TRUE : TRISTATE_FALSE;
1666 }
1667 catch( const Exception& )
1668 {
1670 }
1671 }
1672 _pCheckBoxControl->SetState(eState);
1673}
1674
1675void DbCheckBox::UpdateFromField(const Reference< css::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& /*xFormatter*/)
1676{
1677 lcl_setCheckBoxState( _rxField, static_cast<CheckBoxControl*>(m_pWindow.get()) );
1678}
1679
1681 const Reference< css::sdb::XColumn >& _rxField,
1682 const Reference< XNumberFormatter >& xFormatter)
1683{
1684 CheckBoxControl* pControl = static_cast<CheckBoxControl*>(m_pPainter.get());
1685 lcl_setCheckBoxState( _rxField, pControl );
1686
1687 Size aBoxSize;
1688
1689 switch (rDev.GetOutDevType())
1690 {
1691 case OUTDEV_WINDOW:
1692 case OUTDEV_VIRDEV:
1693 aBoxSize = pControl->GetBox().get_preferred_size();
1694 break;
1695 case OUTDEV_PRINTER:
1696 case OUTDEV_PDF:
1697 {
1698 auto nSize = std::min(rRect.GetWidth(), rRect.GetHeight());
1699 aBoxSize = Size(nSize, nSize);
1700 break;
1701 }
1702 }
1703
1704 tools::Rectangle aRect(Point(rRect.Left() + ((rRect.GetWidth() - aBoxSize.Width()) / 2),
1705 rRect.Top() + ((rRect.GetHeight() - aBoxSize.Height()) / 2)),
1706 aBoxSize);
1707
1708 DbCellControl::PaintFieldToCell(rDev, aRect, _rxField, xFormatter);
1709}
1710
1712{
1713 switch (rDev.GetOutDevType())
1714 {
1715 case OUTDEV_WINDOW:
1716 case OUTDEV_VIRDEV:
1717 DbCellControl::PaintCell(rDev, rRect);
1718 break;
1719 case OUTDEV_PRINTER:
1720 case OUTDEV_PDF:
1721 {
1722 TriState eState = static_cast<CheckBoxControl*>(m_pWindow.get())->GetState();
1723
1724 MapMode aResMapMode(MapUnit::Map100thMM);
1725 Size aImageSize = rDev.LogicToPixel(Size(300, 300), aResMapMode);
1726 Size aBrd1Size = rDev.LogicToPixel(Size(20, 20), aResMapMode);
1727 Size aBrd2Size = rDev.LogicToPixel(Size(30, 30), aResMapMode);
1728 int nCheckWidth = rDev.LogicToPixel(Size(20, 20), aResMapMode).Width();
1729
1730 tools::Rectangle aStateRect;
1731 aStateRect.SetLeft(rRect.Left() + ((rRect.GetWidth() - aImageSize.Width()) / 2));
1732 aStateRect.SetTop(rRect.Top() + ((rRect.GetHeight() - aImageSize.Height()) / 2));
1733 aStateRect.SetRight(aStateRect.Left() + aImageSize.Width() - 1);
1734 aStateRect.SetBottom(aStateRect.Top() + aImageSize.Height() - 1);
1735
1736 rDev.Push();
1737 rDev.SetMapMode();
1738
1739 rDev.SetLineColor();
1740 rDev.SetFillColor(COL_BLACK);
1741 rDev.DrawRect(aStateRect);
1742 aStateRect.AdjustLeft(aBrd1Size.Width());
1743 aStateRect.AdjustTop(aBrd1Size.Height());
1744 aStateRect.AdjustRight(-aBrd1Size.Width());
1745 aStateRect.AdjustBottom(-aBrd1Size.Height());
1746 if (eState == TRISTATE_INDET)
1748 else
1749 rDev.SetFillColor(COL_WHITE);
1750 rDev.DrawRect(aStateRect);
1751
1752 if (eState == TRISTATE_TRUE)
1753 {
1754 aStateRect.AdjustLeft(aBrd2Size.Width());
1755 aStateRect.AdjustTop(aBrd2Size.Height());
1756 aStateRect.AdjustRight(-aBrd2Size.Width());
1757 aStateRect.AdjustBottom(-aBrd2Size.Height());
1758 Point aPos11(aStateRect.TopLeft());
1759 Point aPos12(aStateRect.BottomRight());
1760 Point aPos21(aStateRect.TopRight());
1761 Point aPos22(aStateRect.BottomLeft());
1762 Point aTempPos11(aPos11);
1763 Point aTempPos12(aPos12);
1764 Point aTempPos21(aPos21);
1765 Point aTempPos22(aPos22);
1766 rDev.SetLineColor(COL_BLACK);
1767 int nDX = 0;
1768 for (int i = 0; i < nCheckWidth; i++)
1769 {
1770 if ( !(i % 2) )
1771 {
1772 aTempPos11.setX(aPos11.X() + nDX);
1773 aTempPos12.setX(aPos12.X() + nDX);
1774 aTempPos21.setX(aPos21.X() + nDX);
1775 aTempPos22.setX(aPos22.X() + nDX);
1776 }
1777 else
1778 {
1779 nDX++;
1780 aTempPos11.setX(aPos11.X() - nDX);
1781 aTempPos12.setX(aPos12.X() - nDX);
1782 aTempPos21.setX(aPos21.X() - nDX);
1783 aTempPos22.setX(aPos22.X() - nDX);
1784 }
1785 rDev.DrawLine(aTempPos11, aTempPos12);
1786 rDev.DrawLine(aTempPos21, aTempPos22);
1787 }
1788 }
1789
1790 rDev.Pop();
1791 break;
1792 }
1793 }
1794}
1795
1796void DbCheckBox::updateFromModel( Reference< XPropertySet > _rxModel )
1797{
1798 OSL_ENSURE( _rxModel.is() && m_pWindow, "DbCheckBox::updateFromModel: invalid call!" );
1799
1800 sal_Int16 nState = TRISTATE_INDET;
1801 _rxModel->getPropertyValue( FM_PROP_STATE ) >>= nState;
1802 static_cast< CheckBoxControl* >( m_pWindow.get() )->SetState( static_cast< TriState >( nState ) );
1803}
1804
1806{
1807 m_rColumn.getModel()->setPropertyValue( FM_PROP_STATE,
1808 Any( static_cast<sal_Int16>( static_cast< CheckBoxControl* >( m_pWindow.get() )->GetState() ) ) );
1809 return true;
1810}
1811
1812OUString DbCheckBox::GetFormatText(const Reference< XColumn >& /*_rxField*/, const Reference< XNumberFormatter >& /*xFormatter*/, const Color** /*ppColor*/)
1813{
1814 return OUString();
1815}
1816
1817DbPatternField::DbPatternField( DbGridColumn& _rColumn, const Reference<XComponentContext>& _rContext )
1818 :DbCellControl( _rColumn )
1819 ,m_xContext( _rContext )
1820{
1824}
1825
1826void DbPatternField::implAdjustGenericFieldSetting( const Reference< XPropertySet >& _rxModel )
1827{
1828 DBG_ASSERT( m_pWindow, "DbPatternField::implAdjustGenericFieldSetting: not to be called without window!" );
1829 DBG_ASSERT( _rxModel.is(), "DbPatternField::implAdjustGenericFieldSetting: invalid model!" );
1830 if ( !m_pWindow || !_rxModel.is() )
1831 return;
1832
1833 OUString aLitMask;
1834 OUString aEditMask;
1835 bool bStrict = false;
1836
1837 _rxModel->getPropertyValue( FM_PROP_LITERALMASK ) >>= aLitMask;
1838 _rxModel->getPropertyValue( FM_PROP_EDITMASK ) >>= aEditMask;
1839 _rxModel->getPropertyValue( FM_PROP_STRICTFORMAT ) >>= bStrict;
1840
1841 OString aAsciiEditMask(OUStringToOString(aEditMask, RTL_TEXTENCODING_ASCII_US));
1842
1843 weld::PatternFormatter& rEditFormatter = static_cast<PatternControl*>(m_pWindow.get())->get_formatter();
1844 rEditFormatter.SetMask(aAsciiEditMask, aLitMask);
1845 rEditFormatter.SetStrictFormat(bStrict);
1846
1847 weld::PatternFormatter& rPaintFormatter = static_cast<PatternControl*>(m_pPainter.get())->get_formatter();
1848 rPaintFormatter.SetMask(aAsciiEditMask, aLitMask);
1849 rPaintFormatter.SetStrictFormat(bStrict);
1850}
1851
1852void DbPatternField::Init(BrowserDataWin& rParent, const Reference< XRowSet >& xCursor)
1853{
1855
1858
1859 Reference< XPropertySet > xModel( m_rColumn.getModel() );
1861
1862 DbCellControl::Init( rParent, xCursor );
1863}
1864
1866{
1867 return new EditCellController(static_cast<PatternControl*>(m_pWindow.get()));
1868}
1869
1870OUString DbPatternField::impl_formatText( const OUString& _rText )
1871{
1872 weld::PatternFormatter& rPaintFormatter = static_cast<PatternControl*>(m_pPainter.get())->get_formatter();
1873 rPaintFormatter.get_widget().set_text(_rText);
1874 rPaintFormatter.ReformatAll();
1875 return rPaintFormatter.get_widget().get_text();
1876}
1877
1878OUString DbPatternField::GetFormatText(const Reference< css::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& /*xFormatter*/, const Color** /*ppColor*/)
1879{
1880 bool bIsForPaint = _rxField != m_rColumn.GetField();
1881 ::std::unique_ptr< FormattedColumnValue >& rpFormatter = bIsForPaint ? m_pPaintFormatter : m_pValueFormatter;
1882
1883 if (!rpFormatter)
1884 {
1885 rpFormatter = std::make_unique< FormattedColumnValue> (
1886 m_xContext, getCursor(), Reference< XPropertySet >( _rxField, UNO_QUERY ) );
1887 OSL_ENSURE(rpFormatter, "DbPatternField::Init: no value formatter!");
1888 }
1889 else
1890 OSL_ENSURE( rpFormatter->getColumn() == _rxField, "DbPatternField::GetFormatText: my value formatter is working for another field ...!" );
1891 // re-creating the value formatter here every time would be quite expensive ...
1892
1893 OUString sText;
1894 if (rpFormatter)
1895 sText = rpFormatter->getFormattedValue();
1896
1897 return impl_formatText( sText );
1898}
1899
1900void DbPatternField::UpdateFromField( const Reference< XColumn >& _rxField, const Reference< XNumberFormatter >& _rxFormatter )
1901{
1902 weld::Entry& rEntry = static_cast<PatternControl*>(m_pWindow.get())->get_widget();
1903 rEntry.set_text(GetFormatText(_rxField, _rxFormatter));
1904 rEntry.select_region(-1, 0);
1905}
1906
1907void DbPatternField::updateFromModel( Reference< XPropertySet > _rxModel )
1908{
1909 OSL_ENSURE( _rxModel.is() && m_pWindow, "DbPatternField::updateFromModel: invalid call!" );
1910
1911 OUString sText;
1912 _rxModel->getPropertyValue( FM_PROP_TEXT ) >>= sText;
1913
1914 weld::Entry& rEntry = static_cast<PatternControl*>(m_pWindow.get())->get_widget();
1915 rEntry.set_text(impl_formatText(sText));
1916 rEntry.select_region(-1, 0);
1917}
1918
1920{
1921 weld::Entry& rEntry = static_cast<PatternControl*>(m_pWindow.get())->get_widget();
1922 m_rColumn.getModel()->setPropertyValue(FM_PROP_TEXT, Any(rEntry.get_text()));
1923 return true;
1924}
1925
1926DbSpinField::DbSpinField( DbGridColumn& _rColumn, sal_Int16 _nStandardAlign )
1927 :DbCellControl( _rColumn )
1928 ,m_nStandardAlign( _nStandardAlign )
1929{
1930}
1931
1932void DbSpinField::Init(BrowserDataWin& _rParent, const Reference< XRowSet >& _rxCursor)
1933{
1935
1936 Reference< XPropertySet > xModel( m_rColumn.getModel() );
1937
1938 // determine if we need a spinbutton version
1939 bool bSpinButton(false);
1940 if ( ::comphelper::getBOOL( xModel->getPropertyValue( FM_PROP_SPIN ) ) )
1941 bSpinButton = true;
1942 // create the fields
1943 m_pWindow = createField( &_rParent, bSpinButton, xModel );
1944 m_pPainter = createField( &_rParent, bSpinButton, xModel );
1945
1946 // adjust all other settings which depend on the property values
1948
1949 // call the base class
1950 DbCellControl::Init( _rParent, _rxCursor );
1951}
1952
1954{
1955 return new ::svt::FormattedFieldCellController(static_cast<FormattedControlBase*>(m_pWindow.get()));
1956}
1957
1959 :DbSpinField( _rColumn )
1960{
1967}
1968
1969void DbNumericField::implAdjustGenericFieldSetting( const Reference< XPropertySet >& _rxModel )
1970{
1971 DBG_ASSERT( m_pWindow, "DbNumericField::implAdjustGenericFieldSetting: not to be called without window!" );
1972 DBG_ASSERT( _rxModel.is(), "DbNumericField::implAdjustGenericFieldSetting: invalid model!" );
1973 if ( !m_pWindow || !_rxModel.is() )
1974 return;
1975
1976 sal_Int32 nMin = static_cast<sal_Int32>(getDouble( _rxModel->getPropertyValue( FM_PROP_VALUEMIN ) ));
1977 sal_Int32 nMax = static_cast<sal_Int32>(getDouble( _rxModel->getPropertyValue( FM_PROP_VALUEMAX ) ));
1978 sal_Int32 nStep = static_cast<sal_Int32>(getDouble( _rxModel->getPropertyValue( FM_PROP_VALUESTEP ) ));
1979 bool bStrict = getBOOL( _rxModel->getPropertyValue( FM_PROP_STRICTFORMAT ) );
1980 sal_Int16 nScale = getINT16( _rxModel->getPropertyValue( FM_PROP_DECIMAL_ACCURACY ) );
1981 bool bThousand = getBOOL( _rxModel->getPropertyValue( FM_PROP_SHOWTHOUSANDSEP ) );
1982
1983 Formatter& rEditFormatter = static_cast<FormattedControlBase*>(m_pWindow.get())->get_formatter();
1984 rEditFormatter.SetMinValue(nMin);
1985 rEditFormatter.SetMaxValue(nMax);
1986 rEditFormatter.SetSpinSize(nStep);
1987 rEditFormatter.SetStrictFormat(bStrict);
1988
1989 Formatter& rPaintFormatter = static_cast<FormattedControlBase*>(m_pPainter.get())->get_formatter();
1990 rPaintFormatter.SetMinValue(nMin);
1991 rPaintFormatter.SetMaxValue(nMax);
1992 rPaintFormatter.SetStrictFormat(bStrict);
1993
1994 // give a formatter to the field and the painter;
1995 // test first if I can get from the service behind a connection
1996 Reference< css::util::XNumberFormatsSupplier > xSupplier;
1997 Reference< XRowSet > xForm;
1999 xForm.set( Reference< XInterface >(*m_rColumn.GetParent().getDataSource()), UNO_QUERY );
2000 if ( xForm.is() )
2001 xSupplier = getNumberFormats( getConnection( xForm ), true );
2002 SvNumberFormatter* pFormatterUsed = nullptr;
2003 if ( xSupplier.is() )
2004 {
2005 SvNumberFormatsSupplierObj* pImplementation = comphelper::getFromUnoTunnel<SvNumberFormatsSupplierObj>( xSupplier );
2006 pFormatterUsed = pImplementation ? pImplementation->GetNumberFormatter() : nullptr;
2007 }
2008 if ( nullptr == pFormatterUsed )
2009 { // the cursor didn't lead to success -> standard
2010 pFormatterUsed = rEditFormatter.StandardFormatter();
2011 DBG_ASSERT( pFormatterUsed != nullptr, "DbNumericField::implAdjustGenericFieldSetting: no standard formatter given by the numeric field !" );
2012 }
2013 rEditFormatter.SetFormatter( pFormatterUsed );
2014 rPaintFormatter.SetFormatter( pFormatterUsed );
2015
2016 // and then generate a format which has the desired length after the decimal point, etc.
2018 OUString sFormatString = pFormatterUsed->GenerateFormat(0, aAppLanguage, bThousand, false, nScale);
2019
2020 rEditFormatter.SetFormat( sFormatString, aAppLanguage );
2021 rPaintFormatter.SetFormat( sFormatString, aAppLanguage );
2022}
2023
2024VclPtr<svt::ControlBase> DbNumericField::createField(BrowserDataWin* pParent, bool bSpinButton, const Reference<XPropertySet>& /*rxModel*/)
2025{
2026 return VclPtr<DoubleNumericControl>::Create(pParent, bSpinButton);
2027}
2028
2029namespace
2030{
2031 OUString lcl_setFormattedNumeric_nothrow( FormattedControlBase& _rField, const DbCellControl& _rControl,
2032 const Reference< XColumn >& _rxField, const Reference< XNumberFormatter >& _rxFormatter )
2033 {
2034 OUString sValue;
2035 if ( _rxField.is() )
2036 {
2037 try
2038 {
2039 double fValue = _rControl.GetValue( _rxField, _rxFormatter );
2040 if ( !_rxField->wasNull() )
2041 {
2042 _rField.get_formatter().SetValue(fValue);
2043 sValue = _rField.get_widget().get_text();
2044 }
2045 }
2046 catch( const Exception& )
2047 {
2049 }
2050 }
2051 return sValue;
2052 }
2053}
2054
2055OUString DbNumericField::GetFormatText(const Reference< css::sdb::XColumn >& _rxField, const Reference< css::util::XNumberFormatter >& _rxFormatter, const Color** /*ppColor*/)
2056{
2057 return lcl_setFormattedNumeric_nothrow(dynamic_cast<FormattedControlBase&>(*m_pPainter), *this, _rxField, _rxFormatter);
2058}
2059
2060void DbNumericField::UpdateFromField(const Reference< css::sdb::XColumn >& _rxField, const Reference< css::util::XNumberFormatter >& _rxFormatter)
2061{
2062 lcl_setFormattedNumeric_nothrow(dynamic_cast<FormattedControlBase&>(*m_pWindow), *this, _rxField, _rxFormatter);
2063}
2064
2065void DbNumericField::updateFromModel( Reference< XPropertySet > _rxModel )
2066{
2067 OSL_ENSURE( _rxModel.is() && m_pWindow, "DbNumericField::updateFromModel: invalid call!" );
2068
2069 FormattedControlBase* pControl = static_cast<FormattedControlBase*>(m_pWindow.get());
2070
2071 double dValue = 0;
2072 if ( _rxModel->getPropertyValue( FM_PROP_VALUE ) >>= dValue )
2073 {
2074 Formatter& rFormatter = pControl->get_formatter();
2075 rFormatter.SetValue(dValue);
2076 }
2077 else
2078 pControl->get_widget().set_text(OUString());
2079}
2080
2082{
2083 FormattedControlBase* pControl = static_cast<FormattedControlBase*>(m_pWindow.get());
2084 OUString aText(pControl->get_widget().get_text());
2085 Any aVal;
2086
2087 if (!aText.isEmpty()) // not empty
2088 {
2089 Formatter& rFormatter = pControl->get_formatter();
2090 double fValue = rFormatter.GetValue();
2091 aVal <<= fValue;
2092 }
2093 m_rColumn.getModel()->setPropertyValue(FM_PROP_VALUE, aVal);
2094 return true;
2095}
2096
2098 :DbSpinField( _rColumn )
2099{
2107}
2108
2109void DbCurrencyField::implAdjustGenericFieldSetting( const Reference< XPropertySet >& _rxModel )
2110{
2111 DBG_ASSERT( m_pWindow, "DbCurrencyField::implAdjustGenericFieldSetting: not to be called without window!" );
2112 DBG_ASSERT( _rxModel.is(), "DbCurrencyField::implAdjustGenericFieldSetting: invalid model!" );
2113 if ( !m_pWindow || !_rxModel.is() )
2114 return;
2115
2116 sal_Int16 nScale = getINT16( _rxModel->getPropertyValue( FM_PROP_DECIMAL_ACCURACY ) );
2117 double nMin = getDouble( _rxModel->getPropertyValue( FM_PROP_VALUEMIN ) );
2118 double nMax = getDouble( _rxModel->getPropertyValue( FM_PROP_VALUEMAX ) );
2119 double nStep = getDouble( _rxModel->getPropertyValue( FM_PROP_VALUESTEP ) );
2120 bool bStrict = getBOOL( _rxModel->getPropertyValue( FM_PROP_STRICTFORMAT ) );
2121 bool bThousand = getBOOL( _rxModel->getPropertyValue( FM_PROP_SHOWTHOUSANDSEP ) );
2122 OUString aStr( getString( _rxModel->getPropertyValue(FM_PROP_CURRENCYSYMBOL ) ) );
2123
2124 Formatter& rEditFormatter = static_cast<FormattedControlBase*>(m_pWindow.get())->get_formatter();
2125 rEditFormatter.SetDecimalDigits(nScale);
2126 rEditFormatter.SetMinValue(nMin);
2127 rEditFormatter.SetMaxValue(nMax);
2128 rEditFormatter.SetSpinSize(nStep);
2129 rEditFormatter.SetStrictFormat(bStrict);
2130 weld::LongCurrencyFormatter& rCurrencyEditFormatter = static_cast<weld::LongCurrencyFormatter&>(rEditFormatter);
2131 rCurrencyEditFormatter.SetUseThousandSep(bThousand);
2132 rCurrencyEditFormatter.SetCurrencySymbol(aStr);
2133
2134 Formatter& rPaintFormatter = static_cast<FormattedControlBase*>(m_pPainter.get())->get_formatter();
2135 rPaintFormatter.SetDecimalDigits(nScale);
2136 rPaintFormatter.SetMinValue(nMin);
2137 rPaintFormatter.SetMaxValue(nMax);
2138 rPaintFormatter.SetStrictFormat(bStrict);
2139 weld::LongCurrencyFormatter& rPaintCurrencyFormatter = static_cast<weld::LongCurrencyFormatter&>(rPaintFormatter);
2140 rPaintCurrencyFormatter.SetUseThousandSep(bThousand);
2141 rPaintCurrencyFormatter.SetCurrencySymbol(aStr);
2142}
2143
2144VclPtr<svt::ControlBase> DbCurrencyField::createField(BrowserDataWin* pParent, bool bSpinButton, const Reference< XPropertySet >& /*rxModel*/)
2145{
2146 return VclPtr<LongCurrencyControl>::Create(pParent, bSpinButton);
2147}
2148
2149namespace
2150{
2151 OUString lcl_setFormattedCurrency_nothrow( FormattedControlBase& _rField, const DbCurrencyField& _rControl,
2152 const Reference< XColumn >& _rxField, const Reference< XNumberFormatter >& _rxFormatter )
2153 {
2154 OUString sValue;
2155 if ( _rxField.is() )
2156 {
2157 try
2158 {
2159 double fValue = _rControl.GetValue( _rxField, _rxFormatter );
2160 if ( !_rxField->wasNull() )
2161 {
2162 _rField.get_formatter().SetValue(fValue);
2163 sValue = _rField.get_widget().get_text();
2164 }
2165 }
2166 catch( const Exception& )
2167 {
2169 }
2170 }
2171 return sValue;
2172 }
2173}
2174
2175OUString DbCurrencyField::GetFormatText(const Reference< css::sdb::XColumn >& _rxField, const Reference< css::util::XNumberFormatter >& _rxFormatter, const Color** /*ppColor*/)
2176{
2177 return lcl_setFormattedCurrency_nothrow(dynamic_cast<FormattedControlBase&>(*m_pPainter), *this, _rxField, _rxFormatter);
2178}
2179
2180void DbCurrencyField::UpdateFromField(const Reference< css::sdb::XColumn >& _rxField, const Reference< css::util::XNumberFormatter >& _rxFormatter)
2181{
2182 lcl_setFormattedCurrency_nothrow(dynamic_cast<FormattedControlBase&>(*m_pWindow), *this, _rxField, _rxFormatter);
2183}
2184
2185void DbCurrencyField::updateFromModel( Reference< XPropertySet > _rxModel )
2186{
2187 OSL_ENSURE( _rxModel.is() && m_pWindow, "DbCurrencyField::updateFromModel: invalid call!" );
2188
2189 FormattedControlBase* pControl = static_cast<FormattedControlBase*>(m_pWindow.get());
2190
2191 double dValue = 0;
2192 if ( _rxModel->getPropertyValue( FM_PROP_VALUE ) >>= dValue )
2193 {
2194 Formatter& rFormatter = pControl->get_formatter();
2195 rFormatter.SetValue(dValue);
2196 }
2197 else
2198 pControl->get_widget().set_text(OUString());
2199}
2200
2202{
2203 FormattedControlBase* pControl = static_cast<FormattedControlBase*>(m_pWindow.get());
2204 OUString aText(pControl->get_widget().get_text());
2205 Any aVal;
2206
2207 if (!aText.isEmpty()) // not empty
2208 {
2209 Formatter& rFormatter = pControl->get_formatter();
2210 double fValue = rFormatter.GetValue();
2211 aVal <<= fValue;
2212 }
2213 m_rColumn.getModel()->setPropertyValue(FM_PROP_VALUE, aVal);
2214 return true;
2215}
2216
2218 :DbSpinField( _rColumn )
2219{
2225}
2226
2227VclPtr<svt::ControlBase> DbDateField::createField(BrowserDataWin* pParent, bool bSpinButton, const Reference< XPropertySet >& rxModel)
2228{
2229 // check if there is a DropDown property set to TRUE
2230 bool bDropDown = !hasProperty( FM_PROP_DROPDOWN, rxModel )
2231 || getBOOL( rxModel->getPropertyValue( FM_PROP_DROPDOWN ) );
2232 // given the apparent inability to set a custom up/down action for a gtk
2233 // spinbutton to have different up/down dates depending on the zone the
2234 // mouse is in, show the dropdown calendar for both the spin or dropdown case
2235 return VclPtr<DateControl>::Create(pParent, bSpinButton || bDropDown);
2236}
2237
2238void DbDateField::implAdjustGenericFieldSetting( const Reference< XPropertySet >& _rxModel )
2239{
2240 DBG_ASSERT( m_pWindow, "DbDateField::implAdjustGenericFieldSetting: not to be called without window!" );
2241 DBG_ASSERT( _rxModel.is(), "DbDateField::implAdjustGenericFieldSetting: invalid model!" );
2242 if ( !m_pWindow || !_rxModel.is() )
2243 return;
2244
2245 sal_Int16 nFormat = getINT16( _rxModel->getPropertyValue( FM_PROP_DATEFORMAT ) );
2246 util::Date aMin;
2247 OSL_VERIFY( _rxModel->getPropertyValue( FM_PROP_DATEMIN ) >>= aMin );
2248 util::Date aMax;
2249 OSL_VERIFY( _rxModel->getPropertyValue( FM_PROP_DATEMAX ) >>= aMax );
2250 bool bStrict = getBOOL( _rxModel->getPropertyValue( FM_PROP_STRICTFORMAT ) );
2251
2252 FormattedControlBase* pControl = static_cast<FormattedControlBase*>(m_pWindow.get());
2253 weld::DateFormatter& rControlFormatter = static_cast<weld::DateFormatter&>(pControl->get_formatter());
2254
2255 FormattedControlBase* pPainter = static_cast<FormattedControlBase*>(m_pPainter.get());
2256 weld::DateFormatter& rPainterFormatter = static_cast<weld::DateFormatter&>(pPainter->get_formatter());
2257
2258 Any aCentury = _rxModel->getPropertyValue( FM_PROP_DATE_SHOW_CENTURY );
2259 if ( aCentury.getValueType().getTypeClass() != TypeClass_VOID )
2260 {
2261 bool bShowDateCentury = getBOOL( aCentury );
2262
2263 rControlFormatter.SetShowDateCentury(bShowDateCentury);
2264 rPainterFormatter.SetShowDateCentury(bShowDateCentury);
2265 }
2266
2267 rControlFormatter.SetExtDateFormat( static_cast<ExtDateFieldFormat>(nFormat) );
2268 rControlFormatter.SetMin( aMin );
2269 rControlFormatter.SetMax( aMax );
2270 rControlFormatter.SetStrictFormat( bStrict );
2271 rControlFormatter.EnableEmptyField( true );
2272
2273 rPainterFormatter.SetExtDateFormat( static_cast<ExtDateFieldFormat>(nFormat) );
2274 rPainterFormatter.SetMin( aMin );
2275 rPainterFormatter.SetMax( aMax );
2276 rPainterFormatter.SetStrictFormat( bStrict );
2277 rPainterFormatter.EnableEmptyField( true );
2278}
2279
2280namespace
2281{
2282 OUString lcl_setFormattedDate_nothrow(DateControl& _rField, const Reference<XColumn>& _rxField)
2283 {
2284 OUString sDate;
2285 if ( _rxField.is() )
2286 {
2287 try
2288 {
2289 css::util::Date aValue = _rxField->getDate();
2290 if (!_rxField->wasNull())
2291 {
2292 _rField.SetDate(::Date(aValue.Day, aValue.Month, aValue.Year));
2293 sDate = _rField.get_widget().get_text();
2294 }
2295 }
2296 catch( const Exception& )
2297 {
2299 }
2300 }
2301 return sDate;
2302 }
2303}
2304
2305OUString DbDateField::GetFormatText(const Reference< css::sdb::XColumn >& _rxField, const Reference< css::util::XNumberFormatter >& /*xFormatter*/, const Color** /*ppColor*/)
2306{
2307 return lcl_setFormattedDate_nothrow(*static_cast<DateControl*>(m_pPainter.get()), _rxField);
2308}
2309
2310void DbDateField::UpdateFromField(const Reference< css::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& /*xFormatter*/)
2311{
2312 lcl_setFormattedDate_nothrow(*static_cast<DateControl*>(m_pWindow.get()), _rxField);
2313}
2314
2315void DbDateField::updateFromModel( Reference< XPropertySet > _rxModel )
2316{
2317 OSL_ENSURE( _rxModel.is() && m_pWindow, "DbDateField::updateFromModel: invalid call!" );
2318
2319 DateControl* pControl = static_cast<DateControl*>(m_pWindow.get());
2320
2321 util::Date aDate;
2322 if ( _rxModel->getPropertyValue( FM_PROP_DATE ) >>= aDate )
2323 pControl->SetDate(::Date(aDate));
2324 else
2325 pControl->get_widget().set_text(OUString());
2326}
2327
2329{
2330 FormattedControlBase* pControl = static_cast<FormattedControlBase*>(m_pWindow.get());
2331 OUString aText(pControl->get_widget().get_text());
2332 Any aVal;
2333
2334 if (!aText.isEmpty()) // not empty
2335 {
2336 weld::DateFormatter& rControlFormatter = static_cast<weld::DateFormatter&>(pControl->get_formatter());
2337 aVal <<= rControlFormatter.GetDate().GetUNODate();
2338 }
2339
2340 m_rColumn.getModel()->setPropertyValue(FM_PROP_DATE, aVal);
2341 return true;
2342}
2343
2345 :DbSpinField( _rColumn, css::awt::TextAlign::LEFT )
2346{
2351}
2352
2353VclPtr<svt::ControlBase> DbTimeField::createField(BrowserDataWin* pParent, bool bSpinButton, const Reference< XPropertySet >& /*rxModel*/ )
2354{
2355 return VclPtr<TimeControl>::Create(pParent, bSpinButton);
2356}
2357
2358void DbTimeField::implAdjustGenericFieldSetting( const Reference< XPropertySet >& _rxModel )
2359{
2360 DBG_ASSERT( m_pWindow, "DbTimeField::implAdjustGenericFieldSetting: not to be called without window!" );
2361 DBG_ASSERT( _rxModel.is(), "DbTimeField::implAdjustGenericFieldSetting: invalid model!" );
2362 if ( !m_pWindow || !_rxModel.is() )
2363 return;
2364
2365 sal_Int16 nFormat = getINT16( _rxModel->getPropertyValue( FM_PROP_TIMEFORMAT ) );
2366 util::Time aMin;
2367 OSL_VERIFY( _rxModel->getPropertyValue( FM_PROP_TIMEMIN ) >>= aMin );
2368 util::Time aMax;
2369 OSL_VERIFY( _rxModel->getPropertyValue( FM_PROP_TIMEMAX ) >>= aMax );
2370 bool bStrict = getBOOL( _rxModel->getPropertyValue( FM_PROP_STRICTFORMAT ) );
2371
2372 FormattedControlBase* pControl = static_cast<FormattedControlBase*>(m_pWindow.get());
2373 weld::TimeFormatter& rControlFormatter = static_cast<weld::TimeFormatter&>(pControl->get_formatter());
2374
2375 rControlFormatter.SetExtFormat(static_cast<ExtTimeFieldFormat>(nFormat));
2376 rControlFormatter.SetMin(aMin);
2377 rControlFormatter.SetMax(aMax);
2378 rControlFormatter.SetStrictFormat(bStrict);
2379 rControlFormatter.EnableEmptyField(true);
2380
2381 FormattedControlBase* pPainter = static_cast<FormattedControlBase*>(m_pPainter.get());
2382 weld::TimeFormatter& rPainterFormatter = static_cast<weld::TimeFormatter&>(pPainter->get_formatter());
2383
2384 rPainterFormatter.SetExtFormat(static_cast<ExtTimeFieldFormat>(nFormat));
2385 rPainterFormatter.SetMin(aMin);
2386 rPainterFormatter.SetMax(aMax);
2387 rPainterFormatter.SetStrictFormat(bStrict);
2388 rPainterFormatter.EnableEmptyField(true);
2389}
2390
2391namespace
2392{
2393 OUString lcl_setFormattedTime_nothrow(TimeControl& _rField, const Reference<XColumn>& _rxField)
2394 {
2395 OUString sTime;
2396 if ( _rxField.is() )
2397 {
2398 try
2399 {
2400 css::util::Time aValue = _rxField->getTime();
2401 if (!_rxField->wasNull())
2402 {
2403 static_cast<weld::TimeFormatter&>(_rField.get_formatter()).SetTime( ::tools::Time( aValue ) );
2404 sTime = _rField.get_widget().get_text();
2405 }
2406 }
2407 catch( const Exception& )
2408 {
2410 }
2411 }
2412 return sTime;
2413 }
2414}
2415
2416OUString DbTimeField::GetFormatText(const Reference< css::sdb::XColumn >& _rxField, const Reference< css::util::XNumberFormatter >& /*xFormatter*/, const Color** /*ppColor*/)
2417{
2418 return lcl_setFormattedTime_nothrow(*static_cast<TimeControl*>(m_pPainter.get()), _rxField);
2419}
2420
2421void DbTimeField::UpdateFromField(const Reference< css::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& /*xFormatter*/)
2422{
2423 lcl_setFormattedTime_nothrow(*static_cast<TimeControl*>(m_pWindow.get()), _rxField);
2424}
2425
2426void DbTimeField::updateFromModel( Reference< XPropertySet > _rxModel )
2427{
2428 OSL_ENSURE( _rxModel.is() && m_pWindow, "DbTimeField::updateFromModel: invalid call!" );
2429
2430 FormattedControlBase* pControl = static_cast<FormattedControlBase*>(m_pWindow.get());
2431 weld::TimeFormatter& rControlFormatter = static_cast<weld::TimeFormatter&>(pControl->get_formatter());
2432
2433 util::Time aTime;
2434 if ( _rxModel->getPropertyValue( FM_PROP_TIME ) >>= aTime )
2435 rControlFormatter.SetTime(::tools::Time(aTime));
2436 else
2437 pControl->get_widget().set_text(OUString());
2438}
2439
2441{
2442 FormattedControlBase* pControl = static_cast<FormattedControlBase*>(m_pWindow.get());
2443 OUString aText(pControl->get_widget().get_text());
2444 Any aVal;
2445
2446 if (!aText.isEmpty()) // not empty
2447 {
2448 weld::TimeFormatter& rControlFormatter = static_cast<weld::TimeFormatter&>(pControl->get_formatter());
2449 aVal <<= rControlFormatter.GetTime().GetUNOTime();
2450 }
2451
2452 m_rColumn.getModel()->setPropertyValue(FM_PROP_TIME, aVal);
2453 return true;
2454}
2455
2457 :DbCellControl(_rColumn)
2458{
2459 setAlignedController( false );
2460
2463}
2464
2465void DbComboBox::_propertyChanged( const PropertyChangeEvent& _rEvent )
2466{
2467 if ( _rEvent.PropertyName == FM_PROP_STRINGITEMLIST )
2468 {
2469 SetList(_rEvent.NewValue);
2470 }
2471 else
2472 {
2474 }
2475}
2476
2477void DbComboBox::SetList(const Any& rItems)
2478{
2479 ComboBoxControl* pField = static_cast<ComboBoxControl*>(m_pWindow.get());
2480 weld::ComboBox& rComboBox = pField->get_widget();
2481 rComboBox.clear();
2482
2483 css::uno::Sequence<OUString> aTest;
2484 if (rItems >>= aTest)
2485 {
2486 for (const OUString& rString : std::as_const(aTest))
2487 rComboBox.append_text(rString);
2488
2489 // tell the grid control that this controller is invalid and has to be re-initialized
2491 }
2492}
2493
2494void DbComboBox::implAdjustGenericFieldSetting(const Reference<XPropertySet>&)
2495{
2496 // we no longer pay attention to FM_PROP_LINECOUNT
2497}
2498
2499void DbComboBox::Init(BrowserDataWin& rParent, const Reference< XRowSet >& xCursor)
2500{
2501 m_rColumn.SetAlignmentFromModel(css::awt::TextAlign::LEFT);
2502
2504
2505 // selection from right to left
2506 AllSettings aSettings = m_pWindow->GetSettings();
2507 StyleSettings aStyleSettings = aSettings.GetStyleSettings();
2508 aStyleSettings.SetSelectionOptions(
2509 aStyleSettings.GetSelectionOptions() | SelectionOptions::ShowFirst);
2510 aSettings.SetStyleSettings(aStyleSettings);
2511 m_pWindow->SetSettings(aSettings, true);
2512
2513 // some initial properties
2514 Reference< XPropertySet > xModel(m_rColumn.getModel());
2515 SetList( xModel->getPropertyValue( FM_PROP_STRINGITEMLIST ) );
2517
2518 DbCellControl::Init( rParent, xCursor );
2519}
2520
2522{
2523 return new ComboBoxCellController(static_cast<ComboBoxControl*>(m_pWindow.get()));
2524}
2525
2526OUString DbComboBox::GetFormatText(const Reference< css::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& xFormatter, const Color** /*ppColor*/)
2527{
2528 const css::uno::Reference<css::beans::XPropertySet> xPS(_rxField, UNO_QUERY);
2529 ::dbtools::FormattedColumnValue fmter( xFormatter, xPS );
2530
2531 return fmter.getFormattedValue();
2532}
2533
2534void DbComboBox::UpdateFromField(const Reference< css::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& xFormatter)
2535{
2536 ComboBoxControl* pControl = static_cast<ComboBoxControl*>(m_pWindow.get());
2537 pControl->get_widget().set_entry_text(GetFormatText(_rxField, xFormatter));
2538}
2539
2540void DbComboBox::updateFromModel( Reference< XPropertySet > _rxModel )
2541{
2542 OSL_ENSURE( _rxModel.is() && m_pWindow, "DbComboBox::updateFromModel: invalid call!" );
2543
2544 OUString sText;
2545 _rxModel->getPropertyValue( FM_PROP_TEXT ) >>= sText;
2546
2547 ComboBoxControl* pControl = static_cast<ComboBoxControl*>(m_pWindow.get());
2548 weld::ComboBox& rComboBox = pControl->get_widget();
2549
2550 OUString sOldActive = rComboBox.get_active_text();
2551 rComboBox.set_entry_text(sText);
2552 rComboBox.select_entry_region(0, -1);
2553
2554 if (sOldActive != rComboBox.get_active_text())
2555 pControl->TriggerAuxModify();
2556}
2557
2559{
2560 ComboBoxControl* pControl = static_cast<ComboBoxControl*>(m_pWindow.get());
2561 weld::ComboBox& rComboBox = pControl->get_widget();
2562 OUString aText(rComboBox.get_active_text());
2563 m_rColumn.getModel()->setPropertyValue(FM_PROP_TEXT, Any(aText));
2564 return true;
2565}
2566
2567
2569 :DbCellControl(_rColumn)
2570 ,m_bBound(false)
2571{
2572 setAlignedController( false );
2573
2576}
2577
2578void DbListBox::_propertyChanged( const css::beans::PropertyChangeEvent& _rEvent )
2579{
2580 if ( _rEvent.PropertyName == FM_PROP_STRINGITEMLIST )
2581 {
2582 SetList(_rEvent.NewValue);
2583 }
2584 else
2585 {
2587 }
2588}
2589
2590void DbListBox::SetList(const Any& rItems)
2591{
2592 ListBoxControl* pField = static_cast<ListBoxControl*>(m_pWindow.get());
2593
2594 weld::ComboBox& rFieldList = pField->get_widget();
2595
2596 rFieldList.clear();
2597 m_bBound = false;
2598
2599 css::uno::Sequence<OUString> aTest;
2600 if (!(rItems >>= aTest))
2601 return;
2602
2603 if (aTest.hasElements())
2604 {
2605 for (const OUString& rString : std::as_const(aTest))
2606 rFieldList.append_text(rString);
2607
2608 m_rColumn.getModel()->getPropertyValue(FM_PROP_VALUE_SEQ) >>= m_aValueList;
2609 m_bBound = m_aValueList.hasElements();
2610
2611 // tell the grid control that this controller is invalid and has to be re-initialized
2613 }
2614}
2615
2616void DbListBox::Init(BrowserDataWin& rParent, const Reference< XRowSet >& xCursor)
2617{
2618 m_rColumn.SetAlignment(css::awt::TextAlign::LEFT);
2619
2621
2622 // some initial properties
2623 Reference< XPropertySet > xModel( m_rColumn.getModel() );
2624 SetList( xModel->getPropertyValue( FM_PROP_STRINGITEMLIST ) );
2626
2627 DbCellControl::Init( rParent, xCursor );
2628}
2629
2630void DbListBox::implAdjustGenericFieldSetting( const Reference< XPropertySet >& /*rxModel*/ )
2631{
2632 // ignore FM_PROP_LINECOUNT
2633}
2634
2636{
2637 return new ListBoxCellController(static_cast<ListBoxControl*>(m_pWindow.get()));
2638}
2639
2640OUString DbListBox::GetFormatText(const Reference< css::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& /*xFormatter*/, const Color** /*ppColor*/)
2641{
2642 OUString sText;
2643 if ( _rxField.is() )
2644 {
2645 try
2646 {
2647 sText = _rxField->getString();
2648 if ( m_bBound )
2649 {
2650 sal_Int32 nPos = ::comphelper::findValue( m_aValueList, sText );
2651 if ( nPos != -1 )
2652 sText = static_cast<svt::ListBoxControl*>(m_pWindow.get())->get_widget().get_text(nPos);
2653 else
2654 sText.clear();
2655 }
2656 }
2657 catch( const Exception& )
2658 {
2660 }
2661 }
2662 return sText;
2663}
2664
2665void DbListBox::UpdateFromField(const Reference< css::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& xFormatter)
2666{
2667 OUString sFormattedText( GetFormatText( _rxField, xFormatter ) );
2668 weld::ComboBox& rComboBox = static_cast<ListBoxControl*>(m_pWindow.get())->get_widget();
2669 if (!sFormattedText.isEmpty())
2670 rComboBox.set_active_text(sFormattedText);
2671 else
2672 rComboBox.set_active(-1);
2673}
2674
2675void DbListBox::updateFromModel( Reference< XPropertySet > _rxModel )
2676{
2677 OSL_ENSURE( _rxModel.is() && m_pWindow, "DbListBox::updateFromModel: invalid call!" );
2678
2679 Sequence< sal_Int16 > aSelection;
2680 _rxModel->getPropertyValue( FM_PROP_SELECT_SEQ ) >>= aSelection;
2681
2682 sal_Int16 nSelection = -1;
2683 if ( aSelection.hasElements() )
2684 nSelection = aSelection[ 0 ];
2685
2686 ListBoxControl* pControl = static_cast<ListBoxControl*>(m_pWindow.get());
2687 weld::ComboBox& rComboBox = pControl->get_widget();
2688
2689 int nOldActive = rComboBox.get_active();
2690 if (nSelection >= 0 && nSelection < rComboBox.get_count())
2691 rComboBox.set_active(nSelection);
2692 else
2693 rComboBox.set_active(-1);
2694
2695 if (nOldActive != rComboBox.get_active())
2696 pControl->TriggerAuxModify();
2697}
2698
2700{
2701 Any aVal;
2702 Sequence<sal_Int16> aSelectSeq;
2703 weld::ComboBox& rComboBox = static_cast<ListBoxControl*>(m_pWindow.get())->get_widget();
2704 auto nActive = rComboBox.get_active();
2705 if (nActive != -1)
2706 {
2707 aSelectSeq.realloc(1);
2708 *aSelectSeq.getArray() = static_cast<sal_Int16>(nActive);
2709 }
2710 aVal <<= aSelectSeq;
2711 m_rColumn.getModel()->setPropertyValue(FM_PROP_SELECT_SEQ, aVal);
2712 return true;
2713}
2714
2715DbFilterField::DbFilterField(const Reference< XComponentContext >& rxContext,DbGridColumn& _rColumn)
2716 :DbCellControl(_rColumn)
2717 ,OSQLParserClient(rxContext)
2718 ,m_nControlClass(css::form::FormComponentType::TEXTFIELD)
2719 ,m_bFilterList(false)
2720 ,m_bFilterListFilled(false)
2721{
2722
2723 setAlignedController( false );
2724}
2725
2727{
2728 if (m_nControlClass == css::form::FormComponentType::CHECKBOX)
2729 static_cast<CheckBoxControl*>(m_pWindow.get())->SetToggleHdl(Link<weld::CheckButton&,void>());
2730
2731}
2732
2734{
2735 static const DrawTextFlags nStyle = DrawTextFlags::Clip | DrawTextFlags::VCenter | DrawTextFlags::Left;
2736 switch (m_nControlClass)
2737 {
2738 case FormComponentType::CHECKBOX:
2739 {
2740 // center the checkbox within the space available
2741 CheckBoxControl* pControl = static_cast<CheckBoxControl*>(m_pPainter.get());
2742 Size aBoxSize = pControl->GetBox().get_preferred_size();
2743 tools::Rectangle aRect(Point(rRect.Left() + ((rRect.GetWidth() - aBoxSize.Width()) / 2),
2744 rRect.Top() + ((rRect.GetHeight() - aBoxSize.Height()) / 2)),
2745 aBoxSize);
2746
2747 DbCellControl::PaintCell(rDev, aRect);
2748 break;
2749 }
2750 case FormComponentType::LISTBOX:
2751 rDev.DrawText(rRect, static_cast<ListBoxControl*>(m_pWindow.get())->get_widget().get_active_text(), nStyle);
2752 break;
2753 default:
2754 rDev.DrawText(rRect, m_aText, nStyle);
2755 }
2756}
2757
2758void DbFilterField::SetList(const Any& rItems, bool bComboBox)
2759{
2760 css::uno::Sequence<OUString> aTest;
2761 rItems >>= aTest;
2762 if (!aTest.hasElements())
2763 return;
2764
2765 if (bComboBox)
2766 {
2767 ComboBoxControl* pField = static_cast<ComboBoxControl*>(m_pWindow.get());
2768 weld::ComboBox& rComboBox = pField->get_widget();
2769 for (const OUString& rString : std::as_const(aTest))
2770 rComboBox.append_text(rString);
2771 }
2772 else
2773 {
2774 ListBoxControl* pField = static_cast<ListBoxControl*>(m_pWindow.get());
2775 weld::ComboBox& rFieldBox = pField->get_widget();
2776 for (const OUString& rString : std::as_const(aTest))
2777 rFieldBox.append_text(rString);
2778
2779 m_rColumn.getModel()->getPropertyValue(FM_PROP_VALUE_SEQ) >>= m_aValueList;
2780 }
2781}
2782
2783void DbFilterField::CreateControl(BrowserDataWin* pParent, const Reference< css::beans::XPropertySet >& xModel)
2784{
2785 switch (m_nControlClass)
2786 {
2787 case css::form::FormComponentType::CHECKBOX:
2789 m_pWindow->SetPaintTransparent( true );
2790 static_cast<CheckBoxControl*>(m_pWindow.get())->SetToggleHdl(LINK(this, DbFilterField, OnToggle));
2791
2793 m_pPainter->SetPaintTransparent( true );
2794 m_pPainter->SetBackground();
2795 break;
2796 case css::form::FormComponentType::LISTBOX:
2797 {
2799 Any aItems = xModel->getPropertyValue(FM_PROP_STRINGITEMLIST);
2800 SetList(aItems, false);
2801 } break;
2802 case css::form::FormComponentType::COMBOBOX:
2803 {
2805
2806 AllSettings aSettings = m_pWindow->GetSettings();
2807 StyleSettings aStyleSettings = aSettings.GetStyleSettings();
2808 aStyleSettings.SetSelectionOptions(
2809 aStyleSettings.GetSelectionOptions() | SelectionOptions::ShowFirst);
2810 aSettings.SetStyleSettings(aStyleSettings);
2811 m_pWindow->SetSettings(aSettings, true);
2812
2813 if (!m_bFilterList)
2814 {
2815 Any aItems = xModel->getPropertyValue(FM_PROP_STRINGITEMLIST);
2816 SetList(aItems, true);
2817 }
2818
2819 } break;
2820 default:
2821 {
2823 AllSettings aSettings = m_pWindow->GetSettings();
2824 StyleSettings aStyleSettings = aSettings.GetStyleSettings();
2825 aStyleSettings.SetSelectionOptions(
2826 aStyleSettings.GetSelectionOptions() | SelectionOptions::ShowFirst);
2827 aSettings.SetStyleSettings(aStyleSettings);
2828 m_pWindow->SetSettings(aSettings, true);
2829 }
2830 }
2831}
2832
2833void DbFilterField::Init(BrowserDataWin& rParent, const Reference< XRowSet >& xCursor)
2834{
2835 Reference< css::beans::XPropertySet > xModel(m_rColumn.getModel());
2836 m_rColumn.SetAlignment(css::awt::TextAlign::LEFT);
2837
2838 if (xModel.is())
2839 {
2840 m_bFilterList = ::comphelper::hasProperty(FM_PROP_FILTERPROPOSAL, xModel) && ::comphelper::getBOOL(xModel->getPropertyValue(FM_PROP_FILTERPROPOSAL));
2841 if (m_bFilterList)
2842 m_nControlClass = css::form::FormComponentType::COMBOBOX;
2843 else
2844 {
2845 sal_Int16 nClassId = ::comphelper::getINT16(xModel->getPropertyValue(FM_PROP_CLASSID));
2846 switch (nClassId)
2847 {
2848 case FormComponentType::CHECKBOX:
2849 case FormComponentType::LISTBOX:
2850 case FormComponentType::COMBOBOX:
2851 m_nControlClass = nClassId;
2852 break;
2853 default:
2854 if (m_bFilterList)
2855 m_nControlClass = FormComponentType::COMBOBOX;
2856 else
2857 m_nControlClass = FormComponentType::TEXTFIELD;
2858 }
2859 }
2860 }
2861
2862 CreateControl( &rParent, xModel );
2863 DbCellControl::Init( rParent, xCursor );
2864
2865 // filter cells are never readonly
2866 m_pWindow->SetEditableReadOnly(false);
2867}
2868
2870{
2872 switch (m_nControlClass)
2873 {
2874 case css::form::FormComponentType::CHECKBOX:
2875 xController = new CheckBoxCellController(static_cast<CheckBoxControl*>(m_pWindow.get()));
2876 break;
2877 case css::form::FormComponentType::LISTBOX:
2878 xController = new ListBoxCellController(static_cast<ListBoxControl*>(m_pWindow.get()));
2879 break;
2880 case css::form::FormComponentType::COMBOBOX:
2881 xController = new ComboBoxCellController(static_cast<ComboBoxControl*>(m_pWindow.get()));
2882 break;
2883 default:
2884 if (m_bFilterList)
2885 xController = new ComboBoxCellController(static_cast<ComboBoxControl*>(m_pWindow.get()));
2886 else
2887 xController = new EditCellController(static_cast<EditControlBase*>(m_pWindow.get()));
2888 }
2889 return xController;
2890}
2891
2892void DbFilterField::updateFromModel( Reference< XPropertySet > _rxModel )
2893{
2894 OSL_ENSURE( _rxModel.is() && m_pWindow, "DbFilterField::updateFromModel: invalid call!" );
2895
2896 OSL_FAIL( "DbFilterField::updateFromModel: not implemented yet (how the hell did you reach this?)!" );
2897 // TODO: implement this.
2898 // remember: updateFromModel should be some kind of opposite of commitControl
2899}
2900
2902{
2903 OUString aText(m_aText);
2904 switch (m_nControlClass)
2905 {
2906 case css::form::FormComponentType::CHECKBOX:
2907 return true;
2908 case css::form::FormComponentType::LISTBOX:
2909 {
2910 aText.clear();
2911 weld::ComboBox& rComboBox = static_cast<svt::ListBoxControl*>(m_pWindow.get())->get_widget();
2912 auto nActive = rComboBox.get_active();
2913 if (nActive != -1)
2914 {
2915 sal_Int16 nPos = static_cast<sal_Int16>(nActive);
2916 if ( ( nPos >= 0 ) && ( nPos < m_aValueList.getLength() ) )
2917 aText = m_aValueList.getConstArray()[nPos];
2918 }
2919
2920 if (m_aText != aText)
2921 {
2922 m_aText = aText;
2923 m_aCommitLink.Call(*this);
2924 }
2925 return true;
2926 }
2927 case css::form::FormComponentType::COMBOBOX:
2928 {
2929 aText = static_cast<ComboBoxControl*>(m_pWindow.get())->get_widget().get_active_text();
2930 break;
2931 }
2932 default:
2933 {
2934 aText = static_cast<EditControlBase*>(m_pWindow.get())->get_widget().get_text();
2935 break;
2936 }
2937 }
2938
2939 if (m_aText != aText)
2940 {
2941 // check the text with the SQL-Parser
2942 OUString aNewText(comphelper::string::stripEnd(aText, ' '));
2943 if (!aNewText.isEmpty())
2944 {
2945 OUString aErrorMsg;
2946 Reference< XNumberFormatter > xNumberFormatter(m_rColumn.GetParent().getNumberFormatter());
2947
2948 std::unique_ptr< OSQLParseNode > pParseNode = predicateTree(aErrorMsg, aNewText,xNumberFormatter, m_rColumn.GetField());
2949 if (pParseNode != nullptr)
2950 {
2951 OUString aPreparedText;
2952
2953 css::lang::Locale aAppLocale = Application::GetSettings().GetUILanguageTag().getLocale();
2954
2955 Reference< XRowSet > xDataSourceRowSet(
2956 Reference< XInterface >(*m_rColumn.GetParent().getDataSource()), UNO_QUERY);
2957 Reference< XConnection > xConnection(getConnection(xDataSourceRowSet));
2958
2959 pParseNode->parseNodeToPredicateStr(aPreparedText,
2960 xConnection,
2961 xNumberFormatter,
2963 OUString(),
2964 aAppLocale,
2965 OUString("."),
2966 getParseContext());
2967 m_aText = aPreparedText;
2968 }
2969 else
2970 {
2971
2972 SQLException aError;
2973 aError.Message = aErrorMsg;
2975 // TODO: transport the title
2976
2977 return false;
2978 }
2979 }
2980 else
2981 m_aText = aText;
2982
2983 m_pWindow->SetText(m_aText);
2984 m_aCommitLink.Call(*this);
2985 }
2986 return true;
2987}
2988
2989
2990void DbFilterField::SetText(const OUString& rText)
2991{
2992 m_aText = rText;
2993 switch (m_nControlClass)
2994 {
2995 case css::form::FormComponentType::CHECKBOX:
2996 {
2997 TriState eState;
2998 if (rText == "1")
2999 eState = TRISTATE_TRUE;
3000 else if (rText == "0")
3001 eState = TRISTATE_FALSE;
3002 else
3003 eState = TRISTATE_INDET;
3004
3005 static_cast<CheckBoxControl*>(m_pWindow.get())->SetState(eState);
3006 static_cast<CheckBoxControl*>(m_pPainter.get())->SetState(eState);
3007 } break;
3008 case css::form::FormComponentType::LISTBOX:
3009 {
3010 sal_Int32 nPos = ::comphelper::findValue(m_aValueList, m_aText);
3011 static_cast<ListBoxControl*>(m_pWindow.get())->get_widget().set_active(nPos);
3012 } break;
3013 case css::form::FormComponentType::COMBOBOX:
3014 {
3015 static_cast<ComboBoxControl*>(m_pWindow.get())->get_widget().set_entry_text(m_aText);
3016 break;
3017 }
3018 default:
3019 {
3020 static_cast<EditControlBase*>(m_pWindow.get())->get_widget().set_text(m_aText);
3021 break;
3022 }
3023 }
3024
3025 // now force a repaint on the window
3027}
3028
3029
3031{
3032 // should we fill the combobox with a filter proposal?
3034 return;
3035
3036 m_bFilterListFilled = true;
3037 Reference< css::beans::XPropertySet > xField = m_rColumn.GetField();
3038 if (!xField.is())
3039 return;
3040
3041 OUString aName;
3042 xField->getPropertyValue(FM_PROP_NAME) >>= aName;
3043
3044 // the columnmodel
3045 Reference< css::container::XChild > xModelAsChild(m_rColumn.getModel(), UNO_QUERY);
3046 // the grid model
3047 xModelAsChild.set(xModelAsChild->getParent(),UNO_QUERY);
3048 Reference< XRowSet > xForm(xModelAsChild->getParent(), UNO_QUERY);
3049 if (!xForm.is())
3050 return;
3051
3052 Reference<XPropertySet> xFormProp(xForm,UNO_QUERY);
3053 Reference< XTablesSupplier > xSupTab;
3054 xFormProp->getPropertyValue("SingleSelectQueryComposer") >>= xSupTab;
3055
3056 Reference< XConnection > xConnection(getConnection(xForm));
3057 if (!xSupTab.is())
3058 return;
3059
3060 // search the field
3061 Reference< XColumnsSupplier > xSupCol(xSupTab,UNO_QUERY);
3062 Reference< css::container::XNameAccess > xFieldNames = xSupCol->getColumns();
3063 if (!xFieldNames->hasByName(aName))
3064 return;
3065
3066 Reference< css::container::XNameAccess > xTablesNames = xSupTab->getTables();
3067 Reference< css::beans::XPropertySet > xComposerFieldAsSet(xFieldNames->getByName(aName),UNO_QUERY);
3068
3069 if (!xComposerFieldAsSet.is() ||
3070 !::comphelper::hasProperty(FM_PROP_TABLENAME, xComposerFieldAsSet) ||
3071 !::comphelper::hasProperty(FM_PROP_FIELDSOURCE, xComposerFieldAsSet))
3072 return;
3073
3074 OUString aFieldName;
3075 OUString aTableName;
3076 xComposerFieldAsSet->getPropertyValue(FM_PROP_FIELDSOURCE) >>= aFieldName;
3077 xComposerFieldAsSet->getPropertyValue(FM_PROP_TABLENAME) >>= aTableName;
3078
3079 // no possibility to create a select statement
3080 // looking for the complete table name
3081 if (!xTablesNames->hasByName(aTableName))
3082 return;
3083
3084 // build a statement and send as query;
3085 // Access to the connection
3086 Reference< XStatement > xStatement;
3087 Reference< XResultSet > xListCursor;
3088 Reference< css::sdb::XColumn > xDataField;
3089
3090 try
3091 {
3092 Reference< XDatabaseMetaData > xMeta = xConnection->getMetaData();
3093
3094 OUString aQuote(xMeta->getIdentifierQuoteString());
3095 OUStringBuffer aStatement("SELECT DISTINCT ");
3096 aStatement.append(quoteName(aQuote, aName));
3097 if (!aFieldName.isEmpty() && aName != aFieldName)
3098 {
3099 aStatement.append(" AS ");
3100 aStatement.append(quoteName(aQuote, aFieldName));
3101 }
3102
3103 aStatement.append(" FROM ");
3104
3105 Reference< XPropertySet > xTableNameAccess(xTablesNames->getByName(aTableName), UNO_QUERY_THROW);
3106 aStatement.append(composeTableNameForSelect(xConnection, xTableNameAccess));
3107
3108 xStatement = xConnection->createStatement();
3109 Reference< css::beans::XPropertySet > xStatementProps(xStatement, UNO_QUERY);
3110 xStatementProps->setPropertyValue(FM_PROP_ESCAPE_PROCESSING, Any(true));
3111
3112 xListCursor = xStatement->executeQuery(aStatement.makeStringAndClear());
3113
3114 Reference< css::sdbcx::XColumnsSupplier > xSupplyCols(xListCursor, UNO_QUERY);
3115 Reference< css::container::XIndexAccess > xFields(xSupplyCols->getColumns(), UNO_QUERY);
3116 xDataField.set(xFields->getByIndex(0), css::uno::UNO_QUERY);
3117 if (!xDataField.is())
3118 return;
3119 }
3120 catch(const Exception&)
3121 {
3122 ::comphelper::disposeComponent(xStatement);
3123 return;
3124 }
3125
3126 sal_Int16 i = 0;
3127 ::std::vector< OUString > aStringList;
3128 aStringList.reserve(16);
3129 OUString aStr;
3130 css::util::Date aNullDate = m_rColumn.GetParent().getNullDate();
3131 sal_Int32 nFormatKey = m_rColumn.GetKey();
3132 Reference< XNumberFormatter > xFormatter = m_rColumn.GetParent().getNumberFormatter();
3133 sal_Int16 nKeyType = ::comphelper::getNumberFormatType(xFormatter->getNumberFormatsSupplier()->getNumberFormats(), nFormatKey);
3134
3135 while (!xListCursor->isAfterLast() && i++ < SHRT_MAX) // max number of entries
3136 {
3137 aStr = getFormattedValue(xDataField, xFormatter, aNullDate, nFormatKey, nKeyType);
3138 aStringList.push_back(aStr);
3139 (void)xListCursor->next();
3140 }
3141
3142 ComboBoxControl* pField = static_cast<ComboBoxControl*>(m_pWindow.get());
3143 weld::ComboBox& rComboBox = pField->get_widget();
3144 // filling the entries for the combobox
3145 for (const auto& rString : aStringList)
3146 rComboBox.append_text(rString);
3147}
3148
3149OUString DbFilterField::GetFormatText(const Reference< XColumn >& /*_rxField*/, const Reference< XNumberFormatter >& /*xFormatter*/, const Color** /*ppColor*/)
3150{
3151 return OUString();
3152}
3153
3154void DbFilterField::UpdateFromField(const Reference< XColumn >& /*_rxField*/, const Reference< XNumberFormatter >& /*xFormatter*/)
3155{
3156 OSL_FAIL( "DbFilterField::UpdateFromField: cannot update a filter control from a field!" );
3157}
3158
3160{
3161 TriState eState = static_cast<CheckBoxControl*>(m_pWindow.get())->GetState();
3162 OUStringBuffer aTextBuf;
3163
3164 Reference< XRowSet > xDataSourceRowSet(
3165 Reference< XInterface >(*m_rColumn.GetParent().getDataSource()), UNO_QUERY);
3166 Reference< XConnection > xConnection(getConnection(xDataSourceRowSet));
3167 const sal_Int32 nBooleanComparisonMode = ::dbtools::DatabaseMetaData( xConnection ).getBooleanComparisonMode();
3168
3169 switch (eState)
3170 {
3171 case TRISTATE_TRUE:
3172 ::dbtools::getBooleanComparisonPredicate(u"", true, nBooleanComparisonMode, aTextBuf);
3173 break;
3174 case TRISTATE_FALSE:
3175 ::dbtools::getBooleanComparisonPredicate(u"", false, nBooleanComparisonMode, aTextBuf);
3176 break;
3177 case TRISTATE_INDET:
3178 break;
3179 }
3180
3181 const OUString aText(aTextBuf.makeStringAndClear());
3182
3183 if (m_aText != aText)
3184 {
3185 m_aText = aText;
3186 m_aCommitLink.Call(*this);
3187 }
3188}
3189
3190FmXGridCell::FmXGridCell( DbGridColumn* pColumn, std::unique_ptr<DbCellControl> _pControl )
3191 :OComponentHelper(m_aMutex)
3192 ,m_pColumn(pColumn)
3193 ,m_pCellControl( std::move(_pControl) )
3194 ,m_aWindowListeners( m_aMutex )
3195 ,m_aFocusListeners( m_aMutex )
3196 ,m_aKeyListeners( m_aMutex )
3197 ,m_aMouseListeners( m_aMutex )
3198 ,m_aMouseMotionListeners( m_aMutex )
3199{
3200}
3201
3203{
3204 svt::ControlBase* pEventWindow( getEventWindow() );
3205 if ( pEventWindow )
3206 {
3207 pEventWindow->SetFocusInHdl(LINK( this, FmXGridCell, OnFocusGained));
3208 pEventWindow->SetFocusOutHdl(LINK( this, FmXGridCell, OnFocusLost));
3209 pEventWindow->SetMousePressHdl(LINK( this, FmXGridCell, OnMousePress));
3210 pEventWindow->SetMouseReleaseHdl(LINK( this, FmXGridCell, OnMouseRelease));
3211 pEventWindow->SetMouseMoveHdl(LINK( this, FmXGridCell, OnMouseMove));
3212 pEventWindow->SetKeyInputHdl( LINK( this, FmXGridCell, OnKeyInput) );
3213 pEventWindow->SetKeyReleaseHdl( LINK( this, FmXGridCell, OnKeyRelease) );
3214 }
3215}
3216
3218{
3219 if ( m_pCellControl )
3220 return &m_pCellControl->GetWindow();
3221 return nullptr;
3222}
3223
3225{
3226 if (!OComponentHelper::rBHelper.bDisposed)
3227 {
3228 acquire();
3229 dispose();
3230 }
3231
3232}
3233
3235{
3236 if (m_pCellControl)
3237 m_pCellControl->SetTextLineColor();
3238}
3239
3241{
3242 if (m_pCellControl)
3243 m_pCellControl->SetTextLineColor(_rColor);
3244}
3245
3246// XTypeProvider
3247
3248Sequence< Type > SAL_CALL FmXGridCell::getTypes( )
3249{
3250 Sequence< uno::Type > aTypes = ::comphelper::concatSequences(
3253 );
3254 if ( m_pCellControl )
3255 aTypes = ::comphelper::concatSequences(
3256 aTypes,
3258 );
3259 return aTypes;
3260}
3261
3262
3264
3265// OComponentHelper
3266
3267void FmXGridCell::disposing()
3268{
3269 lang::EventObject aEvent( *this );
3270 m_aWindowListeners.disposeAndClear( aEvent );
3271 m_aFocusListeners.disposeAndClear( aEvent );
3272 m_aKeyListeners.disposeAndClear( aEvent );
3273 m_aMouseListeners.disposeAndClear( aEvent );
3274 m_aMouseMotionListeners.disposeAndClear( aEvent );
3275
3276 OComponentHelper::disposing();
3277 m_pColumn = nullptr;
3278 m_pCellControl.reset();
3279}
3280
3281
3282Any SAL_CALL FmXGridCell::queryAggregation( const css::uno::Type& _rType )
3283{
3284 Any aReturn = OComponentHelper::queryAggregation( _rType );
3285
3286 if ( !aReturn.hasValue() )
3287 aReturn = FmXGridCell_Base::queryInterface( _rType );
3288
3289 if ( !aReturn.hasValue() && ( m_pCellControl != nullptr ) )
3290 aReturn = FmXGridCell_WindowBase::queryInterface( _rType );
3291
3292 return aReturn;
3293}
3294
3295// css::awt::XControl
3296
3297Reference< XInterface > FmXGridCell::getContext()
3298{
3299 return Reference< XInterface > ();
3300}
3301
3302
3303Reference< css::awt::XControlModel > FmXGridCell::getModel()
3304{
3305 checkDisposed(OComponentHelper::rBHelper.bDisposed);
3306 return Reference< css::awt::XControlModel > (m_pColumn->getModel(), UNO_QUERY);
3307}
3308
3309// css::form::XBoundControl
3310
3312{
3313 checkDisposed(OComponentHelper::rBHelper.bDisposed);
3314 return m_pColumn->isLocked();
3315}
3316
3317
3319{
3320 checkDisposed(OComponentHelper::rBHelper.bDisposed);
3321 if (getLock() == _bLock)
3322 return;
3323 else
3324 {
3325 ::osl::MutexGuard aGuard(m_aMutex);
3326 m_pColumn->setLock(_bLock);
3327 }
3328}
3329
3330
3331void SAL_CALL FmXGridCell::setPosSize( ::sal_Int32, ::sal_Int32, ::sal_Int32, ::sal_Int32, ::sal_Int16 )
3332{
3333 OSL_FAIL( "FmXGridCell::setPosSize: not implemented" );
3334 // not allowed to tamper with this for a grid cell
3335}
3336
3337
3338awt::Rectangle SAL_CALL FmXGridCell::getPosSize( )
3339{
3340 OSL_FAIL( "FmXGridCell::getPosSize: not implemented" );
3341 return awt::Rectangle();
3342}
3343
3344
3346{
3347 OSL_FAIL( "FmXGridCell::setVisible: not implemented" );
3348 // not allowed to tamper with this for a grid cell
3349}
3350
3351
3353{
3354 OSL_FAIL( "FmXGridCell::setEnable: not implemented" );
3355 // not allowed to tamper with this for a grid cell
3356}
3357
3358
3360{
3361 OSL_FAIL( "FmXGridCell::setFocus: not implemented" );
3362 // not allowed to tamper with this for a grid cell
3363}
3364
3365
3366void SAL_CALL FmXGridCell::addWindowListener( const Reference< awt::XWindowListener >& _rxListener )
3367{
3368 checkDisposed(OComponentHelper::rBHelper.bDisposed);
3369 m_aWindowListeners.addInterface( _rxListener );
3370}
3371
3372
3373void SAL_CALL FmXGridCell::removeWindowListener( const Reference< awt::XWindowListener >& _rxListener )
3374{
3375 checkDisposed(OComponentHelper::rBHelper.bDisposed);
3376 m_aWindowListeners.removeInterface( _rxListener );
3377}
3378
3379
3380void SAL_CALL FmXGridCell::addFocusListener( const Reference< awt::XFocusListener >& _rxListener )
3381{
3382 checkDisposed(OComponentHelper::rBHelper.bDisposed);
3383 m_aFocusListeners.addInterface( _rxListener );
3384}
3385
3386
3387void SAL_CALL FmXGridCell::removeFocusListener( const Reference< awt::XFocusListener >& _rxListener )
3388{
3389 checkDisposed(OComponentHelper::rBHelper.bDisposed);
3390 m_aFocusListeners.removeInterface( _rxListener );
3391}
3392
3393
3394void SAL_CALL FmXGridCell::addKeyListener( const Reference< awt::XKeyListener >& _rxListener )
3395{
3396 checkDisposed(OComponentHelper::rBHelper.bDisposed);
3397 m_aKeyListeners.addInterface( _rxListener );
3398}
3399
3400
3401void SAL_CALL FmXGridCell::removeKeyListener( const Reference< awt::XKeyListener >& _rxListener )
3402{
3403 checkDisposed(OComponentHelper::rBHelper.bDisposed);
3404 m_aKeyListeners.removeInterface( _rxListener );
3405}
3406
3407
3408void SAL_CALL FmXGridCell::addMouseListener( const Reference< awt::XMouseListener >& _rxListener )
3409{
3410 checkDisposed(OComponentHelper::rBHelper.bDisposed);
3411 m_aMouseListeners.addInterface( _rxListener );
3412}
3413
3414
3415void SAL_CALL FmXGridCell::removeMouseListener( const Reference< awt::XMouseListener >& _rxListener )
3416{
3417 checkDisposed(OComponentHelper::rBHelper.bDisposed);
3418 m_aMouseListeners.removeInterface( _rxListener );
3419}
3420
3421
3422void SAL_CALL FmXGridCell::addMouseMotionListener( const Reference< awt::XMouseMotionListener >& _rxListener )
3423{
3424 checkDisposed(OComponentHelper::rBHelper.bDisposed);
3426}
3427
3428
3429void SAL_CALL FmXGridCell::removeMouseMotionListener( const Reference< awt::XMouseMotionListener >& _rxListener )
3430{
3431 checkDisposed(OComponentHelper::rBHelper.bDisposed);
3433}
3434
3435void SAL_CALL FmXGridCell::addPaintListener( const Reference< awt::XPaintListener >& )
3436{
3437 OSL_FAIL( "FmXGridCell::addPaintListener: not implemented" );
3438}
3439
3440void SAL_CALL FmXGridCell::removePaintListener( const Reference< awt::XPaintListener >& )
3441{
3442 OSL_FAIL( "FmXGridCell::removePaintListener: not implemented" );
3443}
3444
3445void FmXGridCell::onFocusGained( const awt::FocusEvent& _rEvent )
3446{
3447 checkDisposed(OComponentHelper::rBHelper.bDisposed);
3448 m_aFocusListeners.notifyEach( &awt::XFocusListener::focusGained, _rEvent );
3449}
3450
3451void FmXGridCell::onFocusLost( const awt::FocusEvent& _rEvent )
3452{
3453 checkDisposed(OComponentHelper::rBHelper.bDisposed);
3454 m_aFocusListeners.notifyEach( &awt::XFocusListener::focusLost, _rEvent );
3455}
3456
3458{
3459 if (!m_aFocusListeners.getLength())
3460 return;
3461
3462 awt::FocusEvent aEvent;
3463 aEvent.Source = *this;
3464 aEvent.Temporary = false;
3465
3466 onFocusGained(aEvent);
3467}
3468
3470{
3471 if (!m_aFocusListeners.getLength())
3472 return;
3473
3474 awt::FocusEvent aEvent;
3475 aEvent.Source = *this;
3476 aEvent.Temporary = false;
3477
3478 onFocusLost(aEvent);
3479}
3480
3481IMPL_LINK(FmXGridCell, OnMousePress, const MouseEvent&, rEventData, void)
3482{
3483 if (!m_aMouseListeners.getLength())
3484 return;
3485
3486 awt::MouseEvent aEvent(VCLUnoHelper::createMouseEvent(rEventData, *this));
3487 m_aMouseListeners.notifyEach(&awt::XMouseListener::mousePressed, aEvent);
3488}
3489
3490IMPL_LINK(FmXGridCell, OnMouseRelease, const MouseEvent&, rEventData, void)
3491{
3492 if (!m_aMouseListeners.getLength())
3493 return;
3494
3495 awt::MouseEvent aEvent(VCLUnoHelper::createMouseEvent(rEventData, *this));
3496 m_aMouseListeners.notifyEach(&awt::XMouseListener::mouseReleased, aEvent);
3497}
3498
3499IMPL_LINK(FmXGridCell, OnMouseMove, const MouseEvent&, rMouseEvent, void)
3500{
3501 if ( rMouseEvent.IsEnterWindow() || rMouseEvent.IsLeaveWindow() )
3502 {
3503 if ( m_aMouseListeners.getLength() != 0 )
3504 {
3505 awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( rMouseEvent, *this ) );
3506 m_aMouseListeners.notifyEach( rMouseEvent.IsEnterWindow() ? &awt::XMouseListener::mouseEntered: &awt::XMouseListener::mouseExited, aEvent );
3507 }
3508 }
3509 else if ( !rMouseEvent.IsEnterWindow() && !rMouseEvent.IsLeaveWindow() )
3510 {
3511 if ( m_aMouseMotionListeners.getLength() != 0 )
3512 {
3513 awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( rMouseEvent, *this ) );
3514 aEvent.ClickCount = 0;
3515 const bool bSimpleMove = bool( rMouseEvent.GetMode() & MouseEventModifiers::SIMPLEMOVE );
3516 m_aMouseMotionListeners.notifyEach( bSimpleMove ? &awt::XMouseMotionListener::mouseMoved: &awt::XMouseMotionListener::mouseDragged, aEvent );
3517 }
3518 }
3519}
3520
3521IMPL_LINK(FmXGridCell, OnKeyInput, const KeyEvent&, rEventData, void)
3522{
3523 if (!m_aKeyListeners.getLength())
3524 return;
3525
3526 awt::KeyEvent aEvent(VCLUnoHelper::createKeyEvent(rEventData, *this));
3527 m_aKeyListeners.notifyEach(&awt::XKeyListener::keyPressed, aEvent);
3528}
3529
3530IMPL_LINK(FmXGridCell, OnKeyRelease, const KeyEvent&, rEventData, void)
3531{
3532 if (!m_aKeyListeners.getLength())
3533 return;
3534
3535 awt::KeyEvent aEvent(VCLUnoHelper::createKeyEvent(rEventData, *this));
3536 m_aKeyListeners.notifyEach(&awt::XKeyListener::keyReleased, aEvent);
3537}
3538
3540 const Reference< css::sdb::XColumn >& _rxField,
3541 const Reference< XNumberFormatter >& xFormatter)
3542{
3543 m_pCellControl->PaintFieldToCell( rDev, rRect, _rxField, xFormatter );
3544}
3545
3547{
3548 Reference< css::sdb::XColumn > xField(m_pColumn->GetCurrentFieldValue());
3549 if (xField.is())
3550 m_pCellControl->UpdateFromField(xField, m_pColumn->GetParent().getNumberFormatter());
3551}
3552
3553FmXTextCell::FmXTextCell( DbGridColumn* pColumn, std::unique_ptr<DbCellControl> pControl )
3554 :FmXDataCell( pColumn, std::move(pControl) )
3555 ,m_bIsMultiLineText(false)
3556{
3557}
3558
3560 const tools::Rectangle& rRect,
3561 const Reference< css::sdb::XColumn >& _rxField,
3562 const Reference< XNumberFormatter >& xFormatter)
3563{
3564 DrawTextFlags nStyle = DrawTextFlags::Clip;
3565 if ( ( rDev.GetOutDevType() == OUTDEV_WINDOW ) && !rDev.GetOwnerWindow()->IsEnabled() )
3566 nStyle |= DrawTextFlags::Disable;
3567
3568 switch (m_pColumn->GetAlignment())
3569 {
3570 case css::awt::TextAlign::RIGHT:
3571 nStyle |= DrawTextFlags::Right;
3572 break;
3573 case css::awt::TextAlign::CENTER:
3574 nStyle |= DrawTextFlags::Center;
3575 break;
3576 default:
3577 nStyle |= DrawTextFlags::Left;
3578 }
3579
3580 if (!m_bIsMultiLineText)
3581 nStyle |= DrawTextFlags::VCenter;
3582 else
3583 nStyle |= DrawTextFlags::Top | DrawTextFlags::MultiLine | DrawTextFlags::WordBreak;
3584
3585 try
3586 {
3587 const Color* pColor = nullptr;
3588 OUString aText = GetText(_rxField, xFormatter, &pColor);
3589 if (pColor != nullptr)
3590 {
3591 Color aOldTextColor( rDev.GetTextColor() );
3592 rDev.SetTextColor( *pColor );
3593 rDev.DrawText(rRect, aText, nStyle);
3594 rDev.SetTextColor( aOldTextColor );
3595 }
3596 else
3597 rDev.DrawText(rRect, aText, nStyle);
3598 }
3599 catch (const Exception&)
3600 {
3601 TOOLS_WARN_EXCEPTION("svx.fmcomp", "PaintFieldToCell");
3602 }
3603}
3604
3605FmXEditCell::FmXEditCell( DbGridColumn* pColumn, std::unique_ptr<DbCellControl> pControl )
3606 :FmXTextCell( pColumn, std::move(pControl) )
3607 ,m_aTextListeners(m_aMutex)
3608 ,m_aChangeListeners( m_aMutex )
3609 ,m_pEditImplementation( nullptr )
3610 ,m_bOwnEditImplementation( false )
3611{
3612
3613 DbTextField* pTextField = dynamic_cast<DbTextField*>( m_pCellControl.get() );
3614 if ( pTextField )
3615 {
3616
3618 m_bIsMultiLineText = pTextField->IsMultiLineEdit();
3619 }
3620 else
3621 {
3622 m_pEditImplementation = new EntryImplementation(static_cast<EditControlBase&>(m_pCellControl->GetWindow()));
3624 }
3626}
3627
3629{
3630 if (!OComponentHelper::rBHelper.bDisposed)
3631 {
3632 acquire();
3633 dispose();
3634 }
3635}
3636
3637// OComponentHelper
3639{
3640 css::lang::EventObject aEvt(*this);
3643
3645 delete m_pEditImplementation;
3646 m_pEditImplementation = nullptr;
3647
3649}
3650
3651Any SAL_CALL FmXEditCell::queryAggregation( const css::uno::Type& _rType )
3652{
3653 Any aReturn = FmXTextCell::queryAggregation( _rType );
3654
3655 if ( !aReturn.hasValue() )
3656 aReturn = FmXEditCell_Base::queryInterface( _rType );
3657
3658 return aReturn;
3659}
3660
3661Sequence< css::uno::Type > SAL_CALL FmXEditCell::getTypes( )
3662{
3663 return ::comphelper::concatSequences(
3666 );
3667}
3668
3670
3671// css::awt::XTextComponent
3672void SAL_CALL FmXEditCell::addTextListener(const Reference< css::awt::XTextListener >& l)
3673{
3674 m_aTextListeners.addInterface( l );
3675}
3676
3677
3678void SAL_CALL FmXEditCell::removeTextListener(const Reference< css::awt::XTextListener >& l)
3679{
3681}
3682
3683void SAL_CALL FmXEditCell::setText( const OUString& aText )
3684{
3685 ::osl::MutexGuard aGuard( m_aMutex );
3686
3688 {
3690
3691 // In Java, a textChanged is fired as well; not in VCL.
3692 // css::awt::Toolkit must be Java-compliant...
3693 onTextChanged();
3694 }
3695}
3696
3697void SAL_CALL FmXEditCell::insertText(const css::awt::Selection& rSel, const OUString& aText)
3698{
3699 ::osl::MutexGuard aGuard( m_aMutex );
3700
3702 {
3703 m_pEditImplementation->SetSelection( Selection( rSel.Min, rSel.Max ) );
3705 }
3706}
3707
3708OUString SAL_CALL FmXEditCell::getText()
3709{
3710 ::osl::MutexGuard aGuard( m_aMutex );
3711
3712 OUString aText;
3714 {
3716 {
3717 // if the display isn't sync with the cursor we can't ask the edit field
3718 LineEnd eLineEndFormat = getModelLineEndSetting( m_pColumn->getModel() );
3719 aText = m_pEditImplementation->GetText( eLineEndFormat );
3720 }
3721 else
3722 {
3723 Reference< css::sdb::XColumn > xField(m_pColumn->GetCurrentFieldValue());
3724 if (xField.is())
3725 aText = GetText(xField, m_pColumn->GetParent().getNumberFormatter());
3726 }
3727 }
3728 return aText;
3729}
3730
3732{
3733 ::osl::MutexGuard aGuard( m_aMutex );
3734
3735 OUString aText;
3737 {
3738 LineEnd eLineEndFormat = m_pColumn ? getModelLineEndSetting( m_pColumn->getModel() ) : LINEEND_LF;
3739 aText = m_pEditImplementation->GetSelected( eLineEndFormat );
3740 }
3741 return aText;
3742}
3743
3744void SAL_CALL FmXEditCell::setSelection( const css::awt::Selection& aSelection )
3745{
3746 ::osl::MutexGuard aGuard( m_aMutex );
3747
3749 m_pEditImplementation->SetSelection( Selection( aSelection.Min, aSelection.Max ) );
3750}
3751
3752css::awt::Selection SAL_CALL FmXEditCell::getSelection()
3753{
3754 ::osl::MutexGuard aGuard( m_aMutex );
3755
3756 Selection aSel;
3759
3760 return css::awt::Selection(aSel.Min(), aSel.Max());
3761}
3762
3764{
3765 ::osl::MutexGuard aGuard( m_aMutex );
3766
3768}
3769
3770void SAL_CALL FmXEditCell::setEditable( sal_Bool bEditable )
3771{
3772 ::osl::MutexGuard aGuard( m_aMutex );
3773
3775 m_pEditImplementation->SetReadOnly( !bEditable );
3776}
3777
3778sal_Int16 SAL_CALL FmXEditCell::getMaxTextLen()
3779{
3780 ::osl::MutexGuard aGuard( m_aMutex );
3781
3783}
3784
3785void SAL_CALL FmXEditCell::setMaxTextLen( sal_Int16 nLen )
3786{
3787 ::osl::MutexGuard aGuard( m_aMutex );
3788
3791}
3792
3793void SAL_CALL FmXEditCell::addChangeListener( const Reference< form::XChangeListener >& Listener )
3794{
3795 m_aChangeListeners.addInterface( Listener );
3796}
3797
3798void SAL_CALL FmXEditCell::removeChangeListener( const Reference< form::XChangeListener >& Listener )
3799{
3801}
3802
3804{
3805 css::awt::TextEvent aEvent;
3806 aEvent.Source = *this;
3807 m_aTextListeners.notifyEach( &awt::XTextListener::textChanged, aEvent );
3808}
3809
3810void FmXEditCell::onFocusGained( const awt::FocusEvent& _rEvent )
3811{
3812 FmXTextCell::onFocusGained( _rEvent );
3814}
3815
3816void FmXEditCell::onFocusLost( const awt::FocusEvent& _rEvent )
3817{
3818 FmXTextCell::onFocusLost( _rEvent );
3819
3820 if ( getText() != m_sValueOnEnter )
3821 {
3822 lang::EventObject aEvent( *this );
3823 m_aChangeListeners.notifyEach( &XChangeListener::changed, aEvent );
3824 }
3825}
3826
3828{
3829 if (m_aTextListeners.getLength())
3830 onTextChanged();
3831}
3832
3833FmXCheckBoxCell::FmXCheckBoxCell( DbGridColumn* pColumn, std::unique_ptr<DbCellControl> pControl )
3834 :FmXDataCell( pColumn, std::move(pControl) )
3835 ,m_aItemListeners(m_aMutex)
3836 ,m_aActionListeners( m_aMutex )
3837 ,m_pBox( & static_cast< CheckBoxControl& >( m_pCellControl->GetWindow() ) )
3838{
3839 m_pBox->SetAuxModifyHdl(LINK(this, FmXCheckBoxCell, ModifyHdl));
3840}
3841
3843{
3844 if (!OComponentHelper::rBHelper.bDisposed)
3845 {
3846 acquire();
3847 dispose();
3848 }
3849}
3850
3851// OComponentHelper
3853{
3854 css::lang::EventObject aEvt(*this);
3857
3858 m_pBox->SetToggleHdl(Link<weld::CheckButton&,void>());
3859 m_pBox = nullptr;
3860
3862}
3863
3864
3865Any SAL_CALL FmXCheckBoxCell::queryAggregation( const css::uno::Type& _rType )
3866{
3867 Any aReturn = FmXDataCell::queryAggregation( _rType );
3868
3869 if ( !aReturn.hasValue() )
3870 aReturn = FmXCheckBoxCell_Base::queryInterface( _rType );
3871
3872 return aReturn;
3873}
3874
3875
3876Sequence< css::uno::Type > SAL_CALL FmXCheckBoxCell::getTypes( )
3877{
3878 return ::comphelper::concatSequences(
3881 );
3882}
3883
3884
3886
3887void SAL_CALL FmXCheckBoxCell::addItemListener( const Reference< css::awt::XItemListener >& l )
3888{
3889 m_aItemListeners.addInterface( l );
3890}
3891
3892void SAL_CALL FmXCheckBoxCell::removeItemListener( const Reference< css::awt::XItemListener >& l )
3893{
3895}
3896
3897void SAL_CALL FmXCheckBoxCell::setState( sal_Int16 n )
3898{
3899 ::osl::MutexGuard aGuard( m_aMutex );
3900
3901 if (m_pBox)
3902 {
3904 m_pBox->SetState( static_cast<TriState>(n) );
3905 }
3906}
3907
3908sal_Int16 SAL_CALL FmXCheckBoxCell::getState()
3909{
3910 ::osl::MutexGuard aGuard( m_aMutex );
3911
3912 if (m_pBox)
3913 {
3915 return static_cast<sal_Int16>(m_pBox->GetState());
3916 }
3917 return TRISTATE_INDET;
3918}
3919
3921{
3922 ::osl::MutexGuard aGuard( m_aMutex );
3923
3924 if (m_pBox)
3925 m_pBox->EnableTriState( b );
3926}
3927
3928void SAL_CALL FmXCheckBoxCell::addActionListener( const Reference< awt::XActionListener >& Listener )
3929{
3930 m_aActionListeners.addInterface( Listener );
3931}
3932
3933
3934void SAL_CALL FmXCheckBoxCell::removeActionListener( const Reference< awt::XActionListener >& Listener )
3935{
3937}
3938
3939void SAL_CALL FmXCheckBoxCell::setLabel( const OUString& Label )
3940{
3941 SolarMutexGuard aGuard;
3942 if ( m_pColumn )
3943 {
3944 DbGridControl& rGrid( m_pColumn->GetParent() );
3946 }
3947}
3948
3949void SAL_CALL FmXCheckBoxCell::setActionCommand( const OUString& Command )
3950{
3951 m_aActionCommand = Command;
3952}
3953
3955{
3956 // check boxes are to be committed immediately (this holds for ordinary check box controls in
3957 // documents, and this must hold for check boxes in grid columns, too
3958 // 91210 - 22.08.2001 - frank.schoenheit@sun.com
3959 m_pCellControl->Commit();
3960
3961 Reference< XWindow > xKeepAlive( this );
3962 if ( m_aItemListeners.getLength() && m_pBox )
3963 {
3964 awt::ItemEvent aEvent;
3965 aEvent.Source = *this;
3966 aEvent.Highlighted = 0;
3967 aEvent.Selected = m_pBox->GetState();
3968 m_aItemListeners.notifyEach( &awt::XItemListener::itemStateChanged, aEvent );
3969 }
3970 if ( m_aActionListeners.getLength() )
3971 {
3972 awt::ActionEvent aEvent;
3973 aEvent.Source = *this;
3974 aEvent.ActionCommand = m_aActionCommand;
3975 m_aActionListeners.notifyEach( &awt::XActionListener::actionPerformed, aEvent );
3976 }
3977}
3978
3979FmXListBoxCell::FmXListBoxCell(DbGridColumn* pColumn, std::unique_ptr<DbCellControl> pControl)
3980 : FmXTextCell(pColumn, std::move(pControl))
3981 , m_aItemListeners(m_aMutex)
3982 , m_aActionListeners(m_aMutex)
3983 , m_pBox(&static_cast<svt::ListBoxControl&>(m_pCellControl->GetWindow()))
3984 , m_nLines(Application::GetSettings().GetStyleSettings().GetListBoxMaximumLineCount())
3985 , m_bMulti(false)
3986{
3987 m_pBox->SetAuxModifyHdl(LINK(this, FmXListBoxCell, ChangedHdl));
3988}
3989
3991{
3992 if (!OComponentHelper::rBHelper.bDisposed)
3993 {
3994 acquire();
3995 dispose();
3996 }
3997}
3998
3999// OComponentHelper
4001{
4002 css::lang::EventObject aEvt(*this);
4005
4006 m_pBox->SetAuxModifyHdl(Link<bool,void>());
4007 m_pBox = nullptr;
4008
4010}
4011
4012Any SAL_CALL FmXListBoxCell::queryAggregation( const css::uno::Type& _rType )
4013{
4014 Any aReturn = FmXTextCell::queryAggregation(_rType);
4015
4016 if ( !aReturn.hasValue() )
4017 aReturn = FmXListBoxCell_Base::queryInterface( _rType );
4018
4019 return aReturn;
4020}
4021
4022Sequence< css::uno::Type > SAL_CALL FmXListBoxCell::getTypes( )
4023{
4024 return ::comphelper::concatSequences(
4027 );
4028}
4029
4031
4032void SAL_CALL FmXListBoxCell::addItemListener(const Reference< css::awt::XItemListener >& l)
4033{
4034 m_aItemListeners.addInterface( l );
4035}
4036
4037void SAL_CALL FmXListBoxCell::removeItemListener(const Reference< css::awt::XItemListener >& l)
4038{
4040}
4041
4042void SAL_CALL FmXListBoxCell::addActionListener(const Reference< css::awt::XActionListener >& l)
4043{
4045}
4046
4047void SAL_CALL FmXListBoxCell::removeActionListener(const Reference< css::awt::XActionListener >& l)
4048{
4050}
4051
4052void SAL_CALL FmXListBoxCell::addItem(const OUString& aItem, sal_Int16 nPos)
4053{
4054 ::osl::MutexGuard aGuard( m_aMutex );
4055 if (m_pBox)
4056 {
4057 weld::ComboBox& rBox = m_pBox->get_widget();
4058 rBox.insert_text(nPos, aItem);
4059 }
4060}
4061
4062void SAL_CALL FmXListBoxCell::addItems(const css::uno::Sequence<OUString>& aItems, sal_Int16 nPos)
4063{
4064 ::osl::MutexGuard aGuard( m_aMutex );
4065 if (m_pBox)
4066 {
4067 weld::ComboBox& rBox = m_pBox->get_widget();
4068 sal_uInt16 nP = nPos;
4069 for ( const auto& rItem : aItems )
4070 {
4071 rBox.insert_text(nP, rItem);
4072 if ( nPos != -1 ) // Not if 0xFFFF, because LIST_APPEND
4073 nP++;
4074 }
4075 }
4076}
4077
4078void SAL_CALL FmXListBoxCell::removeItems(sal_Int16 nPos, sal_Int16 nCount)
4079{
4080 ::osl::MutexGuard aGuard( m_aMutex );
4081 if ( m_pBox )
4082 {
4083 weld::ComboBox& rBox = m_pBox->get_widget();
4084 for ( sal_uInt16 n = nCount; n; )
4085 rBox.remove( nPos + (--n) );
4086 }
4087}
4088
4090{
4091 ::osl::MutexGuard aGuard( m_aMutex );
4092 if (!m_pBox)
4093 return 0;
4094 weld::ComboBox& rBox = m_pBox->get_widget();
4095 return rBox.get_count();
4096}
4097
4098OUString SAL_CALL FmXListBoxCell::getItem(sal_Int16 nPos)
4099{
4100 ::osl::MutexGuard aGuard( m_aMutex );
4101 if (!m_pBox)
4102 return OUString();
4103 weld::ComboBox& rBox = m_pBox->get_widget();
4104 return rBox.get_text(nPos);
4105}
4106
4107css::uno::Sequence<OUString> SAL_CALL FmXListBoxCell::getItems()
4108{
4109 ::osl::MutexGuard aGuard( m_aMutex );
4110
4111 css::uno::Sequence<OUString> aSeq;
4112 if (m_pBox)
4113 {
4114 weld::ComboBox& rBox = m_pBox->get_widget();
4115 const sal_Int32 nEntries = rBox.get_count();
4116 aSeq = css::uno::Sequence<OUString>( nEntries );
4117 for ( sal_Int32 n = nEntries; n; )
4118 {
4119 --n;
4120 aSeq.getArray()[n] = rBox.get_text( n );
4121 }
4122 }
4123 return aSeq;
4124}
4125
4127{
4128 ::osl::MutexGuard aGuard( m_aMutex );
4129 if (m_pBox)
4130 {
4132 weld::ComboBox& rBox = m_pBox->get_widget();
4133 sal_Int32 nPos = rBox.get_active();
4134 if (nPos > SHRT_MAX || nPos < SHRT_MIN)
4135 throw std::out_of_range("awt::XListBox::getSelectedItemPos can only return a short");
4136 return nPos;
4137 }
4138 return 0;
4139}
4140
4141Sequence< sal_Int16 > SAL_CALL FmXListBoxCell::getSelectedItemsPos()
4142{
4143 ::osl::MutexGuard aGuard( m_aMutex );
4144
4145 if (m_pBox)
4146 {
4148 weld::ComboBox& rBox = m_pBox->get_widget();
4149 auto nActive = rBox.get_active();
4150 if (nActive != -1)
4151 {
4152 return { o3tl::narrowing<short>(nActive) };
4153 }
4154 }
4155 return {};
4156}
4157
4159{
4160 ::osl::MutexGuard aGuard( m_aMutex );
4161
4162 OUString aItem;
4163
4164 if (m_pBox)
4165 {
4167 weld::ComboBox& rBox = m_pBox->get_widget();
4168 aItem = rBox.get_active_text();
4169 }
4170
4171 return aItem;
4172}
4173
4174css::uno::Sequence<OUString> SAL_CALL FmXListBoxCell::getSelectedItems()
4175{
4176 ::osl::MutexGuard aGuard( m_aMutex );
4177
4178 if (m_pBox)
4179 {
4181 weld::ComboBox& rBox = m_pBox->get_widget();
4182 auto nActive = rBox.get_active();
4183 if (nActive != -1)
4184 {
4185 return { rBox.get_text(nActive) };
4186 }
4187 }
4188 return {};
4189}
4190
4191void SAL_CALL FmXListBoxCell::selectItemPos(sal_Int16 nPos, sal_Bool bSelect)
4192{
4193 ::osl::MutexGuard aGuard( m_aMutex );
4194
4195 if (m_pBox)
4196 {
4197 weld::ComboBox& rBox = m_pBox->get_widget();
4198 if (bSelect)
4199 rBox.set_active(nPos);
4200 else if (nPos == rBox.get_active())
4201 rBox.set_active(-1);
4202 }
4203}
4204
4205void SAL_CALL FmXListBoxCell::selectItemsPos(const Sequence< sal_Int16 >& aPositions, sal_Bool bSelect)
4206{
4207 ::osl::MutexGuard aGuard( m_aMutex );
4208
4209 if (m_pBox)
4210 {
4211 weld::ComboBox& rBox = m_pBox->get_widget();
4212 for ( sal_uInt16 n = static_cast<sal_uInt16>(aPositions.getLength()); n; )
4213 {
4214 auto nPos = static_cast<sal_uInt16>(aPositions.getConstArray()[--n]);
4215 if (bSelect)
4216 rBox.set_active(nPos);
4217 else if (nPos == rBox.get_active())
4218 rBox.set_active(-1);
4219 }
4220 }
4221}
4222
4223void SAL_CALL FmXListBoxCell::selectItem(const OUString& aItem, sal_Bool bSelect)
4224{
4225 ::osl::MutexGuard aGuard( m_aMutex );
4226
4227 if (m_pBox)
4228 {
4229 weld::ComboBox& rBox = m_pBox->get_widget();
4230 auto nPos = rBox.find_text(aItem);
4231 if (bSelect)
4232 rBox.set_active(nPos);
4233 else if (nPos == rBox.get_active())
4234 rBox.set_active(-1);
4235 }
4236}
4237
4239{
4240 ::osl::MutexGuard aGuard( m_aMutex );
4241
4242 return m_bMulti;
4243}
4244
4246{
4247 ::osl::MutexGuard aGuard( m_aMutex );
4248
4249 m_bMulti = bMulti;
4250}
4251
4253{
4254 ::osl::MutexGuard aGuard( m_aMutex );
4255 return m_nLines;
4256}
4257
4258void SAL_CALL FmXListBoxCell::setDropDownLineCount(sal_Int16 nLines)
4259{
4260 ::osl::MutexGuard aGuard( m_aMutex );
4261
4262 m_nLines = nLines; // just store it to return it
4263}
4264
4265void SAL_CALL FmXListBoxCell::makeVisible(sal_Int16 /*nEntry*/)
4266{
4267}
4268
4269IMPL_LINK(FmXListBoxCell, ChangedHdl, bool, bInteractive, void)
4270{
4271 if (!m_pBox)
4272 return;
4273
4274 weld::ComboBox& rBox = m_pBox->get_widget();
4275
4276 if (bInteractive && !rBox.changed_by_direct_pick())
4277 return;
4278
4279 OnDoubleClick();
4280
4281 css::awt::ItemEvent aEvent;
4282 aEvent.Source = *this;
4283 aEvent.Highlighted = 0;
4284
4285 // with multiple selection 0xFFFF, otherwise the ID
4286 aEvent.Selected = (rBox.get_active() != -1 )
4287 ? rBox.get_active() : 0xFFFF;
4288
4289 m_aItemListeners.notifyEach( &awt::XItemListener::itemStateChanged, aEvent );
4290}
4291
4293{
4294 css::awt::ActionEvent aEvent;
4295 aEvent.Source = *this;
4296 weld::ComboBox& rBox = m_pBox->get_widget();
4297 aEvent.ActionCommand = rBox.get_active_text();
4298
4299 m_aActionListeners.notifyEach( &css::awt::XActionListener::actionPerformed, aEvent );
4300}
4301
4302FmXComboBoxCell::FmXComboBoxCell( DbGridColumn* pColumn, std::unique_ptr<DbCellControl> pControl )
4303 :FmXTextCell( pColumn, std::move(pControl) )
4304 ,m_aItemListeners( m_aMutex )
4305 ,m_aActionListeners( m_aMutex )
4306 ,m_pComboBox(&static_cast<ComboBoxControl&>(m_pCellControl->GetWindow()))
4307 ,m_nLines(Application::GetSettings().GetStyleSettings().GetListBoxMaximumLineCount())
4308{
4309 m_pComboBox->SetAuxModifyHdl(LINK(this, FmXComboBoxCell, ChangedHdl));
4310}
4311
4313{
4314 if ( !OComponentHelper::rBHelper.bDisposed )
4315 {
4316 acquire();
4317 dispose();
4318 }
4319
4320}
4321
4323{
4324 css::lang::EventObject aEvt(*this);
4327
4328 m_pComboBox->SetAuxModifyHdl(Link<bool,void>());
4329 m_pComboBox = nullptr;
4330
4332}
4333
4334Any SAL_CALL FmXComboBoxCell::queryAggregation( const css::uno::Type& _rType )
4335{
4336 Any aReturn = FmXTextCell::queryAggregation(_rType);
4337
4338 if ( !aReturn.hasValue() )
4339 aReturn = FmXComboBoxCell_Base::queryInterface( _rType );
4340
4341 return aReturn;
4342}
4343
4344Sequence< Type > SAL_CALL FmXComboBoxCell::getTypes( )
4345{
4346 return ::comphelper::concatSequences(
4349 );
4350}
4351
4353
4354void SAL_CALL FmXComboBoxCell::addItemListener(const Reference< awt::XItemListener >& l)
4355{
4356 m_aItemListeners.addInterface( l );
4357}
4358
4359void SAL_CALL FmXComboBoxCell::removeItemListener(const Reference< awt::XItemListener >& l)
4360{
4362}
4363
4364void SAL_CALL FmXComboBoxCell::addActionListener(const Reference< awt::XActionListener >& l)
4365{
4367}
4368
4369
4370void SAL_CALL FmXComboBoxCell::removeActionListener(const Reference< awt::XActionListener >& l)
4371{
4373}
4374
4375void SAL_CALL FmXComboBoxCell::addItem( const OUString& Item, sal_Int16 Pos )
4376{
4377 ::osl::MutexGuard aGuard( m_aMutex );
4378 if (!m_pComboBox)
4379 return;
4380 weld::ComboBox& rBox = m_pComboBox->get_widget();
4381 rBox.insert_text(Pos, Item);
4382}
4383
4384void SAL_CALL FmXComboBoxCell::addItems( const Sequence< OUString >& Items, sal_Int16 Pos )
4385{
4386 ::osl::MutexGuard aGuard( m_aMutex );
4387 if (!m_pComboBox)
4388 return;
4389 weld::ComboBox& rBox = m_pComboBox->get_widget();
4390 sal_uInt16 nP = Pos;
4391 for ( const auto& rItem : Items )
4392 {
4393 rBox.insert_text(nP, rItem);
4394 if ( Pos != -1 )
4395 nP++;
4396 }
4397}
4398
4399void SAL_CALL FmXComboBoxCell::removeItems( sal_Int16 Pos, sal_Int16 Count )
4400{
4401 ::osl::MutexGuard aGuard( m_aMutex );
4402 if (!m_pComboBox)
4403 return;
4404 weld::ComboBox& rBox = m_pComboBox->get_widget();
4405 for ( sal_uInt16 n = Count; n; )
4406 rBox.remove( Pos + (--n) );
4407}
4408
4410{
4411 ::osl::MutexGuard aGuard( m_aMutex );
4412 if (!m_pComboBox)
4413 return 0;
4414 weld::ComboBox& rBox = m_pComboBox->get_widget();
4415 return rBox.get_count();
4416}
4417
4418OUString SAL_CALL FmXComboBoxCell::getItem( sal_Int16 Pos )
4419{
4420 ::osl::MutexGuard aGuard( m_aMutex );
4421 if (!m_pComboBox)
4422 return OUString();
4423 weld::ComboBox& rBox = m_pComboBox->get_widget();
4424 return rBox.get_text(Pos);
4425}
4426
4427Sequence< OUString > SAL_CALL FmXComboBoxCell::getItems()
4428{
4429 ::osl::MutexGuard aGuard( m_aMutex );
4430
4431 Sequence< OUString > aItems;
4432 if (m_pComboBox)
4433 {
4434 weld::ComboBox& rBox = m_pComboBox->get_widget();
4435 const sal_Int32 nEntries = rBox.get_count();
4436 aItems.realloc( nEntries );
4437 OUString* pItem = aItems.getArray();
4438 for ( sal_Int32 n=0; n<nEntries; ++n, ++pItem )
4439 *pItem = rBox.get_text(n);
4440 }
4441 return aItems;
4442}
4443
4445{
4446 ::osl::MutexGuard aGuard( m_aMutex );
4447 return m_nLines;
4448}
4449
4450void SAL_CALL FmXComboBoxCell::setDropDownLineCount(sal_Int16 nLines)
4451{
4452 ::osl::MutexGuard aGuard( m_aMutex );
4453 m_nLines = nLines; // just store it to return it
4454}
4455
4456IMPL_LINK(FmXComboBoxCell, ChangedHdl, bool, bInteractive, void)
4457{
4458 if (!m_pComboBox)
4459 return;
4460
4461 weld::ComboBox& rComboBox = m_pComboBox->get_widget();
4462
4463 if (bInteractive && !rComboBox.changed_by_direct_pick())
4464 return;
4465
4466 awt::ItemEvent aEvent;
4467 aEvent.Source = *this;
4468 aEvent.Highlighted = 0;
4469
4470 // with invalid selection 0xFFFF, otherwise the position
4471 aEvent.Selected = ( rComboBox.get_active() != -1 )
4472 ? rComboBox.get_active()
4473 : 0xFFFF;
4474 m_aItemListeners.notifyEach( &awt::XItemListener::itemStateChanged, aEvent );
4475}
4476
4477FmXFilterCell::FmXFilterCell(DbGridColumn* pColumn, std::unique_ptr<DbFilterField> pControl )
4478 :FmXGridCell( pColumn, std::move(pControl) )
4479 ,m_aTextListeners(m_aMutex)
4480{
4481 static_cast<DbFilterField*>(m_pCellControl.get())->SetCommitHdl( LINK( this, FmXFilterCell, OnCommit ) );
4482}
4483
4485{
4486 if (!OComponentHelper::rBHelper.bDisposed)
4487 {
4488 acquire();
4489 dispose();
4490 }
4491
4492}
4493
4495{
4496 static_cast< DbFilterField* >( m_pCellControl.get() )->PaintCell( rDev, rRect );
4497}
4498
4499// OComponentHelper
4500
4502{
4503 css::lang::EventObject aEvt(*this);
4505
4506 static_cast<DbFilterField*>(m_pCellControl.get())->SetCommitHdl(Link<DbFilterField&,void>());
4507
4509}
4510
4511
4512Any SAL_CALL FmXFilterCell::queryAggregation( const css::uno::Type& _rType )
4513{
4514 Any aReturn = FmXGridCell::queryAggregation(_rType);
4515
4516 if ( !aReturn.hasValue() )
4517 aReturn = FmXFilterCell_Base::queryInterface( _rType );
4518
4519 return aReturn;
4520}
4521
4522
4523Sequence< css::uno::Type > SAL_CALL FmXFilterCell::getTypes( )
4524{
4525 return ::comphelper::concatSequences(
4528 );
4529}
4530
4531
4533
4534// css::awt::XTextComponent
4535
4536void SAL_CALL FmXFilterCell::addTextListener(const Reference< css::awt::XTextListener >& l)
4537{
4538 m_aTextListeners.addInterface( l );
4539}
4540
4541
4542void SAL_CALL FmXFilterCell::removeTextListener(const Reference< css::awt::XTextListener >& l)
4543{
4545}
4546
4547void SAL_CALL FmXFilterCell::setText( const OUString& aText )
4548{
4549 ::osl::MutexGuard aGuard( m_aMutex );
4550 static_cast<DbFilterField*>(m_pCellControl.get())->SetText(aText);
4551}
4552
4553void SAL_CALL FmXFilterCell::insertText( const css::awt::Selection& /*rSel*/, const OUString& /*aText*/ )
4554{
4555}
4556
4557OUString SAL_CALL FmXFilterCell::getText()
4558{
4559 ::osl::MutexGuard aGuard( m_aMutex );
4560 return static_cast<DbFilterField*>(m_pCellControl.get())->GetText();
4561}
4562
4564{
4565 return getText();
4566}
4567
4568void SAL_CALL FmXFilterCell::setSelection( const css::awt::Selection& /*aSelection*/ )
4569{
4570}
4571
4572css::awt::Selection SAL_CALL FmXFilterCell::getSelection()
4573{
4574 return css::awt::Selection();
4575}
4576
4578{
4579 return true;
4580}
4581
4582void SAL_CALL FmXFilterCell::setEditable( sal_Bool /*bEditable*/ )
4583{
4584}
4585
4587{
4588 return 0;
4589}
4590
4591void SAL_CALL FmXFilterCell::setMaxTextLen( sal_Int16 /*nLen*/ )
4592{
4593}
4594
4596{
4597 css::awt::TextEvent aEvt;
4598 aEvt.Source = *this;
4599 m_aTextListeners.notifyEach( &css::awt::XTextListener::textChanged, aEvt );
4600}
4601
4602/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
DrawTextFlags
Reference< XComponentContext > m_xContext
AnyEventRef aEvent
const MouseSettings & GetMouseSettings() const
const LanguageTag & GetUILanguageTag() const
void SetMouseSettings(const MouseSettings &rSet)
const StyleSettings & GetStyleSettings() const
void SetStyleSettings(const StyleSettings &rSet)
static const AllSettings & GetSettings()
sal_uInt16 GetColumnId(sal_uInt16 nPos) const
BrowserDataWin & GetDataWindow() const
sal_Int32 GetCurRow() const
void SetColumnTitle(sal_uInt16 nColumnId, const OUString &rTitle)
sal_uInt16 GetCurColumnId() const
weld::ComboBox * get_widget()
css::util::Date GetUNODate() const
void ImplInitWindow(vcl::Window const &rParent, const InitWindowFacet _eInitWhat)
Definition: gridcell.cxx:696
virtual OUString GetFormatText(const css::uno::Reference< css::sdb::XColumn > &_rxField, const css::uno::Reference< css::util::XNumberFormatter > &xFormatter, const Color **ppColor=nullptr)=0
DbGridColumn & m_rColumn
Definition: gridcell.hxx:202
virtual void _propertyChanged(const css::beans::PropertyChangeEvent &evt) override
Definition: gridcell.cxx:637
void AlignControl(sal_Int16 nAlignment)
Definition: gridcell.cxx:932
bool isTransparent() const
Definition: gridcell.hxx:211
void implAdjustReadOnly(const css::uno::Reference< css::beans::XPropertySet > &_rxModel, bool i_bReadOnly)
updates the "readonly" setting on m_pWindow, according to the respective property value in the given ...
Definition: gridcell.cxx:802
void setTransparent(bool _bSet)
Definition: gridcell.hxx:212
void invalidatedController()
Definition: gridcell.cxx:996
virtual bool commitControl()=0
commits the content of the control (e.g.
rtl::Reference<::comphelper::OPropertyChangeMultiplexer > m_pFieldChangeBroadcaster
Definition: gridcell.hxx:191
virtual void Init(BrowserDataWin &rParent, const css::uno::Reference< css::sdbc::XRowSet > &xCursor)
Definition: gridcell.cxx:829
void implAdjustEnabled(const css::uno::Reference< css::beans::XPropertySet > &_rxModel)
updates the "enabled" setting on m_pWindow, according to the respective property value in the given m...
Definition: gridcell.cxx:817
void unlockValueProperty()
unlocks the listening at the value property
Definition: gridcell.hxx:339
const css::uno::Reference< css::sdbc::XRowSet > & getCursor() const
Definition: gridcell.hxx:208
void doPropertyListening(const OUString &_rPropertyName)
Definition: gridcell.cxx:594
css::uno::Reference< css::sdbc::XRowSet > m_xCursor
Definition: gridcell.hxx:199
VclPtr< svt::ControlBase > m_pWindow
Definition: gridcell.hxx:204
VclPtr< svt::ControlBase > m_pPainter
Definition: gridcell.hxx:203
void setAlignedController(bool _bAlign)
Definition: gridcell.hxx:215
bool isAlignedController() const
Definition: gridcell.hxx:261
bool isValuePropertyLocked() const
determined whether or not the value property is locked
Definition: gridcell.hxx:326
double GetValue(const css::uno::Reference< css::sdb::XColumn > &_rxField, const css::uno::Reference< css::util::XNumberFormatter > &xFormatter) const
Definition: gridcell.cxx:964
virtual void PaintCell(OutputDevice &_rDev, const tools::Rectangle &_rRect)
Definition: gridcell.cxx:952
bool Commit()
Definition: gridcell.cxx:676
void SetTextLineColor()
Definition: gridcell.cxx:888
rtl::Reference<::comphelper::OPropertyChangeMultiplexer > m_pModelChangeBroadcaster
Definition: gridcell.hxx:190
void implValuePropertyChanged()
Definition: gridcell.cxx:618
virtual void updateFromModel(css::uno::Reference< css::beans::XPropertySet > _rxModel)=0
updates the current content of the control (e.g.
virtual void PaintFieldToCell(OutputDevice &rDev, const tools::Rectangle &rRect, const css::uno::Reference< css::sdb::XColumn > &_rxField, const css::uno::Reference< css::util::XNumberFormatter > &xFormatter)
Definition: gridcell.cxx:958
virtual void implAdjustGenericFieldSetting(const css::uno::Reference< css::beans::XPropertySet > &_rxModel)
Definition: gridcell.cxx:631
DbCellControl(DbGridColumn &_rColumn)
Definition: gridcell.cxx:521
virtual ~DbCellControl() override
Definition: gridcell.cxx:609
void implDoPropertyListening(const OUString &_rPropertyName, bool _bWarnIfNotExistent)
Definition: gridcell.cxx:572
void lockValueProperty()
locks the listening at the value property.
Definition: gridcell.hxx:332
virtual void PaintFieldToCell(OutputDevice &rDev, const tools::Rectangle &rRect, const css::uno::Reference< css::sdb::XColumn > &_rxField, const css::uno::Reference< css::util::XNumberFormatter > &xFormatter) override
Definition: gridcell.cxx:1680
DbCheckBox(DbGridColumn &_rColumn)
Definition: gridcell.cxx:1594
virtual void Init(BrowserDataWin &rParent, const css::uno::Reference< css::sdbc::XRowSet > &xCursor) override
Definition: gridcell.cxx:1615
virtual OUString GetFormatText(const css::uno::Reference< css::sdb::XColumn > &_rxField, const css::uno::Reference< css::util::XNumberFormatter > &xFormatter, const Color **ppColor=nullptr) override
Definition: gridcell.cxx:1812
virtual void updateFromModel(css::uno::Reference< css::beans::XPropertySet > _rxModel) override
updates the current content of the control (e.g.
Definition: gridcell.cxx:1796
virtual ::svt::CellControllerRef CreateController() const override
Definition: gridcell.cxx:1650
virtual void UpdateFromField(const css::uno::Reference< css::sdb::XColumn > &_rxField, const css::uno::Reference< css::util::XNumberFormatter > &xFormatter) override
Definition: gridcell.cxx:1675
virtual void PaintCell(OutputDevice &rDev, const tools::Rectangle &rRect) override
Definition: gridcell.cxx:1711
virtual bool commitControl() override
commits the content of the control (e.g.
Definition: gridcell.cxx:1805
DbComboBox(DbGridColumn &_rColumn)
Definition: gridcell.cxx:2456
virtual void Init(BrowserDataWin &rParent, const css::uno::Reference< css::sdbc::XRowSet > &xCursor) override
Definition: gridcell.cxx:2499
virtual void implAdjustGenericFieldSetting(const css::uno::Reference< css::beans::XPropertySet > &_rxModel) override
Definition: gridcell.cxx:2494
virtual OUString GetFormatText(const css::uno::Reference< css::sdb::XColumn > &_rxField, const css::uno::Reference< css::util::XNumberFormatter > &xFormatter, const Color **ppColor=nullptr) override
Definition: gridcell.cxx:2526
virtual void UpdateFromField(const css::uno::Reference< css::sdb::XColumn > &_rxField, const css::uno::Reference< css::util::XNumberFormatter > &xFormatter) override
Definition: gridcell.cxx:2534
virtual void _propertyChanged(const css::beans::PropertyChangeEvent &evt) override
Definition: gridcell.cxx:2465
virtual void updateFromModel(css::uno::Reference< css::beans::XPropertySet > _rxModel) override
updates the current content of the control (e.g.
Definition: gridcell.cxx:2540
virtual bool commitControl() override
commits the content of the control (e.g.
Definition: gridcell.cxx:2558
virtual ::svt::CellControllerRef CreateController() const override
Definition: gridcell.cxx:2521
void SetList(const css::uno::Any &rItems)
Definition: gridcell.cxx:2477
virtual void updateFromModel(css::uno::Reference< css::beans::XPropertySet > _rxModel) override
updates the current content of the control (e.g.
Definition: gridcell.cxx:2185
virtual OUString GetFormatText(const css::uno::Reference< css::sdb::XColumn > &_rxField, const css::uno::Reference< css::util::XNumberFormatter > &xFormatter, const Color **ppColor=nullptr) override
Definition: gridcell.cxx:2175
virtual VclPtr< svt::ControlBase > createField(BrowserDataWin *_pParent, bool bSpinButton, const css::uno::Reference< css::beans::XPropertySet > &_rxModel) override
Definition: gridcell.cxx:2144
virtual bool commitControl() override
commits the content of the control (e.g.
Definition: gridcell.cxx:2201
virtual void UpdateFromField(const css::uno::Reference< css::sdb::XColumn > &_rxField, const css::uno::Reference< css::util::XNumberFormatter > &xFormatter) override
Definition: gridcell.cxx:2180
virtual void implAdjustGenericFieldSetting(const css::uno::Reference< css::beans::XPropertySet > &_rxModel) override
initializes everything which relates to the properties describing the numeric behaviour
Definition: gridcell.cxx:2109
DbCurrencyField(DbGridColumn &_rColumn)
Definition: gridcell.cxx:2097
virtual void updateFromModel(css::uno::Reference< css::beans::XPropertySet > _rxModel) override
updates the current content of the control (e.g.
Definition: gridcell.cxx:2315
virtual void implAdjustGenericFieldSetting(const css::uno::Reference< css::beans::XPropertySet > &_rxModel) override
initializes everything which relates to the properties describing the numeric behaviour
Definition: gridcell.cxx:2238
virtual OUString GetFormatText(const css::uno::Reference< css::sdb::XColumn > &_rxField, const css::uno::Reference< css::util::XNumberFormatter > &xFormatter, const Color **ppColor=nullptr) override
Definition: gridcell.cxx:2305
virtual VclPtr< svt::ControlBase > createField(BrowserDataWin *_pParent, bool bSpinButton, const css::uno::Reference< css::beans::XPropertySet > &_rxModel) override
Definition: gridcell.cxx:2227
virtual void UpdateFromField(const css::uno::Reference< css::sdb::XColumn > &_rxField, const css::uno::Reference< css::util::XNumberFormatter > &xFormatter) override
Definition: gridcell.cxx:2310
DbDateField(DbGridColumn &_rColumn)
Definition: gridcell.cxx:2217
virtual bool commitControl() override
commits the content of the control (e.g.
Definition: gridcell.cxx:2328
void CreateControl(BrowserDataWin *pParent, const css::uno::Reference< css::beans::XPropertySet > &xModel)
Definition: gridcell.cxx:2783
virtual void Init(BrowserDataWin &rParent, const css::uno::Reference< css::sdbc::XRowSet > &xCursor) override
Definition: gridcell.cxx:2833
bool m_bFilterListFilled
Definition: gridcell.hxx:668
css::uno::Sequence< OUString > m_aValueList
Definition: gridcell.hxx:663
virtual bool commitControl() override
commits the content of the control (e.g.
Definition: gridcell.cxx:2901
virtual void updateFromModel(css::uno::Reference< css::beans::XPropertySet > _rxModel) override
updates the current content of the control (e.g.
Definition: gridcell.cxx:2892
virtual void Update() override
Definition: gridcell.cxx:3030
virtual void UpdateFromField(const css::uno::Reference< css::sdb::XColumn > &_rxField, const css::uno::Reference< css::util::XNumberFormatter > &xFormatter) override
Definition: gridcell.cxx:3154
DbFilterField(const css::uno::Reference< css::uno::XComponentContext > &rxContext, DbGridColumn &_rColumn)
Definition: gridcell.cxx:2715
virtual ::svt::CellControllerRef CreateController() const override
Definition: gridcell.cxx:2869
virtual OUString GetFormatText(const css::uno::Reference< css::sdb::XColumn > &_rxField, const css::uno::Reference< css::util::XNumberFormatter > &xFormatter, const Color **ppColor=nullptr) override
Definition: gridcell.cxx:3149
virtual void PaintCell(OutputDevice &rDev, const tools::Rectangle &rRect) override
Definition: gridcell.cxx:2733
bool m_bFilterList
Definition: gridcell.hxx:667
void SetList(const css::uno::Any &rItems, bool bComboBox)
Definition: gridcell.cxx:2758
Link< DbFilterField &, void > m_aCommitLink
Definition: gridcell.hxx:665
OUString m_aText
Definition: gridcell.hxx:664
virtual ~DbFilterField() override
Definition: gridcell.cxx:2726
void SetText(const OUString &rText)
Definition: gridcell.cxx:2990
sal_Int16 m_nControlClass
Definition: gridcell.hxx:666
virtual OUString GetFormatText(const css::uno::Reference< css::sdb::XColumn > &_rxField, const css::uno::Reference< css::util::XNumberFormatter > &xFormatter, const Color **ppColor=nullptr) override
Definition: gridcell.cxx:1457
virtual void updateFromModel(css::uno::Reference< css::beans::XPropertySet > _rxModel) override
updates the current content of the control (e.g.
Definition: gridcell.cxx:1549
virtual bool commitControl() override
commits the content of the control (e.g.
Definition: gridcell.cxx:1573
virtual void _propertyChanged(const css::beans::PropertyChangeEvent &evt) override
Definition: gridcell.cxx:1439
virtual void Init(BrowserDataWin &rParent, const css::uno::Reference< css::sdbc::XRowSet > &xCursor) override
Definition: gridcell.cxx:1225
virtual ~DbFormattedField() override
Definition: gridcell.cxx:1221
css::uno::Reference< css::util::XNumberFormatsSupplier > m_xSupplier
Definition: gridcell.hxx:418
virtual ::svt::CellControllerRef CreateController() const override
Definition: gridcell.cxx:1434
DbFormattedField(DbGridColumn &_rColumn)
Definition: gridcell.cxx:1214
virtual void UpdateFromField(const css::uno::Reference< css::sdb::XColumn > &_rxField, const css::uno::Reference< css::util::XNumberFormatter > &xFormatter) override
Definition: gridcell.cxx:1507
bool Commit()
Definition: gridcell.cxx:268
sal_Int32 GetKey() const
Definition: gridcell.hxx:122
DbGridControl & GetParent() const
Definition: gridcell.hxx:125
sal_uInt16 m_nId
Definition: gridcell.hxx:76
void ImplInitWindow(vcl::Window const &rParent, const InitWindowFacet _eInitWhat)
Definition: gridcell.cxx:511
sal_Int16 SetAlignmentFromModel(sal_Int16 nStandardAlign)
Definition: gridcell.cxx:372
void SetReadOnly(bool bRead)
Definition: gridcell.hxx:157
void UpdateFromField(const DbGridRow *pRow, const css::uno::Reference< css::util::XNumberFormatter > &xFormatter)
Definition: gridcell.cxx:258
bool IsNumeric() const
Definition: gridcell.hxx:120
OUString GetCellText(const DbGridRow *pRow, const css::uno::Reference< css::util::XNumberFormatter > &xFormatter) const
void setModel(const css::uno::Reference< css::beans::XPropertySet > &_xModel)
Definition: gridcell.cxx:294
sal_Int16 GetAlignment() const
Definition: gridcell.hxx:118
::svt::CellControllerRef s_xEmptyController
Definition: gridcell.hxx:87
bool m_bNumeric
Definition: gridcell.hxx:82
bool m_bLocked
Definition: gridcell.hxx:85
sal_uInt16 GetId() const
Definition: gridcell.hxx:115
bool m_bAutoValue
Definition: gridcell.hxx:80
sal_Int16 m_nFieldType
Definition: gridcell.hxx:74
rtl::Reference< FmXGridCell > m_pCell
Definition: gridcell.hxx:70
void CreateControl(sal_Int32 _nFieldPos, const css::uno::Reference< css::beans::XPropertySet > &xField, sal_Int32 nTypeId)
Definition: gridcell.cxx:137
bool m_bHidden
Definition: gridcell.hxx:84
sal_Int16 GetFieldPos() const
Definition: gridcell.hxx:119
css::uno::Reference< css::beans::XPropertySet > m_xModel
Definition: gridcell.hxx:65
bool m_bObject
Definition: gridcell.hxx:83
DbGridControl & m_rParent
Definition: gridcell.hxx:71
void setLock(bool _bLock)
Definition: gridcell.cxx:385
sal_Int16 m_nFieldPos
Definition: gridcell.hxx:77
sal_Int16 m_nTypeId
Definition: gridcell.hxx:75
bool m_bReadOnly
Definition: gridcell.hxx:79
css::uno::Reference< css::sdb::XColumn > GetCurrentFieldValue() const
Definition: gridcell.cxx:432
sal_Int16 SetAlignment(sal_Int16 _nAlign)
Definition: gridcell.cxx:327
bool m_bInSave
Definition: gridcell.hxx:81
sal_Int32 m_nFormatKey
Definition: gridcell.hxx:73
bool isLocked() const
Definition: gridcell.hxx:171
sal_Int16 m_nAlign
Definition: gridcell.hxx:78
bool IsReadOnly() const
Definition: gridcell.hxx:116
const css::uno::Reference< css::beans::XPropertySet > & GetField() const
Definition: gridcell.hxx:124
::svt::CellControllerRef m_xController
Definition: gridcell.hxx:67
css::uno::Reference< css::beans::XPropertySet > m_xField
Definition: gridcell.hxx:66
void Paint(OutputDevice &rDev, const tools::Rectangle &rRect, const DbGridRow *pRow, const css::uno::Reference< css::util::XNumberFormatter > &xFormatter)
Definition: gridcell.cxx:444
void impl_toggleScriptManager_nothrow(bool _bAttach)
attaches or detaches our cell object to the SctriptEventAttacherManager implemented by our model's pa...
Definition: gridcell.cxx:236
void Clear()
Definition: gridcell.cxx:306
const css::uno::Reference< css::beans::XPropertySet > & getModel() const
Definition: gridcell.hxx:111
void refreshController(sal_uInt16 _nColId, GrantControlAccess _aAccess)
called when a controller needs to be re-initialized
Definition: gridctrl.cxx:1141
CursorWrapper * getDataSource() const
Definition: gridctrl.hxx:404
const css::util::Date & getNullDate() const
Definition: gridctrl.hxx:444
const css::uno::Reference< css::util::XNumberFormatter > & getNumberFormatter() const
Definition: gridctrl.hxx:396
bool getDisplaySynchron() const
Definition: gridctrl.hxx:473
bool IsFilterMode() const
Definition: gridctrl.hxx:431
const DbGridRowRef & GetCurrentRow() const
Definition: gridctrl.hxx:480
const css::uno::Reference< css::uno::XComponentContext > & getContext() const
Definition: gridctrl.hxx:504
void RowModified(sal_Int32 nRow)
Definition: gridctrl.cxx:2803
bool IsValid() const
Definition: gridctrl.hxx:89
bool HasField(sal_uInt32 nPos) const
Definition: gridctrl.hxx:79
const ::svxform::DataColumn & GetField(sal_uInt32 nPos) const
Definition: gridctrl.hxx:80
bool IsNew() const
Definition: gridctrl.hxx:85
a field which is bound to a column which supports the MaxTextLen property
Definition: gridcell.hxx:349
virtual void implSetEffectiveMaxTextLen(sal_Int32 _nMaxLen)
Definition: gridcell.cxx:1022
void implSetMaxTextLen(sal_Int16 _nMaxLen)
Definition: gridcell.hxx:360
virtual void implAdjustGenericFieldSetting(const css::uno::Reference< css::beans::XPropertySet > &_rxModel) override
Definition: gridcell.cxx:1010
DbLimitedLengthField(DbGridColumn &_rColumn)
Definition: gridcell.cxx:1003
virtual void _propertyChanged(const css::beans::PropertyChangeEvent &evt) override
Definition: gridcell.cxx:2578
bool m_bBound
Definition: gridcell.hxx:470
virtual void Init(BrowserDataWin &rParent, const css::uno::Reference< css::sdbc::XRowSet > &xCursor) override
Definition: gridcell.cxx:2616
css::uno::Sequence< OUString > m_aValueList
Definition: gridcell.hxx:471
virtual OUString GetFormatText(const css::uno::Reference< css::sdb::XColumn > &_rxField, const css::uno::Reference< css::util::XNumberFormatter > &xFormatter, const Color **ppColor=nullptr) override
Definition: gridcell.cxx:2640
virtual void implAdjustGenericFieldSetting(const css::uno::Reference< css::beans::XPropertySet > &_rxModel) override
Definition: gridcell.cxx:2630
virtual bool commitControl() override
commits the content of the control (e.g.
Definition: gridcell.cxx:2699
DbListBox(DbGridColumn &_rColumn)
Definition: gridcell.cxx:2568
virtual void updateFromModel(css::uno::Reference< css::beans::XPropertySet > _rxModel) override
updates the current content of the control (e.g.
Definition: gridcell.cxx:2675
virtual void UpdateFromField(const css::uno::Reference< css::sdb::XColumn > &_rxField, const css::uno::Reference< css::util::XNumberFormatter > &xFormatter) override
Definition: gridcell.cxx:2665
void SetList(const css::uno::Any &rItems)
Definition: gridcell.cxx:2590
virtual ::svt::CellControllerRef CreateController() const override
Definition: gridcell.cxx:2635
virtual void UpdateFromField(const css::uno::Reference< css::sdb::XColumn > &_rxField, const css::uno::Reference< css::util::XNumberFormatter > &xFormatter) override
Definition: gridcell.cxx:2060
virtual OUString GetFormatText(const css::uno::Reference< css::sdb::XColumn > &_rxField, const css::uno::Reference< css::util::XNumberFormatter > &xFormatter, const Color **ppColor=nullptr) override
Definition: gridcell.cxx:2055
DbNumericField(DbGridColumn &_rColumn)
Definition: gridcell.cxx:1958
virtual VclPtr< svt::ControlBase > createField(BrowserDataWin *_pParent, bool bSpinButton, const css::uno::Reference< css::beans::XPropertySet > &_rxModel) override
Definition: gridcell.cxx:2024
virtual bool commitControl() override
commits the content of the control (e.g.
Definition: gridcell.cxx:2081
virtual void updateFromModel(css::uno::Reference< css::beans::XPropertySet > _rxModel) override
updates the current content of the control (e.g.
Definition: gridcell.cxx:2065
void implAdjustGenericFieldSetting(const css::uno::Reference< css::beans::XPropertySet > &_rxModel) override
initializes everything which relates to the properties describing the numeric behaviour
Definition: gridcell.cxx:1969
virtual void Init(BrowserDataWin &rParent, const css::uno::Reference< css::sdbc::XRowSet > &xCursor) override
Definition: gridcell.cxx:1852
virtual bool commitControl() override
DbCellControl.
Definition: gridcell.cxx:1919
DbPatternField(DbGridColumn &_rColumn, const css::uno::Reference< css::uno::XComponentContext > &_rContext)
Definition: gridcell.cxx:1817
virtual ::svt::CellControllerRef CreateController() const override
Definition: gridcell.cxx:1865
virtual void updateFromModel(css::uno::Reference< css::beans::XPropertySet > _rxModel) override
updates the current content of the control (e.g.
Definition: gridcell.cxx:1907
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: gridcell.hxx:515
virtual void implAdjustGenericFieldSetting(const css::uno::Reference< css::beans::XPropertySet > &_rxModel) override
Definition: gridcell.cxx:1826
OUString impl_formatText(const OUString &_rText)
Definition: gridcell.cxx:1870
virtual void UpdateFromField(const css::uno::Reference< css::sdb::XColumn > &_rxField, const css::uno::Reference< css::util::XNumberFormatter > &xFormatter) override
Definition: gridcell.cxx:1900
::std::unique_ptr< ::dbtools::FormattedColumnValue > m_pPaintFormatter
Definition: gridcell.hxx:514
::std::unique_ptr< ::dbtools::FormattedColumnValue > m_pValueFormatter
Definition: gridcell.hxx:513
virtual OUString GetFormatText(const css::uno::Reference< css::sdb::XColumn > &_rxField, const css::uno::Reference< css::util::XNumberFormatter > &xFormatter, const Color **ppColor=nullptr) override
Definition: gridcell.cxx:1878
DbSpinField(DbGridColumn &_rColumn, sal_Int16 _nStandardAlign=css::awt::TextAlign::RIGHT)
Definition: gridcell.cxx:1926
virtual ::svt::CellControllerRef CreateController() const override
Definition: gridcell.cxx:1953
sal_Int16 m_nStandardAlign
Definition: gridcell.hxx:522
virtual void Init(BrowserDataWin &rParent, const css::uno::Reference< css::sdbc::XRowSet > &_rxCursor) override
Definition: gridcell.cxx:1932
virtual VclPtr< svt::ControlBase > createField(BrowserDataWin *_pParent, bool bSpinButton, const css::uno::Reference< css::beans::XPropertySet > &_rxModel)=0
virtual OUString GetFormatText(const css::uno::Reference< css::sdb::XColumn > &_rxField, const css::uno::Reference< css::util::XNumberFormatter > &xFormatter, const Color **ppColor=nullptr) override
Definition: gridcell.cxx:1145
virtual void implSetEffectiveMaxTextLen(sal_Int32 _nMaxLen) override
Definition: gridcell.cxx:1206
::svt::IEditImplementation * GetEditImplementation()
Definition: gridcell.hxx:379
virtual void Init(BrowserDataWin &rParent, const css::uno::Reference< css::sdbc::XRowSet > &xCursor) override
Definition: gridcell.cxx:1041
virtual void UpdateFromField(const css::uno::Reference< css::sdb::XColumn > &_rxField, const css::uno::Reference< css::util::XNumberFormatter > &xFormatter) override
Definition: gridcell.cxx:1165
virtual void updateFromModel(css::uno::Reference< css::beans::XPropertySet > _rxModel) override
updates the current content of the control (e.g.
Definition: gridcell.cxx:1171
bool m_bIsMultiLineEdit
Definition: gridcell.hxx:372
virtual void PaintFieldToCell(OutputDevice &_rDev, const tools::Rectangle &_rRect, const css::uno::Reference< css::sdb::XColumn > &_rxField, const css::uno::Reference< css::util::XNumberFormatter > &_rxFormatter) override
Definition: gridcell.cxx:1137
DbTextField(DbGridColumn &_rColumn)
Definition: gridcell.cxx:1029
virtual bool commitControl() override
commits the content of the control (e.g.
Definition: gridcell.cxx:1189
bool IsMultiLineEdit() const
Definition: gridcell.hxx:380
virtual ~DbTextField() override
Definition: gridcell.cxx:1035
virtual ::svt::CellControllerRef CreateController() const override
Definition: gridcell.cxx:1132
std::unique_ptr<::svt::IEditImplementation > m_pEdit
Definition: gridcell.hxx:370
std::unique_ptr<::svt::IEditImplementation > m_pPainterImplementation
Definition: gridcell.hxx:371
virtual void updateFromModel(css::uno::Reference< css::beans::XPropertySet > _rxModel) override
updates the current content of the control (e.g.
Definition: gridcell.cxx:2426
virtual void implAdjustGenericFieldSetting(const css::uno::Reference< css::beans::XPropertySet > &_rxModel) override
initializes everything which relates to the properties describing the numeric behaviour
Definition: gridcell.cxx:2358
virtual void UpdateFromField(const css::uno::Reference< css::sdb::XColumn > &_rxField, const css::uno::Reference< css::util::XNumberFormatter > &xFormatter) override
Definition: gridcell.cxx:2421
virtual OUString GetFormatText(const css::uno::Reference< css::sdb::XColumn > &_rxField, const css::uno::Reference< css::util::XNumberFormatter > &xFormatter, const Color **ppColor=nullptr) override
Definition: gridcell.cxx:2416
DbTimeField(DbGridColumn &_rColumn)
Definition: gridcell.cxx:2344
virtual VclPtr< svt::ControlBase > createField(BrowserDataWin *_pParent, bool bSpinButton, const css::uno::Reference< css::beans::XPropertySet > &_rxModel) override
Definition: gridcell.cxx:2353