[Libreoffice-commits] core.git: 5 commits - include/oox oox/CustomTarget_generated.mk oox/source sc/source
Markus Mohrhard
markus.mohrhard at collabora.co.uk
Sat Mar 1 07:23:58 PST 2014
include/oox/core/contexthandler.hxx | 1
include/oox/core/filterbase.hxx | 5 +
include/oox/core/relations.hxx | 11 +++
include/oox/core/xmlfilterbase.hxx | 2
include/oox/token/namespacemap.hxx | 11 +++
oox/CustomTarget_generated.mk | 2
oox/source/core/contexthandler.cxx | 5 +
oox/source/core/fastparser.cxx | 19 +++++-
oox/source/core/filterdetect.cxx | 3 -
oox/source/core/relations.cxx | 39 ++++++++++---
oox/source/core/xmlfilterbase.cxx | 36 +++++++++++-
oox/source/export/vmlexport.cxx | 1
oox/source/token/namespacemap.cxx | 12 +++-
oox/source/token/namespaces-strict.hxx.head | 27 +++++++++
oox/source/token/namespaces-strict.hxx.tail | 62 +++++++++++++++++++++
oox/source/token/namespaces-strict.pl | 70 +++++++++++++++++++++++
oox/source/token/namespaces-strict.txt | 82 ++++++++++++++++++++++++++++
sc/source/filter/oox/excelfilter.cxx | 2
sc/source/filter/oox/workbookfragment.cxx | 17 +++--
sc/source/filter/oox/worksheetfragment.cxx | 8 +-
20 files changed, 384 insertions(+), 31 deletions(-)
New commits:
commit 6471204afda1de1bad014635bfd0fccc18f15946
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat Mar 1 13:18:45 2014 +0100
remove empty lines after comment removal
Change-Id: Iad5cb7303f3797c06a53651b0f0c7e7c2273ef55
diff --git a/oox/source/core/relations.cxx b/oox/source/core/relations.cxx
index 3742531..d2e1b28 100644
--- a/oox/source/core/relations.cxx
+++ b/oox/source/core/relations.cxx
@@ -25,11 +25,6 @@
namespace oox {
namespace core {
-
-
-
-
-
namespace {
OUString lclRemoveFileName( const OUString& rPath )
@@ -57,9 +52,6 @@ OUString createOfficeDocRelationTypeStrict(const OUString& rType)
}
-
-
-
Relations::Relations( const OUString& rFragmentPath ) :
maFragmentPath( rFragmentPath )
{
commit e34870c2396db160c15e3e9bbf3efabf55ee2839
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat Mar 1 12:44:03 2014 +0100
support OOXML strict documents in Calc
Change-Id: I277d76aeec28e173d913ccc1506464afe4d09c6d
diff --git a/include/oox/core/contexthandler.hxx b/include/oox/core/contexthandler.hxx
index 272927a..2dda012 100644
--- a/include/oox/core/contexthandler.hxx
+++ b/include/oox/core/contexthandler.hxx
@@ -71,6 +71,7 @@ public:
OUString getFragmentPathFromRelId( const OUString& rRelId ) const;
/** Returns the full fragment path for the first relation of the passed type. */
OUString getFragmentPathFromFirstType( const OUString& rType ) const;
+ OUString getFragmentPathFromFirstTypeFromOfficeDoc( const OUString& rType ) const;
// com.sun.star.xml.sax.XFastContextHandler interface ---------------------
diff --git a/include/oox/core/filterbase.hxx b/include/oox/core/filterbase.hxx
index 96e488c..45c1ef5 100644
--- a/include/oox/core/filterbase.hxx
+++ b/include/oox/core/filterbase.hxx
@@ -20,7 +20,6 @@
#ifndef INCLUDED_OOX_CORE_FILTERBASE_HXX
#define INCLUDED_OOX_CORE_FILTERBASE_HXX
-#include <memory>
#include <com/sun/star/beans/NamedValue.hpp>
#include <com/sun/star/document/XExporter.hpp>
#include <com/sun/star/document/XFilter.hpp>
@@ -37,6 +36,8 @@
#include <oox/helper/storagebase.hxx>
#include <oox/dllapi.h>
+#include <boost/scoped_ptr.hpp>
+
namespace com { namespace sun { namespace star {
namespace awt { struct DeviceInfo; }
namespace frame { class XFrame; }
@@ -283,7 +284,7 @@ private:
const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& rxOutStream ) const = 0;
private:
- ::std::auto_ptr< FilterBaseImpl > mxImpl;
+ boost::scoped_ptr< FilterBaseImpl > mxImpl;
};
// ============================================================================
diff --git a/include/oox/core/relations.hxx b/include/oox/core/relations.hxx
index c94e293..05d00ad 100644
--- a/include/oox/core/relations.hxx
+++ b/include/oox/core/relations.hxx
@@ -30,11 +30,16 @@ namespace core {
// ============================================================================
-/** Expands to an OUString containing an 'officeDocument' relation type created
+/** Expands to an OUString containing an 'officeDocument' transitional relation type created
from the passed literal(!) ASCII(!) character array. */
#define CREATE_OFFICEDOC_RELATION_TYPE( ascii ) \
( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/" ascii )
+/** Expands to an OUString containing an 'officeDocument' strict relation type created
+ from the passed literal(!) ASCII(!) character array. */
+#define CREATE_OFFICEDOC_RELATION_TYPE_STRICT( ascii ) \
+ ( "http://purl.oclc.org/ooxml/officeDocument/relationships/" ascii )
+
/** Expands to an OUString containing a 'package' relation type created from
the passed literal(!) ASCII(!) character array. */
#define CREATE_PACKAGE_RELATION_TYPE( ascii ) \
@@ -74,8 +79,11 @@ public:
const Relation* getRelationFromRelId( const OUString& rId ) const;
/** Returns the first relation with the passed type. */
const Relation* getRelationFromFirstType( const OUString& rType ) const;
+ /** Returns the first relation with the passed type. */
+ const Relation* getRelationFromFirstTypeFromOfficeDoc( const OUString& rType ) const;
/** Finds all relations associated with the passed type. */
RelationsRef getRelationsFromType( const OUString& rType ) const;
+ RelationsRef getRelationsFromTypeFromOfficeDoc( const OUString& rType ) const;
/** Returns the external target of the relation with the passed relation identifier. */
OUString getExternalTargetFromRelId( const OUString& rRelId ) const;
@@ -88,6 +96,7 @@ public:
OUString getFragmentPathFromRelId( const OUString& rRelId ) const;
/** Returns the full fragment path for the first relation of the passed type. */
OUString getFragmentPathFromFirstType( const OUString& rType ) const;
+ OUString getFragmentPathFromFirstTypeFromOfficeDoc( const OUString& rType ) const;
private:
OUString maFragmentPath;
diff --git a/include/oox/core/xmlfilterbase.hxx b/include/oox/core/xmlfilterbase.hxx
index 604f220..351910d 100644
--- a/include/oox/core/xmlfilterbase.hxx
+++ b/include/oox/core/xmlfilterbase.hxx
@@ -101,6 +101,8 @@ public:
used for fragments referred by the root relations. */
OUString getFragmentPathFromFirstType( const OUString& rType );
+ OUString getFragmentPathFromFirstTypeFromOfficeDoc( const OUString& rPart );
+
/** Imports a fragment using the passed fragment handler, which contains
the full path to the fragment stream.
diff --git a/oox/source/core/contexthandler.cxx b/oox/source/core/contexthandler.cxx
index 296ed71..806d975 100644
--- a/oox/source/core/contexthandler.cxx
+++ b/oox/source/core/contexthandler.cxx
@@ -77,6 +77,11 @@ OUString ContextHandler::getFragmentPathFromFirstType( const OUString& rType ) c
return mxBaseData->mxRelations->getFragmentPathFromFirstType( rType );
}
+OUString ContextHandler::getFragmentPathFromFirstTypeFromOfficeDoc( const OUString& rType ) const
+{
+ return mxBaseData->mxRelations->getFragmentPathFromFirstTypeFromOfficeDoc( rType );
+}
+
void ContextHandler::implSetLocator( const Reference< XLocator >& rxLocator )
{
mxBaseData->mxLocator = rxLocator;
diff --git a/oox/source/core/relations.cxx b/oox/source/core/relations.cxx
index 5b726a5..3742531 100644
--- a/oox/source/core/relations.cxx
+++ b/oox/source/core/relations.cxx
@@ -43,7 +43,20 @@ OUString lclAppendFileName( const OUString& rPath, const OUString& rFileName )
OUStringBuffer( rPath ).append( '/' ).append( rFileName ).makeStringAndClear();
}
-} // namespace
+OUString createOfficeDocRelationTypeTransitional(const OUString& rType)
+{
+ static const OUString aTransitionalBase("http://schemas.openxmlformats.org/officeDocument/2006/relationships/");
+ return aTransitionalBase + rType;
+}
+
+OUString createOfficeDocRelationTypeStrict(const OUString& rType)
+{
+ static const OUString aStrictBase("http://purl.oclc.org/ooxml/officeDocument/relationships/");
+ return aStrictBase + rType;
+}
+
+}
+
@@ -75,6 +88,16 @@ RelationsRef Relations::getRelationsFromType( const OUString& rType ) const
return xRelations;
}
+RelationsRef Relations::getRelationsFromTypeFromOfficeDoc( const OUString& rType ) const
+{
+ RelationsRef xRelations( new Relations( maFragmentPath ) );
+ for( const_iterator aIt = begin(), aEnd = end(); aIt != aEnd; ++aIt )
+ if( aIt->second.maType.equalsIgnoreAsciiCase( createOfficeDocRelationTypeTransitional(rType) ) ||
+ aIt->second.maType.equalsIgnoreAsciiCase( createOfficeDocRelationTypeStrict(rType) ))
+ (*xRelations)[ aIt->first ] = aIt->second;
+ return xRelations;
+}
+
OUString Relations::getExternalTargetFromRelId( const OUString& rRelId ) const
{
const Relation* pRelation = getRelationFromRelId( rRelId );
@@ -132,7 +155,17 @@ OUString Relations::getFragmentPathFromFirstType( const OUString& rType ) const
return pRelation ? getFragmentPathFromRelation( *pRelation ) : OUString();
}
-
+OUString Relations::getFragmentPathFromFirstTypeFromOfficeDoc( const OUString& rType ) const
+{
+ OUString aTransitionalType(createOfficeDocRelationTypeTransitional(rType));
+ const Relation* pRelation = getRelationFromFirstType( aTransitionalType );
+ if(!pRelation)
+ {
+ OUString aStrictType = createOfficeDocRelationTypeStrict(rType);
+ pRelation = getRelationFromFirstType( aStrictType );
+ }
+ return pRelation ? getFragmentPathFromRelation( *pRelation ) : OUString();
+}
} // namespace core
} // namespace oox
diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx
index adbecaa..ecf902e 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -233,6 +233,36 @@ OUString XmlFilterBase::getFragmentPathFromFirstType( const OUString& rType )
return importRelations( OUString() )->getFragmentPathFromFirstType( rType );
}
+namespace {
+
+OUString getTransitionalRelationshipOfficeDocType(const OUString& rPart)
+{
+ static const OUString aBase("http://schemas.openxmlformats.org/officeDocument/2006/relationships/");
+ return aBase + rPart;
+}
+
+OUString getStrictRelationshipOfficeDocType(const OUString& rPart)
+{
+ static const OUString aBase("http://purl.oclc.org/ooxml/officeDocument/relationships/");
+ return aBase + rPart;
+}
+
+}
+
+OUString XmlFilterBase::getFragmentPathFromFirstTypeFromOfficeDoc( const OUString& rPart )
+{
+ // importRelations() caches the relations map for subsequence calls
+ const OUString aTransitionalRelationshipType = getTransitionalRelationshipOfficeDocType(rPart);
+ OUString aFragment = importRelations( OUString() )->getFragmentPathFromFirstType( aTransitionalRelationshipType );
+ if(aFragment.isEmpty())
+ {
+ const OUString aStrictRelationshipType = getStrictRelationshipOfficeDocType(rPart);
+ aFragment = importRelations( OUString() )->getFragmentPathFromFirstType( aStrictRelationshipType );
+ }
+
+ return aFragment;
+}
+
bool XmlFilterBase::importFragment( const rtl::Reference<FragmentHandler>& rxHandler )
{
return importFragment(rxHandler, mxImpl->maFastParser);
diff --git a/sc/source/filter/oox/excelfilter.cxx b/sc/source/filter/oox/excelfilter.cxx
index 0bc886c..063d5f1 100644
--- a/sc/source/filter/oox/excelfilter.cxx
+++ b/sc/source/filter/oox/excelfilter.cxx
@@ -101,7 +101,7 @@ bool ExcelFilter::importDocument() throw()
this variable (nonpro only). */
//OOX_DUMP_FILE( ::oox::dump::xlsb::Dumper );
- OUString aWorkbookPath = getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "officeDocument" ) );
+ OUString aWorkbookPath = getFragmentPathFromFirstTypeFromOfficeDoc( "officeDocument" );
if( aWorkbookPath.isEmpty() )
return false;
diff --git a/sc/source/filter/oox/workbookfragment.cxx b/sc/source/filter/oox/workbookfragment.cxx
index 625c5ff..5342fde 100644
--- a/sc/source/filter/oox/workbookfragment.cxx
+++ b/sc/source/filter/oox/workbookfragment.cxx
@@ -360,26 +360,26 @@ void WorkbookFragment::finalizeImport()
ISegmentProgressBarRef xGlobalSegment = getProgressBar().createSegment( PROGRESS_LENGTH_GLOBALS );
// read the theme substream
- OUString aThemeFragmentPath = getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "theme" ) );
+ OUString aThemeFragmentPath = getFragmentPathFromFirstTypeFromOfficeDoc( "theme" );
if( !aThemeFragmentPath.isEmpty() )
importOoxFragment( new ThemeFragmentHandler( getFilter(), aThemeFragmentPath, getTheme() ) );
xGlobalSegment->setPosition( 0.25 );
// read the styles substream (requires finalized theme buffer)
- OUString aStylesFragmentPath = getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "styles" ) );
+ OUString aStylesFragmentPath = getFragmentPathFromFirstTypeFromOfficeDoc( "styles" );
if( !aStylesFragmentPath.isEmpty() )
importOoxFragment( new StylesFragment( *this, aStylesFragmentPath ) );
xGlobalSegment->setPosition( 0.5 );
// read the shared string table substream (requires finalized styles buffer)
- OUString aSstFragmentPath = getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "sharedStrings" ) );
+ OUString aSstFragmentPath = getFragmentPathFromFirstTypeFromOfficeDoc( "sharedStrings" );
if( !aSstFragmentPath.isEmpty() )
if (!importOoxFragment( new SharedStringsFragment( *this, aSstFragmentPath ) ))
importOoxFragment(new SharedStringsFragment(*this, aSstFragmentPath.replaceFirst("sharedStrings","SharedStrings")));
xGlobalSegment->setPosition( 0.75 );
// read the connections substream
- OUString aConnFragmentPath = getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "connections" ) );
+ OUString aConnFragmentPath = getFragmentPathFromFirstTypeFromOfficeDoc( "connections" );
if( !aConnFragmentPath.isEmpty() )
importOoxFragment( new ConnectionsFragment( *this, aConnFragmentPath ) );
xGlobalSegment->setPosition( 1.0 );
@@ -412,14 +412,17 @@ void WorkbookFragment::finalizeImport()
// get the sheet type according to the relations type
WorksheetType eSheetType = SHEETTYPE_EMPTYSHEET;
- if( pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE( "worksheet" ) )
+ if( pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE( "worksheet" ) ||
+ pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE_STRICT( "worksheet" ))
eSheetType = SHEETTYPE_WORKSHEET;
- else if( pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE( "chartsheet" ) )
+ else if( pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE( "chartsheet" ) ||
+ pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE_STRICT( "chartsheet" ))
eSheetType = SHEETTYPE_CHARTSHEET;
else if( (pRelation->maType == CREATE_MSOFFICE_RELATION_TYPE( "xlMacrosheet" )) ||
(pRelation->maType == CREATE_MSOFFICE_RELATION_TYPE( "xlIntlMacrosheet" )) )
eSheetType = SHEETTYPE_MACROSHEET;
- else if( pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE( "dialogsheet" ) )
+ else if( pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE( "dialogsheet" ) ||
+ pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE_STRICT(" dialogsheet" ))
eSheetType = SHEETTYPE_DIALOGSHEET;
OSL_ENSURE( eSheetType != SHEETTYPE_EMPTYSHEET, "WorkbookFragment::finalizeImport - unknown sheet type" );
if( eSheetType != SHEETTYPE_EMPTYSHEET )
diff --git a/sc/source/filter/oox/worksheetfragment.cxx b/sc/source/filter/oox/worksheetfragment.cxx
index 81b6411b..9ad408a 100644
--- a/sc/source/filter/oox/worksheetfragment.cxx
+++ b/sc/source/filter/oox/worksheetfragment.cxx
@@ -203,12 +203,12 @@ WorksheetFragment::WorksheetFragment( const WorksheetHelper& rHelper, const OUSt
WorksheetFragmentBase( rHelper, rFragmentPath )
{
// import data tables related to this worksheet
- RelationsRef xTableRels = getRelations().getRelationsFromType( CREATE_OFFICEDOC_RELATION_TYPE( "table" ) );
+ RelationsRef xTableRels = getRelations().getRelationsFromTypeFromOfficeDoc( "table" );
for( Relations::const_iterator aIt = xTableRels->begin(), aEnd = xTableRels->end(); aIt != aEnd; ++aIt )
importOoxFragment( new TableFragment( *this, getFragmentPathFromRelation( aIt->second ) ) );
// import comments related to this worksheet
- OUString aCommentsFragmentPath = getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "comments" ) );
+ OUString aCommentsFragmentPath = getFragmentPathFromFirstTypeFromOfficeDoc( "comments" );
if( !aCommentsFragmentPath.isEmpty() )
importOoxFragment( new CommentsFragment( *this, aCommentsFragmentPath ) );
}
@@ -473,12 +473,12 @@ void WorksheetFragment::initializeImport()
initializeWorksheetImport();
// import query table fragments related to this worksheet
- RelationsRef xQueryRels = getRelations().getRelationsFromType( CREATE_OFFICEDOC_RELATION_TYPE( "queryTable" ) );
+ RelationsRef xQueryRels = getRelations().getRelationsFromTypeFromOfficeDoc( "queryTable" );
for( Relations::const_iterator aIt = xQueryRels->begin(), aEnd = xQueryRels->end(); aIt != aEnd; ++aIt )
importOoxFragment( new QueryTableFragment( *this, getFragmentPathFromRelation( aIt->second ) ) );
// import pivot table fragments related to this worksheet
- RelationsRef xPivotRels = getRelations().getRelationsFromType( CREATE_OFFICEDOC_RELATION_TYPE( "pivotTable" ) );
+ RelationsRef xPivotRels = getRelations().getRelationsFromTypeFromOfficeDoc( "pivotTable" );
for( Relations::const_iterator aIt = xPivotRels->begin(), aEnd = xPivotRels->end(); aIt != aEnd; ++aIt )
importOoxFragment( new PivotTableFragment( *this, getFragmentPathFromRelation( aIt->second ) ) );
}
commit 6ba394e6119fee2c5424b6c3b5eb3f4276cc2769
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Fri Feb 28 10:39:56 2014 +0100
handle OOXML strict namespaces
Change-Id: I198862388426161e3f054a5f128639c59f3c9d24
diff --git a/include/oox/token/namespacemap.hxx b/include/oox/token/namespacemap.hxx
index 2d2f2f3..cf1d0fd 100644
--- a/include/oox/token/namespacemap.hxx
+++ b/include/oox/token/namespacemap.hxx
@@ -29,7 +29,16 @@ namespace oox {
// ============================================================================
/** A map that contains all XML namespace URLs used in the filters. */
-struct NamespaceMap : public ::std::map< sal_Int32, OUString > { NamespaceMap(); };
+struct NamespaceMap
+{
+ std::map< sal_Int32, OUString > maTransitionalNamespaceMap;
+ std::map< sal_Int32, OUString > maStrictNamespaceMap;
+
+ NamespaceMap();
+
+ typedef std::map< sal_Int32, OUString >::iterator iterator;
+ typedef std::map< sal_Int32, OUString >::const_iterator const_iterator;
+};
/** Thread-save singleton of a map of all supported XML namespace URLs. */
struct StaticNamespaceMap : public ::rtl::Static< NamespaceMap, StaticNamespaceMap > {};
diff --git a/oox/CustomTarget_generated.mk b/oox/CustomTarget_generated.mk
index 92c8bf8..89ac97d 100644
--- a/oox/CustomTarget_generated.mk
+++ b/oox/CustomTarget_generated.mk
@@ -43,6 +43,7 @@ $(oox_GENHEADERPATH)/$(1).hxx : $(oox_SRC)/$(1).pl $(oox_SRC)/$(1).txt \
endef
$(eval $(call oox_GenTarget,namespaces,namespace,namespaces.txt))
+$(eval $(call oox_GenTarget,namespaces-strict,namespace-strict,namespaces-strict.txt))
$(eval $(call oox_GenTarget,properties,property,))
$(eval $(call oox_GenTarget,tokens,token,tokenhash.gperf))
@@ -54,6 +55,7 @@ $(call gb_CustomTarget_get_target,oox/generated) : \
$(oox_INC)/propertynames.inc \
$(oox_GENHEADERPATH)/tokens.hxx \
$(oox_GENHEADERPATH)/namespaces.hxx \
+ $(oox_GENHEADERPATH)/namespaces-strict.hxx \
$(oox_GENHEADERPATH)/properties.hxx \
$(oox_MISC)/namespaces.txt \
diff --git a/oox/source/core/fastparser.cxx b/oox/source/core/fastparser.cxx
index 6eeefb6..42306a9 100644
--- a/oox/source/core/fastparser.cxx
+++ b/oox/source/core/fastparser.cxx
@@ -94,11 +94,19 @@ void FastParser::registerNamespace( sal_Int32 nNamespaceId ) throw( IllegalArgum
if( !mxParser.is() )
throw RuntimeException();
- const OUString* pNamespaceUrl = ContainerHelper::getMapElement( mrNamespaceMap, nNamespaceId );
+ // add handling for OOXML strict here
+ const OUString* pNamespaceUrl = ContainerHelper::getMapElement( mrNamespaceMap.maTransitionalNamespaceMap, nNamespaceId );
if( !pNamespaceUrl )
throw IllegalArgumentException();
mxParser->registerNamespace( *pNamespaceUrl, nNamespaceId );
+
+ //also register the OOXML strict namespaces for the same id
+ const OUString* pNamespaceStrictUrl = ContainerHelper::getMapElement( mrNamespaceMap.maStrictNamespaceMap, nNamespaceId );
+ if(pNamespaceStrictUrl && (*pNamespaceUrl != *pNamespaceStrictUrl))
+ {
+ mxParser->registerNamespace( *pNamespaceStrictUrl, nNamespaceId );
+ }
}
void FastParser::setDocumentHandler( const Reference< XFastDocumentHandler >& rxDocHandler ) throw( RuntimeException )
@@ -150,9 +158,16 @@ bool FastParser::hasNamespaceURL( const OUString& rPrefix ) const
sal_Int32 FastParser::getNamespaceId( const OUString& rUrl )
{
- for( NamespaceMap::const_iterator aIt = mrNamespaceMap.begin(), aEnd = mrNamespaceMap.end(); aIt != aEnd; ++aIt )
+ for( NamespaceMap::const_iterator aIt = mrNamespaceMap.maTransitionalNamespaceMap.begin(),
+ aEnd = mrNamespaceMap.maTransitionalNamespaceMap.end(); aIt != aEnd; ++aIt )
if( rUrl == aIt->second )
return aIt->first;
+
+ for( NamespaceMap::const_iterator aIt = mrNamespaceMap.maStrictNamespaceMap.begin(),
+ aEnd = mrNamespaceMap.maStrictNamespaceMap.end(); aIt != aEnd; ++aIt )
+ if( rUrl == aIt->second )
+ return aIt->first;
+
return 0;
}
diff --git a/oox/source/core/filterdetect.cxx b/oox/source/core/filterdetect.cxx
index 3fd5578..6262071 100644
--- a/oox/source/core/filterdetect.cxx
+++ b/oox/source/core/filterdetect.cxx
@@ -155,7 +155,8 @@ void SAL_CALL FilterDetectDocHandler::processingInstruction(
void FilterDetectDocHandler::parseRelationship( const AttributeList& rAttribs )
{
OUString aType = rAttribs.getString( XML_Type, OUString() );
- if ( aType == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" )
+ if ( aType == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" // OOXML Transitional
+ || aType == "http://purl.oclc.org/ooxml/officeDocument/relationships/officeDocument" ) //OOXML strict
{
Reference<XUriReferenceFactory> xFactory = UriReferenceFactory::create( mxContext );
try
diff --git a/oox/source/token/namespacemap.cxx b/oox/source/token/namespacemap.cxx
index 4c4766b..65487da 100644
--- a/oox/source/token/namespacemap.cxx
+++ b/oox/source/token/namespacemap.cxx
@@ -32,8 +32,18 @@ NamespaceMap::NamespaceMap()
{ -1, "" }
};
+ static const struct NamespaceStrictUrl { sal_Int32 mnId; const sal_Char* mpcUrl; } spNamespaceStrictUrls[] =
+ {
+// include auto-generated C array with namespace URLs as C strings
+#include "namespace-strictnames.inc"
+ { -1, "" }
+ };
+
for( const NamespaceUrl* pNamespaceUrl = spNamespaceUrls; pNamespaceUrl->mnId != -1; ++pNamespaceUrl )
- operator[]( pNamespaceUrl->mnId ) = OUString::createFromAscii( pNamespaceUrl->mpcUrl );
+ maTransitionalNamespaceMap[ pNamespaceUrl->mnId ] = OUString::createFromAscii( pNamespaceUrl->mpcUrl );
+
+ for( const NamespaceStrictUrl* pNamespaceUrl = spNamespaceStrictUrls; pNamespaceUrl->mnId != -1; ++pNamespaceUrl )
+ maStrictNamespaceMap[ pNamespaceUrl->mnId ] = OUString::createFromAscii( pNamespaceUrl->mpcUrl );
}
}
diff --git a/oox/source/token/namespaces-strict.hxx.head b/oox/source/token/namespaces-strict.hxx.head
new file mode 100644
index 0000000..d00a380
--- /dev/null
+++ b/oox/source/token/namespaces-strict.hxx.head
@@ -0,0 +1,27 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef OOX_TOKEN_NAMESPACES_HXX
+#define OOX_TOKEN_NAMESPACES_HXX
+
+#include <sal/types.h>
+
+namespace oox {
+
+// ============================================================================
+
diff --git a/oox/source/token/namespaces-strict.hxx.tail b/oox/source/token/namespaces-strict.hxx.tail
new file mode 100644
index 0000000..e0baeae
--- /dev/null
+++ b/oox/source/token/namespaces-strict.hxx.tail
@@ -0,0 +1,62 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+// ============================================================================
+
+const sal_Int32 TOKEN_MASK = static_cast< sal_Int32 >( (1 << NMSP_SHIFT) - 1 );
+const sal_Int32 NMSP_MASK = static_cast< sal_Int32 >( SAL_MAX_INT32 & ~TOKEN_MASK );
+
+/** Returns the raw token identifier without namespace of the passed token. */
+inline sal_Int32 getBaseToken( sal_Int32 nToken ) { return nToken & TOKEN_MASK; }
+
+/** Returns the namespace without token identifier of the passed token. */
+inline sal_Int32 getNamespace( sal_Int32 nToken ) { return nToken & NMSP_MASK; }
+
+
+// defines for tokens with specific namespaces
+#define OOX_TOKEN( namespace, token ) (::oox::NMSP_##namespace | ::oox::XML_##token)
+
+#define A_TOKEN( token ) OOX_TOKEN( dml, token )
+#define AX_TOKEN( token ) OOX_TOKEN( ax, token )
+#define C_TOKEN( token ) OOX_TOKEN( dmlChart, token )
+#define CDR_TOKEN( token ) OOX_TOKEN( dmlChartDr, token )
+#define DGM_TOKEN( token ) OOX_TOKEN( dmlDiagram, token )
+#define MCE_TOKEN( token ) OOX_TOKEN( mce, token)
+#define O_TOKEN( token ) OOX_TOKEN( vmlOffice, token )
+#define PC_TOKEN( token ) OOX_TOKEN( packageContentTypes, token )
+#define PPT_TOKEN( token ) OOX_TOKEN( ppt, token )
+#define PR_TOKEN( token ) OOX_TOKEN( packageRel, token )
+#define R_TOKEN( token ) OOX_TOKEN( officeRel, token )
+#define VML_TOKEN( token ) OOX_TOKEN( vml, token )
+#define VMLX_TOKEN( token ) OOX_TOKEN( vmlExcel, token )
+#define XDR_TOKEN( token ) OOX_TOKEN( dmlSpreadDr, token )
+#define XLS_TOKEN( token ) OOX_TOKEN( xls, token )
+#define XLS_EXT_TOKEN( token ) OOX_TOKEN( xlsExtLst, token )
+#define XM_TOKEN( token ) OOX_TOKEN( xm, token )
+#define XML_TOKEN( token ) OOX_TOKEN( xml, token )
+#define VMLPPT_TOKEN( token ) OOX_TOKEN( vmlPowerpoint, token )
+#define DSP_TOKEN( token ) OOX_TOKEN( dsp, token )
+#define LC_TOKEN( token ) OOX_TOKEN( dmlLockedCanvas, token )
+#define WPS_TOKEN( token ) OOX_TOKEN( wps, token )
+#define WPG_TOKEN( token ) OOX_TOKEN( wpg, token )
+
+// ============================================================================
+
+} // namespace oox
+
+#endif
diff --git a/oox/source/token/namespaces-strict.pl b/oox/source/token/namespaces-strict.pl
new file mode 100644
index 0000000..225b8f7
--- /dev/null
+++ b/oox/source/token/namespaces-strict.pl
@@ -0,0 +1,70 @@
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This file incorporates work covered by the following license notice:
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed
+# with this work for additional information regarding copyright
+# ownership. The ASF licenses this file to you under the Apache
+# License, Version 2.0 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.apache.org/licenses/LICENSE-2.0 .
+#
+
+$ARGV0 = shift @ARGV;
+$ARGV1 = shift @ARGV;
+$ARGV2 = shift @ARGV;
+$ARGV3 = shift @ARGV;
+
+# parse input file
+
+open( INFILE, $ARGV0 ) or die "cannot open input file: $!";
+my %namespaces;
+while( <INFILE> )
+{
+ # trim newline
+ chomp( $_ );
+ # trim leading/trailing whitespace
+ $_ =~ s/^\s*//g;
+ $_ =~ s/\s*$//g;
+ # trim comments
+ $_ =~ s/^#.*//;
+ # skip empty lines
+ if( $_ )
+ {
+ # check for valid characters
+ $_ =~ /^([a-zA-Z][a-zA-Z0-9]*)\s+([a-zA-Z0-9-.:\/]+)\s*$/ or die "Error: invalid character in input data";
+ $namespaces{$1} = $2;
+ }
+}
+close( INFILE );
+
+# generate output files
+
+open( IDFILE, ">$ARGV1" ) or die "Error: cannot open output file: $!";
+open( NAMEFILE, ">$ARGV2" ) or die "Error: cannot open output file: $!";
+open( TXTFILE, ">$ARGV3" ) or die "Error: cannot open output file: $!";
+
+# number of bits to shift the namespace identifier
+$shift = 16;
+
+print ( IDFILE "const size_t NMSP_SHIFT = $shift;\n" );
+
+$i = 1;
+foreach( keys( %namespaces ) )
+{
+ print( IDFILE "const sal_Int32 NMSP_$_ = $i << NMSP_SHIFT;\n" );
+ $id = $i << $shift;
+ print( NAMEFILE "{ $id, \"$namespaces{$_}\" },\n" );
+ print( TXTFILE "$id $_ $namespaces{$_}\n" );
+ ++$i;
+}
+
+close( IDFILE );
+close( nameFILE );
+close( TXTFILE );
diff --git a/oox/source/token/namespaces-strict.txt b/oox/source/token/namespaces-strict.txt
new file mode 100644
index 0000000..9549483
--- /dev/null
+++ b/oox/source/token/namespaces-strict.txt
@@ -0,0 +1,82 @@
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This file incorporates work covered by the following license notice:
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed
+# with this work for additional information regarding copyright
+# ownership. The ASF licenses this file to you under the Apache
+# License, Version 2.0 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.apache.org/licenses/LICENSE-2.0 .
+#
+
+# generic XML -----------------------------------------------------------------
+
+xml http://www.w3.org/XML/1998/namespace
+schema http://purl.oclc.org/ooxml/schemaLibrary/main
+
+# package ---------------------------------------------------------------------
+
+packageContentTypes http://schemas.openxmlformats.org/package/2006/content-types
+packageMetaCorePr http://schemas.openxmlformats.org/package/2006/metadata/core-properties
+packageRel http://schemas.openxmlformats.org/package/2006/relationships
+
+# office shared ---------------------------------------------------------------
+
+officeCustomPr http://purl.oclc.org/ooxml/officeDocument/custom-properties
+officeDocPropsVT http://purl.oclc.org/ooxml/officeDocument/docPropsVTypes
+officeExtPr http://purl.oclc.org/ooxml/officeDocument/extended-properties
+officeMath http://purl.oclc.org/ooxml/officeDocument/math
+officeRel http://purl.oclc.org/ooxml/officeDocument/relationships
+officeRelTheme http://purl.oclc.org/ooxml/officeDocument/relationships/theme
+
+# applications ----------------------------------------------------------------
+
+doc http://purl.oclc.org/ooxml/wordprocessingml/main
+xls http://purl.oclc.org/ooxml/spreadsheetml/main
+ppt http://purl.oclc.org/ooxml/presentationml/main
+
+# drawing ---------------------------------------------------------------------
+
+dml http://purl.oclc.org/ooxml/drawingml/main
+dsp http://schemas.microsoft.com/office/drawing/2008/diagram
+dmlChart http://purl.oclc.org/ooxml/drawingml/chart
+dmlChartDr http://purl.oclc.org/ooxml/drawingml/chartDrawing
+dmlDiagram http://purl.oclc.org/ooxml/drawingml/diagram
+dmlLockedCanvas http://purl.oclc.org/ooxml/drawingml/lockedCanvas
+dmlPicture http://purl.oclc.org/ooxml/drawingml/picture
+dmlSpreadDr http://purl.oclc.org/ooxml/drawingml/spreadsheetDrawing
+dmlWordDr http://purl.oclc.org/ooxml/drawingml/wordprocessingDrawing
+
+# VML -------------------------------------------------------------------------
+
+vml urn:schemas-microsoft-com:vml
+vmlExcel urn:schemas-microsoft-com:office:excel
+vmlOffice urn:schemas-microsoft-com:office:office
+vmlPowerpoint urn:schemas-microsoft-com:office:powerpoint
+vmlWord urn:schemas-microsoft-com:office:word
+
+# other -----------------------------------------------------------------------
+
+ax http://schemas.microsoft.com/office/2006/activeX
+dc http://purl.org/dc/elements/1.1/
+dcTerms http://purl.org/dc/terms/
+xm http://schemas.microsoft.com/office/excel/2006/main
+sprm http://sprm
+mce http://schemas.openxmlformats.org/markup-compatibility/2006
+mceTest http://schemas.openxmlformats.org/spreadsheetml/2006/main/v2
+wps http://schemas.microsoft.com/office/word/2010/wordprocessingShape
+wpg http://schemas.microsoft.com/office/word/2010/wordprocessingGroup
+wp14 http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing
+w14 http://schemas.microsoft.com/office/word/2010/wordml
+
+# extlst namespaces
+
+# xlsExtLst for features introduced by excel 2010
+xlsExtLst http://schemas.microsoft.com/office/spreadsheetml/2009/9/main
commit a143beb3a02dc23f5a256e64fb996a1329ce07c0
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Fri Feb 28 06:46:33 2014 +0100
make sure the two namespace lists are sorted the same way
Change-Id: I90b3182e10dbbfc8993010dd885509537d2fe537
diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx
index c9837f6..adbecaa 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -118,16 +118,16 @@ struct NamespaceIds: public rtl::StaticWithInit<
NMSP_dmlDiagram,
NMSP_dmlChart,
NMSP_dmlChartDr,
- NMSP_dmlSpreadDr,
NMSP_vml,
NMSP_vmlOffice,
NMSP_vmlWord,
NMSP_vmlExcel,
NMSP_vmlPowerpoint,
- NMSP_xls,
- NMSP_ppt,
NMSP_ax,
+ NMSP_xls,
NMSP_xm,
+ NMSP_dmlSpreadDr,
+ NMSP_ppt,
NMSP_mce,
NMSP_mceTest,
NMSP_dsp,
commit 63308b1e6c5fe3450783e589df8bd588fb4ceb3e
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Wed Feb 26 13:05:48 2014 +0100
fix OOXML validation issue, related fdo#33951
Change-Id: I6e455ee4bb649a299023f1dba88a01ef5674e074
diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx
index aa4c92a..f348439 100644
--- a/oox/source/export/vmlexport.cxx
+++ b/oox/source/export/vmlexport.cxx
@@ -175,7 +175,6 @@ void VMLExport::AddShape( sal_uInt32 nShapeType, sal_uInt32 nShapeFlags, sal_uIn
{
m_nShapeType = nShapeType;
m_nShapeFlags = nShapeFlags;
- m_pShapeAttrList->add( XML_name, ShapeIdString( nShapeId ) );
m_pShapeAttrList->add( XML_id, ShapeIdString( nShapeId ) );
}
More information about the Libreoffice-commits
mailing list