/* -*- 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 .
*/
using ::com::sun::star::uno::Reference; using ::com::sun::star::beans::PropertyChangeEvent; using ::com::sun::star::uno::RuntimeException; using ::com::sun::star::frame::XFrame; using ::com::sun::star::awt::XTopWindow; using ::com::sun::star::awt::XWindow; using ::com::sun::star::uno::Exception; using ::com::sun::star::uno::UNO_QUERY_THROW; using ::com::sun::star::uno::UNO_QUERY; using ::com::sun::star::beans::PropertyValue; using ::com::sun::star::uno::Sequence; using ::com::sun::star::lang::XComponent; using ::com::sun::star::frame::XComponentLoader; using ::com::sun::star::beans::XPropertySet; using ::com::sun::star::frame::XTitle; using ::com::sun::star::lang::EventObject; using ::com::sun::star::lang::NullPointerException; using ::com::sun::star::lang::DisposedException; using ::com::sun::star::uno::XComponentContext; using ::com::sun::star::frame::XFrames; using ::com::sun::star::util::XCloseable; using ::com::sun::star::lang::XMultiServiceFactory; using ::com::sun::star::frame::XDispatchProvider; using ::com::sun::star::frame::XDispatch; using ::com::sun::star::frame::Desktop; using ::com::sun::star::frame::XDesktop2;
void SQLCommandDesigner::impl_doOpenDesignerFrame_nothrow()
{
OSL_PRECOND( !isActive(), "SQLCommandDesigner::impl_doOpenDesignerFrame_nothrow: already active!" );
OSL_PRECOND( m_xConnection.is(), "SQLCommandDesigner::impl_doOpenDesignerFrame_nothrow: this will crash!" );
osl_atomic_increment(&m_refCount);
try
{ // for various reasons, we don't want the new frame to appear in the desktop's frame list // thus, we create a blank frame at the desktop, remove it from the desktop's frame list // immediately, and then load the component into this blank (and now parent-less) frame
Reference< XComponentLoader > xLoader( impl_createEmptyParentlessTask_nothrow(), UNO_QUERY_THROW ); constbool bEscapeProcessing = m_xObjectAdapter->getEscapeProcessing();
Sequence< PropertyValue > aArgs{
comphelper::makePropertyValue(PROPERTY_ACTIVE_CONNECTION, m_xConnection.getTyped()),
comphelper::makePropertyValue(PROPERTY_COMMAND, m_xObjectAdapter->getSQLCommand()),
comphelper::makePropertyValue(PROPERTY_COMMANDTYPE, CommandType::COMMAND),
comphelper::makePropertyValue(PROPERTY_ESCAPE_PROCESSING, bEscapeProcessing),
comphelper::makePropertyValue(u"GraphicalDesign"_ustr, bEscapeProcessing)
};
// remember this newly loaded component - we need to care for it e.g. when we're suspended
m_xDesigner.set(xQueryDesign, css::uno::UNO_QUERY);
OSL_ENSURE( m_xDesigner.is() || !xQueryDesign.is(), "SQLCommandDesigner::impl_doOpenDesignerFrame_nothrow: the component is expected to be a controller!" ); if ( m_xDesigner.is() )
{
Reference< XPropertySet > xQueryDesignProps( m_xDesigner, UNO_QUERY );
OSL_ENSURE( xQueryDesignProps.is(), "SQLCommandDesigner::impl_doOpenDesignerFrame_nothrow: the controller should have properties!" ); if ( xQueryDesignProps.is() )
{
xQueryDesignProps->addPropertyChangeListener( PROPERTY_ACTIVECOMMAND, this );
xQueryDesignProps->addPropertyChangeListener( PROPERTY_ESCAPE_PROCESSING, this );
}
}
// get the frame which we just opened and set its title
Reference< XTitle> xTitle(xQueryDesign,UNO_QUERY); if ( xTitle.is() )
{
OUString sDisplayName = PcrRes(RID_RSC_ENUM_COMMAND_TYPE[CommandType::COMMAND]);
xTitle->setTitle(sDisplayName);
}
} catch( const Exception& )
{
DBG_UNHANDLED_EXCEPTION("extensions.propctrlr");
m_xDesigner.clear();
}
osl_atomic_decrement(&m_refCount);
}
Reference< XFrame > SQLCommandDesigner::impl_createEmptyParentlessTask_nothrow( ) const
{
OSL_PRECOND( m_xORB.is(), "SQLCommandDesigner::impl_createEmptyParentlessTask_nothrow: this will crash!" );
void SQLCommandDesigner::impl_closeDesigner_nothrow()
{
OSL_PRECOND( isActive(), "SQLCommandDesigner::impl_closeDesigner_nothrow: invalid call!" ); // close it try
{ // do not listen anymore...
Reference< XPropertySet > xProps( m_xDesigner, UNO_QUERY ); if ( xProps.is() )
xProps->removePropertyChangeListener( PROPERTY_ACTIVECOMMAND, this );
// we need to close the frame via the "user interface", by dispatching a close command, // instead of calling XCloseable::close directly. The latter method would also close // the frame, but not care for things like shutting down the office when the last // frame is gone ... const UnoURL aCloseURL( u".uno:CloseDoc"_ustr,
Reference< XMultiServiceFactory >( m_xORB, UNO_QUERY ) );
Reference< XDispatchProvider > xProvider( m_xDesigner->getFrame(), UNO_QUERY_THROW );
Reference< XDispatch > xDispatch( xProvider->queryDispatch( aCloseURL, u"_top"_ustr, FrameSearchFlag::SELF ) );
OSL_ENSURE( xDispatch.is(), "SQLCommandDesigner::impl_closeDesigner_nothrow: no dispatcher for the CloseDoc command!" ); if ( xDispatch.is() )
{
xDispatch->dispatch( aCloseURL, Sequence< PropertyValue >( ) );
} else
{ // fallback: use the XCloseable::close (with all possible disadvantages)
Reference< XCloseable > xClose( m_xDesigner->getFrame(), UNO_QUERY ); if ( xClose.is() )
xClose->close( true );
}
} catch( const Exception& )
{
DBG_UNHANDLED_EXCEPTION("extensions.propctrlr");
}
m_xDesigner.clear();
}
bool SQLCommandDesigner::impl_trySuspendDesigner_nothrow() const
{
OSL_PRECOND( isActive(), "SQLCommandDesigner::impl_trySuspendDesigner_nothrow: no active designer, this will crash!" ); bool bAllow = true; try
{
bAllow = m_xDesigner->suspend( true );
} catch( const Exception& )
{
DBG_UNHANDLED_EXCEPTION("extensions.propctrlr");
} return bAllow;
}
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.