LCOV - code coverage report
Current view: top level - filter/source/msfilter - msocximex.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 38 47 80.9 %
Date: 2012-08-25 Functions: 5 7 71.4 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 46 102 45.1 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      30                 :            : #include <com/sun/star/drawing/XDrawPage.hpp>
      31                 :            : #include <com/sun/star/drawing/XShapes.hpp>
      32                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      33                 :            : #include <com/sun/star/container/XIndexContainer.hpp>
      34                 :            : #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
      35                 :            : #include <com/sun/star/form/XFormsSupplier.hpp>
      36                 :            : #include <com/sun/star/form/XForm.hpp>
      37                 :            : #include <filter/msfilter/msocximex.hxx>
      38                 :            : 
      39                 :            : using namespace ::com::sun::star;
      40                 :            : using namespace ::rtl;
      41                 :            : 
      42                 :            : #define C2U(cChar)  rtl::OUString(cChar)
      43                 :            : 
      44                 :            : static char sWW8_form[] = "WW-Standard";
      45                 :            : 
      46                 :        203 : SvxMSConvertOCXControls::SvxMSConvertOCXControls( const uno::Reference< frame::XModel >& rxModel) : mxModel(rxModel)
      47                 :            : {
      48                 :        203 : }
      49                 :            : 
      50                 :        203 : SvxMSConvertOCXControls::~SvxMSConvertOCXControls()
      51                 :            : {
      52         [ -  + ]:        203 : }
      53                 :            : 
      54                 :            : const uno::Reference< drawing::XDrawPage >&
      55                 :          3 :     SvxMSConvertOCXControls::GetDrawPage()
      56                 :            : {
      57 [ +  - ][ +  - ]:          3 :     if( !xDrawPage.is() && mxModel.is() )
                 [ +  - ]
      58                 :            :     {
      59                 :            :         uno::Reference< drawing::XDrawPageSupplier > xTxtDoc(mxModel,
      60         [ +  - ]:          3 :             uno::UNO_QUERY);
      61                 :            :         OSL_ENSURE(xTxtDoc.is(),"no XDrawPageSupplier from XModel");
      62 [ +  - ][ +  - ]:          3 :         xDrawPage = xTxtDoc->getDrawPage();
                 [ +  - ]
      63                 :          3 :         OSL_ENSURE( xDrawPage.is(), "no XDrawPage" );
      64                 :            :     }
      65                 :            : 
      66                 :          3 :     return xDrawPage;
      67                 :            : }
      68                 :            : 
      69                 :            : 
      70                 :            : const uno::Reference< lang::XMultiServiceFactory >&
      71                 :          6 :     SvxMSConvertOCXControls::GetServiceFactory()
      72                 :            : {
      73 [ +  + ][ +  - ]:          6 :     if( !xServiceFactory.is() && mxModel.is() )
                 [ +  + ]
      74                 :            :     {
      75                 :            :         xServiceFactory = uno::Reference< lang::XMultiServiceFactory >
      76         [ +  - ]:          3 :             (mxModel, uno::UNO_QUERY);
      77                 :            :         OSL_ENSURE( xServiceFactory.is(),
      78                 :            :                 "no XMultiServiceFactory from doc Model" );
      79                 :            :     }
      80                 :            : 
      81                 :          6 :     return xServiceFactory;
      82                 :            : }
      83                 :            : 
      84                 :          0 : const uno::Reference< drawing::XShapes >& SvxMSConvertOCXControls::GetShapes()
      85                 :            : {
      86         [ #  # ]:          0 :     if( !xShapes.is() )
      87                 :            :     {
      88                 :          0 :         GetDrawPage();
      89         [ #  # ]:          0 :         if( xDrawPage.is() )
      90                 :            :         {
      91                 :            : 
      92                 :            :             xShapes = uno::Reference< drawing::XShapes >(xDrawPage,
      93         [ #  # ]:          0 :                 uno::UNO_QUERY);
      94                 :            :             OSL_ENSURE( xShapes.is(), "UNO_QUERY failed for XShapes from XDrawPage" );
      95                 :            :         }
      96                 :            :     }
      97                 :          0 :     return xShapes;
      98                 :            : }
      99                 :            : 
     100                 :            : const uno::Reference< container::XIndexContainer >&
     101                 :          3 :     SvxMSConvertOCXControls::GetFormComps()
     102                 :            : {
     103         [ +  - ]:          3 :     if( !xFormComps.is() )
     104                 :            :     {
     105                 :          3 :         GetDrawPage();
     106         [ +  - ]:          3 :         if( xDrawPage.is() )
     107                 :            :         {
     108                 :            :             uno::Reference< form::XFormsSupplier > xFormsSupplier( xDrawPage,
     109         [ +  - ]:          3 :                 uno::UNO_QUERY );
     110                 :            :             OSL_ENSURE( xFormsSupplier.is(),
     111                 :            :                     "UNO_QUERY failed for XFormsSupplier from XDrawPage" );
     112                 :            : 
     113                 :            :             uno::Reference< container::XNameContainer >  xNameCont =
     114 [ +  - ][ +  - ]:          3 :                 xFormsSupplier->getForms();
     115                 :            : 
     116                 :            :             // Das Formular bekommt einen Namen wie "WW-Standard[n]" und
     117                 :            :             // wird in jedem Fall neu angelegt.
     118         [ +  - ]:          3 :             UniString sName( sWW8_form, RTL_TEXTENCODING_MS_1252 );
     119                 :          3 :             sal_uInt16 n = 0;
     120                 :            : 
     121 [ +  - ][ +  - ]:          3 :             while( xNameCont->hasByName( sName ) )
         [ +  - ][ -  + ]
     122                 :            :             {
     123         [ #  # ]:          0 :                 sName.AssignAscii( sWW8_form );
     124 [ #  # ][ #  # ]:          0 :                 sName += String::CreateFromInt32( ++n );
                 [ #  # ]
     125                 :            :             }
     126                 :            : 
     127                 :            :             const uno::Reference< lang::XMultiServiceFactory > &rServiceFactory
     128         [ +  - ]:          3 :                 = GetServiceFactory();
     129         [ -  + ]:          3 :             if( !rServiceFactory.is() )
     130                 :          0 :                 return xFormComps;
     131                 :            : 
     132                 :            :             uno::Reference< uno::XInterface >  xCreate =
     133         [ +  - ]:          3 :                 rServiceFactory->createInstance(C2U(
     134         [ +  - ]:          3 :                     "com.sun.star.form.component.Form"));
     135         [ +  - ]:          3 :             if( xCreate.is() )
     136                 :            :             {
     137                 :            :                 uno::Reference< beans::XPropertySet > xFormPropSet( xCreate,
     138         [ +  - ]:          3 :                     uno::UNO_QUERY );
     139                 :            : 
     140         [ +  - ]:          3 :                 uno::Any aTmp(&sName,getCppuType((OUString *)0));
     141 [ +  - ][ +  - ]:          3 :                 xFormPropSet->setPropertyValue( C2U("Name"), aTmp );
     142                 :            : 
     143         [ +  - ]:          3 :                 uno::Reference< form::XForm > xForm( xCreate, uno::UNO_QUERY );
     144                 :            :                 OSL_ENSURE(xForm.is(), "no Form?");
     145                 :            : 
     146                 :            :                 uno::Reference< container::XIndexContainer > xForms( xNameCont,
     147         [ +  - ]:          3 :                     uno::UNO_QUERY );
     148                 :            :                 OSL_ENSURE( xForms.is(), "XForms not available" );
     149                 :            : 
     150                 :            :                 aTmp.setValue( &xForm,
     151         [ +  - ]:          3 :                     ::getCppuType((uno::Reference < form::XForm >*)0));
     152 [ +  - ][ +  - ]:          3 :                 xForms->insertByIndex( xForms->getCount(), aTmp );
         [ +  - ][ +  - ]
     153                 :            : 
     154                 :            :                 xFormComps = uno::Reference< container::XIndexContainer >
     155 [ +  - ][ +  - ]:          3 :                     (xCreate, uno::UNO_QUERY);
     156 [ +  - ][ -  + ]:          3 :             }
         [ -  + ][ +  - ]
     157                 :            :         }
     158                 :            :     }
     159                 :            : 
     160                 :          3 :     return xFormComps;
     161                 :            : }
     162                 :            : 
     163                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10