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/fmglob.hxx>
23 #include <svx/fmdpage.hxx>
24 #include <svx/unoshape.hxx>
25 #include <vcl/svapp.hxx>
28 
29 using ::com::sun::star::uno::Any;
30 using ::com::sun::star::uno::RuntimeException;
31 using ::com::sun::star::form::XFormsSupplier2;
32 
34  SvxDrawPage( pInPage )
35 {
36 }
37 
39 {
40 }
41 
42 css::uno::Sequence< sal_Int8 > SAL_CALL SvxFmDrawPage::getImplementationId()
43 {
44  return css::uno::Sequence<sal_Int8>();
45 }
46 
47 Any SAL_CALL SvxFmDrawPage::queryAggregation( const css::uno::Type& _rType )
48 {
49  Any aRet = ::cppu::queryInterface ( _rType
50  , static_cast< XFormsSupplier2* >( this )
51  , static_cast< XFormsSupplier* >( this )
52  );
53  if ( !aRet.hasValue() )
54  aRet = SvxDrawPage::queryAggregation( _rType );
55 
56  return aRet;
57 }
58 
59 css::uno::Sequence< css::uno::Type > SAL_CALL SvxFmDrawPage::getTypes( )
60 {
62  css::uno::Sequence { cppu::UnoType<css::form::XFormsSupplier>::get() });
63 }
64 
65 SdrObject *SvxFmDrawPage::CreateSdrObject_( const css::uno::Reference< css::drawing::XShape > & xDescr )
66 {
67  OUString aShapeType( xDescr->getShapeType() );
68 
69  if ( aShapeType == "com.sun.star.drawing.ShapeControl" // compatibility
70  || aShapeType == "com.sun.star.drawing.ControlShape"
71  )
72  {
73  return new FmFormObj(GetSdrPage()->getSdrModelFromSdrPage());
74  }
75  else
76  {
77  return SvxDrawPage::CreateSdrObject_( xDescr );
78  }
79 }
80 
81 css::uno::Reference< css::drawing::XShape > SvxFmDrawPage::CreateShape( SdrObject *pObj ) const
82 {
83  if( SdrInventor::FmForm == pObj->GetObjInventor() )
84  {
85  css::uno::Reference< css::drawing::XShape > xShape = static_cast<SvxShape*>(new SvxShapeControl( pObj ));
86  return xShape;
87  }
88  else
89  return SvxDrawPage::CreateShape( pObj );
90 }
91 
92 // XFormsSupplier
93 css::uno::Reference< css::container::XNameContainer > SAL_CALL SvxFmDrawPage::getForms()
94 {
96 
97  css::uno::Reference< css::container::XNameContainer > xForms;
98 
99  FmFormPage *pFmPage = dynamic_cast<FmFormPage*>( GetSdrPage() );
100  if( pFmPage )
101  xForms.set( pFmPage->GetForms(), css::uno::UNO_QUERY_THROW );
102 
103  return xForms;
104 }
105 
106 // XFormsSupplier2
108 {
109  SolarMutexGuard g;
110 
111  bool bHas = false;
112  FmFormPage* pFormPage = dynamic_cast<FmFormPage*>( GetSdrPage() );
113  if ( pFormPage )
114  bHas = pFormPage->GetForms( false ).is();
115  return bHas;
116 }
117 
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual css::uno::Reference< css::container::XNameContainer > SAL_CALL getForms() override
Definition: fmdpage.cxx:93
virtual css::uno::Any SAL_CALL queryAggregation(const css::uno::Type &aType) override
Definition: fmdpage.cxx:47
SvxFmDrawPage(SdrPage *pPage)
Definition: fmdpage.cxx:33
virtual SdrObject * CreateSdrObject_(const css::uno::Reference< css::drawing::XShape > &xShape)
Definition: unopage.cxx:501
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: fmdpage.cxx:59
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
Definition: fmdpage.cxx:42
virtual css::uno::Reference< css::drawing::XShape > CreateShape(SdrObject *pObj) const override
Definition: fmdpage.cxx:81
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:107
virtual css::uno::Reference< css::drawing::XShape > CreateShape(SdrObject *pObj) const
Definition: unopage.cxx:836
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:580
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:366
const css::uno::Reference< css::form::XForms > & GetForms(bool _bForceCreate=true) const
Definition: fmpage.cxx:90
virtual SdrObject * CreateSdrObject_(const css::uno::Reference< css::drawing::XShape > &xShape) override
Definition: fmdpage.cxx:65
virtual ~SvxFmDrawPage() override
Definition: fmdpage.cxx:38