Kaydet (Commit) 3d016a2b authored tarafından Caolán McNamara's avatar Caolán McNamara

entire storage dir is unused/unbuilt

üst 9bcad6f6
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef _SCRIPTING_STORAGE_SCRIPTDATA_HXX_
#define _SCRIPTING_STORAGE_SCRIPTDATA_HXX_
#include <vector>
#include <boost/unordered_map.hpp>
#include <cppu/macros.hxx>
#include <rtl/ustring.hxx>
namespace scripting_impl
{
typedef ::std::pair< ::rtl::OUString, ::rtl::OUString > str_pair;
typedef ::std::vector< str_pair > props_vec;
typedef ::boost::unordered_map< ::rtl::OUString, props_vec, ::rtl::OUStringHash,
::std::equal_to< ::rtl::OUString > > strpairvec_map;
typedef ::boost::unordered_map< ::rtl::OUString, ::std::pair< ::rtl::OUString,
::rtl::OUString >, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > strpair_map;
typedef ::boost::unordered_map< ::rtl::OUString, ::std::pair< props_vec, strpairvec_map >, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > filesets_map;
struct ScriptData
{
inline ScriptData::ScriptData() SAL_THROW( () )
: parcelURI()
, language()
, locales()
, functionname()
, logicalname()
, languagedepprops()
, filesets()
{
}
inline ScriptData::ScriptData( const ::rtl::OUString __parcelURI,
const ::rtl::OUString& __language,
const strpair_map& __locales,
const ::rtl::OUString& __functionname,
const ::rtl::OUString& __logicalname,
const props_vec& __languagedepprops,
const filesets_map& __filesets ) SAL_THROW( () )
: parcelURI( __parcelURI )
, language( __language )
, locales( __locales )
, functionname( __functionname )
, logicalname( __logicalname )
, languagedepprops( __languagedepprops )
, filesets( __filesets )
{
}
::rtl::OUString parcelURI;
::rtl::OUString language;
strpair_map locales;
::rtl::OUString functionname;
::rtl::OUString logicalname;
props_vec languagedepprops;
filesets_map filesets;
};
} // namespace scripting_impl
#endif // _SCRIPTING_STORAGE_ScriptData_HXX_
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_scripting.hxx"
#include "ScriptElement.hxx"
#include <util/util.hxx>
using namespace ::rtl;
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
typedef ::std::vector < ::std::pair < ::rtl::OUString, bool > > dependencies_vec;
typedef ::std::vector < ::std::pair < ::rtl::OUString, ::rtl::OUString > > deliveries_vec;
namespace scripting_impl
{
//*************************************************************************
/**
Construct a ScriptElement from a ScriptData object
@param sII
the ScriptDataObject
*/
ScriptElement::ScriptElement( ScriptData & sII ) :
XMLElement( OUSTR( "parcel" ) ),
m_sII( sII )
{
OSL_TRACE( "ScriptElement ctor called\n" );
addAttribute( OUSTR( "language" ), sII.language );
addAttribute( OUSTR( "xmlns:parcel" ), OUSTR( "scripting.dtd" ) );
XMLElement* xScriptElt = new XMLElement( OUSTR( "script" ) );
xScriptElt->addAttribute( OUSTR( "language" ), sII.language );
Reference < xml::sax::XAttributeList > xal( xScriptElt );
addSubElement( xal );
strpair_map::const_iterator mp_it = sII.locales.begin();
strpair_map::const_iterator mp_itend = sII.locales.end();
for( ; mp_it != mp_itend; ++mp_it )
{
XMLElement* xel = new XMLElement( OUSTR( "locale" ) );
xel->addAttribute( OUSTR( "lang" ), mp_it->first );
{
XMLElement* subxel = new XMLElement( OUSTR( "displayname" ) );
subxel->addAttribute( OUSTR( "value" ), mp_it->second.first );
Reference < xml::sax::XAttributeList > subxattl( subxel );
xel->addSubElement( subxattl );
}
{
XMLElement* subxel = new XMLElement( OUSTR( "description" ),
mp_it->second.second );
Reference< xml::sax::XAttributeList > subxattl( subxel );
xel->addSubElement( subxattl );
}
Reference < xml::sax::XAttributeList > xal( xel );
xScriptElt->addSubElement( xal );
}
{
XMLElement* xel = new XMLElement( OUSTR( "functionname" ) );
xel->addAttribute( OUSTR( "value" ), sII.functionname );
Reference < xml::sax::XAttributeList > xal( xel );
xScriptElt->addSubElement( xal );
}
{
XMLElement* xel = new XMLElement( OUSTR( "logicalname" ) );
xel->addAttribute( OUSTR( "value" ), sII.logicalname );
Reference < xml::sax::XAttributeList > xal( xel );
xScriptElt->addSubElement( xal );
}
props_vec::const_iterator vp_it = sII.languagedepprops.begin();
props_vec::const_iterator vp_itend = sII.languagedepprops.end();
if ( vp_it != vp_itend )
{
XMLElement* xel = new XMLElement( OUSTR( "languagedepprops" ) );
for( ; vp_it != vp_itend ; ++vp_it )
{
XMLElement* subxel = new XMLElement( OUSTR( "prop" ) );
subxel->addAttribute( OUSTR( "name" ), vp_it->first );
subxel->addAttribute( OUSTR( "value" ), vp_it->second );
Reference < xml::sax::XAttributeList > subxattl( subxel );
xel->addSubElement( subxattl );
}
Reference < xml::sax::XAttributeList > xal( xel );
xScriptElt->addSubElement( xal );
}
filesets_map::const_iterator fm_it = sII.filesets.begin();
filesets_map::const_iterator fm_itend = sII.filesets.end();
for( ; fm_it != fm_itend; ++fm_it )
{
XMLElement* xel = new XMLElement( OUSTR( "fileset" ) );
xel->addAttribute( OUSTR( "name" ), fm_it->first );
vp_it = fm_it->second.first.begin();
vp_itend = fm_it->second.first.end();
for( ; vp_it != vp_itend; ++vp_it )
{
XMLElement* subxel = new XMLElement( OUSTR( "prop" ) );
subxel->addAttribute( OUSTR( "name" ), vp_it->first );
subxel->addAttribute( OUSTR("value"), vp_it->second );
Reference < xml::sax::XAttributeList > subxattl( subxel );
xel->addSubElement( subxattl );
}
strpairvec_map::const_iterator sm_it = fm_it->second.second.begin();
strpairvec_map::const_iterator sm_itend = fm_it->second.second.end();
if( sm_it != sm_itend )
{
// was there a purpose for contstructing this
// XMLElement* subxel = new XMLElement( OUSTR( "file" ) );
xel->addAttribute( OUSTR( "name" ), sm_it->first );
}
}
}
//*************************************************************************
ScriptElement::~ScriptElement() SAL_THROW(())
{
}
} // namespace scripting_impl
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef _SCRIPT_FRAMEWORK_STORAGE_SCRIPT_ELEMENT_HXX_
#define _SCRIPT_FRAMEWORK_STORAGE_SCRIPT_ELEMENT_HXX_
#include <osl/mutex.hxx>
#include "ScriptData.hxx"
#include "XMLElement.hxx"
namespace scripting_impl
{
// for simplification
#define css ::com::sun::star
#define dcsssf ::drafts::com::sun::star::script::framework
class ScriptElement : public ::scripting_impl::XMLElement
{
public:
/**
Construct a ScriptElement from a ScriptData object
@param sII
the ScriptData Object
*/
explicit ScriptElement( ScriptData & sII );
~ScriptElement() SAL_THROW (());
private:
ScriptData m_sII;
};
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This diff is collapsed.
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef __SCRIPT_FRAMEWORK_STORAGE_SCRIPTINFO_HXX_
#define __SCRIPT_FRAMEWORK_STORAGE_SCRIPTINFO_HXX_
#include <cppuhelper/implbase1.hxx> // helper for component factory
#include <com/sun/star/beans/XPropertySet.hpp>
#include <drafts/com/sun/star/script/framework/storage/XScriptInfo.hpp>
#include "ScriptData.hxx"
namespace scripting_impl
{
// for simplification
#define css ::com::sun::star
#define dcsssf ::drafts::com::sun::star::script::framework
class ScriptInfo : public ::cppu::WeakImplHelper1< dcsssf::storage::XScriptInfo >
{
public:
explicit ScriptInfo( const ScriptData & scriptData, sal_Int32 storageID );
virtual ~ScriptInfo();
// XScriptInfo
virtual ::rtl::OUString SAL_CALL getLogicalName()
throw ( css::uno::RuntimeException );
virtual ::rtl::OUString SAL_CALL getDescription()
throw ( css::uno::RuntimeException ) ;
virtual ::rtl::OUString SAL_CALL getLanguage() throw ( css::uno::RuntimeException );
virtual ::rtl::OUString SAL_CALL getFunctionName()
throw ( css::uno::RuntimeException );
virtual ::rtl::OUString SAL_CALL getParcelURI()
throw ( css::uno::RuntimeException );
virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL
getLanguageProperties() throw ( css::uno::RuntimeException );
virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getFileSetNames()
throw ( css::uno::RuntimeException );
virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL
getFilesInFileSet( const ::rtl::OUString & fileSetName )
throw ( css::uno::RuntimeException );
private:
ScriptData m_scriptData;
sal_Int32 m_storageID;
};
}
#endif // define __SCRIPTING_STORAGE...
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef _SCRIPTING_STORAGE_SCRIPTINFOIMPL_HXX_
#define _SCRIPTING_STORAGE_SCRIPTINFOIMPL_HXX_
#include <vector>
#include <map>
#include <cppu/macros.hxx>
#include <rtl/ustring.hxx>
typedef ::std::pair< ::rtl::OUString, ::rtl::OUString > str_pair;
typedef ::std::map< ::rtl::OUString, str_pair,
::std::equal_to< ::rtl::OUString > > strpair_map;
typedef ::std::vector< str_pair > props_vec;
typedef ::std::map< ::rtl::OUString, ::std::pair< props_vec, strpair_map >,
::std::equal_to< ::rtl::OUString > > filesets_map;
namespace scripting_impl
{
struct ScriptInfoImpl
{
inline ScriptInfoImpl::ScriptInfoImpl() SAL_THROW( () )
: parcelURI()
, language()
, locales()
, functionname()
, logicalname()
, languagedepprops()
, filesets()
{
}
inline ScriptInfoImpl::ScriptInfoImpl( const ::rtl::OUString __parcelURI,
const ::rtl::OUString& __language,
const strpair_map& __locales,
const ::rtl::OUString& __functionname,
const ::rtl::OUString& __logicalname,
const langdepprops_vec& __languagedepprops,
const filesets_map& __filesets ) SAL_THROW( () )
: parcelURI( __parcelURI )
, language( __language )
, locales( __locales )
, functionname( __functionname )
, logicalname( __logicalname )
, languagedepprops( __languagedepprops )
, filesets( __filesets )
{
}
::rtl::OUString parcelURI;
::rtl::OUString language;
strpair_map locales;
::rtl::OUString functionname;
::rtl::OUString logicalname;
props_vec languagedepprops;
filesets_map filesets;
};
} // namespace scripting_impl
#endif // _SCRIPTING_STORAGE_SCRIPTINFOIMPL_HXX_
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef _SCRIPTING_STORAGE_SCRIPTMETADATAIMPORTER_HXX_
#define _SCRIPTING_STORAGE_SCRIPTMETADATAIMPORTER_HXX_
#include <vector>
#include <rtl/ustring.h>
#include <rtl/ustrbuf.hxx>
#include <osl/mutex.hxx>
#include <cppuhelper/implbase1.hxx> // helper for component factory
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
#include <com/sun/star/io/XInputStream.hpp>
#include "ScriptData.hxx"
namespace scripting_impl
{
// for simplification
#define css ::com::sun::star
#define dcsssf ::drafts::com::sun::star::script::framework
typedef ::std::vector< ScriptData > InfoImpls_vec;
typedef ::std::pair< ::rtl::OUString, ::std::pair< ::rtl::OUString,
::rtl::OUString > > strpair_pair;
/**
* Script Meta Data Importer
*/
class ScriptMetadataImporter : public
::cppu::WeakImplHelper1< css::xml::sax::XExtendedDocumentHandler >
{
public:
/**
* This function will begin the parser and parse the meta data
*
* @param xInput The XInputStream for the parser which contains the XML
* @param parcelURI The parcel's URI in the document or the application
*
* @see css::io::XInputStream
*/
void parseMetaData( css::uno::Reference< css::io::XInputStream >
const & xInput, const ::rtl::OUString & parcelURI,
InfoImpls_vec & io_ScriptDatas )
throw ( css::xml::sax::SAXException, css::io::IOException,
css::uno::RuntimeException );
/**
* Constructor for the meta-data parser
*
* @param XComponentContext
*/
explicit ScriptMetadataImporter(
const css::uno::Reference< css::uno::XComponentContext >& );
/**
* Destructor for the parser
*/
virtual ~ScriptMetadataImporter() SAL_THROW( () );
// XExtendedDocumentHandler impl
/**
* Function to handle the start of CDATA in XML
*
* @see com::sun::star::xml::sax::XExtendedDocumentHandler
*/
virtual void SAL_CALL startCDATA()
throw ( css::xml::sax::SAXException, css::uno::RuntimeException );
/**
* Function to handle the end of CDATA in XML
*
* @see com::sun::star::xml::sax::XExtendedDocumentHandler
*/
virtual void SAL_CALL endCDATA() throw ( css::uno::RuntimeException );
/**
* Function to handle comments in XML
*
* @see com::sun::star::xml::sax::XExtendedDocumentHandler
*/
virtual void SAL_CALL comment( const ::rtl::OUString & sComment )
throw ( css::xml::sax::SAXException, css::uno::RuntimeException );
/**
* Function to handle line breaks in XML
*
* @see com::sun::star::xml::sax::XExtendedDocumentHandler
*/
virtual void SAL_CALL allowLineBreak()
throw ( css::xml::sax::SAXException, css::uno::RuntimeException );
/**
* Function to handle unknowns in XML
*
* @see com::sun::star::xml::sax::XExtendedDocumentHandler
*/
virtual void SAL_CALL unknown( const ::rtl::OUString & sString )
throw ( css::xml::sax::SAXException, css::uno::RuntimeException );
/**
* Function to handle the start of XML document
*
* @see com::sun::star::xml::sax::XExtendedDocumentHandler
*/
// XDocumentHandler impl
virtual void SAL_CALL startDocument()
throw ( css::xml::sax::SAXException, css::uno::RuntimeException );
/**
* Function to handle the end of the XML document
*
* @see com::sun::star::xml::sax::XDocumentHandler
*/
virtual void SAL_CALL endDocument()
throw ( css::xml::sax::SAXException, css::uno::RuntimeException );
/**
* Function to handle the start of an element
*
* @see com::sun::star::xml::sax::XDocumentHandler
*/
virtual void SAL_CALL startElement( const ::rtl::OUString& aName,
const css::uno::Reference< css::xml::sax::XAttributeList > & xAttribs )
throw ( css::xml::sax::SAXException,
css::uno::RuntimeException );
/**
* Function to handle the end of an element
*
* @see com::sun::star::xml::sax::XDocumentHandler
*/
virtual void SAL_CALL endElement( const ::rtl::OUString & aName )
throw ( css::xml::sax::SAXException, css::uno::RuntimeException );
/**
* Function to handle characters in elements
*
* @see com::sun::star::xml::sax::XDocumentHandler
*/
virtual void SAL_CALL characters( const ::rtl::OUString & aChars )
throw ( css::xml::sax::SAXException, css::uno::RuntimeException );
/**
* Function to handle whitespace
*
* @see com::sun::star::xml::sax::XDocumentHandler
*/
virtual void SAL_CALL ignorableWhitespace( const ::rtl::OUString & aWhitespaces )
throw ( css::xml::sax::SAXException, css::uno::RuntimeException );
/**
* Function to handle XML processing instructions
*
* @see com::sun::star::xml::sax::XDocumentHandler
*/
virtual void SAL_CALL processingInstruction(
const ::rtl::OUString & aTarget, const ::rtl::OUString & aData )
throw ( css::xml::sax::SAXException, css::uno::RuntimeException );
/**
* Function to set the document locator
*
* @see com::sun::star::xml::sax::XDocumentHandler
*/
virtual void SAL_CALL setDocumentLocator(
const css::uno::Reference< css::xml::sax::XLocator >& xLocator )
throw ( css::xml::sax::SAXException, css::uno::RuntimeException );
private:
/** Vector contains the ScriptData structs */
InfoImpls_vec* mpv_ScriptDatas;
/** @internal */
osl::Mutex m_mutex;
/** @internal */
css::uno::Reference< css::uno::XComponentContext > m_xContext;
/** Placeholder for the parcel URI */
::rtl::OUString ms_parcelURI;
/** States for state machine during parsing */
enum { PARCEL, SCRIPT, LOCALE, DISPLAYNAME, DESCRIPTION, FUNCTIONNAME,
LOGICALNAME, LANGUAGEDEPPROPS, LANGDEPPROPS, FILESET, FILESETPROPS,
FILES, FILEPROPS } m_state;
/** Build up the struct during parsing the meta data */
ScriptData m_ScriptData;
/** @internal */
::rtl::OUString ms_localeLang;
::rtl::OUString ms_localeDisName;
::rtl::OUStringBuffer *ms_localeDesc;
props_vec mv_filesetprops;
::rtl::OUString ms_filename;
::rtl::OUString ms_filesetname;
props_vec mv_fileprops;
strpairvec_map mm_files;
InfoImpls_vec mv_ScriptDatas;
/**
* Helper function to set the state
*
* @param tagName
* The current tag being processed
*/
void setState(const ::rtl::OUString & tagName);
}
; // class ScriptMetadataImporter
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef _FRAMEWORK_SCRIPT_SCRIPTSECURITYMANAGER_HXX_
#define _FRAMEWORK_SCRIPT_SCRIPTSECURITYMANAGER_HXX_
#include <boost/unordered_map.hpp>
#include <rtl/ustring.hxx>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/uno/RuntimeException.hpp>
#include <com/sun/star/lang/IllegalArgumentException.hpp>
#include <com/sun/star/security/AccessControlException.hpp>
#include <drafts/com/sun/star/script/framework/storage/XScriptInfo.hpp>
namespace scripting_securitymgr
{
// for simplification
#define css ::com::sun::star
#define dcsssf ::drafts::com::sun::star::script::framework
struct StoragePerm {
rtl::OUString scriptStorageURL;
sal_Int32 storageID;
sal_Bool execPermission;
};
typedef ::boost::unordered_map< ::rtl::OUString, StoragePerm, ::rtl::OUStringHash,
::std::equal_to< ::rtl::OUString > > Permission_Hash;
/**
* Class responsible for managing the ScriptSecurity.
*/
class ScriptSecurityManager
{
public:
explicit ScriptSecurityManager(
const css::uno::Reference< css::uno::XComponentContext > & xContext )
throw ( css::uno::RuntimeException );
~ScriptSecurityManager();
void addScriptStorage( rtl::OUString scriptStorageURL, sal_Int32 storageID)
throw ( css::uno::RuntimeException );
/**
* checks to see if the requested permission can be granted
* checks to see whether the requested ScriptPeremission is allowed.
*/
void checkPermission( const rtl::OUString & scriptStorageURL,
const rtl::OUString & permissionRequest )
throw ( css::uno::RuntimeException, css::lang::IllegalArgumentException,
css::security::AccessControlException );
void removePermissionSettings ( ::rtl::OUString & scriptStorageURL );
private:
void readConfiguration() throw (css::uno::RuntimeException);
short executeDialog ( const rtl::OUString & path )
throw (css::uno::RuntimeException);
short executeStandardDialog()
throw ( css::uno::RuntimeException );
short executePathDialog(const rtl::OUString & path)
throw ( css::uno::RuntimeException );
void addToSecurePaths ( const rtl::OUString & path )
throw (css::uno::RuntimeException);
bool isSecureURL( const rtl::OUString & path );
css::uno::Reference< css::uno::XComponentContext > m_xContext;
sal_Bool m_confirmationRequired;
sal_Bool m_warning;
sal_Int32 m_runMacroSetting;
css::uno::Reference< css::lang::XMultiServiceFactory > m_xConfigProvFactory;
css::uno::Sequence< rtl::OUString > m_secureURL;
Permission_Hash m_permissionSettings;
};
} // scripting_securitymgr
#endif //_FRAMEWORK_SCRIPT_SCRIPTSECURITYMANAGER_HXX_
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This diff is collapsed.
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef __SCRIPTING_STORAGE_SCRIPTSTORAGE_HXX_
#define __SCRIPTING_STORAGE_SCRIPTSTORAGE_HXX_
#include <vector>
#include <boost/unordered_map.hpp>
#include <osl/mutex.hxx>
#include <cppuhelper/implbase5.hxx> // helper for component factory
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/io/XOutputStream.hpp>
#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
#include <drafts/com/sun/star/script/framework/storage/XScriptInfoAccess.hpp>
#include <drafts/com/sun/star/script/framework/storage/XScriptStorageExport.hpp>
#include <drafts/com/sun/star/script/framework/storage/XScriptStorageRefresh.hpp>
#include <drafts/com/sun/star/script/framework/storage/XScriptInfo.hpp>
namespace scripting_impl
{
// for simplification
#define css ::com::sun::star
#define dcsssf ::drafts::com::sun::star::script::framework
//Typedefs
//=============================================================================
typedef ::std::vector< ScriptData > Datas_vec;
//-----------------------------------------------------------------------------
// function name -> ScriptData
typedef ::boost::unordered_map < ::rtl::OUString, ScriptData, ::rtl::OUStringHash,
::std::equal_to< ::rtl::OUString > > ScriptFunction_hash;
//-----------------------------------------------------------------------------
// language -> hash of function name -> ScriptData
typedef ::boost::unordered_map < ::rtl::OUString, ScriptFunction_hash,
::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > >
ScriptData_hash;
//-----------------------------------------------------------------------------
typedef ::boost::unordered_map < ::rtl::OUString,
css::uno::Reference< css::xml::sax::XExtendedDocumentHandler >,
::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > >
ScriptOutput_hash;
//-----------------------------------------------------------------------------
typedef ::boost::unordered_map < ::rtl::OUString,
::rtl::OUString, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > >
ScriptLanguages_hash;
//=============================================================================
class ScriptStorage : public
::cppu::WeakImplHelper5<
css::lang::XServiceInfo,
css::lang::XInitialization,
dcsssf::storage::XScriptInfoAccess,
dcsssf::storage::XScriptStorageExport,
dcsssf::storage::XScriptStorageRefresh >
{
public:
//Constructors and Destructors
//=========================================================================
explicit ScriptStorage(
const css::uno::Reference< css::uno::XComponentContext > & xContext )
throw ( css::uno::RuntimeException );
//-------------------------------------------------------------------------
virtual ~ScriptStorage() SAL_THROW( () );
//=========================================================================
// XServiceInfo impl
//=========================================================================
virtual ::rtl::OUString SAL_CALL getImplementationName()
throw ( css::uno::RuntimeException );
//-------------------------------------------------------------------------
virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString & ServiceName )
throw ( css::uno::RuntimeException );
//-------------------------------------------------------------------------
virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
throw ( css::uno::RuntimeException );
//-------------------------------------------------------------------------
static css::uno::Sequence< ::rtl::OUString > SAL_CALL
getSupportedServiceNames_Static();
//=========================================================================
// XInitialization impl
//=========================================================================
virtual void SAL_CALL
initialize( css::uno::Sequence< css::uno::Any > const & args )
throw ( css::uno::RuntimeException, css::uno::Exception );
//=========================================================================
//XScriptInfoAccess
//=========================================================================
/**
* Get the logical names for this storage
*
* @return sequence < ::rtl::OUString >
* The logical names
*/
virtual css::uno::Sequence< ::rtl::OUString >
SAL_CALL getScriptLogicalNames()
throw ( css::uno::RuntimeException );
//=========================================================================
/**
* Get the implementations for a given URI
*
* @param queryURI
* The URI to get the implementations for
*
* @return sequence < XScriptInfo >
* The URIs of the implementations
*/
virtual css::uno::Sequence< css::uno::Reference< dcsssf::storage::XScriptInfo > >
SAL_CALL getImplementations(
const ::rtl::OUString& queryURI )
throw ( css::lang::IllegalArgumentException, css::uno::RuntimeException );
//=========================================================================
/**
* Get all script implementations
*
*
* @return sequence < XScriptInfo >
* script implementations
*/
virtual css::uno::Sequence< css::uno::Reference< dcsssf::storage::XScriptInfo > >
SAL_CALL getAllImplementations()
throw ( css::uno::RuntimeException );
//=========================================================================
/**
* Save the scripts stored in the ScriptStorage into the corresponding
* area (document or application)
*/
void SAL_CALL save()
throw ( css::uno::RuntimeException );
//=========================================================================
/**
* Refresh the ScriptStorage from the data stored in the corresponding area
* (document or application).
*/
void SAL_CALL refresh()
throw ( css::uno::RuntimeException );
//=========================================================================
private:
css::uno::Reference< css::uno::XComponentContext > m_xContext;
css::uno::Reference< css::ucb::XSimpleFileAccess > m_xSimpleFileAccess;
css::uno::Reference< css::lang::XMultiComponentFactory > m_xMgr;
::std::vector < ::rtl::OUString > mv_logicalNames;
static ScriptLanguages_hash* mh_scriptLangs;
ScriptData_hash mh_implementations;
ScriptOutput_hash mh_parcels;
sal_Int32 m_scriptStorageID;
::rtl::OUString m_stringUri;
osl::Mutex m_mutex;
bool m_bInitialised;
void updateMaps( const Datas_vec & vScriptDatas );
void writeMetadataHeader(
css::uno::Reference < css::xml::sax::XExtendedDocumentHandler > & xExDocHandler );
void create ()
throw (css::uno::RuntimeException, css::uno::Exception);
void createForFilesystem ( const ::rtl::OUString & scriptLanguage )
throw (css::uno::RuntimeException, css::uno::Exception);
::rtl::OUString getFileExtension ( const ::rtl::OUString & stringUri );
}; // class ScriptingStorage
} // namespace scripting_impl
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef _DRAFTS_COM_SUN_STAR_SCRIPT_FRAMEWORK_STORAGE_SCRIPTSTORAGEMANAGER_HXX_
#define _DRAFTS_COM_SUN_STAR_SCRIPT_FRAMEWORK_STORAGE_SCRIPTSTORAGEMANAGER_HXX_
#include <boost/unordered_map.hpp>
#include <map>
#include <osl/mutex.hxx>
#include <cppuhelper/implbase4.hxx>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XEventListener.hpp>
#include <com/sun/star/lang/IllegalArgumentException.hpp>
#include <com/sun/star/security/AccessControlException.hpp>
#include <com/sun/star/uno/RuntimeException.hpp>
#include <drafts/com/sun/star/script/framework/storage/XScriptStorageManager.hpp>
#include <drafts/com/sun/star/script/framework/storage/XScriptStorageRefresh.hpp>
#include <drafts/com/sun/star/script/framework/storage/XScriptInfo.hpp>
#include <drafts/com/sun/star/script/framework/security/XScriptSecurity.hpp>
#include "ScriptSecurityManager.hxx"
namespace scripting_impl
{
// for simplification
#define css ::com::sun::star
#define dcsssf ::drafts::com::sun::star::script::framework
// Define a map used to store the ScriptingStorages key;d by ID
typedef ::std::map < sal_Int32, css::uno::Reference < css::uno::XInterface > >
ScriptStorage_map;
typedef ::boost::unordered_map < ::rtl::OUString, sal_Int32, ::rtl::OUStringHash>
StorageId_hash;
class ScriptStorageManager : public
::cppu::WeakImplHelper4 < dcsssf::storage::XScriptStorageManager,
dcsssf::security::XScriptSecurity, css::lang::XServiceInfo,
css::lang::XEventListener >
{
public:
explicit ScriptStorageManager(
const css::uno::Reference< css::uno::XComponentContext > & xContext )
SAL_THROW ( ( css::uno::RuntimeException ) );
~ScriptStorageManager() SAL_THROW ( () );
// XServiceInfo implementation
//======================================================================
virtual ::rtl::OUString SAL_CALL getImplementationName()
throw( css::uno::RuntimeException );
//----------------------------------------------------------------------
virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
throw( css::uno::RuntimeException );
//----------------------------------------------------------------------
virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
throw( css::uno::RuntimeException );
//======================================================================
//XScriptStorageManager
//======================================================================
/**
create a ScriptStorage using the XSimpleFileAccess passed as an
argument, and return a ID for getting the associated ScriptStorage
@params xSFA
an implementation of XSimpleFileAccess that knows its own base URL
and can thus take URLs relative to that base.
@returns an unsigned short ScriptStorage ID, which can be used in the
getScriptStorage method
*/
virtual sal_Int32 SAL_CALL createScriptStorage(
const css::uno::Reference< css::ucb::XSimpleFileAccess > & xSFA )
throw ( css::uno::RuntimeException );
//----------------------------------------------------------------------
/**
create a ScriptStorage using the XSimpleFileAccess, and a string URL
and return a ID for getting the associated ScriptStorage
@params xSFA
a standard implementation of XSimpleFileAccess
@params stringURI
a string URI to the head of the script storage
@returns an unsigned short ScriptStorage ID, which can be used in the
getScriptStorage method
*/
virtual sal_Int32 SAL_CALL
createScriptStorageWithURI(
const css::uno::Reference< css::ucb::XSimpleFileAccess >& xSFA,
const ::rtl::OUString& stringURI )
throw ( css::uno::RuntimeException );
//----------------------------------------------------------------------
/**
get a ScriptStorage component using its scriptStorageID
@params scriptStorageID
the usigned short returned by one of the methods above. ID=0 is
reserved for the application/share scripts, and ID=1 is reserved
for the application/user scripts
@returns an XInterface to a component that implements the ScriptStorage
service
*/
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getScriptStorage(
sal_Int32 scriptStorageID )
throw ( css::uno::RuntimeException );
/**
get a ScriptStorage ID using storage URI
@param scriptStorageURI
the file URL for the document will retrieve storage id for the document, special treatment is reserved for the strings "USER"and "SHARE" which
retrieve storage id for application/user application/share areas respectively.
@returns as long ScriptStorage ID (-1 if no storage exists), which can be used in getScriptStorage method.
*/
virtual sal_Int32 SAL_CALL getScriptStorageID( const ::rtl::OUString& scriptStorageURI )
throw (::com::sun::star::uno::RuntimeException);
/**
refresh a storage component using its URI
@param StringURI
URI of storage area, for documents, url to document eg, file:///home/user/ADocument.sxw To refresh the storage for user or share area, use USER or SHARE respectively instead or a url.
*/
virtual void SAL_CALL refreshScriptStorage(const ::rtl::OUString & stringURI)
throw ( css::uno::RuntimeException );
//======================================================================
//XScriptSecurity
//======================================================================
//----------------------------------------------------------------------
/**
the language independent interface for invocation
@param scriptURI
a string containing the script URI
@returns
the value returned from the function being invoked
@throws IllegalArgumentException
if there is no matching script name
*/
virtual void SAL_CALL ScriptStorageManager::checkPermission(
const rtl::OUString & scriptStorageURI,
const rtl::OUString & permissionRequest )
throw ( css::uno::RuntimeException, css::lang::IllegalArgumentException,
css::security::AccessControlException );
//======================================================================
//XEventListener
//======================================================================
virtual void SAL_CALL disposing( const css::lang::EventObject& Source )
throw ( css::uno::RuntimeException );
private:
ScriptStorageManager( const ScriptStorageManager & );
ScriptStorageManager& operator= ( const ScriptStorageManager & );
void removeScriptDocURIHashEntry( const ::rtl::OUString & origURI );
// to obtain other services if needed
css::uno::Reference< css::uno::XComponentContext > m_xContext;
css::uno::Reference< css::lang::XMultiComponentFactory > m_xMgr;
::osl::Mutex m_mutex;
ScriptStorage_map m_ScriptStorageMap;
StorageId_hash m_StorageIdOrigURIHash;
sal_Int32 m_count;
scripting_securitymgr::ScriptSecurityManager m_securityMgr;
void setupAppStorage( const css::uno::Reference< css::util::XMacroExpander > & xME,
const ::rtl::OUString & storageStr,
const ::rtl::OUString & appStr)
SAL_THROW ( ( css::uno::RuntimeException ) );
sal_Int32 setupAnyStorage(
const css::uno::Reference< css::ucb::XSimpleFileAccess> & xSFA,
const ::rtl::OUString & storageStr,
const ::rtl::OUString & origStringURI )
SAL_THROW ( ( css::uno::RuntimeException ) );
};
} // scripting_impl
#endif //_COM_SUN_STAR_SCRIPTING_STORAGE_SCRIPTSTORAGEMANAGER_HXX_
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_scripting.hxx"
#include <osl/diagnose.h>
#include <osl/file.h>
#ifdef _DEBUG
#include <stdio.h>
#endif
//Local headers
#include "ScriptURI.hxx"
#include <util/util.hxx>
using namespace ::rtl;
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
namespace scripting_impl {
static const OUString schema(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.script://"));
/**
* Constructor
*
* @param scriptURI the string script URI
*/
ScriptURI::ScriptURI( const ::rtl::OUString& scriptURI )
throw ( IllegalArgumentException ) : m_uri( scriptURI )
{
OSL_TRACE( "received uri: %s\n",::rtl::OUStringToOString( m_uri, RTL_TEXTENCODING_ASCII_US).pData->buffer );
set_values( parseIt() );
if( !isValid() )
{
OSL_TRACE( "ScriptURI ctor: throwing IllegalArgException" );
throw IllegalArgumentException(
OUSTR( "Failed to parse invalid URI: " ).concat( scriptURI ),
Reference < XInterface > (), 1 );
}
}
/**
* Destuctor
*
*/
// dtor should never throw exceptions, so ensure this by specifying it
ScriptURI::~ScriptURI() SAL_THROW( () )
{
OSL_TRACE( "< ScriptURI dtor called >\n" );
}
/**
* This function is used to determine if this object represents a valid URI
*
*/
bool ScriptURI::isValid( ) {
return ( m_valid == sal_True );
}
/**
* This function returns the location of the script
*
*/
::rtl::OUString ScriptURI::getLocation( )
{
return m_location;
}
/**
* This function returns the language of the script, eg. java, StarBasic,...
*
*/
::rtl::OUString ScriptURI::getLanguage( )
{
return m_language;
}
/**
* This function returns the language dependent function name of the script
*
*/
::rtl::OUString ScriptURI::getFunctionName( )
{
return m_functionName;
}
/**
* This function returns the language independent logical name of the script
*
*/
::rtl::OUString ScriptURI::getLogicalName( )
{
return m_logicalName;
}
/**
* This function returns the full URI
*
*/
::rtl::OUString ScriptURI::getURI( )
{
return m_uri;
}
//Private mutex guarded method for setting the members
void ScriptURI::set_values( scripting_impl::Uri values )
{
osl::Guard< ::osl::Mutex > aGuard( m_mutex );
m_valid = values.valid;
m_location = values.location;
m_language = values.language;
// format is vnd.sun.star.script://[function_name]?language=[languge]&location=[location]
// LogicalName is now not used anymore, further more the ScriptURI class
// will be retired also and a new UNO service will be used. Additionally the
// parcel-description will also need to be modified to remove logical name
// In order to temporarly support the existing code functionname is
// set to the logica name parsed by this class. So getLogicalName() and
// getFunctionName() return identical string.
m_functionName = values.logicalName;
m_logicalName = values.logicalName;
}
/**
* This is a private method used for parsing the URI received by the
* initialization.
*
*/
// rather naive parsing?
Uri ScriptURI::parseIt()
{
sal_Int32 schemaLen = schema.getLength();
scripting_impl::Uri results;
results.valid = sal_True;
//attempt to parse
// check that it starts vnd.sun.star.script
// better check for OBO errors here
if( m_uri.indexOf( schema ) != 0 )
{
OSL_TRACE( "wrong schema" );
results.valid=sal_False;
return results;
}
// substr from here to the '?' and set the logical name
sal_Int32 len = m_uri.indexOf( '?' );
if( len == -1 )
{
// no queries so just set the logical name
results.logicalName = m_uri.copy( schemaLen );
return results;
}
results.logicalName = m_uri.copy( schemaLen, len-schemaLen );
OSL_TRACE( "log name: %s\n", ::rtl::OUStringToOString( results.logicalName,
RTL_TEXTENCODING_ASCII_US ).pData->buffer );
len++;
// now get the attributes
OUString attr;
do
{
attr = m_uri.getToken( 0, '&', len );
OSL_TRACE( "chunk: %s\n", ::rtl::OUStringToOString( attr,
RTL_TEXTENCODING_ASCII_US ).pData->buffer );
if( attr.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "language" ) )
== sal_True )
{
sal_Int32 len2 = attr.indexOf('=');
results.language = attr.copy( len2 + 1 );
continue;
}
else if ( attr.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "location" ) )
== sal_True )
{
sal_Int32 len2 = attr.indexOf( '=' );
results.location = attr.copy( len2 + 1 );
continue;
}
else if ( attr.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "function" ) )
== sal_True )
{
sal_Int32 len2 = attr.indexOf( '=' );
results.functionName = attr.copy( len2 + 1 );
continue;
}
else
{
OSL_TRACE( "Unknown attribute?\n" );
}
}
while ( len >= 0 );
// parse is good
return results;
}
} // namespace script_uri
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef __FRAMEWORK_STORAGE_SCRIPTURI_HXX_
#define __FRAMEWORK_STORAGE_SCRIPTURI_HXX_
#include <osl/mutex.hxx>
#include <rtl/ustring>
#include <com/sun/star/lang/IllegalArgumentException.hpp>
namespace scripting_impl {
// for simplification
#define css ::com::sun::star
#define dcsssf ::drafts::com::sun::star::script::framework
struct Uri {
bool valid;
::rtl::OUString uri;
::rtl::OUString location;
::rtl::OUString language;
::rtl::OUString functionName;
::rtl::OUString logicalName;
};
/**
* Helper class for dealing with script URIs.
*/
class ScriptURI
{
public:
ScriptURI( const ::rtl::OUString& scriptURI )
throw ( css::lang::IllegalArgumentException );
virtual ~ScriptURI() SAL_THROW ( () );
/**
* This function returns the location of the script
*
*/
virtual ::rtl::OUString getLocation();
/**
* This function returns the language of the script, eg. java,
* StarBasic,...
*
*/
virtual ::rtl::OUString getLanguage();
/**
* This function returns the language dependent function name of
* the script
*/
virtual ::rtl::OUString getFunctionName();
/**
* This function returns the language independent logical name of
* the script
*/
virtual ::rtl::OUString getLogicalName();
/**
* This function returns the full URI
*
*/
virtual ::rtl::OUString getURI();
private:
::osl::Mutex m_mutex;
/** @internal */
sal_Bool m_valid;
//the private strings
/** the string representation of the this objects URI */
::rtl::OUString m_uri;
/** the location of the script referred to by this URI */
::rtl::OUString m_location;
/** the language of the script referred to by this URI */
::rtl::OUString m_language;
/** the language dependent function name of the script referred to by this URI */
::rtl::OUString m_functionName;
/** the language independent logical name of the script referred to by this URI */
::rtl::OUString m_logicalName;
//attempt to parse the URI provided
/** @internal */
Uri parseIt();
//set the members
/** @internal */
void set_values( Uri );
bool isValid();
}
; // class ScriptURI
} //namespace script_uri
#endif // define __FRAMEWORK_STORAGE_SCRIPTURI_HXX_
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_scripting.hxx"
#include "XMLElement.hxx"
#include <osl/diagnose.h>
using namespace com::sun::star;
using namespace com::sun::star::uno;
using ::rtl::OUString;
using ::rtl::OUStringToOString;
namespace scripting_impl
{
//*************************************************************************
void XMLElement::addAttribute( OUString const & rAttrName, OUString const & rValue )
SAL_THROW( () )
{
OSL_TRACE( "XMLElement::addAttribute\n" );
_attrNames.push_back( rAttrName );
_attrValues.push_back( rValue );
}
//*************************************************************************
void XMLElement::addSubElement( Reference< xml::sax::XAttributeList > const & xElem )
SAL_THROW( () )
{
OSL_TRACE( "XMLElement::addSubElement\n" );
_subElems.push_back( xElem );
}
//*************************************************************************
Reference< xml::sax::XAttributeList > XMLElement::getSubElement( sal_Int32 nIndex )
SAL_THROW( () )
{
OSL_TRACE( "XMLElement::getSubElement\n" );
return _subElems[ ( size_t )nIndex ];
}
//*************************************************************************
void XMLElement::dumpSubElements( Reference< xml::sax::XExtendedDocumentHandler > const & xOut )
{
OSL_TRACE( "+++++ XMLElement::dumpSubElement\n" );
for ( size_t nPos = 0; nPos < _subElems.size(); ++nPos )
{
XMLElement * pElem = static_cast< XMLElement * >( _subElems[ nPos ].get() );
pElem->dump( xOut );
}
}
//*************************************************************************
void XMLElement::dump( Reference< xml::sax::XExtendedDocumentHandler > const & xOut )
{
OSL_TRACE( "XMLElement::dump" );
xOut->ignorableWhitespace( OUString() );
OSL_TRACE( "XMLElement::dump starting %s",::rtl::OUStringToOString(
_name, RTL_TEXTENCODING_ASCII_US ).pData->buffer );
xOut->startElement( _name, static_cast< xml::sax::XAttributeList * >( this ) );
// Write out CDATA
if( _chars.getLength() > 0 )
{
xOut->ignorableWhitespace( OUString() );
xOut->characters( _chars );
}
// write sub elements
dumpSubElements( xOut );
xOut->ignorableWhitespace( OUString() );
xOut->endElement( _name );
OSL_TRACE( "XMLElement::dump ending %s",::rtl::OUStringToOString(
_name, RTL_TEXTENCODING_ASCII_US ).pData->buffer );
}
//*************************************************************************
// XAttributeList
sal_Int16 XMLElement::getLength()
throw ( RuntimeException )
{
OSL_TRACE( "XMLElement::getLength\n" );
return _attrNames.size();
}
//*************************************************************************
OUString XMLElement::getNameByIndex( sal_Int16 nPos )
throw ( RuntimeException )
{
OSL_TRACE( "XMLElement::getNameByIndex\n" );
OSL_ASSERT( ( size_t )nPos < _attrNames.size() );
return _attrNames[ nPos ];
}
//*************************************************************************
OUString XMLElement::getTypeByIndex( sal_Int16 nPos )
throw ( RuntimeException )
{
OSL_TRACE( "XMLElement::getTypeByIndex\n" );
OSL_ASSERT( (size_t)nPos < _attrNames.size() );
// xxx todo
return OUString();
}
//*************************************************************************
OUString XMLElement::getTypeByName( OUString const & rName )
throw ( RuntimeException )
{
OSL_TRACE( "XMLElement::getTypeByName\n" );
// xxx todo
return OUString();
}
//*************************************************************************
OUString XMLElement::getValueByIndex( sal_Int16 nPos )
throw ( RuntimeException )
{
OSL_TRACE( "XMLElement::getValueByIndex\n" );
OSL_ASSERT( ( size_t )nPos < _attrNames.size() );
return _attrValues[ nPos ];
}
//*************************************************************************
OUString XMLElement::getValueByName( OUString const & rName )
throw ( RuntimeException )
{
OSL_TRACE( "XMLElement::getValueByName\n" );
for ( size_t nPos = 0; nPos < _attrNames.size(); ++nPos )
{
if (_attrNames[ nPos ] == rName)
{
return _attrValues[ nPos ];
}
}
return OUString();
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef _SCRIPTING_XML_ELEMENT_HXX_
#define _SCRIPTING_XML_ELEMENT_HXX_
#include <vector>
#include <cppuhelper/implbase1.hxx>
#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
namespace scripting_impl
{
// for simplification
#define css ::com::sun::star
#define dcsssf ::drafts::com::sun::star::script::framework
/*##################################################################################################
EXPORTING
##################################################################################################*/
//==================================================================================================
class XMLElement : public ::cppu::WeakImplHelper1< css::xml::sax::XAttributeList >
{
public:
inline XMLElement( ::rtl::OUString const & name, ::rtl::OUString const & chars )
SAL_THROW( () )
: _name( name ), _chars( chars )
{
}
inline XMLElement( ::rtl::OUString const & name )
SAL_THROW( () )
: _name( name )
{
}
/** Adds a sub element of element.
@param xElem element reference
*/
void SAL_CALL addSubElement(
css::uno::Reference< css::xml::sax::XAttributeList > const & xElem )
SAL_THROW( () );
/** Gets sub element of given index. The index follows order in which sub elements were added.
@param nIndex index of sub element
*/
css::uno::Reference< css::xml::sax::XAttributeList > SAL_CALL getSubElement(
sal_Int32 nIndex )
SAL_THROW( () );
/** Adds an attribute to elements.
@param rAttrName qname of attribute
@param rValue value string of element
*/
void SAL_CALL addAttribute( ::rtl::OUString const & rAttrName,
::rtl::OUString const & rValue )
SAL_THROW( () );
/** Gets the tag name (qname) of element.
@return
qname of element
*/
inline ::rtl::OUString SAL_CALL getName() SAL_THROW( () )
{
return _name;
}
/** Dumps out element (and all sub elements).
@param xOut document handler to be written to
*/
void SAL_CALL dump(
css::uno::Reference< css::xml::sax::XExtendedDocumentHandler > const & xOut );
/** Dumps out sub elements (and all further sub elements).
@param xOut document handler to be written to
*/
void SAL_CALL dumpSubElements(
css::uno::Reference< css::xml::sax::XExtendedDocumentHandler > const & xOut );
// XAttributeList
virtual sal_Int16 SAL_CALL getLength()
throw ( css::uno::RuntimeException );
virtual ::rtl::OUString SAL_CALL getNameByIndex( sal_Int16 nPos )
throw ( css::uno::RuntimeException );
virtual ::rtl::OUString SAL_CALL getTypeByIndex( sal_Int16 nPos )
throw ( css::uno::RuntimeException );
virtual ::rtl::OUString SAL_CALL getTypeByName( ::rtl::OUString const & rName )
throw ( css::uno::RuntimeException );
virtual ::rtl::OUString SAL_CALL getValueByIndex( sal_Int16 nPos )
throw ( css::uno::RuntimeException );
virtual ::rtl::OUString SAL_CALL getValueByName( ::rtl::OUString const & rName )
throw ( css::uno::RuntimeException );
protected:
::rtl::OUString _name;
::rtl::OUString _chars;
::std::vector< ::rtl::OUString > _attrNames;
::std::vector< ::rtl::OUString > _attrValues;
::std::vector< css::uno::Reference<
css::xml::sax::XAttributeList > > _subElems;
};
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
component_getImplementationEnvironment
component_getFactory
#*************************************************************************
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# Copyright 2000, 2010 Oracle and/or its affiliates.
#
# OpenOffice.org - a multi-platform office productivity suite
#
# This file is part of OpenOffice.org.
#
# OpenOffice.org is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# only, as published by the Free Software Foundation.
#
# OpenOffice.org is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License version 3 for more details
# (a copy is included in the LICENSE file that accompanied this code).
#
# You should have received a copy of the GNU Lesser General Public License
# version 3 along with OpenOffice.org. If not, see
# <http://www.openoffice.org/license.html>
# for a copy of the LGPLv3 License.
#
#*************************************************************************
PRJ=..$/..
PRJNAME= scripting
TARGET= storage
USE_DEFFILE= TRUE
ENABLE_EXCEPTIONS=TRUE
COMP1TYPELIST=$(TARGET)
# --- Settings -----------------------------------------------------
.INCLUDE : settings.mk
# ------------------------------------------------------------------
SLOFILES=\
$(SLO)$/ScriptURI.obj\
$(SLO)$/ScriptStorage.obj\
$(SLO)$/ScriptInfo.obj\
$(SLO)$/ScriptMetadataImporter.obj\
$(SLO)$/ScriptElement.obj\
$(SLO)$/XMLElement.obj\
$(SLO)$/ScriptStorageManager.obj\
$(SLO)$/ScriptSecurityManager.obj\
# --- Targets ------------------------------------------------------
.INCLUDE : target.mk
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd">
<module-description xmlns:xlink="http://www.w3.org/1999/xlink">
<module-name>storage</module-name>
<component-description>
<author></author>
<name>drafts.com.sun.star.script.framework.storage.ScriptStorage</name>
<description></description>
<loader-name>com.sun.star.loader.SharedLibrary</loader-name>
<language>c++</language>
<status value="draft"/>
<supported-service>drafts.com.sun.star.script.framework.storage.ScriptingStorage</supported-service>
<type>com.sun.star.beans.XPropertySet</type>
<type>com.sun.star.beans.XPropertyContainer</type>
<type>com.sun.star.uno.Exception</type>
<type>com.sun.star.uno.XComponentContext</type>
<type>com.sun.star.uno.XWeak</type>
<type>com.sun.star.io.IOException</type>
<type>com.sun.star.io.XStream</type>
<type>com.sun.star.io.XOutputStream</type>
<type>com.sun.star.registry.XRegistryKey</type>
<type>drafts.com.sun.star.script.framework.storage.XScriptInfo</type>
<type>drafts.com.sun.star.script.framework.storage.XScriptInfoAccess</type>
<type>drafts.com.sun.star.script.framework.security.XScriptSecurity</type>
<type>drafts.com.sun.star.script.framework.storage.XScriptStorageExport</type>
<type>drafts.com.sun.star.script.framework.storage.XScriptStorageRefresh</type>
<type>com.sun.star.lang.XInitialization</type>
<type>drafts.com.sun.star.script.framework.storage.XScriptStorageManager</type>
<type>com.sun.star.xml.sax.XExtendedDocumentHandler</type>
<type>com.sun.star.xml.sax.XParser</type>
<type>com.sun.star.io.XInputStream</type>
<type>com.sun.star.ucb.XSimpleFileAccess2</type>
<type>com.sun.star.xml.sax.SAXException</type>
<type>com.sun.star.xml.sax.XAttributeList</type>
<type>com.sun.star.io.XActiveDataSource</type>
<type>com.sun.star.security.AccessControlException</type>
<type>com.sun.star.security.RuntimePermission</type>
<type>com.sun.star.lang.IllegalArgumentException</type>
</component-description>
<project-build-dependency>cppuhelper</project-build-dependency>
<project-build-dependency>cppu</project-build-dependency>
<project-build-dependency>sal</project-build-dependency>
<runtime-module-dependency>cppuhelper2$(COM)</runtime-module-dependency>
<runtime-module-dependency>cppu2</runtime-module-dependency>
<runtime-module-dependency>sal2</runtime-module-dependency>
<runtime-module-dependency>ucb</runtime-module-dependency>
</module-description>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment