1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #include "precompiled_svx.hxx" 25 #include <svx/sdr/primitive2d/primitiveFactory2d.hxx> 26 #include <drawinglayer/primitive2d/baseprimitive2d.hxx> 27 #include <svx/svdobj.hxx> 28 #include <svx/svdpage.hxx> 29 #include <svx/unoapi.hxx> 30 #include <svx/sdr/contact/viewcontact.hxx> 31 32 ////////////////////////////////////////////////////////////////////////////// 33 34 using namespace com::sun::star; 35 36 ////////////////////////////////////////////////////////////////////////////// 37 // UNO API helper methods 38 39 namespace drawinglayer 40 { 41 namespace primitive2d 42 { XPrimitiveFactory2DProvider_createInstance(const uno::Reference<lang::XMultiServiceFactory> &)43 uno::Reference< uno::XInterface > SAL_CALL XPrimitiveFactory2DProvider_createInstance( 44 const uno::Reference< lang::XMultiServiceFactory >& /*rSMgr*/) throw( uno::Exception ) 45 { 46 return *(new PrimitiveFactory2D()); 47 } 48 } // end of namespace primitive2d 49 } // end of namespace drawinglayer 50 51 ////////////////////////////////////////////////////////////////////////////// 52 // UNO API helper methods 53 54 namespace drawinglayer 55 { 56 namespace primitive2d 57 { PrimitiveFactory2D()58 PrimitiveFactory2D::PrimitiveFactory2D() 59 : PrimitiveFactory2DImplBase(m_aMutex) 60 { 61 } 62 createPrimitivesFromXShape(const uno::Reference<drawing::XShape> & xShape,const uno::Sequence<beans::PropertyValue> &)63 Primitive2DSequence SAL_CALL PrimitiveFactory2D::createPrimitivesFromXShape( 64 const uno::Reference< drawing::XShape >& xShape, 65 const uno::Sequence< beans::PropertyValue >& /*aParms*/ ) throw (uno::RuntimeException) 66 { 67 Primitive2DSequence aRetval; 68 69 if(xShape.is()) 70 { 71 SdrObject* pSource = GetSdrObjectFromXShape(xShape); 72 73 if(pSource) 74 { 75 const sdr::contact::ViewContact& rSource(pSource->GetViewContact()); 76 aRetval = rSource.getViewIndependentPrimitive2DSequence(); 77 } 78 } 79 80 return aRetval; 81 } 82 createPrimitivesFromXDrawPage(const uno::Reference<drawing::XDrawPage> & xDrawPage,const uno::Sequence<beans::PropertyValue> &)83 Primitive2DSequence SAL_CALL PrimitiveFactory2D::createPrimitivesFromXDrawPage( 84 const uno::Reference< drawing::XDrawPage >& xDrawPage, 85 const uno::Sequence< beans::PropertyValue >& /*aParms*/ ) throw (uno::RuntimeException) 86 { 87 Primitive2DSequence aRetval; 88 89 if(xDrawPage.is()) 90 { 91 SdrPage* pSource = GetSdrPageFromXDrawPage(xDrawPage); 92 93 if(pSource) 94 { 95 const sdr::contact::ViewContact& rSource(pSource->GetViewContact()); 96 97 aRetval = rSource.getViewIndependentPrimitive2DSequence(); 98 } 99 } 100 101 return aRetval; 102 } 103 getImplementationName_Static()104 rtl::OUString PrimitiveFactory2D::getImplementationName_Static() 105 { 106 static rtl::OUString aRetval(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.graphic.PrimitiveFactory2D")); 107 return aRetval; 108 } 109 getSupportedServiceNames_Static()110 uno::Sequence< rtl::OUString > PrimitiveFactory2D::getSupportedServiceNames_Static() 111 { 112 static uno::Sequence< rtl::OUString > aSeq; 113 osl::Mutex aMutex; 114 osl::MutexGuard aGuard( aMutex ); 115 116 if(!aSeq.getLength()) 117 { 118 aSeq.realloc(1L); 119 aSeq.getArray()[0L] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.graphic.PrimitiveFactory2D")); 120 } 121 122 return aSeq; 123 } 124 } // end of namespace primitive2d 125 } // end of namespace drawinglayer 126 127 ////////////////////////////////////////////////////////////////////////////// 128 // eof 129