/* -*- 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 .
*/
short SvInsertOleDlg::run()
{ short nRet = RET_OK;
SvObjectServerList aObjS; if ( !m_pServers )
{ // if no list was provided, take the complete one
aObjS.FillInsertObjects();
m_pServers = &aObjS;
}
// fill listbox and select default
m_xLbObjecttype->freeze(); for ( size_t i = 0; i < m_pServers->Count(); i++ )
m_xLbObjecttype->append_text((*m_pServers)[i].GetHumanName());
m_xLbObjecttype->thaw();
m_xLbObjecttype->select(0);
OSL_ENSURE( aNewInf.Object.is(), "The object must be created or an exception must be thrown!" );
m_xObj = aNewInf.Object; for ( constauto& opt : aNewInf.Options ) if ( opt.Name == "Icon" )
{
opt.Value >>= m_aIconMetaFile;
} elseif ( opt.Name == "IconFormat" )
{
datatransfer::DataFlavor aFlavor; if ( opt.Value >>= aFlavor )
m_aIconMediaType = aFlavor.MimeType;
}
}
} catch( ucb::CommandAbortedException& )
{ // the user has pressed cancel
} catch( uno::Exception& )
{ // TODO: Error handling
}
} else
{ // create object with desired ClassId
m_xObj = aCnt.CreateEmbeddedObject( pS->GetClassName().GetByteSequence(), aName );
}
if ( !m_xObj.is() )
{ if( !aFileName.isEmpty() ) // from OLE Dialog
{ // object couldn't be created from file // global Resource from svtools (former so3 resource)
OUString aErr(SvtResId(STR_ERROR_OBJNOCREATE_FROM_FILE));
aErr = aErr.replaceFirst( "%", aFileName );
std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(),
VclMessageType::Warning, VclButtonsType::Ok, aErr));
xBox->run();
} else
{ // object couldn't be created // global Resource from svtools (former so3 resource)
OUString aErr(SvtResId(STR_ERROR_OBJNOCREATE));
aErr = aErr.replaceFirst( "%", aServerName );
// create MediaDescriptor for file to create object from
uno::Sequence < beans::PropertyValue > aMedium{
comphelper::makePropertyValue(u"URL"_ustr, aFileName),
comphelper::makePropertyValue(u"InteractionHandler"_ustr, xInteraction)
};
// create object from media descriptor
uno::Reference<task::XStatusIndicator> xProgress; if (SfxViewFrame* pFrame = SfxViewFrame::Current())
{ // Have a current frame, create visual indication that insert is in progress.
uno::Reference<frame::XFrame> xFrame = pFrame->GetFrame().GetFrameInterface();
uno::Reference<task::XStatusIndicatorFactory> xProgressFactory(xFrame, uno::UNO_QUERY); if (xProgressFactory.is())
{
xProgress = xProgressFactory->createStatusIndicator(); if (xProgress)
{
OUString aOleInsert(CuiResId(RID_CUISTR_OLE_INSERT));
xProgress->start(aOleInsert, 100);
}
}
}
if ( !m_xObj.is() )
{ // object couldn't be created from file // global Resource from svtools (former so3 resource)
OUString aErr(SvtResId(STR_ERROR_OBJNOCREATE_FROM_FILE));
aErr = aErr.replaceFirst( "%", aFileName );
std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(),
VclMessageType::Warning, VclButtonsType::Ok, aErr));
xBox->run();
} else
{ if (m_xCbAsIcon->get_active())
{ //something nice here I guess would be to write the filename into //the image with this icon above it
Image aImage = SvFileInformationManager::GetImage(aURL, true);
SvMemoryStream aTemp;
WriteDIBBitmapEx(aImage.GetBitmapEx(), aTemp);
m_aIconMetaFile = Sequence<sal_Int8>(static_cast<const sal_Int8*>(aTemp.GetData()), aTemp.TellEnd());
m_aIconMediaType = "application/x-openoffice-bitmap;windows_formatname=\"Bitmap\"";
}
}
}
}
m_pServers = nullptr; return nRet;
}
uno::Reference< io::XInputStream > SvInsertOleDlg::GetIconIfIconified( OUString* pGraphicMediaType )
{ if ( m_aIconMetaFile.hasElements() )
{ if ( pGraphicMediaType )
*pGraphicMediaType = m_aIconMediaType;
return uno::Reference< io::XInputStream >( new ::comphelper::SequenceInputStream( m_aIconMetaFile ) );
}
bOK = true;
} catch ( uno::Exception& )
{
OSL_FAIL( "No IFrame!" );
}
} else
{
DBG_ASSERT( m_xStorage.is(), "No storage!");
bOK = m_xStorage.is();
}
if (!bOK) return RET_OK;
nRet = InsertObjectDialog_Impl::run(); if ( nRet == RET_OK )
{
OUString aURL; if (!m_xEDURL->get_text().isEmpty())
{ // URL can be a valid and absolute URL or a system file name
INetURLObject aObj;
aObj.SetSmartProtocol( INetProtocol::File ); if ( aObj.SetSmartURL( m_xEDURL->get_text() ) )
aURL = aObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
}
// set the title
aFileDlg.SetTitle(CuiResId(RID_CUISTR_SELECT_FILE_IFRAME));
// show the dialog if ( aFileDlg.Execute() == ERRCODE_NONE )
m_xEDURL->set_text(INetURLObject(aFileDlg.GetPath()).GetMainURL(INetURLObject::DecodeMechanism::WithCharset));
}
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.