Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / svx / source / form / fmdpage.cxx
blobc0867cc9ed779325d90683f0be9f45f3699039f9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <svx/fmpage.hxx>
21 #include "fmobj.hxx"
22 #include <svx/fmglob.hxx>
23 #include <svx/fmdpage.hxx>
24 #include <svx/unoshape.hxx>
25 #include <cppuhelper/queryinterface.hxx>
26 #include <cppuhelper/typeprovider.hxx>
28 using ::com::sun::star::uno::Any;
29 using ::com::sun::star::uno::RuntimeException;
30 using ::com::sun::star::form::XFormsSupplier2;
32 SvxFmDrawPage::SvxFmDrawPage( SdrPage* pInPage ) :
33 SvxDrawPage( pInPage )
37 SvxFmDrawPage::~SvxFmDrawPage() throw ()
41 ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL SvxFmDrawPage::getImplementationId() throw(::com::sun::star::uno::RuntimeException, std::exception)
43 return css::uno::Sequence<sal_Int8>();
46 Any SAL_CALL SvxFmDrawPage::queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(RuntimeException, std::exception)
48 Any aRet = ::cppu::queryInterface ( _rType
49 , static_cast< XFormsSupplier2* >( this )
50 , static_cast< XFormsSupplier* >( this )
52 if ( !aRet.hasValue() )
53 aRet = SvxDrawPage::queryAggregation( _rType );
55 return aRet;
58 /***********************************************************************
59 * *
60 ***********************************************************************/
61 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL SvxFmDrawPage::getTypes( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
63 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypes(SvxDrawPage::getTypes());
64 aTypes.realloc(aTypes.getLength() + 1);
65 ::com::sun::star::uno::Type* pTypes = aTypes.getArray();
67 pTypes[aTypes.getLength()-1] = cppu::UnoType<com::sun::star::form::XFormsSupplier>::get();
68 return aTypes;
71 SdrObject *SvxFmDrawPage::_CreateSdrObject( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > & xDescr )
72 throw (std::exception)
74 OUString aShapeType( xDescr->getShapeType() );
76 if ( aShapeType == "com.sun.star.drawing.ShapeControl" // compatibility
77 || aShapeType == "com.sun.star.drawing.ControlShape"
79 return new FmFormObj();
80 else
81 return SvxDrawPage::_CreateSdrObject( xDescr );
85 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > SvxFmDrawPage::_CreateShape( SdrObject *pObj ) const
86 throw (std::exception)
88 if( FmFormInventor == pObj->GetObjInventor() )
90 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape = (SvxShape*)new SvxShapeControl( pObj );
91 return xShape;
93 else
94 return SvxDrawPage::_CreateShape( pObj );
97 // XFormsSupplier
98 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > SAL_CALL SvxFmDrawPage::getForms(void) throw( ::com::sun::star::uno::RuntimeException, std::exception )
100 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > xForms;
102 FmFormPage *pFmPage = PTR_CAST( FmFormPage, GetSdrPage() );
103 if( pFmPage )
104 xForms.set( pFmPage->GetForms(), css::uno::UNO_QUERY_THROW );
106 return xForms;
109 // XFormsSupplier2
110 sal_Bool SAL_CALL SvxFmDrawPage::hasForms(void) throw( ::com::sun::star::uno::RuntimeException, std::exception )
112 bool bHas = false;
113 FmFormPage* pFormPage = PTR_CAST( FmFormPage, GetSdrPage() );
114 if ( pFormPage )
115 bHas = pFormPage->GetForms( false ).is();
116 return bHas;
119 // ::com::sun::star::lang::XServiceInfo
120 ::com::sun::star::uno::Sequence< OUString > SAL_CALL SvxFmDrawPage::getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException, std::exception )
122 return SvxDrawPage::getSupportedServiceNames();
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */