/* -*- 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 .
*/
bool SvXMLEmbeddedObjectHelper::ImplGetStorageNames( const OUString& rURLStr,
OUString& rContainerStorageName,
OUString& rObjectStorageName, bool bInternalToExternal, bool *pGraphicRepl, bool *pOasisFormat ) const
{ // internal URL: vnd.sun.star.EmbeddedObject:<object-name> // or: vnd.sun.star.EmbeddedObject:<path>/<object-name> // internal replacement images: // vnd.sun.star.EmbeddedObjectGraphic:<object-name> // or: vnd.sun.star.EmbeddedObjectGraphic:<path>/<object-name> // external URL: ./<path>/<object-name> // or: <path>/<object-name> // or: <object-name> // currently, path may only consist of a single directory name // it is also possible to have additional arguments at the end of URL: <main URL>[?<name>=<value>[,<name>=<value>]*]
if( pGraphicRepl )
*pGraphicRepl = false;
if( pOasisFormat )
*pOasisFormat = true; // the default value
if( rURLStr.isEmpty() ) returnfalse;
// get rid of arguments
sal_Int32 nPos = rURLStr.indexOf( '?' );
OUString aURLNoPar; if ( nPos == -1 )
aURLNoPar = rURLStr; else
{
aURLNoPar = rURLStr.copy( 0, nPos );
// check the arguments
nPos++; while( nPos >= 0 && nPos < rURLStr.getLength() )
{
OUString aToken = rURLStr.getToken( 0, ',', nPos ); if ( aToken.equalsIgnoreAsciiCase( "oasis=false" ) )
{ if ( pOasisFormat )
*pOasisFormat = false; break;
} else
{
SAL_WARN( "svx", "invalid arguments was found in URL!" );
}
}
}
// Is the object name unique? // if the object is already instantiated by GetEmbeddedObject // that means that the duplication is being loaded bool bDuplicate = rContainer.HasInstantiatedEmbeddedObject( rObjName );
DBG_ASSERT( !bDuplicate, "An object in the document is referenced twice!" );
if( xDocStor != xCntnrStor || pTemp || bDuplicate )
{ // TODO/LATER: make this altogether a method in the EmbeddedObjectContainer
// create a unique name for the duplicate object if( bDuplicate )
rObjName = rContainer.CreateUniqueObjectName();
// TODO/LATER: what to do when other types of objects are based on substream persistence? // This is an ole object
uno::Reference< beans::XPropertySet > xProps( xStm, uno::UNO_QUERY ); if (xProps)
{
xProps->setPropertyValue(
u"MediaType"_ustr,
uno::Any( u"application/vnd.sun.star.oleobject"_ustr ) );
// make object known to the container // TODO/LATER: could be done a little bit more efficient!
OUString aName( rObjName );
// TODO/LATER: The provided pClassId is ignored for now. // The stream contains OLE storage internally and this storage already has a class id specifying the // server that was used to create the object. pClassId could be used to specify the server that should // be used for the next opening, but this information seems to be out of the file format responsibility // area.
OUString const baseURL(mpDocPersist->getDocumentBaseURL());
rContainer.GetEmbeddedObject(aName, &baseURL);
}
if( xObj.is() )
{ try
{ bool bSwitchBackToLoaded = false;
sal_Int32 nCurState = xObj->getCurrentState(); if ( nCurState == embed::EmbedStates::LOADED || nCurState == embed::EmbedStates::RUNNING )
{ // means that the object is not active // copy replacement image from old to new container
OUString aMediaType;
xStream = mpDocPersist->getEmbeddedObjectContainer().GetGraphicStream( xObj, &aMediaType );
}
if ( !xStream.is() )
{ // the image must be regenerated // TODO/LATER: another aspect could be used if ( nCurState == embed::EmbedStates::LOADED )
bSwitchBackToLoaded = true;
if ( bSwitchBackToLoaded ) // switch back to loaded state; that way we have a minimum cache confusion
xObj->changeState( embed::EmbedStates::LOADED );
} catch( uno::Exception& )
{}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.