LibreOffice Module sw (master) 1
htmlforw.cxx
Go to the documentation of this file.
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/form/FormSubmitEncoding.hpp>
21#include <com/sun/star/form/FormSubmitMethod.hpp>
22#include <com/sun/star/form/FormButtonType.hpp>
23#include <com/sun/star/frame/XModel.hpp>
24#include <com/sun/star/script/XEventAttacherManager.hpp>
25#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
26#include <com/sun/star/form/XFormsSupplier.hpp>
27#include <com/sun/star/form/XForm.hpp>
28#include <com/sun/star/form/FormComponentType.hpp>
29#include <com/sun/star/awt/XTextLayoutConstrains.hpp>
30#include <com/sun/star/beans/XPropertySet.hpp>
31#include <hintids.hxx>
32#include <o3tl/any.hxx>
33#include <rtl/math.hxx>
34#include <utility>
35#include <vcl/svapp.hxx>
36#include <svl/macitem.hxx>
37#include <svtools/htmlout.hxx>
38#include <svtools/htmlkywd.hxx>
39#include <svl/urihelper.hxx>
40#include <vcl/unohelp.hxx>
41#include <svx/svdouno.hxx>
42#include <editeng/brushitem.hxx>
43#include <editeng/colritem.hxx>
44#include <editeng/fhgtitem.hxx>
45#include <editeng/fontitem.hxx>
46#include <editeng/wghtitem.hxx>
47#include <editeng/postitem.hxx>
48#include <editeng/udlnitem.hxx>
50#include <osl/diagnose.h>
51#include <docsh.hxx>
52#include <fmtanchr.hxx>
53#include <viewsh.hxx>
54#include <pam.hxx>
55#include <doc.hxx>
58#include "wrthtml.hxx"
59#include "htmlfly.hxx"
60#include "htmlform.hxx"
61#include <frmfmt.hxx>
62#include <frameformats.hxx>
63#include <memory>
64
65using namespace ::com::sun::star;
66
80
81static void lcl_html_outEvents( SvStream& rStrm,
82 const uno::Reference< form::XFormComponent >& rFormComp,
83 bool bCfgStarBasic )
84{
85 uno::Reference< uno::XInterface > xParentIfc = rFormComp->getParent();
86 OSL_ENSURE( xParentIfc.is(), "lcl_html_outEvents: no parent interface" );
87 if( !xParentIfc.is() )
88 return;
89 uno::Reference< container::XIndexAccess > xIndexAcc( xParentIfc, uno::UNO_QUERY );
90 uno::Reference< script::XEventAttacherManager > xEventManager( xParentIfc,
91 uno::UNO_QUERY );
92 if( !xIndexAcc.is() || !xEventManager.is() )
93 return;
94
95 // and search for the position of the ControlModel within
96 sal_Int32 nCount = xIndexAcc->getCount(), nPos;
97 for( nPos = 0 ; nPos < nCount; nPos++ )
98 {
99 uno::Any aTmp = xIndexAcc->getByIndex(nPos);
100 if( auto x1 = o3tl::tryAccess<uno::Reference<form::XFormComponent>>(aTmp) )
101
102 {
103 if( rFormComp == *x1 )
104 break;
105 }
106 else if( auto x2 = o3tl::tryAccess<uno::Reference<form::XForm>>(aTmp) )
107 {
108 if( rFormComp == *x2 )
109 break;
110 }
111 else
112 {
113 OSL_ENSURE( false, "lcl_html_outEvents: wrong reflection" );
114 }
115 }
116
117 if( nPos == nCount )
118 return;
119
120 const uno::Sequence< script::ScriptEventDescriptor > aDescs =
121 xEventManager->getScriptEvents( nPos );
122 if( !aDescs.hasElements() )
123 return;
124
125 for( const script::ScriptEventDescriptor& rDesc : aDescs )
126 {
127 ScriptType eScriptType = EXTENDED_STYPE;
128 OUString aScriptType( rDesc.ScriptType );
129 if( aScriptType.equalsIgnoreAsciiCase(SVX_MACRO_LANGUAGE_JAVASCRIPT) )
130 eScriptType = JAVASCRIPT;
131 else if( aScriptType.equalsIgnoreAsciiCase(SVX_MACRO_LANGUAGE_STARBASIC ) )
132 eScriptType = STARBASIC;
133 if( JAVASCRIPT != eScriptType && !bCfgStarBasic )
134 continue;
135
136 OUString sListener( rDesc.ListenerType );
137 if (!sListener.isEmpty())
138 {
139 const sal_Int32 nIdx { sListener.lastIndexOf('.')+1 };
140 if (nIdx>0)
141 {
142 if (nIdx<sListener.getLength())
143 {
144 sListener = sListener.copy(nIdx);
145 }
146 else
147 {
148 sListener.clear();
149 }
150 }
151 }
152 OUString sMethod( rDesc.EventMethod );
153
154 const char *pOpt = nullptr;
155 for( int j=0; aEventListenerTable[j]; j++ )
156 {
157 if( sListener.equalsAscii( aEventListenerTable[j] ) &&
158 sMethod.equalsAscii( aEventMethodTable[j] ) )
159 {
160 pOpt = (STARBASIC==eScriptType ? aEventSDOptionTable
161 : aEventOptionTable)[j];
162 break;
163 }
164 }
165
166 OString sOut = " ";
167 if( pOpt && (EXTENDED_STYPE != eScriptType ||
168 rDesc.AddListenerParam.isEmpty()) )
169 sOut += pOpt;
170 else
171 {
173 OUStringToOString(sListener, RTL_TEXTENCODING_ASCII_US) + "-" +
174 OUStringToOString(sMethod, RTL_TEXTENCODING_ASCII_US);
175 }
176 sOut += "=\"";
177 rStrm.WriteOString( sOut );
178 HTMLOutFuncs::Out_String( rStrm, rDesc.ScriptCode );
179 rStrm.WriteChar( '\"' );
180 if( EXTENDED_STYPE == eScriptType &&
181 !rDesc.AddListenerParam.isEmpty() )
182 {
184 OUStringToOString(sListener, RTL_TEXTENCODING_ASCII_US) + "-" +
185 OUStringToOString(sMethod, RTL_TEXTENCODING_ASCII_US) + "=\"";
186 rStrm.WriteOString( sOut );
187 HTMLOutFuncs::Out_String( rStrm, rDesc.AddListenerParam );
188 rStrm.WriteChar( '\"' );
189 }
190 }
191}
192
193static bool lcl_html_isHTMLControl( sal_Int16 nClassId )
194{
195 bool bRet = false;
196
197 switch( nClassId )
198 {
199 case form::FormComponentType::TEXTFIELD:
200 case form::FormComponentType::COMMANDBUTTON:
201 case form::FormComponentType::RADIOBUTTON:
202 case form::FormComponentType::CHECKBOX:
203 case form::FormComponentType::LISTBOX:
204 case form::FormComponentType::IMAGEBUTTON:
205 case form::FormComponentType::FILECONTROL:
206 bRet = true;
207 break;
208 }
209
210 return bRet;
211}
212
214{
215 SwNodeOffset nStartIdx = m_pCurrentPam->GetPoint()->GetNodeIndex();
216 size_t i = 0;
217
218 // Skip all controls in front of the current paragraph
219 while ( i < m_aHTMLControls.size() && m_aHTMLControls[i]->nNdIdx < nStartIdx )
220 ++i;
221
222 return i < m_aHTMLControls.size() && m_aHTMLControls[i]->nNdIdx == nStartIdx;
223}
224
225void SwHTMLWriter::OutForm( bool bTag_On, const SwStartNode *pStartNd )
226{
227 if( m_bPreserveForm ) // we are in a table or an area with form spanned over it
228 return;
229
230 if( !bTag_On )
231 {
232 // end the form when all controls are output
233 if( mxFormComps.is() &&
234 mxFormComps->getCount() == m_nFormCntrlCnt )
235 {
236 OutForm( false, mxFormComps );
237 mxFormComps.clear();
238 }
239 return;
240 }
241
242 uno::Reference< container::XIndexContainer > xNewFormComps;
243 SwNodeOffset nStartIdx = pStartNd ? pStartNd->GetIndex()
244 : m_pCurrentPam->GetPoint()->GetNodeIndex();
245
246 // skip controls before the interesting area
247 size_t i = 0;
248 while ( i < m_aHTMLControls.size() && m_aHTMLControls[i]->nNdIdx < nStartIdx )
249 ++i;
250
251 if( !pStartNd )
252 {
253 // Check for a single node: there it's only interesting, if there is
254 // a control for the node and to which form it belongs.
255 if( i < m_aHTMLControls.size() &&
256 m_aHTMLControls[i]->nNdIdx == nStartIdx )
257 xNewFormComps = m_aHTMLControls[i]->xFormComps;
258 }
259 else
260 {
261 // we iterate over a table/an area: we're interested in:
262 // - if there are controls with different start nodes
263 // - if there is a form, with controls which aren't all in the table/area
264
265 uno::Reference< container::XIndexContainer > xCurrentFormComps;// current form in table
266 const SwStartNode *pCurrentStNd = nullptr; // and the start node of a Control
267 sal_Int32 nCurrentCtrls = 0; // and the found controls in it
268 SwNodeOffset nEndIdx = pStartNd->EndOfSectionIndex();
269 for( ; i < m_aHTMLControls.size() &&
270 m_aHTMLControls[i]->nNdIdx <= nEndIdx; i++ )
271 {
272 const SwStartNode *pCntrlStNd =
273 m_pDoc->GetNodes()[m_aHTMLControls[i]->nNdIdx]->StartOfSectionNode();
274
275 if( xCurrentFormComps.is() )
276 {
277 // already inside a form ...
278 if( xCurrentFormComps==m_aHTMLControls[i]->xFormComps )
279 {
280 // ... and the control is also inside ...
281 if( pCurrentStNd!=pCntrlStNd )
282 {
283 // ... but it's inside another cell:
284 // Then open a form above the table
285 xNewFormComps = xCurrentFormComps;
286 break;
287 }
288 nCurrentCtrls = nCurrentCtrls + m_aHTMLControls[i]->nCount;
289 }
290 else
291 {
292 // ... but the Control is in another cell:
293 // There we act as if we open a new from and continue searching.
294 xCurrentFormComps = m_aHTMLControls[i]->xFormComps;
295 pCurrentStNd = pCntrlStNd;
296 nCurrentCtrls = m_aHTMLControls[i]->nCount;
297 }
298 }
299 else
300 {
301 // We aren't in a form:
302 // There we act as if we open a form.
303 xCurrentFormComps = m_aHTMLControls[i]->xFormComps;
304 pCurrentStNd = pCntrlStNd;
305 nCurrentCtrls = m_aHTMLControls[i]->nCount;
306 }
307 }
308 if( !xNewFormComps.is() && xCurrentFormComps.is() &&
309 nCurrentCtrls != xCurrentFormComps->getCount() )
310 {
311 // A form should be opened in the table/area which isn't completely
312 // inside the table. Then we must also now open the form.
313 xNewFormComps = xCurrentFormComps;
314 }
315 }
316
317 if( !(xNewFormComps.is() &&
318 (!mxFormComps.is() || xNewFormComps != mxFormComps)) )
319 return;
320
321 // A form should be opened ...
322 if( mxFormComps.is() )
323 {
324 // ... but a form is still open: That is in every case an error,
325 // but we'll close the old form nevertheless.
326 OutForm( false, mxFormComps );
327
329 }
330
331 mxFormComps = xNewFormComps;
332
333 OutForm( true, mxFormComps );
334 uno::Reference< beans::XPropertySet > xTmp;
336}
337
339{
340 // Without DrawModel there can't be controls. Then you also can't access the
341 // document via UNO, because otherwise a DrawModel would be created.
343 return;
344
345 SwDocShell *pDocSh = m_pDoc->GetDocShell();
346 if( !pDocSh )
347 return;
348
349 uno::Reference< drawing::XDrawPageSupplier > xDPSupp( pDocSh->GetBaseModel(),
350 uno::UNO_QUERY );
351 OSL_ENSURE( xDPSupp.is(), "XTextDocument not received from XModel" );
352 uno::Reference< drawing::XDrawPage > xDrawPage = xDPSupp->getDrawPage();
353
354 OSL_ENSURE( xDrawPage.is(), "XDrawPage not received" );
355 if( !xDrawPage.is() )
356 return;
357
358 uno::Reference< form::XFormsSupplier > xFormsSupplier( xDrawPage, uno::UNO_QUERY );
359 OSL_ENSURE( xFormsSupplier.is(),
360 "XFormsSupplier not received from XDrawPage" );
361
362 uno::Reference< container::XNameContainer > xTmp = xFormsSupplier->getForms();
363 OSL_ENSURE( xTmp.is(), "XForms not received" );
364 uno::Reference< container::XIndexContainer > xForms( xTmp, uno::UNO_QUERY );
365 OSL_ENSURE( xForms.is(), "XForms without container::XIndexContainer?" );
366
367 sal_Int32 nCount = xForms->getCount();
368 for( sal_Int32 i=0; i<nCount; i++)
369 {
370 uno::Any aTmp = xForms->getByIndex( i );
371 if( auto x = o3tl::tryAccess<uno::Reference<form::XForm>>(aTmp) )
372 OutHiddenForm( *x );
373 else
374 {
375 OSL_ENSURE( false, "OutHiddenForms: wrong reflection" );
376 }
377 }
378}
379
380void SwHTMLWriter::OutHiddenForm( const uno::Reference< form::XForm > & rForm )
381{
382 uno::Reference< container::XIndexContainer > xFormComps( rForm, uno::UNO_QUERY );
383 if( !xFormComps.is() )
384 return;
385
386 sal_Int32 nCount = xFormComps->getCount();
387 bool bHiddenOnly = nCount > 0, bHidden = false;
388 for( sal_Int32 i=0; i<nCount; i++ )
389 {
390 uno::Any aTmp = xFormComps->getByIndex( i );
391 auto xFormComp = o3tl::tryAccess<uno::Reference<form::XFormComponent>>(
392 aTmp);
393 OSL_ENSURE( xFormComp, "OutHiddenForm: wrong reflection" );
394 if( !xFormComp )
395 continue;
396
397 uno::Reference< form::XForm > xForm( *xFormComp, uno::UNO_QUERY );
398 if( xForm.is() )
399 OutHiddenForm( xForm );
400
401 if( bHiddenOnly )
402 {
403 uno::Reference< beans::XPropertySet > xPropSet( *xFormComp, uno::UNO_QUERY );
404 OUString sPropName("ClassId");
405 if( xPropSet->getPropertySetInfo()->hasPropertyByName( sPropName ) )
406 {
407 uno::Any aAny2 = xPropSet->getPropertyValue( sPropName );
408 if( auto n = o3tl::tryAccess<sal_Int16>(aAny2) )
409 {
410 if( form::FormComponentType::HIDDENCONTROL == *n )
411 bHidden = true;
412 else if( lcl_html_isHTMLControl( *n ) )
413 bHiddenOnly = false;
414 }
415 }
416 }
417 }
418
419 if( bHidden && bHiddenOnly )
420 {
421 OutForm( true, xFormComps );
422 uno::Reference< beans::XPropertySet > xTmp;
423 OutHiddenControls( xFormComps, xTmp );
424 OutForm( false, xFormComps );
425 }
426}
427
428void SwHTMLWriter::OutForm( bool bOn,
429 const uno::Reference< container::XIndexContainer > & rFormComps )
430{
431 m_nFormCntrlCnt = 0;
432
433 if( !bOn )
434 {
435 DecIndentLevel(); // indent content of form
436 if( m_bLFPossible )
437 OutNewLine();
438 HTMLOutFuncs::Out_AsciiTag( Strm(), Concat2View(GetNamespace() + OOO_STRING_SVTOOLS_HTML_form), false );
439 m_bLFPossible = true;
440
441 return;
442 }
443
444 // the new form is opened
445 if( m_bLFPossible )
446 OutNewLine();
447 OString sOut = "<" + GetNamespace() + OOO_STRING_SVTOOLS_HTML_form;
448
449 uno::Reference< beans::XPropertySet > xFormPropSet( rFormComps, uno::UNO_QUERY );
450
451 uno::Any aTmp = xFormPropSet->getPropertyValue( "Name" );
452 if( auto s = o3tl::tryAccess<OUString>(aTmp) )
453 {
454 if( !s->isEmpty() )
455 {
456 sOut += " " OOO_STRING_SVTOOLS_HTML_O_name "=\"";
457 Strm().WriteOString( sOut );
459 sOut = "\"";
460 }
461 }
462
463 aTmp = xFormPropSet->getPropertyValue( "TargetURL" );
464 if( auto s = o3tl::tryAccess<OUString>(aTmp) )
465 {
466 if ( !s->isEmpty() )
467 {
468 sOut += " " OOO_STRING_SVTOOLS_HTML_O_action "=\"";
469 Strm().WriteOString( sOut );
470 OUString aURL
473 sOut = "\"";
474 }
475 }
476
477 aTmp = xFormPropSet->getPropertyValue( "SubmitMethod" );
478 if( auto eMethod = o3tl::tryAccess<form::FormSubmitMethod>(aTmp) )
479 {
480 if( form::FormSubmitMethod_POST==*eMethod )
481 {
482 sOut += " " OOO_STRING_SVTOOLS_HTML_O_method "=\""
484 }
485 }
486 aTmp = xFormPropSet->getPropertyValue( "SubmitEncoding" );
487 if( auto eEncType = o3tl::tryAccess<form::FormSubmitEncoding>(aTmp) )
488 {
489 const char *pStr = nullptr;
490 switch( *eEncType )
491 {
492 case form::FormSubmitEncoding_MULTIPART:
494 break;
495 case form::FormSubmitEncoding_TEXT:
497 break;
498 default:
499 ;
500 }
501
502 if( pStr )
503 {
504 sOut += OString::Concat(" " OOO_STRING_SVTOOLS_HTML_O_enctype "=\"") +
505 pStr + "\"";
506 }
507 }
508
509 aTmp = xFormPropSet->getPropertyValue( "TargetFrame" );
510 if( auto s = o3tl::tryAccess<OUString>(aTmp) )
511 {
512 if (!s->isEmpty() )
513 {
514 sOut += " " OOO_STRING_SVTOOLS_HTML_O_target "=\"";
515 Strm().WriteOString( sOut );
517 sOut = "\"";
518 }
519 }
520
521 Strm().WriteOString( sOut );
522 uno::Reference< form::XFormComponent > xFormComp( rFormComps, uno::UNO_QUERY );
523 lcl_html_outEvents( Strm(), xFormComp, m_bCfgStarBasic );
524 Strm().WriteChar( '>' );
525
526 IncIndentLevel(); // indent content of form
527 m_bLFPossible = true;
528}
529
531 const uno::Reference< container::XIndexContainer > & rFormComps,
532 const uno::Reference< beans::XPropertySet > & rPropSet )
533{
534 sal_Int32 nCount = rFormComps->getCount();
535 sal_Int32 nPos = 0;
536 if( rPropSet.is() )
537 {
538 bool bDone = false;
539
540 uno::Reference< form::XFormComponent > xFC( rPropSet, uno::UNO_QUERY );
541 for( nPos=0; !bDone && nPos < nCount; nPos++ )
542 {
543 uno::Any aTmp = rFormComps->getByIndex( nPos );
544 auto x = o3tl::tryAccess<uno::Reference<form::XFormComponent>>(aTmp);
545 OSL_ENSURE( x,
546 "OutHiddenControls: wrong reflection" );
547 bDone = x && *x == xFC;
548 }
549 }
550
551 for( ; nPos < nCount; nPos++ )
552 {
553 uno::Any aTmp = rFormComps->getByIndex( nPos );
554 auto xFC = o3tl::tryAccess<uno::Reference<form::XFormComponent>>(aTmp);
555 OSL_ENSURE( xFC,
556 "OutHiddenControls: wrong reflection" );
557 if( !xFC )
558 continue;
559 uno::Reference< beans::XPropertySet > xPropSet( *xFC, uno::UNO_QUERY );
560
561 OUString sPropName = "ClassId";
562 if( !xPropSet->getPropertySetInfo()->hasPropertyByName( sPropName ) )
563 continue;
564
565 aTmp = xPropSet->getPropertyValue( sPropName );
566 auto n = o3tl::tryAccess<sal_Int16>(aTmp);
567 if( !n )
568 continue;
569
570 if( form::FormComponentType::HIDDENCONTROL == *n )
571 {
572 if( m_bLFPossible )
573 OutNewLine( true );
574 OString sOut = "<" + GetNamespace() + OOO_STRING_SVTOOLS_HTML_input " "
577
578 aTmp = xPropSet->getPropertyValue( "Name" );
579 if( auto s = o3tl::tryAccess<OUString>(aTmp) )
580 {
581 if( !s->isEmpty() )
582 {
583 sOut += " " OOO_STRING_SVTOOLS_HTML_O_name "=\"";
584 Strm().WriteOString( sOut );
586 sOut = "\"";
587 }
588 }
589 aTmp = xPropSet->getPropertyValue( "HiddenValue" );
590 if( auto s = o3tl::tryAccess<OUString>(aTmp) )
591 {
592 if( !s->isEmpty() )
593 {
594 sOut += " " OOO_STRING_SVTOOLS_HTML_O_value "=\"";
595 Strm().WriteOString( sOut );
597 sOut = "\"";
598 }
599 }
600 sOut += ">";
601 Strm().WriteOString( sOut );
602
604 }
605 else if( lcl_html_isHTMLControl( *n ) )
606 {
607 break;
608 }
609 }
610}
611
612// here are the output routines, thus the form::Forms are bundled:
613
615{
616 // it must be a Draw-Format
617 OSL_ENSURE( RES_DRAWFRMFMT == rFormat.Which(),
618 "GetHTMLControl only allow for Draw-Formats" );
619
620 // Look if a SdrObject exists for it
621 const SdrObject *pObj = rFormat.FindSdrObject();
622 if( !pObj || SdrInventor::FmForm != pObj->GetObjInventor() )
623 return nullptr;
624
625 const SdrUnoObj& rFormObj = dynamic_cast<const SdrUnoObj&>(*pObj);
626 const uno::Reference< awt::XControlModel >& xControlModel =
627 rFormObj.GetUnoControlModel();
628
629 OSL_ENSURE( xControlModel.is(), "UNO-Control without model" );
630 if( !xControlModel.is() )
631 return nullptr;
632
633 uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY );
634
635 OUString sPropName("ClassId");
636 if( !xPropSet->getPropertySetInfo()->hasPropertyByName( sPropName ) )
637 return nullptr;
638
639 uno::Any aTmp = xPropSet->getPropertyValue( sPropName );
640 if( auto n = o3tl::tryAccess<sal_Int16>(aTmp) )
641 {
642 if( lcl_html_isHTMLControl( *n ) )
643 {
644 return pObj;
645 }
646 }
647
648 return nullptr;
649}
650
651static void GetControlSize(const SdrUnoObj& rFormObj, Size& rSz, SwDoc *pDoc)
652{
654 if( !pVSh )
655 return;
656
657 uno::Reference< awt::XControl > xControl;
658 SdrView* pDrawView = pVSh->GetDrawView();
659 OSL_ENSURE( pDrawView && pVSh->GetWin(), "no DrawView or window!" );
660 if ( pDrawView && pVSh->GetWin() )
661 xControl = rFormObj.GetUnoControl( *pDrawView, *pVSh->GetWin()->GetOutDev() );
662 uno::Reference< awt::XTextLayoutConstrains > xLC( xControl, uno::UNO_QUERY );
663 OSL_ENSURE( xLC.is(), "no XTextLayoutConstrains" );
664 if( !xLC.is() )
665 return;
666
667 sal_Int16 nCols=0, nLines=0;
668 xLC->getColumnsAndLines( nCols, nLines );
669 rSz.setWidth( nCols );
670 rSz.setHeight( nLines );
671}
672
674 const SwDrawFrameFormat& rFormat,
675 const SdrUnoObj& rFormObj,
676 bool bInCntnr )
677{
678 const uno::Reference< awt::XControlModel >& xControlModel =
679 rFormObj.GetUnoControlModel();
680
681 OSL_ENSURE( xControlModel.is(), "UNO-Control without model" );
682 if( !xControlModel.is() )
683 return rWrt;
684
685 uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY );
686 uno::Reference< beans::XPropertySetInfo > xPropSetInfo =
687 xPropSet->getPropertySetInfo();
688
689 SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
690 rHTMLWrt.m_nFormCntrlCnt++;
691
692 enum Tag { TAG_INPUT, TAG_SELECT, TAG_TEXTAREA, TAG_NONE };
693 static char const * const TagNames[] = {
696 Tag eTag = TAG_INPUT;
697 enum Type {
698 TYPE_TEXT, TYPE_PASSWORD, TYPE_CHECKBOX, TYPE_RADIO, TYPE_FILE,
699 TYPE_SUBMIT, TYPE_IMAGE, TYPE_RESET, TYPE_BUTTON, TYPE_NONE };
700 static char const * const TypeNames[] = {
707 OUString sValue;
708 OString sOptions;
709 bool bEmptyValue = false;
710 uno::Any aTmp = xPropSet->getPropertyValue( "ClassId" );
711 sal_Int16 nClassId = *o3tl::doAccess<sal_Int16>(aTmp);
713 switch( nClassId )
714 {
715 case form::FormComponentType::CHECKBOX:
716 case form::FormComponentType::RADIOBUTTON:
717 eType = (form::FormComponentType::CHECKBOX == nClassId
718 ? TYPE_CHECKBOX : TYPE_RADIO);
719 aTmp = xPropSet->getPropertyValue( "DefaultState" );
720 if( auto n = o3tl::tryAccess<sal_Int16>(aTmp) )
721 {
722 if ( TRISTATE_FALSE != *n )
723 {
724 sOptions += " " OOO_STRING_SVTOOLS_HTML_O_checked "=\""
726 "\"";
727 }
728 }
729
730 aTmp = xPropSet->getPropertyValue( "RefValue" );
731 if( auto rVal = o3tl::tryAccess<OUString>(aTmp) )
732
733 {
734 if( rVal->isEmpty() )
735 bEmptyValue = true;
736 else if( *rVal != OOO_STRING_SVTOOLS_HTML_on )
737 sValue = *rVal;
738 }
739 break;
740
741 case form::FormComponentType::COMMANDBUTTON:
742 {
743 form::FormButtonType eButtonType = form::FormButtonType_PUSH;
744 aTmp = xPropSet->getPropertyValue( "ButtonType" );
745 if( auto t = o3tl::tryAccess<form::FormButtonType>(aTmp) )
746 eButtonType = *t;
747
748 switch( eButtonType )
749 {
750 case form::FormButtonType_RESET:
751 eType = TYPE_RESET;
752 break;
753 case form::FormButtonType_SUBMIT:
754 eType = TYPE_SUBMIT;
755 break;
756 case form::FormButtonType_PUSH:
757 default:
758 eType = TYPE_BUTTON;
759 }
760
761 aTmp = xPropSet->getPropertyValue( "Label" );
762 if( auto s = o3tl::tryAccess<OUString>(aTmp) )
763 {
764 if( !s->isEmpty() )
765 {
766 sValue = *s;
767 }
768 }
769 }
770 break;
771
772 case form::FormComponentType::LISTBOX:
773 if( rHTMLWrt.m_bLFPossible )
774 rHTMLWrt.OutNewLine( true );
775 eTag = TAG_SELECT;
776 aTmp = xPropSet->getPropertyValue( "Dropdown" );
777 if( auto b1 = o3tl::tryAccess<bool>(aTmp) )
778 {
779 if( !*b1 )
780 {
781 Size aSz( 0, 0 );
782 GetControlSize( rFormObj, aSz, rWrt.m_pDoc );
783
784 // How many are visible ??
785 if( aSz.Height() )
786 {
787 sOptions += " " OOO_STRING_SVTOOLS_HTML_O_size "=\"" +
788 OString::number(static_cast<sal_Int32>(aSz.Height())) + "\"";
789 }
790
791 auto aTmp2 = xPropSet->getPropertyValue( "MultiSelection" );
792 if( auto b2 = o3tl::tryAccess<bool>(aTmp2) )
793 {
794 if ( *b2 )
795 {
797 }
798 }
799 }
800 }
801 break;
802
803 case form::FormComponentType::TEXTFIELD:
804 {
805 Size aSz( 0, 0 );
806 GetControlSize( rFormObj, aSz, rWrt.m_pDoc );
807
808 bool bMultiLine = false;
809 OUString sMultiLine("MultiLine");
810 if( xPropSetInfo->hasPropertyByName( sMultiLine ) )
811 {
812 aTmp = xPropSet->getPropertyValue( sMultiLine );
813 auto b = o3tl::tryAccess<bool>(aTmp);
814 bMultiLine = b && *b;
815 }
816
817 if( bMultiLine )
818 {
819 if( rHTMLWrt.m_bLFPossible )
820 rHTMLWrt.OutNewLine( true );
821 eTag = TAG_TEXTAREA;
822
823 if( aSz.Height() )
824 {
825 sOptions += " " OOO_STRING_SVTOOLS_HTML_O_rows "=\"" +
826 OString::number(static_cast<sal_Int32>(aSz.Height())) + "\"";
827 }
828 if( aSz.Width() )
829 {
830 sOptions += " " OOO_STRING_SVTOOLS_HTML_O_cols "=\"" +
831 OString::number(static_cast<sal_Int32>(aSz.Width())) + "\"";
832 }
833
834 aTmp = xPropSet->getPropertyValue( "HScroll" );
835 if( aTmp.getValueType() == cppu::UnoType<void>::get() ||
836 (aTmp.getValueType() == cppu::UnoType<bool>::get() &&
837 !*o3tl::forceAccess<bool>(aTmp)) )
838 {
839 const char *pWrapStr = nullptr;
840 auto aTmp2 = xPropSet->getPropertyValue( "HardLineBreaks" );
841 auto b = o3tl::tryAccess<bool>(aTmp2);
842 pWrapStr = (b && *b) ? OOO_STRING_SVTOOLS_HTML_WW_hard
844 sOptions += OString::Concat(" " OOO_STRING_SVTOOLS_HTML_O_wrap "=\"") +
845 pWrapStr + "\"";
846 }
847 }
848 else
849 {
851 OUString sEchoChar("EchoChar");
852 if( xPropSetInfo->hasPropertyByName( sEchoChar ) )
853 {
854 aTmp = xPropSet->getPropertyValue( sEchoChar );
855 if( auto n = o3tl::tryAccess<sal_Int16>(aTmp) )
856 {
857 if( *n != 0 )
858 eType = TYPE_PASSWORD;
859 }
860 }
861
862 if( aSz.Width() )
863 {
864 sOptions += " " OOO_STRING_SVTOOLS_HTML_O_size "=\"" +
865 OString::number(static_cast<sal_Int32>(aSz.Width())) + "\"";
866 }
867
868 aTmp = xPropSet->getPropertyValue( "MaxTextLen" );
869 if( auto n = o3tl::tryAccess<sal_Int16>(aTmp) )
870 {
871 if( *n != 0 )
872 {
873 sOptions += " " OOO_STRING_SVTOOLS_HTML_O_maxlength "=\"" +
874 OString::number(static_cast<sal_Int32>(*n)) + "\"";
875 }
876 }
877
878 if( xPropSetInfo->hasPropertyByName( "DefaultText" ) )
879 {
880 aTmp = xPropSet->getPropertyValue( "DefaultText" );
881 if( auto s = o3tl::tryAccess<OUString>(aTmp) )
882 {
883 if( !s->isEmpty() )
884 {
885 sValue = *s;
886 }
887 }
888 }
889 }
890 }
891 break;
892
893 case form::FormComponentType::FILECONTROL:
894 {
895 Size aSz( 0, 0 );
896 GetControlSize( rFormObj, aSz, rWrt.m_pDoc );
897 eType = TYPE_FILE;
898
899 if( aSz.Width() )
900 {
901 sOptions += " " OOO_STRING_SVTOOLS_HTML_O_size "=\"" +
902 OString::number(static_cast<sal_Int32>(aSz.Width())) + "\"";
903 }
904
905 // VALUE vim form: don't export because of security reasons
906 }
907 break;
908
909 case form::FormComponentType::IMAGEBUTTON:
911 nFrameOpts = HTML_FRMOPTS_IMG_CONTROL;
912 break;
913
914 default: // doesn't know HTML
915 eTag = TAG_NONE; // therefore skip it
916 break;
917 }
918
919 if( eTag == TAG_NONE )
920 return rWrt;
921
922 OString sOut = OString::Concat("<") + TagNames[eTag];
923 if( eType != TYPE_NONE )
924 {
925 sOut += OString::Concat(" " OOO_STRING_SVTOOLS_HTML_O_type "=\"") +
926 TypeNames[eType] + "\"";
927 }
928
929 aTmp = xPropSet->getPropertyValue("Name");
930 if( auto s = o3tl::tryAccess<OUString>(aTmp) )
931 {
932 if( !s->isEmpty() )
933 {
934 sOut += " " OOO_STRING_SVTOOLS_HTML_O_name "=\"";
935 rWrt.Strm().WriteOString( sOut );
936 HTMLOutFuncs::Out_String( rWrt.Strm(), *s );
937 sOut = "\"";
938 }
939 }
940
941 aTmp = xPropSet->getPropertyValue("Enabled");
942 if( auto b = o3tl::tryAccess<bool>(aTmp) )
943 {
944 if( !*b )
945 {
947 }
948 }
949
950 if( !sValue.isEmpty() || bEmptyValue )
951 {
952 sOut += " " OOO_STRING_SVTOOLS_HTML_O_value "=\"";
953 rWrt.Strm().WriteOString( sOut );
954 HTMLOutFuncs::Out_String( rWrt.Strm(), sValue );
955 sOut = "\"";
956 }
957
958 sOut += " " + sOptions;
959
960 if( TYPE_IMAGE == eType )
961 {
962 aTmp = xPropSet->getPropertyValue( "ImageURL" );
963 if( auto s = o3tl::tryAccess<OUString>(aTmp) )
964 {
965 if( !s->isEmpty() )
966 {
967 sOut += " " OOO_STRING_SVTOOLS_HTML_O_src "=\"";
968 rWrt.Strm().WriteOString( sOut );
969
972 sOut = "\"";
973 }
974 }
975
976 Size aTwipSz( rFormObj.GetLogicRect().GetSize() );
977 Size aPixelSz( 0, 0 );
978 if( (aTwipSz.Width() || aTwipSz.Height()) &&
980 {
981 aPixelSz =
983 MapMode(MapUnit::MapTwip) );
984 if( !aPixelSz.Width() && aTwipSz.Width() )
985 aPixelSz.setWidth( 1 );
986 if( !aPixelSz.Height() && aTwipSz.Height() )
987 aPixelSz.setHeight( 1 );
988 }
989
990 if( aPixelSz.Width() )
991 {
992 sOut += " " OOO_STRING_SVTOOLS_HTML_O_width "=\"" +
993 OString::number(static_cast<sal_Int32>(aPixelSz.Width())) + "\"";
994 }
995
996 if( aPixelSz.Height() )
997 {
998 sOut += " " OOO_STRING_SVTOOLS_HTML_O_height "=\"" +
999 OString::number(static_cast<sal_Int32>(aPixelSz.Height())) + "\"";
1000 }
1001 }
1002
1003 aTmp = xPropSet->getPropertyValue( "TabIndex" );
1004 if( auto n = o3tl::tryAccess<sal_Int16>(aTmp) )
1005 {
1006 sal_Int16 nTabIndex = *n;
1007 if( nTabIndex > 0 )
1008 {
1009 if( nTabIndex >= 32767 )
1010 nTabIndex = 32767;
1011
1012 sOut += " " OOO_STRING_SVTOOLS_HTML_O_tabindex "=\"" +
1013 OString::number(static_cast<sal_Int32>(nTabIndex)) + "\"";
1014 }
1015 }
1016
1017 if( !sOut.isEmpty() )
1018 rWrt.Strm().WriteOString( sOut );
1019
1020 OSL_ENSURE( !bInCntnr, "Container is not supported for Controls" );
1021 if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_DRAW ) && !bInCntnr )
1022 {
1023 // If Character-Objects can't be positioned absolutely,
1024 // then delete the corresponding flag.
1025 nFrameOpts |= (TYPE_IMAGE == eType
1028 }
1029 OString aEndTags;
1030 if( nFrameOpts != HtmlFrmOpts::NONE )
1031 aEndTags = rHTMLWrt.OutFrameFormatOptions(rFormat, OUString(), nFrameOpts);
1032
1033 if( rHTMLWrt.m_bCfgOutStyles )
1034 {
1035 bool bEdit = TAG_TEXTAREA == eTag || TYPE_FILE == eType ||
1036 TYPE_TEXT == eType;
1037
1039 if( xPropSetInfo->hasPropertyByName( "BackgroundColor" ) )
1040 {
1041 aTmp = xPropSet->getPropertyValue( "BackgroundColor" );
1042 if( auto n = o3tl::tryAccess<sal_Int32>(aTmp) )
1043 {
1044 Color aCol(ColorTransparency, *n);
1045 aItemSet.Put( SvxBrushItem( aCol, RES_CHRATR_BACKGROUND ) );
1046 }
1047 }
1048 if( xPropSetInfo->hasPropertyByName( "TextColor" ) )
1049 {
1050 aTmp = xPropSet->getPropertyValue( "TextColor" );
1051 if( auto n = o3tl::tryAccess<sal_Int32>(aTmp) )
1052 {
1053 Color aColor( ColorTransparency, *n );
1054 aItemSet.Put( SvxColorItem( aColor, RES_CHRATR_COLOR ) );
1055 }
1056 }
1057 if( xPropSetInfo->hasPropertyByName( "FontHeight" ) )
1058 {
1059 aTmp = xPropSet->getPropertyValue( "FontHeight" );
1060 if( auto nHeight = o3tl::tryAccess<float>(aTmp) )
1061
1062 {
1063 if( *nHeight > 0 && (!bEdit || !rtl::math::approxEqual(*nHeight, 10.0)) )
1064 aItemSet.Put( SvxFontHeightItem( sal_Int16(*nHeight * 20.), 100, RES_CHRATR_FONTSIZE ) );
1065 }
1066 }
1067 if( xPropSetInfo->hasPropertyByName( "FontName" ) )
1068 {
1069 aTmp = xPropSet->getPropertyValue( "FontName" );
1070 if( auto aFName = o3tl::tryAccess<OUString>(aTmp) )
1071 {
1072 if( !aFName->isEmpty() )
1073 {
1075 DefaultFontType::FIXED, LANGUAGE_ENGLISH_US,
1076 GetDefaultFontFlags::OnlyOne ) );
1077 if( !bEdit || *aFName != aFixedFont.GetFamilyName() )
1078 {
1079 FontFamily eFamily = FAMILY_DONTKNOW;
1080 if( xPropSetInfo->hasPropertyByName( "FontFamily" ) )
1081 {
1082 auto aTmp2 = xPropSet->getPropertyValue( "FontFamily" );
1083 if( auto n = o3tl::tryAccess<sal_Int16>(aTmp2) )
1084 eFamily = static_cast<FontFamily>(*n);
1085 }
1086 SvxFontItem aItem(eFamily, *aFName, OUString(), PITCH_DONTKNOW, RTL_TEXTENCODING_DONTKNOW, RES_CHRATR_FONT);
1087 aItemSet.Put( aItem );
1088 }
1089 }
1090 }
1091 }
1092 if( xPropSetInfo->hasPropertyByName( "FontWeight" ) )
1093 {
1094 aTmp = xPropSet->getPropertyValue( "FontWeight" );
1095 if( auto x = o3tl::tryAccess<float>(aTmp) )
1096 {
1097 FontWeight eWeight =
1099 if( eWeight != WEIGHT_DONTKNOW && eWeight != WEIGHT_NORMAL )
1100 aItemSet.Put( SvxWeightItem( eWeight, RES_CHRATR_WEIGHT ) );
1101 }
1102 }
1103 if( xPropSetInfo->hasPropertyByName( "FontSlant" ) )
1104 {
1105 aTmp = xPropSet->getPropertyValue( "FontSlant" );
1106 if( auto n = o3tl::tryAccess<sal_Int16>(aTmp) )
1107 {
1108 FontItalic eItalic = static_cast<FontItalic>(*n);
1109 if( eItalic != ITALIC_DONTKNOW && eItalic != ITALIC_NONE )
1110 aItemSet.Put( SvxPostureItem( eItalic, RES_CHRATR_POSTURE ) );
1111 }
1112 }
1113 if( xPropSetInfo->hasPropertyByName( "FontLineStyle" ) )
1114 {
1115 aTmp = xPropSet->getPropertyValue( "FontLineStyle" );
1116 if( auto n = o3tl::tryAccess<sal_Int16>(aTmp) )
1117 {
1118 FontLineStyle eUnderline = static_cast<FontLineStyle>(*n);
1119 if( eUnderline != LINESTYLE_DONTKNOW &&
1120 eUnderline != LINESTYLE_NONE )
1121 aItemSet.Put( SvxUnderlineItem( eUnderline, RES_CHRATR_UNDERLINE ) );
1122 }
1123 }
1124 if( xPropSetInfo->hasPropertyByName( "FontStrikeout" ) )
1125 {
1126 aTmp = xPropSet->getPropertyValue( "FontStrikeout" );
1127 if( auto n = o3tl::tryAccess<sal_Int16>(aTmp) )
1128 {
1129 FontStrikeout eStrikeout = static_cast<FontStrikeout>(*n);
1130 if( eStrikeout != STRIKEOUT_DONTKNOW &&
1131 eStrikeout != STRIKEOUT_NONE )
1132 aItemSet.Put( SvxCrossedOutItem( eStrikeout, RES_CHRATR_CROSSEDOUT ) );
1133 }
1134 }
1135
1136 rHTMLWrt.OutCSS1_FrameFormatOptions( rFormat, nFrameOpts, &rFormObj,
1137 &aItemSet );
1138 }
1139
1140 uno::Reference< form::XFormComponent > xFormComp( xControlModel, uno::UNO_QUERY );
1141 lcl_html_outEvents( rWrt.Strm(), xFormComp, rHTMLWrt.m_bCfgStarBasic );
1142
1143 rWrt.Strm().WriteChar( '>' );
1144
1145 if( TAG_SELECT == eTag )
1146 {
1147 aTmp = xPropSet->getPropertyValue( "StringItemList" );
1148 if( auto aList = o3tl::tryAccess<uno::Sequence<OUString>>(aTmp) )
1149 {
1150 rHTMLWrt.IncIndentLevel(); // the content of Select can be indented
1151 sal_Int32 nCnt = aList->getLength();
1152 const OUString *pStrings = aList->getConstArray();
1153
1154 const OUString *pValues = nullptr;
1155 sal_Int32 nValCnt = 0;
1156 auto aTmp2 = xPropSet->getPropertyValue( "ListSource" );
1157 uno::Sequence<OUString> aValList;
1158 if( auto s = o3tl::tryAccess<uno::Sequence<OUString>>(aTmp2) )
1159 {
1160 aValList = *s;
1161 nValCnt = aValList.getLength();
1162 pValues = aValList.getConstArray();
1163 }
1164
1165 uno::Any aSelTmp = xPropSet->getPropertyValue( "DefaultSelection" );
1166 const sal_Int16 *pSels = nullptr;
1167 sal_Int32 nSel = 0;
1168 sal_Int32 nSelCnt = 0;
1169 uno::Sequence<sal_Int16> aSelList;
1170 if( auto s = o3tl::tryAccess<uno::Sequence<sal_Int16>>(aSelTmp) )
1171 {
1172 aSelList = *s;
1173 nSelCnt = aSelList.getLength();
1174 pSels = aSelList.getConstArray();
1175 }
1176
1177 for( sal_Int32 i = 0; i < nCnt; i++ )
1178 {
1179 OUString sVal;
1180 bool bSelected = false, bEmptyVal = false;
1181 if( i < nValCnt )
1182 {
1183 const OUString& rVal = pValues[i];
1184 if( rVal == "$$$empty$$$" )
1185 bEmptyVal = true;
1186 else
1187 sVal = rVal;
1188 }
1189
1190 bSelected = (nSel < nSelCnt) && pSels[nSel] == i;
1191 if( bSelected )
1192 nSel++;
1193
1194 rHTMLWrt.OutNewLine(); // every Option gets its own line
1195 sOut = "<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_option;
1196 if( !sVal.isEmpty() || bEmptyVal )
1197 {
1198 sOut += " " OOO_STRING_SVTOOLS_HTML_O_value "=\"";
1199 rWrt.Strm().WriteOString( sOut );
1200 HTMLOutFuncs::Out_String( rWrt.Strm(), sVal );
1201 sOut = "\"";
1202 }
1203 if( bSelected )
1205
1206 sOut += ">";
1207 rWrt.Strm().WriteOString( sOut );
1208
1209 HTMLOutFuncs::Out_String( rWrt.Strm(), pStrings[i] );
1210 }
1211 HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_option), false );
1212
1213 rHTMLWrt.DecIndentLevel();
1214 rHTMLWrt.OutNewLine();// the </SELECT> gets its own line
1215 }
1216 HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_select), false );
1217 }
1218 else if( TAG_TEXTAREA == eTag )
1219 {
1220 // In TextAreas no additional spaces or LF may be exported!
1221 OUString sVal;
1222 aTmp = xPropSet->getPropertyValue( "DefaultText" );
1223 if( auto s = o3tl::tryAccess<OUString>(aTmp) )
1224 {
1225 if( !s->isEmpty() )
1226 {
1227 sVal = *s;
1228 }
1229 }
1230 if( !sVal.isEmpty() )
1231 {
1232 sVal = convertLineEnd(sVal, LINEEND_LF);
1233 sal_Int32 nPos = 0;
1234 while ( nPos != -1 )
1235 {
1236 if( nPos )
1238 OUString aLine = sVal.getToken( 0, 0x0A, nPos );
1239 HTMLOutFuncs::Out_String( rWrt.Strm(), aLine );
1240 }
1241 }
1242 HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_textarea), false );
1243 }
1244 else if( TYPE_CHECKBOX == eType || TYPE_RADIO == eType )
1245 {
1246 aTmp = xPropSet->getPropertyValue("Label");
1247 if( auto s = o3tl::tryAccess<OUString>(aTmp) )
1248 {
1249 if( !s->isEmpty() )
1250 {
1251 HTMLOutFuncs::Out_String( rWrt.Strm(), *s ).WriteChar( ' ' );
1252 }
1253 }
1254 }
1255
1256 if( !aEndTags.isEmpty() )
1257 rWrt.Strm().WriteOString( aEndTags );
1258
1259 // Controls aren't bound to a paragraph, therefore don't output LF anymore!
1260 rHTMLWrt.m_bLFPossible = false;
1261
1262 if( rHTMLWrt.mxFormComps.is() )
1263 rHTMLWrt.OutHiddenControls( rHTMLWrt.mxFormComps, xPropSet );
1264 return rWrt;
1265}
1266
1270static void AddControl( HTMLControls& rControls,
1271 const SdrUnoObj& rFormObj,
1272 SwNodeOffset nNodeIdx )
1273{
1274 const uno::Reference< awt::XControlModel >& xControlModel =
1275 rFormObj.GetUnoControlModel();
1276 if( !xControlModel.is() )
1277 return;
1278
1279 uno::Reference< form::XFormComponent > xFormComp( xControlModel, uno::UNO_QUERY );
1280 uno::Reference< uno::XInterface > xIfc = xFormComp->getParent();
1281 uno::Reference< form::XForm > xForm(xIfc, uno::UNO_QUERY);
1282
1283 OSL_ENSURE( xForm.is(), "Where is the form?" );
1284 if( xForm.is() )
1285 {
1286 uno::Reference< container::XIndexContainer > xFormComps( xForm, uno::UNO_QUERY );
1287 std::unique_ptr<HTMLControl> pHCntrl(new HTMLControl( xFormComps, nNodeIdx ));
1288 auto itPair = rControls.insert( std::move(pHCntrl) );
1289 if (!itPair.second )
1290 {
1291 if( (*itPair.first)->xFormComps==xFormComps )
1292 (*itPair.first)->nCount++;
1293 }
1294 }
1295}
1296
1298{
1299 // Idea: first off collect the paragraph- and character-bound controls.
1300 // In the process for every control the paragraph position and VCForm are
1301 // saved in an array.
1302 // With that array it's possible to find out where form::Forms must be
1303 // opened and closed.
1304
1305 // collect the paragraph-bound controls
1306 for( size_t i=0; i<m_aHTMLPosFlyFrames.size(); i++ )
1307 {
1308 const SwHTMLPosFlyFrame* pPosFlyFrame = m_aHTMLPosFlyFrames[ i ].get();
1309 if( HtmlOut::Control != pPosFlyFrame->GetOutFn() )
1310 continue;
1311
1312 const SdrObject *pSdrObj = pPosFlyFrame->GetSdrObject();
1313 OSL_ENSURE( pSdrObj, "Where is the SdrObject?" );
1314 if( !pSdrObj )
1315 continue;
1316
1317 AddControl( m_aHTMLControls, dynamic_cast<const SdrUnoObj&>(*pSdrObj),
1318 pPosFlyFrame->GetNdIndex().GetIndex() );
1319 }
1320
1321 // and now the ones in a character-bound frame
1322 const SwFrameFormats* pSpzFrameFormats = m_pDoc->GetSpzFrameFormats();
1323 for( size_t i=0; i<pSpzFrameFormats->size(); i++ )
1324 {
1325 const SwFrameFormat *pFrameFormat = (*pSpzFrameFormats)[i];
1326 if( RES_DRAWFRMFMT != pFrameFormat->Which() )
1327 continue;
1328
1329 const SwFormatAnchor& rAnchor = pFrameFormat->GetAnchor();
1330 const SwNode *pAnchorNode = rAnchor.GetAnchorNode();
1331 if ((RndStdIds::FLY_AS_CHAR != rAnchor.GetAnchorId()) || !pAnchorNode)
1332 continue;
1333
1334 const SdrObject *pSdrObj =
1335 SwHTMLWriter::GetHTMLControl( *static_cast<const SwDrawFrameFormat*>(pFrameFormat) );
1336 if( !pSdrObj )
1337 continue;
1338
1339 AddControl( m_aHTMLControls, dynamic_cast<const SdrUnoObj&>(*pSdrObj), pAnchorNode->GetIndex() );
1340 }
1341}
1342
1344 uno::Reference< container::XIndexContainer > _xFormComps,
1345 SwNodeOffset nIdx ) :
1346 xFormComps(std::move( _xFormComps )), nNdIdx( nIdx ), nCount( 1 )
1347{}
1348
1350{}
1351
1352/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const PropertyValue * pValues
Tag
XPropertyListType t
static OutputDevice * GetDefaultDevice()
virtual const SwDrawModel * GetDrawModel() const =0
Draw Model and id accessors.
virtual const SwViewShell * GetCurrentViewShell() const =0
Returns the layout set at the document.
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
static vcl::Font GetDefaultFont(DefaultFontType nType, LanguageType eLang, GetDefaultFontFlags nFlags, const OutputDevice *pOutDev=nullptr)
virtual SdrInventor GetObjInventor() const
virtual const tools::Rectangle & GetLogicRect() const override
const css::uno::Reference< css::awt::XControlModel > & GetUnoControlModel() const
css::uno::Reference< css::awt::XControl > GetUnoControl(const SdrView &_rView, const OutputDevice &_rOut) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
css::uno::Reference< css::frame::XModel3 > GetBaseModel() const
constexpr tools::Long Height() const
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
SvStream & WriteOString(std::string_view rStr)
SvStream & WriteChar(char nChar)
SvStream & WriteCharPtr(const char *pBuf)
Definition: doc.hxx:195
SwNodes & GetNodes()
Definition: doc.hxx:418
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:413
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1329
IDocumentDrawModelAccess const & getIDocumentDrawModelAccess() const
Definition: doc.cxx:163
const SwFrameFormats * GetSpzFrameFormats() const
Definition: doc.hxx:753
SwDocShell * GetDocShell()
Definition: doc.hxx:1362
FlyAnchors.
Definition: fmtanchr.hxx:37
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:67
SwNode * GetAnchorNode() const
Definition: atrfrm.cxx:1606
sal_uInt16 Which() const
for Querying of Writer-functions.
Definition: format.hxx:82
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:88
Style of a layout element.
Definition: frmfmt.hxx:62
SdrObject * FindSdrObject()
Definition: frmfmt.hxx:141
Specific frame formats (frames, DrawObjects).
size_t size() const
HtmlOut GetOutFn() const
Definition: htmlfly.hxx:120
const SwNodeIndex & GetNdIndex() const
Definition: htmlfly.hxx:117
const SdrObject * GetSdrObject() const
Definition: htmlfly.hxx:116
bool m_bPreserveForm
Definition: wrthtml.hxx:399
SwHTMLPosFlyFrames m_aHTMLPosFlyFrames
Definition: wrthtml.hxx:274
void OutHiddenControls(const css::uno::Reference< css::container::XIndexContainer > &rFormComps, const css::uno::Reference< css::beans::XPropertySet > &rPropSet)
Definition: htmlforw.cxx:530
bool HasControls() const
Definition: htmlforw.cxx:213
void OutHiddenForm(const css::uno::Reference< css::form::XForm > &rForm)
Definition: htmlforw.cxx:380
void IncIndentLevel()
Definition: wrthtml.hxx:525
void OutHiddenForms()
Definition: htmlforw.cxx:338
bool m_bLFPossible
Definition: wrthtml.hxx:395
css::uno::Reference< css::container::XIndexContainer > mxFormComps
Definition: wrthtml.hxx:313
bool m_bCfgOutStyles
Definition: wrthtml.hxx:355
HTMLControls m_aHTMLControls
Definition: wrthtml.hxx:304
void DecIndentLevel()
Definition: wrthtml.hxx:529
sal_uInt16 m_nFormCntrlCnt
Definition: wrthtml.hxx:329
OString GetNamespace() const
Determines the prefix string needed to respect the requested namespace alias.
Definition: wrthtml.cxx:1570
void GetControls()
Definition: htmlforw.cxx:1297
OString OutFrameFormatOptions(const SwFrameFormat &rFrameFormat, const OUString &rAltText, HtmlFrmOpts nFrameOpts)
void OutCSS1_FrameFormatOptions(const SwFrameFormat &rFrameFormat, HtmlFrmOpts nFrameOpts, const SdrObject *pSdrObj=nullptr, const SfxItemSet *pItemSet=nullptr)
Definition: css1atr.cxx:1853
void OutNewLine(bool bCheck=false)
Definition: wrthtml.cxx:1521
bool m_bCfgStarBasic
Definition: wrthtml.hxx:358
static const SdrObject * GetHTMLControl(const SwDrawFrameFormat &rFormat)
Definition: htmlforw.cxx:614
bool IsHTMLMode(sal_uInt32 nMode) const
Definition: wrthtml.hxx:598
void OutForm(bool bTagOn=true, const SwStartNode *pStNd=nullptr)
Definition: htmlforw.cxx:225
SwNodeOffset GetIndex() const
Definition: ndindex.hxx:171
Base class of the Writer document model elements.
Definition: node.hxx:98
SwNodeOffset GetIndex() const
Definition: node.hxx:312
SwNodeOffset EndOfSectionIndex() const
Definition: node.hxx:728
Starts a section of nodes in the document model.
Definition: node.hxx:348
vcl::Window * GetWin() const
Definition: viewsh.hxx:346
SdrView * GetDrawView()
Definition: vnew.cxx:373
SvStream & Strm()
Definition: writer.cxx:214
SwDoc * m_pDoc
Definition: shellio.hxx:399
std::shared_ptr< SwUnoCursor > m_pCurrentPam
Definition: shellio.hxx:401
const OUString & GetBaseURL() const
Definition: shellio.hxx:435
size_type size() const
std::pair< const_iterator, bool > insert(Value &&x)
constexpr Size GetSize() const
const OUString & GetFamilyName() const
::OutputDevice const * GetOutDev() const
ColorTransparency
#define SAL_NEWLINE_STRING
int nCount
URL aURL
float x
OUString const aScriptType
DocumentType eType
FontLineStyle
LINESTYLE_NONE
LINESTYLE_DONTKNOW
FontStrikeout
STRIKEOUT_NONE
STRIKEOUT_DONTKNOW
PITCH_DONTKNOW
FontItalic
ITALIC_NONE
ITALIC_DONTKNOW
FontFamily
FAMILY_DONTKNOW
WEIGHT_NORMAL
WEIGHT_DONTKNOW
TRISTATE_FALSE
#define TYPE_CHECKBOX
constexpr TypedWhichId< SvxCrossedOutItem > RES_CHRATR_CROSSEDOUT(5)
constexpr TypedWhichId< SvxUnderlineItem > RES_CHRATR_UNDERLINE(14)
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_FONTSIZE(8)
constexpr TypedWhichId< SvxWeightItem > RES_CHRATR_WEIGHT(15)
constexpr TypedWhichId< SvxBrushItem > RES_CHRATR_BACKGROUND(21)
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(159)
constexpr TypedWhichId< SvxPostureItem > RES_CHRATR_POSTURE(11)
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_FONT(7)
constexpr TypedWhichId< SvxColorItem > RES_CHRATR_COLOR(3)
const char * aEventListenerTable[]
Definition: htmlform.cxx:139
const char * aEventSDOptionTable[]
Definition: htmlform.cxx:163
const char * aEventOptionTable[]
Definition: htmlform.cxx:175
const char * aEventMethodTable[]
Definition: htmlform.cxx:151
static void lcl_html_outEvents(SvStream &rStrm, const uno::Reference< form::XFormComponent > &rFormComp, bool bCfgStarBasic)
Definition: htmlforw.cxx:81
static void GetControlSize(const SdrUnoObj &rFormObj, Size &rSz, SwDoc *pDoc)
Definition: htmlforw.cxx:651
Writer & OutHTML_DrawFrameFormatAsControl(Writer &rWrt, const SwDrawFrameFormat &rFormat, const SdrUnoObj &rFormObj, bool bInCntnr)
Definition: htmlforw.cxx:673
const HtmlFrmOpts HTML_FRMOPTS_CONTROL_CSS1
Definition: htmlforw.cxx:69
static bool lcl_html_isHTMLControl(sal_Int16 nClassId)
Definition: htmlforw.cxx:193
static void AddControl(HTMLControls &rControls, const SdrUnoObj &rFormObj, SwNodeOffset nNodeIdx)
Find out if a format belongs to a control and if yes return its form.
Definition: htmlforw.cxx:1270
const HtmlFrmOpts HTML_FRMOPTS_IMG_CONTROL_CSS1
Definition: htmlforw.cxx:77
const HtmlFrmOpts HTML_FRMOPTS_CONTROL
Definition: htmlforw.cxx:67
const HtmlFrmOpts HTML_FRMOPTS_IMG_CONTROL
Definition: htmlforw.cxx:74
#define OOO_STRING_SVTOOLS_HTML_IT_checkbox
#define OOO_STRING_SVTOOLS_HTML_O_height
#define OOO_STRING_SVTOOLS_HTML_O_selected
#define OOO_STRING_SVTOOLS_HTML_IT_password
#define OOO_STRING_SVTOOLS_HTML_O_target
#define OOO_STRING_SVTOOLS_HTML_IT_button
#define OOO_STRING_SVTOOLS_HTML_O_rows
#define OOO_STRING_SVTOOLS_HTML_O_action
#define OOO_STRING_SVTOOLS_HTML_O_value
#define OOO_STRING_SVTOOLS_HTML_IT_reset
#define OOO_STRING_SVTOOLS_HTML_IT_submit
#define OOO_STRING_SVTOOLS_HTML_IT_file
#define OOO_STRING_SVTOOLS_HTML_O_tabindex
#define OOO_STRING_SVTOOLS_HTML_WW_soft
#define OOO_STRING_SVTOOLS_HTML_O_multiple
#define OOO_STRING_SVTOOLS_HTML_IT_image
#define OOO_STRING_SVTOOLS_HTML_O_size
#define OOO_STRING_SVTOOLS_HTML_IT_hidden
#define OOO_STRING_SVTOOLS_HTML_option
#define OOO_STRING_SVTOOLS_HTML_O_disabled
#define OOO_STRING_SVTOOLS_HTML_ET_text
#define OOO_STRING_SVTOOLS_HTML_O_wrap
#define OOO_STRING_SVTOOLS_HTML_O_src
#define OOO_STRING_SVTOOLS_HTML_METHOD_post
#define OOO_STRING_SVTOOLS_HTML_textarea
#define OOO_STRING_SVTOOLS_HTML_O_cols
#define OOO_STRING_SVTOOLS_HTML_O_maxlength
#define OOO_STRING_SVTOOLS_HTML_IT_text
#define OOO_STRING_SVTOOLS_HTML_O_sdaddparam
#define OOO_STRING_SVTOOLS_HTML_form
#define OOO_STRING_SVTOOLS_HTML_O_checked
#define OOO_STRING_SVTOOLS_HTML_O_sdevent
#define OOO_STRING_SVTOOLS_HTML_O_type
#define OOO_STRING_SVTOOLS_HTML_select
#define OOO_STRING_SVTOOLS_HTML_on
#define OOO_STRING_SVTOOLS_HTML_O_name
#define OOO_STRING_SVTOOLS_HTML_IT_radio
#define OOO_STRING_SVTOOLS_HTML_WW_hard
#define OOO_STRING_SVTOOLS_HTML_O_width
#define OOO_STRING_SVTOOLS_HTML_ET_multipart
#define OOO_STRING_SVTOOLS_HTML_O_method
#define OOO_STRING_SVTOOLS_HTML_input
sal_Int64 n
#define LANGUAGE_ENGLISH_US
LINEEND_LF
TOOLS_DLLPUBLIC OString convertLineEnd(const OString &rIn, LineEnd eLineEnd)
sal_uInt16 nPos
ScriptType
EXTENDED_STYPE
JAVASCRIPT
STARBASIC
constexpr OUStringLiteral SVX_MACRO_LANGUAGE_JAVASCRIPT
constexpr OUStringLiteral SVX_MACRO_LANGUAGE_STARBASIC
SVL_DLLPUBLIC OUString simpleNormalizedMakeRelative(OUString const &baseUriReference, OUString const &uriReference)
Type
const sal_uInt16 TYPE_IMAGE
const sal_uInt16 TYPE_TEXT
int i
void SvStream & rStrm
detail::Optional< bool >::type tryAccess< bool >(css::uno::Any const &any)
detail::Optional< float >::type tryAccess< float >(css::uno::Any const &any)
detail::Optional< sal_Int32 >::type tryAccess< sal_Int32 >(css::uno::Any const &any)
detail::Optional< sal_Int16 >::type tryAccess< sal_Int16 >(css::uno::Any const &any)
std::enable_if<!(detail::IsDerivedReference< T >::value||detail::IsUnoSequenceType< T >::value||std::is_base_of< css::uno::XInterface, T >::value), typenamedetail::Optional< T >::type >::type tryAccess(css::uno::Any const &any)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
FontWeight
VCL_DLLPUBLIC float ConvertFontWeight(FontWeight eWeight)
HTMLControl(css::uno::Reference< css::container::XIndexContainer > xForm, SwNodeOffset nIdx)
Definition: htmlforw.cxx:1343
static SVT_DLLPUBLIC SvStream & Out_AsciiTag(SvStream &, std::string_view rStr, bool bOn=true)
static SVT_DLLPUBLIC SvStream & Out_String(SvStream &, const OUString &, OUString *pNonConvertableChars=nullptr)
HtmlFrmOpts
Definition: wrthtml.hxx:76
#define HTMLMODE_ABS_POS_DRAW
Definition: wrthtml.hxx:124