LCOV - code coverage report
Current view: top level - filter/source/msfilter - msocximex.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 52 0.0 %
Date: 2014-04-14 Functions: 0 9 0.0 %
Legend: Lines: hit not hit

          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/beans/XPropertySet.hpp>
      21             : #include <com/sun/star/drawing/XDrawPage.hpp>
      22             : #include <com/sun/star/drawing/XShapes.hpp>
      23             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      24             : #include <com/sun/star/container/XIndexContainer.hpp>
      25             : #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
      26             : #include <com/sun/star/form/XFormsSupplier.hpp>
      27             : #include <com/sun/star/form/XForm.hpp>
      28             : #include <filter/msfilter/msocximex.hxx>
      29             : 
      30             : using namespace ::com::sun::star;
      31             : using namespace ::rtl;
      32             : 
      33           0 : OUString sWW8_form( "WW-Standard" );
      34             : 
      35           0 : SvxMSConvertOCXControls::SvxMSConvertOCXControls( const uno::Reference< frame::XModel >& rxModel) : mxModel(rxModel)
      36             : {
      37           0 : }
      38             : 
      39           0 : SvxMSConvertOCXControls::~SvxMSConvertOCXControls()
      40             : {
      41           0 : }
      42             : 
      43             : const uno::Reference< drawing::XDrawPage >&
      44           0 :     SvxMSConvertOCXControls::GetDrawPage()
      45             : {
      46           0 :     if( !xDrawPage.is() && mxModel.is() )
      47             :     {
      48             :         uno::Reference< drawing::XDrawPageSupplier > xTxtDoc(mxModel,
      49           0 :             uno::UNO_QUERY);
      50             :         OSL_ENSURE(xTxtDoc.is(),"no XDrawPageSupplier from XModel");
      51           0 :         xDrawPage = xTxtDoc->getDrawPage();
      52           0 :         OSL_ENSURE( xDrawPage.is(), "no XDrawPage" );
      53             :     }
      54             : 
      55           0 :     return xDrawPage;
      56             : }
      57             : 
      58             : 
      59             : const uno::Reference< lang::XMultiServiceFactory >&
      60           0 :     SvxMSConvertOCXControls::GetServiceFactory()
      61             : {
      62           0 :     if( !xServiceFactory.is() && mxModel.is() )
      63             :     {
      64           0 :         xServiceFactory = uno::Reference< lang::XMultiServiceFactory >
      65           0 :             (mxModel, uno::UNO_QUERY);
      66             :         OSL_ENSURE( xServiceFactory.is(),
      67             :                 "no XMultiServiceFactory from doc Model" );
      68             :     }
      69             : 
      70           0 :     return xServiceFactory;
      71             : }
      72             : 
      73           0 : const uno::Reference< drawing::XShapes >& SvxMSConvertOCXControls::GetShapes()
      74             : {
      75           0 :     if( !xShapes.is() )
      76             :     {
      77           0 :         GetDrawPage();
      78           0 :         if( xDrawPage.is() )
      79             :         {
      80             : 
      81           0 :             xShapes = uno::Reference< drawing::XShapes >(xDrawPage,
      82           0 :                 uno::UNO_QUERY);
      83             :             OSL_ENSURE( xShapes.is(), "UNO_QUERY failed for XShapes from XDrawPage" );
      84             :         }
      85             :     }
      86           0 :     return xShapes;
      87             : }
      88             : 
      89             : const uno::Reference< container::XIndexContainer >&
      90           0 :     SvxMSConvertOCXControls::GetFormComps()
      91             : {
      92           0 :     if( !xFormComps.is() )
      93             :     {
      94           0 :         GetDrawPage();
      95           0 :         if( xDrawPage.is() )
      96             :         {
      97             :             uno::Reference< form::XFormsSupplier > xFormsSupplier( xDrawPage,
      98           0 :                 uno::UNO_QUERY );
      99             :             OSL_ENSURE( xFormsSupplier.is(),
     100             :                     "UNO_QUERY failed for XFormsSupplier from XDrawPage" );
     101             : 
     102             :             uno::Reference< container::XNameContainer >  xNameCont =
     103           0 :                 xFormsSupplier->getForms();
     104             : 
     105             :             // The form gets a new name like "WW-Standard[n]" and will
     106             :             // created new in any case.
     107           0 :             OUString sName( sWW8_form );
     108           0 :             sal_uInt16 n = 0;
     109             : 
     110           0 :             while( xNameCont->hasByName( sName ) )
     111             :             {
     112           0 :                 sName = sWW8_form;
     113           0 :                 sName += OUString::number( ++n );
     114             :             }
     115             : 
     116             :             const uno::Reference< lang::XMultiServiceFactory > &rServiceFactory
     117           0 :                 = GetServiceFactory();
     118           0 :             if( !rServiceFactory.is() )
     119           0 :                 return xFormComps;
     120             : 
     121             :             uno::Reference< uno::XInterface >  xCreate =
     122           0 :                 rServiceFactory->createInstance(
     123           0 :                     "com.sun.star.form.component.Form" );
     124           0 :             if( xCreate.is() )
     125             :             {
     126             :                 uno::Reference< beans::XPropertySet > xFormPropSet( xCreate,
     127           0 :                     uno::UNO_QUERY );
     128             : 
     129           0 :                 uno::Any aTmp(&sName,getCppuType((OUString *)0));
     130           0 :                 xFormPropSet->setPropertyValue( "Name", aTmp );
     131             : 
     132           0 :                 uno::Reference< form::XForm > xForm( xCreate, uno::UNO_QUERY );
     133             :                 OSL_ENSURE(xForm.is(), "no Form?");
     134             : 
     135             :                 uno::Reference< container::XIndexContainer > xForms( xNameCont,
     136           0 :                     uno::UNO_QUERY );
     137             :                 OSL_ENSURE( xForms.is(), "XForms not available" );
     138             : 
     139             :                 aTmp.setValue( &xForm,
     140           0 :                     ::getCppuType((uno::Reference < form::XForm >*)0));
     141           0 :                 xForms->insertByIndex( xForms->getCount(), aTmp );
     142             : 
     143           0 :                 xFormComps = uno::Reference< container::XIndexContainer >
     144           0 :                     (xCreate, uno::UNO_QUERY);
     145           0 :             }
     146             :         }
     147             :     }
     148             : 
     149           0 :     return xFormComps;
     150           0 : }
     151             : 
     152             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10