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

Generated by: LCOV version 1.10