Merged ooxml-sc-docpropsimp.dff from ooo-build

This commit is contained in:
Katarina Machalkova 2010-10-13 18:13:56 +02:00
parent f87f16fe09
commit afc5c31646
2 changed files with 53 additions and 0 deletions

View file

@ -198,6 +198,8 @@ public:
*/
XmlFilterBase& exportDocumentProperties( ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentProperties > xProperties );
void importDocumentProperties() throw();
protected:
virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >
implGetInputStream( ::comphelper::MediaDescriptor& rMediaDesc ) const;

View file

@ -81,6 +81,22 @@ using ::comphelper::MediaDescriptor;
using ::sax_fastparser::FastSerializerHelper;
using ::sax_fastparser::FSHelperPtr;
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
#include <com/sun/star/document/XOOXMLDocumentPropertiesImporter.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <comphelper/processfactory.hxx>
#include <comphelper/mediadescriptor.hxx>
#include <oox/core/filterdetect.hxx>
#include <comphelper/storagehelper.hxx>
using ::com::sun::star::uno::XComponentContext;
using ::com::sun::star::document::XOOXMLDocumentPropertiesImporter;
using ::com::sun::star::document::XDocumentPropertiesSupplier;
using ::com::sun::star::beans::XPropertySet;
using ::com::sun::star::lang::XComponent;
namespace oox {
namespace core {
@ -118,6 +134,22 @@ XmlFilterBaseImpl::XmlFilterBaseImpl() :
{
}
// ============================================================================
static Reference< XComponentContext > lcl_getComponentContext(Reference< XMultiServiceFactory > aFactory)
{
Reference< XComponentContext > xContext;
try
{
Reference< XPropertySet > xFactProp( aFactory, UNO_QUERY );
if( xFactProp.is() )
xFactProp->getPropertyValue( OUString::createFromAscii("DefaultContext") ) >>= xContext;
}
catch( Exception& )
{}
return xContext;
}
// ============================================================================
XmlFilterBase::XmlFilterBase( const Reference< XMultiServiceFactory >& rxGlobalFactory ) :
@ -166,6 +198,25 @@ XmlFilterBase::~XmlFilterBase()
// ----------------------------------------------------------------------------
void XmlFilterBase::importDocumentProperties() throw()
{
Reference< XMultiServiceFactory > xFactory( getGlobalFactory(), UNO_QUERY );
MediaDescriptor aMediaDesc( getMediaDescriptor() );
Reference< XInputStream > xInputStream;
::oox::core::FilterDetect aDetector( xFactory );
xInputStream = aDetector.extractUnencryptedPackage( aMediaDesc );
Reference< XComponent > xModel( getModel(), UNO_QUERY );
Reference< XComponentContext > xContext = lcl_getComponentContext(getGlobalFactory());
Reference< XStorage > xDocumentStorage (
::comphelper::OStorageHelper::GetStorageOfFormatFromInputStream( OFOPXML_STORAGE_FORMAT_STRING, xInputStream ) );
Reference< XInterface > xTemp = xContext->getServiceManager()->createInstanceWithContext(
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.OOXMLDocumentPropertiesImporter")),
xContext);
Reference< XOOXMLDocumentPropertiesImporter > xImporter( xTemp, UNO_QUERY );
Reference< XDocumentPropertiesSupplier > xPropSupplier( xModel, UNO_QUERY);
xImporter->importProperties( xDocumentStorage, xPropSupplier->getDocumentProperties() );
}
OUString XmlFilterBase::getFragmentPathFromFirstType( const OUString& rType )
{
// importRelations() caches the relations map for subsequence calls