LibreOffice Module svx (master)  1
fmdpage.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include <svx/fmpage.hxx>
21 #include <fmobj.hxx>
22 #include <svx/fmdpage.hxx>
23 #include <svx/unoshape.hxx>
24 #include <vcl/svapp.hxx>
26 
27 using ::com::sun::star::uno::Any;
28 using ::com::sun::star::form::XFormsSupplier2;
29 
31  SvxDrawPage( pInPage )
32 {
33 }
34 
36 {
37 }
38 
39 css::uno::Sequence< sal_Int8 > SAL_CALL SvxFmDrawPage::getImplementationId()
40 {
41  return css::uno::Sequence<sal_Int8>();
42 }
43 
44 Any SAL_CALL SvxFmDrawPage::queryAggregation( const css::uno::Type& _rType )
45 {
46  Any aRet = ::cppu::queryInterface ( _rType
47  , static_cast< XFormsSupplier2* >( this )
48  , static_cast< XFormsSupplier* >( this )
49  );
50  if ( !aRet.hasValue() )
51  aRet = SvxDrawPage::queryAggregation( _rType );
52 
53  return aRet;
54 }
55 
56 css::uno::Sequence< css::uno::Type > SAL_CALL SvxFmDrawPage::getTypes( )
57 {
59  css::uno::Sequence { cppu::UnoType<css::form::XFormsSupplier>::get() });
60 }
61 
62 SdrObject *SvxFmDrawPage::CreateSdrObject_( const css::uno::Reference< css::drawing::XShape > & xDescr )
63 {
64  OUString aShapeType( xDescr->getShapeType() );
65 
66  if ( aShapeType == "com.sun.star.drawing.ShapeControl" // compatibility
67  || aShapeType == "com.sun.star.drawing.ControlShape"
68  )
69  {
70  return new FmFormObj(GetSdrPage()->getSdrModelFromSdrPage());
71  }
72  else
73  {
74  return SvxDrawPage::CreateSdrObject_( xDescr );
75  }
76 }
77 
78 css::uno::Reference< css::drawing::XShape > SvxFmDrawPage::CreateShape( SdrObject *pObj ) const
79 {
80  if( SdrInventor::FmForm == pObj->GetObjInventor() )
81  {
82  css::uno::Reference< css::drawing::XShape > xShape = static_cast<SvxShape*>(new SvxShapeControl( pObj ));
83  return xShape;
84  }
85  else
86  return SvxDrawPage::CreateShape( pObj );
87 }
88 
89 // XFormsSupplier
90 css::uno::Reference< css::container::XNameContainer > SAL_CALL SvxFmDrawPage::getForms()
91 {
93 
94  css::uno::Reference< css::container::XNameContainer > xForms;
95 
96  FmFormPage *pFmPage = dynamic_cast<FmFormPage*>( GetSdrPage() );
97  if( pFmPage )
98  xForms.set( pFmPage->GetForms(), css::uno::UNO_QUERY_THROW );
99 
100  return xForms;
101 }
102 
103 // XFormsSupplier2
105 {
106  SolarMutexGuard g;
107 
108  bool bHas = false;
109  FmFormPage* pFormPage = dynamic_cast<FmFormPage*>( GetSdrPage() );
110  if ( pFormPage )
111  bHas = pFormPage->GetForms( false ).is();
112  return bHas;
113 }
114 
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual css::uno::Reference< css::container::XNameContainer > SAL_CALL getForms() override
Definition: fmdpage.cxx:90
virtual css::uno::Any SAL_CALL queryAggregation(const css::uno::Type &aType) override
Definition: fmdpage.cxx:44
SvxFmDrawPage(SdrPage *pPage)
Definition: fmdpage.cxx:30
virtual SdrObject * CreateSdrObject_(const css::uno::Reference< css::drawing::XShape > &xShape)
Definition: unopage.cxx:499
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: fmdpage.cxx:56
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
Definition: fmdpage.cxx:39
virtual css::uno::Reference< css::drawing::XShape > CreateShape(SdrObject *pObj) const override
Definition: fmdpage.cxx:78
SdrPage * GetSdrPage() const
Definition: unopage.hxx:80
unsigned char sal_Bool
css::uno::Type const & get()
virtual sal_Bool SAL_CALL hasForms() override
Definition: fmdpage.cxx:104
virtual css::uno::Reference< css::drawing::XShape > CreateShape(SdrObject *pObj) const
Definition: unopage.cxx:826
css::uno::Sequence< T > concatSequences(const css::uno::Sequence< T > &rS1, const Ss &...rSn)
Abstract DrawObject.
Definition: svdobj.hxx:312
virtual SdrInventor GetObjInventor() const
Definition: svdobj.cxx:553
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:365
const css::uno::Reference< css::form::XForms > & GetForms(bool _bForceCreate=true) const
Definition: fmpage.cxx:84
virtual SdrObject * CreateSdrObject_(const css::uno::Reference< css::drawing::XShape > &xShape) override
Definition: fmdpage.cxx:62
virtual ~SvxFmDrawPage() override
Definition: fmdpage.cxx:35