[PATCH libreoffice-4-0] prepend Validation.Formula1 results with '=' for anything no...
Noel Power (via Code Review)
gerrit at gerrit.libreoffice.org
Fri Apr 5 01:47:52 PDT 2013
Hi,
I have submitted a patch for review:
https://gerrit.libreoffice.org/3206
To pull it, you can do:
git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/06/3206/1
prepend Validation.Formula1 results with '=' for anything not a address
Change-Id: I6061378788b7299f8a8431d1e8d00a4e6ea3e8fb
---
M sc/source/ui/vba/vbarange.cxx
M sc/source/ui/vba/vbarange.hxx
M sc/source/ui/vba/vbavalidation.cxx
3 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index 8b77f27..abbe31e 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -1146,7 +1146,7 @@
};
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 @@
}
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 ff4c618..7c3a3d9 100644
--- a/sc/source/ui/vba/vbarange.hxx
+++ b/sc/source/ui/vba/vbarange.hxx
@@ -285,6 +285,7 @@
// * 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 1ba1724..e7ab396 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::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
--
To view, visit https://gerrit.libreoffice.org/3206
To unsubscribe, visit https://gerrit.libreoffice.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6061378788b7299f8a8431d1e8d00a4e6ea3e8fb
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: libreoffice-4-0
Gerrit-Owner: Noel Power <noel.power at suse.com>
More information about the LibreOffice
mailing list