2010-10-14 08:27:31 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-10-02 14:13:40 +01:00
|
|
|
/*
|
|
|
|
* 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 .
|
|
|
|
*/
|
2003-06-20 09:19:17 +00:00
|
|
|
|
2006-09-16 11:16:09 +00:00
|
|
|
|
2003-06-20 09:19:17 +00:00
|
|
|
#include <toolkit/awt/vclxwindow.hxx>
|
2007-08-30 12:54:48 +00:00
|
|
|
#include <com/sun/star/beans/NamedValue.hpp>
|
2003-06-20 09:19:17 +00:00
|
|
|
#include <vcl/wrkwin.hxx>
|
|
|
|
#include <vcl/window.hxx>
|
2009-05-18 12:01:49 +00:00
|
|
|
|
|
|
|
#ifdef WNT
|
2011-03-28 01:31:21 -06:00
|
|
|
#include <prewin.h>
|
|
|
|
#include <postwin.h>
|
2013-01-11 11:07:23 +02:00
|
|
|
#elif defined ( MACOSX )
|
2007-12-07 10:40:19 +00:00
|
|
|
#include "premac.h"
|
|
|
|
#include <Cocoa/Cocoa.h>
|
|
|
|
#include "postmac.h"
|
|
|
|
#endif
|
2003-06-20 09:19:17 +00:00
|
|
|
#include <vcl/sysdata.hxx>
|
|
|
|
|
|
|
|
/// helper method to set a window handle into a SystemParentData struct
|
2007-08-30 12:54:48 +00:00
|
|
|
void VCLXWindow::SetSystemParent_Impl( const com::sun::star::uno::Any& rHandle )
|
2003-06-20 09:19:17 +00:00
|
|
|
{
|
|
|
|
// does only work for WorkWindows
|
2014-09-23 11:20:40 +02:00
|
|
|
vcl::Window *pWindow = GetWindow();
|
2003-06-20 09:19:17 +00:00
|
|
|
if ( pWindow->GetType() != WINDOW_WORKWINDOW )
|
|
|
|
{
|
2014-02-13 12:43:08 +00:00
|
|
|
com::sun::star::uno::RuntimeException aException;
|
2013-10-31 15:43:06 +02:00
|
|
|
aException.Message = "not a work window";
|
2013-04-16 13:59:34 +01:00
|
|
|
throw aException;
|
2003-06-20 09:19:17 +00:00
|
|
|
}
|
|
|
|
|
2013-03-03 17:11:39 +01:00
|
|
|
// use sal_Int64 here to accommodate all int types
|
2007-08-30 12:54:48 +00:00
|
|
|
// uno::Any shift operator whill upcast if necessary
|
|
|
|
sal_Int64 nHandle = 0;
|
2014-02-24 11:13:09 +01:00
|
|
|
bool bXEmbed = false;
|
2007-08-30 12:54:48 +00:00
|
|
|
bool bThrow = false;
|
|
|
|
if( ! (rHandle >>= nHandle) )
|
|
|
|
{
|
|
|
|
com::sun::star::uno::Sequence< com::sun::star::beans::NamedValue > aProps;
|
|
|
|
if( rHandle >>= aProps )
|
|
|
|
{
|
|
|
|
const int nProps = aProps.getLength();
|
|
|
|
const com::sun::star::beans::NamedValue* pProps = aProps.getConstArray();
|
|
|
|
for( int i = 0; i < nProps; i++ )
|
|
|
|
{
|
2012-04-06 14:28:18 +02:00
|
|
|
if ( pProps[i].Name == "WINDOW" )
|
2007-08-30 12:54:48 +00:00
|
|
|
pProps[i].Value >>= nHandle;
|
2012-04-06 14:28:18 +02:00
|
|
|
else if ( pProps[i].Name == "XEMBED" )
|
2007-08-30 12:54:48 +00:00
|
|
|
pProps[i].Value >>= bXEmbed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bThrow = true;
|
|
|
|
}
|
|
|
|
if( bThrow )
|
|
|
|
{
|
2014-07-01 10:24:30 +01:00
|
|
|
com::sun::star::uno::RuntimeException aException;
|
2013-10-31 15:43:06 +02:00
|
|
|
aException.Message = "incorrect window handle type";
|
2013-04-16 13:59:34 +01:00
|
|
|
throw aException;
|
2007-08-30 12:54:48 +00:00
|
|
|
}
|
2003-06-20 09:19:17 +00:00
|
|
|
// create system parent data
|
|
|
|
SystemParentData aSysParentData;
|
|
|
|
aSysParentData.nSize = sizeof ( SystemParentData );
|
2011-05-21 17:00:45 +03:00
|
|
|
#if defined( WNT )
|
2003-06-20 09:19:17 +00:00
|
|
|
aSysParentData.hWnd = (HWND) nHandle;
|
2013-01-11 11:07:23 +02:00
|
|
|
#elif defined( MACOSX )
|
2007-12-07 10:40:19 +00:00
|
|
|
aSysParentData.pView = reinterpret_cast<NSView*>(nHandle);
|
2013-03-27 02:11:39 +02:00
|
|
|
#elif defined( ANDROID )
|
|
|
|
// Nothing
|
2013-03-27 00:38:36 +02:00
|
|
|
#elif defined( IOS )
|
|
|
|
// Nothing
|
2003-06-20 09:19:17 +00:00
|
|
|
#elif defined( UNX )
|
2006-06-19 22:02:33 +00:00
|
|
|
aSysParentData.aWindow = (long)nHandle;
|
2007-08-30 12:54:48 +00:00
|
|
|
aSysParentData.bXEmbedSupport = bXEmbed;
|
2003-06-20 09:19:17 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// set system parent
|
2014-09-29 09:44:47 +02:00
|
|
|
static_cast<WorkWindow*>(pWindow)->SetPluginParent( &aSysParentData );
|
2003-06-20 09:19:17 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 08:27:31 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|