merged tag ooo/OOO330_m14
[LibreOffice.git] / chart2 / source / model / main / LayoutContainer.cxx
blobd962113f78c7150778610822883f09532548fcd3
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_chart2.hxx"
30 #include "LayoutContainer.hxx"
31 #include "macros.hxx"
32 #include "ContainerHelper.hxx"
34 #include <algorithm>
36 using namespace ::com::sun::star;
38 namespace
41 static const ::rtl::OUString lcl_aServiceName(
42 RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.layout.LayoutContainer" ));
43 } // anonymous namespace
45 namespace chart
48 LayoutContainer::LayoutContainer()
51 LayoutContainer::~LayoutContainer()
54 // ____ XLayoutContainer ____
55 void SAL_CALL LayoutContainer::addConstrainedElementByIdentifier(
56 const ::rtl::OUString& aIdentifier,
57 const layout::Constraint& Constraint )
58 throw (layout::IllegalConstraintException,
59 lang::IllegalArgumentException,
60 uno::RuntimeException)
62 addElementByIdentifier( aIdentifier );
63 m_aConstraints[ aIdentifier ] = Constraint;
66 void SAL_CALL LayoutContainer::addElementByIdentifier( const ::rtl::OUString& aIdentifier )
67 throw (lang::IllegalArgumentException,
68 uno::RuntimeException)
70 if( ::std::find( m_aLayoutElements.begin(),
71 m_aLayoutElements.end(),
72 aIdentifier ) != m_aLayoutElements.end())
73 throw lang::IllegalArgumentException();
75 m_aLayoutElements.push_back( aIdentifier );
78 void SAL_CALL LayoutContainer::removeElementByIdentifier( const ::rtl::OUString& aIdentifier )
79 throw (container::NoSuchElementException,
80 uno::RuntimeException)
82 tLayoutElements::iterator aIt(
83 ::std::find( m_aLayoutElements.begin(),
84 m_aLayoutElements.end(),
85 aIdentifier ));
87 if( aIt == m_aLayoutElements.end())
88 throw container::NoSuchElementException();
90 m_aLayoutElements.erase( aIt );
91 m_aConstraints.erase( aIdentifier );
94 void SAL_CALL LayoutContainer::setConstraintByIdentifier(
95 const ::rtl::OUString& aIdentifier,
96 const layout::Constraint& Constraint )
97 throw (container::NoSuchElementException,
98 uno::RuntimeException)
100 if( ::std::find( m_aLayoutElements.begin(),
101 m_aLayoutElements.end(),
102 aIdentifier ) == m_aLayoutElements.end())
103 throw container::NoSuchElementException();
105 m_aConstraints[ aIdentifier ] = Constraint;
108 layout::Constraint SAL_CALL LayoutContainer::getConstraintByIdentifier( const ::rtl::OUString& aIdentifier )
109 throw (container::NoSuchElementException,
110 uno::RuntimeException)
112 tConstraintsMap::const_iterator aIt( m_aConstraints.find( aIdentifier ));
113 if( aIt == m_aConstraints.end())
114 throw container::NoSuchElementException();
116 return (*aIt).second;
119 uno::Sequence< ::rtl::OUString > SAL_CALL LayoutContainer::getElementIdentifiers()
120 throw (uno::RuntimeException)
122 return ContainerHelper::ContainerToSequence( m_aLayoutElements );
125 uno::Sequence< ::rtl::OUString > LayoutContainer::getSupportedServiceNames_Static()
127 uno::Sequence< ::rtl::OUString > aServices( 1 );
129 aServices[ 0 ] = C2U( "com.sun.star.layout.LayoutContainer" );
130 return aServices;
133 // --------------------------------------------------------------------------------
135 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
136 APPHELPER_XSERVICEINFO_IMPL( LayoutContainer, lcl_aServiceName );
138 } // namespace chart