INTEGRATION: CWS oasisbf1 (1.8.38); FILE MERGED
2004/08/18 15:33:51 mib 1.8.38.1: #i32616#: document events were not saved
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
*
|
||||
* $RCSfile: xmlscripti.cxx,v $
|
||||
*
|
||||
* $Revision: 1.8 $
|
||||
* $Revision: 1.9 $
|
||||
*
|
||||
* last change: $Author: rt $ $Date: 2004-07-13 08:18:07 $
|
||||
* last change: $Author: hr $ $Date: 2004-11-09 12:18:21 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
@@ -59,10 +59,6 @@
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
#include <tools/debug.hxx>
|
||||
#include <tools/isolang.hxx>
|
||||
#include <tools/time.hxx>
|
||||
|
||||
#include "xmlscripti.hxx"
|
||||
#include "xmlnmspe.hxx"
|
||||
#include "xmltoken.hxx"
|
||||
@@ -70,17 +66,12 @@
|
||||
#include "nmspmap.hxx"
|
||||
#include "XMLEventsImportContext.hxx"
|
||||
|
||||
#include <com/sun/star/script/XStarBasicAccess.hpp>
|
||||
#include <com/sun/star/script/XStarBasicModuleInfo.hpp>
|
||||
#include <com/sun/star/script/XStarBasicDialogInfo.hpp>
|
||||
#include <com/sun/star/script/XStarBasicLibraryInfo.hpp>
|
||||
#include <com/sun/star/document/XEventsSupplier.hpp>
|
||||
|
||||
using namespace rtl;
|
||||
using namespace com::sun::star::uno;
|
||||
using namespace com::sun::star::lang;
|
||||
using namespace com::sun::star::frame;
|
||||
using namespace com::sun::star::script;
|
||||
using namespace com::sun::star::document;
|
||||
using namespace com::sun::star::xml::sax;
|
||||
using namespace ::xmloff::token;
|
||||
@@ -88,232 +79,6 @@ using namespace ::xmloff::token;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
class XMLScriptElementContext;
|
||||
|
||||
class XMLScriptModuleContext : public SvXMLImportContext
|
||||
{
|
||||
private:
|
||||
XMLScriptElementContext& mrParent;
|
||||
OUString msSource;
|
||||
Reference<XStarBasicAccess> mxBasicAccess;
|
||||
|
||||
OUString msLibName;
|
||||
OUString msModuleName;
|
||||
OUString msLanguage;
|
||||
|
||||
public:
|
||||
XMLScriptModuleContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
|
||||
const OUString& rLName, const OUString& aLibName,
|
||||
const Reference<XAttributeList>& xAttrList,
|
||||
XMLScriptElementContext& rParentContext,
|
||||
Reference<XStarBasicAccess> xBasicAccess );
|
||||
|
||||
virtual ~XMLScriptModuleContext();
|
||||
|
||||
virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
|
||||
const OUString& rLName,
|
||||
const Reference<XAttributeList>& xAttrList );
|
||||
virtual void EndElement();
|
||||
virtual void Characters( const rtl::OUString& rChars );
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
class XMLScriptElementContext : public SvXMLImportContext
|
||||
{
|
||||
private:
|
||||
XMLScriptContext& mrParent;
|
||||
OUString msLName;
|
||||
OUString msContent;
|
||||
Reference<XStarBasicAccess> mxBasicAccess;
|
||||
|
||||
OUString msLibName;
|
||||
|
||||
public:
|
||||
XMLScriptElementContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
|
||||
const OUString& rLName,
|
||||
const Reference<XAttributeList>& xAttrList,
|
||||
XMLScriptContext& rParentContext,
|
||||
Reference<XStarBasicAccess> xBasicAccess );
|
||||
|
||||
virtual ~XMLScriptElementContext();
|
||||
|
||||
virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
|
||||
const OUString& rLName,
|
||||
const Reference<XAttributeList>& xAttrList );
|
||||
virtual void EndElement();
|
||||
virtual void Characters( const rtl::OUString& rChars );
|
||||
};
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
XMLScriptElementContext::XMLScriptElementContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
|
||||
const OUString& rLName,
|
||||
const Reference<XAttributeList>& xAttrList,
|
||||
XMLScriptContext& rParentContext,
|
||||
Reference<XStarBasicAccess> xBasicAccess )
|
||||
: SvXMLImportContext( rImport, nPrfx, rLName )
|
||||
, msLName( rLName )
|
||||
, mrParent( rParentContext )
|
||||
, mxBasicAccess( xBasicAccess )
|
||||
{
|
||||
mrParent.AddRef();
|
||||
|
||||
OUString sPassword;
|
||||
OUString sExternalSourceURL;
|
||||
OUString sLinkTargetURL;
|
||||
|
||||
sal_Bool bEmbedded = sal_False;
|
||||
sal_Bool bLinked = sal_False;
|
||||
if( IsXMLToken( msLName, XML_LIBRARY_EMBEDDED ) )
|
||||
bEmbedded = sal_True;
|
||||
else if( IsXMLToken( msLName, XML_LIBRARY_LINKED ) )
|
||||
bLinked = sal_True;
|
||||
|
||||
if( bEmbedded || bLinked )
|
||||
{
|
||||
sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
|
||||
for( sal_Int16 i = 0 ; i < nAttrCount ; i++ )
|
||||
{
|
||||
OUString sFullAttrName = xAttrList->getNameByIndex( i );
|
||||
OUString sAttrName;
|
||||
sal_Int16 nAttrPrefix =
|
||||
GetImport().GetNamespaceMap().GetKeyByAttrName( sFullAttrName,
|
||||
&sAttrName );
|
||||
|
||||
if( (XML_NAMESPACE_SCRIPT == nAttrPrefix) &&
|
||||
IsXMLToken( sAttrName, XML_NAME ) )
|
||||
{
|
||||
msLibName = xAttrList->getValueByIndex( i );
|
||||
}
|
||||
else if( (XML_NAMESPACE_SCRIPT == nAttrPrefix) &&
|
||||
IsXMLToken( sAttrName, XML_PASSWORD ) )
|
||||
{
|
||||
sPassword = xAttrList->getValueByIndex( i );
|
||||
}
|
||||
else if( (XML_NAMESPACE_XLINK == nAttrPrefix) && bLinked &&
|
||||
IsXMLToken( sAttrName, XML_HREF ) )
|
||||
{
|
||||
sLinkTargetURL = GetImport().GetAbsoluteReference(xAttrList->getValueByIndex( i ));
|
||||
}
|
||||
//else if( IsXMLToken(msLName, XML_EXTERNAL_SOURCE_URL) )
|
||||
//{
|
||||
//sLinkTargetURL = xAttrList->getValueByIndex( i );
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
if( msLibName.getLength() )
|
||||
mxBasicAccess->createLibrary( msLibName, sPassword, sExternalSourceURL, sLinkTargetURL );
|
||||
}
|
||||
|
||||
XMLScriptElementContext::~XMLScriptElementContext()
|
||||
{
|
||||
mrParent.ReleaseRef();
|
||||
}
|
||||
|
||||
|
||||
SvXMLImportContext* XMLScriptElementContext::CreateChildContext( sal_uInt16 nPrefix,
|
||||
const OUString& rLName,
|
||||
const Reference<XAttributeList>& xAttrList )
|
||||
{
|
||||
SvXMLImportContext* pContext = NULL;
|
||||
|
||||
if ( XML_NAMESPACE_SCRIPT == nPrefix)
|
||||
{
|
||||
if( IsXMLToken( msLName, XML_LIBRARY_EMBEDDED ) )
|
||||
{
|
||||
if( IsXMLToken( rLName, XML_MODULE ) )
|
||||
{
|
||||
pContext = new XMLScriptModuleContext( GetImport(), nPrefix,
|
||||
rLName, msLibName, xAttrList, *this, mxBasicAccess );
|
||||
}
|
||||
//else if( IsXMLToken( rLName, XML_DIALOG ) )
|
||||
//{
|
||||
//pContext = new XMLScriptDialogContext( GetImport(),
|
||||
//nPrefix, rLName, xAttrList, *this, mxBasicAccess );
|
||||
//}
|
||||
}
|
||||
}
|
||||
// else: unknown namespace: ignore
|
||||
|
||||
if ( !pContext )
|
||||
{
|
||||
// default context to ignore unknown elements
|
||||
pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
|
||||
}
|
||||
return pContext;
|
||||
}
|
||||
|
||||
void XMLScriptElementContext::EndElement()
|
||||
{
|
||||
}
|
||||
|
||||
void XMLScriptElementContext::Characters( const rtl::OUString& rChars )
|
||||
{
|
||||
msContent += rChars;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
XMLScriptModuleContext::XMLScriptModuleContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
|
||||
const OUString& rLName, const OUString& aLibName,
|
||||
const Reference<XAttributeList>& xAttrList,
|
||||
XMLScriptElementContext& rParentContext,
|
||||
Reference<XStarBasicAccess> xBasicAccess )
|
||||
: SvXMLImportContext( rImport, nPrfx, rLName )
|
||||
, msLibName( aLibName )
|
||||
, mrParent( rParentContext )
|
||||
, mxBasicAccess( xBasicAccess )
|
||||
{
|
||||
mrParent.AddRef();
|
||||
|
||||
sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
|
||||
for( sal_Int16 i = 0 ; i < nAttrCount ; i++ )
|
||||
{
|
||||
OUString sFullAttrName = xAttrList->getNameByIndex( i );
|
||||
OUString sAttrName;
|
||||
sal_Int16 nAttrPrefix =
|
||||
GetImport().GetNamespaceMap().GetKeyByAttrName( sFullAttrName,
|
||||
&sAttrName );
|
||||
|
||||
if( (XML_NAMESPACE_SCRIPT == nAttrPrefix) &&
|
||||
IsXMLToken( sAttrName, XML_NAME ) )
|
||||
{
|
||||
msModuleName = xAttrList->getValueByIndex( i );
|
||||
}
|
||||
else if( (XML_NAMESPACE_SCRIPT == nAttrPrefix) &&
|
||||
IsXMLToken( sAttrName, XML_LANGUAGE ) )
|
||||
{
|
||||
msLanguage = xAttrList->getValueByIndex( i );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
XMLScriptModuleContext::~XMLScriptModuleContext()
|
||||
{
|
||||
mrParent.ReleaseRef();
|
||||
}
|
||||
|
||||
SvXMLImportContext* XMLScriptModuleContext::CreateChildContext( sal_uInt16 nPrefix,
|
||||
const OUString& rLName,
|
||||
const Reference<XAttributeList>& xAttrList )
|
||||
{
|
||||
SvXMLImportContext* pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
|
||||
return pContext;
|
||||
}
|
||||
|
||||
void XMLScriptModuleContext::EndElement()
|
||||
{
|
||||
mxBasicAccess->addModule( msLibName, msModuleName, msLanguage, msSource );
|
||||
}
|
||||
|
||||
void XMLScriptModuleContext::Characters( const rtl::OUString& rChars )
|
||||
{
|
||||
msSource += rChars;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
@@ -322,12 +87,9 @@ void XMLScriptModuleContext::Characters( const rtl::OUString& rChars )
|
||||
|
||||
XMLScriptContext::XMLScriptContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
|
||||
const OUString& rLName,
|
||||
const Reference<XModel>& rDocModel )
|
||||
const Reference<XModel>& )
|
||||
: SvXMLImportContext( rImport, nPrfx, rLName )
|
||||
{
|
||||
// Get Basic data
|
||||
mxBasicAccess = Reference< XStarBasicAccess >( rDocModel, UNO_QUERY );
|
||||
DBG_ASSERT( mxBasicAccess.is(), "no StarBasicAccess" );
|
||||
}
|
||||
|
||||
XMLScriptContext::~XMLScriptContext()
|
||||
@@ -340,16 +102,7 @@ SvXMLImportContext* XMLScriptContext::CreateChildContext( sal_uInt16 nPrefix,
|
||||
{
|
||||
SvXMLImportContext* pContext = NULL;
|
||||
|
||||
if (XML_NAMESPACE_SCRIPT == nPrefix)
|
||||
{
|
||||
if( IsXMLToken( rLName, XML_LIBRARY_EMBEDDED ) ||
|
||||
IsXMLToken( rLName, XML_LIBRARY_LINKED ) )
|
||||
{
|
||||
pContext = new XMLScriptElementContext(
|
||||
GetImport(), nPrefix, rLName, xAttrList, *this, mxBasicAccess);
|
||||
}
|
||||
}
|
||||
else if (XML_NAMESPACE_OFFICE == nPrefix)
|
||||
if (XML_NAMESPACE_OFFICE == nPrefix)
|
||||
{
|
||||
if ( IsXMLToken( rLName, XML_EVENT_LISTENERS ) )
|
||||
{
|
||||
|
Reference in New Issue
Block a user