1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_svx.hxx" 26 #include <svx/fmpage.hxx> 27 #include "fmobj.hxx" 28 #include <svx/fmglob.hxx> 29 #include <svx/fmdpage.hxx> 30 #include <svx/unoshape.hxx> 31 #include <cppuhelper/queryinterface.hxx> 32 #include <cppuhelper/typeprovider.hxx> 33 34 using ::com::sun::star::uno::Any; 35 using ::com::sun::star::uno::RuntimeException; 36 using ::com::sun::star::form::XFormsSupplier2; 37 38 DBG_NAME(SvxFmDrawPage) 39 SvxFmDrawPage::SvxFmDrawPage( SdrPage* pInPage ) : 40 SvxDrawPage( pInPage ) 41 { 42 DBG_CTOR(SvxFmDrawPage,NULL); 43 } 44 45 SvxFmDrawPage::~SvxFmDrawPage() throw () 46 { 47 DBG_DTOR(SvxFmDrawPage,NULL); 48 } 49 50 ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL SvxFmDrawPage::getImplementationId() throw(::com::sun::star::uno::RuntimeException) 51 { 52 static ::cppu::OImplementationId* pId = 0; 53 if (! pId) 54 { 55 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); 56 if (! pId) 57 { 58 static ::cppu::OImplementationId aId; 59 pId = &aId; 60 } 61 } 62 return pId->getImplementationId(); 63 } 64 65 Any SAL_CALL SvxFmDrawPage::queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(RuntimeException) 66 { 67 Any aRet = ::cppu::queryInterface ( _rType 68 , static_cast< XFormsSupplier2* >( this ) 69 , static_cast< XFormsSupplier* >( this ) 70 ); 71 if ( !aRet.hasValue() ) 72 aRet = SvxDrawPage::queryAggregation( _rType ); 73 74 return aRet; 75 } 76 77 /*********************************************************************** 78 * * 79 ***********************************************************************/ 80 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL SvxFmDrawPage::getTypes( ) throw(::com::sun::star::uno::RuntimeException) 81 { 82 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypes(SvxDrawPage::getTypes()); 83 aTypes.realloc(aTypes.getLength() + 1); 84 ::com::sun::star::uno::Type* pTypes = aTypes.getArray(); 85 86 pTypes[aTypes.getLength()-1] = ::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormsSupplier>*)0); 87 return aTypes; 88 } 89 90 SdrObject *SvxFmDrawPage::_CreateSdrObject( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > & xDescr ) throw () 91 { 92 ::rtl::OUString aShapeType( xDescr->getShapeType() ); 93 94 if ( aShapeType.equalsAscii( "com.sun.star.drawing.ShapeControl" ) // compatibility 95 || aShapeType.equalsAscii( "com.sun.star.drawing.ControlShape" ) 96 ) 97 return new FmFormObj( OBJ_FM_CONTROL ); 98 else 99 return SvxDrawPage::_CreateSdrObject( xDescr ); 100 101 } 102 103 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > SvxFmDrawPage::_CreateShape( SdrObject *pObj ) const throw () 104 { 105 if( FmFormInventor == pObj->GetObjInventor() ) 106 { 107 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape = (SvxShape*)new SvxShapeControl( pObj ); 108 return xShape; 109 } 110 else 111 return SvxDrawPage::_CreateShape( pObj ); 112 } 113 114 // XFormsSupplier 115 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > SAL_CALL SvxFmDrawPage::getForms(void) throw( ::com::sun::star::uno::RuntimeException ) 116 { 117 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > xForms; 118 119 FmFormPage *pFmPage = PTR_CAST( FmFormPage, GetSdrPage() ); 120 if( pFmPage ) 121 xForms = pFmPage->GetForms(); 122 123 return xForms; 124 } 125 126 // XFormsSupplier2 127 sal_Bool SAL_CALL SvxFmDrawPage::hasForms(void) throw( ::com::sun::star::uno::RuntimeException ) 128 { 129 sal_Bool bHas = sal_False; 130 FmFormPage* pFormPage = PTR_CAST( FmFormPage, GetSdrPage() ); 131 if ( pFormPage ) 132 bHas = pFormPage->GetForms( false ).is(); 133 return bHas; 134 } 135 136 // ::com::sun::star::lang::XServiceInfo 137 ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL SvxFmDrawPage::getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ) 138 { 139 return SvxDrawPage::getSupportedServiceNames(); 140 } 141 142 143