Line data Source code
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/graphic/XPrimitiveFactory2D.hpp>
21 : #include <com/sun/star/uno/XComponentContext.hpp>
22 : #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
23 : #include <rtl/ref.hxx>
24 : #include <svx/svdobj.hxx>
25 : #include <svx/svdpage.hxx>
26 : #include <svx/unoapi.hxx>
27 : #include <svx/sdr/contact/viewcontact.hxx>
28 :
29 : using namespace com::sun::star;
30 :
31 : namespace {
32 :
33 : typedef cppu::WeakComponentImplHelper1< ::com::sun::star::graphic::XPrimitiveFactory2D > PrimitiveFactory2DImplBase;
34 :
35 : // base class for C++ implementation of com::sun::star::graphic::XPrimitiveFactory2D
36 650 : class PrimitiveFactory2D
37 : : protected comphelper::OBaseMutex,
38 : public PrimitiveFactory2DImplBase
39 : {
40 : public:
41 325 : PrimitiveFactory2D(): PrimitiveFactory2DImplBase(m_aMutex) {}
42 :
43 : // Methods from XPrimitiveFactory2D
44 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XPrimitive2D > > SAL_CALL createPrimitivesFromXShape( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aParms ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
45 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XPrimitive2D > > SAL_CALL createPrimitivesFromXDrawPage( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xDrawPage, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aParms ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
46 :
47 : };
48 :
49 323 : Primitive2DSequence SAL_CALL PrimitiveFactory2D::createPrimitivesFromXShape(
50 : const uno::Reference< drawing::XShape >& xShape,
51 : const uno::Sequence< beans::PropertyValue >& /*aParms*/ ) throw (uno::RuntimeException, std::exception)
52 : {
53 323 : Primitive2DSequence aRetval;
54 :
55 323 : if(xShape.is())
56 : {
57 323 : SdrObject* pSource = GetSdrObjectFromXShape(xShape);
58 :
59 323 : if(pSource)
60 : {
61 323 : const sdr::contact::ViewContact& rSource(pSource->GetViewContact());
62 323 : aRetval = rSource.getViewIndependentPrimitive2DSequence();
63 : }
64 : }
65 :
66 323 : return aRetval;
67 : }
68 :
69 0 : Primitive2DSequence SAL_CALL PrimitiveFactory2D::createPrimitivesFromXDrawPage(
70 : const uno::Reference< drawing::XDrawPage >& xDrawPage,
71 : const uno::Sequence< beans::PropertyValue >& /*aParms*/ ) throw (uno::RuntimeException, std::exception)
72 : {
73 0 : Primitive2DSequence aRetval;
74 :
75 0 : if(xDrawPage.is())
76 : {
77 0 : SdrPage* pSource = GetSdrPageFromXDrawPage(xDrawPage);
78 :
79 0 : if(pSource)
80 : {
81 0 : const sdr::contact::ViewContact& rSource(pSource->GetViewContact());
82 :
83 0 : aRetval = rSource.getViewIndependentPrimitive2DSequence();
84 : }
85 : }
86 :
87 0 : return aRetval;
88 : }
89 :
90 : }
91 :
92 : extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
93 325 : com_sun_star_comp_graphic_PrimitiveFactory2D_get_implementation(
94 : css::uno::XComponentContext *,
95 : css::uno::Sequence<css::uno::Any> const &)
96 : {
97 325 : return cppu::acquire(new PrimitiveFactory2D);
98 651 : }
99 :
100 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|