Kaydet (Commit) fa18c83e authored tarafından Eike Rathke's avatar Eike Rathke

TableRef: write <tableParts> before <extLst>, resolves tdf#96049

Excel expects this order, so let XclExpTables be managed as
XclExpRecordBase in the sheet's XclExpRecordList.

Change-Id: If2cefc255c74688661e861a26218564117b1e3ce
(cherry picked from commit 4112ecad)
üst b141d206
...@@ -678,6 +678,9 @@ void ExcTable::FillAsTableXml() ...@@ -678,6 +678,9 @@ void ExcTable::FillAsTableXml()
if (pImgData) if (pImgData)
aRecList.AppendRecord(std::shared_ptr<XclExpRecordBase>(pImgData)); aRecList.AppendRecord(std::shared_ptr<XclExpRecordBase>(pImgData));
// <tableParts> after <drawing> and before <extLst>
aRecList.AppendRecord( GetTablesManager().GetTablesBySheet( mnScTab));
aRecList.AppendRecord( xExtLst ); aRecList.AppendRecord( xExtLst );
} }
...@@ -744,10 +747,6 @@ void ExcTable::WriteXml( XclExpXmlStream& rStrm ) ...@@ -744,10 +747,6 @@ void ExcTable::WriteXml( XclExpXmlStream& rStrm )
if (pPT) if (pPT)
pPT->SaveXml(rStrm); pPT->SaveXml(rStrm);
XclExpTables* pTables = GetTablesManager().GetTablesBySheet(mnScTab);
if (pTables)
pTables->SaveXml(rStrm);
rStrm.GetCurrentStream()->endElement( XML_worksheet ); rStrm.GetCurrentStream()->endElement( XML_worksheet );
rStrm.PopStream(); rStrm.PopStream();
} }
......
...@@ -133,27 +133,32 @@ void XclExpTablesManager::Initialize() ...@@ -133,27 +133,32 @@ void XclExpTablesManager::Initialize()
TablesMapType::iterator it = maTablesMap.find( nTab); TablesMapType::iterator it = maTablesMap.find( nTab);
if (it == maTablesMap.end()) if (it == maTablesMap.end())
{ {
XclExpTables* pNew; ::std::shared_ptr< XclExpTables > pNew;
switch( GetBiff() ) switch( GetBiff() )
{ {
case EXC_BIFF5: case EXC_BIFF5:
pNew = new XclExpTablesImpl5( GetRoot()); pNew.reset( new XclExpTablesImpl5( GetRoot()));
break; break;
case EXC_BIFF8: case EXC_BIFF8:
pNew = new XclExpTablesImpl8( GetRoot()); pNew.reset( new XclExpTablesImpl8( GetRoot()));
break; break;
default: default:
assert(!"Unknown BIFF type!"); assert(!"Unknown BIFF type!");
continue; // for continue; // for
} }
it = maTablesMap.insert( nTab, pNew).first; ::std::pair< TablesMapType::iterator, bool > ins( maTablesMap.insert( ::std::make_pair( nTab, pNew)));
if (!ins.second)
{
assert(!"XclExpTablesManager::Initialize - XclExpTables insert failed");
continue; // for
}
it = ins.first;
} }
XclExpTables* p = it->second; it->second->AppendTable( pDBData, ++nTableId);
p->AppendTable( pDBData, ++nTableId);
} }
} }
XclExpTables* XclExpTablesManager::GetTablesBySheet( SCTAB nTab ) ::std::shared_ptr< XclExpTables > XclExpTablesManager::GetTablesBySheet( SCTAB nTab )
{ {
TablesMapType::iterator it = maTablesMap.find(nTab); TablesMapType::iterator it = maTablesMap.find(nTab);
return it == maTablesMap.end() ? nullptr : it->second; return it == maTablesMap.end() ? nullptr : it->second;
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include "xeroot.hxx" #include "xeroot.hxx"
#include "xerecord.hxx" #include "xerecord.hxx"
#include <boost/ptr_container/ptr_map.hpp>
class ScDBData; class ScDBData;
class XclExpTablesManagerImpl; class XclExpTablesManagerImpl;
...@@ -44,7 +43,7 @@ protected: ...@@ -44,7 +43,7 @@ protected:
Entry( const ScDBData* pData, sal_Int32 nTableId ); Entry( const ScDBData* pData, sal_Int32 nTableId );
}; };
typedef std::vector<Entry> TablesType; typedef ::std::vector<Entry> TablesType;
TablesType maTables; TablesType maTables;
static void SaveTableXml( XclExpXmlStream& rStrm, const Entry& rEntry ); static void SaveTableXml( XclExpXmlStream& rStrm, const Entry& rEntry );
...@@ -59,10 +58,10 @@ public: ...@@ -59,10 +58,10 @@ public:
virtual ~XclExpTablesManager(); virtual ~XclExpTablesManager();
void Initialize(); void Initialize();
XclExpTables* GetTablesBySheet( SCTAB nTab ); ::std::shared_ptr< XclExpTables > GetTablesBySheet( SCTAB nTab );
private: private:
typedef boost::ptr_map< SCTAB, XclExpTables > TablesMapType; typedef ::std::map< SCTAB, ::std::shared_ptr< XclExpTables > > TablesMapType;
TablesMapType maTablesMap; TablesMapType maTablesMap;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment