LCOV - code coverage report
Current view: top level - sw/source/filter/html - htmlplug.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 126 679 18.6 %
Date: 2015-06-13 12:38:46 Functions: 7 14 50.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 <config_features.h>
      21             : 
      22             : #include "hintids.hxx"
      23             : #include <rtl/strbuf.hxx>
      24             : #include <svl/urihelper.hxx>
      25             : #include <vcl/svapp.hxx>
      26             : #include <sfx2/frmhtml.hxx>
      27             : #include <sfx2/frmhtmlw.hxx>
      28             : #include <vcl/wrkwin.hxx>
      29             : #include <sot/storage.hxx>
      30             : #include <svx/xoutbmp.hxx>
      31             : #include <editeng/ulspitem.hxx>
      32             : #include <editeng/lrspitem.hxx>
      33             : #include <svtools/htmlkywd.hxx>
      34             : #include <svtools/htmltokn.h>
      35             : #include <SwAppletImpl.hxx>
      36             : #include <fmtornt.hxx>
      37             : #include <fmtfsize.hxx>
      38             : #include <fmtsrnd.hxx>
      39             : #include <fmtanchr.hxx>
      40             : #include <fmtcntnt.hxx>
      41             : #include <frmfmt.hxx>
      42             : 
      43             : #include <svl/ownlist.hxx>
      44             : #include <unotools/mediadescriptor.hxx>
      45             : #include <unotools/streamwrap.hxx>
      46             : #include "pam.hxx"
      47             : #include "doc.hxx"
      48             : #include "ndtxt.hxx"
      49             : #include "swerror.h"
      50             : #include "ndole.hxx"
      51             : #include "swtable.hxx"
      52             : #include "swhtml.hxx"
      53             : #include "wrthtml.hxx"
      54             : #include "htmlfly.hxx"
      55             : #include "swcss1.hxx"
      56             : #include "unoframe.hxx"
      57             : #include <com/sun/star/embed/XClassifiedObject.hpp>
      58             : #include <com/sun/star/embed/EmbedStates.hpp>
      59             : #include <com/sun/star/embed/Aspects.hpp>
      60             : #include <com/sun/star/beans/XPropertySet.hpp>
      61             : #include <com/sun/star/frame/XStorable.hpp>
      62             : 
      63             : #include <comphelper/embeddedobjectcontainer.hxx>
      64             : #include <comphelper/classids.hxx>
      65             : 
      66             : using namespace com::sun::star;
      67             : 
      68             : #define HTML_DFLT_EMBED_WIDTH ((MM50*5)/2)
      69             : #define HTML_DFLT_EMBED_HEIGHT ((MM50*5)/2)
      70             : 
      71             : #define HTML_DFLT_APPLET_WIDTH ((MM50*5)/2)
      72             : #define HTML_DFLT_APPLET_HEIGHT ((MM50*5)/2)
      73             : 
      74             : namespace {
      75             : 
      76             : static char const sHTML_O_Hidden_False[] = "FALSE";
      77             : 
      78             : }
      79             : 
      80             : const sal_uLong HTML_FRMOPTS_EMBED_ALL      =
      81             :     HTML_FRMOPT_ALT |
      82             :     HTML_FRMOPT_SIZE |
      83             :     HTML_FRMOPT_NAME;
      84             : const sal_uLong HTML_FRMOPTS_EMBED_CNTNR    =
      85             :     HTML_FRMOPTS_EMBED_ALL |
      86             :     HTML_FRMOPT_ABSSIZE;
      87             : const sal_uLong HTML_FRMOPTS_EMBED          =
      88             :     HTML_FRMOPTS_EMBED_ALL |
      89             :     HTML_FRMOPT_ALIGN |
      90             :     HTML_FRMOPT_SPACE |
      91             :     HTML_FRMOPT_BRCLEAR |
      92             :     HTML_FRMOPT_NAME;
      93             : const sal_uLong HTML_FRMOPTS_HIDDEN_EMBED   =
      94             :     HTML_FRMOPT_ALT |
      95             :     HTML_FRMOPT_NAME;
      96             : 
      97             : const sal_uLong HTML_FRMOPTS_APPLET_ALL     =
      98             :     HTML_FRMOPT_ALT |
      99             :     HTML_FRMOPT_SIZE;
     100             : const sal_uLong HTML_FRMOPTS_APPLET_CNTNR   =
     101             :     HTML_FRMOPTS_APPLET_ALL |
     102             :     HTML_FRMOPT_ABSSIZE;
     103             : const sal_uLong HTML_FRMOPTS_APPLET         =
     104             :     HTML_FRMOPTS_APPLET_ALL |
     105             :     HTML_FRMOPT_ALIGN |
     106             :     HTML_FRMOPT_SPACE |
     107             :     HTML_FRMOPT_BRCLEAR;
     108             : 
     109             : const sal_uLong HTML_FRMOPTS_IFRAME_ALL     =
     110             :     HTML_FRMOPT_ALT |
     111             :     HTML_FRMOPT_SIZE;
     112             : const sal_uLong HTML_FRMOPTS_IFRAME_CNTNR   =
     113             :     HTML_FRMOPTS_IFRAME_ALL |
     114             :     HTML_FRMOPT_ABSSIZE;
     115             : const sal_uLong HTML_FRMOPTS_IFRAME         =
     116             :     HTML_FRMOPTS_IFRAME_ALL |
     117             :     HTML_FRMOPT_ALIGN |
     118             :     HTML_FRMOPT_SPACE |
     119             :     HTML_FRMOPT_BORDER |
     120             :     HTML_FRMOPT_BRCLEAR;
     121             : 
     122             : const sal_uLong HTML_FRMOPTS_OLE_CSS1       =
     123             :     HTML_FRMOPT_S_ALIGN |
     124             :     HTML_FRMOPT_S_SPACE;
     125             : 
     126           1 : void SwHTMLParser::SetFixSize( const Size& rPixSize,
     127             :                                const Size& rTwipDfltSize,
     128             :                                bool bPrcWidth, bool bPrcHeight,
     129             :                                SfxItemSet& /*rCSS1ItemSet*/,
     130             :                                SvxCSS1PropertyInfo& rCSS1PropInfo,
     131             :                                SfxItemSet& rFlyItemSet )
     132             : {
     133             :     // absolulte Groessenangaben in Twip umrechnen
     134           1 :     sal_uInt8 nPrcWidth = 0, nPrcHeight = 0;
     135           2 :     Size aTwipSz( bPrcWidth || USHRT_MAX==rPixSize.Width() ? 0 : rPixSize.Width(),
     136           3 :                   bPrcHeight || USHRT_MAX==rPixSize.Height() ? 0 : rPixSize.Height() );
     137           1 :     if( (aTwipSz.Width() || aTwipSz.Height()) && Application::GetDefaultDevice() )
     138             :     {
     139             :         aTwipSz =
     140             :             Application::GetDefaultDevice()->PixelToLogic( aTwipSz,
     141           1 :                                                 MapMode(MAP_TWIP) );
     142             :     }
     143             : 
     144             :     // die Breite bearbeiten
     145           1 :     if( SVX_CSS1_LTYPE_PERCENTAGE == rCSS1PropInfo.eWidthType )
     146             :     {
     147           0 :         nPrcWidth = (sal_uInt8)rCSS1PropInfo.nWidth;
     148           0 :         aTwipSz.Width() = rTwipDfltSize.Width();
     149             :     }
     150           1 :     else if( SVX_CSS1_LTYPE_TWIP== rCSS1PropInfo.eWidthType )
     151             :     {
     152           0 :         aTwipSz.Width() = rCSS1PropInfo.nWidth;
     153             :     }
     154           1 :     else if( bPrcWidth && rPixSize.Width() )
     155             :     {
     156           0 :         nPrcWidth = (sal_uInt8)rPixSize.Width();
     157           0 :         if( nPrcWidth > 100 )
     158           0 :             nPrcWidth = 100;
     159             : 
     160           0 :         aTwipSz.Width() = rTwipDfltSize.Width();
     161             :     }
     162           1 :     else if( USHRT_MAX==rPixSize.Width() )
     163             :     {
     164           0 :         aTwipSz.Width() = rTwipDfltSize.Width();
     165             :     }
     166           1 :     if( aTwipSz.Width() < MINFLY )
     167             :     {
     168           0 :         aTwipSz.Width() = MINFLY;
     169             :     }
     170             : 
     171             :     // Hoehe bearbeiten
     172           1 :     if( SVX_CSS1_LTYPE_PERCENTAGE == rCSS1PropInfo.eHeightType )
     173             :     {
     174           0 :         nPrcHeight = (sal_uInt8)rCSS1PropInfo.nHeight;
     175           0 :         aTwipSz.Height() = rTwipDfltSize.Height();
     176             :     }
     177           1 :     else if( SVX_CSS1_LTYPE_TWIP== rCSS1PropInfo.eHeightType )
     178             :     {
     179           0 :         aTwipSz.Height() = rCSS1PropInfo.nHeight;
     180             :     }
     181           1 :     else if( bPrcHeight && rPixSize.Height() )
     182             :     {
     183           0 :         nPrcHeight = (sal_uInt8)rPixSize.Height();
     184           0 :         if( nPrcHeight > 100 )
     185           0 :             nPrcHeight = 100;
     186             : 
     187           0 :         aTwipSz.Height() = rTwipDfltSize.Height();
     188             :     }
     189           1 :     else if( USHRT_MAX==rPixSize.Height() )
     190             :     {
     191           1 :         aTwipSz.Height() = rTwipDfltSize.Height();
     192             :     }
     193           1 :     if( aTwipSz.Height() < MINFLY )
     194             :     {
     195           0 :         aTwipSz.Height() = MINFLY;
     196             :     }
     197             : 
     198             :     // Size setzen
     199           1 :     SwFormatFrmSize aFrmSize( ATT_FIX_SIZE, aTwipSz.Width(), aTwipSz.Height() );
     200           1 :     aFrmSize.SetWidthPercent( nPrcWidth );
     201           1 :     aFrmSize.SetHeightPercent( nPrcHeight );
     202           1 :     rFlyItemSet.Put( aFrmSize );
     203           1 : }
     204             : 
     205           6 : void SwHTMLParser::SetSpace( const Size& rPixSpace,
     206             :                              SfxItemSet& rCSS1ItemSet,
     207             :                              SvxCSS1PropertyInfo& rCSS1PropInfo,
     208             :                              SfxItemSet& rFlyItemSet )
     209             : {
     210           6 :     sal_Int32 nLeftSpace = 0, nRightSpace = 0;
     211           6 :     sal_uInt16 nUpperSpace = 0, nLowerSpace = 0;
     212           6 :     if( (rPixSpace.Width() || rPixSpace.Height()) && Application::GetDefaultDevice() )
     213             :     {
     214           0 :         Size aTwipSpc( rPixSpace.Width(), rPixSpace.Height() );
     215             :         aTwipSpc =
     216             :             Application::GetDefaultDevice()->PixelToLogic( aTwipSpc,
     217           0 :                                                 MapMode(MAP_TWIP) );
     218           0 :         nLeftSpace = nRightSpace = aTwipSpc.Width();
     219           0 :         nUpperSpace = nLowerSpace = (sal_uInt16)aTwipSpc.Height();
     220             :     }
     221             : 
     222             :     // linken/rechten Rand setzen
     223             :     const SfxPoolItem *pItem;
     224           6 :     if( SfxItemState::SET==rCSS1ItemSet.GetItemState( RES_LR_SPACE, true, &pItem ) )
     225             :     {
     226             :         // Ggf. den Erstzeilen-Einzug noch plaetten
     227           0 :         const SvxLRSpaceItem *pLRItem = static_cast<const SvxLRSpaceItem *>(pItem);
     228           0 :         SvxLRSpaceItem aLRItem( *pLRItem );
     229           0 :         aLRItem.SetTextFirstLineOfst( 0 );
     230           0 :         if( rCSS1PropInfo.bLeftMargin )
     231             :         {
     232           0 :             nLeftSpace = aLRItem.GetLeft();
     233           0 :             rCSS1PropInfo.bLeftMargin = false;
     234             :         }
     235           0 :         if( rCSS1PropInfo.bRightMargin )
     236             :         {
     237           0 :             nRightSpace = aLRItem.GetRight();
     238           0 :             rCSS1PropInfo.bRightMargin = false;
     239             :         }
     240           0 :         rCSS1ItemSet.ClearItem( RES_LR_SPACE );
     241             :     }
     242           6 :     if( nLeftSpace > 0 || nRightSpace > 0 )
     243             :     {
     244           0 :         SvxLRSpaceItem aLRItem( RES_LR_SPACE );
     245           0 :         aLRItem.SetLeft( nLeftSpace > 0 ? nLeftSpace : 0 );
     246           0 :         aLRItem.SetRight( nRightSpace > 0 ? nRightSpace : 0 );
     247           0 :         rFlyItemSet.Put( aLRItem );
     248           0 :         if( nLeftSpace )
     249             :         {
     250             :             const SwFormatHoriOrient& rHoriOri =
     251           0 :                 static_cast<const SwFormatHoriOrient&>(rFlyItemSet.Get( RES_HORI_ORIENT ));
     252           0 :             if( text::HoriOrientation::NONE == rHoriOri.GetHoriOrient() )
     253             :             {
     254           0 :                 SwFormatHoriOrient aHoriOri( rHoriOri );
     255           0 :                 aHoriOri.SetPos( aHoriOri.GetPos() + nLeftSpace );
     256           0 :                 rFlyItemSet.Put( aHoriOri );
     257             :             }
     258           0 :         }
     259             :     }
     260             : 
     261             :     // oberen/unteren Rand setzen
     262           6 :     if( SfxItemState::SET==rCSS1ItemSet.GetItemState( RES_UL_SPACE, true, &pItem ) )
     263             :     {
     264             :         // Ggf. den Erstzeilen-Einzug noch plaetten
     265           0 :         const SvxULSpaceItem *pULItem = static_cast<const SvxULSpaceItem *>(pItem);
     266           0 :         if( rCSS1PropInfo.bTopMargin )
     267             :         {
     268           0 :             nUpperSpace = pULItem->GetUpper();
     269           0 :             rCSS1PropInfo.bTopMargin = false;
     270             :         }
     271           0 :         if( rCSS1PropInfo.bBottomMargin )
     272             :         {
     273           0 :             nLowerSpace = pULItem->GetLower();
     274           0 :             rCSS1PropInfo.bBottomMargin = false;
     275             :         }
     276           0 :         rCSS1ItemSet.ClearItem( RES_UL_SPACE );
     277             :     }
     278           6 :     if( nUpperSpace || nLowerSpace )
     279             :     {
     280           0 :         SvxULSpaceItem aULItem( RES_UL_SPACE );
     281           0 :         aULItem.SetUpper( nUpperSpace );
     282           0 :         aULItem.SetLower( nLowerSpace );
     283           0 :         rFlyItemSet.Put( aULItem );
     284           0 :         if( nUpperSpace )
     285             :         {
     286             :             const SwFormatVertOrient& rVertOri =
     287           0 :                 static_cast<const SwFormatVertOrient&>(rFlyItemSet.Get( RES_VERT_ORIENT ));
     288           0 :             if( text::VertOrientation::NONE == rVertOri.GetVertOrient() )
     289             :             {
     290           0 :                 SwFormatVertOrient aVertOri( rVertOri );
     291           0 :                 aVertOri.SetPos( aVertOri.GetPos() + nUpperSpace );
     292           0 :                 rFlyItemSet.Put( aVertOri );
     293             :             }
     294           0 :         }
     295             :     }
     296           6 : }
     297             : 
     298           0 : void SwHTMLParser::InsertEmbed()
     299             : {
     300           0 :     OUString aURL, aType, aName, aAlt, aId, aStyle, aClass;
     301           0 :     Size aSize( USHRT_MAX, USHRT_MAX );
     302           0 :     Size aSpace( USHRT_MAX, USHRT_MAX );
     303           0 :     bool bPrcWidth = false, bPrcHeight = false, bHidden = false;
     304           0 :     sal_Int16 eVertOri = text::VertOrientation::NONE;
     305           0 :     sal_Int16 eHoriOri = text::HoriOrientation::NONE;
     306           0 :     SvCommandList aCmdLst;
     307           0 :     const HTMLOptions& rHTMLOptions = GetOptions();
     308             : 
     309             :     // Die Optionen werden vorwaerts gelesen, weil die Plugins sie in
     310             :     // dieser Reihenfolge erwarten. Trotzdem darf immer nur der erste
     311             :     // Wert einer Option beruecksichtigt werden.
     312           0 :     for (size_t i = 0, n = rHTMLOptions.size(); i < n; ++i)
     313             :     {
     314           0 :         const HTMLOption& rOption = rHTMLOptions[i];
     315           0 :         switch( rOption.GetToken() )
     316             :         {
     317             :         case HTML_O_ID:
     318           0 :             aId = rOption.GetString();
     319           0 :             break;
     320             :         case HTML_O_STYLE:
     321           0 :             aStyle = rOption.GetString();
     322           0 :             break;
     323             :         case HTML_O_CLASS:
     324           0 :             aClass = rOption.GetString();
     325           0 :             break;
     326             :         case HTML_O_NAME:
     327           0 :             aName = rOption.GetString();
     328           0 :             break;
     329             :         case HTML_O_SRC:
     330           0 :             if( aURL.isEmpty() )
     331           0 :                 aURL = rOption.GetString();
     332           0 :             break;
     333             :         case HTML_O_ALT:
     334           0 :             aAlt = rOption.GetString();
     335           0 :             break;
     336             :         case HTML_O_TYPE:
     337           0 :             if( aType.isEmpty() )
     338           0 :                 aType = rOption.GetString();
     339           0 :             break;
     340             :         case HTML_O_ALIGN:
     341           0 :             if( eVertOri==text::VertOrientation::NONE && eHoriOri==text::HoriOrientation::NONE )
     342             :             {
     343           0 :                 eVertOri = rOption.GetEnum( aHTMLImgVAlignTable, eVertOri );
     344           0 :                 eHoriOri = rOption.GetEnum( aHTMLImgHAlignTable, eHoriOri );
     345             :             }
     346           0 :             break;
     347             :         case HTML_O_WIDTH:
     348           0 :             if( USHRT_MAX==aSize.Width() )
     349             :             {
     350           0 :                 bPrcWidth = (rOption.GetString().indexOf('%') != -1);
     351           0 :                 aSize.Width() = (long)rOption.GetNumber();
     352             :             }
     353           0 :             break;
     354             :         case HTML_O_HEIGHT:
     355           0 :             if( USHRT_MAX==aSize.Height() )
     356             :             {
     357           0 :                 bPrcHeight = (rOption.GetString().indexOf('%') != -1);
     358           0 :                 aSize.Height() = (long)rOption.GetNumber();
     359             :             }
     360           0 :             break;
     361             :         case HTML_O_HSPACE:
     362           0 :             if( USHRT_MAX==aSpace.Width() )
     363           0 :                 aSpace.Width() = (long)rOption.GetNumber();
     364           0 :             break;
     365             :         case HTML_O_VSPACE:
     366           0 :             if( USHRT_MAX==aSpace.Height() )
     367           0 :                 aSpace.Height() = (long)rOption.GetNumber();
     368           0 :             break;
     369             :         case HTML_O_UNKNOWN:
     370           0 :             if (rOption.GetTokenString().equalsIgnoreAsciiCase(
     371             :                         OOO_STRING_SW_HTML_O_Hidden))
     372             :             {
     373           0 :                 bHidden = !rOption.GetString().equalsIgnoreAsciiCase(
     374           0 :                                 sHTML_O_Hidden_False);
     375             :             }
     376           0 :             break;
     377             :         }
     378             : 
     379             :         // Es werden alle Parameter an das Plugin weitergereicht
     380           0 :         aCmdLst.Append( rOption.GetTokenString(), rOption.GetString() );
     381             :     }
     382             : 
     383           0 :     SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
     384           0 :     SvxCSS1PropertyInfo aPropInfo;
     385           0 :     if( HasStyleOptions( aStyle, aId, aClass ) )
     386           0 :         ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
     387             : 
     388             :     // Die Default-Werte umsetzen (ausser Hoehe/Breite, das macht schon
     389             :     // SetFrmSize() fuer uns)
     390           0 :     if( eVertOri==text::VertOrientation::NONE && eHoriOri==text::HoriOrientation::NONE )
     391           0 :         eVertOri = text::VertOrientation::TOP;
     392           0 :     if( USHRT_MAX==aSpace.Width() )
     393           0 :         aSpace.Width() = 0;
     394           0 :     if( USHRT_MAX==aSpace.Height() )
     395           0 :         aSpace.Height() = 0;
     396           0 :     if( bHidden )
     397             :     {
     398             :         // Size (0,0) wird in SetFrmSize auf (MINFLY, MINFLY) umgebogen
     399           0 :         aSize.Width() = 0; aSize.Height() = 0;
     400           0 :         aSpace.Width() = 0; aSpace.Height() = 0;
     401           0 :         bPrcWidth = bPrcHeight = false;
     402             :     }
     403             : 
     404             :     // die URL aufbereiten
     405           0 :     INetURLObject aURLObj;
     406           0 :     bool bHasURL = !aURL.isEmpty() &&
     407             :                    aURLObj.SetURL(
     408             :                        URIHelper::SmartRel2Abs(
     409             :                            INetURLObject(sBaseURL), aURL,
     410           0 :                            URIHelper::GetMaybeFileHdl()) );
     411             : 
     412             :     // do not insert plugin if it has neither URL nor type
     413           0 :     bool bHasType = !aType.isEmpty();
     414           0 :     if( !bHasURL && !bHasType )
     415           0 :         return;
     416             : 
     417             :     // das Plugin anlegen
     418           0 :     comphelper::EmbeddedObjectContainer aCnt;
     419           0 :     OUString aObjName;
     420           0 :     uno::Reference < embed::XEmbeddedObject > xObj = aCnt.CreateEmbeddedObject( SvGlobalName( SO3_PLUGIN_CLASSID ).GetByteSequence(), aObjName );
     421           0 :     if ( svt::EmbeddedObjectRef::TryRunningState( xObj ) )
     422             :     {
     423           0 :         uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
     424           0 :         if ( xSet.is() )
     425             :         {
     426           0 :             if( bHasURL )
     427           0 :                 xSet->setPropertyValue("PluginURL",
     428           0 :                     uno::makeAny( OUString( aURL ) ) );
     429           0 :             if( bHasType )
     430           0 :                 xSet->setPropertyValue("PluginMimeType",
     431           0 :                     uno::makeAny( OUString( aType ) ) );
     432             : 
     433           0 :             uno::Sequence < beans::PropertyValue > aProps;
     434           0 :             aCmdLst.FillSequence( aProps );
     435           0 :             xSet->setPropertyValue("PluginCommands", uno::makeAny( aProps ) );
     436             : 
     437           0 :         }
     438             :     }
     439             : 
     440           0 :     SfxItemSet aFrmSet( pDoc->GetAttrPool(),
     441           0 :                         RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
     442           0 :     if( !IsNewDoc() )
     443           0 :         Reader::ResetFrameFormatAttrs( aFrmSet );
     444             : 
     445             :     // den Anker setzen
     446           0 :     if( !bHidden )
     447             :     {
     448           0 :         SetAnchorAndAdjustment( eVertOri, eHoriOri, aItemSet, aPropInfo, aFrmSet );
     449             :     }
     450             :     else
     451             :     {
     452           0 :         SwFormatAnchor aAnchor( FLY_AT_PARA );
     453           0 :         aAnchor.SetAnchor( pPam->GetPoint() );
     454           0 :         aFrmSet.Put( aAnchor );
     455           0 :         aFrmSet.Put( SwFormatHoriOrient( 0, text::HoriOrientation::LEFT, text::RelOrientation::FRAME) );
     456           0 :         aFrmSet.Put( SwFormatSurround( SURROUND_THROUGHT ) );
     457           0 :         aFrmSet.Put( SwFormatVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::PRINT_AREA ) );
     458             :     }
     459             : 
     460             :     // und noch die Groesse des Rahmens
     461           0 :     Size aDfltSz( HTML_DFLT_EMBED_WIDTH, HTML_DFLT_EMBED_HEIGHT );
     462             :     SetFixSize( aSize, aDfltSz, bPrcWidth, bPrcHeight, aItemSet, aPropInfo,
     463           0 :                 aFrmSet );
     464           0 :     SetSpace( aSpace, aItemSet, aPropInfo, aFrmSet );
     465             : 
     466             :     // und in das Dok einfuegen
     467             :     SwFrameFormat* pFlyFormat =
     468           0 :         pDoc->getIDocumentContentOperations().Insert( *pPam, ::svt::EmbeddedObjectRef( xObj, embed::Aspects::MSOLE_CONTENT ), &aFrmSet, NULL, NULL );
     469             : 
     470             :     // Namen am FrameFormat setzen
     471           0 :     if( !aName.isEmpty() )
     472           0 :         pFlyFormat->SetName( aName );
     473             : 
     474             :     // den alternativen Text setzen
     475             :     SwNoTextNode *pNoTextNd =
     476           0 :         pDoc->GetNodes()[ pFlyFormat->GetContent().GetContentIdx()
     477           0 :                           ->GetIndex()+1 ]->GetNoTextNode();
     478           0 :     pNoTextNd->SetTitle( aAlt );
     479             : 
     480             :     // Ggf Frames anlegen und auto-geb. Rahmen registrieren
     481           0 :     if( !bHidden )
     482             :     {
     483             :         // HIDDEN-Plugins sollen absatzgebunden bleiben. Da RegisterFlyFrm
     484             :         // absatzgebundene Rahmen mit DUrchlauf in am Zeichen gebundene
     485             :         // Rahmen umwandelt, muessen die Frames hier von Hand angelegt werden.
     486           0 :         RegisterFlyFrm( pFlyFormat );
     487           0 :     }
     488             : }
     489             : 
     490             : #if HAVE_FEATURE_JAVA
     491           0 : void SwHTMLParser::NewObject()
     492             : {
     493           0 :     OUString aClassID;
     494           0 :     OUString aName, aStandBy, aId, aStyle, aClass;
     495           0 :     Size aSize( USHRT_MAX, USHRT_MAX );
     496           0 :     Size aSpace( 0, 0 );
     497           0 :     sal_Int16 eVertOri = text::VertOrientation::TOP;
     498           0 :     sal_Int16 eHoriOri = text::HoriOrientation::NONE;
     499             : 
     500           0 :     bool bPrcWidth = false, bPrcHeight = false,
     501           0 :              bDeclare = false;
     502             :     // Eine neue Command-List anlegen
     503           0 :     delete pAppletImpl;
     504           0 :     pAppletImpl = new SwApplet_Impl( pDoc->GetAttrPool(),
     505           0 :                                      RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
     506             : 
     507           0 :     const HTMLOptions& rHTMLOptions = GetOptions();
     508           0 :     for (size_t i = rHTMLOptions.size(); i; )
     509             :     {
     510           0 :         const HTMLOption& rOption = rHTMLOptions[--i];
     511           0 :         switch( rOption.GetToken() )
     512             :         {
     513             :         case HTML_O_ID:
     514           0 :             aId = rOption.GetString();
     515           0 :             break;
     516             :         case HTML_O_STYLE:
     517           0 :             aStyle = rOption.GetString();
     518           0 :             break;
     519             :         case HTML_O_CLASS:
     520           0 :             aClass = rOption.GetString();
     521           0 :             break;
     522             :         case HTML_O_DECLARE:
     523           0 :             bDeclare = true;
     524           0 :             break;
     525             :         case HTML_O_CLASSID:
     526           0 :             aClassID = rOption.GetString();
     527           0 :             break;
     528             :         case HTML_O_CODEBASE:
     529           0 :             break;
     530             :         case HTML_O_DATA:
     531           0 :             break;
     532             :         case HTML_O_TYPE:
     533           0 :             break;
     534             :         case HTML_O_CODETYPE:
     535           0 :             break;
     536             :         case HTML_O_ARCHIVE:
     537             :         case HTML_O_UNKNOWN:
     538           0 :             break;
     539             :         case HTML_O_STANDBY:
     540           0 :             aStandBy = rOption.GetString();
     541           0 :             break;
     542             :         case HTML_O_WIDTH:
     543           0 :             bPrcWidth = (rOption.GetString().indexOf('%') != -1);
     544           0 :             aSize.Width() = (long)rOption.GetNumber();
     545           0 :             break;
     546             :         case HTML_O_HEIGHT:
     547           0 :             bPrcHeight = (rOption.GetString().indexOf('%') != -1);
     548           0 :             aSize.Height() = (long)rOption.GetNumber();
     549           0 :             break;
     550             :         case HTML_O_ALIGN:
     551           0 :             eVertOri = rOption.GetEnum( aHTMLImgVAlignTable, eVertOri );
     552           0 :             eHoriOri = rOption.GetEnum( aHTMLImgHAlignTable, eHoriOri );
     553           0 :             break;
     554             :         case HTML_O_USEMAP:
     555           0 :             break;
     556             :         case HTML_O_NAME:
     557           0 :             aName = rOption.GetString();
     558           0 :             break;
     559             :         case HTML_O_HSPACE:
     560           0 :             aSpace.Width() = (long)rOption.GetNumber();
     561           0 :             break;
     562             :         case HTML_O_VSPACE:
     563           0 :             aSpace.Height() = (long)rOption.GetNumber();
     564           0 :             break;
     565             :         case HTML_O_BORDER:
     566           0 :             break;
     567             : 
     568             :         case HTML_O_SDONCLICK:
     569             :         case HTML_O_ONCLICK:
     570             :         case HTML_O_SDONMOUSEOVER:
     571             :         case HTML_O_ONMOUSEOVER:
     572             :         case HTML_O_SDONMOUSEOUT:
     573             :         case HTML_O_ONMOUSEOUT:
     574           0 :             break;
     575             :         }
     576             :         // Es werden alle Parameter auch an das Applet weitergereicht
     577           0 :         pAppletImpl->AppendParam( rOption.GetTokenString(),
     578           0 :                                   rOption.GetString() );
     579             : 
     580             :     }
     581             : 
     582             :     // Objects that are declared only are not evaluated. Moreover, only
     583             :     // Java applets are supported.
     584           0 :     bool bIsApplet = false;
     585             : 
     586           0 :     if( !bDeclare && aClassID.getLength() == 42 &&
     587           0 :         aClassID.startsWith("clsid:") )
     588             :     {
     589           0 :         aClassID = aClassID.copy(6);
     590           0 :         SvGlobalName aCID;
     591           0 :         if( aCID.MakeId( aClassID ) )
     592             :         {
     593             :             SvGlobalName aJavaCID( 0x8AD9C840UL, 0x044EU, 0x11D1U, 0xB3U, 0xE9U,
     594           0 :                                    0x00U, 0x80U, 0x5FU, 0x49U, 0x9DU, 0x93U );
     595             : 
     596           0 :             bIsApplet = aJavaCID == aCID;
     597           0 :         }
     598             :     }
     599             : 
     600           0 :     if( !bIsApplet )
     601             :     {
     602           0 :         delete pAppletImpl;
     603           0 :         pAppletImpl = 0;
     604           0 :         return;
     605             :     }
     606             : 
     607           0 :     pAppletImpl->SetAltText( aStandBy );
     608             : 
     609           0 :     SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
     610           0 :     SvxCSS1PropertyInfo aPropInfo;
     611           0 :     if( HasStyleOptions( aStyle, aId, aClass ) )
     612           0 :         ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
     613             : 
     614           0 :     SfxItemSet& rFrmSet = pAppletImpl->GetItemSet();
     615           0 :     if( !IsNewDoc() )
     616           0 :         Reader::ResetFrameFormatAttrs( rFrmSet );
     617             : 
     618             :     // den Anker und die Ausrichtung setzen
     619           0 :     SetAnchorAndAdjustment( eVertOri, eHoriOri, aItemSet, aPropInfo, rFrmSet );
     620             : 
     621             :     // und noch die Groesse des Rahmens
     622           0 :     Size aDfltSz( HTML_DFLT_APPLET_WIDTH, HTML_DFLT_APPLET_HEIGHT );
     623             :     SetFixSize( aSize, aDfltSz, bPrcWidth, bPrcHeight, aItemSet, aPropInfo,
     624           0 :                 rFrmSet );
     625           0 :     SetSpace( aSpace, aItemSet, aPropInfo, rFrmSet );
     626             : }
     627             : #endif
     628             : 
     629           0 : void SwHTMLParser::EndObject()
     630             : {
     631             : #if HAVE_FEATURE_JAVA
     632           0 :     if( !pAppletImpl )
     633           0 :         return;
     634           0 :     if( pAppletImpl->CreateApplet( sBaseURL ) )
     635             :     {
     636           0 :         pAppletImpl->FinishApplet();
     637             : 
     638             :         // und in das Dok einfuegen
     639             :         SwFrameFormat* pFlyFormat =
     640           0 :             pDoc->getIDocumentContentOperations().Insert( *pPam,
     641             :                     ::svt::EmbeddedObjectRef( pAppletImpl->GetApplet(), embed::Aspects::MSOLE_CONTENT ),
     642           0 :                     &pAppletImpl->GetItemSet(),
     643             :                     NULL,
     644           0 :                     NULL );
     645             : 
     646             :         // den alternativen Namen setzen
     647             :         SwNoTextNode *pNoTextNd =
     648           0 :             pDoc->GetNodes()[ pFlyFormat->GetContent().GetContentIdx()
     649           0 :                               ->GetIndex()+1 ]->GetNoTextNode();
     650           0 :         pNoTextNd->SetTitle( pAppletImpl->GetAltText() );
     651             : 
     652             :         // Ggf Frames anlegen und auto-geb. Rahmen registrieren
     653           0 :         RegisterFlyFrm( pFlyFormat );
     654             : 
     655           0 :         delete pAppletImpl;
     656           0 :         pAppletImpl = 0;
     657             :     }
     658             : #endif
     659             : }
     660             : 
     661             : #if HAVE_FEATURE_JAVA
     662           0 : void SwHTMLParser::InsertApplet()
     663             : {
     664           0 :     OUString aCodeBase, aCode, aName, aAlt, aId, aStyle, aClass;
     665           0 :     Size aSize( USHRT_MAX, USHRT_MAX );
     666           0 :     Size aSpace( 0, 0 );
     667           0 :     bool bPrcWidth = false, bPrcHeight = false, bMayScript = false;
     668           0 :     sal_Int16 eVertOri = text::VertOrientation::TOP;
     669           0 :     sal_Int16 eHoriOri = text::HoriOrientation::NONE;
     670             : 
     671             :     // Eine neue Command-List anlegen
     672           0 :     delete pAppletImpl;
     673           0 :     pAppletImpl = new SwApplet_Impl( pDoc->GetAttrPool(), RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
     674             : 
     675           0 :     const HTMLOptions& rHTMLOptions = GetOptions();
     676           0 :     for (size_t i = rHTMLOptions.size(); i; )
     677             :     {
     678           0 :         const HTMLOption& rOption = rHTMLOptions[--i];
     679           0 :         switch( rOption.GetToken() )
     680             :         {
     681             :         case HTML_O_ID:
     682           0 :             aId = rOption.GetString();
     683           0 :             break;
     684             :         case HTML_O_STYLE:
     685           0 :             aStyle = rOption.GetString();
     686           0 :             break;
     687             :         case HTML_O_CLASS:
     688           0 :             aClass = rOption.GetString();
     689           0 :             break;
     690             :         case HTML_O_CODEBASE:
     691           0 :             aCodeBase = rOption.GetString();
     692           0 :             break;
     693             :         case HTML_O_CODE:
     694           0 :             aCode = rOption.GetString();
     695           0 :             break;
     696             :         case HTML_O_NAME:
     697           0 :             aName = rOption.GetString();
     698           0 :             break;
     699             :         case HTML_O_ALT:
     700           0 :             aAlt = rOption.GetString();
     701           0 :             break;
     702             :         case HTML_O_ALIGN:
     703           0 :             eVertOri = rOption.GetEnum( aHTMLImgVAlignTable, eVertOri );
     704           0 :             eHoriOri = rOption.GetEnum( aHTMLImgHAlignTable, eHoriOri );
     705           0 :             break;
     706             :         case HTML_O_WIDTH:
     707           0 :             bPrcWidth = (rOption.GetString().indexOf('%') != -1);
     708           0 :             aSize.Width() = (long)rOption.GetNumber();
     709           0 :             break;
     710             :         case HTML_O_HEIGHT:
     711           0 :             bPrcHeight = (rOption.GetString().indexOf('%') != -1);
     712           0 :             aSize.Height() = (long)rOption.GetNumber();
     713           0 :             break;
     714             :         case HTML_O_HSPACE:
     715           0 :             aSpace.Width() = (long)rOption.GetNumber();
     716           0 :             break;
     717             :         case HTML_O_VSPACE:
     718           0 :             aSpace.Height() = (long)rOption.GetNumber();
     719           0 :             break;
     720             :         case HTML_O_MAYSCRIPT:
     721           0 :             bMayScript = true;
     722           0 :             break;
     723             :         }
     724             : 
     725             :         // Es werden alle Parameter auch an das Applet weitergereicht
     726           0 :         pAppletImpl->AppendParam( rOption.GetTokenString(),
     727           0 :                                   rOption.GetString() );
     728             :     }
     729             : 
     730           0 :     if( aCode.isEmpty() )
     731             :     {
     732           0 :         delete pAppletImpl;
     733           0 :         pAppletImpl = 0;
     734           0 :         return;
     735             :     }
     736             : 
     737           0 :     if ( !aCodeBase.isEmpty() )
     738           0 :         aCodeBase = INetURLObject::GetAbsURL( sBaseURL, aCodeBase );
     739           0 :     pAppletImpl->CreateApplet( aCode, aName, bMayScript, aCodeBase, sBaseURL );//, aAlt );
     740           0 :     pAppletImpl->SetAltText( aAlt );
     741             : 
     742           0 :     SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
     743           0 :     SvxCSS1PropertyInfo aPropInfo;
     744           0 :     if( HasStyleOptions( aStyle, aId, aClass ) )
     745           0 :         ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
     746             : 
     747           0 :     SfxItemSet& rFrmSet = pAppletImpl->GetItemSet();
     748           0 :     if( !IsNewDoc() )
     749           0 :         Reader::ResetFrameFormatAttrs( rFrmSet );
     750             : 
     751             :     // den Anker und die Ausrichtung setzen
     752           0 :     SetAnchorAndAdjustment( eVertOri, eHoriOri, aItemSet, aPropInfo, rFrmSet );
     753             : 
     754             :     // und noch die Groesse des Rahmens
     755           0 :     Size aDfltSz( HTML_DFLT_APPLET_WIDTH, HTML_DFLT_APPLET_HEIGHT );
     756             :     SetFixSize( aSize, aDfltSz, bPrcWidth, bPrcHeight, aItemSet, aPropInfo,
     757           0 :                 rFrmSet );
     758           0 :     SetSpace( aSpace, aItemSet, aPropInfo, rFrmSet );
     759             : }
     760             : #endif
     761             : 
     762           0 : void SwHTMLParser::EndApplet()
     763             : {
     764             : #if HAVE_FEATURE_JAVA
     765           0 :     if( !pAppletImpl )
     766           0 :         return;
     767             : 
     768           0 :     pAppletImpl->FinishApplet();
     769             : 
     770             :     // und in das Dok einfuegen
     771             :     SwFrameFormat* pFlyFormat =
     772           0 :         pDoc->getIDocumentContentOperations().Insert( *pPam,
     773             :                     ::svt::EmbeddedObjectRef( pAppletImpl->GetApplet(), embed::Aspects::MSOLE_CONTENT ),
     774           0 :                     &pAppletImpl->GetItemSet(),
     775             :                     NULL,
     776           0 :                     NULL );
     777             : 
     778             :     // den alternativen Namen setzen
     779             :     SwNoTextNode *pNoTextNd =
     780           0 :         pDoc->GetNodes()[ pFlyFormat->GetContent().GetContentIdx()
     781           0 :                           ->GetIndex()+1 ]->GetNoTextNode();
     782           0 :     pNoTextNd->SetTitle( pAppletImpl->GetAltText() );
     783             : 
     784             :     // Ggf Frames anlegen und auto-geb. Rahmen registrieren
     785           0 :     RegisterFlyFrm( pFlyFormat );
     786             : 
     787           0 :     delete pAppletImpl;
     788           0 :     pAppletImpl = 0;
     789             : #endif
     790             : }
     791             : 
     792           0 : void SwHTMLParser::InsertParam()
     793             : {
     794             : #if HAVE_FEATURE_JAVA
     795           0 :     if( !pAppletImpl )
     796           0 :         return;
     797             : 
     798           0 :     OUString aName, aValue;
     799             : 
     800           0 :     const HTMLOptions& rHTMLOptions = GetOptions();
     801           0 :     for (size_t i = rHTMLOptions.size(); i; )
     802             :     {
     803           0 :         const HTMLOption& rOption = rHTMLOptions[--i];
     804           0 :         switch( rOption.GetToken() )
     805             :         {
     806             :         case HTML_O_NAME:
     807           0 :             aName = rOption.GetString();
     808           0 :             break;
     809             :         case HTML_O_VALUE:
     810           0 :             aValue = rOption.GetString();
     811           0 :             break;
     812             :         }
     813             :     }
     814             : 
     815           0 :     if( aName.isEmpty() )
     816           0 :         return;
     817             : 
     818           0 :     pAppletImpl->AppendParam( aName, aValue );
     819             : #endif
     820             : }
     821             : 
     822           1 : void SwHTMLParser::InsertFloatingFrame()
     823             : {
     824           2 :     OUString aAlt, aId, aStyle, aClass;
     825           1 :     Size aSize( USHRT_MAX, USHRT_MAX );
     826           1 :     Size aSpace( 0, 0 );
     827           1 :     bool bPrcWidth = false, bPrcHeight = false;
     828           1 :     sal_Int16 eVertOri = text::VertOrientation::TOP;
     829           1 :     sal_Int16 eHoriOri = text::HoriOrientation::NONE;
     830             : 
     831           1 :     const HTMLOptions& rHTMLOptions = GetOptions();
     832             : 
     833             :     // Erstmal die Optionen f?r das Writer-Frame-Format holen
     834           2 :     for (size_t i = 0, n = rHTMLOptions.size(); i < n; ++i)
     835             :     {
     836           1 :         const HTMLOption& rOption = rHTMLOptions[i];
     837           1 :         switch( rOption.GetToken() )
     838             :         {
     839             :         case HTML_O_ID:
     840           0 :             aId = rOption.GetString();
     841           0 :             break;
     842             :         case HTML_O_STYLE:
     843           0 :             aStyle = rOption.GetString();
     844           0 :             break;
     845             :         case HTML_O_CLASS:
     846           0 :             aClass = rOption.GetString();
     847           0 :             break;
     848             :         case HTML_O_ALT:
     849           0 :             aAlt = rOption.GetString();
     850           0 :             break;
     851             :         case HTML_O_ALIGN:
     852           0 :             eVertOri = rOption.GetEnum( aHTMLImgVAlignTable, eVertOri );
     853           0 :             eHoriOri = rOption.GetEnum( aHTMLImgHAlignTable, eHoriOri );
     854           0 :             break;
     855             :         case HTML_O_WIDTH:
     856           1 :             bPrcWidth = (rOption.GetString().indexOf('%') != -1);
     857           1 :             aSize.Width() = (long)rOption.GetNumber();
     858           1 :             break;
     859             :         case HTML_O_HEIGHT:
     860           0 :             bPrcHeight = (rOption.GetString().indexOf('%') != -1);
     861           0 :             aSize.Height() = (long)rOption.GetNumber();
     862           0 :             break;
     863             :         case HTML_O_HSPACE:
     864           0 :             aSpace.Width() = (long)rOption.GetNumber();
     865           0 :             break;
     866             :         case HTML_O_VSPACE:
     867           0 :             aSpace.Height() = (long)rOption.GetNumber();
     868           0 :             break;
     869             :         }
     870             :     }
     871             : 
     872             :     // und jetzt die fuer den SfxFrame
     873           1 :     SfxFrameDescriptor aFrameDesc;
     874             : 
     875           1 :     SfxFrameHTMLParser::ParseFrameOptions( &aFrameDesc, rHTMLOptions, sBaseURL );
     876             : 
     877             :     // den Floating-Frame anlegen
     878           2 :     comphelper::EmbeddedObjectContainer aCnt;
     879           2 :     OUString aObjName;
     880           2 :     uno::Reference < embed::XEmbeddedObject > xObj = aCnt.CreateEmbeddedObject( SvGlobalName( SO3_IFRAME_CLASSID ).GetByteSequence(), aObjName );
     881             : 
     882             :     try
     883             :     {
     884             :         // TODO/MBA: testing
     885           1 :         if ( svt::EmbeddedObjectRef::TryRunningState( xObj ) )
     886             :         {
     887           1 :             uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
     888           1 :             if ( xSet.is() )
     889             :             {
     890           1 :                 OUString aName = aFrameDesc.GetName();
     891           1 :                 ScrollingMode eScroll = aFrameDesc.GetScrollingMode();
     892           1 :                 bool bHasBorder = aFrameDesc.HasFrameBorder();
     893           1 :                 Size aMargin = aFrameDesc.GetMargin();
     894             : 
     895           1 :                 xSet->setPropertyValue("FrameURL", uno::makeAny( OUString( aFrameDesc.GetURL().GetMainURL( INetURLObject::NO_DECODE ) ) ) );
     896           1 :                 xSet->setPropertyValue("FrameName", uno::makeAny( aName ) );
     897             : 
     898           1 :                 if ( eScroll == ScrollingAuto )
     899           1 :                     xSet->setPropertyValue("FrameIsAutoScroll",
     900           1 :                         uno::makeAny( true ) );
     901             :                 else
     902           0 :                     xSet->setPropertyValue("FrameIsScrollingMode",
     903           0 :                         uno::makeAny( eScroll == ScrollingYes ) );
     904             : 
     905           1 :                 xSet->setPropertyValue("FrameIsBorder",
     906           1 :                         uno::makeAny( bHasBorder ) );
     907             : 
     908           1 :                 xSet->setPropertyValue("FrameMarginWidth",
     909           1 :                     uno::makeAny( sal_Int32( aMargin.Width() ) ) );
     910             : 
     911           1 :                 xSet->setPropertyValue("FrameMarginHeight",
     912           1 :                     uno::makeAny( sal_Int32( aMargin.Height() ) ) );
     913           1 :             }
     914             :         }
     915             :     }
     916           0 :     catch ( uno::Exception& )
     917             :     {
     918             :     }
     919             : 
     920           2 :     SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
     921           2 :     SvxCSS1PropertyInfo aPropInfo;
     922           1 :     if( HasStyleOptions( aStyle, aId, aClass ) )
     923           0 :         ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
     924             : 
     925             :     // den Itemset holen
     926           1 :     SfxItemSet aFrmSet( pDoc->GetAttrPool(),
     927           2 :                         RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
     928           1 :     if( !IsNewDoc() )
     929           0 :         Reader::ResetFrameFormatAttrs( aFrmSet );
     930             : 
     931             :     // den Anker und die Ausrichtung setzen
     932           1 :     SetAnchorAndAdjustment( eVertOri, eHoriOri, aItemSet, aPropInfo, aFrmSet );
     933             : 
     934             :     // und noch die Groesse des Rahmens
     935           1 :     Size aDfltSz( HTML_DFLT_APPLET_WIDTH, HTML_DFLT_APPLET_HEIGHT );
     936             :     SetFixSize( aSize, aDfltSz, bPrcWidth, bPrcHeight, aItemSet, aPropInfo,
     937           1 :                 aFrmSet );
     938           1 :     SetSpace( aSpace, aItemSet, aPropInfo, aFrmSet );
     939             : 
     940             :     // und in das Dok einfuegen
     941             :     SwFrameFormat* pFlyFormat =
     942           1 :         pDoc->getIDocumentContentOperations().Insert( *pPam, ::svt::EmbeddedObjectRef( xObj, embed::Aspects::MSOLE_CONTENT ), &aFrmSet, NULL, NULL );
     943             : 
     944             :     // den alternativen Namen setzen
     945             :     SwNoTextNode *pNoTextNd =
     946           2 :         pDoc->GetNodes()[ pFlyFormat->GetContent().GetContentIdx()
     947           2 :                           ->GetIndex()+1 ]->GetNoTextNode();
     948           1 :     pNoTextNd->SetTitle( aAlt );
     949             : 
     950             :     // Ggf Frames anlegen und auto-geb. Rahmen registrieren
     951           1 :     RegisterFlyFrm( pFlyFormat );
     952             : 
     953           3 :     bInFloatingFrame = true;
     954           1 : }
     955             : 
     956           2 : sal_uInt16 SwHTMLWriter::GuessOLENodeFrmType( const SwNode& rNode )
     957             : {
     958           2 :     SwOLEObj& rObj = const_cast<SwOLENode*>(rNode.GetOLENode())->GetOLEObj();
     959             : 
     960           2 :     SwHTMLFrmType eType = HTML_FRMTYPE_OLE;
     961             : 
     962           2 :     uno::Reference < embed::XClassifiedObject > xClass ( rObj.GetOleRef(), uno::UNO_QUERY );
     963           4 :     SvGlobalName aClass( xClass->getClassID() );
     964           2 :     if( aClass == SvGlobalName( SO3_PLUGIN_CLASSID ) )
     965             :     {
     966           0 :         eType = HTML_FRMTYPE_PLUGIN;
     967             :     }
     968           2 :     else if( aClass == SvGlobalName( SO3_IFRAME_CLASSID ) )
     969             :     {
     970           0 :         eType = HTML_FRMTYPE_IFRAME;
     971             :     }
     972             : #if HAVE_FEATURE_JAVA
     973           2 :     else if( aClass == SvGlobalName( SO3_APPLET_CLASSID ) )
     974             :     {
     975           0 :         eType = HTML_FRMTYPE_APPLET;
     976             :     }
     977             : #endif
     978             : 
     979           4 :     return static_cast< sal_uInt16 >(eType);
     980             : }
     981             : 
     982           0 : Writer& OutHTML_FrameFormatOLENode( Writer& rWrt, const SwFrameFormat& rFrameFormat,
     983             :                                bool bInCntnr )
     984             : {
     985           0 :     SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
     986             : 
     987           0 :     const SwFormatContent& rFlyContent = rFrameFormat.GetContent();
     988           0 :     sal_uLong nStt = rFlyContent.GetContentIdx()->GetIndex()+1;
     989           0 :     SwOLENode *pOLENd = rHTMLWrt.pDoc->GetNodes()[ nStt ]->GetOLENode();
     990             : 
     991             :     OSL_ENSURE( pOLENd, "OLE-Node erwartet" );
     992           0 :     if( !pOLENd )
     993           0 :         return rWrt;
     994             : 
     995           0 :     SwOLEObj &rObj = pOLENd->GetOLEObj();
     996             : 
     997           0 :     uno::Reference < embed::XEmbeddedObject > xObj( rObj.GetOleRef() );
     998           0 :     if ( !svt::EmbeddedObjectRef::TryRunningState( xObj ) )
     999           0 :         return rWrt;
    1000             : 
    1001           0 :     uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
    1002           0 :     bool bHiddenEmbed = false;
    1003             : 
    1004           0 :     if( !xSet.is() )
    1005             :     {
    1006             :         OSL_FAIL("Unknown Object" );
    1007           0 :         return rWrt;
    1008             :     }
    1009             : 
    1010             :     sal_uLong nFrmOpts;
    1011             : 
    1012             :     // wenn meoglich vor dem "Objekt" einen Zeilen-Umbruch ausgeben
    1013           0 :     if( rHTMLWrt.bLFPossible )
    1014           0 :         rHTMLWrt.OutNewLine( true );
    1015             : 
    1016           0 :     if( !rFrameFormat.GetName().isEmpty() )
    1017             :         rHTMLWrt.OutImplicitMark( rFrameFormat.GetName(),
    1018           0 :                                   "ole" );
    1019           0 :     uno::Any aAny;
    1020           0 :     SvGlobalName aGlobName( xObj->getClassID() );
    1021           0 :     OStringBuffer sOut;
    1022           0 :     sOut.append('<');
    1023           0 :     if( aGlobName == SvGlobalName( SO3_PLUGIN_CLASSID ) )
    1024             :     {
    1025             :         // erstmal das Plug-spezifische
    1026           0 :         sOut.append(OOO_STRING_SVTOOLS_HTML_embed);
    1027             : 
    1028           0 :         OUString aStr;
    1029           0 :         OUString aURL;
    1030           0 :         aAny = xSet->getPropertyValue("PluginURL");
    1031           0 :         if( (aAny >>= aStr) && !aStr.isEmpty() )
    1032             :         {
    1033           0 :             aURL = URIHelper::simpleNormalizedMakeRelative( rWrt.GetBaseURL(),
    1034           0 :                       aStr);
    1035             :         }
    1036             : 
    1037           0 :         if( !aURL.isEmpty() )
    1038             :         {
    1039           0 :             sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_src)
    1040           0 :                 .append("=\"");
    1041           0 :             rWrt.Strm().WriteCharPtr( sOut.makeStringAndClear().getStr() );
    1042           0 :             HTMLOutFuncs::Out_String( rWrt.Strm(), aURL, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
    1043           0 :             sOut.append('\"');
    1044             :         }
    1045             : 
    1046           0 :         OUString aType;
    1047           0 :         aAny = xSet->getPropertyValue("PluginMimeType");
    1048           0 :         if( (aAny >>= aType) && !aType.isEmpty() )
    1049             :         {
    1050           0 :             sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_type)
    1051           0 :                 .append("=\"");
    1052           0 :             rWrt.Strm().WriteCharPtr( sOut.makeStringAndClear().getStr() );
    1053           0 :             HTMLOutFuncs::Out_String( rWrt.Strm(), aType, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
    1054           0 :             sOut.append('\"');
    1055             :         }
    1056             : 
    1057           0 :         if ((FLY_AT_PARA == rFrameFormat.GetAnchor().GetAnchorId()) &&
    1058           0 :             SURROUND_THROUGHT == rFrameFormat.GetSurround().GetSurround() )
    1059             :         {
    1060             :             // Das Plugin ist HIDDEN
    1061           0 :             sOut.append(' ').append(OOO_STRING_SW_HTML_O_Hidden);
    1062           0 :             nFrmOpts = HTML_FRMOPTS_HIDDEN_EMBED;
    1063           0 :             bHiddenEmbed = true;
    1064             :         }
    1065             :         else
    1066             :         {
    1067             :             nFrmOpts = bInCntnr ? HTML_FRMOPTS_EMBED_CNTNR
    1068           0 :                                 : HTML_FRMOPTS_EMBED;
    1069           0 :         }
    1070             :     }
    1071           0 :     else if( aGlobName == SvGlobalName( SO3_APPLET_CLASSID ) )
    1072             :     {
    1073             :         // oder das Applet-Spezifische
    1074             : 
    1075           0 :         sOut.append(OOO_STRING_SVTOOLS_HTML_applet);
    1076             : 
    1077             :         // CODEBASE
    1078           0 :         OUString aCd;
    1079           0 :         aAny = xSet->getPropertyValue("AppletCodeBase");
    1080           0 :         if( (aAny >>= aCd) && !aCd.isEmpty() )
    1081             :         {
    1082           0 :             OUString sCodeBase( URIHelper::simpleNormalizedMakeRelative(rWrt.GetBaseURL(), aCd) );
    1083           0 :             if( !sCodeBase.isEmpty() )
    1084             :             {
    1085           0 :                 sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_codebase)
    1086           0 :                     .append("=\"");
    1087           0 :                 rWrt.Strm().WriteCharPtr( sOut.makeStringAndClear().getStr() );
    1088           0 :                 HTMLOutFuncs::Out_String( rWrt.Strm(), sCodeBase, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
    1089           0 :                 sOut.append('\"');
    1090           0 :             }
    1091             :         }
    1092             : 
    1093             :         // CODE
    1094           0 :         OUString aClass;
    1095           0 :         aAny = xSet->getPropertyValue("AppletCode");
    1096           0 :         aAny >>= aClass;
    1097           0 :         sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_code)
    1098           0 :             .append("=\"");
    1099           0 :         rWrt.Strm().WriteCharPtr( sOut.makeStringAndClear().getStr() );
    1100           0 :         HTMLOutFuncs::Out_String( rWrt.Strm(), aClass, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
    1101           0 :         sOut.append('\"');
    1102             : 
    1103             :         // NAME
    1104           0 :         OUString aAppletName;
    1105           0 :         aAny = xSet->getPropertyValue("AppletName");
    1106           0 :         aAny >>= aAppletName;
    1107           0 :         if( !aAppletName.isEmpty() )
    1108             :         {
    1109           0 :             sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_name)
    1110           0 :                 .append("=\"");
    1111           0 :             rWrt.Strm().WriteCharPtr( sOut.makeStringAndClear().getStr() );
    1112           0 :             HTMLOutFuncs::Out_String( rWrt.Strm(), aAppletName, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
    1113           0 :             sOut.append('\"');
    1114             :         }
    1115             : 
    1116           0 :         bool bScript = false;
    1117           0 :         aAny = xSet->getPropertyValue("AppletIsScript");
    1118           0 :         aAny >>= bScript;
    1119           0 :         if( bScript )
    1120           0 :             sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_mayscript);
    1121             : 
    1122             :         nFrmOpts = bInCntnr ? HTML_FRMOPTS_APPLET_CNTNR
    1123           0 :                             : HTML_FRMOPTS_APPLET;
    1124             :     }
    1125             :     else
    1126             :     {
    1127             :         // oder das Flating-Frame spezifische
    1128             : 
    1129           0 :         sOut.append(OOO_STRING_SVTOOLS_HTML_iframe);
    1130           0 :         rWrt.Strm().WriteCharPtr( sOut.makeStringAndClear().getStr() );
    1131             : 
    1132           0 :         SfxFrameHTMLWriter::Out_FrameDescriptor( rWrt.Strm(), rWrt.GetBaseURL(),
    1133             :                                         xSet,
    1134             :                                         rHTMLWrt.eDestEnc,
    1135           0 :                                         &rHTMLWrt.aNonConvertableCharacters );
    1136             : 
    1137             :         nFrmOpts = bInCntnr ? HTML_FRMOPTS_IFRAME_CNTNR
    1138           0 :                             : HTML_FRMOPTS_IFRAME;
    1139             :     }
    1140             : 
    1141           0 :     rWrt.Strm().WriteCharPtr( sOut.makeStringAndClear().getStr() );
    1142             : 
    1143             :     // ALT, WIDTH, HEIGHT, HSPACE, VSPACE, ALIGN
    1144           0 :     if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bHiddenEmbed )
    1145           0 :         nFrmOpts |= HTML_FRMOPTS_OLE_CSS1;
    1146           0 :     OString aEndTags = rHTMLWrt.OutFrameFormatOptions( rFrameFormat, pOLENd->GetTitle(), nFrmOpts );
    1147           0 :     if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bHiddenEmbed )
    1148           0 :         rHTMLWrt.OutCSS1_FrameFormatOptions( rFrameFormat, nFrmOpts );
    1149             : 
    1150           0 :     if( aGlobName == SvGlobalName( SO3_APPLET_CLASSID ) )
    1151             :     {
    1152             :         // fuer Applets die Parameter als eigene Tags ausgeben
    1153             :         // und ein </APPLET> schreiben
    1154             : 
    1155           0 :         uno::Sequence < beans::PropertyValue > aProps;
    1156           0 :         aAny = xSet->getPropertyValue("AppletCommands");
    1157           0 :         aAny >>= aProps;
    1158             : 
    1159           0 :         SvCommandList aCommands;
    1160           0 :         aCommands.FillFromSequence( aProps );
    1161           0 :         std::vector<sal_uLong> aParams;
    1162           0 :         size_t i = aCommands.size();
    1163           0 :         while( i > 0 )
    1164             :         {
    1165           0 :             const SvCommand& rCommand = aCommands[ --i ];
    1166           0 :             const OUString& rName = rCommand.GetCommand();
    1167           0 :             SwHtmlOptType nType = SwApplet_Impl::GetOptionType( rName, true );
    1168           0 :             if( SwHtmlOptType::TAG == nType )
    1169             :             {
    1170           0 :                 const OUString& rValue = rCommand.GetArgument();
    1171           0 :                 rWrt.Strm().WriteChar( ' ' );
    1172           0 :                 HTMLOutFuncs::Out_String( rWrt.Strm(), rName, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
    1173           0 :                 rWrt.Strm().WriteCharPtr( "=\"" );
    1174           0 :                 HTMLOutFuncs::Out_String( rWrt.Strm(), rValue, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters ).WriteChar( '\"' );
    1175             :             }
    1176           0 :             else if( SwHtmlOptType::PARAM == nType )
    1177             :             {
    1178           0 :                 aParams.push_back( i );
    1179             :             }
    1180           0 :         }
    1181             : 
    1182           0 :         rHTMLWrt.Strm().WriteChar( '>' );
    1183             : 
    1184           0 :         rHTMLWrt.IncIndentLevel(); // Inhalt von Applet einruecken
    1185             : 
    1186           0 :         size_t ii = aParams.size();
    1187           0 :         while( ii > 0  )
    1188             :         {
    1189           0 :             const SvCommand& rCommand = aCommands[ aParams[--ii] ];
    1190           0 :             const OUString& rName = rCommand.GetCommand();
    1191           0 :             const OUString& rValue = rCommand.GetArgument();
    1192           0 :             rHTMLWrt.OutNewLine();
    1193           0 :             OStringBuffer sBuf;
    1194           0 :             sBuf.append('<').append(OOO_STRING_SVTOOLS_HTML_param)
    1195           0 :                 .append(' ').append(OOO_STRING_SVTOOLS_HTML_O_name)
    1196           0 :                 .append("=\"");
    1197           0 :             rWrt.Strm().WriteCharPtr( sBuf.makeStringAndClear().getStr() );
    1198           0 :             HTMLOutFuncs::Out_String( rWrt.Strm(), rName, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
    1199           0 :             sBuf.append("\" ").append(OOO_STRING_SVTOOLS_HTML_O_value)
    1200           0 :                 .append("=\"");
    1201           0 :             rWrt.Strm().WriteCharPtr( sBuf.makeStringAndClear().getStr() );
    1202           0 :             HTMLOutFuncs::Out_String( rWrt.Strm(), rValue, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters ).WriteCharPtr( "\">" );
    1203           0 :         }
    1204             : 
    1205           0 :         rHTMLWrt.DecIndentLevel(); // Inhalt von Applet einruecken
    1206           0 :         if( aCommands.size() )
    1207           0 :             rHTMLWrt.OutNewLine();
    1208           0 :         HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), OOO_STRING_SVTOOLS_HTML_applet, false );
    1209             :     }
    1210           0 :     else if( aGlobName == SvGlobalName( SO3_PLUGIN_CLASSID ) )
    1211             :     {
    1212             :         // fuer Plugins die Parameter als Optionen schreiben
    1213             : 
    1214           0 :         uno::Sequence < beans::PropertyValue > aProps;
    1215           0 :         aAny = xSet->getPropertyValue("PluginCommands");
    1216           0 :         aAny >>= aProps;
    1217             : 
    1218           0 :         SvCommandList aCommands;
    1219           0 :         aCommands.FillFromSequence( aProps );
    1220           0 :         for( size_t i = 0; i < aCommands.size(); i++ )
    1221             :         {
    1222           0 :             const SvCommand& rCommand = aCommands[ i ];
    1223           0 :             const OUString& rName = rCommand.GetCommand();
    1224             : 
    1225           0 :             if( SwApplet_Impl::GetOptionType( rName, false ) == SwHtmlOptType::TAG )
    1226             :             {
    1227           0 :                 const OUString& rValue = rCommand.GetArgument();
    1228           0 :                 rWrt.Strm().WriteChar( ' ' );
    1229           0 :                 HTMLOutFuncs::Out_String( rWrt.Strm(), rName, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
    1230           0 :                 rWrt.Strm().WriteCharPtr( "=\"" );
    1231           0 :                 HTMLOutFuncs::Out_String( rWrt.Strm(), rValue, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters ).WriteChar( '\"' );
    1232             :             }
    1233           0 :         }
    1234           0 :         rHTMLWrt.Strm().WriteChar( '>' );
    1235             :     }
    1236             :     else
    1237             :     {
    1238             :         // und fuer Floating-Frames einfach noch ein </IFRAME>
    1239             :         // ausgeben
    1240             : 
    1241           0 :         rHTMLWrt.Strm().WriteChar( '>' );
    1242           0 :         HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), OOO_STRING_SVTOOLS_HTML_iframe, false );
    1243             :     }
    1244             : 
    1245           0 :     if( !aEndTags.isEmpty() )
    1246           0 :         rWrt.Strm().WriteCharPtr( aEndTags.getStr() );
    1247             : 
    1248           0 :     return rWrt;
    1249             : }
    1250             : 
    1251           2 : Writer& OutHTML_FrameFormatOLENodeGrf( Writer& rWrt, const SwFrameFormat& rFrameFormat,
    1252             :                                   bool bInCntnr )
    1253             : {
    1254           2 :     SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
    1255             : 
    1256           2 :     const SwFormatContent& rFlyContent = rFrameFormat.GetContent();
    1257           2 :     sal_uLong nStt = rFlyContent.GetContentIdx()->GetIndex()+1;
    1258           2 :     SwOLENode *pOLENd = rHTMLWrt.pDoc->GetNodes()[ nStt ]->GetOLENode();
    1259             : 
    1260             :     OSL_ENSURE( pOLENd, "OLE-Node erwartet" );
    1261           2 :     if( !pOLENd )
    1262           0 :         return rWrt;
    1263             : 
    1264           2 :     if (rHTMLWrt.mbSkipImages)
    1265             :     {
    1266             :         // If we skip images, embedded objects would be completely lost.
    1267             :         // Instead, try to use the HTML export of the embedded object.
    1268           2 :         uno::Reference<text::XTextContent> xTextContent = SwXTextEmbeddedObject::CreateXTextEmbeddedObject(*rHTMLWrt.pDoc, const_cast<SwFrameFormat*>(&rFrameFormat));
    1269           4 :         uno::Reference<document::XEmbeddedObjectSupplier2> xEmbeddedObjectSupplier(xTextContent, uno::UNO_QUERY);
    1270           4 :         uno::Reference<frame::XStorable> xStorable(xEmbeddedObjectSupplier->getEmbeddedObject(), uno::UNO_QUERY);
    1271             :         SAL_WARN_IF(!xStorable.is(), "sw.html", "OutHTML_FrameFormatOLENodeGrf: no embedded object");
    1272             : 
    1273             :         // Figure out what is the filter name of the embedded object.
    1274           4 :         uno::Reference<lang::XServiceInfo> xServiceInfo(xStorable, uno::UNO_QUERY);
    1275           4 :         OUString aFilter;
    1276           2 :         if (xServiceInfo.is())
    1277             :         {
    1278           2 :             if (xServiceInfo->supportsService("com.sun.star.sheet.SpreadsheetDocument"))
    1279           1 :                 aFilter = "HTML (StarCalc)";
    1280           1 :             else if (xServiceInfo->supportsService("com.sun.star.text.TextDocument"))
    1281           1 :                 aFilter = "HTML (StarWriter)";
    1282             :         }
    1283             : 
    1284           2 :         if (xStorable.is() && !aFilter.isEmpty())
    1285             :         {
    1286             :             try
    1287             :             {
    1288             :                 // FIXME: exception for the simplest test document, too
    1289           2 :                 SvMemoryStream aStream;
    1290           4 :                 uno::Reference<io::XOutputStream> xOutputStream(new utl::OStreamWrapper(aStream));
    1291           4 :                 utl::MediaDescriptor aMediaDescriptor;
    1292           2 :                 aMediaDescriptor["FilterName"] <<= aFilter;
    1293           2 :                 aMediaDescriptor["FilterOptions"] <<= OUString("SkipHeaderFooter");
    1294           2 :                 aMediaDescriptor["OutputStream"] <<= xOutputStream;
    1295           2 :                 xStorable->storeToURL("private:stream", aMediaDescriptor.getAsConstPropertyValueList());
    1296           4 :                 OString aData(static_cast<const char*>(aStream.GetData()), aStream.GetSize());
    1297             :                 // Wrap output in a <span> tag to avoid 'HTML parser error: Unexpected end tag: p'
    1298           2 :                 HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), OOO_STRING_SVTOOLS_HTML_span);
    1299           2 :                 rWrt.Strm().WriteCharPtr(aData.getStr());
    1300           4 :                 HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), OOO_STRING_SVTOOLS_HTML_span, false);
    1301             :             }
    1302           0 :             catch ( uno::Exception& )
    1303             :             {
    1304             :             }
    1305             :         }
    1306             : 
    1307           4 :         return rWrt;
    1308             :     }
    1309             : 
    1310           0 :     Graphic aGraphic( *pOLENd->GetGraphic() );
    1311             :     sal_uLong nFlags = bInCntnr ? HTML_FRMOPTS_GENIMG_CNTNR
    1312           0 :         : HTML_FRMOPTS_GENIMG;
    1313             :     OutHTML_Image( rWrt, rFrameFormat, aGraphic,
    1314           0 :             pOLENd->GetTitle(), pOLENd->GetTwipSize(),
    1315           0 :             nFlags, "ole" );
    1316             : 
    1317           0 :     return rWrt;
    1318         177 : }
    1319             : 
    1320             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11