fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / framework / source / fwe / helper / propertysetcontainer.cxx
blob8365ab45a50da35dee9a2e41ca98d57f274750aa
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <helper/propertysetcontainer.hxx>
22 #include <cppuhelper/queryinterface.hxx>
23 #include <vcl/svapp.hxx>
25 #define WRONG_TYPE_EXCEPTION "Only XPropertSet allowed!"
27 using namespace cppu;
28 using namespace com::sun::star::uno;
29 using namespace com::sun::star::container;
30 using namespace com::sun::star::lang;
31 using namespace com::sun::star::beans;
33 namespace framework
36 PropertySetContainer::PropertySetContainer()
37 : OWeakObject()
42 PropertySetContainer::~PropertySetContainer()
46 // XInterface
47 void SAL_CALL PropertySetContainer::acquire() throw ()
49 OWeakObject::acquire();
52 void SAL_CALL PropertySetContainer::release() throw ()
54 OWeakObject::release();
57 Any SAL_CALL PropertySetContainer::queryInterface( const Type& rType )
58 throw ( RuntimeException, std::exception )
60 Any a = ::cppu::queryInterface(
61 rType ,
62 (static_cast< XIndexContainer* >(this)),
63 (static_cast< XIndexReplace* >(this)),
64 (static_cast< XIndexAccess* >(this)),
65 (static_cast< XElementAccess* >(this)) );
67 if( a.hasValue() )
69 return a;
72 return OWeakObject::queryInterface( rType );
75 // XIndexContainer
76 void SAL_CALL PropertySetContainer::insertByIndex( sal_Int32 Index, const ::com::sun::star::uno::Any& Element )
77 throw ( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException, std::exception )
79 SolarMutexGuard g;
81 sal_Int32 nSize = m_aPropertySetVector.size();
83 if ( nSize >= Index )
85 Reference< XPropertySet > aPropertySetElement;
87 if ( Element >>= aPropertySetElement )
89 if ( nSize == Index )
90 m_aPropertySetVector.push_back( aPropertySetElement );
91 else
93 PropertySetVector::iterator aIter = m_aPropertySetVector.begin();
94 aIter += Index;
95 m_aPropertySetVector.insert( aIter, aPropertySetElement );
98 else
100 throw IllegalArgumentException(
101 WRONG_TYPE_EXCEPTION,
102 (OWeakObject *)this, 2 );
105 else
106 throw IndexOutOfBoundsException( OUString(), (OWeakObject *)this );
109 void SAL_CALL PropertySetContainer::removeByIndex( sal_Int32 nIndex )
110 throw ( IndexOutOfBoundsException, WrappedTargetException, RuntimeException, std::exception )
112 SolarMutexGuard g;
114 if ( (sal_Int32)m_aPropertySetVector.size() > nIndex )
116 m_aPropertySetVector.erase(m_aPropertySetVector.begin() + nIndex);
118 else
119 throw IndexOutOfBoundsException( OUString(), (OWeakObject *)this );
122 // XIndexReplace
123 void SAL_CALL PropertySetContainer::replaceByIndex( sal_Int32 Index, const ::com::sun::star::uno::Any& Element )
124 throw ( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException, std::exception)
126 if ( (sal_Int32)m_aPropertySetVector.size() > Index )
128 Reference< XPropertySet > aPropertySetElement;
130 if ( Element >>= aPropertySetElement )
132 m_aPropertySetVector[ Index ] = aPropertySetElement;
134 else
136 throw IllegalArgumentException(
137 WRONG_TYPE_EXCEPTION,
138 (OWeakObject *)this, 2 );
141 else
142 throw IndexOutOfBoundsException( OUString(), (OWeakObject *)this );
145 // XIndexAccess
146 sal_Int32 SAL_CALL PropertySetContainer::getCount()
147 throw ( RuntimeException, std::exception )
149 SolarMutexGuard g;
151 return m_aPropertySetVector.size();
154 Any SAL_CALL PropertySetContainer::getByIndex( sal_Int32 Index )
155 throw ( IndexOutOfBoundsException, WrappedTargetException, RuntimeException, std::exception )
157 SolarMutexGuard g;
159 if ( (sal_Int32)m_aPropertySetVector.size() > Index )
161 Any a;
163 a <<= m_aPropertySetVector[ Index ];
164 return a;
166 else
167 throw IndexOutOfBoundsException( OUString(), (OWeakObject *)this );
170 // XElementAccess
171 sal_Bool SAL_CALL PropertySetContainer::hasElements()
172 throw (::com::sun::star::uno::RuntimeException, std::exception)
174 SolarMutexGuard g;
176 return !( m_aPropertySetVector.empty() );
181 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */