xref: /AOO41X/main/svx/source/form/fmdpage.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
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.
14  *
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).
20  *
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.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_svx.hxx"
30 #include <svx/fmpage.hxx>
31 #include "fmobj.hxx"
32 #include <svx/fmglob.hxx>
33 #include <svx/fmdpage.hxx>
34 #include <svx/unoshape.hxx>
35 #include <cppuhelper/queryinterface.hxx>
36 #include <cppuhelper/typeprovider.hxx>
37 
38 using ::com::sun::star::uno::Any;
39 using ::com::sun::star::uno::RuntimeException;
40 using ::com::sun::star::form::XFormsSupplier2;
41 
42 DBG_NAME(SvxFmDrawPage)
43 SvxFmDrawPage::SvxFmDrawPage( SdrPage* pInPage ) :
44 	SvxDrawPage( pInPage )
45 {
46 	DBG_CTOR(SvxFmDrawPage,NULL);
47 }
48 
49 SvxFmDrawPage::~SvxFmDrawPage() throw ()
50 {
51 	DBG_DTOR(SvxFmDrawPage,NULL);
52 }
53 
54 ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL SvxFmDrawPage::getImplementationId() throw(::com::sun::star::uno::RuntimeException)
55 {
56     static ::cppu::OImplementationId* pId = 0;
57 	if (! pId)
58 	{
59         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
60 		if (! pId)
61 		{
62 			static ::cppu::OImplementationId aId;
63 			pId = &aId;
64 		}
65 	}
66 	return pId->getImplementationId();
67 }
68 
69 Any SAL_CALL SvxFmDrawPage::queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(RuntimeException)
70 {
71 	Any aRet = ::cppu::queryInterface   (   _rType
72 		                                ,   static_cast< XFormsSupplier2* >( this )
73 		                                ,   static_cast< XFormsSupplier* >( this )
74                                         );
75 	if ( !aRet.hasValue() )
76 		aRet = SvxDrawPage::queryAggregation( _rType );
77 
78     return aRet;
79 }
80 
81 /***********************************************************************
82 *                                                                      *
83 ***********************************************************************/
84 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL SvxFmDrawPage::getTypes(  ) throw(::com::sun::star::uno::RuntimeException)
85 {
86 	::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypes(SvxDrawPage::getTypes());
87 	aTypes.realloc(aTypes.getLength() + 1);
88 	::com::sun::star::uno::Type* pTypes = aTypes.getArray();
89 
90 	pTypes[aTypes.getLength()-1] = ::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormsSupplier>*)0);
91 	return aTypes;
92 }
93 
94 SdrObject *SvxFmDrawPage::_CreateSdrObject( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > & xDescr ) throw ()
95 {
96 	::rtl::OUString aShapeType( xDescr->getShapeType() );
97 
98 	if  (   aShapeType.equalsAscii( "com.sun.star.drawing.ShapeControl" )   // compatibility
99         ||  aShapeType.equalsAscii( "com.sun.star.drawing.ControlShape" )
100         )
101 		return new FmFormObj( OBJ_FM_CONTROL );
102 	else
103 		return SvxDrawPage::_CreateSdrObject( xDescr );
104 
105 }
106 
107 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >  SvxFmDrawPage::_CreateShape( SdrObject *pObj ) const throw ()
108 {
109 	if( FmFormInventor == pObj->GetObjInventor() )
110 	{
111 		::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >  xShape = (SvxShape*)new SvxShapeControl( pObj );
112 		return xShape;
113 	}
114 	else
115 		return SvxDrawPage::_CreateShape( pObj );
116 }
117 
118 // XFormsSupplier
119 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > SAL_CALL SvxFmDrawPage::getForms(void) throw( ::com::sun::star::uno::RuntimeException )
120 {
121 	::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >  xForms;
122 
123 	FmFormPage *pFmPage = PTR_CAST( FmFormPage, GetSdrPage() );
124 	if( pFmPage )
125 		xForms = pFmPage->GetForms();
126 
127 	return xForms;
128 }
129 
130 // XFormsSupplier2
131 sal_Bool SAL_CALL SvxFmDrawPage::hasForms(void) throw( ::com::sun::star::uno::RuntimeException )
132 {
133     sal_Bool bHas = sal_False;
134 	FmFormPage* pFormPage = PTR_CAST( FmFormPage, GetSdrPage() );
135 	if ( pFormPage )
136 		bHas = pFormPage->GetForms( false ).is();
137 	return bHas;
138 }
139 
140 // ::com::sun::star::lang::XServiceInfo
141 ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL SvxFmDrawPage::getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException )
142 {
143 	return SvxDrawPage::getSupportedServiceNames();
144 }
145 
146 
147