LCOV - code coverage report
Current view: top level - sw/source/filter/html - SwAppletImpl.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 102 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 7 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 <SwAppletImpl.hxx>
      21             : #include <svtools/htmlkywd.hxx>
      22             : #include <svl/urihelper.hxx>
      23             : #include <com/sun/star/beans/XPropertySet.hpp>
      24             : #include <com/sun/star/embed/EmbedStates.hpp>
      25             : 
      26             : #include <comphelper/embeddedobjectcontainer.hxx>
      27             : #include <comphelper/classids.hxx>
      28             : #include <com/sun/star/uno/Any.hxx>
      29             : #include <svtools/embedhlp.hxx>
      30             : 
      31             : using namespace com::sun::star;
      32             : 
      33             : namespace {
      34             : 
      35             : static char const sHTML_O_archive[] = "ARCHIVE";
      36             : static char const sHTML_O_Archives[] = "ARCHIVES";
      37             : static char const sHTML_O_Object[] = "OBJECT";
      38             : 
      39             : }
      40             : 
      41           0 : SwHtmlOptType SwApplet_Impl::GetOptionType( const OUString& rName, bool bApplet )
      42             : {
      43           0 :     SwHtmlOptType nType = bApplet ? SwHtmlOptType::PARAM : SwHtmlOptType::TAG;
      44             : 
      45           0 :     switch( rName.toChar() )
      46             :     {
      47             :     case 'A':
      48             :     case 'a':
      49           0 :         if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_align ) ||
      50           0 :             rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_alt ) )
      51           0 :             nType = SwHtmlOptType::IGNORE;
      52           0 :         else if( bApplet &&
      53           0 :                  (rName == sHTML_O_archive || rName == sHTML_O_Archives ) )
      54           0 :             nType = SwHtmlOptType::TAG;
      55           0 :         break;
      56             :     case 'C':
      57             :     case 'c':
      58           0 :         if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_class ) ||
      59           0 :             (bApplet && (rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_code ) ||
      60           0 :                          rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_codebase ))) )
      61           0 :             nType = SwHtmlOptType::IGNORE;
      62           0 :         break;
      63             :     case 'H':
      64             :     case 'h':
      65           0 :         if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_height ) )
      66           0 :             nType = SwHtmlOptType::SIZE;
      67           0 :         else if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_hspace ) ||
      68           0 :             (!bApplet && rName.equalsIgnoreAsciiCase( OOO_STRING_SW_HTML_O_Hidden )) )
      69           0 :             nType = SwHtmlOptType::IGNORE;
      70           0 :         break;
      71             :     case 'I':
      72             :     case 'i':
      73           0 :         if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_id ) )
      74           0 :             nType = SwHtmlOptType::IGNORE;
      75           0 :         break;
      76             :     case 'M':
      77             :     case 'm':
      78           0 :         if( bApplet && rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_mayscript ) )
      79           0 :             nType = SwHtmlOptType::IGNORE;
      80           0 :         break;
      81             :     case 'N':
      82             :     case 'n':
      83           0 :         if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_name ) )
      84           0 :             nType = SwHtmlOptType::IGNORE;
      85           0 :         break;
      86             :     case 'O':
      87             :     case 'o':
      88           0 :         if( bApplet && rName == sHTML_O_Object )
      89           0 :             nType = SwHtmlOptType::TAG;
      90           0 :         break;
      91             :     case 'S':
      92             :     case 's':
      93           0 :         if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_style ) ||
      94           0 :             (!bApplet && rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_src )) )
      95           0 :             nType = SwHtmlOptType::IGNORE;
      96           0 :         break;
      97             :     case 'T':
      98             :     case 't':
      99           0 :         if( !bApplet && rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_type ) )
     100           0 :             nType = SwHtmlOptType::IGNORE;
     101           0 :         break;
     102             :     case 'V':
     103             :     case 'v':
     104           0 :         if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_vspace ) )
     105           0 :             nType = SwHtmlOptType::IGNORE;
     106           0 :         break;
     107             :     case 'W':
     108             :     case 'w':
     109           0 :         if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_width ) )
     110           0 :             nType = SwHtmlOptType::SIZE;
     111           0 :         break;
     112             :     }
     113             : 
     114           0 :     return nType;
     115             : }
     116           0 : SwApplet_Impl::SwApplet_Impl( SfxItemPool& rPool, sal_uInt16 nWhich1, sal_uInt16 nWhich2 ) :
     117           0 :         aItemSet( rPool, nWhich1, nWhich2 )
     118             : {
     119           0 : }
     120             : 
     121           0 : void SwApplet_Impl::CreateApplet( const OUString& rCode, const OUString& rName,
     122             :                                   bool bMayScript, const OUString& rCodeBase,
     123             :                                   const OUString& rDocumentBaseURL )
     124             : {
     125           0 :     comphelper::EmbeddedObjectContainer aCnt;
     126           0 :     OUString aName;
     127             : 
     128             :     // create Applet; it will be in running state
     129           0 :     xApplet = aCnt.CreateEmbeddedObject( SvGlobalName( SO3_APPLET_CLASSID ).GetByteSequence(), aName );
     130           0 :     ::svt::EmbeddedObjectRef::TryRunningState( xApplet );
     131             : 
     132           0 :     INetURLObject aUrlBase(rDocumentBaseURL);
     133           0 :     aUrlBase.removeSegment();
     134             : 
     135           0 :     OUString sDocBase = aUrlBase.GetMainURL(INetURLObject::NO_DECODE);
     136           0 :     uno::Reference < beans::XPropertySet > xSet( xApplet->getComponent(), uno::UNO_QUERY );
     137           0 :     if ( xSet.is() )
     138             :     {
     139           0 :         xSet->setPropertyValue("AppletCode", uno::makeAny( rCode ) );
     140           0 :         xSet->setPropertyValue("AppletName", uno::makeAny( rName ) );
     141           0 :         xSet->setPropertyValue("AppletIsScript", uno::makeAny( bMayScript ) );
     142           0 :         xSet->setPropertyValue("AppletDocBase", uno::makeAny( sDocBase ) );
     143           0 :         if ( !rCodeBase.isEmpty() )
     144           0 :             xSet->setPropertyValue("AppletCodeBase", uno::makeAny( rCodeBase ) );
     145             :         else
     146           0 :             xSet->setPropertyValue("AppletCodeBase", uno::makeAny( sDocBase ) );
     147           0 :     }
     148           0 : }
     149             : #if HAVE_FEATURE_JAVA
     150           0 : bool SwApplet_Impl::CreateApplet( const OUString& rBaseURL )
     151             : {
     152           0 :     OUString aCode, aName, aCodeBase;
     153           0 :     bool bMayScript = false;
     154             : 
     155           0 :     size_t nArgCount = aCommandList.size();
     156           0 :     for( size_t i = 0; i < nArgCount; i++ )
     157             :     {
     158           0 :         const SvCommand& rArg = aCommandList[i];
     159           0 :         const OUString& rName = rArg.GetCommand();
     160           0 :         if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_code ) )
     161           0 :             aCode = rArg.GetArgument();
     162           0 :         else if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_codebase ) )
     163           0 :             aCodeBase = INetURLObject::GetAbsURL( rBaseURL, rArg.GetArgument() );
     164           0 :         else if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_name ) )
     165           0 :             aName = rArg.GetArgument();
     166           0 :         else if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_mayscript ) )
     167           0 :             bMayScript = true;
     168           0 :     }
     169             : 
     170           0 :     if( aCode.isEmpty() )
     171           0 :         return false;
     172           0 :     CreateApplet( aCode, aName, bMayScript, aCodeBase, rBaseURL );
     173           0 :     return true;
     174             : }
     175             : #endif
     176             : 
     177           0 : SwApplet_Impl::~SwApplet_Impl()
     178             : {
     179           0 : }
     180           0 : void SwApplet_Impl::FinishApplet()
     181             : {
     182           0 :     uno::Reference < beans::XPropertySet > xSet( xApplet->getComponent(), uno::UNO_QUERY );
     183           0 :     if ( xSet.is() )
     184             :     {
     185           0 :         uno::Sequence < beans::PropertyValue > aProps;
     186           0 :         aCommandList.FillSequence( aProps );
     187           0 :         xSet->setPropertyValue("AppletCommands", uno::makeAny( aProps ) );
     188           0 :     }
     189           0 : }
     190             : 
     191             : #if HAVE_FEATURE_JAVA
     192           0 : void SwApplet_Impl::AppendParam( const OUString& rName, const OUString& rValue )
     193             : {
     194           0 :     aCommandList.Append( rName, rValue );
     195           0 : }
     196             : #endif
     197             : 
     198             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11