LCOV - code coverage report
Current view: top level - reportdesign/source/ui/inspection - DefaultInspection.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 97 0.0 %
Date: 2014-04-14 Functions: 0 22 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             : #include "DefaultInspection.hxx"
      20             : #include <com/sun/star/ucb/AlreadyInitializedException.hpp>
      21             : #include <com/sun/star/lang/IllegalArgumentException.hpp>
      22             : #include <RptResId.hrc>
      23             : #include "ModuleHelper.hxx"
      24             : #include "helpids.hrc"
      25             : #include <cppuhelper/implbase1.hxx>
      26             : #include <cppuhelper/supportsservice.hxx>
      27             : #include <osl/diagnose.h>
      28             : #include <rtl/ustrbuf.hxx>
      29             : #include <tools/debug.hxx>
      30             : #include "metadata.hxx"
      31             : #include <tools/urlobj.hxx>
      32             : 
      33             : 
      34             : namespace rptui
      35             : {
      36           0 :     OUString HelpIdUrl::getHelpURL( const OString& sHelpId )
      37             :     {
      38           0 :         OUStringBuffer aBuffer;
      39           0 :         OUString aTmp( OStringToOUString(sHelpId, RTL_TEXTENCODING_UTF8) );
      40             :         DBG_ASSERT( INetURLObject( aTmp ).GetProtocol() == INET_PROT_NOT_VALID, "Wrong HelpId!" );
      41           0 :         aBuffer.appendAscii( INET_HID_SCHEME );
      42           0 :         aBuffer.append( aTmp.getStr() );
      43           0 :         return aBuffer.makeStringAndClear();
      44             :     }
      45             : 
      46             :     using namespace com::sun::star::uno;
      47             :     using namespace com::sun::star;
      48             :     using com::sun::star::inspection::PropertyCategoryDescriptor;
      49             : 
      50             : 
      51             :     //= DefaultComponentInspectorModel
      52             : 
      53             : 
      54           0 :     DefaultComponentInspectorModel::DefaultComponentInspectorModel( const Reference< XComponentContext >& _rxContext)
      55             :         :m_xContext( _rxContext )
      56             :         ,m_bConstructed( false )
      57             :         ,m_bHasHelpSection( false )
      58             :         ,m_bIsReadOnly(sal_False)
      59             :         ,m_nMinHelpTextLines( 3 )
      60             :         ,m_nMaxHelpTextLines( 8 )
      61           0 :         ,m_pInfoService(new OPropertyInfoService())
      62             :     {
      63           0 :     }
      64             : 
      65           0 :     DefaultComponentInspectorModel::~DefaultComponentInspectorModel()
      66             :     {
      67           0 :     }
      68             : 
      69           0 :     OUString SAL_CALL DefaultComponentInspectorModel::getImplementationName(  ) throw(RuntimeException, std::exception)
      70             :     {
      71           0 :         return getImplementationName_Static();
      72             :     }
      73             : 
      74           0 :     sal_Bool SAL_CALL DefaultComponentInspectorModel::supportsService( const OUString& ServiceName ) throw(RuntimeException, std::exception)
      75             :     {
      76           0 :         return cppu::supportsService(this, ServiceName);
      77             :     }
      78             : 
      79           0 :     Sequence< OUString > SAL_CALL DefaultComponentInspectorModel::getSupportedServiceNames(  ) throw(RuntimeException, std::exception)
      80             :     {
      81           0 :         return getSupportedServiceNames_static();
      82             :     }
      83             : 
      84           0 :     OUString DefaultComponentInspectorModel::getImplementationName_Static(  ) throw(RuntimeException)
      85             :     {
      86           0 :         return OUString("com.sun.star.comp.report.DefaultComponentInspectorModel");
      87             :     }
      88             : 
      89           0 :     Sequence< OUString > DefaultComponentInspectorModel::getSupportedServiceNames_static(  ) throw(RuntimeException)
      90             :     {
      91           0 :         Sequence< OUString > aSupported(1);
      92           0 :         aSupported[0] = "com.sun.star.report.inspection.DefaultComponentInspectorModel";
      93           0 :         return aSupported;
      94             :     }
      95             : 
      96           0 :     Reference< XInterface > SAL_CALL DefaultComponentInspectorModel::create( const Reference< XComponentContext >& _rxContext )
      97             :     {
      98           0 :         return *(new DefaultComponentInspectorModel( _rxContext ));
      99             :     }
     100             : 
     101             : 
     102           0 :     Sequence< Any > SAL_CALL DefaultComponentInspectorModel::getHandlerFactories() throw (RuntimeException, std::exception)
     103             :     {
     104           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     105             : 
     106             : 
     107             :         // service names for all our handlers
     108             :         const struct
     109             :         {
     110             :             const sal_Char* serviceName;
     111             :         } aFactories[] = {
     112             : 
     113             :             { "com.sun.star.report.inspection.ReportComponentHandler"},
     114             :             { "com.sun.star.form.inspection.EditPropertyHandler"},
     115             :             { "com.sun.star.report.inspection.DataProviderHandler"},
     116             :             { "com.sun.star.report.inspection.GeometryHandler"}
     117             : 
     118             :             // generic virtual edit properties
     119             : 
     120           0 :         };
     121             : 
     122           0 :         const size_t nFactories = sizeof( aFactories ) / sizeof( aFactories[ 0 ] );
     123           0 :         Sequence< Any > aReturn( nFactories );
     124           0 :         Any* pReturn = aReturn.getArray();
     125           0 :         for ( size_t i = 0; i < nFactories; ++i )
     126             :         {
     127           0 :             *pReturn++ <<= OUString::createFromAscii( aFactories[i].serviceName );
     128             :         }
     129             : 
     130           0 :         return aReturn;
     131             :     }
     132             : 
     133           0 :     sal_Bool SAL_CALL DefaultComponentInspectorModel::getHasHelpSection() throw (RuntimeException, std::exception)
     134             :     {
     135           0 :         ::osl::MutexGuard aGuard(m_aMutex);
     136           0 :         return m_bHasHelpSection;
     137             :     }
     138             : 
     139             : 
     140           0 :     ::sal_Int32 SAL_CALL DefaultComponentInspectorModel::getMinHelpTextLines() throw (RuntimeException, std::exception)
     141             :     {
     142           0 :         ::osl::MutexGuard aGuard(m_aMutex);
     143           0 :         return m_nMinHelpTextLines;
     144             :     }
     145             : 
     146           0 :     sal_Bool SAL_CALL DefaultComponentInspectorModel::getIsReadOnly() throw (::com::sun::star::uno::RuntimeException, std::exception)
     147             :     {
     148           0 :         ::osl::MutexGuard aGuard(m_aMutex);
     149           0 :         return m_bIsReadOnly;
     150             :     }
     151             : 
     152           0 :     void SAL_CALL DefaultComponentInspectorModel::setIsReadOnly( sal_Bool _isreadonly ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     153             :     {
     154           0 :         ::osl::MutexGuard aGuard(m_aMutex);
     155           0 :         m_bIsReadOnly = _isreadonly;
     156           0 :     }
     157             : 
     158             : 
     159           0 :     ::sal_Int32 SAL_CALL DefaultComponentInspectorModel::getMaxHelpTextLines() throw (RuntimeException, std::exception)
     160             :     {
     161           0 :         ::osl::MutexGuard aGuard(m_aMutex);
     162           0 :         return m_nMaxHelpTextLines;
     163             :     }
     164             : 
     165           0 :     void SAL_CALL DefaultComponentInspectorModel::initialize( const Sequence< Any >& _arguments ) throw (Exception, RuntimeException, std::exception)
     166             :     {
     167           0 :         ::osl::MutexGuard aGuard(m_aMutex);
     168           0 :         if ( m_bConstructed )
     169           0 :             throw ucb::AlreadyInitializedException();
     170             : 
     171           0 :         if ( !_arguments.hasElements() )
     172             :         {   // constructor: "createDefault()"
     173           0 :             createDefault();
     174           0 :             return;
     175             :         }
     176             : 
     177           0 :         sal_Int32 nMinHelpTextLines( 0 ), nMaxHelpTextLines( 0 );
     178           0 :         if ( _arguments.getLength() == 2 )
     179             :         {   // constructor: "createWithHelpSection( long, long )"
     180           0 :             if ( !( _arguments[0] >>= nMinHelpTextLines ) || !( _arguments[1] >>= nMaxHelpTextLines ) )
     181           0 :                 throw lang::IllegalArgumentException( OUString(), *this, 0 );
     182           0 :             createWithHelpSection( nMinHelpTextLines, nMaxHelpTextLines );
     183           0 :             return;
     184             :         }
     185             : 
     186           0 :         throw lang::IllegalArgumentException( OUString(), *this, 0 );
     187             :     }
     188             : 
     189             : 
     190           0 :     void DefaultComponentInspectorModel::createDefault()
     191             :     {
     192           0 :         m_bConstructed = true;
     193           0 :     }
     194             : 
     195           0 :     void DefaultComponentInspectorModel::createWithHelpSection( sal_Int32 _nMinHelpTextLines, sal_Int32 _nMaxHelpTextLines )
     196             :     {
     197           0 :         if ( ( _nMinHelpTextLines <= 0 ) || ( _nMaxHelpTextLines <= 0 ) || ( _nMinHelpTextLines > _nMaxHelpTextLines ) )
     198           0 :             throw lang::IllegalArgumentException( OUString(), *this, 0 );
     199             : 
     200           0 :         m_bHasHelpSection = true;
     201           0 :         m_nMinHelpTextLines = _nMinHelpTextLines;
     202           0 :         m_nMaxHelpTextLines = _nMaxHelpTextLines;
     203           0 :         m_bConstructed = true;
     204           0 :     }
     205             : 
     206           0 :     Sequence< PropertyCategoryDescriptor > SAL_CALL DefaultComponentInspectorModel::describeCategories(  ) throw (RuntimeException, std::exception)
     207             :     {
     208           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     209             : 
     210             :         const struct
     211           0 :         {
     212             :             const sal_Char* programmaticName;
     213             :             sal_uInt16          uiNameResId;
     214             :             OString    helpId;
     215             :         } aCategories[] = {
     216             :             { "General",    RID_STR_PROPPAGE_DEFAULT,   HID_RPT_PROPDLG_TAB_GENERAL },
     217             :             { "Data",       RID_STR_PROPPAGE_DATA,      HID_RPT_PROPDLG_TAB_DATA },
     218           0 :         };
     219             : 
     220           0 :         const size_t nCategories = sizeof( aCategories ) / sizeof( aCategories[0] );
     221           0 :         Sequence< PropertyCategoryDescriptor > aReturn( nCategories );
     222           0 :         PropertyCategoryDescriptor* pReturn = aReturn.getArray();
     223           0 :         for ( size_t i=0; i<nCategories; ++i, ++pReturn )
     224             :         {
     225           0 :             pReturn->ProgrammaticName = OUString::createFromAscii( aCategories[i].programmaticName );
     226           0 :             pReturn->UIName = ModuleRes( aCategories[i].uiNameResId );
     227           0 :             pReturn->HelpURL = HelpIdUrl::getHelpURL( aCategories[i].helpId );
     228             :         }
     229             : 
     230           0 :         return aReturn;
     231             :     }
     232             : 
     233             : 
     234           0 :     ::sal_Int32 SAL_CALL DefaultComponentInspectorModel::getPropertyOrderIndex( const OUString& _rPropertyName ) throw (RuntimeException, std::exception)
     235             :     {
     236           0 :         ::osl::MutexGuard aGuard(m_aMutex);
     237           0 :         const sal_Int32 nPropertyId( m_pInfoService->getPropertyId( _rPropertyName ) );
     238           0 :         if ( nPropertyId != -1 )
     239           0 :             return nPropertyId;
     240             : 
     241           0 :         if ( !m_xComponent.is() )
     242             :             try
     243             :             {
     244           0 :                 m_xComponent.set(m_xContext->getServiceManager()->createInstanceWithContext("com.sun.star.form.inspection.DefaultFormComponentInspectorModel",m_xContext),UNO_QUERY_THROW);
     245             :             }
     246           0 :             catch(const Exception &)
     247             :             {
     248           0 :                 return 0;
     249             :             }
     250             : 
     251           0 :         return m_xComponent->getPropertyOrderIndex(_rPropertyName);
     252             :     }
     253             : 
     254             : 
     255             : } // namespace rptui
     256             : 
     257             : 
     258             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10