Version 7.1.7.1, tag libreoffice-7.1.7.1
[LibreOffice.git] / svx / source / sdr / primitive2d / primitivefactory2d.cxx
blob975e7fdaaa0b3426da5acd0fd7707a5637fc4838
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 <com/sun/star/graphic/XPrimitiveFactory2D.hpp>
21 #include <com/sun/star/lang/XServiceInfo.hpp>
22 #include <com/sun/star/uno/XComponentContext.hpp>
23 #include <cppuhelper/basemutex.hxx>
24 #include <cppuhelper/compbase.hxx>
25 #include <cppuhelper/supportsservice.hxx>
26 #include <svx/svdobj.hxx>
27 #include <svx/svdpage.hxx>
28 #include <svx/unoapi.hxx>
29 #include <svx/sdr/contact/viewcontact.hxx>
30 #include <comphelper/sequence.hxx>
32 using namespace com::sun::star;
34 namespace {
36 typedef cppu::WeakComponentImplHelper< css::graphic::XPrimitiveFactory2D, css::lang::XServiceInfo > PrimitiveFactory2DImplBase;
38 // base class for C++ implementation of css::graphic::XPrimitiveFactory2D
39 class PrimitiveFactory2D
40 : protected cppu::BaseMutex,
41 public PrimitiveFactory2DImplBase
43 public:
44 PrimitiveFactory2D(): PrimitiveFactory2DImplBase(m_aMutex) {}
46 // Methods from XPrimitiveFactory2D
47 virtual css::uno::Sequence< css::uno::Reference< css::graphic::XPrimitive2D > > SAL_CALL createPrimitivesFromXShape( const css::uno::Reference< css::drawing::XShape >& xShape, const css::uno::Sequence< css::beans::PropertyValue >& aParms ) override;
48 virtual css::uno::Sequence< css::uno::Reference< css::graphic::XPrimitive2D > > SAL_CALL createPrimitivesFromXDrawPage( const css::uno::Reference< css::drawing::XDrawPage >& xDrawPage, const css::uno::Sequence< css::beans::PropertyValue >& aParms ) override;
50 OUString SAL_CALL getImplementationName() override
51 { return "com.sun.star.comp.graphic.PrimitiveFactory2D"; }
53 sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override
54 { return cppu::supportsService(this, ServiceName); }
56 css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override
58 return css::uno::Sequence<OUString>{
59 "com.sun.star.graphic.PrimitiveFactory2D"};
63 css::uno::Sequence< css::uno::Reference< css::graphic::XPrimitive2D > > SAL_CALL PrimitiveFactory2D::createPrimitivesFromXShape(
64 const uno::Reference< drawing::XShape >& xShape,
65 const uno::Sequence< beans::PropertyValue >& /*aParms*/ )
67 css::uno::Sequence< css::uno::Reference< css::graphic::XPrimitive2D > > aRetval;
69 if(xShape.is())
71 SdrObject* pSource = GetSdrObjectFromXShape(xShape);
73 if(pSource)
75 const sdr::contact::ViewContact& rSource(pSource->GetViewContact());
76 aRetval = comphelper::containerToSequence(rSource.getViewIndependentPrimitive2DContainer());
80 return aRetval;
83 css::uno::Sequence< css::uno::Reference< css::graphic::XPrimitive2D > > SAL_CALL PrimitiveFactory2D::createPrimitivesFromXDrawPage(
84 const uno::Reference< drawing::XDrawPage >& xDrawPage,
85 const uno::Sequence< beans::PropertyValue >& /*aParms*/ )
87 css::uno::Sequence< css::uno::Reference< css::graphic::XPrimitive2D > > aRetval;
89 if(xDrawPage.is())
91 SdrPage* pSource = GetSdrPageFromXDrawPage(xDrawPage);
93 if(pSource)
95 const sdr::contact::ViewContact& rSource(pSource->GetViewContact());
97 aRetval = comphelper::containerToSequence(rSource.getViewIndependentPrimitive2DContainer());
101 return aRetval;
106 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
107 com_sun_star_comp_graphic_PrimitiveFactory2D_get_implementation(
108 css::uno::XComponentContext *,
109 css::uno::Sequence<css::uno::Any> const &)
111 return cppu::acquire(new PrimitiveFactory2D);
114 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */