Kaydet (Commit) bb8900ba authored tarafından Noel Grandin's avatar Noel Grandin

fdo#46808, Create new-style ui::WindowContentFactoryManager service

The service already existed, it just did not have an IDL file.

Change-Id: Ie059e8d81fdfb4c3a5eca274a2406f806ee77b5c
üst c1e42d60
......@@ -81,7 +81,6 @@ namespace framework{
#define SERVICENAME_STRINGABBREVIATION DECLARE_ASCII("com.sun.star.util.UriAbbreviation" )
#define SERVICENAME_IMAGEMANAGER DECLARE_ASCII("com.sun.star.ui.ImageManager" )
#define SERVICENAME_TABWINDOWSERVICE DECLARE_ASCII("com.sun.star.ui.dialogs.TabContainerWindow" )
#define SERVICENAME_WINDOWCONTENTFACTORYMANAGER DECLARE_ASCII("com.sun.star.ui.WindowContentFactoryManager" )
#define SERVICENAME_DISPLAYACCESS DECLARE_ASCII("com.sun.star.awt.DisplayAccess" )
#define SERVICENAME_PANELFACTORY DECLARE_ASCII("com.sun.star.ui.PanelFactory" )
#define SERVICENAME_MODELWINSERVICE DECLARE_ASCII("com.sun.star.ui.ModelWinService" )
......
......@@ -56,7 +56,7 @@ namespace framework
//*****************************************************************************************************************
DEFINE_XSERVICEINFO_ONEINSTANCESERVICE_2 ( WindowContentFactoryManager ,
::cppu::OWeakObject ,
SERVICENAME_WINDOWCONTENTFACTORYMANAGER ,
DECLARE_ASCII("com.sun.star.ui.WindowContentFactoryManager"),
IMPLEMENTATIONNAME_WINDOWCONTENTFACTORYMANAGER
)
......
......@@ -305,6 +305,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/ui,\
GlobalAcceleratorConfiguration \
ModuleUIConfigurationManagerSupplier \
WindowContentFactory \
WindowContentFactoryManager \
WindowStateConfiguration \
))
$(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/ui/dialogs,\
......
/* -*- 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 .
*/
#ifndef __com_sun_star_ui_WindowContentFactoryManager_idl__
#define __com_sun_star_ui_WindowContentFactoryManager_idl__
#include <com/sun/star/lang/XSingleComponentFactory.idl>
module com { module sun { module star { module ui {
/**
This interface could be imcomplete since I derived it from it's sole place of use.
@since LibreOffice 4.1
*/
service WindowContentFactoryManager : com::sun::star::lang::XSingleComponentFactory;
}; }; }; };
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -46,6 +46,7 @@
#include <com/sun/star/frame/ModuleManager.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/ui/WindowStateConfiguration.hpp>
#include <com/sun/star/ui/WindowContentFactoryManager.hpp>
#define MAX_TOGGLEAREA_WIDTH 20
#define MAX_TOGGLEAREA_HEIGHT 20
......@@ -128,7 +129,7 @@ SfxDockingWrapper::SfxDockingWrapper( Window* pParentWnd ,
SfxChildWinInfo* pInfo )
: SfxChildWindow( pParentWnd , nId )
{
uno::Reference< lang::XMultiServiceFactory > xServiceManager = ::comphelper::getProcessServiceFactory();
uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
const rtl::OUString aDockWindowResourceURL( RTL_CONSTASCII_USTRINGPARAM( "private:resource/dockingwindow/" ));
SfxTitleDockingWindow* pTitleDockWindow = new SfxTitleDockingWindow( pBindings, this, pParentWnd,
......@@ -136,86 +137,76 @@ SfxDockingWrapper::SfxDockingWrapper( Window* pParentWnd ,
pWindow = pTitleDockWindow;
eChildAlignment = SFX_ALIGN_NOALIGNMENT;
// Use factory manager to retrieve XWindow factory. That can be used to instanciate
// Use factory manager to retrieve XWindow factory. That can be used to instantiate
// the real window factory.
uno::Reference< lang::XSingleComponentFactory > xFactoryMgr(
xServiceManager->createInstance(
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.ui.WindowContentFactoryManager"))),
uno::UNO_QUERY );
if (xFactoryMgr.is())
uno::Reference< lang::XSingleComponentFactory > xFactoryMgr = ui::WindowContentFactoryManager::create(xContext);
SfxDispatcher* pDispatcher = pBindings->GetDispatcher();
uno::Reference< frame::XFrame > xFrame( pDispatcher->GetFrame()->GetFrame().GetFrameInterface(), uno::UNO_QUERY );
uno::Sequence< uno::Any > aArgs(2);
beans::PropertyValue aPropValue;
aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Frame" ));
aPropValue.Value = uno::makeAny( xFrame );
aArgs[0] <<= aPropValue;
aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ResourceURL" ));
// create a resource URL from the nId provided by the sfx2
::rtl::OUString aResourceURL( aDockWindowResourceURL );
aResourceURL += ::rtl::OUString::valueOf(sal_Int32(nId));
aPropValue.Value = uno::makeAny( aResourceURL );
aArgs[1] <<= aPropValue;
uno::Reference< awt::XWindow > xWindow;
try
{
SfxDispatcher* pDispatcher = pBindings->GetDispatcher();
uno::Reference< frame::XFrame > xFrame( pDispatcher->GetFrame()->GetFrame().GetFrameInterface(), uno::UNO_QUERY );
uno::Sequence< uno::Any > aArgs(2);
beans::PropertyValue aPropValue;
aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Frame" ));
aPropValue.Value = uno::makeAny( xFrame );
aArgs[0] <<= aPropValue;
aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ResourceURL" ));
// create a resource URL from the nId provided by the sfx2
::rtl::OUString aResourceURL( aDockWindowResourceURL );
aResourceURL += ::rtl::OUString::valueOf(sal_Int32(nId));
aPropValue.Value = uno::makeAny( aResourceURL );
aArgs[1] <<= aPropValue;
uno::Reference< awt::XWindow > xWindow;
try
{
uno::Reference< uno::XComponentContext > xContext(
comphelper::getComponentContext( xServiceManager ) );
xWindow = uno::Reference< awt::XWindow>(
xFactoryMgr->createInstanceWithArgumentsAndContext( aArgs, xContext ),
uno::UNO_QUERY );
static uno::WeakReference< frame::XModuleManager2 > m_xModuleManager;
uno::Reference< frame::XModuleManager2 > xModuleManager( m_xModuleManager );
if ( !xModuleManager.is() )
{
xModuleManager = frame::ModuleManager::create(comphelper::getComponentContext(xServiceManager));
m_xModuleManager = xModuleManager;
}
static uno::WeakReference< container::XNameAccess > m_xWindowStateConfiguration;
xWindow = uno::Reference< awt::XWindow>(
xFactoryMgr->createInstanceWithArgumentsAndContext( aArgs, xContext ),
uno::UNO_QUERY );
uno::Reference< container::XNameAccess > xWindowStateConfiguration( m_xWindowStateConfiguration );
if ( !xWindowStateConfiguration.is() )
{
xWindowStateConfiguration = ui::WindowStateConfiguration::create( comphelper::getComponentContext(xServiceManager) );
m_xWindowStateConfiguration = xWindowStateConfiguration;
}
static uno::WeakReference< frame::XModuleManager2 > m_xModuleManager;
::rtl::OUString sModuleIdentifier = xModuleManager->identify( xFrame );
uno::Reference< container::XNameAccess > xModuleWindowState(
xWindowStateConfiguration->getByName( sModuleIdentifier ),
uno::UNO_QUERY );
if ( xModuleWindowState.is() )
{
WindowState aDockWinState;
if ( lcl_getWindowState( xModuleWindowState, aResourceURL, aDockWinState ))
pTitleDockWindow->SetText( aDockWinState.sTitle );
}
}
catch ( beans::UnknownPropertyException& )
uno::Reference< frame::XModuleManager2 > xModuleManager( m_xModuleManager );
if ( !xModuleManager.is() )
{
xModuleManager = frame::ModuleManager::create(xContext);
m_xModuleManager = xModuleManager;
}
catch ( uno::RuntimeException& )
static uno::WeakReference< container::XNameAccess > m_xWindowStateConfiguration;
uno::Reference< container::XNameAccess > xWindowStateConfiguration( m_xWindowStateConfiguration );
if ( !xWindowStateConfiguration.is() )
{
xWindowStateConfiguration = ui::WindowStateConfiguration::create( xContext );
m_xWindowStateConfiguration = xWindowStateConfiguration;
}
catch ( uno::Exception& )
::rtl::OUString sModuleIdentifier = xModuleManager->identify( xFrame );
uno::Reference< container::XNameAccess > xModuleWindowState(
xWindowStateConfiguration->getByName( sModuleIdentifier ),
uno::UNO_QUERY );
if ( xModuleWindowState.is() )
{
WindowState aDockWinState;
if ( lcl_getWindowState( xModuleWindowState, aResourceURL, aDockWinState ))
pTitleDockWindow->SetText( aDockWinState.sTitle );
}
Window* pContentWindow = VCLUnoHelper::GetWindow(xWindow);
if ( pContentWindow )
pContentWindow->SetStyle( pContentWindow->GetStyle() | WB_DIALOGCONTROL | WB_CHILDDLGCTRL );
pTitleDockWindow->SetWrappedWindow(pContentWindow);
}
catch ( beans::UnknownPropertyException& )
{
}
catch ( uno::RuntimeException& )
{
}
catch ( uno::Exception& )
{
}
Window* pContentWindow = VCLUnoHelper::GetWindow(xWindow);
if ( pContentWindow )
pContentWindow->SetStyle( pContentWindow->GetStyle() | WB_DIALOGCONTROL | WB_CHILDDLGCTRL );
pTitleDockWindow->SetWrappedWindow(pContentWindow);
pWindow->SetOutputSizePixel( Size( 270, 240 ) );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment