tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / reportdesign / source / core / sdr / ReportDrawPage.cxx
blobae3a277b823fc65e05534399d00c3851f37b673f
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 .
19 #include <ReportDrawPage.hxx>
20 #include <RptObject.hxx>
21 #include <RptModel.hxx>
22 #include <strings.hxx>
23 #include <comphelper/mimeconfighelper.hxx>
24 #include <comphelper/embeddedobjectcontainer.hxx>
26 #include <svx/svdmodel.hxx>
27 #include <com/sun/star/embed/Aspects.hpp>
28 #include <com/sun/star/embed/XEmbeddedObject.hpp>
29 #include <comphelper/diagnose_ex.hxx>
30 #include <svx/unoshape.hxx>
31 #include <svx/svdpage.hxx>
33 namespace reportdesign
35 using namespace ::com::sun::star;
36 using namespace rptui;
38 OReportDrawPage::OReportDrawPage(SdrPage* _pPage
39 ,const uno::Reference< report::XSection >& _xSection)
40 : SvxDrawPage(_pPage)
41 ,m_xSection(_xSection)
45 rtl::Reference<SdrObject> OReportDrawPage::CreateSdrObject_(const uno::Reference< drawing::XShape > & xDescr)
47 uno::Reference< report::XReportComponent> xReportComponent(xDescr,uno::UNO_QUERY);
48 if ( xReportComponent.is() )
50 return OObjectBase::createObject(
51 GetSdrPage()->getSdrModelFromSdrPage(),
52 xReportComponent);
55 return SvxDrawPage::CreateSdrObject_( xDescr );
58 uno::Reference< drawing::XShape > OReportDrawPage::CreateShape( SdrObject *pObj ) const
60 OObjectBase* pBaseObj = dynamic_cast<OObjectBase*>(pObj);
61 if ( !pBaseObj )
62 return SvxDrawPage::CreateShape( pObj );
64 uno::Reference< report::XSection> xSection = m_xSection;
65 uno::Reference< lang::XMultiServiceFactory> xFactory;
66 if ( xSection.is() )
67 xFactory.set(xSection->getReportDefinition(),uno::UNO_QUERY);
68 uno::Reference< drawing::XShape > xRet;
69 uno::Reference< drawing::XShape > xShape;
70 if ( xFactory.is() )
72 bool bChangeOrientation = false;
73 const OUString& sServiceName = pBaseObj->getServiceName();
74 OSL_ENSURE(!sServiceName.isEmpty(),"No Service Name given!");
76 if (dynamic_cast< const OUnoObject* >(pObj) != nullptr)
78 OUnoObject& rUnoObj = dynamic_cast<OUnoObject&>(*pObj);
79 if (rUnoObj.GetObjIdentifier() == SdrObjKind::ReportDesignFixedText)
81 uno::Reference<beans::XPropertySet> xControlModel(rUnoObj.GetUnoControlModel(),uno::UNO_QUERY);
82 if ( xControlModel.is() )
83 xControlModel->setPropertyValue( PROPERTY_MULTILINE,uno::Any(true));
85 else
86 bChangeOrientation = rUnoObj.GetObjIdentifier() == SdrObjKind::ReportDesignHorizontalFixedLine;
87 rtl::Reference<SvxShapeControl> pShape = new SvxShapeControl( pObj );
88 xShape = static_cast<SvxShape_UnoImplHelper *>(pShape.get());
89 pShape->setShapeKind(pObj->GetObjIdentifier());
91 else if (dynamic_cast< const OCustomShape* >(pObj) != nullptr)
93 rtl::Reference<SvxCustomShape> pShape = new SvxCustomShape( pObj );
94 xShape = pShape;
95 pShape->setShapeKind(pObj->GetObjIdentifier());
97 else if (dynamic_cast< const SdrOle2Obj* >(pObj) != nullptr)
99 SdrOle2Obj& rOle2Obj = dynamic_cast<SdrOle2Obj&>(*pObj);
100 if (!rOle2Obj.GetObjRef().is())
102 sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
103 uno::Reference < embed::XEmbeddedObject > xObj;
104 OUString sName;
105 xObj = pObj->getSdrModelFromSdrObject().GetPersist()->getEmbeddedObjectContainer().CreateEmbeddedObject(
106 ::comphelper::MimeConfigurationHelper::GetSequenceClassIDRepresentation(
107 u"80243D39-6741-46C5-926E-069164FF87BB"), sName );
108 OSL_ENSURE(xObj.is(),"Embedded Object could not be created!");
110 /**************************************************
111 * The empty OLE object gets a new IPObj
112 **************************************************/
113 pObj->SetEmptyPresObj(false);
114 rOle2Obj.SetOutlinerParaObject(std::nullopt);
115 rOle2Obj.SetObjRef(xObj);
116 rOle2Obj.SetPersistName(sName);
117 rOle2Obj.SetName(sName);
118 rOle2Obj.SetAspect(nAspect);
119 tools::Rectangle aRect = rOle2Obj.GetLogicRect();
121 Size aTmp = aRect.GetSize();
122 awt::Size aSz( aTmp.Width(), aTmp.Height() );
123 xObj->setVisualAreaSize( nAspect, aSz );
125 rtl::Reference<SvxOle2Shape> pShape = new SvxOle2Shape( pObj, u""_ustr /*TODO?*/ );
126 xShape = pShape;
127 pShape->setShapeKind(pObj->GetObjIdentifier());
130 if ( !xShape.is() )
131 xShape.set( SvxDrawPage::CreateShape( pObj ) );
135 OReportModel& rRptModel(static_cast< OReportModel& >(pObj->getSdrModelFromSdrObject()));
136 xRet.set( rRptModel.createShape(sServiceName,xShape,bChangeOrientation ? 0 : 1), uno::UNO_QUERY_THROW );
138 catch( const uno::Exception& )
140 DBG_UNHANDLED_EXCEPTION("reportdesign");
144 return xRet;
149 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */