[API CHANGE] remove BasicImport UNO interfaces

which are unused since
    commit 4e97fa0f4e
    Date:   Thu Feb 20 13:09:32 2020 +0200
    use fast-parser APIs for embedded script parsing

and highly unlikely to be externally used since they parse document
internal script code.

Change-Id: I2e0e237fb31bba85f1ef63c88f3a6959eedf2ca7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89104
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2020-02-20 15:33:05 +02:00
parent ef6d1789e4
commit 214e6caf2c
10 changed files with 0 additions and 1086 deletions

View File

@@ -134,7 +134,6 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/document,\
OOXMLDocumentPropertiesImporter \
XMLBasicExporter \
XMLOasisBasicExporter \
XMLOasisBasicImporter \
))
$(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/drawing,\
ColorTable \
@@ -757,7 +756,6 @@ $(eval $(call gb_UnoApi_add_idlfiles_noheader,offapi,com/sun/star/document,\
PDFDialog \
Settings \
TypeDetection \
XMLBasicImporter \
))
$(eval $(call gb_UnoApi_add_idlfiles_noheader,offapi,com/sun/star/drawing,\
AccessibleDrawDocumentView \
@@ -2258,7 +2256,6 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/document,\
XVbaMethodParameter \
XViewDataSupplier \
XXMLBasicExporter \
XXMLOasisBasicImporter \
))
$(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/drawing,\
Alignment \

View File

@@ -1,59 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* 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 __com_sun_star_document_XMLBasicImporter_idl__
#define __com_sun_star_document_XMLBasicImporter_idl__
#include <com/sun/star/document/XImporter.idl>
#include <com/sun/star/xml/sax/XDocumentHandler.idl>
module com { module sun { module star { module document {
/** Filter for importing Basic macros from the OpenOffice.org file format.
<p>The XImporter::setTargetDocument() method must be
called in order to provide the import component with the target document
to which the data should be imported.
The com::sun::star::xml::sax::XDocumentHandler
interface is used to stream the XML data into the filter.</p>
@since OOo 2.0
*/
published service XMLBasicImporter
{
/** sets the target document for this filter.
*/
interface com::sun::star::document::XImporter;
/** receives notification of general document events.
*/
interface com::sun::star::xml::sax::XDocumentHandler;
};
}; }; }; };
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -1,46 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* 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 __com_sun_star_document_XMLOasisBasicImporter_idl__
#define __com_sun_star_document_XMLOasisBasicImporter_idl__
#include <com/sun/star/document/XXMLOasisBasicImporter.idl>
module com { module sun { module star { module document {
/** Filter for importing Basic macros from the OASIS Open Office file format.
<p>The XImporter::setTargetDocument() method must be
called in order to provide the import component with the target document
to which the data should be imported.
The com::sun::star::xml::sax::XDocumentHandler
interface is used to stream the XML data into the filter.</p>
@since OOo 2.0
*/
published service XMLOasisBasicImporter : XXMLOasisBasicImporter;
}; }; }; };
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -1,52 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* 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 __com_sun_star_document_XXMLOasisBasicImporter_idl__
#define __com_sun_star_document_XXMLOasisBasicImporter_idl__
#include <com/sun/star/document/XImporter.idl>
#include <com/sun/star/xml/sax/XDocumentHandler.idl>
module com { module sun { module star { module document {
/**
@since LibreOffice 4.1
*/
published interface XXMLOasisBasicImporter
{
/** sets the target document for this filter.
*/
interface com::sun::star::document::XImporter;
/** receives notification of general document events.
*/
interface com::sun::star::xml::sax::XDocumentHandler;
};
}; }; }; };
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -4974,18 +4974,9 @@ module com {
};
};
module document {
published service XMLBasicImporter {
interface ::com::sun::star::document::XImporter;
interface ::com::sun::star::xml::sax::XDocumentHandler;
};
published service XMLOasisBasicExporter: ::com::sun::star::document::XXMLBasicExporter {
createWithHandler([in] ::com::sun::star::xml::sax::XDocumentHandler DocumentHandler);
};
published interface XXMLOasisBasicImporter {
interface ::com::sun::star::document::XImporter;
interface ::com::sun::star::xml::sax::XDocumentHandler;
};
published service XMLOasisBasicImporter: ::com::sun::star::document::XXMLOasisBasicImporter;
published interface XMimeTypeInfo {
interface ::com::sun::star::uno::XInterface;
boolean supportsMimeType([in] string MimeTypeName);

View File

@@ -322,9 +322,7 @@ core_constructor_list = [
"com_sun_star_comp_Chart_XMLOasisMetaImporter_get_implementation",
# xmlscript/util/xmlscript.component
"com_sun_star_comp_xmlscript_XMLBasicExporter",
"com_sun_star_comp_xmlscript_XMLBasicImporter",
"com_sun_star_comp_xmlscript_XMLOasisBasicExporter",
"com_sun_star_comp_xmlscript_XMLOasisBasicImporter",
# xmlsecurity/util/xmlsecurity.component
("com_sun_star_security_CertificateContainer_get_implementation", "#if HAVE_FEATURE_NSS"),
("com_sun_star_security_DocumentDigitalSignatures_get_implementation", "#if HAVE_FEATURE_NSS"),

View File

@@ -46,7 +46,6 @@ $(eval $(call gb_Library_add_exception_objects,xmlscript,\
xmlscript/source/xmldlg_imexp/xmldlg_impmodels \
xmlscript/source/xmldlg_imexp/xmldlg_import \
xmlscript/source/xmlflat_imexp/xmlbas_export \
xmlscript/source/xmlflat_imexp/xmlbas_import \
xmlscript/source/xmllib_imexp/xmllib_export \
xmlscript/source/xmllib_imexp/xmllib_import \
xmlscript/source/xmlmod_imexp/xmlmod_export \

View File

@@ -1,645 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* 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 .
*/
#include <sal/config.h>
#include "xmlbas_import.hxx"
#include <sal/log.hxx>
#include <xmlscript/xmlns.h>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/lang/XMultiComponentFactory.hpp>
#include <com/sun/star/document/XEmbeddedScripts.hpp>
#include <com/sun/star/xml/sax/SAXException.hpp>
#include <cppuhelper/supportsservice.hxx>
#include <tools/diagnose_ex.h>
using namespace ::com::sun::star;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::uno;
namespace xmlscript
{
// BasicElementBase
BasicElementBase::BasicElementBase( const OUString& rLocalName,
const Reference< xml::input::XAttributes >& xAttributes,
BasicElementBase* pParent, BasicImport* pImport )
:m_xImport( pImport )
,m_xParent( pParent )
,m_aLocalName( rLocalName )
,m_xAttributes( xAttributes )
{
}
BasicElementBase::~BasicElementBase()
{
}
bool BasicElementBase::getBoolAttr( bool* pRet, const OUString& rAttrName,
const css::uno::Reference< css::xml::input::XAttributes >& xAttributes,
sal_Int32 nUid )
{
if ( xAttributes.is() )
{
OUString aValue( xAttributes->getValueByUidName( nUid, rAttrName ) );
if ( !aValue.isEmpty() )
{
if ( aValue == "true" )
{
*pRet = true;
return true;
}
else if ( aValue == "false" )
{
*pRet = false;
return true;
}
else
{
throw xml::sax::SAXException(rAttrName + ": no boolean value (true|false)!", Reference< XInterface >(), Any() );
}
}
}
return false;
}
// XElement
Reference< xml::input::XElement > BasicElementBase::getParent()
{
return m_xParent.get();
}
OUString BasicElementBase::getLocalName()
{
return m_aLocalName;
}
sal_Int32 BasicElementBase::getUid()
{
sal_Int32 nId = -1;
if ( m_xImport.is() )
nId = m_xImport->XMLNS_UID;
return nId;
}
Reference< xml::input::XAttributes > BasicElementBase::getAttributes()
{
return m_xAttributes;
}
Reference< xml::input::XElement > BasicElementBase::startChildElement(
sal_Int32 /*nUid*/, const OUString& /*rLocalName*/,
const Reference< xml::input::XAttributes >& /*xAttributes*/ )
{
throw xml::sax::SAXException("unexpected element!", Reference< XInterface >(), Any() );
}
void BasicElementBase::characters( const OUString& /*rChars*/ )
{
// not used, all characters ignored
}
void BasicElementBase::ignorableWhitespace( const OUString& /*rWhitespaces*/ )
{
}
void BasicElementBase::processingInstruction( const OUString& /*rTarget*/, const OUString& /*rData*/ )
{
}
void BasicElementBase::endElement()
{
}
// BasicLibrariesElement
BasicLibrariesElement::BasicLibrariesElement( const OUString& rLocalName,
const Reference< xml::input::XAttributes >& xAttributes,
BasicImport* pImport,
const Reference< script::XLibraryContainer2 >& rxLibContainer )
:BasicElementBase( rLocalName, xAttributes, nullptr, pImport )
,m_xLibContainer( rxLibContainer )
{
}
// XElement
Reference< xml::input::XElement > BasicLibrariesElement::startChildElement(
sal_Int32 nUid, const OUString& rLocalName,
const Reference< xml::input::XAttributes >& xAttributes )
{
Reference< xml::input::XElement > xElement;
if ( nUid != m_xImport->XMLNS_UID )
{
throw xml::sax::SAXException( "illegal namespace!", Reference< XInterface >(), Any() );
}
else if ( rLocalName == "library-linked" )
{
if ( xAttributes.is() )
{
OUString aName = xAttributes->getValueByUidName( m_xImport->XMLNS_UID, "name" );
OUString aStorageURL = xAttributes->getValueByUidName(m_xImport->XMLNS_XLINK_UID, "href" );
bool bReadOnly = false;
getBoolAttr( &bReadOnly,"readonly", xAttributes, m_xImport->XMLNS_UID );
if ( m_xLibContainer.is() )
{
try
{
Reference< container::XNameAccess > xLib(
m_xLibContainer->createLibraryLink( aName, aStorageURL, bReadOnly ) );
if ( xLib.is() )
xElement.set( new BasicElementBase( rLocalName, xAttributes, this, m_xImport.get() ) );
}
catch ( const container::ElementExistException& )
{
TOOLS_INFO_EXCEPTION("xmlscript.xmlflat", "BasicLibrariesElement::startChildElement" );
}
catch ( const lang::IllegalArgumentException& )
{
TOOLS_INFO_EXCEPTION("xmlscript.xmlflat", "BasicLibrariesElement::startChildElement" );
}
}
}
}
else if ( rLocalName == "library-embedded" )
{
// TODO: create password protected libraries
if ( xAttributes.is() )
{
OUString aName = xAttributes->getValueByUidName( m_xImport->XMLNS_UID, "name" );
bool bReadOnly = false;
getBoolAttr( &bReadOnly, "readonly", xAttributes, m_xImport->XMLNS_UID );
if ( m_xLibContainer.is() )
{
try
{
Reference< container::XNameContainer > xLib;
if ( m_xLibContainer->hasByName( aName ) )
{
// Standard library
m_xLibContainer->getByName( aName ) >>= xLib;
}
else
{
xLib.set( m_xLibContainer->createLibrary( aName ) );
}
if ( xLib.is() )
xElement.set( new BasicEmbeddedLibraryElement( rLocalName, xAttributes, this, m_xImport.get(), m_xLibContainer, aName, bReadOnly ) );
}
catch ( const lang::IllegalArgumentException& )
{
TOOLS_INFO_EXCEPTION("xmlscript.xmlflat", "BasicLibrariesElement::startChildElement" );
}
}
}
}
else
{
throw xml::sax::SAXException( "expected library-linked or library-embedded element!", Reference< XInterface >(), Any() );
}
return xElement;
}
void BasicLibrariesElement::endElement()
{
}
// BasicEmbeddedLibraryElement
BasicEmbeddedLibraryElement::BasicEmbeddedLibraryElement( const OUString& rLocalName,
const Reference< xml::input::XAttributes >& xAttributes,
BasicElementBase* pParent, BasicImport* pImport,
const Reference< script::XLibraryContainer2 >& rxLibContainer,
const OUString& rLibName, bool bReadOnly )
:BasicElementBase( rLocalName, xAttributes, pParent, pImport )
,m_xLibContainer( rxLibContainer )
,m_aLibName( rLibName )
,m_bReadOnly( bReadOnly )
{
try
{
if ( m_xLibContainer.is() && m_xLibContainer->hasByName( m_aLibName ) )
m_xLibContainer->getByName( m_aLibName ) >>= m_xLib;
}
catch ( const lang::WrappedTargetException& )
{
TOOLS_INFO_EXCEPTION("xmlscript.xmlflat", "BasicEmbeddedLibraryElement::CTOR:" );
}
}
// XElement
Reference< xml::input::XElement > BasicEmbeddedLibraryElement::startChildElement(
sal_Int32 nUid, const OUString& rLocalName,
const Reference< xml::input::XAttributes >& xAttributes )
{
Reference< xml::input::XElement > xElement;
if ( nUid != m_xImport->XMLNS_UID )
{
throw xml::sax::SAXException( "illegal namespace!", Reference< XInterface >(), Any() );
}
else if ( rLocalName == "module" )
{
if ( xAttributes.is() )
{
OUString aName = xAttributes->getValueByUidName(m_xImport->XMLNS_UID, "name" );
if ( m_xLib.is() && !aName.isEmpty() )
xElement.set( new BasicModuleElement( rLocalName, xAttributes, this, m_xImport.get(), m_xLib, aName ) );
}
}
else
{
throw xml::sax::SAXException( "expected module element!", Reference< XInterface >(), Any() );
}
return xElement;
}
void BasicEmbeddedLibraryElement::endElement()
{
if ( m_xLibContainer.is() && m_xLibContainer->hasByName( m_aLibName ) && m_bReadOnly )
m_xLibContainer->setLibraryReadOnly( m_aLibName, m_bReadOnly );
}
// BasicModuleElement
BasicModuleElement::BasicModuleElement( const OUString& rLocalName,
const Reference< xml::input::XAttributes >& xAttributes,
BasicElementBase* pParent, BasicImport* pImport,
const Reference< container::XNameContainer >& rxLib, const OUString& rName )
:BasicElementBase( rLocalName, xAttributes, pParent, pImport )
,m_xLib( rxLib )
,m_aName( rName )
{
}
// XElement
Reference< xml::input::XElement > BasicModuleElement::startChildElement(
sal_Int32 nUid, const OUString& rLocalName,
const Reference< xml::input::XAttributes >& xAttributes )
{
// TODO: <byte-code>
Reference< xml::input::XElement > xElement;
if ( nUid != m_xImport->XMLNS_UID )
{
throw xml::sax::SAXException( "illegal namespace!", Reference< XInterface >(), Any() );
}
else if ( rLocalName == "source-code" )
{
// TODO: password protected libraries
if ( xAttributes.is() )
{
if ( m_xLib.is() && !m_aName.isEmpty() )
xElement.set( new BasicSourceCodeElement( rLocalName, xAttributes, this, m_xImport.get(), m_xLib, m_aName ) );
}
}
else
{
throw xml::sax::SAXException( "expected source-code element!", Reference< XInterface >(), Any() );
}
return xElement;
}
void BasicModuleElement::endElement()
{
}
// BasicSourceCodeElement
BasicSourceCodeElement::BasicSourceCodeElement( const OUString& rLocalName,
const Reference< xml::input::XAttributes >& xAttributes,
BasicElementBase* pParent, BasicImport* pImport,
const Reference< container::XNameContainer >& rxLib, const OUString& rName )
:BasicElementBase( rLocalName, xAttributes, pParent, pImport )
,m_xLib( rxLib )
,m_aName( rName )
{
}
// XElement
void BasicSourceCodeElement::characters( const OUString& rChars )
{
m_aBuffer.append( rChars );
}
void BasicSourceCodeElement::endElement()
{
try
{
if ( m_xLib.is() && !m_aName.isEmpty() )
{
Any aElement;
aElement <<= m_aBuffer.makeStringAndClear();
m_xLib->insertByName( m_aName, aElement );
}
}
catch ( const container::ElementExistException& )
{
TOOLS_INFO_EXCEPTION("xmlscript.xmlflat", "BasicSourceCodeElement::endElement" );
}
catch ( const lang::IllegalArgumentException& )
{
TOOLS_INFO_EXCEPTION("xmlscript.xmlflat", "BasicSourceCodeElement::endElement" );
}
catch ( const lang::WrappedTargetException& )
{
TOOLS_INFO_EXCEPTION("xmlscript.xmlflat", "BasicSourceCodeElement::endElement" );
}
}
// BasicImport
BasicImport::BasicImport( const Reference< frame::XModel >& rxModel, bool bOasis )
: XMLNS_UID(0)
, XMLNS_XLINK_UID(0)
, m_xModel(rxModel)
, m_bOasis(bOasis)
{
}
BasicImport::~BasicImport()
{
}
// XRoot
void BasicImport::startDocument( const Reference< xml::input::XNamespaceMapping >& xNamespaceMapping )
{
if ( xNamespaceMapping.is() )
{
OUString aURI;
if ( m_bOasis )
aURI = XMLNS_OOO_URI;
else
aURI = XMLNS_SCRIPT_URI;
XMLNS_UID = xNamespaceMapping->getUidByUri( aURI );
XMLNS_XLINK_UID = xNamespaceMapping->getUidByUri( XMLNS_XLINK_URI );
}
}
void BasicImport::endDocument()
{
}
void BasicImport::processingInstruction( const OUString& /*rTarget*/, const OUString& /*rData*/ )
{
}
void BasicImport::setDocumentLocator( const Reference< xml::sax::XLocator >& /*xLocator*/ )
{
}
Reference< xml::input::XElement > BasicImport::startRootElement( sal_Int32 nUid, const OUString& rLocalName,
Reference< xml::input::XAttributes > const & xAttributes )
{
Reference< xml::input::XElement > xElement;
if ( nUid != XMLNS_UID )
{
throw xml::sax::SAXException( "illegal namespace!", Reference< XInterface >(), Any() );
}
else if ( rLocalName == "libraries" )
{
Reference< script::XLibraryContainer2 > xLibContainer;
// try the XEmbeddedScripts interface
Reference< document::XEmbeddedScripts > xDocumentScripts( m_xModel, UNO_QUERY );
if ( xDocumentScripts.is() )
xLibContainer.set( xDocumentScripts->getBasicLibraries().get() );
if ( !xLibContainer.is() )
{
// try the "BasicLibraries" property (old-style, for compatibility)
Reference< beans::XPropertySet > xPSet( m_xModel, UNO_QUERY );
if ( xPSet.is() )
xPSet->getPropertyValue("BasicLibraries" ) >>= xLibContainer;
}
SAL_WARN_IF( !xLibContainer.is(), "xmlscript.xmlflat", "BasicImport::startRootElement: nowhere to import to!" );
if ( xLibContainer.is() )
{
xElement.set( new BasicLibrariesElement( rLocalName, xAttributes, this, xLibContainer ) );
}
}
else
{
throw xml::sax::SAXException("illegal root element (expected libraries) given: " + rLocalName, Reference< XInterface >(), Any() );
}
return xElement;
}
// XMLBasicImporterBase
XMLBasicImporterBase::XMLBasicImporterBase( const Reference< XComponentContext >& rxContext, bool bOasis )
:m_xContext( rxContext )
,m_bOasis( bOasis )
{
}
XMLBasicImporterBase::~XMLBasicImporterBase()
{
}
// XServiceInfo
sal_Bool XMLBasicImporterBase::supportsService( const OUString& rServiceName )
{
return cppu::supportsService(this, rServiceName);
}
// XImporter
void XMLBasicImporterBase::setTargetDocument( const Reference< XComponent >& rxDoc )
{
::osl::MutexGuard aGuard( m_aMutex );
m_xModel.set( rxDoc, UNO_QUERY );
if ( !m_xModel.is() )
{
throw IllegalArgumentException( "XMLBasicExporter::setTargetDocument: no document model!", Reference< XInterface >(), 1 );
}
if ( m_xContext.is() )
{
Reference< XMultiComponentFactory > xSMgr( m_xContext->getServiceManager() );
if ( xSMgr.is() )
{
Reference < xml::input::XRoot > xRoot( new BasicImport( m_xModel, m_bOasis ) );
Sequence < Any > aArgs( 1 );
aArgs[0] <<= xRoot;
m_xHandler.set( xSMgr->createInstanceWithArgumentsAndContext("com.sun.star.xml.input.SaxDocumentHandler", aArgs, m_xContext ), UNO_QUERY );
}
}
}
// XDocumentHandler
void XMLBasicImporterBase::startDocument()
{
::osl::MutexGuard aGuard( m_aMutex );
if ( m_xHandler.is() )
m_xHandler->startDocument();
}
void XMLBasicImporterBase::endDocument()
{
::osl::MutexGuard aGuard( m_aMutex );
if ( m_xHandler.is() )
m_xHandler->endDocument();
}
void XMLBasicImporterBase::startElement( const OUString& aName,
const Reference< xml::sax::XAttributeList >& xAttribs )
{
::osl::MutexGuard aGuard( m_aMutex );
if ( m_xHandler.is() )
m_xHandler->startElement( aName, xAttribs );
}
void XMLBasicImporterBase::endElement( const OUString& aName )
{
::osl::MutexGuard aGuard( m_aMutex );
if ( m_xHandler.is() )
m_xHandler->endElement( aName );
}
void XMLBasicImporterBase::characters( const OUString& aChars )
{
::osl::MutexGuard aGuard( m_aMutex );
if ( m_xHandler.is() )
m_xHandler->characters( aChars );
}
void XMLBasicImporterBase::ignorableWhitespace( const OUString& aWhitespaces )
{
::osl::MutexGuard aGuard( m_aMutex );
if ( m_xHandler.is() )
m_xHandler->ignorableWhitespace( aWhitespaces );
}
void XMLBasicImporterBase::processingInstruction( const OUString& aTarget,
const OUString& aData )
{
::osl::MutexGuard aGuard( m_aMutex );
if ( m_xHandler.is() )
m_xHandler->processingInstruction( aTarget, aData );
}
void XMLBasicImporterBase::setDocumentLocator( const Reference< xml::sax::XLocator >& xLocator )
{
::osl::MutexGuard aGuard( m_aMutex );
if ( m_xHandler.is() )
m_xHandler->setDocumentLocator( xLocator );
}
// XMLBasicImporter
XMLBasicImporter::XMLBasicImporter( const Reference< XComponentContext >& rxContext )
:XMLBasicImporterBase( rxContext, false )
{
}
XMLBasicImporter::~XMLBasicImporter()
{
}
// XServiceInfo
OUString XMLBasicImporter::getImplementationName( )
{
return "com.sun.star.comp.xmlscript.XMLBasicImporter";
}
Sequence< OUString > XMLBasicImporter::getSupportedServiceNames( )
{
Sequence< OUString > aNames { "com.sun.star.document.XMLBasicImporter" };
return aNames;
}
// XMLOasisBasicImporter
XMLOasisBasicImporter::XMLOasisBasicImporter( const Reference< XComponentContext >& rxContext )
:XMLBasicImporterBase( rxContext, true )
{
}
XMLOasisBasicImporter::~XMLOasisBasicImporter()
{
}
// XServiceInfo
OUString XMLOasisBasicImporter::getImplementationName( )
{
return "com.sun.star.comp.xmlscript.XMLOasisBasicImporter";
}
Sequence< OUString > XMLOasisBasicImporter::getSupportedServiceNames( )
{
Sequence< OUString > aNames { "com.sun.star.document.XMLOasisBasicImporter" };
return aNames;
}
} // namespace xmlscript
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
com_sun_star_comp_xmlscript_XMLBasicImporter(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{
return cppu::acquire(new xmlscript::XMLBasicImporter(context));
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
com_sun_star_comp_xmlscript_XMLOasisBasicImporter(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{
return cppu::acquire(new xmlscript::XMLOasisBasicImporter(context));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -1,261 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* 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 .
*/
#pragma once
#include <com/sun/star/document/XXMLOasisBasicImporter.hpp>
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/script/XLibraryContainer2.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/xml/input/XRoot.hpp>
#include <cppuhelper/implbase.hxx>
#include <osl/mutex.hxx>
#include <rtl/ustrbuf.hxx>
#include <rtl/ref.hxx>
namespace xmlscript
{
class BasicImport;
typedef ::cppu::WeakImplHelper<
css::xml::input::XElement > BasicElementBase_BASE;
class BasicElementBase : public BasicElementBase_BASE
{
protected:
rtl::Reference<BasicImport> m_xImport;
private:
rtl::Reference<BasicElementBase> m_xParent;
OUString const m_aLocalName;
css::uno::Reference< css::xml::input::XAttributes > m_xAttributes;
protected:
static bool getBoolAttr( bool* pRet, const OUString& rAttrName,
const css::uno::Reference< css::xml::input::XAttributes >& xAttributes,
sal_Int32 nUid );
public:
BasicElementBase( const OUString& rLocalName,
const css::uno::Reference< css::xml::input::XAttributes >& xAttributes,
BasicElementBase* pParent, BasicImport* pImport );
virtual ~BasicElementBase() override;
// XElement
virtual css::uno::Reference< css::xml::input::XElement > SAL_CALL getParent() override;
virtual OUString SAL_CALL getLocalName() override;
virtual sal_Int32 SAL_CALL getUid() override;
virtual css::uno::Reference< css::xml::input::XAttributes > SAL_CALL getAttributes() override;
virtual css::uno::Reference< css::xml::input::XElement > SAL_CALL startChildElement(
sal_Int32 nUid, const OUString& rLocalName,
const css::uno::Reference< css::xml::input::XAttributes >& xAttributes ) override;
virtual void SAL_CALL characters( const OUString& rChars ) override;
virtual void SAL_CALL ignorableWhitespace(
const OUString& rWhitespaces ) override;
virtual void SAL_CALL processingInstruction(
const OUString& rTarget, const OUString& rData ) override;
virtual void SAL_CALL endElement() override;
};
class BasicLibrariesElement : public BasicElementBase
{
private:
css::uno::Reference< css::script::XLibraryContainer2 > m_xLibContainer;
public:
BasicLibrariesElement( const OUString& rLocalName,
const css::uno::Reference< css::xml::input::XAttributes >& xAttributes,
BasicImport* pImport,
const css::uno::Reference< css::script::XLibraryContainer2 >& rxLibContainer );
// XElement
virtual css::uno::Reference< css::xml::input::XElement > SAL_CALL startChildElement(
sal_Int32 nUid, const OUString& rLocalName,
const css::uno::Reference< css::xml::input::XAttributes >& xAttributes ) override;
virtual void SAL_CALL endElement() override;
};
class BasicEmbeddedLibraryElement : public BasicElementBase
{
private:
css::uno::Reference< css::script::XLibraryContainer2 > m_xLibContainer;
css::uno::Reference< css::container::XNameContainer > m_xLib;
OUString const m_aLibName;
bool const m_bReadOnly;
public:
BasicEmbeddedLibraryElement( const OUString& rLocalName,
const css::uno::Reference< css::xml::input::XAttributes >& xAttributes,
BasicElementBase* pParent, BasicImport* pImport,
const css::uno::Reference< css::script::XLibraryContainer2 >& rxLibContainer,
const OUString& rLibName, bool bReadOnly );
// XElement
virtual css::uno::Reference< css::xml::input::XElement > SAL_CALL startChildElement(
sal_Int32 nUid, const OUString& rLocalName,
const css::uno::Reference< css::xml::input::XAttributes >& xAttributes ) override;
virtual void SAL_CALL endElement() override;
};
class BasicModuleElement : public BasicElementBase
{
private:
css::uno::Reference< css::container::XNameContainer > m_xLib;
OUString const m_aName;
public:
BasicModuleElement( const OUString& rLocalName,
const css::uno::Reference< css::xml::input::XAttributes >& xAttributes,
BasicElementBase* pParent, BasicImport* pImport,
const css::uno::Reference< css::container::XNameContainer >& rxLib,
const OUString& rName );
// XElement
virtual css::uno::Reference< css::xml::input::XElement > SAL_CALL startChildElement(
sal_Int32 nUid, const OUString& rLocalName,
const css::uno::Reference< css::xml::input::XAttributes >& xAttributes ) override;
virtual void SAL_CALL endElement() override;
};
class BasicSourceCodeElement : public BasicElementBase
{
private:
css::uno::Reference< css::container::XNameContainer > m_xLib;
OUString const m_aName;
OUStringBuffer m_aBuffer;
public:
BasicSourceCodeElement( const OUString& rLocalName,
const css::uno::Reference< css::xml::input::XAttributes >& xAttributes,
BasicElementBase* pParent, BasicImport* pImport,
const css::uno::Reference< css::container::XNameContainer >& rxLib,
const OUString& rName );
// XElement
virtual void SAL_CALL characters( const OUString& rChars ) override;
virtual void SAL_CALL endElement() override;
};
typedef ::cppu::WeakImplHelper<
css::xml::input::XRoot > BasicImport_BASE;
class BasicImport : public BasicImport_BASE
{
friend class BasicElementBase;
friend class BasicLibrariesElement;
friend class BasicEmbeddedLibraryElement;
friend class BasicModuleElement;
private:
sal_Int32 XMLNS_UID;
sal_Int32 XMLNS_XLINK_UID;
css::uno::Reference< css::frame::XModel > m_xModel;
bool const m_bOasis;
public:
BasicImport( const css::uno::Reference< css::frame::XModel >& rxModel, bool bOasis );
virtual ~BasicImport() override;
// XRoot
virtual void SAL_CALL startDocument(
const css::uno::Reference< css::xml::input::XNamespaceMapping >& xNamespaceMapping ) override;
virtual void SAL_CALL endDocument() override;
virtual void SAL_CALL processingInstruction(
const OUString& rTarget, const OUString& rData ) override;
virtual void SAL_CALL setDocumentLocator(
const css::uno::Reference< css::xml::sax::XLocator >& xLocator ) override;
virtual css::uno::Reference< css::xml::input::XElement > SAL_CALL startRootElement(
sal_Int32 nUid, const OUString& rLocalName,
const css::uno::Reference< css::xml::input::XAttributes >& xAttributes ) override;
};
typedef ::cppu::WeakImplHelper<
css::lang::XServiceInfo,
css::document::XXMLOasisBasicImporter > XMLBasicImporterBase_BASE;
class XMLBasicImporterBase : public XMLBasicImporterBase_BASE
{
private:
::osl::Mutex m_aMutex;
css::uno::Reference< css::uno::XComponentContext > m_xContext;
css::uno::Reference< css::xml::sax::XDocumentHandler > m_xHandler;
css::uno::Reference< css::frame::XModel > m_xModel;
bool const m_bOasis;
public:
XMLBasicImporterBase(
const css::uno::Reference< css::uno::XComponentContext >& rxContext, bool bOasis );
virtual ~XMLBasicImporterBase() override;
// XServiceInfo
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
// XImporter
virtual void SAL_CALL setTargetDocument( const css::uno::Reference< css::lang::XComponent >& rxDoc ) override;
// XDocumentHandler
virtual void SAL_CALL startDocument() override;
virtual void SAL_CALL endDocument() override;
virtual void SAL_CALL startElement( const OUString& aName,
const css::uno::Reference< css::xml::sax::XAttributeList >& xAttribs ) override;
virtual void SAL_CALL endElement( const OUString& aName ) override;
virtual void SAL_CALL characters( const OUString& aChars ) override;
virtual void SAL_CALL ignorableWhitespace( const OUString& aWhitespaces ) override;
virtual void SAL_CALL processingInstruction( const OUString& aTarget, const OUString& aData ) override;
virtual void SAL_CALL setDocumentLocator( const css::uno::Reference< css::xml::sax::XLocator >& xLocator ) override;
};
class XMLBasicImporter : public XMLBasicImporterBase
{
public:
explicit XMLBasicImporter(
const css::uno::Reference< css::uno::XComponentContext >& rxContext );
virtual ~XMLBasicImporter() override;
// XServiceInfo
virtual OUString SAL_CALL getImplementationName( ) override;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
};
class XMLOasisBasicImporter : public XMLBasicImporterBase
{
public:
explicit XMLOasisBasicImporter(
const css::uno::Reference< css::uno::XComponentContext >& rxContext );
virtual ~XMLOasisBasicImporter() override;
// XServiceInfo
virtual OUString SAL_CALL getImplementationName( ) override;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
};
} // namespace xmlscript
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -26,16 +26,8 @@
constructor="com_sun_star_comp_xmlscript_XMLBasicExporter">
<service name="com.sun.star.document.XMLBasicExporter"/>
</implementation>
<implementation name="com.sun.star.comp.xmlscript.XMLBasicImporter"
constructor="com_sun_star_comp_xmlscript_XMLBasicImporter">
<service name="com.sun.star.document.XMLBasicImporter"/>
</implementation>
<implementation name="com.sun.star.comp.xmlscript.XMLOasisBasicExporter"
constructor="com_sun_star_comp_xmlscript_XMLOasisBasicExporter">
<service name="com.sun.star.document.XMLOasisBasicExporter"/>
</implementation>
<implementation name="com.sun.star.comp.xmlscript.XMLOasisBasicImporter"
constructor="com_sun_star_comp_xmlscript_XMLOasisBasicImporter">
<service name="com.sun.star.document.XMLOasisBasicImporter"/>
</implementation>
</component>