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

fdo#46808, Convert frame::FrameControl service to new style

Change-Id: I38fc91e70d99472a4336250acd5c7dc3457b21ab
üst 8ac910bb
......@@ -46,6 +46,18 @@ using namespace ::com::sun::star::util ;
namespace unocontrols{
#define SERVICENAME_FRAMECONTROL "com.sun.star.frame.FrameControl"
#define IMPLEMENTATIONNAME_FRAMECONTROL "stardiv.UnoControls.FrameControl"
#define PROPERTYNAME_LOADERARGUMENTS "LoaderArguments"
#define PROPERTYNAME_COMPONENTURL "ComponentURL"
#define PROPERTYNAME_FRAME "Frame"
#define ERRORTEXT_VOSENSHURE "This is an invalid property handle."
#define PROPERTY_COUNT 3 // you must count the propertys
#define PROPERTYHANDLE_COMPONENTURL 0 // Id must be the index into the array
#define PROPERTYHANDLE_FRAME 1
#define PROPERTYHANDLE_LOADERARGUMENTS 2
//______________________________________________________________________________________________________________
// construct/destruct
//______________________________________________________________________________________________________________
......
......@@ -21,6 +21,7 @@
#define _UNOCONTROLS_FRAMECONTROL_CTRL_HXX
#include <com/sun/star/frame/XFrameActionListener.hpp>
#include <com/sun/star/frame/XFrameControl.hpp>
#include <com/sun/star/frame/XComponentLoader.hpp>
#include <com/sun/star/frame/XFrame2.hpp>
#include <com/sun/star/frame/FrameActionEvent.hpp>
......@@ -39,23 +40,13 @@
namespace unocontrols{
#define SERVICENAME_FRAMECONTROL "com.sun.star.frame.FrameControl"
#define IMPLEMENTATIONNAME_FRAMECONTROL "stardiv.UnoControls.FrameControl"
#define PROPERTYNAME_LOADERARGUMENTS "LoaderArguments"
#define PROPERTYNAME_COMPONENTURL "ComponentURL"
#define PROPERTYNAME_FRAME "Frame"
#define ERRORTEXT_VOSENSHURE "This is an invalid property handle."
#define PROPERTY_COUNT 3 // you must count the propertys
#define PROPERTYHANDLE_COMPONENTURL 0 // Id must be the index into the array
#define PROPERTYHANDLE_FRAME 1
#define PROPERTYHANDLE_LOADERARGUMENTS 2
//______________________________________________________________________________________________________________
// class
//______________________________________________________________________________________________________________
class FrameControl : public ::com::sun::star::awt::XControlModel
, public ::com::sun::star::lang::XConnectionPointContainer
, public ::com::sun::star::frame::XFrameControl
, public BaseControl // This order is necessary for right initialization of m_aMutex!
, public ::cppu::OBroadcastHelper
, public ::cppu::OPropertySetHelper
......@@ -184,6 +175,104 @@ public:
const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xListener
) throw( ::com::sun::star::uno::RuntimeException );
//__________________________________________________________________________________________________________
// XFrameControl
//__________________________________________________________________________________________________________
virtual rtl::OUString SAL_CALL getComponentURL()
throw( ::com::sun::star::uno::RuntimeException )
{ return m_sComponentURL; }
virtual void SAL_CALL setComponentURL(const rtl::OUString& rVal)
throw( ::com::sun::star::uno::RuntimeException )
{ m_sComponentURL = rVal; }
virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame2 > SAL_CALL getFrame()
throw( ::com::sun::star::uno::RuntimeException )
{ return m_xFrame; }
virtual void SAL_CALL setFrame(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame2 > & rxFrame)
throw( ::com::sun::star::uno::RuntimeException )
{ m_xFrame = rxFrame; }
virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getLoaderArguments()
throw( ::com::sun::star::uno::RuntimeException )
{ return m_seqLoaderArguments; }
virtual void SAL_CALL setLoaderArguments(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > & rVal)
throw( ::com::sun::star::uno::RuntimeException )
{ m_seqLoaderArguments = rVal; }
//__________________________________________________________________________________________________________
// overrides to remove inheritance ambiguity
//__________________________________________________________________________________________________________
virtual css::uno::Reference<css::awt::XWindowPeer> getPeer() throw (css::uno::RuntimeException)
{ return BaseControl::getPeer(); }
virtual css::awt::Rectangle getPosSize() throw (css::uno::RuntimeException)
{ return BaseControl::getPosSize(); }
virtual void setPosSize(sal_Int32 p1, sal_Int32 p2, sal_Int32 p3, sal_Int32 p4, sal_Int16 p5) throw (css::uno::RuntimeException)
{ return BaseControl::setPosSize(p1, p2, p3, p4, p5); }
virtual void addEventListener(const css::uno::Reference<css::lang::XEventListener>& p1) throw (css::uno::RuntimeException)
{ return BaseControl::addEventListener(p1); }
virtual void removeEventListener(const css::uno::Reference<css::lang::XEventListener>& p1) throw (css::uno::RuntimeException)
{ return BaseControl::removeEventListener(p1); }
virtual void setVisible(sal_Bool p1) throw (css::uno::RuntimeException)
{ return BaseControl::setVisible(p1); }
virtual void setEnable(sal_Bool p1) throw (css::uno::RuntimeException)
{ return BaseControl::setEnable(p1); }
virtual void setFocus() throw (css::uno::RuntimeException)
{ return BaseControl::setFocus(); }
virtual void addWindowListener(const css::uno::Reference<css::awt::XWindowListener>& p1) throw (css::uno::RuntimeException)
{ return BaseControl::addWindowListener(p1); }
virtual void removeWindowListener(const css::uno::Reference<css::awt::XWindowListener>& p1) throw (css::uno::RuntimeException)
{ return BaseControl::removeWindowListener(p1); }
virtual void addFocusListener(const css::uno::Reference<css::awt::XFocusListener>& p1) throw (css::uno::RuntimeException)
{ return BaseControl::addFocusListener(p1); }
virtual void removeFocusListener(const css::uno::Reference<css::awt::XFocusListener>& p1) throw (css::uno::RuntimeException)
{ return BaseControl::removeFocusListener(p1); }
virtual void addKeyListener(const css::uno::Reference<css::awt::XKeyListener>& p1) throw (css::uno::RuntimeException)
{ return BaseControl::addKeyListener(p1); }
virtual void removeKeyListener(const css::uno::Reference<css::awt::XKeyListener>& p1) throw (css::uno::RuntimeException)
{ return BaseControl::removeKeyListener(p1); }
virtual void addMouseListener(const css::uno::Reference<css::awt::XMouseListener>& p1) throw (css::uno::RuntimeException)
{ return BaseControl::addMouseListener(p1); }
virtual void removeMouseListener(const css::uno::Reference<css::awt::XMouseListener>& p1) throw (css::uno::RuntimeException)
{ return BaseControl::removeMouseListener(p1); }
virtual void addMouseMotionListener(const css::uno::Reference<css::awt::XMouseMotionListener>& p1) throw (css::uno::RuntimeException)
{ return BaseControl::addMouseMotionListener(p1); }
virtual void removeMouseMotionListener(const css::uno::Reference<css::awt::XMouseMotionListener>& p1) throw (css::uno::RuntimeException)
{ return BaseControl::removeMouseMotionListener(p1); }
virtual void addPaintListener(const css::uno::Reference<css::awt::XPaintListener>& p1) throw (css::uno::RuntimeException)
{ return BaseControl::addPaintListener(p1); }
virtual void removePaintListener(const css::uno::Reference<css::awt::XPaintListener>& p1) throw (css::uno::RuntimeException)
{ return BaseControl::removePaintListener(p1); }
virtual css::awt::Size getSize() throw (css::uno::RuntimeException)
{ return BaseControl::getSize(); }
virtual void draw(sal_Int32 p1, sal_Int32 p2) throw (css::uno::RuntimeException)
{ return BaseControl::draw(p1, p2); }
virtual void setZoom(float p1, float p2) throw (css::uno::RuntimeException)
{ return BaseControl::setZoom(p1, p2); }
virtual void setPropertyValue(const rtl::OUString& p1, const css::uno::Any& p2) throw (css::uno::RuntimeException)
{ return ::cppu::OPropertySetHelper::setPropertyValue(p1, p2); }
virtual css::uno::Any getPropertyValue(const rtl::OUString& p1) throw (css::uno::RuntimeException)
{ return ::cppu::OPropertySetHelper::getPropertyValue(p1); }
virtual void addPropertyChangeListener(const rtl::OUString& p1, const css::uno::Reference<css::beans::XPropertyChangeListener>& p2) throw (css::uno::RuntimeException)
{ return ::cppu::OPropertySetHelper::addPropertyChangeListener(p1, p2); }
virtual void removePropertyChangeListener(const rtl::OUString& p1, const css::uno::Reference<css::beans::XPropertyChangeListener>& p2) throw (css::uno::RuntimeException)
{ return ::cppu::OPropertySetHelper::removePropertyChangeListener(p1, p2); }
virtual void addVetoableChangeListener(const rtl::OUString& p1, const css::uno::Reference<css::beans::XVetoableChangeListener>& p2) throw (css::uno::RuntimeException)
{ return ::cppu::OPropertySetHelper::addVetoableChangeListener(p1, p2); }
virtual void removeVetoableChangeListener(const rtl::OUString& p1, const css::uno::Reference<css::beans::XVetoableChangeListener>& p2) throw (css::uno::RuntimeException)
{ return ::cppu::OPropertySetHelper::removeVetoableChangeListener(p1, p2); }
virtual void setContext(const css::uno::Reference<css::uno::XInterface>& p1) throw (css::uno::RuntimeException)
{ return BaseControl::setContext(p1); }
virtual css::uno::Reference<css::uno::XInterface> getContext() throw (css::uno::RuntimeException)
{ return BaseControl::getContext(); }
virtual css::uno::Reference<css::awt::XView> getView() throw (css::uno::RuntimeException)
{ return BaseControl::getView(); }
virtual void setDesignMode(sal_Bool p1) throw (css::uno::RuntimeException)
{ return BaseControl::setDesignMode(p1); }
virtual sal_Bool isDesignMode() throw (css::uno::RuntimeException)
{ return BaseControl::isDesignMode(); }
virtual sal_Bool isTransparent() throw (css::uno::RuntimeException)
{ return BaseControl::isTransparent(); }
//__________________________________________________________________________________________________________
// impl but public methods to register service!
//__________________________________________________________________________________________________________
......
......@@ -199,6 +199,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/frame,\
DispatchRecorderSupplier \
DocumentTemplates \
Frame \
FrameControl \
FrameLoaderFactory \
GlobalEventBroadcaster \
LayoutManager \
......@@ -942,7 +943,6 @@ $(eval $(call gb_UnoApi_add_idlfiles_noheader,offapi,offapi/com/sun/star/frame,\
DesktopTask \
DesktopTasks \
DispatchProvider \
FrameControl \
FrameLoader \
FramesContainer \
PopupMenuController \
......@@ -2586,6 +2586,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,offapi/com/sun/star/frame,\
XFrame \
XFrame2 \
XFrameActionListener \
XFrameControl \
XFrameLoader \
XFrameLoaderQuery \
XFrameSetModel \
......
......@@ -19,8 +19,7 @@
#ifndef __com_sun_star_frame_FrameControl_idl__
#define __com_sun_star_frame_FrameControl_idl__
#include <com/sun/star/awt/UnoControl.idl>
#include <com/sun/star/beans/XPropertySet.idl>
#include <com/sun/star/frame/XFrameControl.idl>
module com { module sun { module star { module frame {
......@@ -34,26 +33,7 @@
any UI.
</p>
*/
published service FrameControl
{
/** the base service of all controls
*/
service com::sun::star::awt::UnoControl;
/** contains the type of the component which is loaded into the frame,
or the document which implicitly specifies the type
*/
[property] string ComponentUrl;
/** the frame held by this control
<p>
The Frame is created if the control
is shown and the #ComponentUrl is set.
</p>
*/
[property, readonly] string Frame;
};
published service FrameControl : XFrameControl;
}; }; }; };
......
/* -*- 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_frame_XFrameControl_idl__
#define __com_sun_star_frame_XFrameControl_idl__
#include <com/sun/star/awt/UnoControl.idl>
#include <com/sun/star/beans/XPropertySet.idl>
#include <com/sun/star/beans/PropertyValue.idl>
#include <com/sun/star/frame/XFrame2.idl>
module com { module sun { module star { module frame {
/**
Unified interface for the FrameControl service.
This is not the complete set of interfaces this service implements, just the bare minimum
that we use internally.
@since LibreOffice 4.2
*/
published interface XFrameControl
{
interface com::sun::star::awt::XControl;
interface com::sun::star::awt::XWindow;
/** contains the type of the component which is loaded into the frame,
or the document which implicitly specifies the type
*/
[attribute] string ComponentURL;
/** the frame held by this control
<p>
The Frame is created if the control
is shown and the #ComponentUrl is set.
</p>
*/
[attribute] com::sun::star::frame::XFrame2 Frame;
[attribute] sequence< ::com::sun::star::beans::PropertyValue > LoaderArguments;
};
}; }; }; };
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -26,11 +26,11 @@
#include <vcl/fixed.hxx>
#include <vcl/layout.hxx>
#include <actctrl.hxx>
#include <com/sun/star/frame/XController.hpp>
#include <com/sun/star/text/XTextCursor.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/awt/XControl.hpp>
#include <com/sun/star/container/XNamed.hpp>
#include <com/sun/star/frame/XController.hpp>
#include <com/sun/star/frame/XFrameControl.hpp>
#include <com/sun/star/text/XTextCursor.hpp>
#include <tools/resary.hxx>
#include "swdllapi.h"
......@@ -68,7 +68,7 @@ class SwView;
class SW_DLLPUBLIC SwOneExampleFrame
{
::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > _xControl;
::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrameControl > m_xFrameControl;
::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > _xModel;
::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > _xController;
::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > _xCursor;
......@@ -102,10 +102,10 @@ public:
String* pURL = 0);
~SwOneExampleFrame();
::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > & GetControl() {return _xControl; }
::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & GetModel() {return _xModel;}
::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > & GetController() {return _xController;}
::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > & GetTextCursor() {return _xCursor;}
::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrameControl > & GetFrameControl() {return m_xFrameControl; }
::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & GetModel() {return _xModel;}
::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > & GetController() {return _xController;}
::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > & GetTextCursor() {return _xCursor;}
void ClearDocument( sal_Bool bStartTimer = sal_False );
......
......@@ -38,6 +38,7 @@
#include <com/sun/star/awt/PosSize.hpp>
#include <com/sun/star/view/XViewSettingsSupplier.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/frame/FrameControl.hpp>
#include <com/sun/star/frame/XLayoutManager.hpp>
#include <comphelper/processfactory.hxx>
#include <sfx2/dispatch.hxx>
......@@ -106,62 +107,51 @@ SwOneExampleFrame::~SwOneExampleFrame()
void SwOneExampleFrame::CreateControl()
{
if(_xControl.is())
if(m_xFrameControl.is())
return ;
uno::Reference< lang::XMultiServiceFactory >
xMgr = comphelper::getProcessServiceFactory();
uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext();
uno::Reference< uno::XInterface > xInst = xMgr->createInstance( "com.sun.star.frame.FrameControl" );
_xControl = uno::Reference< awt::XControl >(xInst, uno::UNO_QUERY);
if(_xControl.is())
{
uno::Reference< awt::XWindowPeer > xParent( aTopWindow.GetComponentInterface() );
m_xFrameControl = frame::FrameControl::create(xContext);
uno::Reference< awt::XToolkit > xToolkit( awt::Toolkit::create(xContext), uno::UNO_QUERY_THROW );
uno::Reference< awt::XWindowPeer > xParent( aTopWindow.GetComponentInterface() );
_xControl->createPeer( xToolkit, xParent );
uno::Reference< awt::XToolkit > xToolkit( awt::Toolkit::create(xContext), uno::UNO_QUERY_THROW );
uno::Reference< awt::XWindow > xWin( _xControl, uno::UNO_QUERY );
xWin->setVisible(sal_False);
Size aWinSize(aTopWindow.GetOutputSizePixel());
xWin->setPosSize( 0, 0, aWinSize.Width(), aWinSize.Height(), awt::PosSize::SIZE );
uno::Reference< beans::XPropertySet > xPrSet(xInst, uno::UNO_QUERY);
uno::Any aURL;
// create new doc
OUString sTempURL(cFactory);
if(sArgumentURL.Len())
sTempURL = sArgumentURL;
aURL <<= sTempURL;
uno::Sequence<beans::PropertyValue> aSeq(3);
beans::PropertyValue* pValues = aSeq.getArray();
pValues[0].Name = "ReadOnly";
sal_Bool bTrue = sal_True;
pValues[0].Value.setValue(&bTrue, ::getBooleanCppuType());
pValues[1].Name = "OpenFlags";
pValues[1].Value <<= OUString("-RB");
pValues[2].Name = "Referer";
pValues[2].Value <<= OUString("private:user");
uno::Any aArgs;
aArgs.setValue(&aSeq, ::getCppuType((uno::Sequence<beans::PropertyValue>*)0));
m_xFrameControl->createPeer( xToolkit, xParent );
xPrSet->setPropertyValue( "LoaderArguments", aArgs );
//save and set readonly???
m_xFrameControl->setVisible(sal_False);
Size aWinSize(aTopWindow.GetOutputSizePixel());
m_xFrameControl->setPosSize( 0, 0, aWinSize.Width(), aWinSize.Height(), awt::PosSize::SIZE );
xPrSet->setPropertyValue("ComponentURL", aURL);
// create new doc
OUString sTempURL(cFactory);
if(sArgumentURL.Len())
sTempURL = sArgumentURL;
aLoadedTimer.Start();
bServiceAvailable = sal_True;
}
uno::Sequence<beans::PropertyValue> aSeq(3);
beans::PropertyValue* pValues = aSeq.getArray();
pValues[0].Name = "ReadOnly";
sal_Bool bTrue = sal_True;
pValues[0].Value.setValue(&bTrue, ::getBooleanCppuType());
pValues[1].Name = "OpenFlags";
pValues[1].Value <<= OUString("-RB");
pValues[2].Name = "Referer";
pValues[2].Value <<= OUString("private:user");
m_xFrameControl->setLoaderArguments( aSeq );
//save and set readonly???
m_xFrameControl->setComponentURL( sTempURL );
aLoadedTimer.Start();
bServiceAvailable = sal_True;
}
void SwOneExampleFrame::DisposeControl()
{
_xCursor = 0;
if(_xControl.is())
_xControl->dispose();
_xControl = 0;
m_xFrameControl.clear();
_xModel = 0;
_xController = 0;
}
......@@ -193,14 +183,11 @@ static void disableScrollBars(uno::Reference< beans::XPropertySet > xViewProps,
IMPL_LINK( SwOneExampleFrame, TimeoutHdl, Timer*, pTimer )
{
if(!_xControl.is())
if(!m_xFrameControl.is())
return 0;
// now get the model
uno::Reference< beans::XPropertySet > xPrSet(_xControl, uno::UNO_QUERY);
uno::Any aFrame = xPrSet->getPropertyValue("Frame");
uno::Reference< frame::XFrame > xFrm;
aFrame >>= xFrm;
uno::Reference< frame::XFrame > xFrm = m_xFrameControl->getFrame();
uno::Reference< beans::XPropertySet > xPropSet( xFrm, uno::UNO_QUERY );
if ( xPropSet.is() )
......@@ -362,9 +349,8 @@ IMPL_LINK( SwOneExampleFrame, TimeoutHdl, Timer*, pTimer )
xPProp->setPropertyValue(OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_RIGHT_MARGIN)), aZero);
}
uno::Reference< awt::XWindow > xWin( _xControl, uno::UNO_QUERY );
Size aWinSize(aTopWindow.GetOutputSizePixel());
xWin->setPosSize( 0, 0, aWinSize.Width(), aWinSize.Height(), awt::PosSize::SIZE );
m_xFrameControl->setPosSize( 0, 0, aWinSize.Width(), aWinSize.Height(), awt::PosSize::SIZE );
// can only be done here - the SFX changes the ScrollBar values
disableScrollBars(xViewProps, nStyleFlags&EX_SHOW_ONLINE_LAYOUT);
......@@ -377,7 +363,7 @@ IMPL_LINK( SwOneExampleFrame, TimeoutHdl, Timer*, pTimer )
if(xScrCrsr.is())
xScrCrsr->screenUp();
xWin->setVisible( sal_True );
m_xFrameControl->setVisible( sal_True );
aTopWindow.Show();
if( xTunnel.is() )
......
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