LCOV - code coverage report
Current view: top level - framework/source/classes - taskcreator.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 36 39 92.3 %
Date: 2012-08-25 Functions: 3 4 75.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 38 94 40.4 %

           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 <classes/taskcreator.hxx>
      30                 :            : #include "services/taskcreatorsrv.hxx"
      31                 :            : #include <threadhelp/readguard.hxx>
      32                 :            : #include <loadenv/targethelper.hxx>
      33                 :            : #include <services.h>
      34                 :            : 
      35                 :            : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
      36                 :            : #include <com/sun/star/beans/NamedValue.hpp>
      37                 :            : 
      38                 :            : #include <comphelper/configurationhelper.hxx>
      39                 :            : #include <vcl/svapp.hxx>
      40                 :            : 
      41                 :            : namespace framework{
      42                 :            : 
      43                 :            : /*-****************************************************************************************************//**
      44                 :            :     @short      initialize instance with neccessary informations
      45                 :            :     @descr      We need a valid uno service manager to create or instanciate new services.
      46                 :            :                 All other informations to create frames or tasks come in on right interface methods.
      47                 :            : 
      48                 :            :     @param      xSMGR
      49                 :            :                     points to the valid uno service manager
      50                 :            : *//*-*****************************************************************************************************/
      51                 :       1743 : TaskCreator::TaskCreator( const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR )
      52                 :            :     : ThreadHelpBase(       )
      53                 :       1743 :     , m_xSMGR       ( xSMGR )
      54                 :            : {
      55                 :       1743 : }
      56                 :            : 
      57                 :            : /*-****************************************************************************************************//**
      58                 :            :     @short      deinitialize instance
      59                 :            :     @descr      We should release all used resource which are not needed any longer.
      60                 :            : *//*-*****************************************************************************************************/
      61                 :       1743 : TaskCreator::~TaskCreator()
      62                 :            : {
      63                 :       1743 :     m_xSMGR.clear();
      64         [ -  + ]:       1743 : }
      65                 :            : 
      66                 :            : /*-****************************************************************************************************//**
      67                 :            :     TODO document me
      68                 :            : *//*-*****************************************************************************************************/
      69                 :       1743 : css::uno::Reference< css::frame::XFrame > TaskCreator::createTask( const ::rtl::OUString& sName    ,
      70                 :            :                                                                          sal_Bool         bVisible )
      71                 :            : {
      72                 :            :     /* SAFE { */
      73         [ +  - ]:       1743 :     ReadGuard aReadLock( m_aLock );
      74                 :       1743 :     css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = m_xSMGR;
      75         [ +  - ]:       1743 :     aReadLock.unlock();
      76                 :            :     /* } SAFE */
      77                 :            : 
      78                 :       1743 :     css::uno::Reference< css::lang::XSingleServiceFactory > xCreator;
      79         [ +  - ]:       1743 :     ::rtl::OUString sCreator = IMPLEMENTATIONNAME_FWK_TASKCREATOR;
      80                 :            : 
      81                 :            :     try
      82                 :            :     {
      83 [ -  + ][ #  # ]:       1743 :         if (
                 [ +  - ]
      84         [ +  - ]:       1743 :             ( TargetHelper::matchSpecialTarget(sName, TargetHelper::E_BLANK  ) ) ||
      85         [ #  # ]:          0 :             ( TargetHelper::matchSpecialTarget(sName, TargetHelper::E_DEFAULT) )
      86                 :            :            )
      87                 :            :         {
      88                 :            :             ::comphelper::ConfigurationHelper::readDirectKey(xSMGR,
      89                 :            :                 "org.openoffice.Office.TabBrowse",
      90                 :            :                 "TaskCreatorService",
      91                 :            :                 "ImplementationName",
      92         [ +  - ]:       1743 :                 ::comphelper::ConfigurationHelper::E_READONLY) >>= sCreator;
      93                 :            :         }
      94                 :            : 
      95                 :            :         xCreator = css::uno::Reference< css::lang::XSingleServiceFactory >(
      96 [ +  - ][ +  - ]:       1743 :                     xSMGR->createInstance(sCreator), css::uno::UNO_QUERY_THROW);
         [ +  - ][ +  - ]
                 [ #  # ]
      97                 :            :     }
      98         [ #  # ]:          0 :     catch(const css::uno::Exception&)
      99                 :            :     {}
     100                 :            : 
     101                 :            :     // no catch here ... without an task creator service we cant open ANY document window within the office.
     102                 :            :     // Thats IMHO not a good idea. Then we should accept the stacktrace showing us the real problem.
     103                 :            :     // BTW: The used fallback creator service (IMPLEMENTATIONNAME_FWK_TASKCREATOR) is implemented in the same
     104                 :            :     // library then these class here ... Why we should not be able to create it ?
     105         [ -  + ]:       1743 :     if ( ! xCreator.is())
     106                 :            :         xCreator = css::uno::Reference< css::lang::XSingleServiceFactory >(
     107 [ #  # ][ #  # ]:          0 :                     xSMGR->createInstance(IMPLEMENTATIONNAME_FWK_TASKCREATOR), css::uno::UNO_QUERY_THROW);
         [ #  # ][ #  # ]
                 [ #  # ]
     108                 :            : 
     109         [ +  - ]:       1743 :     css::uno::Sequence< css::uno::Any > lArgs(5);
     110                 :       1743 :     css::beans::NamedValue              aArg    ;
     111                 :            : 
     112                 :       1743 :     aArg.Name    = rtl::OUString(ARGUMENT_PARENTFRAME);
     113 [ +  - ][ +  - ]:       1743 :     aArg.Value <<= css::uno::Reference< css::frame::XFrame >(xSMGR->createInstance(SERVICENAME_DESKTOP), css::uno::UNO_QUERY_THROW);
         [ +  - ][ +  - ]
                 [ +  - ]
     114 [ +  - ][ +  - ]:       1743 :     lArgs[0]   <<= aArg;
     115                 :            : 
     116                 :       1743 :     aArg.Name    = rtl::OUString(ARGUMENT_CREATETOPWINDOW);
     117         [ +  - ]:       1743 :     aArg.Value <<= sal_True;
     118 [ +  - ][ +  - ]:       1743 :     lArgs[1]   <<= aArg;
     119                 :            : 
     120                 :       1743 :     aArg.Name    = rtl::OUString(ARGUMENT_MAKEVISIBLE);
     121         [ +  - ]:       1743 :     aArg.Value <<= bVisible;
     122 [ +  - ][ +  - ]:       1743 :     lArgs[2]   <<= aArg;
     123                 :            : 
     124                 :       1743 :     aArg.Name    = rtl::OUString(ARGUMENT_SUPPORTPERSISTENTWINDOWSTATE);
     125         [ +  - ]:       1743 :     aArg.Value <<= sal_True;
     126 [ +  - ][ +  - ]:       1743 :     lArgs[3]   <<= aArg;
     127                 :            : 
     128                 :       1743 :     aArg.Name    = rtl::OUString(ARGUMENT_FRAMENAME);
     129         [ +  - ]:       1743 :     aArg.Value <<= sName;
     130 [ +  - ][ +  - ]:       1743 :     lArgs[4]   <<= aArg;
     131                 :            : 
     132 [ +  - ][ +  - ]:       1743 :     css::uno::Reference< css::frame::XFrame > xTask(xCreator->createInstanceWithArguments(lArgs), css::uno::UNO_QUERY_THROW);
                 [ +  - ]
     133 [ +  - ][ +  - ]:       1743 :     return xTask;
     134                 :            : }
     135                 :            : 
     136                 :            : } // namespace framework
     137                 :            : 
     138                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10