LCOV - code coverage report
Current view: top level - sw/source/filter/html - htmlform.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 404 1253 32.2 %
Date: 2015-06-13 12:38:46 Functions: 20 54 37.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 <hintids.hxx>
      21             : #include <comphelper/string.hxx>
      22             : #include <vcl/svapp.hxx>
      23             : #include <vcl/wrkwin.hxx>
      24             : 
      25             : #include <toolkit/helper/vclunohelper.hxx>
      26             : #include <svtools/htmlkywd.hxx>
      27             : #include <svtools/htmltokn.h>
      28             : #include <svl/urihelper.hxx>
      29             : #include <sfx2/request.hxx>
      30             : #include <sfx2/docfile.hxx>
      31             : #include <sfx2/viewfrm.hxx>
      32             : #include <editeng/lrspitem.hxx>
      33             : #include <editeng/ulspitem.hxx>
      34             : #include <editeng/brushitem.hxx>
      35             : #include <editeng/colritem.hxx>
      36             : #include <editeng/fontitem.hxx>
      37             : #include <editeng/fhgtitem.hxx>
      38             : #include <editeng/wghtitem.hxx>
      39             : #include <editeng/postitem.hxx>
      40             : #include <editeng/udlnitem.hxx>
      41             : #include <editeng/crossedoutitem.hxx>
      42             : #include <svx/svdouno.hxx>
      43             : #include <svx/fmglob.hxx>
      44             : #include <cppuhelper/implbase.hxx>
      45             : #include <com/sun/star/form/ListSourceType.hpp>
      46             : #include <com/sun/star/form/FormButtonType.hpp>
      47             : #include <com/sun/star/form/FormSubmitEncoding.hpp>
      48             : #include <com/sun/star/form/FormSubmitMethod.hpp>
      49             : #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
      50             : #include <com/sun/star/script/XEventAttacherManager.hpp>
      51             : #include <com/sun/star/text/WrapTextMode.hpp>
      52             : #include <com/sun/star/text/HoriOrientation.hpp>
      53             : #include <com/sun/star/text/VertOrientation.hpp>
      54             : #include <com/sun/star/text/TextContentAnchorType.hpp>
      55             : #include <com/sun/star/container/XIndexContainer.hpp>
      56             : #include <com/sun/star/drawing/XControlShape.hpp>
      57             : #include <com/sun/star/awt/XTextLayoutConstrains.hpp>
      58             : #include <com/sun/star/awt/XLayoutConstrains.hpp>
      59             : #include <com/sun/star/awt/XImageConsumer.hpp>
      60             : #include <com/sun/star/awt/ImageStatus.hpp>
      61             : #include <com/sun/star/form/XImageProducerSupplier.hpp>
      62             : #include <com/sun/star/form/XForm.hpp>
      63             : #include <doc.hxx>
      64             : #include <IDocumentLayoutAccess.hxx>
      65             : #include <pam.hxx>
      66             : #include <swtable.hxx>
      67             : #include <fmtanchr.hxx>
      68             : #include <htmltbl.hxx>
      69             : #include <docsh.hxx>
      70             : #include <viewsh.hxx>
      71             : #include <unodraw.hxx>
      72             : #include <unotextrange.hxx>
      73             : #include "dcontact.hxx"
      74             : 
      75             : #include "swcss1.hxx"
      76             : #include "swhtml.hxx"
      77             : #include "htmlform.hxx"
      78             : 
      79             : using namespace ::com::sun::star;
      80             : using namespace ::com::sun::star::uno;
      81             : using namespace ::com::sun::star::lang;
      82             : using namespace ::com::sun::star::form;
      83             : 
      84             : const sal_uInt16 TABINDEX_MIN = 0;
      85             : const sal_uInt16 TABINDEX_MAX = 32767;
      86             : 
      87             : static HTMLOptionEnum aHTMLFormMethodTable[] =
      88             : {
      89             :     { OOO_STRING_SVTOOLS_HTML_METHOD_get,       FormSubmitMethod_GET    },
      90             :     { OOO_STRING_SVTOOLS_HTML_METHOD_post,  FormSubmitMethod_POST   },
      91             :     { 0,                    0                       }
      92             : };
      93             : 
      94             : static HTMLOptionEnum aHTMLFormEncTypeTable[] =
      95             : {
      96             :     { OOO_STRING_SVTOOLS_HTML_ET_url,           FormSubmitEncoding_URL          },
      97             :     { OOO_STRING_SVTOOLS_HTML_ET_multipart, FormSubmitEncoding_MULTIPART    },
      98             :     { OOO_STRING_SVTOOLS_HTML_ET_text,      FormSubmitEncoding_TEXT         },
      99             :     { 0,                    0                               }
     100             : };
     101             : 
     102             : enum HTMLWordWrapMode { HTML_WM_OFF, HTML_WM_HARD, HTML_WM_SOFT };
     103             : 
     104             : static HTMLOptionEnum aHTMLTextAreaWrapTable[] =
     105             : {
     106             :     { OOO_STRING_SVTOOLS_HTML_WW_off,       HTML_WM_OFF },
     107             :     { OOO_STRING_SVTOOLS_HTML_WW_hard,  HTML_WM_HARD    },
     108             :     { OOO_STRING_SVTOOLS_HTML_WW_soft,  HTML_WM_SOFT    },
     109             :     { OOO_STRING_SVTOOLS_HTML_WW_physical,HTML_WM_HARD  },
     110             :     { OOO_STRING_SVTOOLS_HTML_WW_virtual,   HTML_WM_SOFT    },
     111             :     { 0,                0               }
     112             : };
     113             : 
     114             : HTMLEventType aEventTypeTable[] =
     115             : {
     116             :     HTML_ET_ONSUBMITFORM,
     117             :     HTML_ET_ONRESETFORM,
     118             :     HTML_ET_ONGETFOCUS,
     119             :     HTML_ET_ONLOSEFOCUS,
     120             :     HTML_ET_ONCLICK,
     121             :     HTML_ET_ONCLICK_ITEM,
     122             :     HTML_ET_ONCHANGE,
     123             :     HTML_ET_ONSELECT,
     124             :     HTML_ET_END
     125             : };
     126             : 
     127             : const sal_Char * aEventListenerTable[] =
     128             : {
     129             :     "XSubmitListener",
     130             :     "XResetListener",
     131             :     "XFocusListener",
     132             :     "XFocusListener",
     133             :     "XApproveActionListener",
     134             :     "XItemListener",
     135             :     "XChangeListener",
     136             :     ""
     137             : };
     138             : 
     139             : const sal_Char * aEventMethodTable[] =
     140             : {
     141             :     "approveSubmit",
     142             :     "approveReset",
     143             :     "focusGained",
     144             :     "focusLost",
     145             :     "approveAction",
     146             :     "itemStateChanged",
     147             :     "changed",
     148             :     ""
     149             : };
     150             : 
     151             : const sal_Char * aEventSDOptionTable[] =
     152             : {
     153             :     OOO_STRING_SVTOOLS_HTML_O_SDonsubmit,
     154             :     OOO_STRING_SVTOOLS_HTML_O_SDonreset,
     155             :     OOO_STRING_SVTOOLS_HTML_O_SDonfocus,
     156             :     OOO_STRING_SVTOOLS_HTML_O_SDonblur,
     157             :     OOO_STRING_SVTOOLS_HTML_O_SDonclick,
     158             :     OOO_STRING_SVTOOLS_HTML_O_SDonclick,
     159             :     OOO_STRING_SVTOOLS_HTML_O_SDonchange,
     160             :     0
     161             : };
     162             : 
     163             : const sal_Char * aEventOptionTable[] =
     164             : {
     165             :     OOO_STRING_SVTOOLS_HTML_O_onsubmit,
     166             :     OOO_STRING_SVTOOLS_HTML_O_onreset,
     167             :     OOO_STRING_SVTOOLS_HTML_O_onfocus,
     168             :     OOO_STRING_SVTOOLS_HTML_O_onblur,
     169             :     OOO_STRING_SVTOOLS_HTML_O_onclick,
     170             :     OOO_STRING_SVTOOLS_HTML_O_onclick,
     171             :     OOO_STRING_SVTOOLS_HTML_O_onchange,
     172             :     0
     173             : };
     174             : 
     175           1 : class SwHTMLForm_Impl
     176             : {
     177             :     SwDocShell                  *pDocSh;
     178             : 
     179             :     SvKeyValueIterator          *pHeaderAttrs;
     180             : 
     181             :     // gecachte Interfaces
     182             :     uno::Reference< drawing::XDrawPage >            xDrawPage;
     183             :     uno::Reference< container::XIndexContainer >    xForms;
     184             :     uno::Reference< drawing::XShapes >              xShapes;
     185             :     uno::Reference< XMultiServiceFactory >          xServiceFactory;
     186             : 
     187             :     uno::Reference< script::XEventAttacherManager >     xControlEventManager;
     188             :     uno::Reference< script::XEventAttacherManager >     xFormEventManager;
     189             : 
     190             :     // Kontext-Informationen
     191             :     uno::Reference< container::XIndexContainer >    xFormComps;
     192             :     uno::Reference< beans::XPropertySet >           xFCompPropSet;
     193             :     uno::Reference< drawing::XShape >               xShape;
     194             : 
     195             :     OUString                    sText;
     196             :     std::vector<OUString>         aStringList;
     197             :     std::vector<OUString>         aValueList;
     198             :     std::vector<sal_uInt16>     aSelectedList;
     199             : 
     200             : public:
     201           1 :     explicit SwHTMLForm_Impl( SwDocShell *pDSh ) :
     202             :         pDocSh( pDSh ),
     203           1 :         pHeaderAttrs( pDSh ? pDSh->GetHeaderAttributes() : 0 )
     204             :     {
     205             :         OSL_ENSURE( pDocSh, "Keine DocShell, keine Controls" );
     206           1 :     }
     207             : 
     208             :     const uno::Reference< XMultiServiceFactory >& GetServiceFactory();
     209             :     const uno::Reference< drawing::XDrawPage >& GetDrawPage();
     210             :     const uno::Reference< drawing::XShapes >& GetShapes();
     211             :     const uno::Reference< script::XEventAttacherManager >& GetControlEventManager();
     212             :     const uno::Reference< script::XEventAttacherManager >& GetFormEventManager();
     213             :     const uno::Reference< container::XIndexContainer >& GetForms();
     214             : 
     215          11 :     const uno::Reference< container::XIndexContainer >& GetFormComps() const
     216             :     {
     217          11 :         return xFormComps;
     218             :     }
     219             : 
     220           2 :     void SetFormComps( const uno::Reference< container::XIndexContainer >& r )
     221             :     {
     222           2 :         xFormComps = r;
     223           2 :     }
     224             : 
     225           2 :     void ReleaseFormComps() { xFormComps = 0; xControlEventManager = 0; }
     226             : 
     227           0 :     const uno::Reference< beans::XPropertySet >& GetFCompPropSet() const
     228             :     {
     229           0 :         return xFCompPropSet;
     230             :     }
     231             : 
     232           0 :     void SetFCompPropSet( const uno::Reference< beans::XPropertySet >& r )
     233             :     {
     234           0 :         xFCompPropSet = r;
     235           0 :     }
     236             : 
     237           0 :     void ReleaseFCompPropSet() { xFCompPropSet = 0; }
     238             : 
     239           0 :     const uno::Reference< drawing::XShape >& GetShape() const { return xShape; }
     240           0 :     void SetShape( const uno::Reference< drawing::XShape >& r ) { xShape = r; }
     241             : 
     242           0 :     OUString& GetText() { return sText; }
     243           0 :     void EraseText() { sText = aEmptyOUStr; }
     244             : 
     245           0 :     std::vector<OUString>& GetStringList() { return aStringList; }
     246           0 :     void EraseStringList()
     247             :     {
     248           0 :         aStringList.clear();
     249           0 :     }
     250             : 
     251           0 :     std::vector<OUString>& GetValueList() { return aValueList; }
     252           0 :     void EraseValueList()
     253             :     {
     254           0 :         aValueList.clear();
     255           0 :     }
     256             : 
     257           0 :     std::vector<sal_uInt16>& GetSelectedList() { return aSelectedList; }
     258           0 :     void EraseSelectedList()
     259             :     {
     260           0 :         aSelectedList.clear();
     261           0 :     }
     262             : 
     263           6 :     SvKeyValueIterator *GetHeaderAttrs() const { return pHeaderAttrs; }
     264             : };
     265             : 
     266           8 : const uno::Reference< XMultiServiceFactory >& SwHTMLForm_Impl::GetServiceFactory()
     267             : {
     268           8 :     if( !xServiceFactory.is() && pDocSh )
     269             :     {
     270           2 :         xServiceFactory =
     271             :             uno::Reference< XMultiServiceFactory >( pDocSh->GetBaseModel(),
     272           1 :                                                UNO_QUERY );
     273             :         OSL_ENSURE( xServiceFactory.is(),
     274             :                 "XServiceFactory nicht vom Model erhalten" );
     275             :     }
     276           8 :     return xServiceFactory;
     277             : }
     278             : 
     279           2 : const uno::Reference< drawing::XDrawPage >& SwHTMLForm_Impl::GetDrawPage()
     280             : {
     281           2 :     if( !xDrawPage.is() && pDocSh )
     282             :     {
     283             :         uno::Reference< drawing::XDrawPageSupplier > xTextDoc( pDocSh->GetBaseModel(),
     284           1 :                                                          UNO_QUERY );
     285             :         OSL_ENSURE( xTextDoc.is(),
     286             :                 "drawing::XDrawPageSupplier nicht vom XModel erhalten" );
     287           1 :         xDrawPage = xTextDoc->getDrawPage();
     288           1 :         OSL_ENSURE( xDrawPage.is(), "drawing::XDrawPage nicht erhalten" );
     289             :     }
     290           2 :     return xDrawPage;
     291             : }
     292             : 
     293           2 : const uno::Reference< container::XIndexContainer >& SwHTMLForm_Impl::GetForms()
     294             : {
     295           2 :     if( !xForms.is() )
     296             :     {
     297           1 :         GetDrawPage();
     298           1 :         if( xDrawPage.is() )
     299             :         {
     300           1 :             uno::Reference< XFormsSupplier > xFormsSupplier( xDrawPage, UNO_QUERY );
     301             :             OSL_ENSURE( xFormsSupplier.is(),
     302             :                     "XFormsSupplier nicht vom drawing::XDrawPage erhalten" );
     303             : 
     304             :             uno::Reference< container::XNameContainer > xNameCont =
     305           2 :                 xFormsSupplier->getForms();
     306           2 :             xForms = uno::Reference< container::XIndexContainer >( xNameCont,
     307           1 :                                                               UNO_QUERY );
     308             : 
     309           1 :             OSL_ENSURE( xForms.is(), "XForms nicht erhalten" );
     310             :         }
     311             :     }
     312           2 :     return xForms;
     313             : }
     314             : 
     315           2 : const uno::Reference< drawing::XShapes > & SwHTMLForm_Impl::GetShapes()
     316             : {
     317           2 :     if( !xShapes.is() )
     318             :     {
     319           1 :         GetDrawPage();
     320           1 :         if( xDrawPage.is() )
     321             :         {
     322           1 :             xShapes = uno::Reference< drawing::XShapes >( xDrawPage, UNO_QUERY );
     323             :             OSL_ENSURE( xShapes.is(),
     324             :                     "XShapes nicht vom drawing::XDrawPage erhalten" );
     325             :         }
     326             :     }
     327           2 :     return xShapes;
     328             : }
     329             : 
     330             : const uno::Reference< script::XEventAttacherManager >&
     331           0 :                                     SwHTMLForm_Impl::GetControlEventManager()
     332             : {
     333           0 :     if( !xControlEventManager.is() && xFormComps.is() )
     334             :     {
     335           0 :         xControlEventManager =
     336           0 :             uno::Reference< script::XEventAttacherManager >( xFormComps, UNO_QUERY );
     337             :         OSL_ENSURE( xControlEventManager.is(),
     338             :     "uno::Reference< XEventAttacherManager > nicht von xFormComps erhalten" );
     339             :     }
     340             : 
     341           0 :     return xControlEventManager;
     342             : }
     343             : 
     344             : const uno::Reference< script::XEventAttacherManager >&
     345           0 :     SwHTMLForm_Impl::GetFormEventManager()
     346             : {
     347           0 :     if( !xFormEventManager.is() )
     348             :     {
     349           0 :         GetForms();
     350           0 :         if( xForms.is() )
     351             :         {
     352           0 :             xFormEventManager =
     353           0 :                 uno::Reference< script::XEventAttacherManager >( xForms, UNO_QUERY );
     354             :             OSL_ENSURE( xFormEventManager.is(),
     355             :         "uno::Reference< XEventAttacherManager > nicht von xForms erhalten" );
     356             :         }
     357             :     }
     358             : 
     359           0 :     return xFormEventManager;
     360             : }
     361             : 
     362             : class SwHTMLImageWatcher :
     363             :     public cppu::WeakImplHelper< awt::XImageConsumer, XEventListener >
     364             : {
     365             :     uno::Reference< drawing::XShape >       xShape;     // das control
     366             :     uno::Reference< XImageProducerSupplier >    xSrc;
     367             :     uno::Reference< awt::XImageConsumer >   xThis;      // man selbst
     368             :     bool                            bSetWidth;
     369             :     bool                            bSetHeight;
     370             : 
     371             :     void clear();
     372             : 
     373             : public:
     374             :     SwHTMLImageWatcher( const uno::Reference< drawing::XShape > & rShape,
     375             :                         bool bWidth, bool bHeight );
     376             :     virtual ~SwHTMLImageWatcher();
     377             : 
     378             :     // startProduction darf nicht im Konstruktor gerufen werden, weil
     379             :     // wir und ggf. selbst zerstoeren ... Deshlab eine eigene Methode.
     380           0 :     void start() { xSrc->getImageProducer()->startProduction(); }
     381             : 
     382             :     // UNO Anbindung
     383             : 
     384             :     // XImageConsumer
     385             :     virtual void SAL_CALL init( sal_Int32 Width, sal_Int32 Height)
     386             :         throw( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     387             :     virtual void SAL_CALL setColorModel(
     388             :             sal_Int16 BitCount, const uno::Sequence< sal_Int32 >& RGBAPal,
     389             :             sal_Int32 RedMask, sal_Int32 GreenMask, sal_Int32 BlueMask,
     390             :             sal_Int32 AlphaMask)
     391             :         throw( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     392             :     virtual void SAL_CALL setPixelsByBytes(
     393             :             sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height,
     394             :             const uno::Sequence< sal_Int8 >& ProducerData,
     395             :             sal_Int32 Offset, sal_Int32 Scansize)
     396             :         throw( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     397             :     virtual void SAL_CALL setPixelsByLongs(
     398             :             sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height,
     399             :             const uno::Sequence< sal_Int32 >& ProducerData,
     400             :             sal_Int32 Offset, sal_Int32 Scansize)
     401             :         throw( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     402             :     virtual void SAL_CALL complete(
     403             :             sal_Int32 Status,
     404             :             const uno::Reference< awt::XImageProducer > & Producer)
     405             :         throw( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     406             : 
     407             :     // XEventListener
     408             :     virtual void SAL_CALL disposing( const EventObject& Source ) throw ( uno::RuntimeException, std::exception) SAL_OVERRIDE;
     409             : };
     410             : 
     411           0 : SwHTMLImageWatcher::SwHTMLImageWatcher(
     412             :         const uno::Reference< drawing::XShape >& rShape,
     413             :         bool bWidth, bool bHeight ) :
     414             :     xShape( rShape ),
     415           0 :     bSetWidth( bWidth ), bSetHeight( bHeight )
     416             : {
     417             :     // Die Quelle des Images merken
     418           0 :     uno::Reference< drawing::XControlShape > xControlShape( xShape, UNO_QUERY );
     419             :     uno::Reference< awt::XControlModel > xControlModel(
     420           0 :             xControlShape->getControl() );
     421           0 :     xSrc = uno::Reference< XImageProducerSupplier >( xControlModel, UNO_QUERY );
     422             :     OSL_ENSURE( xSrc.is(), "Kein XImageProducerSupplier" );
     423             : 
     424             :     // Als Event-Listener am Shape anmelden, damit wir es beim dispose
     425             :     // loslassen ko"onnen ...
     426           0 :     uno::Reference< XEventListener > xEvtLstnr = static_cast<XEventListener *>(this);
     427           0 :     uno::Reference< XComponent > xComp( xShape, UNO_QUERY );
     428           0 :     xComp->addEventListener( xEvtLstnr );
     429             : 
     430             :     // Zum Schluss halten wir noch eine Referenz auf uns selbst, damit
     431             :     // wir am Leben bleiben ... (eigentlich sollte das nicht neotig sein,
     432             :     // weil wir ja noch an diversen anderen Stellen angemeldet sind)
     433           0 :     xThis = static_cast<awt::XImageConsumer *>(this);
     434             : 
     435             :     // und am ImageProducer anmelden, um die Groesse zu erehalten ...
     436           0 :     xSrc->getImageProducer()->addConsumer( xThis );
     437           0 : }
     438             : 
     439           0 : SwHTMLImageWatcher::~SwHTMLImageWatcher()
     440             : {
     441           0 : }
     442             : 
     443           0 : void SwHTMLImageWatcher::clear()
     444             : {
     445             :     // Am Shape als Event-Listener abmelden
     446           0 :     uno::Reference< XEventListener > xEvtLstnr = static_cast<XEventListener *>(this);
     447           0 :     uno::Reference< XComponent > xComp( xShape, UNO_QUERY );
     448           0 :     xComp->removeEventListener( xEvtLstnr );
     449             : 
     450             :     // Am ImageProducer abmelden
     451           0 :     uno::Reference<awt::XImageProducer> xProd = xSrc->getImageProducer();
     452           0 :     if( xProd.is() )
     453           0 :         xProd->removeConsumer( xThis );
     454           0 : }
     455             : 
     456           0 : void SwHTMLImageWatcher::init( sal_Int32 Width, sal_Int32 Height )
     457             :     throw( uno::RuntimeException, std::exception )
     458             : {
     459             :     OSL_ENSURE( bSetWidth || bSetHeight,
     460             :             "Breite oder Hoehe muss angepasst werden" );
     461             : 
     462             :     // Wenn keine Breite oder Hoehe angegeben ist, ist das das init von
     463             :     // der leeren Grafik, die angezeigt wird, bevor der Stream einer
     464             :     // asynchron anzuzeigenden Grfik verfuegbar ist.
     465           0 :     if( !Width && !Height )
     466           0 :         return;
     467             : 
     468           0 :     awt::Size aNewSz;
     469           0 :     aNewSz.Width = Width;
     470           0 :     aNewSz.Height = Height;
     471           0 :     if( Application::GetDefaultDevice() )
     472             :     {
     473           0 :         Size aTmp(aNewSz.Width, aNewSz.Height);
     474             :         aTmp = Application::GetDefaultDevice()
     475           0 :                     ->PixelToLogic( aTmp, MapMode( MAP_100TH_MM ) );
     476           0 :         aNewSz.Width = aTmp.Width();
     477           0 :         aNewSz.Height = aTmp.Height();
     478             :     }
     479             : 
     480           0 :     if( !bSetWidth || !bSetHeight )
     481             :     {
     482           0 :         awt::Size aSz( xShape->getSize() );
     483           0 :         if( bSetWidth && aNewSz.Height )
     484             :         {
     485           0 :             aNewSz.Width *= aSz.Height;
     486           0 :             aNewSz.Width /= aNewSz.Height;
     487           0 :             aNewSz.Height = aSz.Height;
     488             :         }
     489           0 :         if( bSetHeight && aNewSz.Width )
     490             :         {
     491           0 :             aNewSz.Height *= aSz.Width;
     492           0 :             aNewSz.Height /= aNewSz.Width;
     493           0 :             aNewSz.Width = aSz.Width;
     494             :         }
     495             :     }
     496           0 :     if( aNewSz.Width < MINFLY )
     497           0 :         aNewSz.Width = MINFLY;
     498           0 :     if( aNewSz.Height < MINFLY )
     499           0 :         aNewSz.Height = MINFLY;
     500             : 
     501           0 :     xShape->setSize( aNewSz );
     502           0 :     if( bSetWidth )
     503             :     {
     504             :         // Wenn das Control in einer Tabelle verankert ist, muesen
     505             :         // die Tabellen-Spalten neu berechnet werden
     506             : 
     507             :         // Um an den SwXShape* zu gelangen, brauchen wir ein Interface,
     508             :         // das auch vom SwXShape implementiert wird.
     509             : 
     510           0 :         uno::Reference< beans::XPropertySet > xPropSet( xShape, UNO_QUERY );
     511           0 :         uno::Reference< XUnoTunnel> xTunnel( xPropSet, UNO_QUERY );
     512           0 :                 SwXShape *pSwShape = xTunnel.is() ?
     513             :                     reinterpret_cast< SwXShape * >( sal::static_int_cast< sal_IntPtr>(
     514           0 :                     xTunnel->getSomething(SwXShape::getUnoTunnelId()) ))
     515           0 :                 : 0;
     516             : 
     517             :         OSL_ENSURE( pSwShape, "Wo ist das SW-Shape?" );
     518           0 :         if( pSwShape )
     519             :         {
     520           0 :             SwFrameFormat *pFrameFormat = pSwShape->GetFrameFormat();
     521             : 
     522           0 :             const SwDoc *pDoc = pFrameFormat->GetDoc();
     523           0 :             const SwPosition* pAPos = pFrameFormat->GetAnchor().GetContentAnchor();
     524             :             SwNode *pANd;
     525             :             SwTableNode *pTableNd;
     526           0 :             if( pAPos &&
     527           0 :                 0 != (pANd = & pAPos->nNode.GetNode()) &&
     528             :                 0 != (pTableNd = pANd->FindTableNode()) )
     529             :             {
     530           0 :                 const bool bLastGrf = !pTableNd->GetTable().DecGrfsThatResize();
     531             :                 SwHTMLTableLayout *pLayout =
     532           0 :                     pTableNd->GetTable().GetHTMLTableLayout();
     533           0 :                 if( pLayout )
     534             :                 {
     535             :                     const sal_uInt16 nBrowseWidth =
     536           0 :                         pLayout->GetBrowseWidthByTable( *pDoc );
     537             : 
     538           0 :                     if ( nBrowseWidth )
     539             :                     {
     540             :                         pLayout->Resize( nBrowseWidth, true, true,
     541             :                                          bLastGrf ? HTMLTABLE_RESIZE_NOW
     542           0 :                                                   : 500 );
     543             :                     }
     544             :                 }
     545             :             }
     546           0 :         }
     547             :     }
     548             : 
     549             :     // uns selbst abmelden und loeschen
     550           0 :     clear();
     551           0 :     uno::Reference< awt::XImageConsumer >  xTmp = static_cast<awt::XImageConsumer*>(this);
     552           0 :     xThis = 0;
     553             : }
     554             : 
     555           0 : void SwHTMLImageWatcher::setColorModel(
     556             :         sal_Int16, const Sequence< sal_Int32 >&, sal_Int32, sal_Int32,
     557             :         sal_Int32, sal_Int32 )
     558             :     throw( uno::RuntimeException, std::exception )
     559             : {
     560           0 : }
     561             : 
     562           0 : void SwHTMLImageWatcher::setPixelsByBytes(
     563             :         sal_Int32, sal_Int32, sal_Int32, sal_Int32,
     564             :         const Sequence< sal_Int8 >&, sal_Int32, sal_Int32 )
     565             :     throw( uno::RuntimeException, std::exception )
     566             : {
     567           0 : }
     568             : 
     569           0 : void SwHTMLImageWatcher::setPixelsByLongs(
     570             :         sal_Int32, sal_Int32, sal_Int32, sal_Int32,
     571             :         const Sequence< sal_Int32 >&, sal_Int32, sal_Int32 )
     572             :     throw( uno::RuntimeException, std::exception )
     573             : {
     574           0 : }
     575             : 
     576           0 : void SwHTMLImageWatcher::complete( sal_Int32 Status,
     577             :         const uno::Reference< awt::XImageProducer >& )
     578             :     throw( uno::RuntimeException, std::exception )
     579             : {
     580           0 :     if( awt::ImageStatus::IMAGESTATUS_ERROR == Status || awt::ImageStatus::IMAGESTATUS_ABORTED == Status )
     581             :     {
     582             :         // uns selbst abmelden und loeschen
     583           0 :         clear();
     584           0 :         uno::Reference< awt::XImageConsumer > xTmp = static_cast<awt::XImageConsumer*>(this);
     585           0 :         xThis = 0;
     586             :     }
     587           0 : }
     588             : 
     589           0 : void SwHTMLImageWatcher::disposing(const lang::EventObject& evt) throw ( uno::RuntimeException, std::exception)
     590             : {
     591           0 :     uno::Reference< awt::XImageConsumer > xTmp;
     592             : 
     593             :     // Wenn das Shape verschwindet soll muessen wir es loslassen
     594           0 :     uno::Reference< drawing::XShape > xTmpShape;
     595           0 :     if( evt.Source == xShape )
     596             :     {
     597           0 :         clear();
     598           0 :         xTmp = static_cast<awt::XImageConsumer*>(this);
     599           0 :         xThis = 0;
     600           0 :     }
     601           0 : }
     602             : 
     603          16 : void SwHTMLParser::DeleteFormImpl()
     604             : {
     605          16 :     delete pFormImpl;
     606          16 :     pFormImpl = 0;
     607          16 : }
     608             : 
     609           1 : static void lcl_html_setFixedFontProperty(
     610             :         const uno::Reference< beans::XPropertySet >& rPropSet )
     611             : {
     612             :     vcl::Font aFixedFont( OutputDevice::GetDefaultFont(
     613             :                                     DefaultFontType::FIXED, LANGUAGE_ENGLISH_US,
     614           1 :                                     GetDefaultFontFlags::OnlyOne )  );
     615           2 :     Any aTmp;
     616           1 :     aTmp <<= OUString( aFixedFont.GetName() );
     617           1 :     rPropSet->setPropertyValue("FontName", aTmp );
     618             : 
     619           1 :     aTmp <<= OUString( aFixedFont.GetStyleName() );
     620           1 :     rPropSet->setPropertyValue("FontStyleName",
     621           1 :                                 aTmp );
     622             : 
     623           1 :     aTmp <<= (sal_Int16) aFixedFont.GetFamily();
     624           1 :     rPropSet->setPropertyValue("FontFamily", aTmp );
     625             : 
     626           1 :     aTmp <<= (sal_Int16) aFixedFont.GetCharSet();
     627           1 :     rPropSet->setPropertyValue("FontCharset",
     628           1 :                                 aTmp );
     629             : 
     630           1 :     aTmp <<= (sal_Int16) aFixedFont.GetPitch();
     631           1 :     rPropSet->setPropertyValue("FontPitch", aTmp );
     632             : 
     633           1 :     float fVal(10.);
     634           1 :     aTmp.setValue( &fVal, cppu::UnoType<decltype(fVal)>::get());
     635           2 :     rPropSet->setPropertyValue("FontHeight", aTmp );
     636           1 : }
     637             : 
     638           2 : void SwHTMLParser::SetControlSize( const uno::Reference< drawing::XShape >& rShape,
     639             :                                    const Size& rTextSz,
     640             :                                    bool bMinWidth,
     641             :                                    bool bMinHeight )
     642             : {
     643           2 :     if( !rTextSz.Width() && !rTextSz.Height() && !bMinWidth  && !bMinHeight )
     644           2 :         return;
     645             : 
     646             :     // Um an den SwXShape* zu gelangen, brauchen wir ein Interface,
     647             :     // das auch vom SwXShape implementiert wird.
     648           2 :     uno::Reference< beans::XPropertySet > xPropSet( rShape, UNO_QUERY );
     649             : 
     650           2 :     SwViewShell *pVSh = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell();
     651           2 :     if( !pVSh && !nEventId )
     652             :     {
     653             :         // If there is no view shell by now and the doc shell is an internal
     654             :         // one, no view shell will be created. That for, we have to do that of
     655             :         // our own. This happens if a linked section is inserted or refreshed.
     656           1 :         SwDocShell *pDocSh = pDoc->GetDocShell();
     657           1 :         if( pDocSh )
     658             :         {
     659           1 :             if ( pDocSh->GetMedium() )
     660             :             {
     661             :                 // if there is no hidden property in the MediaDescriptor it should be removed after loading
     662           1 :                 SFX_ITEMSET_ARG( pDocSh->GetMedium()->GetItemSet(), pHiddenItem, SfxBoolItem, SID_HIDDEN, false );
     663           1 :                 bRemoveHidden = ( pHiddenItem == NULL || !pHiddenItem->GetValue() );
     664             :             }
     665             : 
     666           1 :             pTempViewFrame = SfxViewFrame::LoadHiddenDocument( *pDocSh, 0 );
     667           1 :             CallStartAction();
     668           1 :             pVSh = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell();
     669             :         }
     670             :     }
     671             : 
     672           4 :     uno::Reference< XUnoTunnel> xTunnel( xPropSet, UNO_QUERY );
     673           2 :     SwXShape *pSwShape = xTunnel.is() ?
     674             :         reinterpret_cast< SwXShape *>( sal::static_int_cast< sal_IntPtr >(
     675           2 :             xTunnel->getSomething(SwXShape::getUnoTunnelId()) ))
     676           4 :         : 0;
     677             : 
     678             :     OSL_ENSURE( pSwShape, "Wo ist das SW-Shape?" );
     679             : 
     680             :     // es muss ein Draw-Format sein
     681           2 :     SwFrameFormat *pFrameFormat = pSwShape ? pSwShape->GetFrameFormat() : NULL ;
     682             :     OSL_ENSURE( pFrameFormat && RES_DRAWFRMFMT == pFrameFormat->Which(), "Kein DrawFrameFormat" );
     683             : 
     684             :     // Schauen, ob es ein SdrObject dafuer gibt
     685           2 :     const SdrObject *pObj = pFrameFormat ? pFrameFormat->FindSdrObject() : NULL;
     686             :     OSL_ENSURE( pObj, "SdrObject nicht gefunden" );
     687             :     OSL_ENSURE( pObj && FmFormInventor == pObj->GetObjInventor(), "falscher Inventor" );
     688             : 
     689           2 :     const SdrView* pDrawView = pVSh ? pVSh->GetDrawView() : 0;
     690             : 
     691           2 :     const SdrUnoObj *pFormObj = PTR_CAST( SdrUnoObj, pObj );
     692           4 :     uno::Reference< awt::XControl > xControl;
     693           2 :     if ( pDrawView && pVSh->GetWin() && pFormObj )
     694           2 :         xControl = pFormObj->GetUnoControl( *pDrawView, *pVSh->GetWin() );
     695             : 
     696           2 :     awt::Size aSz( rShape->getSize() );
     697           2 :     awt::Size aNewSz( 0, 0 );
     698             : 
     699             :     // #i71248# ensure we got a XControl before apllying corrections
     700           2 :     if(xControl.is())
     701             :     {
     702           2 :         if( bMinWidth || bMinHeight )
     703             :         {
     704           2 :             uno::Reference< awt::XLayoutConstrains > xLC( xControl, UNO_QUERY );
     705           2 :             awt::Size aTmpSz( xLC->getPreferredSize() );
     706           2 :             if( bMinWidth )
     707           1 :                 aNewSz.Width = aTmpSz.Width;
     708           2 :             if( bMinHeight )
     709           2 :                 aNewSz.Height = aTmpSz.Height;
     710             :         }
     711           2 :         if( rTextSz.Width() || rTextSz.Height())
     712             :         {
     713           1 :             uno::Reference< awt::XTextLayoutConstrains > xLC( xControl, UNO_QUERY );
     714             :             OSL_ENSURE( xLC.is(), "kein XTextLayoutConstrains" );
     715           1 :             if( xLC.is() )
     716             :             {
     717           1 :                 awt::Size aTmpSz( rTextSz.Width(), rTextSz.Height() );
     718           1 :                 if( -1 == rTextSz.Width() )
     719             :                 {
     720           0 :                     aTmpSz.Width = 0;
     721           0 :                     aTmpSz.Height = nSelectEntryCnt;
     722             :                 }
     723           1 :                 aTmpSz = xLC->getMinimumSize( static_cast< sal_Int16 >(aTmpSz.Width), static_cast< sal_Int16 >(aTmpSz.Height) );
     724           1 :                 if( rTextSz.Width() )
     725           1 :                     aNewSz.Width = aTmpSz.Width;
     726           1 :                 if( rTextSz.Height() )
     727           0 :                     aNewSz.Height = aTmpSz.Height;
     728           1 :             }
     729             :         }
     730             :     }
     731             : 
     732           2 :     if( Application::GetDefaultDevice() )
     733             :     {
     734           2 :         Size aTmpSz( aNewSz.Width, aNewSz.Height );
     735             :         aTmpSz = Application::GetDefaultDevice()
     736           2 :                         ->PixelToLogic( aTmpSz, MapMode( MAP_100TH_MM ) );
     737           2 :         aNewSz.Width  = aTmpSz.Width();
     738           2 :         aNewSz.Height = aTmpSz.Height();
     739             :     }
     740           2 :     if( aNewSz.Width )
     741             :     {
     742           2 :         if( aNewSz.Width < MINLAY )
     743           0 :             aNewSz.Width = MINLAY;
     744           2 :         aSz.Width = aNewSz.Width;
     745             :     }
     746           2 :     if( aNewSz.Height )
     747             :     {
     748           2 :         if( aNewSz.Height < MINLAY )
     749           0 :             aNewSz.Height = MINLAY;
     750           2 :         aSz.Height = aNewSz.Height;
     751             :     }
     752             : 
     753           4 :     rShape->setSize( aSz );
     754             : }
     755             : 
     756           0 : static void lcl_html_setEvents(
     757             :         const uno::Reference< script::XEventAttacherManager > & rEvtMn,
     758             :         sal_uInt32 nPos, const SvxMacroTableDtor& rMacroTable,
     759             :         const std::vector<OUString>& rUnoMacroTable,
     760             :         const std::vector<OUString>& rUnoMacroParamTable,
     761             :         const OUString& rType )
     762             : {
     763             :     // Erstmal muss die Anzahl der Events ermittelt werden ...
     764           0 :     sal_Int32 nEvents = 0;
     765             : 
     766           0 :     for( int i = 0; HTML_ET_END != aEventTypeTable[i]; ++i )
     767             :     {
     768           0 :         const SvxMacro *pMacro = rMacroTable.Get( aEventTypeTable[i] );
     769             :         // Solange nicht alle Events implementiert sind, enthaelt die
     770             :         // Tabelle auch Leerstrings!
     771           0 :         if( pMacro && aEventListenerTable[i] )
     772           0 :             nEvents++;
     773             :     }
     774           0 :     for( const auto &rStr : rUnoMacroTable )
     775             :     {
     776           0 :         sal_Int32 nIndex = 0;
     777           0 :         if( rStr.getToken( 0, '-', nIndex ).isEmpty() || -1 == nIndex )
     778           0 :             continue;
     779           0 :         if( rStr.getToken( 0, '-', nIndex ).isEmpty() || -1 == nIndex )
     780           0 :             continue;
     781           0 :         if( nIndex < rStr.getLength() )
     782           0 :             nEvents++;
     783             :     }
     784             : 
     785           0 :     if( 0==nEvents )
     786           0 :         return;
     787             : 
     788           0 :     Sequence<script::ScriptEventDescriptor> aDescs( nEvents );
     789           0 :     script::ScriptEventDescriptor* pDescs = aDescs.getArray();
     790           0 :     sal_Int32 nEvent = 0;
     791             : 
     792           0 :     for( int i=0; HTML_ET_END != aEventTypeTable[i]; ++i )
     793             :     {
     794           0 :         const SvxMacro *pMacro = rMacroTable.Get( aEventTypeTable[i] );
     795           0 :         if( pMacro && aEventListenerTable[i] )
     796             :         {
     797           0 :             script::ScriptEventDescriptor& rDesc = pDescs[nEvent++];
     798           0 :             rDesc.ListenerType =
     799           0 :                     OUString::createFromAscii(aEventListenerTable[i]);
     800           0 :             rDesc.EventMethod = OUString::createFromAscii(aEventMethodTable[i]);
     801           0 :             rDesc.ScriptType = pMacro->GetLanguage();
     802           0 :             rDesc.ScriptCode = pMacro->GetMacName();
     803             :         }
     804             :     }
     805             : 
     806           0 :     for( const auto &rStr : rUnoMacroTable )
     807             :     {
     808           0 :         sal_Int32 nIndex = 0;
     809           0 :         OUString sListener( rStr.getToken( 0, '-', nIndex ) );
     810           0 :         if( sListener.isEmpty() || -1 == nIndex )
     811           0 :             continue;
     812             : 
     813           0 :         OUString sMethod( rStr.getToken( 0, '-', nIndex ) );
     814           0 :         if( sMethod.isEmpty() || -1 == nIndex )
     815           0 :             continue;
     816             : 
     817           0 :         OUString sCode( rStr.copy( nIndex ) );
     818           0 :         if( sCode.isEmpty() )
     819           0 :             continue;
     820             : 
     821           0 :         script::ScriptEventDescriptor& rDesc = pDescs[nEvent++];
     822           0 :         rDesc.ListenerType = sListener;
     823           0 :         rDesc.EventMethod = sMethod;
     824           0 :         rDesc.ScriptType = rType;
     825           0 :         rDesc.ScriptCode = sCode;
     826           0 :         rDesc.AddListenerParam.clear();
     827             : 
     828           0 :         if(!rUnoMacroParamTable.empty())
     829             :         {
     830           0 :             OUString sSearch( sListener );
     831           0 :             sSearch += "-" +sMethod + "-";
     832           0 :             sal_Int32 nLen = sSearch.getLength();
     833           0 :             for(size_t j = 0; j < rUnoMacroParamTable.size(); ++j)
     834             :             {
     835           0 :                 const OUString& rParam = rUnoMacroParamTable[j];
     836           0 :                 if( rParam.startsWith( sSearch ) && rParam.getLength() > nLen )
     837             :                 {
     838           0 :                     rDesc.AddListenerParam = rParam.copy(nLen);
     839           0 :                     break;
     840             :                 }
     841           0 :             }
     842             :         }
     843           0 :     }
     844           0 :     rEvtMn->registerScriptEvents( nPos, aDescs );
     845             : }
     846             : 
     847           5 : static void lcl_html_getEvents( const OUString& rOption, const OUString& rValue,
     848             :                                 std::vector<OUString>& rUnoMacroTable,
     849             :                                 std::vector<OUString>& rUnoMacroParamTable )
     850             : {
     851           5 :     if( rOption.startsWithIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_sdevent ) )
     852             :     {
     853           0 :         OUString aEvent( rOption.copy( strlen( OOO_STRING_SVTOOLS_HTML_O_sdevent ) ) );
     854           0 :         aEvent += "-" + rValue;
     855           0 :         rUnoMacroTable.push_back(aEvent);
     856             :     }
     857           5 :     else if( rOption.startsWithIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_sdaddparam ) )
     858             :     {
     859           0 :         OUString aParam( rOption.copy( strlen( OOO_STRING_SVTOOLS_HTML_O_sdaddparam ) ) );
     860           0 :         aParam += "-" + rValue;
     861           0 :         rUnoMacroParamTable.push_back(aParam);
     862             :     }
     863           5 : }
     864             : 
     865           4 : uno::Reference< drawing::XShape > SwHTMLParser::InsertControl(
     866             :         const uno::Reference< XFormComponent > & rFComp,
     867             :         const uno::Reference< beans::XPropertySet > & rFCompPropSet,
     868             :         const Size& rSize, sal_Int16 eVertOri, sal_Int16 eHoriOri,
     869             :         SfxItemSet& rCSS1ItemSet, SvxCSS1PropertyInfo& rCSS1PropInfo,
     870             :         const SvxMacroTableDtor& rMacroTable, const std::vector<OUString>& rUnoMacroTable,
     871             :         const std::vector<OUString>& rUnoMacroParamTable, bool bSetFCompPropSet,
     872             :         bool bHidden )
     873             : {
     874           4 :     uno::Reference< drawing::XShape >  xShape;
     875             : 
     876             :     const uno::Reference< container::XIndexContainer > & rFormComps =
     877           4 :         pFormImpl->GetFormComps();
     878           8 :     Any aAny( &rFComp, cppu::UnoType<XFormComponent>::get());
     879           4 :     rFormComps->insertByIndex( rFormComps->getCount(), aAny );
     880             : 
     881           4 :     if( !bHidden )
     882             :     {
     883           2 :         Any aTmp;
     884           2 :         sal_Int32 nLeftSpace = 0;
     885           2 :         sal_Int32 nRightSpace = 0;
     886           2 :         sal_Int32 nUpperSpace = 0;
     887           2 :         sal_Int32 nLowerSpace = 0;
     888             : 
     889             :         const uno::Reference< XMultiServiceFactory > & rServiceFactory =
     890           2 :             pFormImpl->GetServiceFactory();
     891           2 :         if( !rServiceFactory.is() )
     892           0 :             return xShape;
     893             : 
     894             :         uno::Reference< XInterface > xCreate =
     895           2 :             rServiceFactory ->createInstance(
     896           4 :         OUString("com.sun.star.drawing.ControlShape"));
     897           2 :         if( !xCreate.is() )
     898           0 :             return xShape;
     899             : 
     900           2 :         xShape = uno::Reference< drawing::XShape >( xCreate, UNO_QUERY );
     901             : 
     902             :         OSL_ENSURE( xShape.is(), "XShape nicht erhalten" );
     903           2 :         awt::Size aTmpSz;
     904           2 :         aTmpSz.Width  = rSize.Width();
     905           2 :         aTmpSz.Height = rSize.Height();
     906           2 :         xShape->setSize( aTmpSz );
     907             : 
     908           4 :         uno::Reference< beans::XPropertySet > xShapePropSet( xCreate, UNO_QUERY );
     909             : 
     910             :         // linken/rechten Rand setzen
     911             :         const SfxPoolItem *pItem;
     912           2 :         if( SfxItemState::SET==rCSS1ItemSet.GetItemState( RES_LR_SPACE, true,
     913           2 :                                                      &pItem ) )
     914             :         {
     915             :             // Ggf. den Erstzeilen-Einzug noch plaetten
     916           0 :             const SvxLRSpaceItem *pLRItem = static_cast<const SvxLRSpaceItem *>(pItem);
     917           0 :             SvxLRSpaceItem aLRItem( *pLRItem );
     918           0 :             aLRItem.SetTextFirstLineOfst( 0 );
     919           0 :             if( rCSS1PropInfo.bLeftMargin )
     920             :             {
     921           0 :                 nLeftSpace = convertTwipToMm100( aLRItem.GetLeft() );
     922           0 :                 rCSS1PropInfo.bLeftMargin = false;
     923             :             }
     924           0 :             if( rCSS1PropInfo.bRightMargin )
     925             :             {
     926           0 :                 nRightSpace = convertTwipToMm100( aLRItem.GetRight() );
     927           0 :                 rCSS1PropInfo.bRightMargin = false;
     928             :             }
     929           0 :             rCSS1ItemSet.ClearItem( RES_LR_SPACE );
     930             :         }
     931           2 :         if( nLeftSpace || nRightSpace )
     932             :         {
     933           0 :             Any aAny2;
     934           0 :             aAny2 <<= nLeftSpace;
     935           0 :             xShapePropSet->setPropertyValue("LeftMargin", aAny2 );
     936             : 
     937           0 :             aAny2 <<= nRightSpace;
     938           0 :             xShapePropSet->setPropertyValue("RightMargin", aAny2 );
     939             :         }
     940             : 
     941             :         // oberen/unteren Rand setzen
     942           2 :         if( SfxItemState::SET==rCSS1ItemSet.GetItemState( RES_UL_SPACE, true,
     943           2 :                                                      &pItem ) )
     944             :         {
     945             :             // Ggf. den Erstzeilen-Einzug noch plaetten
     946           0 :             const SvxULSpaceItem *pULItem = static_cast<const SvxULSpaceItem *>(pItem);
     947           0 :             if( rCSS1PropInfo.bTopMargin )
     948             :             {
     949           0 :                 nUpperSpace = convertTwipToMm100( pULItem->GetUpper() );
     950           0 :                 rCSS1PropInfo.bTopMargin = false;
     951             :             }
     952           0 :             if( rCSS1PropInfo.bBottomMargin )
     953             :             {
     954           0 :                 nLowerSpace = convertTwipToMm100( pULItem->GetLower() );
     955           0 :                 rCSS1PropInfo.bBottomMargin = false;
     956             :             }
     957             : 
     958           0 :             rCSS1ItemSet.ClearItem( RES_UL_SPACE );
     959             :         }
     960           2 :         if( nUpperSpace || nLowerSpace )
     961             :         {
     962           0 :             uno::Any aAny2;
     963           0 :             aAny2 <<= nUpperSpace;
     964           0 :             xShapePropSet->setPropertyValue("TopMargin", aAny2 );
     965             : 
     966           0 :             aAny2 <<= nLowerSpace;
     967           0 :             xShapePropSet->setPropertyValue("BottomMargin", aAny2 );
     968             :         }
     969             : 
     970             :         uno::Reference< beans::XPropertySetInfo > xPropSetInfo =
     971           4 :             rFCompPropSet->getPropertySetInfo();
     972           4 :         OUString sPropName = "BackgroundColor";
     973           2 :         if( SfxItemState::SET==rCSS1ItemSet.GetItemState( RES_BACKGROUND, true,
     974           2 :                                                      &pItem ) &&
     975           0 :             xPropSetInfo->hasPropertyByName( sPropName ) )
     976             :         {
     977           0 :             const Color &rColor = static_cast<const SvxBrushItem *>(pItem)->GetColor();
     978             :             /// copy color, if color is not "no fill"/"auto fill"
     979           0 :             if( rColor.GetColor() != COL_TRANSPARENT )
     980             :             {
     981             :                 /// copy complete color with transparency
     982           0 :                 aTmp <<= static_cast<sal_Int32>(rColor.GetColor());
     983           0 :                 rFCompPropSet->setPropertyValue( sPropName, aTmp );
     984             :             }
     985             : 
     986             :         }
     987             : 
     988           2 :         sPropName = "TextColor";
     989           2 :         if( SfxItemState::SET==rCSS1ItemSet.GetItemState( RES_CHRATR_COLOR, true,
     990           2 :                                                      &pItem ) &&
     991           0 :             xPropSetInfo->hasPropertyByName( sPropName ) )
     992             :         {
     993           0 :             aTmp <<= (sal_Int32)static_cast<const SvxColorItem *>(pItem)->GetValue()
     994           0 :                                                          .GetRGBColor();
     995           0 :             rFCompPropSet->setPropertyValue( sPropName, aTmp );
     996             :         }
     997             : 
     998           2 :         sPropName = "FontHeight";
     999           2 :         if( SfxItemState::SET==rCSS1ItemSet.GetItemState( RES_CHRATR_FONTSIZE,
    1000           2 :                                                      true, &pItem ) &&
    1001           0 :             xPropSetInfo->hasPropertyByName( sPropName ) )
    1002             :         {
    1003             :             float fVal = static_cast< float >(
    1004           0 :                 (static_cast<const SvxFontHeightItem *>(pItem)->GetHeight()) / 20.0 );
    1005           0 :             aTmp.setValue( &fVal, cppu::UnoType<decltype(fVal)>::get());
    1006           0 :             rFCompPropSet->setPropertyValue( sPropName, aTmp );
    1007             :         }
    1008             : 
    1009           2 :         if( SfxItemState::SET==rCSS1ItemSet.GetItemState( RES_CHRATR_FONT, true,
    1010           2 :                                                      &pItem ) )
    1011             :         {
    1012           0 :             const SvxFontItem *pFontItem = static_cast<const SvxFontItem *>(pItem);
    1013           0 :             sPropName = "FontName";
    1014           0 :             if( xPropSetInfo->hasPropertyByName( sPropName ) )
    1015             :             {
    1016           0 :                 aTmp <<= OUString( pFontItem->GetFamilyName() );
    1017           0 :                 rFCompPropSet->setPropertyValue( sPropName, aTmp );
    1018             :             }
    1019           0 :             sPropName = "FontStyleName";
    1020           0 :             if( xPropSetInfo->hasPropertyByName( sPropName ) )
    1021             :             {
    1022           0 :                 aTmp <<= OUString( pFontItem->GetStyleName() );
    1023           0 :                 rFCompPropSet->setPropertyValue( sPropName, aTmp );
    1024             :             }
    1025           0 :             sPropName = "FontFamily";
    1026           0 :             if( xPropSetInfo->hasPropertyByName( sPropName ) )
    1027             :             {
    1028           0 :                 aTmp <<= (sal_Int16)pFontItem->GetFamily() ;
    1029           0 :                 rFCompPropSet->setPropertyValue( sPropName, aTmp );
    1030             :             }
    1031           0 :             sPropName = "FontCharset";
    1032           0 :             if( xPropSetInfo->hasPropertyByName( sPropName ) )
    1033             :             {
    1034           0 :                 aTmp <<= (sal_Int16)pFontItem->GetCharSet() ;
    1035           0 :                 rFCompPropSet->setPropertyValue( sPropName, aTmp );
    1036             :             }
    1037           0 :             sPropName = "FontPitch";
    1038           0 :             if( xPropSetInfo->hasPropertyByName( sPropName ) )
    1039             :             {
    1040           0 :                 aTmp <<= (sal_Int16)pFontItem->GetPitch() ;
    1041           0 :                 rFCompPropSet->setPropertyValue( sPropName, aTmp );
    1042             :             }
    1043             :         }
    1044             : 
    1045           2 :         sPropName = "FontWeight";
    1046           2 :         if( SfxItemState::SET==rCSS1ItemSet.GetItemState( RES_CHRATR_WEIGHT,
    1047           2 :                                                      true, &pItem ) &&
    1048           0 :             xPropSetInfo->hasPropertyByName( sPropName ) )
    1049             :         {
    1050             :             float fVal = VCLUnoHelper::ConvertFontWeight(
    1051           0 :                     static_cast<const SvxWeightItem *>(pItem)->GetWeight() );
    1052           0 :             aTmp.setValue( &fVal, cppu::UnoType<decltype(fVal)>::get());
    1053           0 :             rFCompPropSet->setPropertyValue( sPropName, aTmp );
    1054             :         }
    1055             : 
    1056           2 :         sPropName = "FontSlant";
    1057           2 :         if( SfxItemState::SET==rCSS1ItemSet.GetItemState( RES_CHRATR_POSTURE,
    1058           2 :                                                      true, &pItem ) &&
    1059           0 :             xPropSetInfo->hasPropertyByName( sPropName ) )
    1060             :         {
    1061           0 :             aTmp <<= (sal_Int16)static_cast<const SvxPostureItem *>(pItem)->GetPosture();
    1062           0 :             rFCompPropSet->setPropertyValue( sPropName, aTmp );
    1063             :         }
    1064             : 
    1065           2 :         sPropName = "FontUnderline";
    1066           2 :         if( SfxItemState::SET==rCSS1ItemSet.GetItemState( RES_CHRATR_UNDERLINE,
    1067           2 :                                                      true, &pItem ) &&
    1068           0 :             xPropSetInfo->hasPropertyByName( sPropName ) )
    1069             :         {
    1070           0 :             aTmp <<= (sal_Int16)static_cast<const SvxUnderlineItem *>(pItem)->GetLineStyle();
    1071           0 :             rFCompPropSet->setPropertyValue( sPropName, aTmp );
    1072             :         }
    1073             : 
    1074           2 :         sPropName = "FontStrikeout";
    1075           2 :         if( SfxItemState::SET==rCSS1ItemSet.GetItemState( RES_CHRATR_CROSSEDOUT,
    1076           2 :                                                      true, &pItem ) &&
    1077           0 :             xPropSetInfo->hasPropertyByName( sPropName ) )
    1078             :         {
    1079           0 :             aTmp <<= (sal_Int16)static_cast<const SvxCrossedOutItem *>(pItem)->GetStrikeout();
    1080           0 :             rFCompPropSet->setPropertyValue( sPropName, aTmp );
    1081             :         }
    1082             : 
    1083           4 :         uno::Reference< text::XTextRange >  xTextRg;
    1084           2 :         sal_Int16 nAnchorType = text::TextContentAnchorType_AS_CHARACTER;
    1085           2 :         bool bSetPos = false, bSetSurround = false;
    1086           2 :         sal_Int32 nXPos = 0, nYPos = 0;
    1087           2 :         sal_Int16 nSurround = text::WrapTextMode_NONE;
    1088           2 :         if( SVX_CSS1_POS_ABSOLUTE == rCSS1PropInfo.ePosition &&
    1089           0 :             SVX_CSS1_LTYPE_TWIP == rCSS1PropInfo.eLeftType &&
    1090           0 :             SVX_CSS1_LTYPE_TWIP == rCSS1PropInfo.eTopType )
    1091             :         {
    1092             :             const SwStartNode *pFlySttNd =
    1093           0 :                 pPam->GetPoint()->nNode.GetNode().FindFlyStartNode();
    1094             : 
    1095           0 :             if( pFlySttNd )
    1096             :             {
    1097           0 :                 nAnchorType = text::TextContentAnchorType_AT_FRAME;
    1098           0 :                 SwPaM aPaM( *pFlySttNd );
    1099             : 
    1100           0 :                 uno::Reference< text::XText >  xDummyTextRef; // unsauber, aber laut OS geht das ...
    1101           0 :                 xTextRg = new SwXTextRange( aPaM, xDummyTextRef );
    1102             :             }
    1103             :             else
    1104             :             {
    1105           0 :                 nAnchorType = text::TextContentAnchorType_AT_PAGE;
    1106             :             }
    1107           0 :             nXPos = convertTwipToMm100( rCSS1PropInfo.nLeft ) + nLeftSpace;
    1108           0 :             nYPos = convertTwipToMm100( rCSS1PropInfo.nTop ) + nUpperSpace;
    1109           0 :             bSetPos = true;
    1110             : 
    1111           0 :             nSurround = text::WrapTextMode_THROUGHT;
    1112           0 :             bSetSurround = true;
    1113             :         }
    1114           2 :         else if( SVX_ADJUST_LEFT == rCSS1PropInfo.eFloat ||
    1115             :                  text::HoriOrientation::LEFT == eHoriOri )
    1116             :         {
    1117           0 :             nAnchorType = text::TextContentAnchorType_AT_PARAGRAPH;
    1118           0 :             nXPos = nLeftSpace;
    1119           0 :             nYPos = nUpperSpace;
    1120           0 :             bSetPos = true;
    1121           0 :             nSurround = text::WrapTextMode_RIGHT;
    1122           0 :             bSetSurround = true;
    1123             :         }
    1124           2 :         else if( text::VertOrientation::NONE != eVertOri )
    1125             :         {
    1126           2 :             sal_Int16 nVertOri = text::VertOrientation::NONE;
    1127           2 :             switch( eVertOri )
    1128             :             {
    1129             :             case text::VertOrientation::TOP:
    1130           2 :                 nVertOri = text::VertOrientation::TOP;
    1131           2 :                 break;
    1132             :             case text::VertOrientation::CENTER:
    1133           0 :                 nVertOri = text::VertOrientation::CENTER;
    1134           0 :                 break;
    1135             :             case text::VertOrientation::BOTTOM:
    1136           0 :                 nVertOri = text::VertOrientation::BOTTOM;
    1137           0 :                 break;
    1138             :             case text::VertOrientation::CHAR_TOP:
    1139           0 :                 nVertOri = text::VertOrientation::CHAR_TOP;
    1140           0 :                 break;
    1141             :             case text::VertOrientation::CHAR_CENTER:
    1142           0 :                 nVertOri = text::VertOrientation::CHAR_CENTER;
    1143           0 :                 break;
    1144             :             case text::VertOrientation::CHAR_BOTTOM:
    1145           0 :                 nVertOri = text::VertOrientation::CHAR_BOTTOM;
    1146           0 :                 break;
    1147             :             case text::VertOrientation::LINE_TOP:
    1148           0 :                 nVertOri = text::VertOrientation::LINE_TOP;
    1149           0 :                 break;
    1150             :             case text::VertOrientation::LINE_CENTER:
    1151           0 :                 nVertOri = text::VertOrientation::LINE_CENTER;
    1152           0 :                 break;
    1153             :             case text::VertOrientation::LINE_BOTTOM:
    1154           0 :                 nVertOri = text::VertOrientation::LINE_BOTTOM;
    1155           0 :                 break;
    1156             :             // coverity[dead_error_begin] - following conditions exist to avoid compiler warning
    1157             :             case text::VertOrientation::NONE:
    1158           0 :                 nVertOri = text::VertOrientation::NONE;
    1159           0 :                 break;
    1160             :             }
    1161           2 :             aTmp <<= (sal_Int16)nVertOri ;
    1162           2 :             xShapePropSet->setPropertyValue("VertOrient", aTmp );
    1163             :         }
    1164             : 
    1165           2 :         aTmp <<= (sal_Int16)nAnchorType ;
    1166           2 :         xShapePropSet->setPropertyValue("AnchorType", aTmp );
    1167             : 
    1168           2 :         if( text::TextContentAnchorType_AT_PAGE == nAnchorType )
    1169             :         {
    1170           0 :             aTmp <<= (sal_Int16) 1 ;
    1171           0 :             xShapePropSet->setPropertyValue("AnchorPageNo", aTmp );
    1172             :         }
    1173             :         else
    1174             :         {
    1175           2 :             if( !xTextRg.is() )
    1176             :             {
    1177           2 :                 uno::Reference< text::XText >  xDummyTextRef; // unsauber, aber laut OS geht das ...
    1178           2 :                 xTextRg = new SwXTextRange( *pPam, xDummyTextRef );
    1179             :             }
    1180             : 
    1181             :             aTmp.setValue( &xTextRg,
    1182           2 :                            cppu::UnoType<text::XTextRange>::get());
    1183           2 :             xShapePropSet->setPropertyValue("TextRange", aTmp );
    1184             :         }
    1185             : 
    1186           2 :         if( bSetPos )
    1187             :         {
    1188           0 :             aTmp <<= (sal_Int16)text::HoriOrientation::NONE;
    1189           0 :             xShapePropSet->setPropertyValue("HoriOrient", aTmp );
    1190           0 :             aTmp <<= (sal_Int32)nXPos ;
    1191           0 :             xShapePropSet->setPropertyValue("HoriOrientPosition", aTmp );
    1192             : 
    1193           0 :             aTmp <<= (sal_Int16)text::VertOrientation::NONE;
    1194           0 :             xShapePropSet->setPropertyValue("VertOrient", aTmp );
    1195           0 :             aTmp <<= (sal_Int32)nYPos ;
    1196           0 :             xShapePropSet->setPropertyValue("VertOrientPosition", aTmp );
    1197             :         }
    1198           2 :         if( bSetSurround )
    1199             :         {
    1200           0 :             aTmp <<= (sal_Int16)nSurround ;
    1201           0 :             xShapePropSet->setPropertyValue("Surround", aTmp );
    1202             :         }
    1203             : 
    1204           2 :         pFormImpl->GetShapes()->add(xShape);
    1205             : 
    1206             :         // Das Control-Model am Control-Shape setzen
    1207           2 :         uno::Reference< drawing::XControlShape > xControlShape( xShape, UNO_QUERY );
    1208           4 :         uno::Reference< awt::XControlModel >  xControlModel( rFComp, UNO_QUERY );
    1209           6 :         xControlShape->setControl( xControlModel );
    1210             :     }
    1211             : 
    1212             :     // Da beim Einfuegen der Controls der Fokus gesetzt wird, werden
    1213             :     // auch schon Fokus-Events verschickt. Damit die nicht evtl. schon
    1214             :     // vorhendene JavaSCript-Eents rufen, werden die Events nachtraeglich
    1215             :     // gesetzt.
    1216           4 :     if( !rMacroTable.empty() || !rUnoMacroTable.empty() )
    1217             :     {
    1218           0 :         lcl_html_setEvents( pFormImpl->GetControlEventManager(),
    1219           0 :                             rFormComps->getCount() - 1,
    1220             :                             rMacroTable, rUnoMacroTable, rUnoMacroParamTable,
    1221           0 :                             GetScriptTypeString(pFormImpl->GetHeaderAttrs()) );
    1222             :     }
    1223             : 
    1224           4 :     if( bSetFCompPropSet )
    1225             :     {
    1226           0 :         pFormImpl->SetFCompPropSet( rFCompPropSet );
    1227             :     }
    1228             : 
    1229           4 :     return xShape;
    1230             : }
    1231             : 
    1232           2 : void SwHTMLParser::NewForm( bool bAppend )
    1233             : {
    1234             :     // Gibt es schon eine Form?
    1235           2 :     if( pFormImpl && pFormImpl->GetFormComps().is() )
    1236           0 :         return;
    1237             : 
    1238           2 :     if( bAppend )
    1239             :     {
    1240           2 :         if( pPam->GetPoint()->nContent.GetIndex() )
    1241           0 :             AppendTextNode( AM_SPACE );
    1242             :         else
    1243           2 :             AddParSpace();
    1244             :     }
    1245             : 
    1246           2 :     if( !pFormImpl )
    1247           1 :         pFormImpl = new SwHTMLForm_Impl( pDoc->GetDocShell() );
    1248             : 
    1249           2 :     OUString aAction( sBaseURL );
    1250           4 :     OUString sName, sTarget;
    1251           2 :     sal_uInt16 nEncType = FormSubmitEncoding_URL;
    1252           2 :     sal_uInt16 nMethod = FormSubmitMethod_GET;
    1253           4 :     SvxMacroTableDtor aMacroTable;
    1254           4 :     std::vector<OUString> aUnoMacroTable;
    1255           4 :     std::vector<OUString> aUnoMacroParamTable;
    1256           2 :     SvKeyValueIterator *pHeaderAttrs = pFormImpl->GetHeaderAttrs();
    1257           2 :     ScriptType eDfltScriptType = GetScriptType( pHeaderAttrs );
    1258           2 :     const OUString& rDfltScriptType = GetScriptTypeString( pHeaderAttrs );
    1259             : 
    1260           2 :     const HTMLOptions& rHTMLOptions = GetOptions();
    1261          10 :     for (size_t i = rHTMLOptions.size(); i; )
    1262             :     {
    1263           6 :         const HTMLOption& rOption = rHTMLOptions[--i];
    1264           6 :         ScriptType eScriptType2 = eDfltScriptType;
    1265           6 :         sal_uInt16 nEvent = 0;
    1266           6 :         bool bSetEvent = false;
    1267             : 
    1268           6 :         switch( rOption.GetToken() )
    1269             :         {
    1270             :         case HTML_O_ACTION:
    1271           0 :             aAction = rOption.GetString();
    1272           0 :             break;
    1273             :         case HTML_O_METHOD:
    1274           2 :             nMethod = rOption.GetEnum( aHTMLFormMethodTable, nMethod );
    1275           2 :             break;
    1276             :         case HTML_O_ENCTYPE:
    1277           0 :             nEncType = rOption.GetEnum( aHTMLFormEncTypeTable, nEncType );
    1278           0 :             break;
    1279             :         case HTML_O_TARGET:
    1280           0 :             sTarget = rOption.GetString();
    1281           0 :             break;
    1282             :         case HTML_O_NAME:
    1283           0 :             sName = rOption.GetString();
    1284           0 :             break;
    1285             : 
    1286             :         case HTML_O_SDONSUBMIT:
    1287           0 :             eScriptType2 = STARBASIC;
    1288             :             //fallthrough
    1289             :         case HTML_O_ONSUBMIT:
    1290           0 :             nEvent = HTML_ET_ONSUBMITFORM;
    1291           0 :             bSetEvent = true;
    1292           0 :             break;
    1293             : 
    1294             :         case HTML_O_SDONRESET:
    1295           0 :             eScriptType2 = STARBASIC;
    1296             :             //fallthrough
    1297             :         case HTML_O_ONRESET:
    1298           0 :             nEvent = HTML_ET_ONRESETFORM;
    1299           0 :             bSetEvent = true;
    1300           0 :             break;
    1301             : 
    1302             :         default:
    1303           4 :             lcl_html_getEvents( rOption.GetTokenString(),
    1304           4 :                                 rOption.GetString(),
    1305           4 :                                 aUnoMacroTable, aUnoMacroParamTable );
    1306           4 :             break;
    1307             :         }
    1308             : 
    1309           6 :         if( bSetEvent )
    1310             :         {
    1311           0 :             OUString sEvent( rOption.GetString() );
    1312           0 :             if( !sEvent.isEmpty() )
    1313             :             {
    1314           0 :                 sEvent = convertLineEnd(sEvent, GetSystemLineEnd());
    1315           0 :                 OUString aScriptType2;
    1316           0 :                 if( EXTENDED_STYPE==eScriptType2 )
    1317           0 :                     aScriptType2 = rDfltScriptType;
    1318           0 :                 aMacroTable.Insert( nEvent, SvxMacro( sEvent, aScriptType2, eScriptType2 ) );
    1319           0 :             }
    1320             :         }
    1321             :     }
    1322             : 
    1323             :     const uno::Reference< XMultiServiceFactory > & rSrvcMgr =
    1324           2 :         pFormImpl->GetServiceFactory();
    1325           2 :     if( !rSrvcMgr.is() )
    1326           0 :         return;
    1327             : 
    1328           2 :     uno::Reference< XInterface > xInt = rSrvcMgr->createInstance(
    1329           2 :         OUString("com.sun.star.form.component.Form") );
    1330           2 :     if( !xInt.is() )
    1331           0 :         return;
    1332             : 
    1333           4 :     uno::Reference< XForm >  xForm( xInt, UNO_QUERY );
    1334             :     OSL_ENSURE( xForm.is(), "keine Form?" );
    1335             : 
    1336           4 :     uno::Reference< container::XIndexContainer > xFormComps( xForm, UNO_QUERY );
    1337           2 :     pFormImpl->SetFormComps( xFormComps );
    1338             : 
    1339           4 :     uno::Reference< beans::XPropertySet > xFormPropSet( xForm, UNO_QUERY );
    1340             : 
    1341           4 :     Any aTmp;
    1342           2 :     aTmp <<= OUString(sName);
    1343           2 :     xFormPropSet->setPropertyValue("Name", aTmp );
    1344             : 
    1345           2 :     if( !aAction.isEmpty() )
    1346             :     {
    1347           2 :         aAction = URIHelper::SmartRel2Abs(INetURLObject(sBaseURL), aAction, Link<OUString *, bool>(), false);
    1348             :     }
    1349             :     else
    1350             :     {
    1351             :         // Bei leerer URL das Directory nehmen
    1352           0 :         INetURLObject aURLObj( aPathToFile );
    1353           0 :         aAction = aURLObj.GetPartBeforeLastName();
    1354             :     }
    1355           2 :     aTmp <<= OUString(aAction);
    1356           2 :     xFormPropSet->setPropertyValue("TargetURL",
    1357           2 :                                     aTmp );
    1358             : 
    1359           2 :     FormSubmitMethod eMethod = (FormSubmitMethod)nMethod;
    1360           2 :     aTmp.setValue( &eMethod, cppu::UnoType<FormSubmitMethod>::get());
    1361           2 :     xFormPropSet->setPropertyValue("SubmitMethod",
    1362           2 :                                     aTmp );
    1363             : 
    1364           2 :      FormSubmitEncoding eEncType = (FormSubmitEncoding)nEncType;
    1365           2 :     aTmp.setValue( &eEncType, cppu::UnoType<FormSubmitEncoding>::get());
    1366           2 :     xFormPropSet->setPropertyValue("SubmitEncoding", aTmp );
    1367             : 
    1368           2 :     if( !sTarget.isEmpty() )
    1369             :     {
    1370           0 :         aTmp <<= sTarget;
    1371           0 :         xFormPropSet->setPropertyValue( "TargetFrame", aTmp );
    1372             :     }
    1373             : 
    1374             :     const uno::Reference< container::XIndexContainer > & rForms =
    1375           2 :         pFormImpl->GetForms();
    1376           4 :     Any aAny( &xForm, cppu::UnoType<XForm>::get());
    1377           2 :     rForms->insertByIndex( rForms->getCount(), aAny );
    1378           2 :     if( !aMacroTable.empty() )
    1379           0 :         lcl_html_setEvents( pFormImpl->GetFormEventManager(),
    1380           0 :                             rForms->getCount() - 1,
    1381             :                             aMacroTable, aUnoMacroTable, aUnoMacroParamTable,
    1382           4 :                             rDfltScriptType );
    1383             : }
    1384             : 
    1385           2 : void SwHTMLParser::EndForm( bool bAppend )
    1386             : {
    1387           2 :     if( pFormImpl && pFormImpl->GetFormComps().is() )
    1388             :     {
    1389           2 :         if( bAppend )
    1390             :         {
    1391           2 :             if( pPam->GetPoint()->nContent.GetIndex() )
    1392           0 :                 AppendTextNode( AM_SPACE );
    1393             :             else
    1394           2 :                 AddParSpace();
    1395             :         }
    1396             : 
    1397           2 :         pFormImpl->ReleaseFormComps();
    1398             :     }
    1399           2 : }
    1400             : 
    1401           4 : void SwHTMLParser::InsertInput()
    1402             : {
    1403             :     assert(pPendStack == 0);
    1404             : 
    1405           4 :     if( !pFormImpl || !pFormImpl->GetFormComps().is() )
    1406           0 :         return;
    1407             : 
    1408           8 :     OUString sImgSrc, aId, aClass, aStyle, sName;
    1409           8 :     OUString sText;
    1410           8 :     SvxMacroTableDtor aMacroTable;
    1411           8 :     std::vector<OUString> aUnoMacroTable;
    1412           8 :     std::vector<OUString> aUnoMacroParamTable;
    1413           4 :     sal_uInt16 nSize = 0;
    1414           4 :     sal_Int16 nMaxLen = 0;
    1415           4 :     sal_Int16 nChecked = TRISTATE_FALSE;
    1416           4 :     sal_Int32 nTabIndex = TABINDEX_MAX + 1;
    1417           4 :     HTMLInputType eType = HTML_IT_TEXT;
    1418           4 :     bool bDisabled = false, bValue = false;
    1419           4 :     bool bSetGrfWidth = false, bSetGrfHeight = false;
    1420           4 :     bool bHidden = false;
    1421           4 :     long nWidth=0, nHeight=0;
    1422           4 :     sal_Int16 eVertOri = text::VertOrientation::TOP;
    1423           4 :     sal_Int16 eHoriOri = text::HoriOrientation::NONE;
    1424           4 :     SvKeyValueIterator *pHeaderAttrs = pFormImpl->GetHeaderAttrs();
    1425           4 :     ScriptType eDfltScriptType = GetScriptType( pHeaderAttrs );
    1426           4 :     const OUString& rDfltScriptType = GetScriptTypeString( pHeaderAttrs );
    1427             : 
    1428           4 :     sal_uInt16 nKeepCRLFToken = HTML_O_VALUE;
    1429           4 :     const HTMLOptions& rHTMLOptions = GetOptions( &nKeepCRLFToken );
    1430          25 :     for (size_t i = rHTMLOptions.size(); i; )
    1431             :     {
    1432          17 :         const HTMLOption& rOption = rHTMLOptions[--i];
    1433          17 :         ScriptType eScriptType2 = eDfltScriptType;
    1434          17 :         sal_uInt16 nEvent = 0;
    1435          17 :         bool bSetEvent = false;
    1436             : 
    1437          17 :         switch( rOption.GetToken() )
    1438             :         {
    1439             :         case HTML_O_ID:
    1440           2 :             aId = rOption.GetString();
    1441           2 :             break;
    1442             :         case HTML_O_STYLE:
    1443           0 :             aStyle = rOption.GetString();
    1444           0 :             break;
    1445             :         case HTML_O_CLASS:
    1446           1 :             aClass = rOption.GetString();
    1447           1 :             break;
    1448             :         case HTML_O_TYPE:
    1449           4 :             eType = rOption.GetInputType();
    1450           4 :             break;
    1451             :         case HTML_O_NAME:
    1452           4 :             sName = rOption.GetString();
    1453           4 :             break;
    1454             :         case HTML_O_VALUE:
    1455           3 :             sText = rOption.GetString();
    1456           3 :             bValue = true;
    1457           3 :             break;
    1458             :         case HTML_O_CHECKED:
    1459           0 :             nChecked = TRISTATE_TRUE;
    1460           0 :             break;
    1461             :         case HTML_O_DISABLED:
    1462           0 :             bDisabled = true;
    1463           0 :             break;
    1464             :         case HTML_O_MAXLENGTH:
    1465           0 :             nMaxLen = (sal_Int16)rOption.GetNumber();
    1466           0 :             break;
    1467             :         case HTML_O_SIZE:
    1468           0 :             nSize = (sal_uInt16)rOption.GetNumber();
    1469           0 :             break;
    1470             :         case HTML_O_SRC:
    1471           0 :             sImgSrc = rOption.GetString();
    1472           0 :             break;
    1473             :         case HTML_O_WIDTH:
    1474             :             // erstmal nur als Pixelwerte merken!
    1475           0 :             nWidth = rOption.GetNumber();
    1476           0 :             break;
    1477             :         case HTML_O_HEIGHT:
    1478             :             // erstmal nur als Pixelwerte merken!
    1479           0 :             nHeight = rOption.GetNumber();
    1480           0 :             break;
    1481             :         case HTML_O_ALIGN:
    1482             :             eVertOri =
    1483           0 :                 rOption.GetEnum( aHTMLImgVAlignTable, eVertOri );
    1484             :             eHoriOri =
    1485           0 :                 rOption.GetEnum( aHTMLImgHAlignTable, eHoriOri );
    1486           0 :             break;
    1487             :         case HTML_O_TABINDEX:
    1488             :             // erstmal nur als Pixelwerte merken!
    1489           2 :             nTabIndex = rOption.GetNumber();
    1490           2 :             break;
    1491             : 
    1492             :         case HTML_O_SDONFOCUS:
    1493           0 :             eScriptType2 = STARBASIC;
    1494             :             //fallthrough
    1495             :         case HTML_O_ONFOCUS:
    1496           0 :             nEvent = HTML_ET_ONGETFOCUS;
    1497           0 :             bSetEvent = true;
    1498           0 :             break;
    1499             : 
    1500             :         case HTML_O_SDONBLUR:               // eigtl. nur EDIT
    1501           0 :             eScriptType2 = STARBASIC;
    1502             :             //fallthrough
    1503             :         case HTML_O_ONBLUR:
    1504           0 :             nEvent = HTML_ET_ONLOSEFOCUS;
    1505           0 :             bSetEvent = true;
    1506           0 :             break;
    1507             : 
    1508             :         case HTML_O_SDONCLICK:
    1509           0 :             eScriptType2 = STARBASIC;
    1510             :             //fallthrough
    1511             :         case HTML_O_ONCLICK:
    1512           0 :             nEvent = HTML_ET_ONCLICK;
    1513           0 :             bSetEvent = true;
    1514           0 :             break;
    1515             : 
    1516             :         case HTML_O_SDONCHANGE:             // eigtl. nur EDIT
    1517           0 :             eScriptType2 = STARBASIC;
    1518             :             //fallthrough
    1519             :         case HTML_O_ONCHANGE:
    1520           0 :             nEvent = HTML_ET_ONCHANGE;
    1521           0 :             bSetEvent = true;
    1522           0 :             break;
    1523             : 
    1524             :         case HTML_O_SDONSELECT:             // eigtl. nur EDIT
    1525           0 :             eScriptType2 = STARBASIC;
    1526             :             //fallthrough
    1527             :         case HTML_O_ONSELECT:
    1528           0 :             nEvent = HTML_ET_ONSELECT;
    1529           0 :             bSetEvent = true;
    1530           0 :             break;
    1531             : 
    1532             :         default:
    1533           1 :             lcl_html_getEvents( rOption.GetTokenString(),
    1534           1 :                                 rOption.GetString(),
    1535           1 :                                 aUnoMacroTable, aUnoMacroParamTable );
    1536           1 :             break;
    1537             :         }
    1538             : 
    1539          17 :         if( bSetEvent )
    1540             :         {
    1541           0 :             OUString sEvent( rOption.GetString() );
    1542           0 :             if( !sEvent.isEmpty() )
    1543             :             {
    1544           0 :                 sEvent = convertLineEnd(sEvent, GetSystemLineEnd());
    1545           0 :                 OUString aScriptType2;
    1546           0 :                 if( EXTENDED_STYPE==eScriptType2 )
    1547           0 :                     aScriptType2 = rDfltScriptType;
    1548           0 :                 aMacroTable.Insert( nEvent, SvxMacro( sEvent, aScriptType2, eScriptType2 ) );
    1549           0 :             }
    1550             :         }
    1551             :     }
    1552             : 
    1553           4 :     if( HTML_IT_IMAGE==eType )
    1554             :     {
    1555             :         // Image-Controls ohne Image-URL werden ignoriert (wie bei MS)
    1556           0 :         if( sImgSrc.isEmpty() )
    1557           0 :             return;
    1558             :     }
    1559             :     else
    1560             :     {
    1561             :         // ALIGN fuer alle Controls auszuwerten ist keine so gute Idee,
    1562             :         // solange Absatz-gebundene Controls die Hoehe von Tabellen-Zellen
    1563             :         // nicht beeinflussen
    1564           4 :         eVertOri = text::VertOrientation::TOP;
    1565           4 :         eHoriOri = text::HoriOrientation::NONE;
    1566             :     }
    1567             : 
    1568             :     // Defaults entsprechen HTML_IT_TEXT
    1569           4 :     const sal_Char *pType = "TextField";
    1570           4 :     bool bKeepCRLFInValue = false;
    1571           4 :     switch( eType )
    1572             :     {
    1573             :     case HTML_IT_CHECKBOX:
    1574           0 :         pType = "CheckBox";
    1575           0 :         bKeepCRLFInValue = true;
    1576           0 :         break;
    1577             : 
    1578             :     case HTML_IT_RADIO:
    1579           0 :         pType = "RadioButton";
    1580           0 :         bKeepCRLFInValue = true;
    1581           0 :         break;
    1582             : 
    1583             :     case HTML_IT_PASSWORD:
    1584           0 :         bKeepCRLFInValue = true;
    1585           0 :         break;
    1586             : 
    1587             :     case HTML_IT_BUTTON:
    1588           0 :         bKeepCRLFInValue = true;
    1589             :     case HTML_IT_SUBMIT:
    1590             :     case HTML_IT_RESET:
    1591           1 :         pType = "CommandButton";
    1592           1 :         break;
    1593             : 
    1594             :     case HTML_IT_IMAGE:
    1595           0 :         pType = "ImageButton";
    1596           0 :         break;
    1597             : 
    1598             :     case HTML_IT_FILE:
    1599           0 :         pType = "FileControl";
    1600           0 :         break;
    1601             : 
    1602             :     case HTML_IT_HIDDEN:
    1603           2 :         pType = "HiddenControl";
    1604           2 :         bKeepCRLFInValue = true;
    1605           2 :         break;
    1606             :     default:
    1607             :         ;
    1608             :     }
    1609             : 
    1610             :     // Fuer ein par Controls mussen CR/LF noch aus dem VALUE
    1611             :     // geloescht werden.
    1612           4 :     if( !bKeepCRLFInValue )
    1613             :     {
    1614           2 :         sText = comphelper::string::remove(sText, '\r');
    1615           2 :         sText = comphelper::string::remove(sText, '\n');
    1616             :     }
    1617             : 
    1618             :     const uno::Reference< XMultiServiceFactory > & rServiceFactory =
    1619           4 :         pFormImpl->GetServiceFactory();
    1620           4 :     if( !rServiceFactory.is() )
    1621           0 :         return;
    1622             : 
    1623           4 :     OUString sServiceName("com.sun.star.form.component.");
    1624           4 :     sServiceName += OUString::createFromAscii(pType);
    1625             :     uno::Reference< XInterface > xInt =
    1626           8 :         rServiceFactory->createInstance( sServiceName );
    1627           4 :     if( !xInt.is() )
    1628           0 :         return;
    1629             : 
    1630           8 :     uno::Reference< XFormComponent > xFComp( xInt, UNO_QUERY );
    1631           4 :     if( !xFComp.is() )
    1632           0 :         return;
    1633             : 
    1634           8 :     uno::Reference< beans::XPropertySet > xPropSet( xFComp, UNO_QUERY );
    1635             : 
    1636           8 :     Any aTmp;
    1637           4 :     aTmp <<= OUString(sName);
    1638           4 :     xPropSet->setPropertyValue("Name", aTmp );
    1639             : 
    1640           4 :     if( HTML_IT_HIDDEN != eType  )
    1641             :     {
    1642           2 :         if( nTabIndex >= TABINDEX_MIN && nTabIndex <= TABINDEX_MAX  )
    1643             :         {
    1644           2 :             aTmp <<= (sal_Int16) (sal_Int16)nTabIndex ;
    1645           2 :             xPropSet->setPropertyValue("TabIndex", aTmp );
    1646             :         }
    1647             : 
    1648           2 :         if( bDisabled )
    1649             :         {
    1650           0 :             xPropSet->setPropertyValue("Enabled", makeAny(false) );
    1651             :         }
    1652             :     }
    1653             : 
    1654           4 :     aTmp <<= sText;
    1655             : 
    1656           4 :     Size aSz( 0, 0 );       // defaults
    1657           4 :     Size aTextSz( 0, 0 );   // Text-Size
    1658           4 :     bool bMinWidth = false, bMinHeight = false;
    1659           4 :     bool bUseSize = false;
    1660           4 :     switch( eType )
    1661             :     {
    1662             :     case HTML_IT_CHECKBOX:
    1663             :     case HTML_IT_RADIO:
    1664             :         {
    1665           0 :             if( !bValue )
    1666           0 :                 aTmp <<= OUString( OOO_STRING_SVTOOLS_HTML_on );
    1667           0 :             xPropSet->setPropertyValue("RefValue",
    1668           0 :                                         aTmp );
    1669           0 :             aTmp <<= OUString();
    1670           0 :             xPropSet->setPropertyValue("Label",
    1671           0 :                                         aTmp );
    1672             :             // Beim RadioButton darf die DefaultChecked-Property
    1673             :             // erst gesetzt werden, wenn das Control angelegt und ein
    1674             :             // activateTabOrder gerufen wurde, weil es sonst noch zu der
    1675             :             // vorhergehenden Gruppe gehoert.
    1676           0 :             if( HTML_IT_CHECKBOX == eType )
    1677             :             {
    1678           0 :                 aTmp <<= (sal_Int16) nChecked ;
    1679           0 :                 xPropSet->setPropertyValue("DefaultState", aTmp );
    1680             :             }
    1681             : 
    1682           0 :             const SvxMacro* pMacro = aMacroTable.Get( HTML_ET_ONCLICK );
    1683           0 :             if( pMacro )
    1684             :             {
    1685           0 :                 aMacroTable.Insert( HTML_ET_ONCLICK_ITEM, *pMacro );
    1686           0 :                 aMacroTable.Erase( HTML_ET_ONCLICK );
    1687             :             }
    1688             :             // SIZE auszuwerten duerfte hier keinen Sinn machen???
    1689           0 :             bMinWidth = bMinHeight = true;
    1690             :         }
    1691           0 :         break;
    1692             : 
    1693             :     case HTML_IT_IMAGE:
    1694             :         {
    1695             :             // SIZE = WIDTH
    1696           0 :             aSz.Width() = nSize ? nSize : nWidth;
    1697           0 :             aSz.Width() = nWidth;
    1698           0 :             aSz.Height() = nHeight;
    1699           0 :             if( (aSz.Width() || aSz.Height()) && Application::GetDefaultDevice() )
    1700             :             {
    1701             :                 aSz = Application::GetDefaultDevice()
    1702           0 :                     ->PixelToLogic( aSz, MapMode( MAP_100TH_MM ) );
    1703             :             }
    1704           0 :              FormButtonType eButtonType = FormButtonType_SUBMIT;
    1705             :             aTmp.setValue( &eButtonType,
    1706           0 :                            cppu::UnoType<FormButtonType>::get());
    1707           0 :             xPropSet->setPropertyValue("ButtonType", aTmp );
    1708             : 
    1709           0 :             aTmp <<= (sal_Int16) 0  ;
    1710           0 :             xPropSet->setPropertyValue("Border",
    1711           0 :                                         aTmp );
    1712             :         }
    1713           0 :         break;
    1714             : 
    1715             :     case HTML_IT_BUTTON:
    1716             :     case HTML_IT_SUBMIT:
    1717             :     case HTML_IT_RESET:
    1718             :         {
    1719             :              FormButtonType eButtonType;
    1720           1 :             switch( eType )
    1721             :             {
    1722             :             case HTML_IT_BUTTON:
    1723           0 :                 eButtonType = FormButtonType_PUSH;
    1724           0 :                 break;
    1725             :             case HTML_IT_SUBMIT:
    1726           1 :                 eButtonType = FormButtonType_SUBMIT;
    1727           1 :                 if (sText.isEmpty())
    1728           0 :                     sText = OOO_STRING_SVTOOLS_HTML_IT_submit;
    1729           1 :                 break;
    1730             :             case HTML_IT_RESET:
    1731           0 :                 eButtonType = FormButtonType_RESET;
    1732           0 :                 if (sText.isEmpty())
    1733           0 :                     sText = OOO_STRING_SVTOOLS_HTML_IT_reset;
    1734           0 :                 break;
    1735             :             default:
    1736             :                 ;
    1737             :             }
    1738           1 :             aTmp <<= sText;
    1739           1 :             xPropSet->setPropertyValue("Label",
    1740           1 :                                         aTmp );
    1741             : 
    1742             :             aTmp.setValue( &eButtonType,
    1743           1 :                            cppu::UnoType<FormButtonType>::get());
    1744           1 :             xPropSet->setPropertyValue("ButtonType", aTmp );
    1745             : 
    1746           1 :             bMinWidth = bMinHeight = true;
    1747           1 :             bUseSize = true;
    1748             :         }
    1749           1 :         break;
    1750             : 
    1751             :     case HTML_IT_PASSWORD:
    1752             :     case HTML_IT_TEXT:
    1753             :     case HTML_IT_FILE:
    1754           1 :         if( HTML_IT_FILE != eType )
    1755             :         {
    1756             :         // Beim File-Control wird der VALUE aus Sicherheitsgruenden ignoriert.
    1757           1 :             xPropSet->setPropertyValue("DefaultText", aTmp );
    1758           1 :             if( nMaxLen != 0 )
    1759             :             {
    1760           0 :                 aTmp <<= (sal_Int16) nMaxLen ;
    1761           0 :                 xPropSet->setPropertyValue("MaxTextLen", aTmp );
    1762             :             }
    1763             :         }
    1764             : 
    1765           1 :         if( HTML_IT_PASSWORD == eType )
    1766             :         {
    1767           0 :             aTmp <<= (sal_Int16)'*' ;
    1768           0 :             xPropSet->setPropertyValue("EchoChar", aTmp );
    1769             :         }
    1770             : 
    1771           1 :         lcl_html_setFixedFontProperty( xPropSet );
    1772             : 
    1773           1 :         if( !nSize )
    1774           1 :             nSize = 20;
    1775           1 :         aTextSz.Width() = nSize;
    1776           1 :         bMinHeight = true;
    1777           1 :         break;
    1778             : 
    1779             :     case HTML_IT_HIDDEN:
    1780           2 :         xPropSet->setPropertyValue("HiddenValue", aTmp );
    1781           2 :         bHidden = true;
    1782           2 :         break;
    1783             :     default:
    1784             :         ;
    1785             :     }
    1786             : 
    1787           4 :     if( bUseSize && nSize>0 )
    1788             :     {
    1789           0 :         if( Application::GetDefaultDevice() )
    1790             :         {
    1791           0 :             Size aNewSz( nSize, 0 );
    1792             :             aNewSz = Application::GetDefaultDevice()
    1793           0 :                         ->PixelToLogic( aNewSz, MapMode( MAP_100TH_MM ) );
    1794           0 :             aSz.Width() = aNewSz.Width();
    1795             :             OSL_ENSURE( !aTextSz.Width(), "Text-Breite ist gegeben" );
    1796           0 :             bMinWidth = false;
    1797             :         }
    1798             :     }
    1799             : 
    1800           4 :     SfxItemSet aCSS1ItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
    1801           8 :     SvxCSS1PropertyInfo aCSS1PropInfo;
    1802           4 :     if( HasStyleOptions( aStyle, aId, aClass ) )
    1803             :     {
    1804           2 :         ParseStyleOptions( aStyle, aId, aClass, aCSS1ItemSet, aCSS1PropInfo );
    1805           2 :         if( !aId.isEmpty() )
    1806           2 :             InsertBookmark( aId );
    1807             :     }
    1808             : 
    1809           4 :     if( SVX_CSS1_LTYPE_TWIP== aCSS1PropInfo.eWidthType )
    1810             :     {
    1811           0 :         aSz.Width() = convertTwipToMm100( aCSS1PropInfo.nWidth );
    1812           0 :         aTextSz.Width() = 0;
    1813           0 :         bMinWidth = false;
    1814             :     }
    1815           4 :     if( SVX_CSS1_LTYPE_TWIP== aCSS1PropInfo.eHeightType )
    1816             :     {
    1817           0 :         aSz.Height() = convertTwipToMm100( aCSS1PropInfo.nHeight );
    1818           0 :         aTextSz.Height() = 0;
    1819           0 :         bMinHeight = false;
    1820             :     }
    1821             : 
    1822             :     // Beim Image-Button bei nicht gegebern Groesse einen sinnvollen Default
    1823             :     // setzen
    1824           4 :     if( HTML_IT_IMAGE== eType )
    1825             :     {
    1826           0 :         if( !aSz.Width() )
    1827             :         {
    1828           0 :             aSz.Width() = HTML_DFLT_IMG_WIDTH;
    1829           0 :             bSetGrfWidth = true;
    1830           0 :             if( pTable != 0 )
    1831           0 :                 IncGrfsThatResizeTable();
    1832             :         }
    1833           0 :         if( !aSz.Height() )
    1834             :         {
    1835           0 :             aSz.Height() = HTML_DFLT_IMG_HEIGHT;
    1836           0 :             bSetGrfHeight = true;
    1837             :         }
    1838             :     }
    1839           4 :     if( aSz.Width() < MINFLY )
    1840           4 :         aSz.Width() = MINFLY;
    1841           4 :     if( aSz.Height() < MINFLY )
    1842           4 :         aSz.Height() = MINFLY;
    1843             : 
    1844             :     uno::Reference< drawing::XShape > xShape = InsertControl(
    1845             :                                              xFComp, xPropSet, aSz,
    1846             :                                              eVertOri, eHoriOri,
    1847             :                                              aCSS1ItemSet, aCSS1PropInfo,
    1848             :                                              aMacroTable, aUnoMacroTable,
    1849             :                                              aUnoMacroParamTable, false,
    1850           8 :                                              bHidden );
    1851           4 :     if( aTextSz.Width() || aTextSz.Height() || bMinWidth || bMinHeight )
    1852             :     {
    1853             :         OSL_ENSURE( !(bSetGrfWidth || bSetGrfHeight), "Grafikgroesse anpassen???" );
    1854           2 :         SetControlSize( xShape, aTextSz, bMinWidth, bMinHeight );
    1855             :     }
    1856             : 
    1857           4 :     if( HTML_IT_RADIO == eType )
    1858             :     {
    1859           0 :         aTmp <<= (sal_Int16) nChecked ;
    1860           0 :         xPropSet->setPropertyValue("DefaultState", aTmp );
    1861             :     }
    1862             : 
    1863           4 :     if( HTML_IT_IMAGE == eType )
    1864             :     {
    1865             :         // Die URL erst nach dem Einfuegen setzen, weil sich der
    1866             :         // Download der Grafik erst dann am XModel anmelden kann,
    1867             :         // wenn das Control eingefuegt ist.
    1868           0 :         aTmp <<= OUString( URIHelper::SmartRel2Abs(INetURLObject(sBaseURL), sImgSrc, Link<OUString *, bool>(), false));
    1869           0 :         xPropSet->setPropertyValue("ImageURL",
    1870           0 :                                     aTmp );
    1871             :     }
    1872             : 
    1873           4 :     if( bSetGrfWidth || bSetGrfHeight )
    1874             :     {
    1875             :         SwHTMLImageWatcher* pWatcher =
    1876           0 :             new SwHTMLImageWatcher( xShape, bSetGrfWidth, bSetGrfHeight );
    1877           0 :         uno::Reference< awt::XImageConsumer > xCons = pWatcher;
    1878           0 :         pWatcher->start();
    1879          12 :     }
    1880             : }
    1881             : 
    1882           0 : void SwHTMLParser::NewTextArea()
    1883             : {
    1884             :     assert(pPendStack == 0);
    1885             : 
    1886             :     OSL_ENSURE( !bTextArea, "TextArea in TextArea???" );
    1887             :     OSL_ENSURE( !pFormImpl || !pFormImpl->GetFCompPropSet().is(),
    1888             :             "TextArea in Control???" );
    1889             : 
    1890           0 :     if( !pFormImpl || !pFormImpl->GetFormComps().is() )
    1891             :     {
    1892             :         // Spezialbehandlung fuer TextArea auch untem im Parser beenden
    1893           0 :         FinishTextArea();
    1894           0 :         return;
    1895             :     }
    1896             : 
    1897           0 :     OUString aId, aClass, aStyle;
    1898           0 :     OUString sName;
    1899           0 :     sal_Int32 nTabIndex = TABINDEX_MAX + 1;
    1900           0 :     SvxMacroTableDtor aMacroTable;
    1901           0 :     std::vector<OUString> aUnoMacroTable;
    1902           0 :     std::vector<OUString> aUnoMacroParamTable;
    1903           0 :     sal_uInt16 nRows = 0, nCols = 0;
    1904           0 :     sal_uInt16 nWrap = HTML_WM_OFF;
    1905           0 :     bool bDisabled = false;
    1906           0 :     SvKeyValueIterator *pHeaderAttrs = pFormImpl->GetHeaderAttrs();
    1907           0 :     ScriptType eDfltScriptType = GetScriptType( pHeaderAttrs );
    1908           0 :     const OUString& rDfltScriptType = GetScriptTypeString( pHeaderAttrs );
    1909             : 
    1910           0 :     const HTMLOptions& rHTMLOptions = GetOptions();
    1911           0 :     for (size_t i = rHTMLOptions.size(); i; )
    1912             :     {
    1913           0 :         const HTMLOption& rOption = rHTMLOptions[--i];
    1914           0 :         ScriptType eScriptType2 = eDfltScriptType;
    1915           0 :         sal_uInt16 nEvent = 0;
    1916           0 :         bool bSetEvent = false;
    1917             : 
    1918           0 :         switch( rOption.GetToken() )
    1919             :         {
    1920             :         case HTML_O_ID:
    1921           0 :             aId = rOption.GetString();
    1922           0 :             break;
    1923             :         case HTML_O_STYLE:
    1924           0 :             aStyle = rOption.GetString();
    1925           0 :             break;
    1926             :         case HTML_O_CLASS:
    1927           0 :             aClass = rOption.GetString();
    1928           0 :             break;
    1929             :         case HTML_O_NAME:
    1930           0 :             sName = rOption.GetString();
    1931           0 :             break;
    1932             :         case HTML_O_DISABLED:
    1933           0 :             bDisabled = true;
    1934           0 :             break;
    1935             :         case HTML_O_ROWS:
    1936           0 :             nRows = (sal_uInt16)rOption.GetNumber();
    1937           0 :             break;
    1938             :         case HTML_O_COLS:
    1939           0 :             nCols = (sal_uInt16)rOption.GetNumber();
    1940           0 :             break;
    1941             :         case HTML_O_WRAP:
    1942           0 :             nWrap = rOption.GetEnum( aHTMLTextAreaWrapTable, nWrap );
    1943           0 :             break;
    1944             : 
    1945             :         case HTML_O_TABINDEX:
    1946           0 :             nTabIndex = rOption.GetSNumber();
    1947           0 :             break;
    1948             : 
    1949             :         case HTML_O_SDONFOCUS:
    1950           0 :             eScriptType2 = STARBASIC;
    1951             :             //fallthrough
    1952             :         case HTML_O_ONFOCUS:
    1953           0 :             nEvent = HTML_ET_ONGETFOCUS;
    1954           0 :             bSetEvent = true;
    1955           0 :             break;
    1956             : 
    1957             :         case HTML_O_SDONBLUR:
    1958           0 :             eScriptType2 = STARBASIC;
    1959             :             //fallthrough
    1960             :         case HTML_O_ONBLUR:
    1961           0 :             nEvent = HTML_ET_ONLOSEFOCUS;
    1962           0 :             bSetEvent = true;
    1963           0 :             break;
    1964             : 
    1965             :         case HTML_O_SDONCLICK:
    1966           0 :             eScriptType2 = STARBASIC;
    1967             :             //fallthrough
    1968             :         case HTML_O_ONCLICK:
    1969           0 :             nEvent = HTML_ET_ONCLICK;
    1970           0 :             bSetEvent = true;
    1971           0 :             break;
    1972             : 
    1973             :         case HTML_O_SDONCHANGE:
    1974           0 :             eScriptType2 = STARBASIC;
    1975             :             //fallthrough
    1976             :         case HTML_O_ONCHANGE:
    1977           0 :             nEvent = HTML_ET_ONCHANGE;
    1978           0 :             bSetEvent = true;
    1979           0 :             break;
    1980             : 
    1981             :         case HTML_O_SDONSELECT:
    1982           0 :             eScriptType2 = STARBASIC;
    1983             :             //fallthrough
    1984             :         case HTML_O_ONSELECT:
    1985           0 :             nEvent = HTML_ET_ONSELECT;
    1986           0 :             bSetEvent = true;
    1987           0 :             break;
    1988             : 
    1989             :         default:
    1990           0 :             lcl_html_getEvents( rOption.GetTokenString(),
    1991           0 :                                 rOption.GetString(),
    1992           0 :                                 aUnoMacroTable, aUnoMacroParamTable );
    1993           0 :             break;
    1994             :         }
    1995             : 
    1996           0 :         if( bSetEvent )
    1997             :         {
    1998           0 :             OUString sEvent( rOption.GetString() );
    1999           0 :             if( !sEvent.isEmpty() )
    2000             :             {
    2001           0 :                 sEvent = convertLineEnd(sEvent, GetSystemLineEnd());
    2002           0 :                 if( EXTENDED_STYPE==eScriptType2 )
    2003           0 :                     aScriptType = rDfltScriptType;
    2004           0 :                 aMacroTable.Insert( nEvent, SvxMacro( sEvent, aScriptType, eScriptType2 ) );
    2005           0 :             }
    2006             :         }
    2007             :     }
    2008             : 
    2009             :     const uno::Reference< lang::XMultiServiceFactory > & rSrvcMgr =
    2010           0 :         pFormImpl->GetServiceFactory();
    2011           0 :     if( !rSrvcMgr.is() )
    2012             :     {
    2013           0 :         FinishTextArea();
    2014           0 :         return;
    2015             :     }
    2016           0 :     uno::Reference< uno::XInterface >  xInt = rSrvcMgr->createInstance(
    2017           0 :         OUString("com.sun.star.form.component.TextField") );
    2018           0 :     if( !xInt.is() )
    2019             :     {
    2020           0 :         FinishTextArea();
    2021           0 :         return;
    2022             :     }
    2023             : 
    2024           0 :     uno::Reference< XFormComponent > xFComp( xInt, UNO_QUERY );
    2025             :     OSL_ENSURE( xFComp.is(), "keine FormComponent?" );
    2026             : 
    2027           0 :     uno::Reference< beans::XPropertySet > xPropSet( xFComp, UNO_QUERY );
    2028             : 
    2029           0 :     Any aTmp;
    2030           0 :     aTmp <<= OUString(sName);
    2031           0 :     xPropSet->setPropertyValue("Name", aTmp );
    2032             : 
    2033           0 :     aTmp <<= true;
    2034           0 :     xPropSet->setPropertyValue("MultiLine", aTmp );
    2035           0 :     xPropSet->setPropertyValue("VScroll", aTmp );
    2036           0 :     if( HTML_WM_OFF == nWrap )
    2037           0 :         xPropSet->setPropertyValue("HScroll", aTmp );
    2038           0 :     if( HTML_WM_HARD == nWrap )
    2039           0 :         xPropSet->setPropertyValue("HardLineBreaks", aTmp );
    2040             : 
    2041           0 :     if( nTabIndex >= TABINDEX_MIN && nTabIndex <= TABINDEX_MAX  )
    2042             :     {
    2043           0 :         aTmp <<= (sal_Int16)nTabIndex ;
    2044           0 :         xPropSet->setPropertyValue("TabIndex", aTmp );
    2045             :     }
    2046             : 
    2047           0 :     lcl_html_setFixedFontProperty( xPropSet );
    2048             : 
    2049           0 :     if( bDisabled )
    2050             :     {
    2051           0 :         xPropSet->setPropertyValue("Enabled", makeAny(false) );
    2052             :     }
    2053             : 
    2054             :     OSL_ENSURE( pFormImpl->GetText().isEmpty(), "Text ist nicht leer!" );
    2055             : 
    2056           0 :     if( !nCols )
    2057           0 :         nCols = 20;
    2058           0 :     if( !nRows )
    2059           0 :         nRows = 1;
    2060             : 
    2061           0 :     Size aTextSz( nCols, nRows );
    2062             : 
    2063           0 :     SfxItemSet aCSS1ItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
    2064           0 :     SvxCSS1PropertyInfo aCSS1PropInfo;
    2065           0 :     if( HasStyleOptions( aStyle, aId, aClass ) )
    2066             :     {
    2067           0 :         ParseStyleOptions( aStyle, aId, aClass, aCSS1ItemSet, aCSS1PropInfo );
    2068           0 :         if( !aId.isEmpty() )
    2069           0 :             InsertBookmark( aId );
    2070             :     }
    2071             : 
    2072           0 :     Size aSz( MINFLY, MINFLY );
    2073           0 :     if( SVX_CSS1_LTYPE_TWIP== aCSS1PropInfo.eWidthType )
    2074             :     {
    2075           0 :         aSz.Width() = convertTwipToMm100( aCSS1PropInfo.nWidth );
    2076           0 :         aTextSz.Width() = 0;
    2077             :     }
    2078           0 :     if( SVX_CSS1_LTYPE_TWIP== aCSS1PropInfo.eHeightType )
    2079             :     {
    2080           0 :         aSz.Height() = convertTwipToMm100( aCSS1PropInfo.nHeight );
    2081           0 :         aTextSz.Height() = 0;
    2082             :     }
    2083           0 :     if( aSz.Width() < MINFLY )
    2084           0 :         aSz.Width() = MINFLY;
    2085           0 :     if( aSz.Height() < MINFLY )
    2086           0 :         aSz.Height() = MINFLY;
    2087             : 
    2088             :     uno::Reference< drawing::XShape > xShape = InsertControl( xFComp, xPropSet, aSz,
    2089             :                                       text::VertOrientation::TOP, text::HoriOrientation::NONE,
    2090             :                                       aCSS1ItemSet, aCSS1PropInfo,
    2091             :                                       aMacroTable, aUnoMacroTable,
    2092           0 :                                       aUnoMacroParamTable );
    2093           0 :     if( aTextSz.Width() || aTextSz.Height() )
    2094           0 :         SetControlSize( xShape, aTextSz, false, false );
    2095             : 
    2096             :     // einen neuen Kontext anlegen
    2097           0 :     _HTMLAttrContext *pCntxt = new _HTMLAttrContext( HTML_TEXTAREA_ON );
    2098             : 
    2099             :     // und PRE/Listing/XMP voruebergehend aussetzen
    2100           0 :     SplitPREListingXMP( pCntxt );
    2101           0 :     PushContext( pCntxt );
    2102             : 
    2103           0 :     bTextArea = true;
    2104           0 :     bTAIgnoreNewPara = true;
    2105             : }
    2106             : 
    2107           0 : void SwHTMLParser::EndTextArea()
    2108             : {
    2109             :     OSL_ENSURE( bTextArea, "keine TextArea oder falscher Typ" );
    2110             :     OSL_ENSURE( pFormImpl && pFormImpl->GetFCompPropSet().is(),
    2111             :             "TextArea fehlt" );
    2112             : 
    2113             :     const uno::Reference< beans::XPropertySet > & rPropSet =
    2114           0 :         pFormImpl->GetFCompPropSet();
    2115             : 
    2116           0 :     Any aTmp;
    2117           0 :     aTmp <<= pFormImpl->GetText();
    2118           0 :     rPropSet->setPropertyValue("DefaultText", aTmp );
    2119           0 :     pFormImpl->EraseText();
    2120             : 
    2121           0 :     pFormImpl->ReleaseFCompPropSet();
    2122             : 
    2123             :     // den Kontext holen
    2124           0 :     _HTMLAttrContext *pCntxt = PopContext( HTML_TEXTAREA_ON );
    2125           0 :     if( pCntxt )
    2126             :     {
    2127             :         // und ggf. die Attribute beenden
    2128           0 :         EndContext( pCntxt );
    2129           0 :         delete pCntxt;
    2130             :     }
    2131             : 
    2132           0 :     bTextArea = false;
    2133           0 : }
    2134             : 
    2135           0 : void SwHTMLParser::InsertTextAreaText( sal_uInt16 nToken )
    2136             : {
    2137             :     OSL_ENSURE( bTextArea, "keine TextArea oder falscher Typ" );
    2138             :     OSL_ENSURE( pFormImpl && pFormImpl->GetFCompPropSet().is(),
    2139             :             "TextArea fehlt" );
    2140             : 
    2141           0 :     OUString& rText = pFormImpl->GetText();
    2142           0 :     switch( nToken)
    2143             :     {
    2144             :     case HTML_TEXTTOKEN:
    2145           0 :         rText += aToken;
    2146           0 :         break;
    2147             :     case HTML_NEWPARA:
    2148           0 :         if( !bTAIgnoreNewPara )
    2149           0 :             rText += "\n";    // das ist hier richtig!!!
    2150           0 :         break;
    2151             :     default:
    2152           0 :         rText += "<";
    2153           0 :         rText += sSaveToken;
    2154           0 :         if( !aToken.isEmpty() )
    2155             :         {
    2156           0 :             rText += " ";
    2157           0 :             rText += aToken;
    2158             :         }
    2159           0 :         rText += ">";
    2160             :     }
    2161             : 
    2162           0 :     bTAIgnoreNewPara = false;
    2163           0 : }
    2164             : 
    2165           0 : void SwHTMLParser::NewSelect()
    2166             : {
    2167             :     assert(pPendStack == 0);
    2168             : 
    2169             :     OSL_ENSURE( !bSelect, "Select in Select???" );
    2170             :     OSL_ENSURE( !pFormImpl || !pFormImpl->GetFCompPropSet().is(),
    2171             :             "Select in Control???" );
    2172             : 
    2173           0 :     if( !pFormImpl || !pFormImpl->GetFormComps().is() )
    2174           0 :         return;
    2175             : 
    2176           0 :     OUString aId, aClass, aStyle;
    2177           0 :     OUString sName;
    2178           0 :     sal_Int32 nTabIndex = TABINDEX_MAX + 1;
    2179           0 :     SvxMacroTableDtor aMacroTable;
    2180           0 :     std::vector<OUString> aUnoMacroTable;
    2181           0 :     std::vector<OUString> aUnoMacroParamTable;
    2182           0 :     bool bMultiple = false;
    2183           0 :     bool bDisabled = false;
    2184           0 :     nSelectEntryCnt = 1;
    2185           0 :     SvKeyValueIterator *pHeaderAttrs = pFormImpl->GetHeaderAttrs();
    2186           0 :     ScriptType eDfltScriptType = GetScriptType( pHeaderAttrs );
    2187           0 :     const OUString& rDfltScriptType = GetScriptTypeString( pHeaderAttrs );
    2188             : 
    2189           0 :     const HTMLOptions& rHTMLOptions = GetOptions();
    2190           0 :     for (size_t i = rHTMLOptions.size(); i; )
    2191             :     {
    2192           0 :         const HTMLOption& rOption = rHTMLOptions[--i];
    2193           0 :         ScriptType eScriptType2 = eDfltScriptType;
    2194           0 :         sal_uInt16 nEvent = 0;
    2195           0 :         bool bSetEvent = false;
    2196             : 
    2197           0 :         switch( rOption.GetToken() )
    2198             :         {
    2199             :         case HTML_O_ID:
    2200           0 :             aId = rOption.GetString();
    2201           0 :             break;
    2202             :         case HTML_O_STYLE:
    2203           0 :             aStyle = rOption.GetString();
    2204           0 :             break;
    2205             :         case HTML_O_CLASS:
    2206           0 :             aClass = rOption.GetString();
    2207           0 :             break;
    2208             :         case HTML_O_NAME:
    2209           0 :             sName = rOption.GetString();
    2210           0 :             break;
    2211             :         case HTML_O_MULTIPLE:
    2212           0 :             bMultiple = true;
    2213           0 :             break;
    2214             :         case HTML_O_DISABLED:
    2215           0 :             bDisabled = true;
    2216           0 :             break;
    2217             :         case HTML_O_SIZE:
    2218           0 :             nSelectEntryCnt = (sal_uInt16)rOption.GetNumber();
    2219           0 :             break;
    2220             : 
    2221             :         case HTML_O_TABINDEX:
    2222           0 :             nTabIndex = rOption.GetSNumber();
    2223           0 :             break;
    2224             : 
    2225             :         case HTML_O_SDONFOCUS:
    2226           0 :             eScriptType2 = STARBASIC;
    2227             :             //fall-through
    2228             :         case HTML_O_ONFOCUS:
    2229           0 :             nEvent = HTML_ET_ONGETFOCUS;
    2230           0 :             bSetEvent = true;
    2231           0 :             break;
    2232             : 
    2233             :         case HTML_O_SDONBLUR:
    2234           0 :             eScriptType2 = STARBASIC;
    2235             :             //fall-through
    2236             :         case HTML_O_ONBLUR:
    2237           0 :             nEvent = HTML_ET_ONLOSEFOCUS;
    2238           0 :             bSetEvent = true;
    2239           0 :             break;
    2240             : 
    2241             :         case HTML_O_SDONCLICK:
    2242           0 :             eScriptType2 = STARBASIC;
    2243             :             //fall-through
    2244             :         case HTML_O_ONCLICK:
    2245           0 :             nEvent = HTML_ET_ONCLICK;
    2246           0 :             bSetEvent = true;
    2247           0 :             break;
    2248             : 
    2249             :         case HTML_O_SDONCHANGE:
    2250           0 :             eScriptType2 = STARBASIC;
    2251             :             //fall-through
    2252             :         case HTML_O_ONCHANGE:
    2253           0 :             nEvent = HTML_ET_ONCHANGE;
    2254           0 :             bSetEvent = true;
    2255           0 :             break;
    2256             : 
    2257             :         default:
    2258           0 :             lcl_html_getEvents( rOption.GetTokenString(),
    2259           0 :                                 rOption.GetString(),
    2260           0 :                                 aUnoMacroTable, aUnoMacroParamTable );
    2261           0 :             break;
    2262             :         }
    2263             : 
    2264           0 :         if( bSetEvent )
    2265             :         {
    2266           0 :             OUString sEvent( rOption.GetString() );
    2267           0 :             if( !sEvent.isEmpty() )
    2268             :             {
    2269           0 :                 sEvent = convertLineEnd(sEvent, GetSystemLineEnd());
    2270           0 :                 if( EXTENDED_STYPE==eScriptType2 )
    2271           0 :                     aScriptType = rDfltScriptType;
    2272           0 :                 aMacroTable.Insert( nEvent, SvxMacro( sEvent, aScriptType, eScriptType2 ) );
    2273           0 :             }
    2274             :         }
    2275             :     }
    2276             : 
    2277             :     const uno::Reference< lang::XMultiServiceFactory > & rSrvcMgr =
    2278           0 :         pFormImpl->GetServiceFactory();
    2279           0 :     if( !rSrvcMgr.is() )
    2280             :     {
    2281           0 :         FinishTextArea();
    2282           0 :         return;
    2283             :     }
    2284           0 :     uno::Reference< uno::XInterface >  xInt = rSrvcMgr->createInstance(
    2285           0 :         OUString("com.sun.star.form.component.ListBox") );
    2286           0 :     if( !xInt.is() )
    2287             :     {
    2288           0 :         FinishTextArea();
    2289           0 :         return;
    2290             :     }
    2291             : 
    2292           0 :     uno::Reference< XFormComponent > xFComp( xInt, UNO_QUERY );
    2293             :     OSL_ENSURE(xFComp.is(), "keine FormComponent?");
    2294             : 
    2295           0 :     uno::Reference< beans::XPropertySet >  xPropSet( xFComp, UNO_QUERY );
    2296             : 
    2297           0 :     Any aTmp;
    2298           0 :     aTmp <<= OUString(sName);
    2299           0 :     xPropSet->setPropertyValue("Name", aTmp );
    2300             : 
    2301           0 :     if( nTabIndex >= TABINDEX_MIN && nTabIndex <= TABINDEX_MAX  )
    2302             :     {
    2303           0 :         aTmp <<= (sal_Int16)nTabIndex ;
    2304           0 :         xPropSet->setPropertyValue("TabIndex", aTmp );
    2305             :     }
    2306             : 
    2307           0 :     if( bDisabled )
    2308             :     {
    2309           0 :         xPropSet->setPropertyValue("Enabled", makeAny(false) );
    2310             :     }
    2311             : 
    2312           0 :     Size aTextSz( 0, 0 );
    2313           0 :     bool bMinWidth = true, bMinHeight = true;
    2314           0 :     if( !bMultiple && 1==nSelectEntryCnt )
    2315             :     {
    2316           0 :         xPropSet->setPropertyValue("Dropdown", makeAny(true) );
    2317             :     }
    2318             :     else
    2319             :     {
    2320           0 :         if( nSelectEntryCnt <= 1 )      // 4 Zeilen als default
    2321           0 :             nSelectEntryCnt = 4;
    2322             : 
    2323           0 :         if( bMultiple )
    2324             :         {
    2325           0 :             xPropSet->setPropertyValue("MultiSelection", makeAny(true) );
    2326             :         }
    2327           0 :         aTextSz.Height() = nSelectEntryCnt;
    2328           0 :         bMinHeight = false;
    2329             :     }
    2330             : 
    2331           0 :     SfxItemSet aCSS1ItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
    2332           0 :     SvxCSS1PropertyInfo aCSS1PropInfo;
    2333           0 :     if( HasStyleOptions( aStyle, aId, aClass ) )
    2334             :     {
    2335           0 :         ParseStyleOptions( aStyle, aId, aClass, aCSS1ItemSet, aCSS1PropInfo );
    2336           0 :         if( !aId.isEmpty() )
    2337           0 :             InsertBookmark( aId );
    2338             :     }
    2339             : 
    2340           0 :     Size aSz( MINFLY, MINFLY );
    2341           0 :     bFixSelectWidth = bFixSelectHeight = true;
    2342           0 :     if( SVX_CSS1_LTYPE_TWIP== aCSS1PropInfo.eWidthType )
    2343             :     {
    2344           0 :         aSz.Width() = convertTwipToMm100( aCSS1PropInfo.nWidth );
    2345           0 :         bFixSelectWidth = false;
    2346           0 :         bMinWidth = false;
    2347             :     }
    2348           0 :     if( SVX_CSS1_LTYPE_TWIP== aCSS1PropInfo.eHeightType )
    2349             :     {
    2350           0 :         aSz.Height() = convertTwipToMm100( aCSS1PropInfo.nHeight );
    2351           0 :         aTextSz.Height() = 0;
    2352           0 :         bMinHeight = false;
    2353             :     }
    2354           0 :     if( aSz.Width() < MINFLY )
    2355           0 :         aSz.Width() = MINFLY;
    2356           0 :     if( aSz.Height() < MINFLY )
    2357           0 :         aSz.Height() = MINFLY;
    2358             : 
    2359             :     uno::Reference< drawing::XShape >  xShape = InsertControl( xFComp, xPropSet, aSz,
    2360             :                                       text::VertOrientation::TOP, text::HoriOrientation::NONE,
    2361             :                                       aCSS1ItemSet, aCSS1PropInfo,
    2362             :                                       aMacroTable, aUnoMacroTable,
    2363           0 :                                       aUnoMacroParamTable );
    2364           0 :     if( bFixSelectWidth )
    2365           0 :         pFormImpl->SetShape( xShape );
    2366           0 :     if( aTextSz.Height() || bMinWidth || bMinHeight )
    2367           0 :         SetControlSize( xShape, aTextSz, bMinWidth, bMinHeight );
    2368             : 
    2369             :     // einen neuen Kontext anlegen
    2370           0 :     _HTMLAttrContext *pCntxt = new _HTMLAttrContext( HTML_SELECT_ON );
    2371             : 
    2372             :     // und PRE/Listing/XMP voruebergehend aussetzen
    2373           0 :     SplitPREListingXMP( pCntxt );
    2374           0 :     PushContext( pCntxt );
    2375             : 
    2376           0 :     bSelect = true;
    2377             : }
    2378             : 
    2379           0 : void SwHTMLParser::EndSelect()
    2380             : {
    2381             :     assert(pPendStack == 0);
    2382             : 
    2383             :     OSL_ENSURE( bSelect, "keine Select" );
    2384             :     OSL_ENSURE( pFormImpl && pFormImpl->GetFCompPropSet().is(),
    2385             :             "kein Select-Control" );
    2386             : 
    2387             :     const uno::Reference< beans::XPropertySet > & rPropSet =
    2388           0 :         pFormImpl->GetFCompPropSet();
    2389             : 
    2390           0 :     size_t nEntryCnt = pFormImpl->GetStringList().size();
    2391           0 :     if(!pFormImpl->GetStringList().empty())
    2392             :     {
    2393           0 :         Sequence<OUString> aList( (sal_Int32)nEntryCnt );
    2394           0 :         Sequence<OUString> aValueList( (sal_Int32)nEntryCnt );
    2395           0 :         OUString *pStrings = aList.getArray();
    2396           0 :         OUString *pValues = aValueList.getArray();
    2397             : 
    2398           0 :         for(size_t i = 0; i < nEntryCnt; ++i)
    2399             :         {
    2400           0 :             OUString sText(pFormImpl->GetStringList()[i]);
    2401           0 :             sText = comphelper::string::stripEnd(sText, ' ');
    2402           0 :             pStrings[i] = sText;
    2403             : 
    2404           0 :             sText = pFormImpl->GetValueList()[i];
    2405           0 :             pValues[i] = sText;
    2406           0 :         }
    2407             : 
    2408           0 :         Any aAny( &aList, cppu::UnoType<uno::Sequence<OUString>>::get() );
    2409             : 
    2410           0 :         rPropSet->setPropertyValue("StringItemList", aAny );
    2411             : 
    2412           0 :         aAny <<= ListSourceType_VALUELIST;
    2413           0 :         rPropSet->setPropertyValue("ListSourceType", aAny );
    2414             : 
    2415           0 :         aAny.setValue( &aValueList, cppu::UnoType<uno::Sequence<OUString>>::get() );
    2416             : 
    2417           0 :         rPropSet->setPropertyValue("ListSource", aAny );
    2418             : 
    2419           0 :         size_t nSelCnt = pFormImpl->GetSelectedList().size();
    2420           0 :         if( !nSelCnt && 1 == nSelectEntryCnt && nEntryCnt )
    2421             :         {
    2422             :             // In einer DropDown-Listbox sollte immer ein Eintrag selektiert
    2423             :             // sein.
    2424           0 :             pFormImpl->GetSelectedList().insert( pFormImpl->GetSelectedList().begin(), 0 );
    2425           0 :             nSelCnt = 1;
    2426             :         }
    2427           0 :         Sequence<sal_Int16> aSelList( (sal_Int32)nSelCnt );
    2428           0 :         sal_Int16 *pSels = aSelList.getArray();
    2429           0 :         for(size_t i = 0; i < nSelCnt; ++i)
    2430             :         {
    2431           0 :             pSels[i] = (sal_Int16)pFormImpl->GetSelectedList()[i];
    2432             :         }
    2433             :         aAny.setValue( &aSelList,
    2434           0 :                        cppu::UnoType<uno::Sequence<sal_Int16>>::get() );
    2435             : 
    2436           0 :         rPropSet->setPropertyValue("DefaultSelection", aAny );
    2437             : 
    2438           0 :         pFormImpl->EraseStringList();
    2439           0 :         pFormImpl->EraseValueList();
    2440             :     }
    2441             : 
    2442           0 :     pFormImpl->EraseSelectedList();
    2443             : 
    2444           0 :     if( bFixSelectWidth )
    2445             :     {
    2446             :         OSL_ENSURE( pFormImpl->GetShape().is(), "Kein Shape gemerkt" );
    2447           0 :         Size aTextSz( -1, 0 );
    2448           0 :         SetControlSize( pFormImpl->GetShape(), aTextSz, false, false );
    2449             :     }
    2450             : 
    2451           0 :     pFormImpl->ReleaseFCompPropSet();
    2452             : 
    2453             :     // den Kontext holen
    2454           0 :     _HTMLAttrContext *pCntxt = PopContext( HTML_SELECT_ON );
    2455           0 :     if( pCntxt )
    2456             :     {
    2457             :         // und ggf. die Attribute beenden
    2458           0 :         EndContext( pCntxt );
    2459           0 :         delete pCntxt;
    2460             :     }
    2461             : 
    2462           0 :     bSelect = false;
    2463           0 : }
    2464             : 
    2465           0 : void SwHTMLParser::InsertSelectOption()
    2466             : {
    2467             :     OSL_ENSURE( bSelect, "keine Select" );
    2468             :     OSL_ENSURE( pFormImpl && pFormImpl->GetFCompPropSet().is(),
    2469             :             "kein Select-Control" );
    2470             : 
    2471           0 :     bLBEntrySelected = false;
    2472           0 :     OUString aValue;
    2473             : 
    2474           0 :     const HTMLOptions& rHTMLOptions = GetOptions();
    2475           0 :     for (size_t i = rHTMLOptions.size(); i; )
    2476             :     {
    2477           0 :         const HTMLOption& rOption = rHTMLOptions[--i];
    2478           0 :         switch( rOption.GetToken() )
    2479             :         {
    2480             :         case HTML_O_ID:
    2481             :             // erstmal weglassen!!!
    2482           0 :             break;
    2483             :         case HTML_O_SELECTED:
    2484           0 :             bLBEntrySelected = true;
    2485           0 :             break;
    2486             :         case HTML_O_VALUE:
    2487           0 :             aValue = rOption.GetString();
    2488           0 :             if( aValue.isEmpty() )
    2489           0 :                 aValue = "$$$empty$$$";
    2490           0 :             break;
    2491             :         }
    2492             :     }
    2493             : 
    2494           0 :     sal_uInt16 nEntryCnt = pFormImpl->GetStringList().size();
    2495           0 :     pFormImpl->GetStringList().push_back(aEmptyOUStr);
    2496           0 :     pFormImpl->GetValueList().push_back(aValue);
    2497           0 :     if( bLBEntrySelected )
    2498             :     {
    2499           0 :         pFormImpl->GetSelectedList().push_back( nEntryCnt );
    2500           0 :     }
    2501           0 : }
    2502             : 
    2503           0 : void SwHTMLParser::InsertSelectText()
    2504             : {
    2505             :     OSL_ENSURE( bSelect, "keine Select" );
    2506             :     OSL_ENSURE( pFormImpl && pFormImpl->GetFCompPropSet().is(),
    2507             :             "kein Select-Control" );
    2508             : 
    2509           0 :     if(!pFormImpl->GetStringList().empty())
    2510             :     {
    2511           0 :         OUString& rText = pFormImpl->GetStringList().back();
    2512             : 
    2513           0 :         if( !aToken.isEmpty() && ' '==aToken[ 0 ] )
    2514             :         {
    2515           0 :             sal_Int32 nLen = rText.getLength();
    2516           0 :             if( !nLen || ' '==rText[nLen-1])
    2517           0 :                 aToken = aToken.replaceAt( 0, 1, "" );
    2518             :         }
    2519           0 :         if( !aToken.isEmpty() )
    2520           0 :             rText += aToken;
    2521             :     }
    2522         177 : }
    2523             : 
    2524             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11