summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/source/filter/excel/xeroot.cxx2
-rw-r--r--sc/source/filter/excel/xestyle.cxx92
-rw-r--r--sc/source/filter/inc/xestyle.hxx14
3 files changed, 96 insertions, 12 deletions
diff --git a/sc/source/filter/excel/xeroot.cxx b/sc/source/filter/excel/xeroot.cxx
index 9df6afecddca..31ad08bbd678 100644
--- a/sc/source/filter/excel/xeroot.cxx
+++ b/sc/source/filter/excel/xeroot.cxx
@@ -212,7 +212,7 @@ void XclExpRoot::InitializeGlobals()
// BIFF8: only one link manager for all sheets
mrExpData.mxLocLinkMgr = mrExpData.mxGlobLinkMgr;
mrExpData.mxDxfs.reset( new XclExpDxfs( GetRoot() ) );
- mrExpData.mxTableStyles.reset( new XclExpTableStyles( GetRoot() ) );
+ mrExpData.mxTableStyles.reset( new XclExpTableStyles( GetRoot(), GetDxfs() ) );
}
if( GetOutput() == EXC_OUTPUT_XML_2007 )
diff --git a/sc/source/filter/excel/xestyle.cxx b/sc/source/filter/excel/xestyle.cxx
index a1a7341f384e..028678c6e248 100644
--- a/sc/source/filter/excel/xestyle.cxx
+++ b/sc/source/filter/excel/xestyle.cxx
@@ -3134,8 +3134,8 @@ void XclExpDxf::SaveXml( XclExpXmlStream& rStrm )
XclExpTableStyleElement::XclExpTableStyleElement( const XclExpRoot& rRoot, OUString& rType, int iSize, int iDxfId )
:XclExpRoot( rRoot),
maType( rType ),
- maDxfId( iDxfId ),
- maSize( iSize )
+ miSize( iSize ),
+ miDxfId( iDxfId )
{
}
@@ -3143,16 +3143,54 @@ XclExpTableStyleElement::~XclExpTableStyleElement()
{
}
-void XclExpTableStyleElement::SaveXml( XclExpStream& rStrm )
+void XclExpTableStyleElement::SaveXml( XclExpXmlStream& rStrm )
{
+ sax_fastparser::FSHelperPtr& rStyleSheet = rStrm.GetCurrentStream();
+ rStyleSheet->singleElement( XML_tableStyleElement,
+ XML_type, OUStringToOString(maType, RTL_TEXTENCODING_UTF8 ).getStr(),
+ XML_size, OString::number(miSize).getStr(),
+ XML_dxfId, OString::number(miDxfId).getStr(),
+ FSEND );
}
// ============================================================================
-XclExpTableStyle::XclExpTableStyle( const XclExpRoot& rRoot, OUString& rTableStyleName )
+XclExpTableStyle::XclExpTableStyle( const XclExpRoot& rRoot, ScDBDataFormatting& rTableStyle, XclExpDxfs& rDxfs )
:XclExpRoot( rRoot ),
- maTableStyleName( rTableStyleName )
+ maTableStyle( rTableStyle )
{
+ //Get the table style name
+ maTableStyleName = maTableStyle.GetTableStyleName();
+ //Keep adding table style elements
+ OUString aStyleString;
+ OUString aElementType;
+ int aiDxfId;
+ if( !(aStyleString = maTableStyle.GetFirstRowStripeStyle()).isEmpty() )
+ {
+ //Resolve this string style sheet name to a dxf id
+ aiDxfId = rDxfs.GetDxfId( aStyleString );
+ aElementType = "firstRowStripe";
+ maStyleElementContainer.push_back( new XclExpTableStyleElement( rRoot, aElementType, 1, aiDxfId ) );
+ }
+ if( !(aStyleString = maTableStyle.GetSecondRowStripeStyle()).isEmpty() )
+ {
+ aiDxfId = rDxfs.GetDxfId( aStyleString );
+ aElementType = "secondRowStripe";
+ maStyleElementContainer.push_back( new XclExpTableStyleElement( rRoot, aElementType, 1, aiDxfId ) );
+ }
+ if( !(aStyleString = maTableStyle.GetFirstColStripeStyle()).isEmpty() )
+ {
+ aiDxfId = rDxfs.GetDxfId( aStyleString );
+ aElementType = "firstColumnStripe";
+ maStyleElementContainer.push_back( new XclExpTableStyleElement( rRoot, aElementType, 1, aiDxfId ) );
+ }
+ if( !(aStyleString = maTableStyle.GetSecondColStripeStyle()).isEmpty() )
+ {
+ aiDxfId = rDxfs.GetDxfId( aStyleString );
+ aElementType = "secondColumnStripe";
+ maStyleElementContainer.push_back( new XclExpTableStyleElement( rRoot, aElementType, 1, aiDxfId ) );
+ }
+ miCount = maStyleElementContainer.size();
}
XclExpTableStyle::~XclExpTableStyle()
@@ -3161,13 +3199,47 @@ XclExpTableStyle::~XclExpTableStyle()
void XclExpTableStyle::SaveXml( XclExpXmlStream& rStrm )
{
+ sax_fastparser::FSHelperPtr& rStyleSheet = rStrm.GetCurrentStream();
+ rStyleSheet->startElement( XML_tableStyle, XML_name, OUStringToOString(maTableStyleName, RTL_TEXTENCODING_UTF8 ).getStr(), XML_count, OString::number(miCount).getStr(), FSEND );
+ for ( StyleElementContainer::iterator itr = maStyleElementContainer.begin(); itr != maStyleElementContainer.end(); ++itr )
+ {
+ itr->SaveXml( rStrm );
+ }
+ rStyleSheet->endElement( XML_tableStyle );
}
// ===========================================================================
-XclExpTableStyles::XclExpTableStyles( const XclExpRoot& rRoot )
+XclExpTableStyles::XclExpTableStyles( const XclExpRoot& rRoot, XclExpDxfs& rDxfs )
:XclExpRoot( rRoot )
{
+ //Search through the collection of ScDBData (Database Ranges)
+ //checking for any table styles associated with them
+ miCount = 0;
+ ScDBCollection* pDBCollection = rRoot.GetDoc().GetDBCollection();
+ //Now iterate through this collection gathering style names
+ if( pDBCollection )
+ {
+ ScDBCollection::NamedDBs& aNamedDBs = pDBCollection->getNamedDBs();
+ ScDBCollection::NamedDBs::iterator itr = aNamedDBs.begin();
+ ScDBCollection::NamedDBs::iterator itrEnd = aNamedDBs.end();
+ for(; itr!= itrEnd; ++itr)
+ {
+ /*Probably have an issue here..looks like the imported DB is
+ taken into the DBCollection as a named DB, but the DB Range
+ we define by Data->define range is not classified as a named DB.
+ I haven't investigated why yet. For now allow me to consider only
+ the named DBs for table style information.
+ */
+ ScDBDataFormatting aDBFormatting;
+ (*itr).GetTableFormatting( aDBFormatting );
+ if( &(aDBFormatting) )//Probably non-standard?
+ {
+ miCount++;
+ maStyleContainer.push_back( new XclExpTableStyle( rRoot, aDBFormatting, rDxfs ) );
+ }
+ }
+ }
}
XclExpTableStyles::~XclExpTableStyles()
@@ -3176,6 +3248,13 @@ XclExpTableStyles::~XclExpTableStyles()
void XclExpTableStyles::SaveXml( XclExpXmlStream& rStrm )
{
+ sax_fastparser::FSHelperPtr& rStyleSheet = rStrm.GetCurrentStream();
+ rStyleSheet->startElement( XML_tableStyles, XML_count, OString::number(miCount).getStr(), FSEND );
+ for ( StyleContainer::iterator itr = maStyleContainer.begin(); itr != maStyleContainer.end(); ++itr )
+ {
+ itr->SaveXml( rStrm );
+ }
+ rStyleSheet->endElement( XML_tableStyles );
}
// ============================================================================
@@ -3204,6 +3283,7 @@ void XclExpXmlStyleSheet::SaveXml( XclExpXmlStream& rStrm )
CreateRecord( EXC_ID_XFLIST )->SaveXml( rStrm );
CreateRecord( EXC_ID_DXFS )->SaveXml( rStrm );
CreateRecord( EXC_ID_PALETTE )->SaveXml( rStrm );
+ CreateRecord( EXC_ID_TABLESTYLES )->SaveXml( rStrm );
aStyleSheet->endElement( XML_styleSheet );
diff --git a/sc/source/filter/inc/xestyle.hxx b/sc/source/filter/inc/xestyle.hxx
index 6f22449a8e0b..a4e6017dedd3 100644
--- a/sc/source/filter/inc/xestyle.hxx
+++ b/sc/source/filter/inc/xestyle.hxx
@@ -30,6 +30,7 @@
#include "xlstyle.hxx"
#include "xeroot.hxx"
#include "conditio.hxx"
+#include "dbdata.hxx"
#include <boost/shared_ptr.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
@@ -772,34 +773,37 @@ class XclExpTableStyleElement : public XclExpRecordBase, protected XclExpRoot
public:
XclExpTableStyleElement( const XclExpRoot& rRoot, OUString& rType, int iSize, int iDxfId );
virtual ~XclExpTableStyleElement();
- virtual void SaveXml( XclExpStream& rStrm );
+ virtual void SaveXml( XclExpXmlStream& rStrm );
private:
OUString maType;
- int maSize;
- int maDxfId;
+ int miSize;
+ int miDxfId;
};
class XclExpTableStyle : public XclExpRecordBase, protected XclExpRoot
{
public:
- XclExpTableStyle( const XclExpRoot& rRoot, OUString& rTableStyleName );
+ XclExpTableStyle( const XclExpRoot& rRoot, ScDBDataFormatting& rTableStyle, XclExpDxfs& rDxfs );
virtual ~XclExpTableStyle();
virtual void SaveXml( XclExpXmlStream& rStrm );
private:
typedef boost::ptr_vector< XclExpTableStyleElement > StyleElementContainer;
StyleElementContainer maStyleElementContainer;
+ ScDBDataFormatting maTableStyle;
OUString maTableStyleName;
+ int miCount;
};
class XclExpTableStyles : public XclExpRecordBase, protected XclExpRoot
{
public:
- XclExpTableStyles( const XclExpRoot& rRoot );
+ XclExpTableStyles( const XclExpRoot& rRoot, XclExpDxfs& rDxfs );
virtual ~XclExpTableStyles();
virtual void SaveXml( XclExpXmlStream& rStrm );
private:
typedef boost::ptr_vector< XclExpTableStyle > StyleContainer;
StyleContainer maStyleContainer;
+ int miCount;
};
// ============================================================================