summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Power <noel.power@suse.com>2013-03-29 15:54:08 +0000
committerNoel Power <noel.power@suse.com>2013-04-04 17:31:00 +0100
commitb23f3059af8724cf6c1b19a4835e1bca3522ab2c (patch)
treee09d0dfa358d2efada4d086a2c042f73b335b25a
parentdea93b72779747f7a10ecd9681232eb0f0de5d03 (diff)
prepend Validation.Formula1 results with '=' for anything not a address
Change-Id: I6061378788b7299f8a8431d1e8d00a4e6ea3e8fb
-rw-r--r--sc/source/ui/vba/vbarange.cxx4
-rw-r--r--sc/source/ui/vba/vbarange.hxx1
-rw-r--r--sc/source/ui/vba/vbavalidation.cxx19
3 files changed, 21 insertions, 3 deletions
diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index 8b77f27a7239..abbe31e509d9 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -1146,7 +1146,7 @@ public:
};
bool
-getCellRangesForAddress( sal_uInt16& rResFlags, const rtl::OUString& sAddress, ScDocShell* pDocSh, ScRangeList& rCellRanges, formula::FormulaGrammar::AddressConvention& eConv, char cDelimiter = 0 )
+ScVbaRange::getCellRangesForAddress( sal_uInt16& rResFlags, const rtl::OUString& sAddress, ScDocShell* pDocSh, ScRangeList& rCellRanges, formula::FormulaGrammar::AddressConvention& eConv, char cDelimiter )
{
ScDocument* pDoc = NULL;
@@ -1221,7 +1221,7 @@ bool getScRangeListForAddress( const rtl::OUString& sName, ScDocShell* pDocSh, S
}
sal_uInt16 nFlags = 0;
- if ( !getCellRangesForAddress( nFlags, sAddress, pDocSh, aCellRanges, eConv, aChar ) )
+ if ( !ScVbaRange::getCellRangesForAddress( nFlags, sAddress, pDocSh, aCellRanges, eConv, aChar ) )
return false;
bool bTabFromReferrer = !( nFlags & SCA_TAB_3D );
diff --git a/sc/source/ui/vba/vbarange.hxx b/sc/source/ui/vba/vbarange.hxx
index ff4c618f681e..7c3a3d9a701f 100644
--- a/sc/source/ui/vba/vbarange.hxx
+++ b/sc/source/ui/vba/vbarange.hxx
@@ -285,6 +285,7 @@ public:
// * object should be a lightweight as possible
// * we shouldn't need hacks like this below
static css::uno::Reference< ov::excel::XRange > ApplicationRange( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Any &Cell1, const css::uno::Any &Cell2 ) throw (css::uno::RuntimeException);
+ static bool getCellRangesForAddress( sal_uInt16& rResFlags, const rtl::OUString& sAddress, ScDocShell* pDocSh, ScRangeList& rCellRanges, formula::FormulaGrammar::AddressConvention& eConv, char cDelimiter = 0 );
virtual sal_Bool SAL_CALL GoalSeek( const css::uno::Any& Goal, const css::uno::Reference< ov::excel::XRange >& ChangingCell ) throw (css::uno::RuntimeException);
virtual css::uno::Reference< ov::excel::XRange > SAL_CALL SpecialCells( const css::uno::Any& _oType, const css::uno::Any& _oValue) throw ( css::script::BasicErrorException );
// XErrorQuery
diff --git a/sc/source/ui/vba/vbavalidation.cxx b/sc/source/ui/vba/vbavalidation.cxx
index 1ba1724ed179..e7ab39642f75 100644
--- a/sc/source/ui/vba/vbavalidation.cxx
+++ b/sc/source/ui/vba/vbavalidation.cxx
@@ -28,6 +28,9 @@
#include <ooo/vba/excel/XlDVAlertStyle.hpp>
#include "unonames.hxx"
+#include "rangelst.hxx"
+#include "excelvbahelper.hxx"
+#include "vbarange.hxx"
using namespace ::ooo::vba;
using namespace ::com::sun::star;
@@ -307,7 +310,21 @@ ScVbaValidation::Add( const uno::Any& Type, const uno::Any& AlertStyle, const un
ScVbaValidation::getFormula1() throw (uno::RuntimeException)
{
uno::Reference< sheet::XSheetCondition > xCond( lcl_getValidationProps( m_xRange ), uno::UNO_QUERY_THROW );
- return xCond->getFormula1();
+ rtl::OUString sString = xCond->getFormula1();
+
+ sal_uInt16 nFlags = 0;
+ ScRangeList aCellRanges;
+ formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_XL_A1;
+
+ ScDocShell* pDocSh = excel::GetDocShellFromRange( m_xRange );
+ // in calc validation formula is either a range or formula
+ // that results in range.
+ // In VBA both formula and address can have a leading '='
+ // in result of getFormula1, however it *seems* that a named range or
+ // real formula has to (or is expected to) have the '='
+ if ( pDocSh && !ScVbaRange::getCellRangesForAddress( nFlags, sString, pDocSh, aCellRanges, eConv ) )
+ sString = "=" + sString;
+ return sString;
}
::rtl::OUString SAL_CALL