23#include <helper/property.hxx>
24#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
25#include <com/sun/star/uno/XComponentContext.hpp>
45 throw IllegalArgumentException();
50 throw IndexOutOfBoundsException();
59 ,maContainerListeners( *this )
79 OUString UnoControlRoadmapModel::getServiceName()
81 return "stardiv.vcl.controlmodel.Roadmap";
84 OUString UnoControlRoadmapModel::getImplementationName()
86 return "stardiv.Toolkit.UnoControlRoadmapModel";
89 css::uno::Sequence<OUString>
90 UnoControlRoadmapModel::getSupportedServiceNames()
92 auto s(UnoControlRoadmapModel_Base::getSupportedServiceNames());
93 s.realloc(s.getLength() + 2);
94 auto ps = s.getArray();
95 ps[s.getLength() - 2] =
"com.sun.star.awt.UnoControlRoadmapModel";
96 ps[s.getLength() - 1] =
"stardiv.vcl.controlmodel.Roadmap";
100 Any UnoControlRoadmapModel::ImplGetDefaultValue( sal_uInt16 nPropId )
const
112 aReturn <<= sal_Int16(-1);
117 aReturn <<= sal_Int16(2);
120 aReturn <<= OUString(
"stardiv.vcl.control.Roadmap" );
122 default : aReturn = UnoControlRoadmapModel_Base::ImplGetDefaultValue( nPropId );
break;
129 Reference< XInterface > SAL_CALL UnoControlRoadmapModel::createInstance( )
132 Reference< XInterface > xNewRoadmapItem =
static_cast<cppu::OWeakObject*
>(pRoadmapItem.get());
133 return xNewRoadmapItem;
137 Reference< XInterface > SAL_CALL UnoControlRoadmapModel::createInstanceWithArguments(
const Sequence< Any >& )
141 Reference< XInterface > xNewRoadmapItem =
static_cast<cppu::OWeakObject*
>(pRoadmapItem.get());
142 return xNewRoadmapItem;
151 Any aRet = UnoControlRoadmapModel_Base::queryAggregation( rType );
152 if ( !aRet.hasValue() )
153 aRet = UnoControlRoadmapModel_IBase::queryInterface( rType );
167 Reference< XPropertySetInfo > UnoControlRoadmapModel::getPropertySetInfo( )
169 static Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
174 sal_Int32 SAL_CALL UnoControlRoadmapModel::getCount()
176 return maRoadmapItems.size();
179 Any SAL_CALL UnoControlRoadmapModel::getByIndex( sal_Int32
Index )
183 Any aAny( maRoadmapItems.at(
Index ) );
188 void UnoControlRoadmapModel::MakeRMItemValidation( sal_Int32
Index,
const Reference< XInterface >& xRoadmapItem )
192 if ( !xRoadmapItem.is() )
194 Reference< XServiceInfo > xServiceInfo( xRoadmapItem, UNO_QUERY );
195 bool bIsRoadmapItem = xServiceInfo->supportsService(
"com.sun.star.awt.RoadmapItem");
196 if ( !bIsRoadmapItem )
201 void UnoControlRoadmapModel::SetRMItemDefaultProperties(
const Reference< XInterface >& xRoadmapItem)
203 Reference< XPropertySet > xPropertySet( xRoadmapItem, UNO_QUERY );
204 Reference< XPropertySet > xProps( xRoadmapItem, UNO_QUERY );
208 Any aValue = xPropertySet->getPropertyValue(
"ID");
212 xPropertySet->setPropertyValue(
"ID",
Any(GetUniqueID()) );
221 sal_Int32 UnoControlRoadmapModel::GetUniqueID()
224 bool bIncrement =
true;
226 sal_Int32 n_CurItemID = 0;
227 Reference< XInterface > CurRoadmapItem;
231 for (
const auto& rRoadmapItem : maRoadmapItems )
233 CurRoadmapItem = rRoadmapItem;
234 Reference< XPropertySet > xPropertySet( CurRoadmapItem, UNO_QUERY );
235 aAny = xPropertySet->getPropertyValue(
"ID");
236 aAny >>= n_CurItemID;
237 if (n_CurItemID == CurID)
249 ContainerEvent UnoControlRoadmapModel::GetContainerEvent(sal_Int32
Index,
const Reference< XInterface >& xRoadmapItem)
253 aEvent.Element <<= xRoadmapItem;
259 sal_Int16 UnoControlRoadmapModel::GetCurrentItemID(
const Reference< XPropertySet >& xPropertySet )
262 sal_Int16 n_CurrentItemID = 0;
263 aAny >>= n_CurrentItemID;
264 return n_CurrentItemID;
268 void SAL_CALL UnoControlRoadmapModel::insertByIndex(
const sal_Int32
Index,
const Any& Element)
270 if ( (
Index >= (
static_cast<sal_Int32
>(maRoadmapItems.size()) + 1 ) ) || (
Index < 0))
272 Reference< XInterface > xRoadmapItem;
273 Element >>= xRoadmapItem;
274 MakeRMItemValidation(
Index, xRoadmapItem);
275 SetRMItemDefaultProperties( xRoadmapItem );
276 maRoadmapItems.insert( maRoadmapItems.begin() +
Index, xRoadmapItem);
277 ContainerEvent
aEvent = GetContainerEvent(
Index, xRoadmapItem);
278 maContainerListeners.elementInserted(
aEvent );
279 Reference< XPropertySet > xPropertySet(
this );
280 sal_Int16 n_CurrentItemID = GetCurrentItemID( xPropertySet );
281 if (
Index <= n_CurrentItemID )
283 Any aAny(
static_cast<sal_Int16
>( n_CurrentItemID + 1 ) );
289 void SAL_CALL UnoControlRoadmapModel::removeByIndex( sal_Int32
Index)
293 Reference< XInterface > xRoadmapItem;
294 maRoadmapItems.erase( maRoadmapItems.begin() +
Index );
295 ContainerEvent
aEvent = GetContainerEvent(
Index, xRoadmapItem);
296 maContainerListeners.elementRemoved(
aEvent );
297 Reference< XPropertySet > xPropertySet(
this );
298 sal_Int16 n_CurrentItemID = GetCurrentItemID( xPropertySet );
300 if (
Index > n_CurrentItemID )
303 if ( n_CurrentItemID >=
static_cast<sal_Int32
>(maRoadmapItems.size()) )
305 n_CurrentItemID = sal::static_int_cast< sal_Int16 >(
306 maRoadmapItems.size()-1);
307 if ( n_CurrentItemID < 0 )
309 aAny <<= n_CurrentItemID;
311 else if (
Index == n_CurrentItemID)
312 aAny <<= sal_Int16(-1);
313 else if(
Index < n_CurrentItemID)
314 aAny <<= static_cast<sal_Int16>( n_CurrentItemID - 1 );
319 void SAL_CALL UnoControlRoadmapModel::replaceByIndex(
const sal_Int32
Index,
const Any& Element)
321 Reference< XInterface > xRoadmapItem;
322 Element >>= xRoadmapItem;
323 MakeRMItemValidation(
Index, xRoadmapItem);
324 SetRMItemDefaultProperties( xRoadmapItem );
325 maRoadmapItems.erase( maRoadmapItems.begin() +
Index );
326 maRoadmapItems.insert( maRoadmapItems.begin() +
Index, xRoadmapItem);
327 ContainerEvent
aEvent = GetContainerEvent(
Index, xRoadmapItem);
328 maContainerListeners.elementReplaced(
aEvent );
332 Type SAL_CALL UnoControlRoadmapModel::getElementType()
339 sal_Bool SAL_CALL UnoControlRoadmapModel::hasElements()
341 return !maRoadmapItems.empty();
345 void SAL_CALL UnoControlRoadmapModel::addContainerListener(
const css::uno::Reference< css::container::XContainerListener >& xListener )
347 maContainerListeners.addInterface( xListener );
350 void SAL_CALL UnoControlRoadmapModel::removeContainerListener(
const css::uno::Reference< css::container::XContainerListener >& xListener )
352 maContainerListeners.removeInterface( xListener );
359 UnoRoadmapControl::UnoRoadmapControl()
360 :maItemListeners( *this )
368 if (!ret.hasValue()) {
377 Reference< XContainer > xC(
getModel(), UNO_QUERY );
379 xC->removeContainerListener(
this );
383 xC.set(
getModel(), css::uno::UNO_QUERY);
385 xC->addContainerListener(
this );
408 Reference< XInterface > xRoadmapItem;
409 rEvent.Element >>= xRoadmapItem;
410 Reference< XPropertySet > xRoadmapPropertySet( xRoadmapItem, UNO_QUERY );
411 if ( xRoadmapPropertySet.is() )
412 xRoadmapPropertySet->addPropertyChangeListener( OUString(),
this );
414 Reference< XContainerListener > xPeer(
getPeer(), UNO_QUERY);
417 xPeer->elementInserted( rEvent );
418 Reference < XPropertySet > xPropertySet( xPeer, UNO_QUERY );
419 if ( xPropertySet.is() )
420 xPropertySet->addPropertyChangeListener( OUString(),
this );
427 Reference< XContainerListener > xPeer(
getPeer(), UNO_QUERY);
429 xPeer->elementRemoved( rEvent );
430 Reference< XInterface > xRoadmapItem;
431 rEvent.Element >>= xRoadmapItem;
432 Reference< XPropertySet > xPropertySet( xRoadmapItem, UNO_QUERY );
433 if ( xPropertySet.is() )
434 xPropertySet->removePropertyChangeListener( OUString(),
this );
440 Reference< XContainerListener > xPeer(
getPeer(), UNO_QUERY);
442 xPeer->elementReplaced( rEvent );
448 sal_Int16 CurItemIndex = sal::static_int_cast< sal_Int16 >(rEvent.ItemId);
450 Reference< XPropertySet > xPropertySet(
xModel, UNO_QUERY );
462 Reference < XItemEventBroadcaster > xRoadmap(
getPeer(), UNO_QUERY );
463 xRoadmap->addItemListener(
this );
472 Reference < XItemEventBroadcaster > xRoadmap(
getPeer(), UNO_QUERY );
473 xRoadmap->removeItemListener(
this );
482 Reference< XPropertyChangeListener > xPeer(
getPeer(), UNO_QUERY);
484 xPeer->propertyChange( evt );
489 return "stardiv.Toolkit.UnoRoadmapControl";
495 s.realloc(s.getLength() + 2);
496 auto ps = s.getArray();
497 ps[s.getLength() - 2] =
"com.sun.star.awt.UnoControlRoadmap";
498 ps[s.getLength() - 1] =
"stardiv.vcl.control.Roadmap";
504extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
506 css::uno::XComponentContext *context,
507 css::uno::Sequence<css::uno::Any>
const &)
512extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
514 css::uno::XComponentContext *,
515 css::uno::Sequence<css::uno::Any>
const &)
css::uno::Reference< css::awt::XControlModel > SAL_CALL getModel() override
void SAL_CALL dispose() override
sal_Bool SAL_CALL setModel(const css::uno::Reference< css::awt::XControlModel > &Model) override
css::uno::Reference< css::awt::XWindowPeer > SAL_CALL getPeer() override
css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const &rType) SAL_OVERRIDE
css::uno::Type const & get()
virtual css::uno::Any SAL_CALL queryAggregation(css::uno::Type const &rType) SAL_OVERRIDE
static void lcl_throwIllegalArgumentException()
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
const OUString & GetPropertyName(sal_uInt16 nPropertyId)
#define BASEPROPERTY_COMPLETE
#define BASEPROPERTY_BORDER
#define BASEPROPERTY_CURRENTITEMID
#define BASEPROPERTY_TEXT
#define BASEPROPERTY_HELPURL
#define BASEPROPERTY_ACTIVATED
#define BASEPROPERTY_IMAGEURL
#define BASEPROPERTY_BACKGROUNDCOLOR
#define BASEPROPERTY_TABSTOP
#define BASEPROPERTY_DEFAULTCONTROL
#define BASEPROPERTY_GRAPHIC
#define BASEPROPERTY_BORDERCOLOR
#define BASEPROPERTY_FONTDESCRIPTOR
#define BASEPROPERTY_HELPTEXT
#define BASEPROPERTY_PRINTABLE
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * stardiv_Toolkit_UnoControlRoadmapModel_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * stardiv_Toolkit_UnoRoadmapControl_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
IMPLEMENT_FORWARD_XTYPEPROVIDER2(ORoadmapEntry, ORoadmapEntry_Base, ::comphelper::OPropertyContainer)
Reference< XModel > xModel