summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@collabora.co.uk>2014-02-28 10:39:56 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-03-11 05:40:05 -0500
commit585bd120327508ad68816c8005cb36e1d3116351 (patch)
tree10438e144c77af86939d68deb0c7140c71e4ec77 /oox
parent0ceeab004f3e448322bf5a0119f779443bb42b91 (diff)
handle OOXML strict namespaces
Change-Id: I198862388426161e3f054a5f128639c59f3c9d24 support OOXML strict documents in Calc Conflicts: oox/source/core/relations.cxx Change-Id: I277d76aeec28e173d913ccc1506464afe4d09c6d import date cells from OOXML Change-Id: Id0b9ec034d559d489ca4ee2d1d6aca1bdf1beb9d no need to add another layer of macros Change-Id: I49992559a7d10127d55dbf0c7e257c86619fd8d6 fix one more relation type for OOXML strict Change-Id: Ia63309271ac225883540ca0453fc5da21844d3ad make more places aware of OOXML strict relations Change-Id: I292217537eb592cbad9af11f87402baa9f4cc442 fix strict namespace list generation The two perl scripts were apparently only generating the same order by luck. It did not work on all systems. Change-Id: Ib83ee5c6572d3bae2e2ac1846850bd65303e7d43 allow OOXML strict relationships in writer Conflicts: writerfilter/source/ooxml/OOXMLDocumentImpl.cxx writerfilter/source/ooxml/OOXMLStreamImpl.cxx Change-Id: I1c09280f68467748faedee19c4a66be3bc7d7aa3 make sure the two namespace lists are sorted the same way Change-Id: I90b3182e10dbbfc8993010dd885509537d2fe537 fix OOXML strict chart import Change-Id: I84a2fd575ced64d4774147063f13ebb8605c100f add the xml strict namespaces to misc/namespaces.txt Change-Id: Ie83b5c94f1f002851bff3b39b1d9b676a3e44aa1 Reviewed-on: https://gerrit.libreoffice.org/8515 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'oox')
-rw-r--r--oox/CustomTarget_generated.mk5
-rw-r--r--oox/source/core/contexthandler.cxx5
-rw-r--r--oox/source/core/fastparser.cxx19
-rw-r--r--oox/source/core/filterdetect.cxx3
-rw-r--r--oox/source/core/relations.cxx37
-rw-r--r--oox/source/core/xmlfilterbase.cxx36
-rw-r--r--oox/source/docprop/ooxmldocpropimport.cxx9
-rw-r--r--oox/source/drawingml/graphicshapecontext.cxx14
-rw-r--r--oox/source/ppt/dgmimport.cxx2
-rw-r--r--oox/source/ppt/pptimport.cxx4
-rw-r--r--oox/source/ppt/presentationfragmenthandler.cxx10
-rw-r--r--oox/source/ppt/slidefragmenthandler.cxx4
-rw-r--r--oox/source/shape/ShapeContextHandler.cxx2
-rw-r--r--oox/source/token/namespacemap.cxx12
-rw-r--r--oox/source/token/namespaces-strict.txt82
-rw-r--r--oox/source/token/namespaces.pl31
16 files changed, 247 insertions, 28 deletions
diff --git a/oox/CustomTarget_generated.mk b/oox/CustomTarget_generated.mk
index 92c8bf8196d8..14789d63b53d 100644
--- a/oox/CustomTarget_generated.mk
+++ b/oox/CustomTarget_generated.mk
@@ -27,7 +27,7 @@ $(oox_INC)/tokenhash.inc : $(oox_MISC)/tokenhash.gperf
$(GPERF) --compare-strncmp $< | sed -e 's/(char\*)0/(char\*)0, 0/g' | grep -v '^#line' > $@
define oox_GenTarget
-$(oox_MISC)/$(2)ids.inc $(oox_INC)/$(2)names.inc $(if $(3),$(oox_MISC)/$(3)) : \
+$(oox_MISC)/$(2)ids.inc $(oox_INC)/$(2)names.inc $(if $(3),$(oox_MISC)/$(3)) $(if $(4),$(oox_INC)/$(4)names.inc) : \
$(oox_GENHEADERPATH)/$(1).hxx
@touch $$@
@@ -37,12 +37,13 @@ $(oox_GENHEADERPATH)/$(1).hxx : $(oox_SRC)/$(1).pl $(oox_SRC)/$(1).txt \
mkdir -p $(oox_MISC) $(oox_INC) $(oox_GENHEADERPATH)
perl $(oox_SRC)/$(1).pl $(oox_SRC)/$(1).txt $(oox_MISC)/$(2)ids.inc \
$(oox_INC)/$(2)names.inc $(if $(3),$(oox_MISC)/$(3)) \
+ $(if $(4),$(oox_SRC)/$(4).txt $(oox_INC)/$(4)names.inc) \
&& cat $(oox_SRC)/$(1).hxx.head $(oox_MISC)/$(2)ids.inc \
$(oox_SRC)/$(1).hxx.tail > $(oox_GENHEADERPATH)/$(1).hxx \
&& touch $$@
endef
-$(eval $(call oox_GenTarget,namespaces,namespace,namespaces.txt))
+$(eval $(call oox_GenTarget,namespaces,namespace,namespaces.txt,namespaces-strict))
$(eval $(call oox_GenTarget,properties,property,))
$(eval $(call oox_GenTarget,tokens,token,tokenhash.gperf))
diff --git a/oox/source/core/contexthandler.cxx b/oox/source/core/contexthandler.cxx
index 2d41797631f6..ed80a55d4064 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/fastparser.cxx b/oox/source/core/fastparser.cxx
index 70e12a896098..2a62a8c7a594 100644
--- a/oox/source/core/fastparser.cxx
+++ b/oox/source/core/fastparser.cxx
@@ -92,11 +92,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 )
@@ -148,9 +156,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 0c68966fe815..03eb80d5051a 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/core/relations.cxx b/oox/source/core/relations.cxx
index b00fcea313e2..78bb779eb093 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 c0a016da142b..cf996ebf6110 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -120,16 +120,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,
@@ -236,6 +236,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/oox/source/docprop/ooxmldocpropimport.cxx b/oox/source/docprop/ooxmldocpropimport.cxx
index 2361bd1ccd74..b3b1ae6fcd17 100644
--- a/oox/source/docprop/ooxmldocpropimport.cxx
+++ b/oox/source/docprop/ooxmldocpropimport.cxx
@@ -131,12 +131,21 @@ void SAL_CALL DocumentPropertiesImport::importProperties(
throw IllegalArgumentException();
Sequence< InputSource > aCoreStreams = lclGetRelatedStreams( rxSource, CREATE_OFFICEDOC_RELATION_TYPE( "metadata/core-properties" ) );
+ // OOXML strict
+ if( !aCoreStreams.hasElements() )
+ aCoreStreams = lclGetRelatedStreams( rxSource, CREATE_OFFICEDOC_RELATION_TYPE_STRICT( "metadata/core-properties" ) );
// MS Office seems to have a bug, so we have to do similar handling
if( !aCoreStreams.hasElements() )
aCoreStreams = lclGetRelatedStreams( rxSource, CREATE_PACKAGE_RELATION_TYPE( "metadata/core-properties" ) );
Sequence< InputSource > aExtStreams = lclGetRelatedStreams( rxSource, CREATE_OFFICEDOC_RELATION_TYPE( "extended-properties" ) );
+ // OOXML strict
+ if( !aExtStreams.hasElements() )
+ aExtStreams = lclGetRelatedStreams( rxSource, CREATE_OFFICEDOC_RELATION_TYPE_STRICT( "extended-properties" ) );
Sequence< InputSource > aCustomStreams = lclGetRelatedStreams( rxSource, CREATE_OFFICEDOC_RELATION_TYPE( "custom-properties" ) );
+ // OOXML strict
+ if( !aCustomStreams.hasElements() )
+ aCustomStreams = lclGetRelatedStreams( rxSource, CREATE_OFFICEDOC_RELATION_TYPE_STRICT( "custom-properties" ) );
if( aCoreStreams.hasElements() || aExtStreams.hasElements() || aCustomStreams.hasElements() )
{
diff --git a/oox/source/drawingml/graphicshapecontext.cxx b/oox/source/drawingml/graphicshapecontext.cxx
index 4cf3366e1808..e0818ac1c010 100644
--- a/oox/source/drawingml/graphicshapecontext.cxx
+++ b/oox/source/drawingml/graphicshapecontext.cxx
@@ -122,17 +122,21 @@ ContextHandlerRef GraphicalObjectFrameContext::onCreateContext( sal_Int32 aEleme
case XML_graphicData : // CT_GraphicalObjectData
{
OUString sUri( rAttribs.getString( XML_uri ).get() );
- if ( sUri == "http://schemas.openxmlformats.org/presentationml/2006/ole" )
+ if ( sUri == "http://schemas.openxmlformats.org/presentationml/2006/ole" ||
+ sUri == "http://purl.oclc.org/ooxml/presentationml/ole" )
return new OleObjectGraphicDataContext( *this, mpShapePtr );
- else if ( sUri == "http://schemas.openxmlformats.org/drawingml/2006/diagram" )
+ else if ( sUri == "http://schemas.openxmlformats.org/drawingml/2006/diagram" ||
+ sUri == "http://purl.oclc.org/ooxml/drawingml/diagram" )
return new DiagramGraphicDataContext( *this, mpShapePtr );
- else if ( sUri == "http://schemas.openxmlformats.org/drawingml/2006/chart" )
+ else if ( sUri == "http://schemas.openxmlformats.org/drawingml/2006/chart" ||
+ sUri == "http://purl.oclc.org/ooxml/drawingml/chart" )
return new ChartGraphicDataContext( *this, mpShapePtr, mbEmbedShapesInChart );
- else if ( sUri.equalsAscii( "http://schemas.openxmlformats.org/drawingml/2006/table" ) )
+ else if ( sUri == "http://schemas.openxmlformats.org/drawingml/2006/table" ||
+ sUri == "http://purl.oclc.org/ooxml/drawingml/table" )
return new table::TableContext( *this, mpShapePtr );
else
{
- OSL_TRACE( "OOX: Ignore graphicsData of %s", OUSTRING_TO_CSTR( sUri ) );
+ SAL_WARN("oox", "OOX: Ignore graphicsData of :" << sUri );
return 0;
}
}
diff --git a/oox/source/ppt/dgmimport.cxx b/oox/source/ppt/dgmimport.cxx
index 10d16141cc70..602fb72fca32 100644
--- a/oox/source/ppt/dgmimport.cxx
+++ b/oox/source/ppt/dgmimport.cxx
@@ -60,7 +60,7 @@ bool QuickDiagrammingImport::importDocument() throw()
OOX_DUMP_FILE( ::oox::dump::pptx::Dumper );
OUString aEmpty;
- OUString aFragmentPath = getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "diagramLayout" ) );
+ OUString aFragmentPath = getFragmentPathFromFirstTypeFromOfficeDoc( "diagramLayout" );
Reference<drawing::XShapes> xParentShape(getParentShape(),
UNO_QUERY_THROW);
diff --git a/oox/source/ppt/pptimport.cxx b/oox/source/ppt/pptimport.cxx
index 285ac2a064bc..fc9dadf863c0 100644
--- a/oox/source/ppt/pptimport.cxx
+++ b/oox/source/ppt/pptimport.cxx
@@ -77,9 +77,9 @@ bool PowerPointImport::importDocument() throw()
file:///<path-to-oox-module>/source/dump/pptxdumper.ini. */
OOX_DUMP_FILE( ::oox::dump::pptx::Dumper );
- OUString aFragmentPath = getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "officeDocument" ) );
+ OUString aFragmentPath = getFragmentPathFromFirstTypeFromOfficeDoc( "officeDocument" );
FragmentHandlerRef xPresentationFragmentHandler( new PresentationFragmentHandler( *this, aFragmentPath ) );
- maTableStyleListPath = xPresentationFragmentHandler->getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "tableStyles" ) );
+ maTableStyleListPath = xPresentationFragmentHandler->getFragmentPathFromFirstTypeFromOfficeDoc( "tableStyles" );
return importFragment( xPresentationFragmentHandler );
diff --git a/oox/source/ppt/presentationfragmenthandler.cxx b/oox/source/ppt/presentationfragmenthandler.cxx
index 826130cf65a9..4e400f18ee31 100644
--- a/oox/source/ppt/presentationfragmenthandler.cxx
+++ b/oox/source/ppt/presentationfragmenthandler.cxx
@@ -163,13 +163,13 @@ void PresentationFragmentHandler::importSlide(sal_uInt32 nSlide, sal_Bool bFirst
FragmentHandlerRef xSlideFragmentHandler( new SlideFragmentHandler( rFilter, aSlideFragmentPath, pSlidePersistPtr, Slide ) );
// importing the corresponding masterpage/layout
- OUString aLayoutFragmentPath = xSlideFragmentHandler->getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "slideLayout" ) );
- OUString aCommentFragmentPath = xSlideFragmentHandler->getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "comments" ) );
+ OUString aLayoutFragmentPath = xSlideFragmentHandler->getFragmentPathFromFirstTypeFromOfficeDoc( "slideLayout" );
+ OUString aCommentFragmentPath = xSlideFragmentHandler->getFragmentPathFromFirstTypeFromOfficeDoc( "comments" );
if ( !aLayoutFragmentPath.isEmpty() )
{
// importing layout
RelationsRef xLayoutRelations = rFilter.importRelations( aLayoutFragmentPath );
- OUString aMasterFragmentPath = xLayoutRelations->getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "slideMaster" ) );
+ OUString aMasterFragmentPath = xLayoutRelations->getFragmentPathFromFirstTypeFromOfficeDoc( "slideMaster" );
if( !aMasterFragmentPath.isEmpty() )
{
// check if the corresponding masterpage+layout has already been imported
@@ -204,7 +204,7 @@ void PresentationFragmentHandler::importSlide(sal_uInt32 nSlide, sal_Bool bFirst
FragmentHandlerRef xMasterFragmentHandler( new SlideFragmentHandler( rFilter, aMasterFragmentPath, pMasterPersistPtr, Master ) );
// set the correct theme
- OUString aThemeFragmentPath = xMasterFragmentHandler->getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "theme" ) );
+ OUString aThemeFragmentPath = xMasterFragmentHandler->getFragmentPathFromFirstTypeFromOfficeDoc( "theme" );
if( !aThemeFragmentPath.isEmpty() )
{
std::map< OUString, oox::drawingml::ThemePtr >& rThemes( rFilter.getThemes() );
@@ -255,7 +255,7 @@ void PresentationFragmentHandler::importSlide(sal_uInt32 nSlide, sal_Bool bFirst
if(bImportNotesPage) {
// now importing the notes page
- OUString aNotesFragmentPath = xSlideFragmentHandler->getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "notesSlide" ) );
+ OUString aNotesFragmentPath = xSlideFragmentHandler->getFragmentPathFromFirstTypeFromOfficeDoc( "notesSlide" );
if( !aNotesFragmentPath.isEmpty() )
{
Reference< XPresentationPage > xPresentationPage( xSlide, UNO_QUERY );
diff --git a/oox/source/ppt/slidefragmenthandler.cxx b/oox/source/ppt/slidefragmenthandler.cxx
index 7ae3b0fec627..07076a02e971 100644
--- a/oox/source/ppt/slidefragmenthandler.cxx
+++ b/oox/source/ppt/slidefragmenthandler.cxx
@@ -54,7 +54,7 @@ SlideFragmentHandler::SlideFragmentHandler( XmlFilterBase& rFilter, const OUStri
, mpSlidePersistPtr( pPersistPtr )
, meShapeLocation( eShapeLocation )
{
- OUString aVMLDrawingFragmentPath = getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "vmlDrawing" ) );
+ OUString aVMLDrawingFragmentPath = getFragmentPathFromFirstTypeFromOfficeDoc( "vmlDrawing" );
if( !aVMLDrawingFragmentPath.isEmpty() )
getFilter().importFragment( new oox::vml::DrawingFragment(
getFilter(), aVMLDrawingFragmentPath, *pPersistPtr->getDrawing() ) );
@@ -87,7 +87,7 @@ SlideFragmentHandler::~SlideFragmentHandler() throw()
{
// Import notesMaster
PowerPointImport& rFilter = dynamic_cast< PowerPointImport& >( getFilter() );
- OUString aNotesFragmentPath = getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "notesMaster" ) );
+ OUString aNotesFragmentPath = getFragmentPathFromFirstTypeFromOfficeDoc( "notesMaster" );
std::vector< SlidePersistPtr >& rMasterPages( rFilter.getMasterPages() );
std::vector< SlidePersistPtr >::iterator aIter( rMasterPages.begin() );
diff --git a/oox/source/shape/ShapeContextHandler.cxx b/oox/source/shape/ShapeContextHandler.cxx
index 8286def8ffe4..54fed81d0e91 100644
--- a/oox/source/shape/ShapeContextHandler.cxx
+++ b/oox/source/shape/ShapeContextHandler.cxx
@@ -246,7 +246,7 @@ void SAL_CALL ShapeContextHandler::startFastElement
if (!msRelationFragmentPath.isEmpty())
{
FragmentHandlerRef rFragmentHandler(new ShapeFragmentHandler(*mxFilterBase, msRelationFragmentPath));
- OUString aThemeFragmentPath = rFragmentHandler->getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "theme" ) );
+ OUString aThemeFragmentPath = rFragmentHandler->getFragmentPathFromFirstTypeFromOfficeDoc( "theme" );
if(!aThemeFragmentPath.isEmpty())
{
uno::Reference<xml::sax::XFastSAXSerializable> xDoc(mxFilterBase->importFragment(aThemeFragmentPath), uno::UNO_QUERY_THROW);
diff --git a/oox/source/token/namespacemap.cxx b/oox/source/token/namespacemap.cxx
index faa9f6b840df..3f582db7e957 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 "namespaces-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.txt b/oox/source/token/namespaces-strict.txt
new file mode 100644
index 000000000000..9549483ec280
--- /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
diff --git a/oox/source/token/namespaces.pl b/oox/source/token/namespaces.pl
index 25ffdc25420d..c3dbb10a51ef 100644
--- a/oox/source/token/namespaces.pl
+++ b/oox/source/token/namespaces.pl
@@ -20,6 +20,8 @@ $ARGV0 = shift @ARGV;
$ARGV1 = shift @ARGV;
$ARGV2 = shift @ARGV;
$ARGV3 = shift @ARGV;
+$ARGV4 = shift @ARGV;
+$ARGV5 = shift @ARGV;
# parse input file
@@ -44,11 +46,35 @@ while( <INFILE> )
}
close( INFILE );
+# OOXML strict namespaces
+
+open( INFILE_STRICT, $ARGV4 ) or die "cannot open input file: $!";
+my %namespaces_strict;
+while( <INFILE_STRICT> )
+{
+ # 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_strict{$1} = $2;
+ }
+}
+close( INFILE_STRICT );
+
# 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: $!";
+open( NAMEFILE_STRICT, ">$ARGV5" ) or die "Error: cannot open output file: $!";
# number of bits to shift the namespace identifier
$shift = 16;
@@ -61,10 +87,13 @@ foreach( keys( %namespaces ) )
print( IDFILE "const sal_Int32 NMSP_$_ = $i << NMSP_SHIFT;\n" );
$id = $i << $shift;
print( NAMEFILE "{ $id, \"$namespaces{$_}\" },\n" );
+ print( NAMEFILE_STRICT "{ $id, \"$namespaces_strict{$_}\" },\n" );
print( TXTFILE "$id $_ $namespaces{$_}\n" );
+ print( TXTFILE "$id $_ $namespaces_strict{$_}\n" );
++$i;
}
close( IDFILE );
-close( nameFILE );
+close( NAMEFILE );
+close( NAMEFILE_STRICT );
close( TXTFILE );