UnoControls: inline defines or convert to enum
and remove needless local statics Change-Id: Iaa2d7776d439a824e521d0bb7ef51a9f8e44c009 Reviewed-on: https://gerrit.libreoffice.org/38595 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
committed by
Noel Grandin
parent
eb3bcfff0e
commit
2347dcf3ba
@@ -44,6 +44,13 @@ using namespace ::com::sun::star::util;
|
|||||||
|
|
||||||
namespace unocontrols{
|
namespace unocontrols{
|
||||||
|
|
||||||
|
enum PropertyHandle // values represent index in PropertyArray
|
||||||
|
{ // for FrameControl
|
||||||
|
Componenturl = 0,
|
||||||
|
Frame = 1,
|
||||||
|
Loaderarguments = 2
|
||||||
|
};
|
||||||
|
|
||||||
// construct/destruct
|
// construct/destruct
|
||||||
|
|
||||||
FrameControl::FrameControl( const Reference< XComponentContext >& rxContext)
|
FrameControl::FrameControl( const Reference< XComponentContext >& rxContext)
|
||||||
@@ -245,7 +252,7 @@ void SAL_CALL FrameControl::unadvise( const Type& aTyp
|
|||||||
|
|
||||||
const Sequence< OUString > FrameControl::impl_getStaticSupportedServiceNames()
|
const Sequence< OUString > FrameControl::impl_getStaticSupportedServiceNames()
|
||||||
{
|
{
|
||||||
Sequence<OUString> seqServiceNames { SERVICENAME_FRAMECONTROL };
|
Sequence<OUString> seqServiceNames { "com.sun.star.frame.FrameControl" };
|
||||||
return seqServiceNames;
|
return seqServiceNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,7 +260,7 @@ const Sequence< OUString > FrameControl::impl_getStaticSupportedServiceNames()
|
|||||||
|
|
||||||
const OUString FrameControl::impl_getStaticImplementationName()
|
const OUString FrameControl::impl_getStaticImplementationName()
|
||||||
{
|
{
|
||||||
return OUString(IMPLEMENTATIONNAME_FRAMECONTROL);
|
return OUString("stardiv.UnoControls.FrameControl");
|
||||||
}
|
}
|
||||||
|
|
||||||
// OPropertySetHelper
|
// OPropertySetHelper
|
||||||
@@ -266,12 +273,12 @@ sal_Bool FrameControl::convertFastPropertyValue( Any& rConvertedVa
|
|||||||
bool bReturn = false;
|
bool bReturn = false;
|
||||||
switch (nHandle)
|
switch (nHandle)
|
||||||
{
|
{
|
||||||
case PROPERTYHANDLE_COMPONENTURL : rConvertedValue = rValue;
|
case PropertyHandle::Componenturl : rConvertedValue = rValue;
|
||||||
rOldValue <<= m_sComponentURL;
|
rOldValue <<= m_sComponentURL;
|
||||||
bReturn = true;
|
bReturn = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROPERTYHANDLE_LOADERARGUMENTS : rConvertedValue = rValue;
|
case PropertyHandle::Loaderarguments : rConvertedValue = rValue;
|
||||||
rOldValue <<= m_seqLoaderArguments;
|
rOldValue <<= m_seqLoaderArguments;
|
||||||
bReturn = true;
|
bReturn = true;
|
||||||
break;
|
break;
|
||||||
@@ -294,14 +301,14 @@ void FrameControl::setFastPropertyValue_NoBroadcast( sal_Int32 nHan
|
|||||||
MutexGuard aGuard (m_aMutex);
|
MutexGuard aGuard (m_aMutex);
|
||||||
switch (nHandle)
|
switch (nHandle)
|
||||||
{
|
{
|
||||||
case PROPERTYHANDLE_COMPONENTURL : rValue >>= m_sComponentURL;
|
case PropertyHandle::Componenturl : rValue >>= m_sComponentURL;
|
||||||
if (getPeer().is())
|
if (getPeer().is())
|
||||||
{
|
{
|
||||||
impl_createFrame ( getPeer(), m_sComponentURL, m_seqLoaderArguments );
|
impl_createFrame ( getPeer(), m_sComponentURL, m_seqLoaderArguments );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROPERTYHANDLE_LOADERARGUMENTS : rValue >>= m_seqLoaderArguments;
|
case PropertyHandle::Loaderarguments : rValue >>= m_seqLoaderArguments;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default : OSL_ENSURE ( nHandle == -1, "This is an invalid property handle." );
|
default : OSL_ENSURE ( nHandle == -1, "This is an invalid property handle." );
|
||||||
@@ -317,13 +324,13 @@ void FrameControl::getFastPropertyValue( Any& rRet ,
|
|||||||
|
|
||||||
switch (nHandle)
|
switch (nHandle)
|
||||||
{
|
{
|
||||||
case PROPERTYHANDLE_COMPONENTURL : rRet <<= m_sComponentURL;
|
case PropertyHandle::Componenturl : rRet <<= m_sComponentURL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROPERTYHANDLE_LOADERARGUMENTS : rRet <<= m_seqLoaderArguments;
|
case PropertyHandle::Loaderarguments : rRet <<= m_seqLoaderArguments;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROPERTYHANDLE_FRAME : rRet <<= m_xFrame;
|
case PropertyHandle::Frame : rRet <<= m_xFrame;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default : OSL_ENSURE ( nHandle == -1, "This is an invalid property handle." );
|
default : OSL_ENSURE ( nHandle == -1, "This is an invalid property handle." );
|
||||||
@@ -335,7 +342,17 @@ void FrameControl::getFastPropertyValue( Any& rRet ,
|
|||||||
IPropertyArrayHelper& FrameControl::getInfoHelper()
|
IPropertyArrayHelper& FrameControl::getInfoHelper()
|
||||||
{
|
{
|
||||||
// Create a table that map names to index values.
|
// Create a table that map names to index values.
|
||||||
static OPropertyArrayHelper ourPropertyInfo( impl_getStaticPropertyDescriptor(), true );
|
// attention: properties need to be sorted by name!
|
||||||
|
static OPropertyArrayHelper ourPropertyInfo(
|
||||||
|
{
|
||||||
|
Property( "ComponentURL", PropertyHandle::Componenturl, cppu::UnoType<OUString>::get(),
|
||||||
|
PropertyAttribute::BOUND | PropertyAttribute::CONSTRAINED ),
|
||||||
|
Property( "Frame", PropertyHandle::Frame, cppu::UnoType<XFrame>::get(),
|
||||||
|
PropertyAttribute::BOUND | PropertyAttribute::TRANSIENT ),
|
||||||
|
Property( "LoaderArguments", PropertyHandle::Loaderarguments, cppu::UnoType<Sequence<PropertyValue>>::get(),
|
||||||
|
PropertyAttribute::BOUND | PropertyAttribute::CONSTRAINED )
|
||||||
|
},
|
||||||
|
true );
|
||||||
|
|
||||||
return ourPropertyInfo;
|
return ourPropertyInfo;
|
||||||
}
|
}
|
||||||
@@ -407,7 +424,7 @@ void FrameControl::impl_createFrame( const Reference< XWindowPeer >& xPee
|
|||||||
}
|
}
|
||||||
|
|
||||||
// notify the listeners
|
// notify the listeners
|
||||||
sal_Int32 nFrameId = PROPERTYHANDLE_FRAME;
|
sal_Int32 nFrameId = PropertyHandle::Frame;
|
||||||
Any aNewFrame ( &xNewFrame, cppu::UnoType<XFrame>::get());
|
Any aNewFrame ( &xNewFrame, cppu::UnoType<XFrame>::get());
|
||||||
Any aOldFrame ( &xOldFrame, cppu::UnoType<XFrame>::get());
|
Any aOldFrame ( &xOldFrame, cppu::UnoType<XFrame>::get());
|
||||||
|
|
||||||
@@ -434,7 +451,7 @@ void FrameControl::impl_deleteFrame()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// notify the listeners
|
// notify the listeners
|
||||||
sal_Int32 nFrameId = PROPERTYHANDLE_FRAME;
|
sal_Int32 nFrameId = PropertyHandle::Frame;
|
||||||
Any aNewFrame( &xNullFrame, cppu::UnoType<XFrame2>::get());
|
Any aNewFrame( &xNullFrame, cppu::UnoType<XFrame2>::get());
|
||||||
Any aOldFrame( &xOldFrame, cppu::UnoType<XFrame2>::get());
|
Any aOldFrame( &xOldFrame, cppu::UnoType<XFrame2>::get());
|
||||||
fire( &nFrameId, &aNewFrame, &aOldFrame, 1, false );
|
fire( &nFrameId, &aNewFrame, &aOldFrame, 1, false );
|
||||||
@@ -444,22 +461,6 @@ void FrameControl::impl_deleteFrame()
|
|||||||
xOldFrame->dispose();
|
xOldFrame->dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
// private method
|
|
||||||
|
|
||||||
const Sequence< Property >& FrameControl::impl_getStaticPropertyDescriptor()
|
|
||||||
{
|
|
||||||
// All Properties of this implementation. The array must be sorted!
|
|
||||||
static const Property pPropertys[PROPERTY_COUNT] =
|
|
||||||
{
|
|
||||||
Property( PROPERTYNAME_COMPONENTURL, PROPERTYHANDLE_COMPONENTURL, cppu::UnoType<OUString>::get(), PropertyAttribute::BOUND | PropertyAttribute::CONSTRAINED ),
|
|
||||||
Property( PROPERTYNAME_FRAME, PROPERTYHANDLE_FRAME, cppu::UnoType<XFrame>::get(), PropertyAttribute::BOUND | PropertyAttribute::TRANSIENT ),
|
|
||||||
Property( PROPERTYNAME_LOADERARGUMENTS, PROPERTYHANDLE_LOADERARGUMENTS, cppu::UnoType<Sequence<PropertyValue>>::get(), PropertyAttribute::BOUND | PropertyAttribute::CONSTRAINED )
|
|
||||||
};
|
|
||||||
|
|
||||||
static const Sequence< Property > seqPropertys( pPropertys, PROPERTY_COUNT );
|
|
||||||
|
|
||||||
return seqPropertys;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace unocontrols
|
} // namespace unocontrols
|
||||||
|
|
||||||
|
@@ -38,16 +38,6 @@
|
|||||||
|
|
||||||
namespace unocontrols{
|
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 PROPERTY_COUNT 3 // you must count the properties
|
|
||||||
#define PROPERTYHANDLE_COMPONENTURL 0 // Id must be the index into the array
|
|
||||||
#define PROPERTYHANDLE_FRAME 1
|
|
||||||
#define PROPERTYHANDLE_LOADERARGUMENTS 2
|
|
||||||
|
|
||||||
// class
|
// class
|
||||||
|
|
||||||
class FrameControl : public css::awt::XControlModel
|
class FrameControl : public css::awt::XControlModel
|
||||||
@@ -198,8 +188,6 @@ private:
|
|||||||
|
|
||||||
void impl_deleteFrame();
|
void impl_deleteFrame();
|
||||||
|
|
||||||
static const css::uno::Sequence< css::beans::Property >& impl_getStaticPropertyDescriptor();
|
|
||||||
|
|
||||||
// private variables
|
// private variables
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Reference in New Issue
Block a user