[Libreoffice-commits] core.git: 2 commits - sc/inc sc/qa sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Mon Feb 24 13:04:44 PST 2014
sc/inc/address.hxx | 6 +++---
sc/inc/compiler.hxx | 10 +++++-----
sc/inc/tokenuno.hxx | 2 +-
sc/qa/unit/data/xlsx/external-refs.xlsx |binary
sc/qa/unit/subsequent_filters-test.cxx | 17 +++++++++++++++++
sc/source/core/tool/address.cxx | 12 ++++++------
sc/source/core/tool/compiler.cxx | 14 +++++---------
sc/source/filter/oox/formulabuffer.cxx | 21 ++++++++++++++-------
8 files changed, 51 insertions(+), 31 deletions(-)
New commits:
commit 4917cebdb988223be47b0f1a82241ade643bc675
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Mon Feb 24 16:02:20 2014 -0500
fdo#75304: Set external reference info to ScCompiler.
And remove this excessive const fetish which was unfortunately necessary to
get this to compile. Setting the container const is good enough.
Change-Id: I2c6cc55a88643a68e065c4518cdf069c247f4f02
diff --git a/sc/inc/address.hxx b/sc/inc/address.hxx
index cde53d0..3c08c60 100644
--- a/sc/inc/address.hxx
+++ b/sc/inc/address.hxx
@@ -285,7 +285,7 @@ public:
const Details& rDetails = detailsOOOa1,
ExternalInfo* pExtInfo = NULL,
const ::com::sun::star::uno::Sequence<
- const ::com::sun::star::sheet::ExternalLinkInfo > * pExternalLinks = NULL );
+ com::sun::star::sheet::ExternalLinkInfo>* pExternalLinks = NULL );
SC_DLLPUBLIC OUString Format( sal_uInt16 = 0, const ScDocument* = NULL,
const Details& rDetails = detailsOOOa1) const;
@@ -449,7 +449,7 @@ public:
const ScAddress::Details& rDetails = ScAddress::detailsOOOa1,
ScAddress::ExternalInfo* pExtInfo = NULL,
const ::com::sun::star::uno::Sequence<
- const ::com::sun::star::sheet::ExternalLinkInfo > * pExternalLinks = NULL );
+ com::sun::star::sheet::ExternalLinkInfo>* pExternalLinks = NULL );
SC_DLLPUBLIC sal_uInt16 ParseAny( const OUString&, ScDocument* = NULL,
const ScAddress::Details& rDetails = ScAddress::detailsOOOa1 );
@@ -482,7 +482,7 @@ public:
OUString& rExternDocName, OUString& rStartTabName, OUString& rEndTabName, sal_uInt16& nFlags,
bool bOnlyAcceptSingle,
const ::com::sun::star::uno::Sequence<
- const ::com::sun::star::sheet::ExternalLinkInfo > * pExternalLinks = NULL );
+ com::sun::star::sheet::ExternalLinkInfo>* pExternalLinks = NULL );
SC_DLLPUBLIC OUString Format(sal_uInt16 = 0, const ScDocument* = NULL,
const ScAddress::Details& rDetails = ScAddress::detailsOOOa1) const;
diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index a9f2d83..6ca4a6c 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -254,7 +254,7 @@ public:
virtual bool parseExternalName( const OUString& rSymbol, OUString& rFile, OUString& rName,
const ScDocument* pDoc,
const ::com::sun::star::uno::Sequence<
- const ::com::sun::star::sheet::ExternalLinkInfo > * pExternalLinks ) const = 0;
+ com::sun::star::sheet::ExternalLinkInfo>* pExternalLinks ) const = 0;
virtual OUString makeExternalNameStr( const OUString& rFile, const OUString& rName ) const = 0;
@@ -312,7 +312,7 @@ private:
SvNumberFormatter* mpFormatter;
// For CONV_XL_OOX, may be set via API by MOOXML filter.
- ::com::sun::star::uno::Sequence< const ::com::sun::star::sheet::ExternalLinkInfo > maExternalLinks;
+ com::sun::star::uno::Sequence<com::sun::star::sheet::ExternalLinkInfo> maExternalLinks;
sal_Unicode cSymbol[MAXSTRLEN]; // current Symbol
OUString aFormula; // formula source code
@@ -425,9 +425,9 @@ private:
public:
/// Set external link info for ScAddress::CONV_XL_OOX.
- inline void SetExternalLinks(
- const ::com::sun::star::uno::Sequence<
- const ::com::sun::star::sheet::ExternalLinkInfo > & rLinks )
+ void SetExternalLinks(
+ const ::com::sun::star::uno::Sequence<
+ com::sun::star::sheet::ExternalLinkInfo>& rLinks )
{
maExternalLinks = rLinks;
}
diff --git a/sc/inc/tokenuno.hxx b/sc/inc/tokenuno.hxx
index 4287405..408298d 100644
--- a/sc/inc/tokenuno.hxx
+++ b/sc/inc/tokenuno.hxx
@@ -56,7 +56,7 @@ class ScFormulaParserObj : public ::cppu::WeakImplHelper3<
{
private:
::com::sun::star::uno::Sequence< const ::com::sun::star::sheet::FormulaOpCodeMapEntry > maOpCodeMapping;
- ::com::sun::star::uno::Sequence< const ::com::sun::star::sheet::ExternalLinkInfo > maExternalLinks;
+ ::com::sun::star::uno::Sequence<com::sun::star::sheet::ExternalLinkInfo> maExternalLinks;
ScCompiler::OpCodeMapPtr mxOpCodeMap;
ScDocShell* mpDocShell;
sal_Int16 mnConv;
diff --git a/sc/source/core/tool/address.cxx b/sc/source/core/tool/address.cxx
index adb1d65..3cdd2fe 100644
--- a/sc/source/core/tool/address.cxx
+++ b/sc/source/core/tool/address.cxx
@@ -383,7 +383,7 @@ lcl_XL_ParseSheetRef( const sal_Unicode* start,
name is not numeric.
*/
static bool lcl_XL_getExternalDoc( const sal_Unicode** ppErrRet, OUString& rExternDocName,
- const uno::Sequence< const sheet::ExternalLinkInfo > * pExternalLinks)
+ const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks )
{
// 1-based, sequence starts with an empty element.
if (pExternalLinks && pExternalLinks->hasElements())
@@ -434,7 +434,7 @@ const sal_Unicode* ScRange::Parse_XL_Header(
OUString& rEndTabName,
sal_uInt16& nFlags,
bool bOnlyAcceptSingle,
- const uno::Sequence< const sheet::ExternalLinkInfo > * pExternalLinks )
+ const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks )
{
const sal_Unicode* startTabs, *start = p;
sal_uInt16 nSaveFlags = nFlags;
@@ -881,7 +881,7 @@ lcl_ScRange_Parse_XL_A1( ScRange& r,
ScDocument* pDoc,
bool bOnlyAcceptSingle,
ScAddress::ExternalInfo* pExtInfo,
- const uno::Sequence< const sheet::ExternalLinkInfo > * pExternalLinks )
+ const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks )
{
const sal_Unicode* tmp1, *tmp2;
OUString aExternDocName, aStartTabName, aEndTabName; // for external link table
@@ -1270,7 +1270,7 @@ static sal_uInt16
lcl_ScAddress_Parse ( const sal_Unicode* p, ScDocument* pDoc, ScAddress& rAddr,
const ScAddress::Details& rDetails,
ScAddress::ExternalInfo* pExtInfo = NULL,
- const uno::Sequence< const sheet::ExternalLinkInfo > * pExternalLinks = NULL )
+ const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks = NULL )
{
if( !*p )
return 0;
@@ -1353,7 +1353,7 @@ bool ConvertDoubleRef( ScDocument* pDoc, const OUString& rRefString, SCTAB nDefT
sal_uInt16 ScAddress::Parse( const OUString& r, ScDocument* pDoc,
const Details& rDetails,
ExternalInfo* pExtInfo,
- const uno::Sequence< const sheet::ExternalLinkInfo > * pExternalLinks )
+ const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks )
{
return lcl_ScAddress_Parse( r.getStr(), pDoc, *this, rDetails, pExtInfo, pExternalLinks );
}
@@ -1486,7 +1486,7 @@ lcl_ScRange_Parse_OOo( ScRange &aRange, const OUString& r, ScDocument* pDoc, ScA
sal_uInt16 ScRange::Parse( const OUString& r, ScDocument* pDoc,
const ScAddress::Details& rDetails,
ScAddress::ExternalInfo* pExtInfo,
- const uno::Sequence< const sheet::ExternalLinkInfo > * pExternalLinks )
+ const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks )
{
if (r.isEmpty())
return 0;
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 1ddbcfb..afb8f5f 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -454,7 +454,7 @@ static bool lcl_parseExternalName(
OUString& rName,
const sal_Unicode cSep,
const ScDocument* pDoc = NULL,
- const uno::Sequence< const sheet::ExternalLinkInfo > * pExternalLinks = NULL )
+ const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks = NULL )
{
/* TODO: future versions will have to support sheet-local names too, thus
* return a possible sheet name as well. */
@@ -818,8 +818,7 @@ struct ConventionOOO_A1 : public Convention_A1
virtual bool parseExternalName( const OUString& rSymbol, OUString& rFile, OUString& rName,
const ScDocument* pDoc,
- const ::com::sun::star::uno::Sequence<
- const ::com::sun::star::sheet::ExternalLinkInfo > * pExternalLinks ) const
+ const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks ) const
{
return lcl_parseExternalName(rSymbol, rFile, rName, '#', pDoc, pExternalLinks);
}
@@ -1045,8 +1044,7 @@ struct ConventionXL
static bool parseExternalName( const OUString& rSymbol, OUString& rFile, OUString& rName,
const ScDocument* pDoc,
- const ::com::sun::star::uno::Sequence<
- const ::com::sun::star::sheet::ExternalLinkInfo > * pExternalLinks )
+ const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks )
{
return lcl_parseExternalName( rSymbol, rFile, rName, '!', pDoc, pExternalLinks);
}
@@ -1261,8 +1259,7 @@ struct ConventionXL_A1 : public Convention_A1, public ConventionXL
virtual bool parseExternalName( const OUString& rSymbol, OUString& rFile, OUString& rName,
const ScDocument* pDoc,
- const ::com::sun::star::uno::Sequence<
- const ::com::sun::star::sheet::ExternalLinkInfo > * pExternalLinks ) const
+ const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks ) const
{
return ConventionXL::parseExternalName( rSymbol, rFile, rName, pDoc, pExternalLinks);
}
@@ -1436,8 +1433,7 @@ struct ConventionXL_R1C1 : public ScCompiler::Convention, public ConventionXL
virtual bool parseExternalName( const OUString& rSymbol, OUString& rFile, OUString& rName,
const ScDocument* pDoc,
- const ::com::sun::star::uno::Sequence<
- const ::com::sun::star::sheet::ExternalLinkInfo > * pExternalLinks ) const
+ const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks ) const
{
return ConventionXL::parseExternalName( rSymbol, rFile, rName, pDoc, pExternalLinks);
}
diff --git a/sc/source/filter/oox/formulabuffer.cxx b/sc/source/filter/oox/formulabuffer.cxx
index 9f4404b..ca241a6 100644
--- a/sc/source/filter/oox/formulabuffer.cxx
+++ b/sc/source/filter/oox/formulabuffer.cxx
@@ -9,6 +9,7 @@
#include "formulabuffer.hxx"
#include "formulaparser.hxx"
+#include <externallinkbuffer.hxx>
#include <com/sun/star/sheet/XFormulaTokens.hpp>
#include <com/sun/star/sheet/XArrayFormulaTokens.hpp>
#include <com/sun/star/container/XIndexAccess.hpp>
@@ -178,6 +179,7 @@ void applySharedFormulas(
void applyCellFormulas(
ScDocumentImport& rDoc, CachedTokenArray& rCache, SvNumberFormatter& rFormatter,
+ const uno::Sequence<sheet::ExternalLinkInfo>& rExternalLinks,
const std::vector<FormulaBuffer::TokenAddressItem>& rCells )
{
std::vector<FormulaBuffer::TokenAddressItem>::const_iterator it = rCells.begin(), itEnd = rCells.end();
@@ -220,6 +222,7 @@ void applyCellFormulas(
ScCompiler aCompiler(&rDoc.getDoc(), aPos);
aCompiler.SetNumberFormatter(&rFormatter);
aCompiler.SetGrammar(formula::FormulaGrammar::GRAM_OOXML);
+ aCompiler.SetExternalLinks(rExternalLinks);
ScTokenArray* pCode = aCompiler.CompileString(it->maTokenStr);
if (!pCode)
continue;
@@ -271,7 +274,8 @@ void applyCellFormulaValues(
}
void processSheetFormulaCells(
- ScDocumentImport& rDoc, FormulaBuffer::SheetItem& rItem, SvNumberFormatter& rFormatter )
+ ScDocumentImport& rDoc, FormulaBuffer::SheetItem& rItem, SvNumberFormatter& rFormatter,
+ const uno::Sequence<sheet::ExternalLinkInfo>& rExternalLinks )
{
if (rItem.mpSharedFormulaEntries && rItem.mpSharedFormulaIDs)
applySharedFormulas(rDoc, rFormatter, *rItem.mpSharedFormulaEntries, *rItem.mpSharedFormulaIDs);
@@ -279,7 +283,7 @@ void processSheetFormulaCells(
if (rItem.mpCellFormulas)
{
CachedTokenArray aCache(rDoc.getDoc());
- applyCellFormulas(rDoc, aCache, rFormatter, *rItem.mpCellFormulas);
+ applyCellFormulas(rDoc, aCache, rFormatter, rExternalLinks, *rItem.mpCellFormulas);
}
if (rItem.mpArrayFormulas)
@@ -294,21 +298,24 @@ class WorkerThread : public salhelper::Thread
ScDocumentImport& mrDoc;
FormulaBuffer::SheetItem& mrItem;
boost::scoped_ptr<SvNumberFormatter> mpFormatter;
+ const uno::Sequence<sheet::ExternalLinkInfo>& mrExternalLinks;
WorkerThread( const WorkerThread& );
WorkerThread& operator= ( const WorkerThread& );
public:
- WorkerThread( ScDocumentImport& rDoc, FormulaBuffer::SheetItem& rItem, SvNumberFormatter* pFormatter ) :
+ WorkerThread(
+ ScDocumentImport& rDoc, FormulaBuffer::SheetItem& rItem, SvNumberFormatter* pFormatter,
+ const uno::Sequence<sheet::ExternalLinkInfo>& rExternalLinks ) :
salhelper::Thread("xlsx-import-formula-buffer-worker-thread"),
- mrDoc(rDoc), mrItem(rItem), mpFormatter(pFormatter) {}
+ mrDoc(rDoc), mrItem(rItem), mpFormatter(pFormatter), mrExternalLinks(rExternalLinks) {}
virtual ~WorkerThread() {}
protected:
virtual void execute()
{
- processSheetFormulaCells(mrDoc, mrItem, *mpFormatter);
+ processSheetFormulaCells(mrDoc, mrItem, *mpFormatter, mrExternalLinks);
}
};
@@ -366,7 +373,7 @@ void FormulaBuffer::finalizeImport()
if (nThreadCount == 1)
{
for (; it != itEnd; ++it)
- processSheetFormulaCells(rDoc, *it, *rDoc.getDoc().GetFormatTable());
+ processSheetFormulaCells(rDoc, *it, *rDoc.getDoc().GetFormatTable(), getExternalLinks().getLinkInfos());
}
else
{
@@ -384,7 +391,7 @@ void FormulaBuffer::finalizeImport()
if (it == itEnd)
break;
- WorkerThreadRef xThread(new WorkerThread(rDoc, *it, rDoc.getDoc().CreateFormatTable()));
+ WorkerThreadRef xThread(new WorkerThread(rDoc, *it, rDoc.getDoc().CreateFormatTable(), getExternalLinks().getLinkInfos()));
++it;
aThreads.push_back(xThread);
xThread->launch();
commit 3cf0847e7514a3f1217554c08cb109902cf2a637
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Mon Feb 24 13:53:12 2014 -0500
fdo#75304: Add test for external reference cache import from XLSX.
Change-Id: I93c4398b5673e1edaacfe4b68015000dfd224612
diff --git a/sc/qa/unit/data/xlsx/external-refs.xlsx b/sc/qa/unit/data/xlsx/external-refs.xlsx
new file mode 100644
index 0000000..805e36c
Binary files /dev/null and b/sc/qa/unit/data/xlsx/external-refs.xlsx differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index f4acfa9..7c332c4 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -159,6 +159,7 @@ public:
void testColumnStyleXLSX();
void testSharedFormulaHorizontalXLS();
+ void testExternalRefCacheXLSX();
CPPUNIT_TEST_SUITE(ScFiltersTest);
CPPUNIT_TEST(testBasicCellContentODS);
@@ -234,6 +235,7 @@ public:
CPPUNIT_TEST(testOutlineODS);
CPPUNIT_TEST(testColumnStyleXLSX);
CPPUNIT_TEST(testSharedFormulaHorizontalXLS);
+ CPPUNIT_TEST(testExternalRefCacheXLSX);
CPPUNIT_TEST_SUITE_END();
private:
@@ -2471,6 +2473,21 @@ void ScFiltersTest::testSharedFormulaHorizontalXLS()
xDocSh->DoClose();
}
+void ScFiltersTest::testExternalRefCacheXLSX()
+{
+ ScDocShellRef xDocSh = loadDoc("external-refs.", XLSX);
+ CPPUNIT_ASSERT(xDocSh.Is());
+ ScDocument* pDoc = xDocSh->GetDocument();
+
+ // These string values are cached external cell values.
+ CPPUNIT_ASSERT_EQUAL(OUString("Name"), pDoc->GetString(ScAddress(0,0,0)));
+ CPPUNIT_ASSERT_EQUAL(OUString("Andy"), pDoc->GetString(ScAddress(0,1,0)));
+ CPPUNIT_ASSERT_EQUAL(OUString("Bruce"), pDoc->GetString(ScAddress(0,2,0)));
+ CPPUNIT_ASSERT_EQUAL(OUString("Charlie"), pDoc->GetString(ScAddress(0,3,0)));
+
+ xDocSh->DoClose();
+}
+
ScFiltersTest::ScFiltersTest()
: ScBootstrapFixture( "/sc/qa/unit/data" )
{
More information about the Libreoffice-commits
mailing list