LCOV - code coverage report
Current view: top level - libreoffice/sw/source/filter/html - htmlform.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 1306 0.0 %
Date: 2012-12-27 Functions: 0 59 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10