LCOV - code coverage report
Current view: top level - libreoffice/sw/source/filter/html - htmlforw.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 767 0.0 %
Date: 2012-12-27 Functions: 0 15 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 <com/sun/star/frame/XModel.hpp>
      21             : #include <com/sun/star/form/FormSubmitEncoding.hpp>
      22             : #include <com/sun/star/form/FormSubmitMethod.hpp>
      23             : #include <com/sun/star/form/FormButtonType.hpp>
      24             : #include <com/sun/star/script/XEventAttacher.hpp>
      25             : #include <com/sun/star/script/XEventAttacherManager.hpp>
      26             : #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
      27             : #include <com/sun/star/form/XFormsSupplier.hpp>
      28             : #include <com/sun/star/form/XForm.hpp>
      29             : #include <com/sun/star/form/FormComponentType.hpp>
      30             : #include <com/sun/star/awt/XTextLayoutConstrains.hpp>
      31             : #include <comphelper/string.hxx>
      32             : #include <hintids.hxx>
      33             : #include <vcl/svapp.hxx>
      34             : #include <vcl/wrkwin.hxx>
      35             : #include <svl/macitem.hxx>
      36             : #include <svtools/htmlout.hxx>
      37             : #include <svtools/htmltokn.h>
      38             : #include <svtools/htmlkywd.hxx>
      39             : #include <svl/urihelper.hxx>
      40             : #include <toolkit/helper/vclunohelper.hxx>
      41             : #include <svx/svdouno.hxx>
      42             : #include <svx/fmglob.hxx>
      43             : #include <editeng/brshitem.hxx>
      44             : #include <editeng/colritem.hxx>
      45             : #include <editeng/fhgtitem.hxx>
      46             : #include <editeng/fontitem.hxx>
      47             : #include <editeng/wghtitem.hxx>
      48             : #include <editeng/postitem.hxx>
      49             : #include <editeng/udlnitem.hxx>
      50             : #include <editeng/crsditem.hxx>
      51             : #include <docsh.hxx>
      52             : #include <fmtanchr.hxx>
      53             : #include <docary.hxx>
      54             : #include <viewsh.hxx>
      55             : #include "pam.hxx"
      56             : #include "doc.hxx"
      57             : #include "ndtxt.hxx"
      58             : #include "flypos.hxx"
      59             : #include "wrthtml.hxx"
      60             : #include "htmlfly.hxx"
      61             : #include "htmlform.hxx"
      62             : #include "frmfmt.hxx"
      63             : #include <rtl/strbuf.hxx>
      64             : 
      65             : using namespace ::com::sun::star;
      66             : using ::rtl::OUString;
      67             : 
      68             : const sal_uInt32 HTML_FRMOPTS_CONTROL   =
      69             :     0;
      70             : const sal_uInt32 HTML_FRMOPTS_CONTROL_CSS1  =
      71             :     HTML_FRMOPT_S_ALIGN |
      72             :     HTML_FRMOPT_S_SIZE |
      73             :     HTML_FRMOPT_S_SPACE |
      74             :     HTML_FRMOPT_BRCLEAR;
      75             : const sal_uInt32 HTML_FRMOPTS_IMG_CONTROL   =
      76             :     HTML_FRMOPT_ALIGN |
      77             :     HTML_FRMOPT_BRCLEAR;
      78             : const sal_uInt32 HTML_FRMOPTS_IMG_CONTROL_CSS1 =
      79             :     HTML_FRMOPT_S_ALIGN |
      80             :     HTML_FRMOPT_S_SPACE;
      81             : 
      82             : 
      83             : 
      84           0 : static void lcl_html_outEvents( SvStream& rStrm,
      85             :                          const uno::Reference< form::XFormComponent > rFormComp,
      86             :                          sal_Bool bCfgStarBasic,
      87             :                          rtl_TextEncoding eDestEnc,
      88             :                            String *pNonConvertableChars )
      89             : {
      90           0 :     uno::Reference< container::XChild > xChild( rFormComp, uno::UNO_QUERY );
      91           0 :     uno::Reference< uno::XInterface > xParentIfc = xChild->getParent();
      92             :     OSL_ENSURE( xParentIfc.is(), "lcl_html_outEvents: no parent interface" );
      93           0 :     if( !xParentIfc.is() )
      94             :         return;
      95           0 :     uno::Reference< container::XIndexAccess > xIndexAcc( xParentIfc, uno::UNO_QUERY );
      96             :     uno::Reference< script::XEventAttacherManager > xEventManager( xParentIfc,
      97           0 :                                                               uno::UNO_QUERY );
      98           0 :     if( !xIndexAcc.is() || !xEventManager.is() )
      99             :         return;
     100             : 
     101             :     // Und die Position des ControlModel darin suchen
     102           0 :     sal_Int32 nCount = xIndexAcc->getCount(), nPos;
     103           0 :     for( nPos = 0 ; nPos < nCount; nPos++ )
     104             :     {
     105           0 :         uno::Any aTmp = xIndexAcc->getByIndex(nPos);
     106             :         OSL_ENSURE( aTmp.getValueType() ==
     107             :                         ::getCppuType( (uno::Reference<form::XFormComponent>*)0 ) ||
     108             :                 aTmp.getValueType() ==
     109             :                         ::getCppuType( (uno::Reference<form::XForm>*)0 ),
     110             :                 "lcl_html_outEvents: falsche Reflection" );
     111           0 :         if( aTmp.getValueType() ==
     112           0 :                     ::getCppuType( (uno::Reference< form::XFormComponent >*)0) )
     113             : 
     114             :         {
     115           0 :             if( rFormComp ==
     116           0 :                     *(uno::Reference< form::XFormComponent > *)aTmp.getValue() )
     117             :                 break;
     118             :         }
     119           0 :         else if( aTmp.getValueType() ==
     120           0 :                             ::getCppuType( (uno::Reference< form::XForm>*)0) )
     121             :         {
     122             :             uno::Reference< form::XFormComponent > xFC(
     123           0 :                 *(uno::Reference< form::XForm > *)aTmp.getValue(), uno::UNO_QUERY );
     124           0 :             if( rFormComp == xFC )
     125           0 :                 break;
     126             :         }
     127           0 :     }
     128             : 
     129           0 :     if( nPos == nCount )
     130             :         return;
     131             : 
     132             :     uno::Sequence< script::ScriptEventDescriptor > aDescs =
     133           0 :             xEventManager->getScriptEvents( nPos );
     134           0 :     nCount = aDescs.getLength();
     135           0 :     if( !nCount )
     136             :         return;
     137             : 
     138           0 :     const script::ScriptEventDescriptor *pDescs = aDescs.getConstArray();
     139           0 :     for( sal_Int32 i = 0; i < nCount; i++ )
     140             :     {
     141           0 :         ScriptType eScriptType = EXTENDED_STYPE;
     142           0 :         String aScriptType( pDescs[i].ScriptType );
     143           0 :         if( aScriptType.EqualsIgnoreCaseAscii(SVX_MACRO_LANGUAGE_JAVASCRIPT) )
     144           0 :             eScriptType = JAVASCRIPT;
     145           0 :         else if( aScriptType.EqualsIgnoreCaseAscii(SVX_MACRO_LANGUAGE_STARBASIC ) )
     146           0 :             eScriptType = STARBASIC;
     147           0 :         if( JAVASCRIPT != eScriptType && !bCfgStarBasic )
     148           0 :             continue;
     149             : 
     150           0 :         String sListener( pDescs[i].ListenerType );
     151           0 :         xub_StrLen nTok = comphelper::string::getTokenCount(sListener, '.');
     152           0 :         if( nTok )
     153           0 :             sListener = sListener.GetToken( nTok-1, '.' );
     154           0 :         String sMethod( pDescs[i].EventMethod );
     155             : 
     156           0 :         const sal_Char *pOpt = 0;
     157           0 :         for( sal_uInt16 j=0; aEventListenerTable[j]; j++ )
     158             :         {
     159           0 :             if( sListener.EqualsAscii( aEventListenerTable[j] ) &&
     160           0 :                 sMethod.EqualsAscii( aEventMethodTable[j] ) )
     161             :             {
     162             :                 pOpt = (STARBASIC==eScriptType ? aEventSDOptionTable
     163           0 :                                                : aEventOptionTable)[j];
     164           0 :                 break;
     165             :             }
     166             :         }
     167             : 
     168           0 :         rtl::OStringBuffer sOut;
     169           0 :         sOut.append(' ');
     170           0 :         if( pOpt && (EXTENDED_STYPE != eScriptType ||
     171           0 :                      pDescs[i].AddListenerParam.isEmpty()) )
     172           0 :             sOut.append(pOpt);
     173             :         else
     174             :         {
     175           0 :             sOut.append(OOO_STRING_SVTOOLS_HTML_O_sdevent)
     176             :                 .append(rtl::OUStringToOString(sListener,
     177           0 :                     RTL_TEXTENCODING_ASCII_US))
     178           0 :                 .append('-')
     179             :                 .append(rtl::OUStringToOString(sMethod,
     180           0 :                     RTL_TEXTENCODING_ASCII_US));
     181             :         }
     182           0 :         sOut.append("=\"");
     183           0 :         rStrm << sOut.makeStringAndClear().getStr();
     184           0 :         HTMLOutFuncs::Out_String( rStrm, pDescs[i].ScriptCode, eDestEnc, pNonConvertableChars );
     185           0 :         rStrm << '\"';
     186           0 :         if( EXTENDED_STYPE == eScriptType &&
     187           0 :             !pDescs[i].AddListenerParam.isEmpty() )
     188             :         {
     189           0 :             sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_sdaddparam)
     190             :                 .append(rtl::OUStringToOString(sListener,
     191           0 :                     RTL_TEXTENCODING_ASCII_US))
     192           0 :                 .append('-')
     193             :                 .append(rtl::OUStringToOString(sMethod,
     194           0 :                     RTL_TEXTENCODING_ASCII_US))
     195           0 :                 .append("=\"");
     196           0 :             rStrm << sOut.makeStringAndClear().getStr();
     197           0 :             HTMLOutFuncs::Out_String( rStrm, pDescs[i].AddListenerParam,
     198           0 :                                       eDestEnc, pNonConvertableChars );
     199           0 :             rStrm << '\"';
     200             :         }
     201           0 :     }
     202             : }
     203             : 
     204           0 : static sal_Bool lcl_html_isHTMLControl( sal_Int16 nClassId )
     205             : {
     206           0 :     sal_Bool bRet = sal_False;
     207             : 
     208           0 :     switch( nClassId )
     209             :     {
     210             :     case form::FormComponentType::TEXTFIELD:
     211             :     case form::FormComponentType::COMMANDBUTTON:
     212             :     case form::FormComponentType::RADIOBUTTON:
     213             :     case form::FormComponentType::CHECKBOX:
     214             :     case form::FormComponentType::LISTBOX:
     215             :     case form::FormComponentType::IMAGEBUTTON:
     216             :     case form::FormComponentType::FILECONTROL:
     217           0 :         bRet = sal_True;
     218           0 :         break;
     219             :     }
     220             : 
     221           0 :     return bRet;
     222             : }
     223             : 
     224           0 : sal_Bool SwHTMLWriter::HasControls() const
     225             : {
     226           0 :     sal_uInt32 nStartIdx = pCurPam->GetPoint()->nNode.GetIndex();
     227             :     sal_uInt16 i;
     228             : 
     229             :     // Skip all controls in front of the current paragraph
     230           0 :     for( i = 0; i < aHTMLControls.size() &&
     231           0 :         aHTMLControls[i]->nNdIdx < nStartIdx; i++ )
     232             :         ;
     233             : 
     234           0 :     return i < aHTMLControls.size() && aHTMLControls[i]->nNdIdx == nStartIdx;
     235             : }
     236             : 
     237           0 : void SwHTMLWriter::OutForm( sal_Bool bTag_On, const SwStartNode *pStartNd )
     238             : {
     239           0 :     if( bPreserveForm )     // wir sind in einer Tabelle oder einem Bereich
     240             :         return;             // ueber dem eine Form aufgespannt wurde
     241             : 
     242           0 :     if( !bTag_On )
     243             :     {
     244             :         // die Form beenden wenn alle Controls ausgegeben wurden
     245           0 :         if( pxFormComps && pxFormComps->is() &&
     246           0 :             (*pxFormComps)->getCount() == nFormCntrlCnt )
     247             :         {
     248           0 :             OutForm( sal_False, *pxFormComps );
     249           0 :             (*pxFormComps) = 0;
     250             :         }
     251             :         return;
     252             :     }
     253             : 
     254           0 :     uno::Reference< container::XIndexContainer > xNewFormComps;  // die neue Form
     255           0 :     sal_uInt32 nStartIdx = pStartNd ? pStartNd->GetIndex()
     256           0 :                                     : pCurPam->GetPoint()->nNode.GetIndex();
     257             : 
     258             :     // Ueberspringen von Controls vor dem interesanten Bereich
     259             :     sal_uInt16 i;
     260           0 :     for( i = 0; i < aHTMLControls.size() &&
     261           0 :         aHTMLControls[i]->nNdIdx < nStartIdx; i++ )
     262             :         ;
     263             : 
     264           0 :     if( !pStartNd )
     265             :     {
     266             :         // Check fuer einen einzelnen Node: da ist nur interessant, ob
     267             :         // es zu dem Node ein Control gibt und zu welcher Form es gehoert
     268           0 :         if( i < aHTMLControls.size() &&
     269           0 :             aHTMLControls[i]->nNdIdx == nStartIdx )
     270           0 :             xNewFormComps = aHTMLControls[i]->xFormComps;
     271             :     }
     272             :     else
     273             :     {
     274             :         // wir klappern eine Tabelle/einen Bereich ab: hier interessiert uns:
     275             :         // - ob es Controls mit unterschiedlichen Start-Nodes gibt
     276             :         // - ob es eine Form gibt, fuer die nicht alle Controls in der
     277             :         //   Tabelle/dem Bereich liegen
     278             : 
     279           0 :         uno::Reference< container::XIndexContainer > xCurrentFormComps;// die aktuelle Form in der Tabelle
     280           0 :         const SwStartNode *pCurrentStNd = 0; // und der Start-Node eines Ctrls
     281           0 :         xub_StrLen nCurrentCtrls = 0;   // und die in ihr gefundenen Controls
     282           0 :         sal_uInt32 nEndIdx =  pStartNd->EndOfSectionIndex();
     283           0 :         for( ; i < aHTMLControls.size() &&
     284           0 :             aHTMLControls[i]->nNdIdx <= nEndIdx; i++ )
     285             :         {
     286             :             const SwStartNode *pCntrlStNd =
     287           0 :                 pDoc->GetNodes()[aHTMLControls[i]->nNdIdx]->StartOfSectionNode();
     288             : 
     289           0 :             if( xCurrentFormComps.is() )
     290             :             {
     291             :                 // Wir befinden uns bereits in einer Form ...
     292           0 :                 if( xCurrentFormComps==aHTMLControls[i]->xFormComps )
     293             :                 {
     294             :                     // ... und das Control befindet sich auch darin ...
     295           0 :                     if( pCurrentStNd!=pCntrlStNd )
     296             :                     {
     297             :                         // ... aber es liegt in einer anderen Zelle:
     298             :                         // Dann muessen eir eine Form ueber der Tabelle
     299             :                         // aufmachen
     300           0 :                         xNewFormComps = xCurrentFormComps;
     301           0 :                         break;
     302             :                     }
     303           0 :                     nCurrentCtrls = nCurrentCtrls + aHTMLControls[i]->nCount;
     304             :                 }
     305             :                 else
     306             :                 {
     307             :                     // ... aber das Control liegt in einer anderen Zelle:
     308             :                     // Da tun wir so, als ob wir eine neue Form aufmachen
     309             :                     // und suchen weiter.
     310           0 :                     xCurrentFormComps = aHTMLControls[i]->xFormComps;
     311           0 :                     pCurrentStNd = pCntrlStNd;
     312           0 :                     nCurrentCtrls = aHTMLControls[i]->nCount;
     313             :                 }
     314             :             }
     315             :             else
     316             :             {
     317             :                 // Wir befinden uns noch in keiner Form:
     318             :                 // Da tun wir mal so, als ob wie wir die Form aufmachen.
     319           0 :                 xCurrentFormComps = aHTMLControls[i]->xFormComps;
     320           0 :                 pCurrentStNd = pCntrlStNd;
     321           0 :                 nCurrentCtrls = aHTMLControls[i]->nCount;
     322             :             }
     323             :         }
     324           0 :         if( !xNewFormComps.is() && xCurrentFormComps.is() &&
     325           0 :             nCurrentCtrls != xCurrentFormComps->getCount() )
     326             :         {
     327             :             // In der Tablle/dem Bereich sollte eine Form aufgemacht werden,
     328             :             // die nicht vollstaendig in der Tabelle liegt. Dan muessen
     329             :             // wie die Form jetzt ebenfalls oeffen.
     330           0 :             xNewFormComps = xCurrentFormComps;
     331           0 :         }
     332             :     }
     333             : 
     334           0 :     if( xNewFormComps.is() &&
     335           0 :         (!pxFormComps || !(xNewFormComps == *pxFormComps)) )
     336             :     {
     337             :         // Es soll eine Form aufgemacht werden ...
     338           0 :         if( pxFormComps && pxFormComps->is() )
     339             :         {
     340             :             // .. es ist aber noch eine Form offen: Das ist in
     341             :             // jedem Fall eine Fehler, aber wir schliessen die alte
     342             :             // Form trotzdem
     343           0 :             OutForm( sal_False, *pxFormComps );
     344             : 
     345             :             //!!!nWarn = 1; // Control wird falscher Form zugeordnet
     346             :         }
     347             : 
     348           0 :         if( !pxFormComps )
     349           0 :             pxFormComps = new uno::Reference< container::XIndexContainer > ;
     350           0 :         *pxFormComps = xNewFormComps;
     351             : 
     352           0 :         OutForm( sal_True, *pxFormComps );
     353           0 :         uno::Reference< beans::XPropertySet >  xTmp;
     354           0 :         OutHiddenControls( *pxFormComps, xTmp );
     355           0 :     }
     356             : }
     357             : 
     358           0 : void SwHTMLWriter::OutHiddenForms()
     359             : {
     360             :     // Ohne DrawModel kann es auch keine Controls geben. Dann darf man
     361             :     // auch nicht per UNO auf das Dok zugreifen, weil sonst ein DrawModel
     362             :     // angelegt wird.
     363           0 :     if( !pDoc->GetDrawModel() )
     364             :         return;
     365             : 
     366           0 :     SwDocShell *pDocSh = pDoc->GetDocShell();
     367           0 :     if( !pDocSh )
     368             :         return;
     369             : 
     370             :     uno::Reference< drawing::XDrawPageSupplier > xDPSupp( pDocSh->GetBaseModel(),
     371           0 :                                                      uno::UNO_QUERY );
     372             :     OSL_ENSURE( xDPSupp.is(), "XTextDocument nicht vom XModel erhalten" );
     373           0 :     uno::Reference< drawing::XDrawPage > xDrawPage = xDPSupp->getDrawPage();
     374             : 
     375             :     OSL_ENSURE( xDrawPage.is(), "XDrawPage nicht erhalten" );
     376           0 :     if( !xDrawPage.is() )
     377             :         return;
     378             : 
     379           0 :     uno::Reference< form::XFormsSupplier > xFormsSupplier( xDrawPage, uno::UNO_QUERY );
     380             :     OSL_ENSURE( xFormsSupplier.is(),
     381             :             "XFormsSupplier nicht vom XDrawPage erhalten" );
     382             : 
     383           0 :     uno::Reference< container::XNameContainer > xTmp = xFormsSupplier->getForms();
     384             :     OSL_ENSURE( xTmp.is(), "XForms nicht erhalten" );
     385           0 :     uno::Reference< container::XIndexContainer > xForms( xTmp, uno::UNO_QUERY );
     386             :     OSL_ENSURE( xForms.is(), "XForms ohne container::XIndexContainer?" );
     387             : 
     388           0 :     sal_Int32 nCount = xForms->getCount();
     389           0 :     for( sal_Int32 i=0; i<nCount; i++)
     390             :     {
     391           0 :         uno::Any aTmp = xForms->getByIndex( i );
     392             :         OSL_ENSURE( aTmp.getValueType() ==
     393             :                         ::getCppuType((uno::Reference< form::XForm >*)0),
     394             :                 "OutHiddenForms: falsche Reflection" );
     395           0 :         if( aTmp.getValueType() ==
     396           0 :                     ::getCppuType((uno::Reference< form::XForm >*)0) )
     397           0 :             OutHiddenForm( *(uno::Reference< form::XForm > *)aTmp.getValue() );
     398           0 :     }
     399             : }
     400             : 
     401           0 : void SwHTMLWriter::OutHiddenForm( const uno::Reference< form::XForm > & rForm )
     402             : {
     403           0 :     uno::Reference< container::XIndexContainer > xFormComps( rForm, uno::UNO_QUERY );
     404           0 :     if( !xFormComps.is() )
     405           0 :         return;
     406             : 
     407           0 :     sal_Int32 nCount = xFormComps->getCount();
     408           0 :     sal_Bool bHiddenOnly = nCount > 0, bHidden = sal_False;
     409           0 :     for( sal_Int32 i=0; i<nCount; i++ )
     410             :     {
     411           0 :         uno::Any aTmp = xFormComps->getByIndex( i );
     412             :         OSL_ENSURE( aTmp.getValueType() ==
     413             :                         ::getCppuType((uno::Reference<form::XFormComponent>*)0),
     414             :                 "OutHiddenForm: falsche Reflection" );
     415           0 :         if( aTmp.getValueType() !=
     416           0 :                     ::getCppuType((uno::Reference<form::XFormComponent>*)0) )
     417           0 :             continue;
     418             : 
     419             :         uno::Reference< form::XFormComponent > xFormComp =
     420           0 :             *(uno::Reference< form::XFormComponent > *)aTmp.getValue();
     421           0 :         uno::Reference< form::XForm > xForm( xFormComp, uno::UNO_QUERY );
     422           0 :         if( xForm.is() )
     423           0 :             OutHiddenForm( xForm );
     424             : 
     425           0 :         if( bHiddenOnly )
     426             :         {
     427           0 :             uno::Reference< beans::XPropertySet >  xPropSet( xFormComp, uno::UNO_QUERY );
     428           0 :             OUString sPropName(RTL_CONSTASCII_USTRINGPARAM("ClassId"));
     429           0 :             if( xPropSet->getPropertySetInfo()->hasPropertyByName( sPropName ) )
     430             :             {
     431           0 :                 uno::Any aAny2 = xPropSet->getPropertyValue( sPropName );
     432           0 :                 if( aAny2.getValueType() == ::getCppuType((sal_Int16*)0) )
     433             :                 {
     434           0 :                     if( form::FormComponentType::HIDDENCONTROL ==
     435           0 :                                                 *(sal_Int16*)aAny2.getValue() )
     436           0 :                         bHidden = sal_True;
     437           0 :                     else if( lcl_html_isHTMLControl(
     438           0 :                                             *(sal_Int16*)aAny2.getValue() ) )
     439           0 :                         bHiddenOnly = sal_False;
     440           0 :                 }
     441           0 :             }
     442             :         }
     443           0 :     }
     444             : 
     445           0 :     if( bHidden && bHiddenOnly )
     446             :     {
     447           0 :         OutForm( sal_True, xFormComps );
     448           0 :         uno::Reference< beans::XPropertySet > xTmp;
     449           0 :         OutHiddenControls( xFormComps, xTmp );
     450           0 :         OutForm( sal_False, xFormComps );
     451           0 :     }
     452             : }
     453             : 
     454           0 : void SwHTMLWriter::OutForm( sal_Bool bOn,
     455             :                 const uno::Reference< container::XIndexContainer > & rFormComps )
     456             : {
     457           0 :     nFormCntrlCnt = 0;
     458             : 
     459           0 :     if( !bOn )
     460             :     {
     461           0 :         DecIndentLevel(); // Inhalt der Form einruecken
     462           0 :         if( bLFPossible )
     463           0 :             OutNewLine();
     464           0 :         HTMLOutFuncs::Out_AsciiTag( Strm(), OOO_STRING_SVTOOLS_HTML_form, sal_False );
     465           0 :         bLFPossible = sal_True;
     466             : 
     467           0 :         return;
     468             :     }
     469             : 
     470             :     // die neue Form wird geoeffnet
     471           0 :     if( bLFPossible )
     472           0 :         OutNewLine();
     473           0 :     rtl::OStringBuffer sOut;
     474           0 :     sOut.append('<').append(OOO_STRING_SVTOOLS_HTML_form);
     475             : 
     476           0 :     uno::Reference< beans::XPropertySet > xFormPropSet( rFormComps, uno::UNO_QUERY );
     477             : 
     478           0 :     uno::Any aTmp = xFormPropSet->getPropertyValue(
     479           0 :                                     OUString(RTL_CONSTASCII_USTRINGPARAM("Name")) );
     480           0 :     if( aTmp.getValueType() == ::getCppuType((const OUString*)0) &&
     481           0 :         !((OUString*)aTmp.getValue())->isEmpty() )
     482             :     {
     483           0 :         sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_name).append("=\"");
     484           0 :         Strm() << sOut.makeStringAndClear().getStr();
     485           0 :         HTMLOutFuncs::Out_String( Strm(), *(OUString*)aTmp.getValue(),
     486           0 :                                   eDestEnc, &aNonConvertableCharacters );
     487           0 :         sOut.append('\"');
     488             :     }
     489             : 
     490           0 :     aTmp = xFormPropSet->getPropertyValue(
     491           0 :                     OUString(RTL_CONSTASCII_USTRINGPARAM("TargetURL")) );
     492           0 :     if( aTmp.getValueType() == ::getCppuType((const OUString*)0) &&
     493           0 :         !((OUString*)aTmp.getValue())->isEmpty() )
     494             :     {
     495           0 :         sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_action).append("=\"");
     496           0 :         Strm() << sOut.makeStringAndClear().getStr();
     497           0 :         String aURL( *(OUString*)aTmp.getValue() );
     498           0 :         aURL = URIHelper::simpleNormalizedMakeRelative( GetBaseURL(), aURL);
     499           0 :         HTMLOutFuncs::Out_String( Strm(), aURL, eDestEnc, &aNonConvertableCharacters );
     500           0 :         sOut.append('\"');
     501             :     }
     502             : 
     503           0 :     aTmp = xFormPropSet->getPropertyValue(
     504           0 :                     OUString(RTL_CONSTASCII_USTRINGPARAM("SubmitMethod")) );
     505           0 :     if( aTmp.getValueType() == ::getCppuType((const form::FormSubmitMethod*)0) )
     506             :     {
     507             :         form::FormSubmitMethod eMethod =
     508           0 :                 *( form::FormSubmitMethod*)aTmp.getValue();
     509           0 :         if( form::FormSubmitMethod_POST==eMethod )
     510             :         {
     511           0 :             sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_method)
     512           0 :                 .append("=\"").append(OOO_STRING_SVTOOLS_HTML_METHOD_post)
     513           0 :                 .append('\"');
     514             :         }
     515             :     }
     516           0 :     aTmp = xFormPropSet->getPropertyValue(
     517           0 :                     OUString(RTL_CONSTASCII_USTRINGPARAM("SubmitEncoding")) );
     518           0 :     if( aTmp.getValueType()==::getCppuType((const form::FormSubmitEncoding*)0) )
     519             :     {
     520             :         form::FormSubmitEncoding eEncType =
     521           0 :                     *( form::FormSubmitEncoding*)aTmp.getValue();
     522           0 :         const sal_Char *pStr = 0;
     523           0 :         switch( eEncType )
     524             :         {
     525             :         case form::FormSubmitEncoding_MULTIPART:
     526           0 :             pStr = OOO_STRING_SVTOOLS_HTML_ET_multipart;
     527           0 :             break;
     528             :         case form::FormSubmitEncoding_TEXT:
     529           0 :             pStr = OOO_STRING_SVTOOLS_HTML_ET_text;
     530           0 :             break;
     531             :         default:
     532             :             ;
     533             :         }
     534             : 
     535           0 :         if( pStr )
     536             :         {
     537           0 :             sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_enctype)
     538           0 :                 .append("=\"").append(pStr).append('\"');
     539             :         }
     540             :     }
     541             : 
     542           0 :     aTmp = xFormPropSet->getPropertyValue(
     543           0 :                         OUString(RTL_CONSTASCII_USTRINGPARAM("TargetFrame")) );
     544           0 :     if( aTmp.getValueType() == ::getCppuType((const OUString*)0)&&
     545           0 :         !((OUString*)aTmp.getValue())->isEmpty() )
     546             :     {
     547           0 :         sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_target).append("=\"");
     548           0 :         Strm() << sOut.makeStringAndClear().getStr();
     549           0 :         HTMLOutFuncs::Out_String( Strm(), *(OUString*)aTmp.getValue(),
     550           0 :                                   eDestEnc, &aNonConvertableCharacters );
     551           0 :         sOut.append('\"');
     552             :     }
     553             : 
     554           0 :     Strm() << sOut.makeStringAndClear().getStr();
     555           0 :     uno::Reference< form::XFormComponent > xFormComp( rFormComps, uno::UNO_QUERY );
     556           0 :     lcl_html_outEvents( Strm(), xFormComp, bCfgStarBasic, eDestEnc, &aNonConvertableCharacters );
     557           0 :     Strm() << '>';
     558             : 
     559           0 :     IncIndentLevel(); // Inhalt der Form einruecken
     560           0 :     bLFPossible = sal_True;
     561             : }
     562             : 
     563           0 : void SwHTMLWriter::OutHiddenControls(
     564             :         const uno::Reference< container::XIndexContainer > & rFormComps,
     565             :         const uno::Reference< beans::XPropertySet > & rPropSet )
     566             : {
     567           0 :     sal_Int32 nCount = rFormComps->getCount();
     568           0 :     sal_Int32 nPos = 0;
     569           0 :     sal_Bool bDone = sal_False;
     570           0 :     if( rPropSet.is() )
     571             :     {
     572           0 :         uno::Reference< form::XFormComponent > xFC( rPropSet, uno::UNO_QUERY );
     573           0 :         for( nPos=0; !bDone && nPos < nCount; nPos++ )
     574             :         {
     575           0 :             uno::Any aTmp = rFormComps->getByIndex( nPos );
     576             :             OSL_ENSURE( aTmp.getValueType() ==
     577             :                         ::getCppuType((uno::Reference< form::XFormComponent>*)0),
     578             :                     "OutHiddenControls: falsche Reflection" );
     579           0 :             bDone = aTmp.getValueType() ==
     580           0 :                         ::getCppuType((uno::Reference< form::XFormComponent>*)0) &&
     581           0 :                     *(uno::Reference< form::XFormComponent > *)aTmp.getValue() ==
     582           0 :                         xFC;
     583           0 :         }
     584             :     }
     585             : 
     586           0 :     for( ; nPos < nCount; nPos++ )
     587             :     {
     588           0 :         uno::Any aTmp = rFormComps->getByIndex( nPos );
     589             :         OSL_ENSURE( aTmp.getValueType() ==
     590             :                         ::getCppuType((uno::Reference< form::XFormComponent>*)0),
     591             :                 "OutHiddenControls: falsche Reflection" );
     592           0 :         if( aTmp.getValueType() !=
     593           0 :                     ::getCppuType((uno::Reference< form::XFormComponent>*)0) )
     594           0 :             continue;
     595             :         uno::Reference< form::XFormComponent > xFC =
     596           0 :                 *(uno::Reference< form::XFormComponent > *)aTmp.getValue();
     597           0 :         uno::Reference< beans::XPropertySet > xPropSet( xFC, uno::UNO_QUERY );
     598             : 
     599           0 :         OUString sPropName = OUString(RTL_CONSTASCII_USTRINGPARAM("ClassId"));
     600           0 :         if( !xPropSet->getPropertySetInfo()->hasPropertyByName( sPropName ) )
     601           0 :             continue;
     602             : 
     603           0 :         aTmp = xPropSet->getPropertyValue( sPropName );
     604           0 :         if( aTmp.getValueType() != ::getCppuType((const sal_Int16*)0) )
     605           0 :             continue;
     606             : 
     607           0 :         if( form::FormComponentType::HIDDENCONTROL ==
     608           0 :                                             *(sal_Int16*) aTmp.getValue() )
     609             :         {
     610           0 :             if( bLFPossible )
     611           0 :                 OutNewLine( sal_True );
     612           0 :             rtl::OStringBuffer sOut;
     613           0 :             sOut.append('<').append(OOO_STRING_SVTOOLS_HTML_input).append(' ')
     614           0 :                 .append(OOO_STRING_SVTOOLS_HTML_O_type).append('=')
     615           0 :                 .append(OOO_STRING_SVTOOLS_HTML_IT_hidden);
     616             : 
     617           0 :             aTmp = xPropSet->getPropertyValue(
     618           0 :                             OUString(RTL_CONSTASCII_USTRINGPARAM("Name")) );
     619           0 :             if( aTmp.getValueType() == ::getCppuType((const OUString*)0) &&
     620           0 :                 !((OUString*)aTmp.getValue())->isEmpty() )
     621             :             {
     622           0 :                 sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_name)
     623           0 :                     .append("=\"");
     624           0 :                 Strm() << sOut.makeStringAndClear().getStr();
     625           0 :                 HTMLOutFuncs::Out_String( Strm(), *(OUString*)aTmp.getValue(),
     626           0 :                                           eDestEnc, &aNonConvertableCharacters );
     627           0 :                 sOut.append('\"');
     628             :             }
     629           0 :             aTmp = xPropSet->getPropertyValue(
     630           0 :                             OUString(RTL_CONSTASCII_USTRINGPARAM("HiddenValue")) );
     631           0 :             if( aTmp.getValueType() == ::getCppuType((const OUString*)0) &&
     632           0 :                 !((OUString*)aTmp.getValue())->isEmpty() )
     633             :             {
     634           0 :                 sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_value)
     635           0 :                     .append("=\"");
     636           0 :                 Strm() << sOut.makeStringAndClear().getStr();
     637           0 :                 HTMLOutFuncs::Out_String( Strm(), *(OUString*)aTmp.getValue(),
     638           0 :                                           eDestEnc, &aNonConvertableCharacters );
     639           0 :                 sOut.append('\"');
     640             :             }
     641           0 :             sOut.append('>');
     642           0 :             Strm() << sOut.makeStringAndClear().getStr();
     643             : 
     644           0 :             nFormCntrlCnt++;
     645             :         }
     646           0 :         else if( lcl_html_isHTMLControl( *(sal_Int16*) aTmp.getValue() ) )
     647             :         {
     648             :             break;
     649             :         }
     650           0 :     }
     651           0 : }
     652             : 
     653             : 
     654             : // hier folgen die Ausgabe-Routinen, dadurch sind die form::Forms gebuendelt:
     655             : 
     656           0 : const SdrObject *SwHTMLWriter::GetHTMLControl( const SwDrawFrmFmt& rFmt )
     657             : {
     658             :     // es muss ein Draw-Format sein
     659             :     OSL_ENSURE( RES_DRAWFRMFMT == rFmt.Which(),
     660             :             "GetHTMLControl nuer fuer Draw-Formate erlaubt" );
     661             : 
     662             :     // Schauen, ob es ein SdrObject dafuer gibt
     663           0 :     const SdrObject *pObj = rFmt.FindSdrObject();
     664           0 :     if( !pObj || FmFormInventor != pObj->GetObjInventor() )
     665           0 :         return 0;
     666             : 
     667           0 :     SdrUnoObj *pFormObj = PTR_CAST( SdrUnoObj, pObj );
     668             :     uno::Reference< awt::XControlModel >  xControlModel =
     669           0 :             pFormObj->GetUnoControlModel();
     670             : 
     671             :     OSL_ENSURE( xControlModel.is(), "UNO-Control ohne Model" );
     672           0 :     if( !xControlModel.is() )
     673           0 :         return 0;
     674             : 
     675           0 :     uno::Reference< beans::XPropertySet >  xPropSet( xControlModel, uno::UNO_QUERY );
     676             : 
     677           0 :     OUString sPropName(RTL_CONSTASCII_USTRINGPARAM("ClassId"));
     678           0 :     if( !xPropSet->getPropertySetInfo()->hasPropertyByName( sPropName ) )
     679           0 :         return 0;
     680             : 
     681           0 :     uno::Any aTmp = xPropSet->getPropertyValue( sPropName );
     682           0 :     if( aTmp.getValueType() == ::getCppuType((const sal_Int16*)0)&&
     683           0 :         lcl_html_isHTMLControl( *(sal_Int16*) aTmp.getValue() ) )
     684             :     {
     685           0 :         return pObj;
     686             :     }
     687             : 
     688           0 :     return 0;
     689             : }
     690             : 
     691           0 : static void GetControlSize( const SdrObject& rSdrObj, Size& rSz,
     692             :                             SwDoc *pDoc )
     693             : {
     694           0 :     ViewShell *pVSh = 0;
     695           0 :     pDoc->GetEditShell( &pVSh );
     696           0 :     if( !pVSh )
     697             :         return;
     698             : 
     699           0 :     SdrUnoObj *pFormObj = PTR_CAST( SdrUnoObj, &rSdrObj );
     700           0 :     uno::Reference< awt::XControl >  xControl;
     701           0 :     SdrView* pDrawView = pVSh->GetDrawView();
     702             :     OSL_ENSURE( pDrawView && pVSh->GetWin(), "no DrawView or window!" );
     703           0 :     if ( pDrawView && pVSh->GetWin() )
     704           0 :         xControl = pFormObj->GetUnoControl( *pDrawView, *pVSh->GetWin() );
     705           0 :     uno::Reference< awt::XTextLayoutConstrains > xLC( xControl, uno::UNO_QUERY );
     706             :     OSL_ENSURE( xLC.is(), "kein XTextLayoutConstrains" );
     707           0 :     if( !xLC.is() )
     708             :         return;
     709             : 
     710           0 :     sal_Int16 nCols=0, nLines=0;
     711           0 :     xLC->getColumnsAndLines( nCols, nLines );
     712           0 :     rSz.Width() = nCols;
     713           0 :     rSz.Height() = nLines;
     714             : }
     715             : 
     716           0 : Writer& OutHTML_DrawFrmFmtAsControl( Writer& rWrt,
     717             :                                      const SwDrawFrmFmt& rFmt,
     718             :                                      const SdrObject& rSdrObject,
     719             :                                      sal_Bool bInCntnr )
     720             : {
     721           0 :     SwHTMLWriter & rHTMLWrt = (SwHTMLWriter&)rWrt;
     722             : 
     723           0 :     SdrUnoObj *pFormObj = PTR_CAST( SdrUnoObj, &rSdrObject );
     724             :     uno::Reference< awt::XControlModel > xControlModel =
     725           0 :         pFormObj->GetUnoControlModel();
     726             : 
     727             :     OSL_ENSURE( xControlModel.is(), "UNO-Control ohne Model" );
     728           0 :     if( !xControlModel.is() )
     729           0 :         return rWrt;
     730             : 
     731           0 :     uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY );
     732             :     uno::Reference< beans::XPropertySetInfo > xPropSetInfo =
     733           0 :             xPropSet->getPropertySetInfo();
     734             : 
     735           0 :     rHTMLWrt.nFormCntrlCnt++;
     736             : 
     737             :     enum Tag { TAG_INPUT, TAG_SELECT, TAG_TEXTAREA, TAG_NONE };
     738             :     static char const * const TagNames[] = {
     739             :         OOO_STRING_SVTOOLS_HTML_input, OOO_STRING_SVTOOLS_HTML_select,
     740             :         OOO_STRING_SVTOOLS_HTML_textarea };
     741           0 :     Tag eTag = TAG_INPUT;
     742             :     enum Type {
     743             :         TYPE_TEXT, TYPE_PASSWORD, TYPE_CHECKBOX, TYPE_RADIO, TYPE_FILE,
     744             :         TYPE_SUBMIT, TYPE_IMAGE, TYPE_RESET, TYPE_BUTTON, TYPE_NONE };
     745             :     static char const * const TypeNames[] = {
     746             :         OOO_STRING_SVTOOLS_HTML_IT_text, OOO_STRING_SVTOOLS_HTML_IT_password,
     747             :         OOO_STRING_SVTOOLS_HTML_IT_checkbox, OOO_STRING_SVTOOLS_HTML_IT_radio,
     748             :         OOO_STRING_SVTOOLS_HTML_IT_file, OOO_STRING_SVTOOLS_HTML_IT_submit,
     749             :         OOO_STRING_SVTOOLS_HTML_IT_image, OOO_STRING_SVTOOLS_HTML_IT_reset,
     750             :         OOO_STRING_SVTOOLS_HTML_IT_button };
     751           0 :     Type eType = TYPE_NONE;
     752           0 :     OUString sValue;
     753           0 :     rtl::OStringBuffer sOptions;
     754           0 :     sal_Bool bEmptyValue = sal_False;
     755           0 :     uno::Any aTmp = xPropSet->getPropertyValue(
     756           0 :                     OUString(RTL_CONSTASCII_USTRINGPARAM("ClassId")) );
     757           0 :     sal_Int16 nClassId = *(sal_Int16*) aTmp.getValue();
     758           0 :     sal_uInt32 nFrmOpts = HTML_FRMOPTS_CONTROL;
     759           0 :     switch( nClassId )
     760             :     {
     761             :     case form::FormComponentType::CHECKBOX:
     762             :     case form::FormComponentType::RADIOBUTTON:
     763             :         eType = (form::FormComponentType::CHECKBOX == nClassId
     764           0 :                     ? TYPE_CHECKBOX : TYPE_RADIO);
     765           0 :         aTmp = xPropSet->getPropertyValue(
     766           0 :                         OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultState")) );
     767           0 :         if( aTmp.getValueType() == ::getCppuType((const sal_Int16*)0) &&
     768           0 :             STATE_NOCHECK != *(sal_Int16*) aTmp.getValue() )
     769             :         {
     770           0 :             sOptions.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_checked);
     771             :         }
     772             : 
     773           0 :         aTmp = xPropSet->getPropertyValue(
     774           0 :                         OUString(RTL_CONSTASCII_USTRINGPARAM("RefValue")) );
     775           0 :         if( aTmp.getValueType() == ::getCppuType((const OUString*)0) )
     776             : 
     777             :         {
     778           0 :             const OUString& rVal = *(OUString*)aTmp.getValue();
     779           0 :             if( rVal.isEmpty() )
     780           0 :                 bEmptyValue = sal_True;
     781           0 :             else if( rVal.compareToAscii( OOO_STRING_SVTOOLS_HTML_on ) != 0 )
     782           0 :                 sValue = rVal;
     783             :         }
     784           0 :         break;
     785             : 
     786             :     case form::FormComponentType::COMMANDBUTTON:
     787             :         {
     788           0 :             form::FormButtonType eButtonType = form::FormButtonType_PUSH;
     789           0 :             aTmp = xPropSet->getPropertyValue(
     790           0 :                             OUString(RTL_CONSTASCII_USTRINGPARAM("ButtonType")) );
     791           0 :             if( aTmp.getValueType() ==
     792           0 :                             ::getCppuType((const form::FormButtonType*)0) )
     793           0 :                 eButtonType = *( form::FormButtonType*)aTmp.getValue();
     794             : 
     795           0 :             switch( eButtonType )
     796             :             {
     797             :             case form::FormButtonType_RESET:
     798           0 :                 eType = TYPE_RESET;
     799           0 :                 break;
     800             :             case form::FormButtonType_SUBMIT:
     801           0 :                 eType = TYPE_SUBMIT;
     802           0 :                 break;
     803             :             case form::FormButtonType_PUSH:
     804             :             default:
     805           0 :                 eType = TYPE_BUTTON;
     806             :             }
     807             : 
     808           0 :             aTmp = xPropSet->getPropertyValue(
     809           0 :                             OUString(RTL_CONSTASCII_USTRINGPARAM("Label")) );
     810           0 :             if( aTmp.getValueType() == ::getCppuType((const OUString*)0) &&
     811           0 :                 !((OUString*)aTmp.getValue())->isEmpty() )
     812             :             {
     813           0 :                 sValue = *(OUString*)aTmp.getValue();
     814             :             }
     815             :         }
     816           0 :         break;
     817             : 
     818             :     case form::FormComponentType::LISTBOX:
     819           0 :         if( rHTMLWrt.bLFPossible )
     820           0 :             rHTMLWrt.OutNewLine( sal_True );
     821           0 :         eTag = TAG_SELECT;
     822           0 :         aTmp = xPropSet->getPropertyValue(
     823           0 :                         OUString(RTL_CONSTASCII_USTRINGPARAM("Dropdown")) );
     824           0 :         if( aTmp.getValueType() == ::getBooleanCppuType() &&
     825           0 :             !*(sal_Bool*)aTmp.getValue() )
     826             :         {
     827           0 :             Size aSz( 0, 0 );
     828           0 :             GetControlSize( rSdrObject, aSz, rWrt.pDoc );
     829             : 
     830             :             // wieviele sind sichtbar ??
     831           0 :             if( aSz.Height() )
     832             :             {
     833           0 :                 sOptions.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_size).
     834           0 :                     append('=').append(static_cast<sal_Int32>(aSz.Height()));
     835             :             }
     836             : 
     837           0 :             aTmp = xPropSet->getPropertyValue(
     838           0 :                         OUString(RTL_CONSTASCII_USTRINGPARAM("MultiSelection")) );
     839           0 :             if( aTmp.getValueType() == ::getBooleanCppuType() &&
     840           0 :                 *(sal_Bool*)aTmp.getValue() )
     841             :             {
     842           0 :                 sOptions.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_multiple);
     843             :             }
     844             :         }
     845           0 :         break;
     846             : 
     847             :     case form::FormComponentType::TEXTFIELD:
     848             :         {
     849           0 :             Size aSz( 0, 0 );
     850           0 :             GetControlSize( rSdrObject, aSz, rWrt.pDoc );
     851             : 
     852           0 :             sal_Bool bMultiLine = sal_False;
     853           0 :             OUString sMultiLine(RTL_CONSTASCII_USTRINGPARAM("MultiLine"));
     854           0 :             if( xPropSetInfo->hasPropertyByName( sMultiLine ) )
     855             :             {
     856           0 :                 aTmp = xPropSet->getPropertyValue( sMultiLine );
     857           0 :                 bMultiLine = aTmp.getValueType() == ::getBooleanCppuType() &&
     858           0 :                              *(sal_Bool*)aTmp.getValue();
     859             :             }
     860             : 
     861           0 :             if( bMultiLine )
     862             :             {
     863           0 :                 if( rHTMLWrt.bLFPossible )
     864           0 :                     rHTMLWrt.OutNewLine( sal_True );
     865           0 :                 eTag = TAG_TEXTAREA;
     866             : 
     867           0 :                 if( aSz.Height() )
     868             :                 {
     869           0 :                     sOptions.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_rows).
     870           0 :                         append('=').
     871           0 :                         append(static_cast<sal_Int32>(aSz.Height()));
     872             :                 }
     873           0 :                 if( aSz.Width() )
     874             :                 {
     875           0 :                     sOptions.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_cols).
     876           0 :                         append('=').
     877           0 :                         append(static_cast<sal_Int32>(aSz.Width()));
     878             :                 }
     879             : 
     880           0 :                 aTmp = xPropSet->getPropertyValue(
     881           0 :                                 OUString(RTL_CONSTASCII_USTRINGPARAM("HScroll")) );
     882           0 :                 if( aTmp.getValueType() == ::getVoidCppuType() ||
     883           0 :                     (aTmp.getValueType() == ::getBooleanCppuType() &&
     884           0 :                     !*(sal_Bool*)aTmp.getValue()) )
     885             :                 {
     886           0 :                     const sal_Char *pWrapStr = 0;
     887           0 :                     aTmp = xPropSet->getPropertyValue(
     888           0 :                             OUString(RTL_CONSTASCII_USTRINGPARAM("HardLineBreaks")) );
     889             :                     pWrapStr =
     890           0 :                         (aTmp.getValueType() == ::getBooleanCppuType() &&
     891           0 :                         *(sal_Bool*)aTmp.getValue()) ? OOO_STRING_SVTOOLS_HTML_WW_hard
     892           0 :                                                      : OOO_STRING_SVTOOLS_HTML_WW_soft;
     893           0 :                     sOptions.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_wrap).
     894           0 :                         append('=').append(pWrapStr);
     895             :                 }
     896             :             }
     897             :             else
     898             :             {
     899           0 :                 eType = TYPE_TEXT;
     900           0 :                 OUString sEchoChar(RTL_CONSTASCII_USTRINGPARAM("EchoChar"));
     901           0 :                 if( xPropSetInfo->hasPropertyByName( sEchoChar ) )
     902             :                 {
     903           0 :                     aTmp = xPropSet->getPropertyValue( sEchoChar );
     904           0 :                     if( aTmp.getValueType() == ::getCppuType((const sal_Int16*)0) &&
     905           0 :                         *(sal_Int16*)aTmp.getValue() != 0 )
     906           0 :                         eType = TYPE_PASSWORD;
     907             :                 }
     908             : 
     909           0 :                 if( aSz.Width() )
     910             :                 {
     911           0 :                     sOptions.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_size).
     912           0 :                         append('=').append(static_cast<sal_Int32>(aSz.Width()));
     913             :                 }
     914             : 
     915           0 :                 aTmp = xPropSet->getPropertyValue(
     916           0 :                             OUString(RTL_CONSTASCII_USTRINGPARAM("MaxTextLen")) );
     917           0 :                 if( aTmp.getValueType() == ::getCppuType((const sal_Int16*)0) &&
     918           0 :                     *(sal_Int16*) aTmp.getValue() != 0 )
     919             :                 {
     920           0 :                     sOptions.append(' ').
     921           0 :                         append(OOO_STRING_SVTOOLS_HTML_O_maxlength).
     922           0 :                         append('=').append(static_cast<sal_Int32>(
     923           0 :                                 *(sal_Int16*) aTmp.getValue()));
     924             :                 }
     925             : 
     926           0 :                 OUString sDefaultText(RTL_CONSTASCII_USTRINGPARAM("DefaultText"));
     927           0 :                 if( xPropSetInfo->hasPropertyByName( sDefaultText ) )
     928             :                 {
     929           0 :                     aTmp = xPropSet->getPropertyValue( sDefaultText );
     930           0 :                     if( aTmp.getValueType() == ::getCppuType((const OUString*)0) &&
     931           0 :                         !((OUString*)aTmp.getValue())->isEmpty() )
     932             :                     {
     933           0 :                         sValue = *(OUString*)aTmp.getValue();
     934             :                     }
     935           0 :                 }
     936           0 :             }
     937             :         }
     938           0 :         break;
     939             : 
     940             :     case form::FormComponentType::FILECONTROL:
     941             :         {
     942           0 :             Size aSz( 0, 0 );
     943           0 :             GetControlSize( rSdrObject, aSz, rWrt.pDoc );
     944           0 :             eType = TYPE_FILE;
     945             : 
     946           0 :             if( aSz.Width() )
     947             :             {
     948           0 :                 sOptions.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_size).
     949           0 :                     append('=').append(static_cast<sal_Int32>(aSz.Width()));
     950             :             }
     951             : 
     952             :             // VALUE vim form aus Sicherheitsgruenden nicht exportieren
     953             :         }
     954           0 :         break;
     955             : 
     956             : 
     957             :     case form::FormComponentType::IMAGEBUTTON:
     958           0 :         eType = TYPE_IMAGE;
     959           0 :         nFrmOpts = HTML_FRMOPTS_IMG_CONTROL;
     960           0 :         break;
     961             : 
     962             :     default:                // kennt HTML nicht
     963           0 :         eTag = TAG_NONE;        // also ueberspringen
     964           0 :         break;
     965             :     }
     966             : 
     967           0 :     if( eTag == TAG_NONE )
     968           0 :         return rWrt;
     969             : 
     970           0 :     rtl::OStringBuffer sOut;
     971           0 :     sOut.append('<').append(TagNames[eTag]);
     972           0 :     if( eType != TYPE_NONE )
     973             :     {
     974           0 :         sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_type).
     975           0 :             append('=').append(TypeNames[eType]);
     976             :     }
     977             : 
     978           0 :     aTmp = xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("Name")) );
     979           0 :     if( aTmp.getValueType() == ::getCppuType((const OUString*)0) &&
     980           0 :         !((OUString*)aTmp.getValue())->isEmpty() )
     981             :     {
     982           0 :         sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_name).
     983           0 :             append(RTL_CONSTASCII_STRINGPARAM("=\""));
     984           0 :         rWrt.Strm() << sOut.makeStringAndClear().getStr();
     985           0 :         HTMLOutFuncs::Out_String( rWrt.Strm(), *(OUString*)aTmp.getValue(),
     986           0 :                                   rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
     987           0 :         sOut.append('\"');
     988             :     }
     989             : 
     990           0 :     aTmp = xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("Enabled")) );
     991           0 :     if( aTmp.getValueType() == ::getBooleanCppuType() &&
     992           0 :         !*(sal_Bool*)aTmp.getValue() )
     993             :     {
     994           0 :         sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_disabled);
     995             :     }
     996             : 
     997           0 :     if( !sValue.isEmpty() || bEmptyValue )
     998             :     {
     999           0 :         sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_value).append(
    1000           0 :             RTL_CONSTASCII_STRINGPARAM("=\""));
    1001           0 :         rWrt.Strm() << sOut.makeStringAndClear().getStr();
    1002           0 :         HTMLOutFuncs::Out_String( rWrt.Strm(), sValue, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
    1003           0 :         sOut.append('\"');
    1004             :     }
    1005             : 
    1006           0 :     sOut.append(sOptions.makeStringAndClear());
    1007             : 
    1008           0 :     if( TYPE_IMAGE == eType )
    1009             :     {
    1010           0 :         aTmp = xPropSet->getPropertyValue(
    1011           0 :                     OUString(RTL_CONSTASCII_USTRINGPARAM("ImageURL")) );
    1012           0 :         if( aTmp.getValueType() == ::getCppuType((const OUString*)0) &&
    1013           0 :             !((OUString*)aTmp.getValue())->isEmpty() )
    1014             :         {
    1015           0 :             sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_src).
    1016           0 :                 append(RTL_CONSTASCII_STRINGPARAM("=\""));
    1017           0 :             rWrt.Strm() << sOut.makeStringAndClear().getStr();
    1018             : 
    1019           0 :             HTMLOutFuncs::Out_String( rWrt.Strm(),
    1020           0 :                         URIHelper::simpleNormalizedMakeRelative( rWrt.GetBaseURL(), *(OUString*)aTmp.getValue()),
    1021           0 :                         rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
    1022           0 :             sOut.append('\"');
    1023             :         }
    1024             : 
    1025           0 :         Size aTwipSz( rSdrObject.GetLogicRect().GetSize() );
    1026           0 :         Size aPixelSz( 0, 0 );
    1027           0 :         if( (aTwipSz.Width() || aTwipSz.Height()) &&
    1028           0 :             Application::GetDefaultDevice() )
    1029             :         {
    1030             :             aPixelSz =
    1031             :                 Application::GetDefaultDevice()->LogicToPixel( aTwipSz,
    1032           0 :                                                     MapMode(MAP_TWIP) );
    1033           0 :             if( !aPixelSz.Width() && aTwipSz.Width() )
    1034           0 :                 aPixelSz.Width() = 1;
    1035           0 :             if( !aPixelSz.Height() && aTwipSz.Height() )
    1036           0 :                 aPixelSz.Height() = 1;
    1037             :         }
    1038             : 
    1039           0 :         if( aPixelSz.Width() )
    1040             :         {
    1041           0 :             sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_width).
    1042           0 :                 append('=').append(static_cast<sal_Int32>(aPixelSz.Width()));
    1043             :         }
    1044             : 
    1045           0 :         if( aPixelSz.Height() )
    1046             :         {
    1047           0 :             sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_height).
    1048           0 :                 append('=').append(static_cast<sal_Int32>(aPixelSz.Height()));
    1049             :         }
    1050             :     }
    1051             : 
    1052           0 :     aTmp = xPropSet->getPropertyValue(
    1053           0 :                     OUString(RTL_CONSTASCII_USTRINGPARAM("TabIndex")) );
    1054           0 :     if( aTmp.getValueType() == ::getCppuType((const sal_Int16*)0) )
    1055             :     {
    1056           0 :         sal_Int16 nTabIndex = *(sal_Int16*) aTmp.getValue();
    1057           0 :         if( nTabIndex > 0 )
    1058             :         {
    1059           0 :             if( nTabIndex >= 32767 )
    1060           0 :                 nTabIndex = 32767;
    1061             : 
    1062           0 :             sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_tabindex).
    1063           0 :                 append('=').append(static_cast<sal_Int32>(nTabIndex));
    1064             :         }
    1065             :     }
    1066             : 
    1067           0 :     if( sOut.getLength() )
    1068           0 :         rWrt.Strm() << sOut.makeStringAndClear().getStr();
    1069             : 
    1070             :     OSL_ENSURE( !bInCntnr, "Container wird fuer Controls nicht unterstuertzt" );
    1071           0 :     if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_DRAW ) && !bInCntnr )
    1072             :     {
    1073             :         // Wenn Zeichen-Objekte nicht absolut positioniert werden duerfen,
    1074             :         // das entsprechende Flag loeschen.
    1075             :         nFrmOpts |= (TYPE_IMAGE == eType
    1076             :                             ? HTML_FRMOPTS_IMG_CONTROL_CSS1
    1077           0 :                             : HTML_FRMOPTS_CONTROL_CSS1);
    1078             :     }
    1079           0 :     rtl::OString aEndTags;
    1080           0 :     if( nFrmOpts != 0 )
    1081           0 :         aEndTags = rHTMLWrt.OutFrmFmtOptions( rFmt, aEmptyStr, nFrmOpts );
    1082             : 
    1083           0 :     if( rHTMLWrt.bCfgOutStyles )
    1084             :     {
    1085             :         sal_Bool bEdit = TAG_TEXTAREA == eTag || TYPE_FILE == eType ||
    1086           0 :                      TYPE_TEXT == eType;
    1087             : 
    1088           0 :         SfxItemSet aItemSet( rHTMLWrt.pDoc->GetAttrPool(), RES_CHRATR_BEGIN,
    1089           0 :                              RES_CHRATR_END );
    1090           0 :         OUString sPropName(RTL_CONSTASCII_USTRINGPARAM("BackgroundColor"));
    1091           0 :         if( xPropSetInfo->hasPropertyByName( sPropName ) )
    1092             :         {
    1093           0 :             aTmp = xPropSet->getPropertyValue( sPropName );
    1094           0 :             if( aTmp.getValueType() == ::getCppuType((const sal_Int32*)0) )
    1095             :             {
    1096           0 :                 Color aCol(*(sal_Int32*)aTmp .getValue());
    1097           0 :                 aItemSet.Put( SvxBrushItem( aCol, RES_CHRATR_BACKGROUND ) );
    1098             :             }
    1099             :         }
    1100           0 :         sPropName = OUString(RTL_CONSTASCII_USTRINGPARAM("TextColor"));
    1101           0 :         if( xPropSetInfo->hasPropertyByName( sPropName ) )
    1102             :         {
    1103           0 :             aTmp = xPropSet->getPropertyValue( sPropName );
    1104           0 :             if( aTmp.getValueType() == ::getCppuType((const sal_Int32*)0) )
    1105             :             {
    1106           0 :                 Color aColor( *(sal_Int32*)aTmp .getValue() );
    1107           0 :                 aItemSet.Put( SvxColorItem( aColor, RES_CHRATR_COLOR ) );
    1108             :             }
    1109             :         }
    1110           0 :         sPropName = OUString(RTL_CONSTASCII_USTRINGPARAM("FontHeight"));
    1111           0 :         if( xPropSetInfo->hasPropertyByName( sPropName ) )
    1112             :         {
    1113           0 :             aTmp = xPropSet->getPropertyValue( sPropName );
    1114           0 :             if( aTmp.getValueType() == ::getCppuType((const float*)0) )
    1115             : 
    1116             :             {
    1117           0 :                 float nHeight = *(float*)aTmp.getValue();
    1118           0 :                 if( nHeight > 0  && (!bEdit || nHeight != 10.) )
    1119           0 :                     aItemSet.Put( SvxFontHeightItem( sal_Int16(nHeight * 20.), 100, RES_CHRATR_FONTSIZE ) );
    1120             :             }
    1121             :         }
    1122           0 :         sPropName = OUString(RTL_CONSTASCII_USTRINGPARAM("FontName"));
    1123           0 :         if( xPropSetInfo->hasPropertyByName( sPropName ) )
    1124             :         {
    1125           0 :             aTmp = xPropSet->getPropertyValue( sPropName );
    1126           0 :             if( aTmp.getValueType() == ::getCppuType((const OUString*)0) &&
    1127           0 :                 !((OUString*)aTmp.getValue())->isEmpty() )
    1128             :             {
    1129             :                 Font aFixedFont( OutputDevice::GetDefaultFont(
    1130             :                                     DEFAULTFONT_FIXED, LANGUAGE_ENGLISH_US,
    1131           0 :                                     DEFAULTFONT_FLAGS_ONLYONE ) );
    1132           0 :                 String aFName( *(OUString*)aTmp.getValue() );
    1133           0 :                 if( !bEdit || aFName != aFixedFont.GetName() )
    1134             :                 {
    1135           0 :                     FontFamily eFamily = FAMILY_DONTKNOW;
    1136           0 :                     sPropName = OUString(RTL_CONSTASCII_USTRINGPARAM("FontFamily"));
    1137           0 :                     if( xPropSetInfo->hasPropertyByName( sPropName ) )
    1138             :                     {
    1139           0 :                         aTmp = xPropSet->getPropertyValue( sPropName );
    1140           0 :                         if( aTmp.getValueType() == ::getCppuType((const sal_Int16*)0))
    1141           0 :                             eFamily = (FontFamily)*(sal_Int16*) aTmp.getValue();
    1142             :                     }
    1143           0 :                     SvxFontItem aItem( eFamily, aFName, aEmptyStr, PITCH_DONTKNOW, RTL_TEXTENCODING_DONTKNOW, RES_CHRATR_FONT );
    1144           0 :                     aItemSet.Put( aItem );
    1145           0 :                 }
    1146             :             }
    1147             :         }
    1148           0 :         sPropName = OUString(RTL_CONSTASCII_USTRINGPARAM("FontWeight"));
    1149           0 :         if( xPropSetInfo->hasPropertyByName( sPropName ) )
    1150             :         {
    1151           0 :             aTmp = xPropSet->getPropertyValue( sPropName );
    1152           0 :             if( aTmp.getValueType() == ::getCppuType((const float*)0) )
    1153             :             {
    1154             :                 FontWeight eWeight =
    1155           0 :                     VCLUnoHelper::ConvertFontWeight( *(float*)aTmp.getValue() );
    1156           0 :                 if( eWeight != WEIGHT_DONTKNOW && eWeight != WEIGHT_NORMAL )
    1157           0 :                     aItemSet.Put( SvxWeightItem( eWeight, RES_CHRATR_WEIGHT ) );
    1158             :             }
    1159             :         }
    1160           0 :         sPropName = OUString(RTL_CONSTASCII_USTRINGPARAM("FontSlant"));
    1161           0 :         if( xPropSetInfo->hasPropertyByName( sPropName ) )
    1162             :         {
    1163           0 :             aTmp = xPropSet->getPropertyValue( sPropName );
    1164           0 :             if( aTmp.getValueType() == ::getCppuType((const sal_Int16*)0))
    1165             :             {
    1166           0 :                 FontItalic eItalic = (FontItalic)*(sal_Int16*)aTmp.getValue();
    1167           0 :                 if( eItalic != ITALIC_DONTKNOW && eItalic != ITALIC_NONE )
    1168           0 :                     aItemSet.Put( SvxPostureItem( eItalic, RES_CHRATR_POSTURE ) );
    1169             :             }
    1170             :         }
    1171           0 :         sPropName = OUString(RTL_CONSTASCII_USTRINGPARAM("FontUnderline"));
    1172           0 :         if( xPropSetInfo->hasPropertyByName( sPropName ) )
    1173             :         {
    1174           0 :             aTmp = xPropSet->getPropertyValue( sPropName );
    1175           0 :             if( aTmp.getValueType() == ::getCppuType((const sal_Int16*)0) )
    1176             :             {
    1177             :                 FontUnderline eUnderline =
    1178           0 :                     (FontUnderline)*(sal_Int16*)aTmp.getValue();
    1179           0 :                 if( eUnderline != UNDERLINE_DONTKNOW  &&
    1180             :                     eUnderline != UNDERLINE_NONE )
    1181           0 :                     aItemSet.Put( SvxUnderlineItem( eUnderline, RES_CHRATR_UNDERLINE ) );
    1182             :             }
    1183             :         }
    1184           0 :         sPropName = OUString(RTL_CONSTASCII_USTRINGPARAM("FontStrikeout"));
    1185           0 :         if( xPropSetInfo->hasPropertyByName( sPropName ) )
    1186             :         {
    1187           0 :             aTmp = xPropSet->getPropertyValue( sPropName );
    1188           0 :             if( aTmp.getValueType() == ::getCppuType((const sal_Int16*)0))
    1189             :             {
    1190             :                 FontStrikeout eStrikeout =
    1191           0 :                     (FontStrikeout)*(sal_Int16*)aTmp.getValue();
    1192           0 :                 if( eStrikeout != STRIKEOUT_DONTKNOW &&
    1193             :                     eStrikeout != STRIKEOUT_NONE )
    1194           0 :                     aItemSet.Put( SvxCrossedOutItem( eStrikeout, RES_CHRATR_CROSSEDOUT ) );
    1195             :             }
    1196             :         }
    1197             : 
    1198             :         rHTMLWrt.OutCSS1_FrmFmtOptions( rFmt, nFrmOpts, &rSdrObject,
    1199           0 :                                         &aItemSet );
    1200             :     }
    1201             : 
    1202           0 :     uno::Reference< form::XFormComponent >  xFormComp( xControlModel, uno::UNO_QUERY );
    1203           0 :     lcl_html_outEvents( rWrt.Strm(), xFormComp, rHTMLWrt.bCfgStarBasic,
    1204           0 :                         rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
    1205             : 
    1206           0 :     rWrt.Strm() << '>';
    1207             : 
    1208           0 :     if( TAG_SELECT == eTag )
    1209             :     {
    1210           0 :         aTmp = xPropSet->getPropertyValue(
    1211           0 :                     OUString(RTL_CONSTASCII_USTRINGPARAM("StringItemList")) );
    1212           0 :         if( aTmp.getValueType() == ::getCppuType((uno::Sequence<OUString>*)0) )
    1213             :         {
    1214           0 :             rHTMLWrt.IncIndentLevel(); // der Inhalt von Select darf
    1215             :                                        // eingerueckt werden
    1216           0 :             uno::Sequence<OUString> aList( *(uno::Sequence<OUString>*)aTmp.getValue() );
    1217           0 :             sal_Int32 nCnt = aList.getLength();
    1218           0 :             const OUString *pStrings = aList.getConstArray();
    1219             : 
    1220           0 :             const OUString *pValues = 0;
    1221           0 :             sal_Int32 nValCnt = 0;
    1222           0 :             aTmp = xPropSet->getPropertyValue(
    1223           0 :                             OUString(RTL_CONSTASCII_USTRINGPARAM("ListSource")) );
    1224           0 :             uno::Sequence<OUString> aValList;
    1225           0 :             if( aTmp.getValueType() == ::getCppuType((uno::Sequence<OUString>*)0) )
    1226             :             {
    1227           0 :                 aValList = *(uno::Sequence<OUString>*)aTmp.getValue();
    1228           0 :                 nValCnt = aValList.getLength();
    1229           0 :                 pValues = aValList.getConstArray();
    1230             :             }
    1231             : 
    1232           0 :             uno::Any aSelTmp = xPropSet->getPropertyValue(
    1233           0 :                             OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultSelection")) );
    1234           0 :             const sal_Int16 *pSels = 0;
    1235           0 :             sal_Int32 nSel = 0;
    1236           0 :             sal_Int32 nSelCnt = 0;
    1237           0 :             uno::Sequence<sal_Int16> aSelList;
    1238           0 :             if( aSelTmp.getValueType() ==::getCppuType((uno::Sequence<sal_Int16>*)0))
    1239             :             {
    1240           0 :                 aSelList = *(uno::Sequence<sal_Int16>*)aSelTmp.getValue();
    1241           0 :                 nSelCnt = aSelList.getLength();
    1242           0 :                 pSels = aSelList.getConstArray();
    1243             :             }
    1244             : 
    1245           0 :             for( sal_Int32 i = 0; i < nCnt; i++ )
    1246             :             {
    1247           0 :                 OUString sVal;
    1248           0 :                 sal_Bool bSelected = sal_False, bEmptyVal = sal_False;
    1249           0 :                 if( i < nValCnt )
    1250             :                 {
    1251           0 :                     const OUString& rVal = pValues[i];
    1252           0 :                     if( rVal.compareToAscii( "$$$empty$$$" ) == 0 )
    1253           0 :                         bEmptyVal = sal_True;
    1254             :                     else
    1255           0 :                         sVal = rVal;
    1256             :                 }
    1257             : 
    1258           0 :                 bSelected = (nSel < nSelCnt) && pSels[nSel] == i;
    1259           0 :                 if( bSelected )
    1260           0 :                     nSel++;
    1261             : 
    1262           0 :                 rHTMLWrt.OutNewLine(); // jede Option bekommt eine eigene Zeile
    1263           0 :                 sOut.append('<').append(OOO_STRING_SVTOOLS_HTML_option);
    1264           0 :                 if( !sVal.isEmpty() || bEmptyVal )
    1265             :                 {
    1266           0 :                     sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_value).
    1267           0 :                         append(RTL_CONSTASCII_STRINGPARAM("=\""));
    1268           0 :                     rWrt.Strm() << sOut.makeStringAndClear().getStr();
    1269           0 :                     HTMLOutFuncs::Out_String( rWrt.Strm(), sVal,
    1270           0 :                         rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
    1271           0 :                     sOut.append('\"');
    1272             :                 }
    1273           0 :                 if( bSelected )
    1274           0 :                     sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_selected);
    1275             : 
    1276           0 :                 sOut.append('>');
    1277           0 :                 rWrt.Strm() << sOut.makeStringAndClear().getStr();
    1278             : 
    1279           0 :                 HTMLOutFuncs::Out_String( rWrt.Strm(), pStrings[i],
    1280           0 :                                           rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
    1281           0 :             }
    1282           0 :             HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), OOO_STRING_SVTOOLS_HTML_option, sal_False );
    1283             : 
    1284           0 :             rHTMLWrt.DecIndentLevel();
    1285           0 :             rHTMLWrt.OutNewLine();// das </SELECT> bekommt eine eigene Zeile
    1286             :         }
    1287           0 :         HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), OOO_STRING_SVTOOLS_HTML_select, sal_False );
    1288             :     }
    1289           0 :     else if( TAG_TEXTAREA == eTag )
    1290             :     {
    1291             :         // In TextAreas duerfen keine zusaetzlichen Spaces oder LF exportiert
    1292             :         // werden!
    1293           0 :         String sVal;
    1294           0 :         aTmp = xPropSet->getPropertyValue(
    1295           0 :         OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultText")) );
    1296           0 :         if( aTmp.getValueType() == ::getCppuType((const OUString*)0)&&
    1297           0 :             !((OUString*)aTmp.getValue())->isEmpty() )
    1298             :         {
    1299           0 :             sVal = String( *(OUString*)aTmp.getValue() );
    1300             :         }
    1301           0 :         if( sVal.Len() )
    1302             :         {
    1303           0 :             sVal = convertLineEnd(sVal, LINEEND_LF);
    1304           0 :             xub_StrLen nPos = 0;
    1305           0 :             while ( nPos != STRING_NOTFOUND )
    1306             :             {
    1307           0 :                 if( nPos )
    1308           0 :                     rWrt.Strm() << SwHTMLWriter::sNewLine;
    1309           0 :                 String aLine = sVal.GetToken( 0, 0x0A, nPos );
    1310           0 :                 HTMLOutFuncs::Out_String( rWrt.Strm(), aLine,
    1311           0 :                                         rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
    1312           0 :             }
    1313             :         }
    1314           0 :         HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), OOO_STRING_SVTOOLS_HTML_textarea, sal_False );
    1315             :     }
    1316           0 :     else if( TYPE_CHECKBOX == eType || TYPE_RADIO == eType )
    1317             :     {
    1318           0 :         aTmp = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Label")));
    1319           0 :         if( aTmp.getValueType() == ::getCppuType((const OUString*)0) &&
    1320           0 :             !((OUString*)aTmp.getValue())->isEmpty() )
    1321             :         {
    1322           0 :             sValue = *(OUString*)aTmp.getValue();
    1323           0 :             HTMLOutFuncs::Out_String( rWrt.Strm(), sValue,
    1324           0 :                 rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters ) << ' ';
    1325             :         }
    1326             :     }
    1327             : 
    1328           0 :     if( !aEndTags.isEmpty() )
    1329           0 :         rWrt.Strm() << aEndTags.getStr();
    1330             : 
    1331             :     // Controls sind nicht absatz-gebunden, deshalb kein LF mehr ausgeben!
    1332           0 :     rHTMLWrt.bLFPossible = sal_False;
    1333             : 
    1334           0 :     if( rHTMLWrt.pxFormComps && rHTMLWrt.pxFormComps->is() )
    1335           0 :         rHTMLWrt.OutHiddenControls( *rHTMLWrt.pxFormComps, xPropSet );
    1336           0 :     return rWrt;
    1337             : }
    1338             : 
    1339             : 
    1340             : // Ermitteln, ob eine Format zu einem Control gehoert und wenn ja
    1341             : // dessen Form zurueckgeben
    1342           0 : static void AddControl( HTMLControls& rControls,
    1343             :                         const SdrObject *pSdrObj,
    1344             :                         sal_uInt32 nNodeIdx )
    1345             : {
    1346           0 :     SdrUnoObj *pFormObj = PTR_CAST( SdrUnoObj, pSdrObj );
    1347             :     OSL_ENSURE( pFormObj, "Doch kein FormObj" );
    1348             :     uno::Reference< awt::XControlModel > xControlModel =
    1349           0 :             pFormObj->GetUnoControlModel();
    1350           0 :     if( !xControlModel.is() )
    1351           0 :         return;
    1352             : 
    1353           0 :     uno::Reference< form::XFormComponent >  xFormComp( xControlModel, uno::UNO_QUERY );
    1354           0 :     uno::Reference< uno::XInterface >  xIfc = xFormComp->getParent();
    1355           0 :     uno::Reference< form::XForm >  xForm(xIfc, uno::UNO_QUERY);
    1356             : 
    1357             :     OSL_ENSURE( xForm.is(), "Wo ist die Form?" );
    1358           0 :     if( xForm.is() )
    1359             :     {
    1360           0 :         uno::Reference< container::XIndexContainer >  xFormComps( xForm, uno::UNO_QUERY );
    1361           0 :         HTMLControl *pHCntrl = new HTMLControl( xFormComps, nNodeIdx );
    1362           0 :         HTMLControls::const_iterator it = rControls.find( pHCntrl );
    1363           0 :         if( it == rControls.end() )
    1364           0 :             rControls.insert( pHCntrl );
    1365             :         else
    1366             :         {
    1367           0 :             if( (*it)->xFormComps==xFormComps )
    1368           0 :                 (*it)->nCount++;
    1369           0 :             delete pHCntrl;
    1370           0 :         }
    1371           0 :     }
    1372             : }
    1373             : 
    1374             : 
    1375           0 : void SwHTMLWriter::GetControls()
    1376             : {
    1377             :     // Idee: die absatz- und zeichengebundenen Controls werden erst einmal
    1378             :     // eingesammelt. Dabei wird fuer jedes Control des Absatz-Position
    1379             :     // und VCForm in einem Array gemerkt.
    1380             :     // Ueber dieses Array laesst sich dann feststellen, wo form::Forms geoeffnet
    1381             :     // und geschlossen werden muessen.
    1382             :     sal_uInt16 i;
    1383           0 :     if( pHTMLPosFlyFrms )
    1384             :     {
    1385             :         // die absatz-gebundenen Controls einsammeln
    1386           0 :         for( i=0; i<pHTMLPosFlyFrms->size(); i++ )
    1387             :         {
    1388           0 :             const SwHTMLPosFlyFrm* pPosFlyFrm = (*pHTMLPosFlyFrms)[ i ];
    1389           0 :             if( HTML_OUT_CONTROL != pPosFlyFrm->GetOutFn() )
    1390           0 :                 continue;
    1391             : 
    1392           0 :             const SdrObject *pSdrObj = pPosFlyFrm->GetSdrObject();
    1393             :             OSL_ENSURE( pSdrObj, "Wo ist das SdrObject?" );
    1394           0 :             if( !pSdrObj )
    1395           0 :                 continue;
    1396             : 
    1397             :             AddControl( aHTMLControls, pSdrObj,
    1398           0 :                         pPosFlyFrm->GetNdIndex().GetIndex() );
    1399             :         }
    1400             :     }
    1401             : 
    1402             :     // und jetzt die in einem zeichengebundenen Rahmen
    1403           0 :     const SwFrmFmts* pSpzFrmFmts = pDoc->GetSpzFrmFmts();
    1404           0 :     for( i=0; i<pSpzFrmFmts->size(); i++ )
    1405             :     {
    1406           0 :         const SwFrmFmt *pFrmFmt = (*pSpzFrmFmts)[i];
    1407           0 :         if( RES_DRAWFRMFMT != pFrmFmt->Which() )
    1408           0 :             continue;
    1409             : 
    1410           0 :         const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor();
    1411           0 :         const SwPosition *pPos = rAnchor.GetCntntAnchor();
    1412           0 :         if ((FLY_AS_CHAR != rAnchor.GetAnchorId()) || !pPos)
    1413           0 :             continue;
    1414             : 
    1415             :         const SdrObject *pSdrObj =
    1416           0 :             SwHTMLWriter::GetHTMLControl( *(const SwDrawFrmFmt*)pFrmFmt );
    1417           0 :         if( !pSdrObj )
    1418           0 :             continue;
    1419             : 
    1420           0 :         AddControl( aHTMLControls, pSdrObj, pPos->nNode.GetIndex() );
    1421             :     }
    1422           0 : }
    1423             : 
    1424             : 
    1425           0 : HTMLControl::HTMLControl(
    1426             :         const uno::Reference< container::XIndexContainer > & rFormComps,
    1427             :         sal_uInt32 nIdx ) :
    1428           0 :     xFormComps( rFormComps ), nNdIdx( nIdx ), nCount( 1 )
    1429           0 : {}
    1430             : 
    1431             : 
    1432           0 : HTMLControl::~HTMLControl()
    1433           0 : {}
    1434             : 
    1435             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10