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 0 : class PrimitiveFactory2D
37 : : protected comphelper::OBaseMutex,
38 : public PrimitiveFactory2DImplBase
39 : {
40 : public:
41 0 : 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 0 : 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 0 : Primitive2DSequence aRetval;
54 :
55 0 : if(xShape.is())
56 : {
57 0 : SdrObject* pSource = GetSdrObjectFromXShape(xShape);
58 :
59 0 : if(pSource)
60 : {
61 0 : const sdr::contact::ViewContact& rSource(pSource->GetViewContact());
62 0 : aRetval = rSource.getViewIndependentPrimitive2DSequence();
63 : }
64 : }
65 :
66 0 : 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 0 : com_sun_star_comp_graphic_PrimitiveFactory2D_get_implementation(
94 : css::uno::XComponentContext *,
95 : css::uno::Sequence<css::uno::Any> const &)
96 : {
97 0 : return cppu::acquire(new PrimitiveFactory2D);
98 : }
99 :
100 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|