summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Power <noel.power@suse.com>2013-03-27 12:59:34 +0000
committerNoel Power <noel.power@suse.com>2013-04-04 17:29:54 +0100
commita48e4b6415af147177f27774843af6b64198ef68 (patch)
tree022c1f69b9f45973214b8a1c3a94f6b64fa59d25
parentbc8f2941f3d9cb36bfadf79260ebbe83574b805d (diff)
prepend Validation.Formula1 results with '=' for anything not a address
Change-Id: If8e0b720bca4198123b1717967fc9e0beff6f874
-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 958888eeb2ff..fc46ffb0cbaf 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -1130,7 +1130,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;
@@ -1205,7 +1205,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 23290c1f6dc8..413b84dbd522 100644
--- a/sc/source/ui/vba/vbarange.hxx
+++ b/sc/source/ui/vba/vbarange.hxx
@@ -312,6 +312,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 03ce70ab85fd..358d373806cd 100644
--- a/sc/source/ui/vba/vbavalidation.cxx
+++ b/sc/source/ui/vba/vbavalidation.cxx
@@ -36,6 +36,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;
@@ -314,7 +317,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 = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("=") ).concat( sString );
+ return sString;
}
::rtl::OUString SAL_CALL