summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-02-10 18:27:14 +0100
committerEike Rathke <erack@redhat.com>2017-02-14 11:49:35 +0100
commit838fab822c8052dd9471e28a70b1907dfde111af (patch)
tree036311c563a47419f0c0dd3321872aa74ea868bb /sc
parentcdbec91da4931be72ed4f1b28f78d83a9a0d616f (diff)
Resolves: tdf#79250 add typed list to form control listbox
... so numeric and text data can be distinguished input. Change-Id: I63280a93c272ccc6f5e7ca06a1a1fcbfb3db8455
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/unoobj/celllistsource.cxx83
-rw-r--r--sc/source/ui/unoobj/celllistsource.hxx12
2 files changed, 84 insertions, 11 deletions
diff --git a/sc/source/ui/unoobj/celllistsource.cxx b/sc/source/ui/unoobj/celllistsource.cxx
index b2dec388e63e..c78b86282ea9 100644
--- a/sc/source/ui/unoobj/celllistsource.cxx
+++ b/sc/source/ui/unoobj/celllistsource.cxx
@@ -161,16 +161,64 @@ namespace calc
return aAddress;
}
- OUString OCellListSource::getCellTextContent_noCheck( sal_Int32 _nRangeRelativeRow )
+ OUString OCellListSource::getCellTextContent_noCheck( sal_Int32 _nRangeRelativeRow, css::uno::Any* pAny )
{
+ OUString sText;
+
OSL_PRECOND( m_xRange.is(), "OCellListSource::getRangeAddress: invalid range!" );
+
+ if (!m_xRange.is())
+ return sText;
+
+ Reference< XCell > xCell( m_xRange->getCellByPosition( 0, _nRangeRelativeRow ));
+ if (!xCell.is())
+ {
+ if (pAny)
+ *pAny <<= sText;
+ return sText;
+ }
+
Reference< XTextRange > xCellText;
- if ( m_xRange.is() )
- xCellText.set(m_xRange->getCellByPosition( 0, _nRangeRelativeRow ), css::uno::UNO_QUERY);
+ xCellText.set( xCell, UNO_QUERY);
+
+ if (xCellText.is())
+ sText = xCellText->getString(); // formatted output string
+
+ if (pAny)
+ {
+ switch (xCell->getType())
+ {
+ case CellContentType_VALUE:
+ *pAny <<= xCell->getValue();
+ break;
+ case CellContentType_TEXT:
+ *pAny <<= sText;
+ break;
+ case CellContentType_FORMULA:
+ if (xCell->getError())
+ *pAny <<= sText; // Err:... or #...!
+ else
+ {
+ Reference< XPropertySet > xProp( xCell, UNO_QUERY);
+ if (xProp.is())
+ {
+ CellContentType eResultType;
+ if ((xProp->getPropertyValue("FormulaResultType") >>= eResultType) &&
+ eResultType == CellContentType_VALUE)
+ *pAny <<= xCell->getValue();
+ else
+ *pAny <<= sText;
+ }
+ }
+ break;
+ case CellContentType_EMPTY:
+ *pAny <<= OUString();
+ break;
+ default:
+ ; // nothing, if actually occurred it would result in #N/A being displayed if selected
+ }
+ }
- OUString sText;
- if ( xCellText.is() )
- sText = xCellText->getString();
return sText;
}
@@ -193,7 +241,7 @@ namespace calc
if ( _nPosition >= getListEntryCount() )
throw IndexOutOfBoundsException();
- return getCellTextContent_noCheck( _nPosition );
+ return getCellTextContent_noCheck( _nPosition, nullptr );
}
Sequence< OUString > SAL_CALL OCellListSource::getAllListEntries( )
@@ -206,7 +254,26 @@ namespace calc
OUString* pAllEntries = aAllEntries.getArray();
for ( sal_Int32 i = 0; i < aAllEntries.getLength(); ++i )
{
- *pAllEntries++ = getCellTextContent_noCheck( i );
+ *pAllEntries++ = getCellTextContent_noCheck( i, nullptr );
+ }
+
+ return aAllEntries;
+ }
+
+ Sequence< OUString > SAL_CALL OCellListSource::getAllListEntriesTyped( Sequence< Any >& rDataValues )
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed();
+ checkInitialized();
+
+ const sal_Int32 nCount = getListEntryCount();
+ Sequence< OUString > aAllEntries( nCount );
+ rDataValues = Sequence< Any >( nCount );
+ OUString* pAllEntries = aAllEntries.getArray();
+ Any* pDataValues = rDataValues.getArray();
+ for ( sal_Int32 i = 0; i < nCount; ++i )
+ {
+ *pAllEntries++ = getCellTextContent_noCheck( i, pDataValues++ );
}
return aAllEntries;
diff --git a/sc/source/ui/unoobj/celllistsource.hxx b/sc/source/ui/unoobj/celllistsource.hxx
index 2763c768bc2d..5444dfe60ca6 100644
--- a/sc/source/ui/unoobj/celllistsource.hxx
+++ b/sc/source/ui/unoobj/celllistsource.hxx
@@ -20,7 +20,7 @@
#ifndef INCLUDED_SC_SOURCE_UI_UNOOBJ_CELLLISTSOURCE_HXX
#define INCLUDED_SC_SOURCE_UI_UNOOBJ_CELLLISTSOURCE_HXX
-#include <com/sun/star/form/binding/XListEntrySource.hpp>
+#include <com/sun/star/form/binding/XListEntryTypedSource.hpp>
#include <cppuhelper/compbase4.hxx>
#include <cppuhelper/basemutex.hxx>
#include <comphelper/interfacecontainer2.hxx>
@@ -42,7 +42,7 @@ namespace calc
class OCellListSource;
// the base for our interfaces
- typedef ::cppu::WeakAggComponentImplHelper4 < css::form::binding::XListEntrySource
+ typedef ::cppu::WeakAggComponentImplHelper4 < css::form::binding::XListEntryTypedSource
, css::util::XModifyListener
, css::lang::XServiceInfo
, css::lang::XInitialization
@@ -91,6 +91,9 @@ namespace calc
virtual void SAL_CALL addListEntryListener( const css::uno::Reference< css::form::binding::XListEntryListener >& Listener ) override;
virtual void SAL_CALL removeListEntryListener( const css::uno::Reference< css::form::binding::XListEntryListener >& Listener ) override;
+ // XListEntryTypedSource
+ virtual css::uno::Sequence< OUString > SAL_CALL getAllListEntriesTyped( css::uno::Sequence< css::uno::Any >& rDataValues ) override;
+
// OComponentHelper/XComponent
virtual void SAL_CALL disposing() override;
@@ -130,12 +133,15 @@ namespace calc
/** retrievs the text of a cell within our range
@param _nRangeRelativeRow
the relative row index of the cell within our range
+ @param pAny
+ if not <NULL/> then the underlying data value is returned in the Any
@precond
our m_xRange is not <NULL/>
*/
OUString
getCellTextContent_noCheck(
- sal_Int32 _nRangeRelativeRow
+ sal_Int32 _nRangeRelativeRow,
+ css::uno::Any* pAny
);
void notifyModified();