[Libreoffice-commits] core.git: 2 commits - sc/source
Markus Mohrhard
markus.mohrhard at googlemail.com
Sat Apr 4 07:44:45 PDT 2015
sc/source/filter/excel/xelink.cxx | 39 +++++++++++++++-----
sc/source/ui/condformat/condformatdlgentry.cxx | 47 +++++++++++++++++++++----
2 files changed, 70 insertions(+), 16 deletions(-)
New commits:
commit 9f1be6c65210e600baee5c63480df58e8b8ce7b1
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sat Apr 4 15:54:44 2015 +0200
save at least some of the external range name stuff to XLSX
Change-Id: If08968487f62d0bc4c827bb69be25db6f9d5a0ee
diff --git a/sc/source/filter/excel/xelink.cxx b/sc/source/filter/excel/xelink.cxx
index ace55e4..9ea0822 100644
--- a/sc/source/filter/excel/xelink.cxx
+++ b/sc/source/filter/excel/xelink.cxx
@@ -63,7 +63,7 @@ private:
@descr Derived classes should overwrite this function to write their data. */
virtual void WriteAddData( XclExpStream& rStrm );
-private:
+protected:
OUString maName; /// Calc name (title) of the external name.
XclExpStringRef mxName; /// Excel name (title) of the external name.
sal_uInt16 mnFlags; /// Flags for record export.
@@ -104,6 +104,8 @@ public:
explicit XclExpExtName( const XclExpRoot& rRoot, const XclExpSupbook& rSupbook, const OUString& rName,
const ScExternalRefCache::TokenArrayRef& rArray );
+ virtual void SaveXml(XclExpXmlStream& rStrm) SAL_OVERRIDE;
+
private:
/** Writes additional record contents. */
virtual void WriteAddData( XclExpStream& rStrm ) SAL_OVERRIDE;
@@ -135,6 +137,8 @@ public:
/** Writes the EXTERNNAME record list. */
virtual void Save( XclExpStream& rStrm ) SAL_OVERRIDE;
+ virtual void SaveXml(XclExpXmlStream& rStrm) SAL_OVERRIDE;
+
private:
typedef XclExpRecordList< XclExpExtNameBase > XclExpExtNameList;
typedef XclExpExtNameList::RecordRefType XclExpExtNameRef;
@@ -1045,6 +1049,19 @@ void XclExpExtName::WriteAddData( XclExpStream& rStrm )
rStrm << static_cast<sal_uInt16>(2) << EXC_TOKID_ERR << EXC_ERR_REF;
}
+void XclExpExtName::SaveXml(XclExpXmlStream& rStrm)
+{
+ sax_fastparser::FSHelperPtr pExternalLink = rStrm.GetCurrentStream();
+
+ pExternalLink->startElement(XML_definedName,
+ XML_name, XclXmlUtils::ToOString(maName).getStr(),
+ XML_refersTo, NULL,
+ XML_sheetId, NULL,
+ FSEND);
+
+ pExternalLink->endElement(XML_definedName);
+}
+
// List of external names =====================================================
XclExpExtNameBuffer::XclExpExtNameBuffer( const XclExpRoot& rRoot ) :
@@ -1098,6 +1115,11 @@ void XclExpExtNameBuffer::Save( XclExpStream& rStrm )
maNameList.Save( rStrm );
}
+void XclExpExtNameBuffer::SaveXml(XclExpXmlStream& rStrm)
+{
+ maNameList.SaveXml(rStrm);
+}
+
sal_uInt16 XclExpExtNameBuffer::GetIndex( const OUString& rName ) const
{
for( size_t nPos = 0, nSize = maNameList.GetSize(); nPos < nSize; ++nPos )
diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx b/sc/source/ui/condformat/condformatdlgentry.cxx
index a7ea722..b89b3b0 100644
--- a/sc/source/ui/condformat/condformatdlgentry.cxx
+++ b/sc/source/ui/condformat/condformatdlgentry.cxx
@@ -272,6 +272,26 @@ ScFormatEntry* ScConditionFrmtEntry::createConditionEntry() const
return pEntry;
}
+namespace {
+
+bool containsOnlyColumnLabel(Edit* pEdit, ScTokenArray* pArr)
+{
+ formula::FormulaToken* token = pArr->First();
+ formula::StackVar t = token->GetType();
+ OpCode op = token->GetOpCode();
+ if( ( op == ocColRowName ) ||
+ ( ( op == ocBad ) && ( t == formula::svString ) )
+ )
+ {
+ pEdit->SetControlBackground(COL_YELLOW);
+ return true;
+ }
+
+ return false;
+}
+
+}
+
IMPL_LINK(ScConditionFrmtEntry, OnEdChanged, Edit*, pEdit)
{
OUString aFormula = pEdit->GetText();
@@ -295,14 +315,27 @@ IMPL_LINK(ScConditionFrmtEntry, OnEdChanged, Edit*, pEdit)
}
// Recognized col/row name or string token, warn the user
- formula::FormulaToken* token = ta->First();
- formula::StackVar t = token->GetType();
- OpCode op = token->GetOpCode();
- if( ( op == ocColRowName ) ||
- ( ( op == ocBad ) && ( t == formula::svString ) )
- )
+ bool bContainsColumnLabel = containsOnlyColumnLabel(pEdit, ta.get());;
+ if (!bContainsColumnLabel)
+ {
+ ScCompiler aComp2( mpDoc, maPos );
+ aComp2.SetGrammar( mpDoc->GetGrammar() );
+ if (&maEdVal1 == pEdit)
+ {
+ OUString aFormula2 = maEdVal2.GetText();
+ boost::scoped_ptr<ScTokenArray> pArr2(aComp2.CompileString(aFormula2));
+ bContainsColumnLabel = containsOnlyColumnLabel(&maEdVal2, pArr2.get());
+ }
+ else
+ {
+ OUString aFormula1 = maEdVal1.GetText();
+ boost::scoped_ptr<ScTokenArray> pArr1(aComp2.CompileString(aFormula1));
+ bContainsColumnLabel = containsOnlyColumnLabel(&maEdVal1, pArr1.get());
+ }
+ }
+
+ if (bContainsColumnLabel)
{
- pEdit->SetControlBackground(COL_YELLOW);
maFtVal.SetText(ScGlobal::GetRscString(STR_UNQUOTED_STRING));
return 0;
}
commit de90039b9f04233a87b8dffb9a00ea3f534bc22c
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sat Apr 4 10:33:30 2015 +0200
actually make the exported file valid, related tdf#59663
Change-Id: Icc432d6d3e40be9a6e1956c2d0c1dd2250c273a9
diff --git a/sc/source/filter/excel/xelink.cxx b/sc/source/filter/excel/xelink.cxx
index 7962745..ace55e4 100644
--- a/sc/source/filter/excel/xelink.cxx
+++ b/sc/source/filter/excel/xelink.cxx
@@ -1389,19 +1389,18 @@ void XclExpXct::Save( XclExpStream& rStrm )
void XclExpXct::SaveXml( XclExpXmlStream& rStrm )
{
XclExpCrnList aCrnRecs;
- if (!BuildCrnList( aCrnRecs))
- {
- SAL_WARN("sc", "generating invalid OOXML files: sheetDataSet without sheetData child element");
- return;
- }
sax_fastparser::FSHelperPtr pFS = rStrm.GetCurrentStream();
+ bool bValid = BuildCrnList( aCrnRecs);
pFS->startElement( XML_sheetData,
- XML_sheetId, OString::number( mnSBTab).getStr(),
+ XML_sheetId, OString::number( mnSBTab).getStr(),
FSEND);
- // row elements
- aCrnRecs.SaveXml( rStrm );
+ if (bValid)
+ {
+ // row elements
+ aCrnRecs.SaveXml( rStrm );
+ }
pFS->endElement( XML_sheetData);
}
More information about the Libreoffice-commits
mailing list