Conflicts: avmedia/source/gstreamer/gstframegrabber.cxx avmedia/source/gstreamer/gstplayer.cxx avmedia/source/gstreamer/gstplayer.hxx basic/inc/basic/sbxdef.hxx basic/source/classes/sbxmod.cxx basic/source/comp/makefile.mk basic/source/comp/sbcomp.cxx basic/source/inc/namecont.hxx basic/source/inc/scriptcont.hxx basic/source/runtime/methods.cxx basic/source/runtime/runtime.cxx basic/source/runtime/stdobj.cxx basic/source/runtime/step1.cxx basic/source/uno/namecont.cxx basic/util/makefile.mk connectivity/source/commontools/predicateinput.cxx connectivity/source/drivers/dbase/DNoException.cxx connectivity/source/drivers/dbase/DTable.cxx connectivity/source/drivers/file/fcomp.cxx connectivity/source/drivers/jdbc/JConnection.cxx connectivity/source/drivers/odbcbase/OResultSet.cxx connectivity/source/drivers/odbcbase/OStatement.cxx connectivity/source/parse/sqlnode.cxx desktop/source/app/app.cxx drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx drawinglayer/source/processor2d/vclprocessor2d.cxx formula/inc/formula/token.hxx formula/source/core/api/token.cxx fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx fpicker/source/win32/filepicker/platform_vista.h framework/source/helper/persistentwindowstate.cxx framework/source/uielement/menubarmanager.cxx oovbaapi/ooo/vba/XFoundFiles.idl oovbaapi/ooo/vba/excel/XApplication.idl oovbaapi/ooo/vba/msforms/XCheckBox.idl oovbaapi/ooo/vba/msforms/XComboBox.idl oovbaapi/ooo/vba/msforms/XControl.idl oovbaapi/ooo/vba/msforms/XGroupBox.idl oovbaapi/ooo/vba/msforms/XLabel.idl oovbaapi/ooo/vba/msforms/XListBox.idl oovbaapi/ooo/vba/msforms/XNewFont.idl oovbaapi/ooo/vba/msforms/XRadioButton.idl oovbaapi/ooo/vba/msforms/XTextBox.idl oovbaapi/ooo/vba/msforms/XToggleButton.idl scripting/source/dlgprov/dlgevtatt.cxx sfx2/source/control/unoctitm.cxx sfx2/source/doc/objstor.cxx sfx2/source/doc/objxtor.cxx svx/inc/svx/svdograf.hxx svx/source/form/fmpage.cxx svx/source/form/fmpgeimp.cxx svx/source/svdraw/svdedtv.cxx svx/source/svdraw/svdfmtf.cxx svx/source/svdraw/svdograf.cxx svx/source/svdraw/svdouno.cxx svx/source/xml/xmlgrhlp.cxx uui/source/iahndl-ssl.cxx vbahelper/Library_msforms.mk vbahelper/Library_vbahelper.mk vbahelper/inc/vbahelper/vbahelper.hxx vbahelper/prj/build.lst vbahelper/source/msforms/vbacombobox.cxx vbahelper/source/msforms/vbacontrol.cxx vbahelper/source/msforms/vbacontrols.cxx vbahelper/source/msforms/vbaframe.cxx vbahelper/source/msforms/vbaframe.hxx vbahelper/source/msforms/vbalabel.cxx vbahelper/source/msforms/vbalabel.hxx vbahelper/source/msforms/vbalistbox.cxx vbahelper/source/msforms/vbalistbox.hxx vbahelper/source/msforms/vbamultipage.cxx vbahelper/source/msforms/vbatogglebutton.cxx vbahelper/source/msforms/vbauserform.cxx vbahelper/source/vbahelper/vbacommandbar.cxx vbahelper/source/vbahelper/vbacommandbarcontrol.cxx vbahelper/source/vbahelper/vbacommandbarcontrols.hxx vbahelper/source/vbahelper/vbahelper.cxx vbahelper/source/vbahelper/vbawindowbase.cxx xmloff/source/meta/xmlmetai.cxx xmloff/source/style/PageMasterExportPropMapper.cxx xmloff/source/style/PageMasterStyleMap.cxx xmloff/source/text/txtexppr.cxx xmloff/source/text/txtprmap.cxx
333 lines
14 KiB
C++
333 lines
14 KiB
C++
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
/*************************************************************************
|
|
*
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
*
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
|
*
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
|
*
|
|
* This file is part of OpenOffice.org.
|
|
*
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
* only, as published by the Free Software Foundation.
|
|
*
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Lesser General Public License version 3 for more details
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
* <http://www.openoffice.org/license.html>
|
|
* for a copy of the LGPLv3 License.
|
|
*
|
|
************************************************************************/
|
|
#include "vbacommandbarcontrols.hxx"
|
|
#include "vbacommandbarcontrol.hxx"
|
|
|
|
using namespace com::sun::star;
|
|
using namespace ooo::vba;
|
|
|
|
typedef ::cppu::WeakImplHelper1< container::XEnumeration > CommandBarControlEnumeration_BASE;
|
|
class CommandBarControlEnumeration : public CommandBarControlEnumeration_BASE
|
|
{
|
|
//uno::Reference< uno::XComponentContext > m_xContext;
|
|
CommandBarControls_BASE* m_pCommandBarControls;
|
|
sal_Int32 m_nCurrentPosition;
|
|
public:
|
|
CommandBarControlEnumeration( CommandBarControls_BASE* pCommandBarControls ) : m_pCommandBarControls( pCommandBarControls ), m_nCurrentPosition( 0 ) {}
|
|
virtual sal_Bool SAL_CALL hasMoreElements() throw ( uno::RuntimeException )
|
|
{
|
|
if( m_nCurrentPosition < m_pCommandBarControls->getCount() )
|
|
return sal_True;
|
|
return sal_False;
|
|
}
|
|
virtual uno::Any SAL_CALL nextElement() throw ( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
|
|
{
|
|
if( hasMoreElements() )
|
|
{
|
|
return m_pCommandBarControls->createCollectionObject( uno::makeAny( m_nCurrentPosition++ ) );
|
|
}
|
|
else
|
|
throw container::NoSuchElementException();
|
|
}
|
|
};
|
|
|
|
ScVbaCommandBarControls::ScVbaCommandBarControls( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess>& xIndexAccess, VbaCommandBarHelperRef pHelper, const uno::Reference< container::XIndexAccess>& xBarSettings, const rtl::OUString& sResourceUrl ) throw (uno::RuntimeException) : CommandBarControls_BASE( xParent, xContext, xIndexAccess ), pCBarHelper( pHelper ), m_xBarSettings( xBarSettings ), m_sResourceUrl( sResourceUrl )
|
|
{
|
|
m_bIsMenu = sResourceUrl.equalsAscii( ITEM_MENUBAR_URL ) ? sal_True : sal_False;
|
|
}
|
|
|
|
uno::Sequence< beans::PropertyValue > ScVbaCommandBarControls::CreateMenuItemData( const rtl::OUString& sCommandURL,
|
|
const rtl::OUString& sHelpURL,
|
|
const rtl::OUString& sLabel,
|
|
sal_uInt16 nType,
|
|
const uno::Any& aSubMenu,
|
|
sal_Bool isVisible,
|
|
sal_Bool isEnabled )
|
|
{
|
|
uno::Sequence< beans::PropertyValue > aProps(7);
|
|
|
|
aProps[0].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_COMMANDURL ));
|
|
aProps[0].Value <<= sCommandURL;
|
|
aProps[1].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_HELPURL ));
|
|
aProps[1].Value <<= sHelpURL;
|
|
aProps[2].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_LABEL ));
|
|
aProps[2].Value <<= sLabel;
|
|
aProps[3].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_TYPE ));
|
|
aProps[3].Value <<= nType;
|
|
aProps[4].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_CONTAINER ));
|
|
aProps[4].Value = aSubMenu;
|
|
aProps[5].Name = rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_ISVISIBLE );
|
|
aProps[5].Value <<= isVisible;
|
|
aProps[6].Name = rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_ENABLED );
|
|
aProps[6].Value <<= isEnabled;
|
|
|
|
return aProps;
|
|
}
|
|
|
|
uno::Sequence< beans::PropertyValue > ScVbaCommandBarControls::CreateToolbarItemData( const rtl::OUString& sCommandURL, const rtl::OUString& sHelpURL, const rtl::OUString& sLabel, sal_uInt16 nType, const uno::Any& aSubMenu, sal_Bool isVisible, sal_Int32 nStyle )
|
|
{
|
|
uno::Sequence< beans::PropertyValue > aProps(7);
|
|
|
|
aProps[0].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_COMMANDURL ));
|
|
aProps[0].Value <<= sCommandURL;
|
|
aProps[1].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_HELPURL ));
|
|
aProps[1].Value <<= sHelpURL;
|
|
aProps[2].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_LABEL ));
|
|
aProps[2].Value <<= sLabel;
|
|
aProps[3].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_TYPE ));
|
|
aProps[3].Value <<= nType;
|
|
aProps[4].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_CONTAINER ));
|
|
aProps[4].Value = aSubMenu;
|
|
aProps[5].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_ISVISIBLE ));
|
|
aProps[5].Value <<= isVisible;
|
|
aProps[6].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_STYLE ));
|
|
aProps[6].Value <<= nStyle;
|
|
|
|
return aProps;
|
|
}
|
|
|
|
// XEnumerationAccess
|
|
uno::Type SAL_CALL
|
|
ScVbaCommandBarControls::getElementType() throw ( uno::RuntimeException )
|
|
{
|
|
return XCommandBarControl::static_type( 0 );
|
|
}
|
|
|
|
uno::Reference< container::XEnumeration >
|
|
ScVbaCommandBarControls::createEnumeration() throw ( uno::RuntimeException )
|
|
{
|
|
return uno::Reference< container::XEnumeration >( new CommandBarControlEnumeration( this ) );
|
|
}
|
|
|
|
uno::Any
|
|
ScVbaCommandBarControls::createCollectionObject( const uno::Any& aSource )
|
|
{
|
|
sal_Int32 nPosition = -1;
|
|
aSource >>= nPosition;
|
|
uno::Sequence< beans::PropertyValue > aProps;
|
|
m_xIndexAccess->getByIndex( nPosition ) >>= aProps;
|
|
uno::Reference< container::XIndexAccess > xSubMenu;
|
|
getPropertyValue( aProps, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_CONTAINER )) ) >>= xSubMenu;
|
|
ScVbaCommandBarControl* pNewCommandBarControl = NULL;
|
|
if( xSubMenu.is() )
|
|
pNewCommandBarControl = new ScVbaCommandBarPopup( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, sal_True );
|
|
else
|
|
pNewCommandBarControl = new ScVbaCommandBarButton( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, sal_True );
|
|
|
|
return uno::makeAny( uno::Reference< XCommandBarControl > ( pNewCommandBarControl ) );
|
|
}
|
|
|
|
// Methods
|
|
uno::Any SAL_CALL
|
|
ScVbaCommandBarControls::Item( const uno::Any& aIndex, const uno::Any& /*aIndex*/ ) throw (uno::RuntimeException)
|
|
{
|
|
sal_Int32 nPosition = -1;
|
|
if( aIndex.getValueTypeClass() == uno::TypeClass_STRING )
|
|
{
|
|
rtl::OUString sName;
|
|
aIndex >>= sName;
|
|
nPosition = VbaCommandBarHelper::findControlByName( m_xIndexAccess, sName, m_bIsMenu );
|
|
}
|
|
else
|
|
{
|
|
aIndex >>= nPosition;
|
|
}
|
|
|
|
if( nPosition < 0 || nPosition >= getCount() )
|
|
{
|
|
throw uno::RuntimeException();
|
|
}
|
|
|
|
return createCollectionObject( uno::makeAny( nPosition ) );
|
|
}
|
|
|
|
uno::Reference< XCommandBarControl > SAL_CALL
|
|
ScVbaCommandBarControls::Add( const uno::Any& Type, const uno::Any& Id, const uno::Any& Parameter, const uno::Any& Before, const uno::Any& Temporary ) throw (script::BasicErrorException, uno::RuntimeException)
|
|
{
|
|
// Parameter is not supported
|
|
// the following name needs to be individually created;
|
|
rtl::OUString sLabel(RTL_CONSTASCII_USTRINGPARAM("Custom"));
|
|
rtl::OUString sCommandUrl(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( CUSTOM_MENU_STR)) + sLabel);
|
|
sal_Int32 nType = office::MsoControlType::msoControlButton;
|
|
sal_Int32 nPosition = 0;
|
|
sal_Bool bTemporary = sal_True;
|
|
|
|
if( Type.hasValue() )
|
|
{
|
|
Type >>= nType;
|
|
}
|
|
|
|
if( nType != office::MsoControlType::msoControlButton &&
|
|
nType != office::MsoControlType::msoControlPopup )
|
|
throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
|
|
|
|
if( Id.hasValue() || Parameter.hasValue( ) )
|
|
{
|
|
throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
|
|
}
|
|
|
|
if( Before.hasValue() )
|
|
Before >>= nPosition;
|
|
else
|
|
nPosition = m_xIndexAccess->getCount();
|
|
|
|
if( Temporary.hasValue() )
|
|
Temporary >>= bTemporary;
|
|
|
|
uno::Any aSubMenu;
|
|
if( nType == office::MsoControlType::msoControlPopup )
|
|
{
|
|
// it is a Popmenu
|
|
uno::Reference< lang::XSingleComponentFactory > xSCF( m_xBarSettings, uno::UNO_QUERY_THROW );
|
|
aSubMenu <<= xSCF->createInstanceWithContext( mxContext );
|
|
}
|
|
|
|
// create control
|
|
uno::Sequence< beans::PropertyValue > aProps;
|
|
rtl::OUString sHelpUrl;
|
|
sal_uInt16 nItemType = 0;
|
|
if( IsMenu() )
|
|
{
|
|
aProps = CreateMenuItemData( sCommandUrl, sHelpUrl, sLabel, nItemType, aSubMenu, true, true );
|
|
}
|
|
else
|
|
{
|
|
sal_Bool isVisible = sal_True;
|
|
sal_Int32 nStyle = 0;
|
|
aProps = CreateToolbarItemData( sCommandUrl, sHelpUrl, sLabel, nItemType, aSubMenu, isVisible, nStyle );
|
|
}
|
|
|
|
|
|
uno::Reference< container::XIndexContainer > xIndexContainer( m_xIndexAccess, uno::UNO_QUERY_THROW );
|
|
xIndexContainer->insertByIndex( nPosition, uno::makeAny( aProps ) );
|
|
|
|
pCBarHelper->ApplyChange( m_sResourceUrl, m_xBarSettings );
|
|
|
|
ScVbaCommandBarControl* pNewCommandBarControl = NULL;
|
|
if( nType == office::MsoControlType::msoControlPopup )
|
|
pNewCommandBarControl = new ScVbaCommandBarPopup( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, bTemporary );
|
|
else
|
|
pNewCommandBarControl = new ScVbaCommandBarButton( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, bTemporary );
|
|
|
|
return uno::Reference< XCommandBarControl >( pNewCommandBarControl );
|
|
}
|
|
|
|
// XHelperInterface
|
|
rtl::OUString&
|
|
ScVbaCommandBarControls::getServiceImplName()
|
|
{
|
|
static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaCommandBarControls") );
|
|
return sImplName;
|
|
}
|
|
uno::Sequence<rtl::OUString>
|
|
ScVbaCommandBarControls::getServiceNames()
|
|
{
|
|
static uno::Sequence< rtl::OUString > aServiceNames;
|
|
if ( aServiceNames.getLength() == 0 )
|
|
{
|
|
aServiceNames.realloc( 1 );
|
|
aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.CommandBarControls" ) );
|
|
}
|
|
return aServiceNames;
|
|
}
|
|
|
|
// ============================================================================
|
|
|
|
class VbaDummyIndexAccess : public ::cppu::WeakImplHelper1< container::XIndexAccess >
|
|
{
|
|
public:
|
|
inline VbaDummyIndexAccess() {}
|
|
// XIndexAccess
|
|
virtual ::sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException)
|
|
{ return 0; }
|
|
virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 /*Index*/ ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
|
|
{ throw lang::IndexOutOfBoundsException(); }
|
|
// XElementAccess
|
|
virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException)
|
|
{ return XCommandBarControl::static_type( 0 ); }
|
|
virtual ::sal_Bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException)
|
|
{ return false; }
|
|
};
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
VbaDummyCommandBarControls::VbaDummyCommandBarControls(
|
|
const uno::Reference< XHelperInterface >& xParent,
|
|
const uno::Reference< uno::XComponentContext >& xContext ) throw (uno::RuntimeException) :
|
|
CommandBarControls_BASE( xParent, xContext, new VbaDummyIndexAccess )
|
|
{
|
|
}
|
|
|
|
// XEnumerationAccess
|
|
uno::Type SAL_CALL VbaDummyCommandBarControls::getElementType() throw ( uno::RuntimeException )
|
|
{
|
|
return XCommandBarControl::static_type( 0 );
|
|
}
|
|
|
|
uno::Reference< container::XEnumeration > VbaDummyCommandBarControls::createEnumeration() throw ( uno::RuntimeException )
|
|
{
|
|
return uno::Reference< container::XEnumeration >( new CommandBarControlEnumeration( this ) );
|
|
}
|
|
|
|
uno::Any VbaDummyCommandBarControls::createCollectionObject( const uno::Any& /*aSource*/ )
|
|
{
|
|
return uno::Any( uno::Reference< XCommandBarControl >() );
|
|
}
|
|
|
|
// Methods
|
|
uno::Any SAL_CALL VbaDummyCommandBarControls::Item( const uno::Any& /*aIndex*/, const uno::Any& /*aIndex*/ ) throw (uno::RuntimeException)
|
|
{
|
|
return uno::Any( uno::Reference< XCommandBarControl >() );
|
|
}
|
|
|
|
uno::Reference< XCommandBarControl > SAL_CALL VbaDummyCommandBarControls::Add(
|
|
const uno::Any& /*Type*/, const uno::Any& /*Id*/, const uno::Any& /*Parameter*/, const uno::Any& /*Before*/, const uno::Any& /*Temporary*/ ) throw (script::BasicErrorException, uno::RuntimeException)
|
|
{
|
|
return uno::Reference< XCommandBarControl >();
|
|
}
|
|
|
|
// XHelperInterface
|
|
rtl::OUString& VbaDummyCommandBarControls::getServiceImplName()
|
|
{
|
|
static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("VbaDummyCommandBarControls") );
|
|
return sImplName;
|
|
}
|
|
|
|
uno::Sequence<rtl::OUString> VbaDummyCommandBarControls::getServiceNames()
|
|
{
|
|
static uno::Sequence< rtl::OUString > aServiceNames;
|
|
if ( aServiceNames.getLength() == 0 )
|
|
{
|
|
aServiceNames.realloc( 1 );
|
|
aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.CommandBarControls" ) );
|
|
}
|
|
return aServiceNames;
|
|
}
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|