merge the formfield patch from ooo-build
[ooovba.git] / svx / source / form / fmdpage.cxx
blob5765d00bf8fdd95de220028c3f11582693eb7a19
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: fmdpage.cxx,v $
10 * $Revision: 1.12 $
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_svx.hxx"
33 #include <svx/fmpage.hxx>
34 #include "fmobj.hxx"
35 #include <svx/fmglob.hxx>
36 #include <svx/fmdpage.hxx>
37 #include <svx/unoshape.hxx>
38 #include <cppuhelper/queryinterface.hxx>
39 #include <cppuhelper/typeprovider.hxx>
41 using ::com::sun::star::uno::Any;
42 using ::com::sun::star::uno::RuntimeException;
43 using ::com::sun::star::form::XFormsSupplier2;
45 DBG_NAME(SvxFmDrawPage)
46 SvxFmDrawPage::SvxFmDrawPage( SdrPage* pInPage ) :
47 SvxDrawPage( pInPage )
49 DBG_CTOR(SvxFmDrawPage,NULL);
52 SvxFmDrawPage::~SvxFmDrawPage() throw ()
54 DBG_DTOR(SvxFmDrawPage,NULL);
57 ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL SvxFmDrawPage::getImplementationId() throw(::com::sun::star::uno::RuntimeException)
59 static ::cppu::OImplementationId* pId = 0;
60 if (! pId)
62 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
63 if (! pId)
65 static ::cppu::OImplementationId aId;
66 pId = &aId;
69 return pId->getImplementationId();
72 Any SAL_CALL SvxFmDrawPage::queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(RuntimeException)
74 Any aRet = ::cppu::queryInterface ( _rType
75 , static_cast< XFormsSupplier2* >( this )
76 , static_cast< XFormsSupplier* >( this )
78 if ( !aRet.hasValue() )
79 aRet = SvxDrawPage::queryAggregation( _rType );
81 return aRet;
84 /***********************************************************************
85 * *
86 ***********************************************************************/
87 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL SvxFmDrawPage::getTypes( ) throw(::com::sun::star::uno::RuntimeException)
89 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypes(SvxDrawPage::getTypes());
90 aTypes.realloc(aTypes.getLength() + 1);
91 ::com::sun::star::uno::Type* pTypes = aTypes.getArray();
93 pTypes[aTypes.getLength()-1] = ::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormsSupplier>*)0);
94 return aTypes;
97 SdrObject *SvxFmDrawPage::_CreateSdrObject( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > & xDescr ) throw ()
99 ::rtl::OUString aShapeType( xDescr->getShapeType() );
101 if ( aShapeType.equalsAscii( "com.sun.star.drawing.ShapeControl" ) // compatibility
102 || aShapeType.equalsAscii( "com.sun.star.drawing.ControlShape" )
104 return new FmFormObj( OBJ_FM_CONTROL );
105 else
106 return SvxDrawPage::_CreateSdrObject( xDescr );
110 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > SvxFmDrawPage::_CreateShape( SdrObject *pObj ) const throw ()
112 if( FmFormInventor == pObj->GetObjInventor() )
114 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape = (SvxShape*)new SvxShapeControl( pObj );
115 return xShape;
117 else
118 return SvxDrawPage::_CreateShape( pObj );
121 // XFormsSupplier
122 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > SAL_CALL SvxFmDrawPage::getForms(void) throw( ::com::sun::star::uno::RuntimeException )
124 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > xForms;
126 FmFormPage *pFmPage = PTR_CAST( FmFormPage, GetSdrPage() );
127 if( pFmPage )
128 xForms = pFmPage->GetForms();
130 return xForms;
133 // XFormsSupplier2
134 sal_Bool SAL_CALL SvxFmDrawPage::hasForms(void) throw( ::com::sun::star::uno::RuntimeException )
136 sal_Bool bHas = sal_False;
137 FmFormPage* pFormPage = PTR_CAST( FmFormPage, GetSdrPage() );
138 if ( pFormPage )
139 bHas = pFormPage->GetForms( false ).is();
140 return bHas;
143 // ::com::sun::star::lang::XServiceInfo
144 ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL SvxFmDrawPage::getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException )
146 return SvxDrawPage::getSupportedServiceNames();