/* -*- 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 .
*/
/************************************************************************* |* |* Data-struct for documenttypes in listbox |*
|************************************************************************/
SvxHyperlinkNewDocTp::~SvxHyperlinkNewDocTp ()
{ if (m_xLbDocTypes)
{ for (sal_Int32 n = 0, nEntryCount = m_xLbDocTypes->n_children(); n < nEntryCount; ++n) delete weld::fromId<DocumentTypeData*>(m_xLbDocTypes->get_id(n));
m_xLbDocTypes = nullptr;
}
}
/************************************************************************* |* |* Fill the all dialog-controls except controls in groupbox "more..." |*
|************************************************************************/
//#i96822# business cards, labels and database should not be inserted here if( aDocumentUrl == "private:factory/swriter?slot=21051" ||
aDocumentUrl == "private:factory/swriter?slot=21052" ||
aDocumentUrl == "private:factory/sdatabase?Interactive" ) continue;
// Insert into listbox if ( !aDocumentUrl.isEmpty() )
{ if ( aDocumentUrl == "private:factory/simpress?slot=6686" ) // SJ: #106216# do not start
aDocumentUrl = "private:factory/simpress"; // the AutoPilot for impress
// insert private-url and default-extension as user-data
std::shared_ptr<const SfxFilter> pFilter = SfxFilter::GetDefaultFilterFromFactory( aDocumentUrl ); if ( pFilter )
{ // insert doc-name and image
OUString aTitleName = aTitle.replaceFirst( "~", "" );
/************************************************************************* |* |* retrieve and prepare data from dialog-fields |*
|************************************************************************/
void SvxHyperlinkNewDocTp::GetCurrentItemData ( OUString& rStrURL, OUString& aStrName,
OUString& aStrIntName, OUString& aStrFrame,
SvxLinkInsertMode& eMode )
{ // get data from dialog-controls
rStrURL = m_xCbbPath->get_active_text();
INetURLObject aURL; if ( ImplGetURLObject( rStrURL, m_xCbbPath->GetBaseURL(), aURL ) )
{
rStrURL = aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE );
}
// save new doc const SfxViewFrameItem *pItem = dynamic_cast<const SfxViewFrameItem*>(aResult.getItem()); // aResult is NULL if the Hyperlink if ( pItem ) // creation is cancelled #106216#
{
pViewFrame = pItem->GetFrame(); if (pViewFrame)
{
SfxStringItem aNewName( SID_FILE_NAME, xExecuteInfo->aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
SfxUnoFrameItem aDocFrame( SID_FILLFRAME, pViewFrame->GetFrame().GetFrameInterface() );
pViewFrame->GetDispatcher()->ExecuteList(
SID_SAVEASDOC, SfxCallMode::SYNCHRON,
{ &aNewName }, { &aDocFrame });
}
}
if (xExecuteInfo->bRbtEditNow)
{
css::uno::Reference<css::awt::XTopWindow> xWindow(xExecuteInfo->xFrame->getContainerWindow(), css::uno::UNO_QUERY); if (xWindow.is()) //will be false if the frame was exited while the document was loading (e.g. we waited for warning dialogs)
xWindow->toFront();
}
/************************************************************************* |* |* Any action to do after apply-button is pressed |*
\************************************************************************/ void SvxHyperlinkNewDocTp::DoApply()
{
weld::WaitObject aWait(mpDialog->getDialog());
// get data from dialog-controls
OUString aStrNewName = m_xCbbPath->get_active_text();
if ( aStrNewName.isEmpty() )
aStrNewName = maStrInitURL;
// create a real URL-String
INetURLObject aURL; if ( !ImplGetURLObject( aStrNewName, m_xCbbPath->GetBaseURL(), aURL ) ) return;
// create Document
aStrNewName = aURL.GetURLPath( INetURLObject::DecodeMechanism::NONE ); bool bCreate = true; try
{ // check if file exists, warn before we overwrite it
std::unique_ptr<SvStream> pIStm = ::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::READ );
bool bOk = pIStm && ( pIStm->GetError() == ERRCODE_NONE);
OUString aStrPath = aStrURL; bool bZeroPath = aStrPath.isEmpty(); bool bHandleFileName = bZeroPath; // when path has length of 0, then the rest should always be handled // as file name, otherwise we do not yet know
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.