Update ooo320-m1
[ooovba.git] / chart2 / source / model / main / LayoutContainer.cxx
blob1ba44198cc0c4d580a7afb717d265d85e41c5bb9
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: LayoutContainer.cxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_chart2.hxx"
33 #include "LayoutContainer.hxx"
34 #include "macros.hxx"
35 #include "ContainerHelper.hxx"
37 #include <algorithm>
39 using namespace ::com::sun::star;
41 namespace
44 static const ::rtl::OUString lcl_aServiceName(
45 RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.layout.LayoutContainer" ));
46 } // anonymous namespace
48 namespace chart
51 LayoutContainer::LayoutContainer()
54 LayoutContainer::~LayoutContainer()
57 // ____ XLayoutContainer ____
58 void SAL_CALL LayoutContainer::addConstrainedElementByIdentifier(
59 const ::rtl::OUString& aIdentifier,
60 const layout::Constraint& Constraint )
61 throw (layout::IllegalConstraintException,
62 lang::IllegalArgumentException,
63 uno::RuntimeException)
65 addElementByIdentifier( aIdentifier );
66 m_aConstraints[ aIdentifier ] = Constraint;
69 void SAL_CALL LayoutContainer::addElementByIdentifier( const ::rtl::OUString& aIdentifier )
70 throw (lang::IllegalArgumentException,
71 uno::RuntimeException)
73 if( ::std::find( m_aLayoutElements.begin(),
74 m_aLayoutElements.end(),
75 aIdentifier ) != m_aLayoutElements.end())
76 throw lang::IllegalArgumentException();
78 m_aLayoutElements.push_back( aIdentifier );
81 void SAL_CALL LayoutContainer::removeElementByIdentifier( const ::rtl::OUString& aIdentifier )
82 throw (container::NoSuchElementException,
83 uno::RuntimeException)
85 tLayoutElements::iterator aIt(
86 ::std::find( m_aLayoutElements.begin(),
87 m_aLayoutElements.end(),
88 aIdentifier ));
90 if( aIt == m_aLayoutElements.end())
91 throw container::NoSuchElementException();
93 m_aLayoutElements.erase( aIt );
94 m_aConstraints.erase( aIdentifier );
97 void SAL_CALL LayoutContainer::setConstraintByIdentifier(
98 const ::rtl::OUString& aIdentifier,
99 const layout::Constraint& Constraint )
100 throw (container::NoSuchElementException,
101 uno::RuntimeException)
103 if( ::std::find( m_aLayoutElements.begin(),
104 m_aLayoutElements.end(),
105 aIdentifier ) == m_aLayoutElements.end())
106 throw container::NoSuchElementException();
108 m_aConstraints[ aIdentifier ] = Constraint;
111 layout::Constraint SAL_CALL LayoutContainer::getConstraintByIdentifier( const ::rtl::OUString& aIdentifier )
112 throw (container::NoSuchElementException,
113 uno::RuntimeException)
115 tConstraintsMap::const_iterator aIt( m_aConstraints.find( aIdentifier ));
116 if( aIt == m_aConstraints.end())
117 throw container::NoSuchElementException();
119 return (*aIt).second;
122 uno::Sequence< ::rtl::OUString > SAL_CALL LayoutContainer::getElementIdentifiers()
123 throw (uno::RuntimeException)
125 return ContainerHelper::ContainerToSequence( m_aLayoutElements );
128 uno::Sequence< ::rtl::OUString > LayoutContainer::getSupportedServiceNames_Static()
130 uno::Sequence< ::rtl::OUString > aServices( 1 );
132 aServices[ 0 ] = C2U( "com.sun.star.layout.LayoutContainer" );
133 return aServices;
136 // --------------------------------------------------------------------------------
138 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
139 APPHELPER_XSERVICEINFO_IMPL( LayoutContainer, lcl_aServiceName );
141 } // namespace chart