merge the formfield patch from ooo-build
[ooovba.git] / svx / source / sdr / primitive2d / primitivefactory2d.cxx
blob379195a8c9149731c1e2db9da6289026bfe42998
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: primitivefactory2d.cxx,v $
11 * $Revision: 1.2 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 #include "precompiled_svx.hxx"
33 #include <svx/sdr/primitive2d/primitiveFactory2d.hxx>
34 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
35 #include <svx/svdobj.hxx>
36 #include <svx/svdpage.hxx>
37 #include <unoapi.hxx>
38 #include <svx/sdr/contact/viewcontact.hxx>
40 //////////////////////////////////////////////////////////////////////////////
42 using namespace com::sun::star;
44 //////////////////////////////////////////////////////////////////////////////
45 // UNO API helper methods
47 namespace drawinglayer
49 namespace primitive2d
51 uno::Reference< uno::XInterface > SAL_CALL XPrimitiveFactory2DProvider_createInstance(
52 const uno::Reference< lang::XMultiServiceFactory >& /*rSMgr*/) throw( uno::Exception )
54 return *(new PrimitiveFactory2D());
56 } // end of namespace primitive2d
57 } // end of namespace drawinglayer
59 //////////////////////////////////////////////////////////////////////////////
60 // UNO API helper methods
62 namespace drawinglayer
64 namespace primitive2d
66 PrimitiveFactory2D::PrimitiveFactory2D()
67 : PrimitiveFactory2DImplBase(m_aMutex)
71 Primitive2DSequence SAL_CALL PrimitiveFactory2D::createPrimitivesFromXShape(
72 const uno::Reference< drawing::XShape >& xShape,
73 const uno::Sequence< beans::PropertyValue >& /*aParms*/ ) throw (uno::RuntimeException)
75 Primitive2DSequence aRetval;
77 if(xShape.is())
79 SdrObject* pSource = GetSdrObjectFromXShape(xShape);
81 if(pSource)
83 const sdr::contact::ViewContact& rSource(pSource->GetViewContact());
84 aRetval = rSource.getViewIndependentPrimitive2DSequence();
88 return aRetval;
91 Primitive2DSequence SAL_CALL PrimitiveFactory2D::createPrimitivesFromXDrawPage(
92 const uno::Reference< drawing::XDrawPage >& xDrawPage,
93 const uno::Sequence< beans::PropertyValue >& /*aParms*/ ) throw (uno::RuntimeException)
95 Primitive2DSequence aRetval;
97 if(xDrawPage.is())
99 SdrPage* pSource = GetSdrPageFromXDrawPage(xDrawPage);
101 if(pSource)
103 const sdr::contact::ViewContact& rSource(pSource->GetViewContact());
105 aRetval = rSource.getViewIndependentPrimitive2DSequence();
109 return aRetval;
112 rtl::OUString PrimitiveFactory2D::getImplementationName_Static()
114 static rtl::OUString aRetval(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.graphic.PrimitiveFactory2D"));
115 return aRetval;
118 uno::Sequence< rtl::OUString > PrimitiveFactory2D::getSupportedServiceNames_Static()
120 static uno::Sequence< rtl::OUString > aSeq;
121 osl::Mutex aMutex;
122 osl::MutexGuard aGuard( aMutex );
124 if(!aSeq.getLength())
126 aSeq.realloc(1L);
127 aSeq.getArray()[0L] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.graphic.PrimitiveFactory2D"));
130 return aSeq;
132 } // end of namespace primitive2d
133 } // end of namespace drawinglayer
135 //////////////////////////////////////////////////////////////////////////////
136 // eof