LibreOffice Module filter (master) 1
msocximex.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 <com/sun/star/beans/XPropertySet.hpp>
21#include <com/sun/star/drawing/XDrawPage.hpp>
22#include <com/sun/star/drawing/XShapes.hpp>
23#include <com/sun/star/frame/XModel.hpp>
24#include <com/sun/star/lang/XMultiServiceFactory.hpp>
25#include <com/sun/star/container/XIndexContainer.hpp>
26#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
27#include <com/sun/star/form/XFormsSupplier.hpp>
28#include <com/sun/star/form/XForm.hpp>
29#include <osl/diagnose.h>
31#include <utility>
32
33using namespace ::com::sun::star;
34
35constexpr OUStringLiteral sWW8_form( u"WW-Standard" );
36
37SvxMSConvertOCXControls::SvxMSConvertOCXControls( uno::Reference< frame::XModel > xModel) : mxModel(std::move(xModel))
38{
39}
40
42{
43}
44
46{
47 if( !xDrawPage.is() && mxModel.is() )
48 {
49 uno::Reference< drawing::XDrawPageSupplier > xTxtDoc(mxModel,
50 uno::UNO_QUERY);
51 OSL_ENSURE(xTxtDoc.is(),"no XDrawPageSupplier from XModel");
52 xDrawPage = xTxtDoc->getDrawPage();
53 OSL_ENSURE( xDrawPage.is(), "no XDrawPage" );
54 }
55}
56
57
58const uno::Reference< lang::XMultiServiceFactory >&
60{
61 if( !xServiceFactory.is() && mxModel.is() )
62 {
63 xServiceFactory = uno::Reference< lang::XMultiServiceFactory >
64 (mxModel, uno::UNO_QUERY);
65 OSL_ENSURE( xServiceFactory.is(),
66 "no XMultiServiceFactory from doc Model" );
67 }
68
69 return xServiceFactory;
70}
71
72const uno::Reference< drawing::XShapes >& SvxMSConvertOCXControls::GetShapes()
73{
74 if( !xShapes.is() )
75 {
77 if( xDrawPage.is() )
78 {
80 }
81 }
82 return xShapes;
83}
84
85const uno::Reference< container::XIndexContainer >&
87{
88 if( !xFormComps.is() )
89 {
91 if( xDrawPage.is() )
92 {
93 uno::Reference< form::XFormsSupplier > xFormsSupplier( xDrawPage,
94 uno::UNO_QUERY );
95 OSL_ENSURE( xFormsSupplier.is(),
96 "UNO_QUERY failed for XFormsSupplier from XDrawPage" );
97
98 uno::Reference< container::XNameContainer > xNameCont =
99 xFormsSupplier->getForms();
100
101 // The form gets a new name like "WW-Standard[n]" and will
102 // created new in any case.
103 OUString sName( sWW8_form );
104 sal_uInt16 n = 0;
105
106 while( xNameCont->hasByName( sName ) )
107 {
108 sName = sWW8_form + OUString::number( ++n );
109 }
110
111 const uno::Reference< lang::XMultiServiceFactory > &rServiceFactory
113 if( !rServiceFactory.is() )
114 return xFormComps;
115
116 uno::Reference< uno::XInterface > xCreate =
117 rServiceFactory->createInstance(
118 "com.sun.star.form.component.Form" );
119 if( xCreate.is() )
120 {
121 uno::Reference< beans::XPropertySet > xFormPropSet( xCreate,
122 uno::UNO_QUERY );
123
125 xFormPropSet->setPropertyValue( "Name", aTmp );
126
127 uno::Reference< form::XForm > xForm( xCreate, uno::UNO_QUERY );
128 OSL_ENSURE(xForm.is(), "no Form?");
129
130 uno::Reference< container::XIndexContainer > xForms( xNameCont,
131 uno::UNO_QUERY );
132 OSL_ENSURE( xForms.is(), "XForms not available" );
133
134 aTmp <<= xForm;
135 xForms->insertByIndex( xForms->getCount(), aTmp );
136
137 xFormComps = uno::Reference< container::XIndexContainer >
138 (xCreate, uno::UNO_QUERY);
139 }
140 }
141 }
142
143 return xFormComps;
144}
145
146/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::frame::XModel2 > mxModel
const css::uno::Reference< css::container::XIndexContainer > & GetFormComps()
Definition: msocximex.cxx:86
css::uno::Reference< css::frame::XModel > mxModel
Definition: msocximex.hxx:69
virtual ~SvxMSConvertOCXControls()
Definition: msocximex.cxx:41
css::uno::Reference< css::lang::XMultiServiceFactory > xServiceFactory
Definition: msocximex.hxx:74
virtual void GetDrawPage()
Definition: msocximex.cxx:45
const css::uno::Reference< css::lang::XMultiServiceFactory > & GetServiceFactory()
Definition: msocximex.cxx:59
SvxMSConvertOCXControls(css::uno::Reference< css::frame::XModel > xModel)
Definition: msocximex.cxx:37
const css::uno::Reference< css::drawing::XShapes > & GetShapes()
Definition: msocximex.cxx:72
css::uno::Reference< css::drawing::XShapes > xShapes
Definition: msocximex.hxx:73
css::uno::Reference< css::container::XIndexContainer > xFormComps
Definition: msocximex.hxx:77
css::uno::Reference< css::drawing::XDrawPage > xDrawPage
Definition: msocximex.hxx:72
OUString sName
sal_Int64 n
constexpr OUStringLiteral sWW8_form(u"WW-Standard")
Shape IDs per cluster in DGG atom.
Reference< XModel > xModel