/* -*- 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 .
*/
void OCommonEmbeddedObject::LinkInit_Impl( const uno::Sequence< beans::NamedValue >& aObjectProps, const uno::Sequence< beans::PropertyValue >& aMediaDescr, const uno::Sequence< beans::PropertyValue >& aObjectDescr )
{ // setPersistance has no effect on own links, so the complete initialization must be done here
if(m_bIsLinkURL && !m_bReadOnly)
{ // tdf#141529 we have a linked OLE object. To prevent the original OLE // data to be changed each time the OLE gets changed (at deactivate), copy it to // a temporary file. That file will be changed on activated OLE changes then. // The moment the original gets changed itself will now be associated with the // file/document embedding the OLE being changed (see other additions to the // task-ID above) // // open OLE original data as read input file if ( comphelper::DirectoryHelper::fileExists( m_aLinkURL ) )
{ // create temporary file
m_aLinkTempFile = io::TempFile::create( m_xContext );
void OCommonEmbeddedObject::requestPositioning( const awt::Rectangle& aRect )
{ // the method is called in case object is inplace active and the object window was resized
OSL_ENSURE( m_xClientSite.is(), "The client site must be set for inplace active object!" ); if ( !m_xClientSite.is() ) return;
OSL_ENSURE( xInplaceClient.is(), "The client site must support XInplaceClient to allow inplace activation!" ); if ( xInplaceClient.is() )
{ try {
xInplaceClient->changedPlacement( aRect );
} catch( const uno::Exception& )
{
TOOLS_WARN_EXCEPTION( "embeddedobj", "Exception on request to resize!" );
}
}
}
void OCommonEmbeddedObject::handleLinkedOLE( CopyBackToOLELink eState )
{ // do not refresh and autosave at the same time // when refresh all, then get both Link and Ole Update, in this case ignore OLE-refresh if ( m_bInHndFunc || m_bOleUpdate || !m_aLinkTempFile.is() ) return;
if ( eState != CopyBackToOLELink::CopyLinkToTempInit && !bLnkFileChg && !bTmpFileChg )
{ // no changes
eState = CopyBackToOLELink::NoCopy;
} elseif ( ( eState == CopyBackToOLELink::CopyTempToLink ) && bLnkFileChg && !bTmpFileChg )
{ // Save pressed, but the Link-file is changed, but not the temp-file // in this case update the object with new link data
eState = CopyBackToOLELink::CopyLinkToTempRefresh;
} elseif ( ( eState == CopyBackToOLELink::CopyTempToLink ) && bLnkFileChg && bTmpFileChg )
{ // Save pressed, but the Link-file is changed, question to user for overwrite if ( ShowMsgDialog(STR_OVERWRITE_LINK, m_aLinkURL) == RET_CANCEL )
eState = CopyBackToOLELink::NoCopy;
} elseif ( ( eState == CopyBackToOLELink::CopyLinkToTemp ) && bTmpFileChg )
{ // Refresh pressed, but the Temp-file is changed, question to user for overwrite // it is not important it has bLnkFileChg, always overwrite the temp-file if ( ShowMsgDialog( STR_OVERWRITE_TEMP, m_aLinkURL ) == RET_CANCEL )
eState = CopyBackToOLELink::NoCopy;
}
// This is *needed* since OTempFileService calls OTempFileService::readBytes which // ensures the SvStream mpStream gets/is opened, *but* also sets the mnCachedPos from // OTempFileService which still points to the end-of-file (from write-cc'ing).
uno::Reference < io::XSeekable > xSeek( xInStream, uno::UNO_QUERY_THROW );
xSeek->seek( 0 );
switch ( eState )
{ case CopyBackToOLELink::NoCopy: break; case CopyBackToOLELink::CopyLinkToTemp: // copy Link-File to Temp-File (Refresh) case CopyBackToOLELink::CopyLinkToTempInit: //create temp file
writeFile( m_aLinkURL, m_aLinkTempFile->getUri() ); break; case CopyBackToOLELink::CopyTempToLink: // copy Temp-File to Link-File (Save) // tdf#141529 if we have a changed copy of the original OLE data we now // need to write it back 'over' the original OLE data
writeFile( m_aLinkTempFile->getUri(), m_aLinkURL ); break; case CopyBackToOLELink::CopyLinkToTempRefresh: // need a Refresh not save // do nothing break; default: break;
}
OUString SAL_CALL OCommonEmbeddedObject::getClassName()
{ if ( m_bDisposed ) throw lang::DisposedException();
return m_aClassName;
}
void SAL_CALL OCommonEmbeddedObject::setClassInfo( const uno::Sequence< sal_Int8 >& /*aClassID*/, const OUString& /*aClassName*/ )
{ // the object class info can not be changed explicitly throw lang::NoSupportException(); //TODO:
}
uno::Reference< util::XCloseable > SAL_CALL OCommonEmbeddedObject::getComponent()
{
SolarMutexGuard aGuard; if ( m_bDisposed ) throw lang::DisposedException(); // TODO
// add an exception if ( m_nObjectState == -1 )
{ // the object is still not loaded throw uno::RuntimeException( u"Can't store object without persistence!"_ustr, static_cast< ::cppu::OWeakObject* >(this) );
}
return m_xDocHolder->GetComponent();
}
void SAL_CALL OCommonEmbeddedObject::addStateChangeListener( const uno::Reference< embed::XStateChangeListener >& xListener )
{
SolarMutexGuard aGuard; if ( m_bDisposed ) throw lang::DisposedException(); // TODO
if ( !m_pInterfaceContainer )
m_pInterfaceContainer.reset(new comphelper::OMultiTypeInterfaceContainerHelper2( m_aMutex ));
m_bDisposed = true; // the object is disposed now for outside
// it is possible that the document can not be closed, in this case if the argument is false // the exception will be thrown otherwise in addition to exception the object must register itself // as termination listener and listen for document events
if ( m_xDocHolder.is() )
{
m_xDocHolder->CloseFrame();
// TODO: for now the storage will be disposed by the object, but after the document // will use the storage, the storage will be disposed by the document and recreated by the object if ( m_xObjectStorage.is() )
{ try {
m_xObjectStorage->dispose();
} catch ( const 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.0.23Bemerkung:
(vorverarbeitet)
¤
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 ist noch experimentell.