summaryrefslogtreecommitdiff
path: root/sc/source/ui/vba
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-05 17:15:00 +0100
commit6f814b5f4ceca2f50edffd8b9023c613fffb9cdf (patch)
treec9be6cacdb27922173ecda1cd999caf3fca61380 /sc/source/ui/vba
parent7e7302730454aa417f2711024e3a5d9d953add67 (diff)
prepend Validation.Formula1 results with '=' for anything not a address
Change-Id: I6061378788b7299f8a8431d1e8d00a4e6ea3e8fb
Diffstat (limited to 'sc/source/ui/vba')
-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 836f2aa38ef3..f3383326329a 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;
@@ -1220,7 +1220,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 e8cd9a550bee..26c583eb7de4 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 6fe1ffca789e..41189f859edd 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