LibreOffice Module sw (master)  1
htmlform.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 <sal/config.h>
21 
22 #include <string_view>
23 
24 #include <hintids.hxx>
26 #include <comphelper/string.hxx>
27 #include <vcl/svapp.hxx>
28 #include <tools/UnitConversion.hxx>
29 
30 #include <o3tl/string_view.hxx>
31 #include <tools/diagnose_ex.h>
32 #include <vcl/unohelp.hxx>
33 #include <svtools/htmlkywd.hxx>
34 #include <svtools/htmltokn.h>
35 #include <svl/urihelper.hxx>
36 #include <sfx2/docfile.hxx>
37 #include <sfx2/event.hxx>
38 #include <sfx2/sfxsids.hrc>
39 #include <sfx2/viewfrm.hxx>
40 #include <editeng/lrspitem.hxx>
41 #include <editeng/ulspitem.hxx>
42 #include <editeng/brushitem.hxx>
43 #include <editeng/colritem.hxx>
44 #include <editeng/fontitem.hxx>
45 #include <editeng/fhgtitem.hxx>
46 #include <editeng/wghtitem.hxx>
47 #include <editeng/postitem.hxx>
48 #include <editeng/udlnitem.hxx>
50 #include <svx/svdouno.hxx>
51 #include <cppuhelper/implbase.hxx>
52 #include <com/sun/star/form/ListSourceType.hpp>
53 #include <com/sun/star/form/FormButtonType.hpp>
54 #include <com/sun/star/form/FormSubmitEncoding.hpp>
55 #include <com/sun/star/form/FormSubmitMethod.hpp>
56 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
57 #include <com/sun/star/script/XEventAttacherManager.hpp>
58 #include <com/sun/star/text/WrapTextMode.hpp>
59 #include <com/sun/star/text/HoriOrientation.hpp>
60 #include <com/sun/star/text/VertOrientation.hpp>
61 #include <com/sun/star/text/TextContentAnchorType.hpp>
62 #include <com/sun/star/container/XIndexContainer.hpp>
63 #include <com/sun/star/drawing/XControlShape.hpp>
64 #include <com/sun/star/awt/XTextLayoutConstrains.hpp>
65 #include <com/sun/star/awt/XLayoutConstrains.hpp>
66 #include <com/sun/star/awt/XImageConsumer.hpp>
67 #include <com/sun/star/awt/ImageStatus.hpp>
68 #include <com/sun/star/form/XImageProducerSupplier.hpp>
69 #include <com/sun/star/form/XForm.hpp>
70 #include <doc.hxx>
72 #include <IDocumentUndoRedo.hxx>
73 #include <pam.hxx>
74 #include <swtable.hxx>
75 #include <fmtanchr.hxx>
76 #include <htmltbl.hxx>
77 #include <docsh.hxx>
78 #include <viewsh.hxx>
79 #include <unodraw.hxx>
80 #include <unotextrange.hxx>
81 
82 #include "swcss1.hxx"
83 #include "swhtml.hxx"
84 #include "htmlform.hxx"
85 
86 using namespace ::com::sun::star;
87 using namespace ::com::sun::star::uno;
88 using namespace ::com::sun::star::lang;
89 using namespace ::com::sun::star::form;
90 
91 const sal_uInt16 TABINDEX_MIN = 0;
92 const sal_uInt16 TABINDEX_MAX = 32767;
93 
95 {
96  { OOO_STRING_SVTOOLS_HTML_METHOD_get, FormSubmitMethod_GET },
97  { OOO_STRING_SVTOOLS_HTML_METHOD_post, FormSubmitMethod_POST },
98  { nullptr, FormSubmitMethod(0) }
99 };
100 
102 {
103  { OOO_STRING_SVTOOLS_HTML_ET_url, FormSubmitEncoding_URL },
104  { OOO_STRING_SVTOOLS_HTML_ET_multipart, FormSubmitEncoding_MULTIPART },
105  { OOO_STRING_SVTOOLS_HTML_ET_text, FormSubmitEncoding_TEXT },
106  { nullptr, FormSubmitEncoding(0) }
107 };
108 
109 namespace {
110 
111 enum HTMLWordWrapMode { HTML_WM_OFF, HTML_WM_HARD, HTML_WM_SOFT };
112 
113 }
114 
116 {
117  { OOO_STRING_SVTOOLS_HTML_WW_off, HTML_WM_OFF },
118  { OOO_STRING_SVTOOLS_HTML_WW_hard, HTML_WM_HARD },
119  { OOO_STRING_SVTOOLS_HTML_WW_soft, HTML_WM_SOFT },
120  { OOO_STRING_SVTOOLS_HTML_WW_physical, HTML_WM_HARD },
121  { OOO_STRING_SVTOOLS_HTML_WW_virtual, HTML_WM_SOFT },
122  { nullptr, HTMLWordWrapMode(0) }
123 };
124 
126 {
127  SvMacroItemId::HtmlOnSubmitForm,
128  SvMacroItemId::HtmlOnResetForm,
129  SvMacroItemId::HtmlOnGetFocus,
130  SvMacroItemId::HtmlOnLoseFocus,
131  SvMacroItemId::HtmlOnClick,
132  SvMacroItemId::HtmlOnClickItem,
133  SvMacroItemId::HtmlOnChange,
134  SvMacroItemId::HtmlOnSelect,
135  SvMacroItemId::NONE
136 };
137 
138 const char * aEventListenerTable[] =
139 {
140  "XSubmitListener",
141  "XResetListener",
142  "XFocusListener",
143  "XFocusListener",
144  "XApproveActionListener",
145  "XItemListener",
146  "XChangeListener",
147  ""
148 };
149 
150 const char * aEventMethodTable[] =
151 {
152  "approveSubmit",
153  "approveReset",
154  "focusGained",
155  "focusLost",
156  "approveAction",
157  "itemStateChanged",
158  "changed",
159  ""
160 };
161 
162 const char * aEventSDOptionTable[] =
163 {
169  OOO_STRING_SVTOOLS_HTML_O_SDonclick,
171  nullptr
172 };
173 
174 const char * aEventOptionTable[] =
175 {
181  OOO_STRING_SVTOOLS_HTML_O_onclick,
183  nullptr
184 };
185 
187 {
189 
191 
192  // Cached interfaces
193  uno::Reference< drawing::XDrawPage > m_xDrawPage;
194  uno::Reference< container::XIndexContainer > m_xForms;
195  uno::Reference< drawing::XShapes > m_xShapes;
196  uno::Reference< XMultiServiceFactory > m_xServiceFactory;
197 
198  uno::Reference< script::XEventAttacherManager > m_xControlEventManager;
199  uno::Reference< script::XEventAttacherManager > m_xFormEventManager;
200 
201  // Context information
202  uno::Reference< container::XIndexContainer > m_xFormComps;
203  uno::Reference< beans::XPropertySet > m_xFCompPropertySet;
204  uno::Reference< drawing::XShape > m_xShape;
205 
206  OUString m_sText;
207  std::vector<OUString> m_aStringList;
208  std::vector<OUString> m_aValueList;
209  std::vector<sal_uInt16> m_aSelectedList;
210 
211 public:
212  explicit SwHTMLForm_Impl( SwDocShell *pDSh ) :
213  m_pDocShell( pDSh ),
214  m_pHeaderAttrs( pDSh ? pDSh->GetHeaderAttributes() : nullptr )
215  {
216  OSL_ENSURE( m_pDocShell, "No DocShell, no Controls" );
217  }
218 
219  const uno::Reference< XMultiServiceFactory >& GetServiceFactory();
220  void GetDrawPage();
221  const uno::Reference< drawing::XShapes >& GetShapes();
222  const uno::Reference< script::XEventAttacherManager >& GetControlEventManager();
223  const uno::Reference< script::XEventAttacherManager >& GetFormEventManager();
224  const uno::Reference< container::XIndexContainer >& GetForms();
225 
226  const uno::Reference< container::XIndexContainer >& GetFormComps() const
227  {
228  return m_xFormComps;
229  }
230 
231  void SetFormComps( const uno::Reference< container::XIndexContainer >& r )
232  {
233  m_xFormComps = r;
234  }
235 
236  void ReleaseFormComps() { m_xFormComps = nullptr; m_xControlEventManager = nullptr; }
237 
238  const uno::Reference< beans::XPropertySet >& GetFCompPropSet() const
239  {
240  return m_xFCompPropertySet;
241  }
242 
243  void SetFCompPropSet( const uno::Reference< beans::XPropertySet >& r )
244  {
245  m_xFCompPropertySet = r;
246  }
247 
248  void ReleaseFCompPropSet() { m_xFCompPropertySet = nullptr; }
249 
250  const uno::Reference< drawing::XShape >& GetShape() const { return m_xShape; }
251  void SetShape( const uno::Reference< drawing::XShape >& r ) { m_xShape = r; }
252 
253  OUString& GetText() { return m_sText; }
254  void EraseText() { m_sText.clear(); }
255 
256  std::vector<OUString>& GetStringList() { return m_aStringList; }
258  {
259  m_aStringList.clear();
260  }
261 
262  std::vector<OUString>& GetValueList() { return m_aValueList; }
264  {
265  m_aValueList.clear();
266  }
267 
268  std::vector<sal_uInt16>& GetSelectedList() { return m_aSelectedList; }
270  {
271  m_aSelectedList.clear();
272  }
273 
275 };
276 
277 const uno::Reference< XMultiServiceFactory >& SwHTMLForm_Impl::GetServiceFactory()
278 {
279  if( !m_xServiceFactory.is() && m_pDocShell )
280  {
282  uno::Reference< XMultiServiceFactory >( m_pDocShell->GetBaseModel(),
283  UNO_QUERY );
284  OSL_ENSURE( m_xServiceFactory.is(),
285  "XServiceFactory not received from model" );
286  }
287  return m_xServiceFactory;
288 }
289 
291 {
292  if( !m_xDrawPage.is() && m_pDocShell )
293  {
294  uno::Reference< drawing::XDrawPageSupplier > xTextDoc( m_pDocShell->GetBaseModel(),
295  UNO_QUERY );
296  OSL_ENSURE( xTextDoc.is(),
297  "drawing::XDrawPageSupplier not received from model" );
298  m_xDrawPage = xTextDoc->getDrawPage();
299  OSL_ENSURE( m_xDrawPage.is(), "drawing::XDrawPage not received" );
300  }
301 }
302 
303 const uno::Reference< container::XIndexContainer >& SwHTMLForm_Impl::GetForms()
304 {
305  if( !m_xForms.is() )
306  {
307  GetDrawPage();
308  if( m_xDrawPage.is() )
309  {
310  uno::Reference< XFormsSupplier > xFormsSupplier( m_xDrawPage, UNO_QUERY );
311  OSL_ENSURE( xFormsSupplier.is(),
312  "XFormsSupplier not received from drawing::XDrawPage" );
313 
314  uno::Reference< container::XNameContainer > xNameCont =
315  xFormsSupplier->getForms();
316  m_xForms.set( xNameCont, UNO_QUERY );
317 
318  OSL_ENSURE( m_xForms.is(), "XForms not received" );
319  }
320  }
321  return m_xForms;
322 }
323 
324 const uno::Reference< drawing::XShapes > & SwHTMLForm_Impl::GetShapes()
325 {
326  if( !m_xShapes.is() )
327  {
328  GetDrawPage();
329  if( m_xDrawPage.is() )
330  {
332  OSL_ENSURE( m_xShapes.is(),
333  "XShapes not received from drawing::XDrawPage" );
334  }
335  }
336  return m_xShapes;
337 }
338 
339 const uno::Reference< script::XEventAttacherManager >&
341 {
342  if( !m_xControlEventManager.is() && m_xFormComps.is() )
343  {
345  uno::Reference< script::XEventAttacherManager >( m_xFormComps, UNO_QUERY );
346  OSL_ENSURE( m_xControlEventManager.is(),
347  "uno::Reference< XEventAttacherManager > not received from xFormComps" );
348  }
349 
350  return m_xControlEventManager;
351 }
352 
353 const uno::Reference< script::XEventAttacherManager >&
355 {
356  if( !m_xFormEventManager.is() )
357  {
358  GetForms();
359  if( m_xForms.is() )
360  {
362  uno::Reference< script::XEventAttacherManager >( m_xForms, UNO_QUERY );
363  OSL_ENSURE( m_xFormEventManager.is(),
364  "uno::Reference< XEventAttacherManager > not received from xForms" );
365  }
366  }
367 
368  return m_xFormEventManager;
369 }
370 
371 namespace {
372 
373 class SwHTMLImageWatcher :
374  public cppu::WeakImplHelper< awt::XImageConsumer, XEventListener >
375 {
376  uno::Reference< drawing::XShape > m_xShape; // the control
377  uno::Reference< XImageProducerSupplier > m_xSrc;
378  uno::Reference< awt::XImageConsumer > m_xThis; // reference to self
379  bool m_bSetWidth;
380  bool m_bSetHeight;
381 
382  void clear();
383 
384 public:
385  SwHTMLImageWatcher( const uno::Reference< drawing::XShape > & rShape,
386  bool bWidth, bool bHeight );
387 
388  // startProduction can not be called in the constructor because it can
389  // destruct itself, hence a separate method.
390  void start() { m_xSrc->getImageProducer()->startProduction(); }
391 
392  // UNO binding
393 
394  // XImageConsumer
395  virtual void SAL_CALL init( sal_Int32 Width, sal_Int32 Height) override;
396  virtual void SAL_CALL setColorModel(
397  sal_Int16 BitCount, const uno::Sequence< sal_Int32 >& RGBAPal,
398  sal_Int32 RedMask, sal_Int32 GreenMask, sal_Int32 BlueMask,
399  sal_Int32 AlphaMask) override;
400  virtual void SAL_CALL setPixelsByBytes(
401  sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height,
402  const uno::Sequence< sal_Int8 >& ProducerData,
403  sal_Int32 Offset, sal_Int32 Scansize) override;
404  virtual void SAL_CALL setPixelsByLongs(
405  sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height,
406  const uno::Sequence< sal_Int32 >& ProducerData,
407  sal_Int32 Offset, sal_Int32 Scansize) override;
408  virtual void SAL_CALL complete(
409  sal_Int32 Status,
410  const uno::Reference< awt::XImageProducer > & Producer) override;
411 
412  // XEventListener
413  virtual void SAL_CALL disposing( const EventObject& Source ) override;
414 };
415 
416 }
417 
418 SwHTMLImageWatcher::SwHTMLImageWatcher(
419  const uno::Reference< drawing::XShape >& rShape,
420  bool bWidth, bool bHeight ) :
421  m_xShape( rShape ),
422  m_bSetWidth( bWidth ), m_bSetHeight( bHeight )
423 {
424  // Remember the source of the image
425  uno::Reference< drawing::XControlShape > xControlShape( m_xShape, UNO_QUERY );
426  uno::Reference< awt::XControlModel > xControlModel(
427  xControlShape->getControl() );
428  m_xSrc.set( xControlModel, UNO_QUERY );
429  OSL_ENSURE( m_xSrc.is(), "No XImageProducerSupplier" );
430 
431  // Register as Event-Listener on the shape to be able to release it on dispose.
432  uno::Reference< XEventListener > xEvtLstnr = static_cast<XEventListener *>(this);
433  uno::Reference< XComponent > xComp( m_xShape, UNO_QUERY );
434  xComp->addEventListener( xEvtLstnr );
435 
436  // Lastly we keep a reference to ourselves so we are not destroyed
437  // (should not be necessary since we're still registered elsewhere)
438  m_xThis = static_cast<awt::XImageConsumer *>(this);
439 
440  // Register at ImageProducer to retrieve the size...
441  m_xSrc->getImageProducer()->addConsumer( m_xThis );
442 }
443 
444 void SwHTMLImageWatcher::clear()
445 {
446  // Unregister on Shape
447  uno::Reference< XEventListener > xEvtLstnr = static_cast<XEventListener *>(this);
448  uno::Reference< XComponent > xComp( m_xShape, UNO_QUERY );
449  xComp->removeEventListener( xEvtLstnr );
450 
451  // Unregister on ImageProducer
452  uno::Reference<awt::XImageProducer> xProd = m_xSrc->getImageProducer();
453  if( xProd.is() )
454  xProd->removeConsumer( m_xThis );
455 }
456 
457 void SwHTMLImageWatcher::init( sal_Int32 Width, sal_Int32 Height )
458 {
459  OSL_ENSURE( m_bSetWidth || m_bSetHeight,
460  "Width or height has to be adjusted" );
461 
462  // If no width or height is given, it is initialized to those of
463  // the empty graphic that is available before the stream of a graphic
464  // that is to be displayed asynchronous is available.
465  if( !Width && !Height )
466  return;
467 
468  awt::Size aNewSz;
469  aNewSz.Width = Width;
470  aNewSz.Height = Height;
472  {
473  Size aTmp(aNewSz.Width, aNewSz.Height);
475  ->PixelToLogic( aTmp, MapMode( MapUnit::Map100thMM ) );
476  aNewSz.Width = aTmp.Width();
477  aNewSz.Height = aTmp.Height();
478  }
479 
480  if( !m_bSetWidth || !m_bSetHeight )
481  {
482  awt::Size aSz( m_xShape->getSize() );
483  if( m_bSetWidth && aNewSz.Height )
484  {
485  aNewSz.Width *= aSz.Height;
486  aNewSz.Width /= aNewSz.Height;
487  aNewSz.Height = aSz.Height;
488  }
489  if( m_bSetHeight && aNewSz.Width )
490  {
491  aNewSz.Height *= aSz.Width;
492  aNewSz.Height /= aNewSz.Width;
493  aNewSz.Width = aSz.Width;
494  }
495  }
496  if( aNewSz.Width < MINFLY )
497  aNewSz.Width = MINFLY;
498  if( aNewSz.Height < MINFLY )
499  aNewSz.Height = MINFLY;
500 
501  m_xShape->setSize( aNewSz );
502  if( m_bSetWidth )
503  {
504  // If the control is anchored to a table, the column have to be recalculated
505 
506  // To get to the SwXShape* we need an interface that is implemented by SwXShape
507 
508  uno::Reference< beans::XPropertySet > xPropSet( m_xShape, UNO_QUERY );
509  SwXShape *pSwShape = comphelper::getFromUnoTunnel<SwXShape>(xPropSet);
510 
511  OSL_ENSURE( pSwShape, "Where is SW-Shape?" );
512  if( pSwShape )
513  {
514  SwFrameFormat *pFrameFormat = pSwShape->GetFrameFormat();
515 
516  const SwDoc *pDoc = pFrameFormat->GetDoc();
517  const SwPosition* pAPos = pFrameFormat->GetAnchor().GetContentAnchor();
518  SwTableNode *pTableNd;
519  if (pAPos && nullptr != (pTableNd = pAPos->nNode.GetNode().FindTableNode()))
520  {
521  const bool bLastGrf = !pTableNd->GetTable().DecGrfsThatResize();
522  SwHTMLTableLayout *pLayout =
523  pTableNd->GetTable().GetHTMLTableLayout();
524  if( pLayout )
525  {
526  const sal_uInt16 nBrowseWidth =
527  pLayout->GetBrowseWidthByTable( *pDoc );
528 
529  if ( nBrowseWidth )
530  {
531  pLayout->Resize( nBrowseWidth, true, true,
532  bLastGrf ? HTMLTABLE_RESIZE_NOW
533  : 500 );
534  }
535  }
536  }
537  }
538  }
539 
540  // unregister and delete self
541  clear();
542  m_xThis = nullptr;
543 }
544 
545 void SwHTMLImageWatcher::setColorModel(
546  sal_Int16, const Sequence< sal_Int32 >&, sal_Int32, sal_Int32,
547  sal_Int32, sal_Int32 )
548 {
549 }
550 
551 void SwHTMLImageWatcher::setPixelsByBytes(
552  sal_Int32, sal_Int32, sal_Int32, sal_Int32,
553  const Sequence< sal_Int8 >&, sal_Int32, sal_Int32 )
554 {
555 }
556 
557 void SwHTMLImageWatcher::setPixelsByLongs(
558  sal_Int32, sal_Int32, sal_Int32, sal_Int32,
559  const Sequence< sal_Int32 >&, sal_Int32, sal_Int32 )
560 {
561 }
562 
563 void SwHTMLImageWatcher::complete( sal_Int32 Status,
564  const uno::Reference< awt::XImageProducer >& )
565 {
566  if( awt::ImageStatus::IMAGESTATUS_ERROR == Status || awt::ImageStatus::IMAGESTATUS_ABORTED == Status )
567  {
568  // unregister and delete self
569  clear();
570  m_xThis = nullptr;
571  }
572 }
573 
574 void SwHTMLImageWatcher::disposing(const lang::EventObject& evt)
575 {
576  uno::Reference< awt::XImageConsumer > xTmp;
577 
578  // We need to release the shape if it is disposed of
579  if( evt.Source == m_xShape )
580  {
581  clear();
582  xTmp = static_cast<awt::XImageConsumer*>(this);
583  m_xThis = nullptr;
584  }
585 }
586 
588 {
589  delete m_pFormImpl;
590  m_pFormImpl = nullptr;
591 }
592 
594  const uno::Reference< beans::XPropertySet >& rPropSet )
595 {
597  DefaultFontType::FIXED, LANGUAGE_ENGLISH_US,
598  GetDefaultFontFlags::OnlyOne ) );
599  Any aTmp;
600  aTmp <<= aFixedFont.GetFamilyName();
601  rPropSet->setPropertyValue("FontName", aTmp );
602 
603  aTmp <<= aFixedFont.GetStyleName();
604  rPropSet->setPropertyValue("FontStyleName",
605  aTmp );
606 
607  aTmp <<= static_cast<sal_Int16>(aFixedFont.GetFamilyType());
608  rPropSet->setPropertyValue("FontFamily", aTmp );
609 
610  aTmp <<= static_cast<sal_Int16>(aFixedFont.GetCharSet());
611  rPropSet->setPropertyValue("FontCharset",
612  aTmp );
613 
614  aTmp <<= static_cast<sal_Int16>(aFixedFont.GetPitch());
615  rPropSet->setPropertyValue("FontPitch", aTmp );
616 
617  aTmp <<= float(10.0);
618  rPropSet->setPropertyValue("FontHeight", aTmp );
619 }
620 
621 void SwHTMLParser::SetControlSize( const uno::Reference< drawing::XShape >& rShape,
622  const Size& rTextSz,
623  bool bMinWidth,
624  bool bMinHeight )
625 {
626  if( !rTextSz.Width() && !rTextSz.Height() && !bMinWidth && !bMinHeight )
627  return;
628 
629  // To get to SwXShape* we need an interface that is implemented by SwXShape
630 
631  uno::Reference< beans::XPropertySet > xPropSet( rShape, UNO_QUERY );
632 
633  SwViewShell *pVSh = m_xDoc->getIDocumentLayoutAccess().GetCurrentViewShell();
634  if( !pVSh && !m_nEventId )
635  {
636  // If there is no view shell by now and the doc shell is an internal
637  // one, no view shell will be created. That for, we have to do that of
638  // our own. This happens if a linked section is inserted or refreshed.
639  SwDocShell *pDocSh = m_xDoc->GetDocShell();
640  if( pDocSh )
641  {
642  if ( pDocSh->GetMedium() )
643  {
644  // if there is no hidden property in the MediaDescriptor it should be removed after loading
645  const SfxBoolItem* pHiddenItem = SfxItemSet::GetItem<SfxBoolItem>(pDocSh->GetMedium()->GetItemSet(), SID_HIDDEN, false);
646  m_bRemoveHidden = ( pHiddenItem == nullptr || !pHiddenItem->GetValue() );
647  }
648 
650  CallStartAction();
651  pVSh = m_xDoc->getIDocumentLayoutAccess().GetCurrentViewShell();
652  // this ridiculous hack also enables Undo, so turn it off again
653  m_xDoc->GetIDocumentUndoRedo().DoUndo(false);
654  }
655  }
656 
657  SwXShape *pSwShape = comphelper::getFromUnoTunnel<SwXShape>(xPropSet);
658 
659  OSL_ENSURE( pSwShape, "Where is SW-Shape?" );
660 
661  // has to be a Draw-Format
662  SwFrameFormat *pFrameFormat = pSwShape ? pSwShape->GetFrameFormat() : nullptr ;
663  OSL_ENSURE( pFrameFormat && RES_DRAWFRMFMT == pFrameFormat->Which(), "No DrawFrameFormat" );
664 
665  // look if a SdrObject exists for it
666  const SdrObject *pObj = pFrameFormat ? pFrameFormat->FindSdrObject() : nullptr;
667  OSL_ENSURE( pObj, "SdrObject not found" );
668  OSL_ENSURE( pObj && SdrInventor::FmForm == pObj->GetObjInventor(), "wrong Inventor" );
669 
670  const SdrView* pDrawView = pVSh ? pVSh->GetDrawView() : nullptr;
671 
672  const SdrUnoObj *pFormObj = dynamic_cast<const SdrUnoObj*>( pObj );
673  uno::Reference< awt::XControl > xControl;
674  if ( pDrawView && pVSh->GetWin() && pFormObj )
675  xControl = pFormObj->GetUnoControl( *pDrawView, *pVSh->GetWin()->GetOutDev() );
676 
677  awt::Size aSz( rShape->getSize() );
678  awt::Size aNewSz( 0, 0 );
679 
680  // #i71248# ensure we got a XControl before applying corrections
681  if(xControl.is())
682  {
683  if( bMinWidth || bMinHeight )
684  {
685  uno::Reference< awt::XLayoutConstrains > xLC( xControl, UNO_QUERY );
686  awt::Size aTmpSz( xLC->getPreferredSize() );
687  if( bMinWidth )
688  aNewSz.Width = aTmpSz.Width;
689  if( bMinHeight )
690  aNewSz.Height = aTmpSz.Height;
691  }
692  if( rTextSz.Width() || rTextSz.Height())
693  {
694  uno::Reference< awt::XTextLayoutConstrains > xLC( xControl, UNO_QUERY );
695  OSL_ENSURE( xLC.is(), "no XTextLayoutConstrains" );
696  if( xLC.is() )
697  {
698  awt::Size aTmpSz( rTextSz.Width(), rTextSz.Height() );
699  if( -1 == rTextSz.Width() )
700  {
701  aTmpSz.Width = 0;
702  aTmpSz.Height = m_nSelectEntryCnt;
703  }
704  aTmpSz = xLC->getMinimumSize( static_cast< sal_Int16 >(aTmpSz.Width), static_cast< sal_Int16 >(aTmpSz.Height) );
705  if( rTextSz.Width() )
706  aNewSz.Width = aTmpSz.Width;
707  if( rTextSz.Height() )
708  aNewSz.Height = aTmpSz.Height;
709  }
710  }
711  }
712 
714  {
715  Size aTmpSz( aNewSz.Width, aNewSz.Height );
717  ->PixelToLogic( aTmpSz, MapMode( MapUnit::Map100thMM ) );
718  aNewSz.Width = aTmpSz.Width();
719  aNewSz.Height = aTmpSz.Height();
720  }
721  if( aNewSz.Width )
722  {
723  if( aNewSz.Width < MINLAY )
724  aNewSz.Width = MINLAY;
725  aSz.Width = aNewSz.Width;
726  }
727  if( aNewSz.Height )
728  {
729  if( aNewSz.Height < MINLAY )
730  aNewSz.Height = MINLAY;
731  aSz.Height = aNewSz.Height;
732  }
733 
734  rShape->setSize( aSz );
735 }
736 
737 static bool lcl_html_setEvents(
738  const uno::Reference< script::XEventAttacherManager > & rEvtMn,
739  sal_uInt32 nPos, const SvxMacroTableDtor& rMacroTable,
740  const std::vector<OUString>& rUnoMacroTable,
741  const std::vector<OUString>& rUnoMacroParamTable,
742  const OUString& rType )
743 {
744  // First the number of events has to be determined
745  sal_Int32 nEvents = 0;
746 
747  for( int i = 0; SvMacroItemId::NONE != aEventTypeTable[i]; ++i )
748  {
749  const SvxMacro *pMacro = rMacroTable.Get( aEventTypeTable[i] );
750  // As long as not all events are implemented the table also holds empty strings
751  if( pMacro && aEventListenerTable[i] )
752  nEvents++;
753  }
754  for( const auto &rStr : rUnoMacroTable )
755  {
756  sal_Int32 nIndex = 0;
757  if( o3tl::getToken(rStr, 0, '-', nIndex ).empty() || -1 == nIndex )
758  continue;
759  if( o3tl::getToken(rStr, 0, '-', nIndex ).empty() || -1 == nIndex )
760  continue;
761  if( nIndex < rStr.getLength() )
762  nEvents++;
763  }
764 
765  if( 0==nEvents )
766  return false;
767 
768  Sequence<script::ScriptEventDescriptor> aDescs( nEvents );
769  script::ScriptEventDescriptor* pDescs = aDescs.getArray();
770  sal_Int32 nEvent = 0;
771 
772  for( int i=0; SvMacroItemId::NONE != aEventTypeTable[i]; ++i )
773  {
774  const SvxMacro *pMacro = rMacroTable.Get( aEventTypeTable[i] );
775  if( pMacro && aEventListenerTable[i] )
776  {
777  script::ScriptEventDescriptor& rDesc = pDescs[nEvent++];
778  rDesc.ListenerType =
779  OUString::createFromAscii(aEventListenerTable[i]);
780  rDesc.EventMethod = OUString::createFromAscii(aEventMethodTable[i]);
781  rDesc.ScriptType = pMacro->GetLanguage();
782  rDesc.ScriptCode = pMacro->GetMacName();
783  }
784  }
785 
786  for( const auto &rStr : rUnoMacroTable )
787  {
788  sal_Int32 nIndex = 0;
789  OUString sListener( rStr.getToken( 0, '-', nIndex ) );
790  if( sListener.isEmpty() || -1 == nIndex )
791  continue;
792 
793  OUString sMethod( rStr.getToken( 0, '-', nIndex ) );
794  if( sMethod.isEmpty() || -1 == nIndex )
795  continue;
796 
797  OUString sCode( rStr.copy( nIndex ) );
798  if( sCode.isEmpty() )
799  continue;
800 
801  script::ScriptEventDescriptor& rDesc = pDescs[nEvent++];
802  rDesc.ListenerType = sListener;
803  rDesc.EventMethod = sMethod;
804  rDesc.ScriptType = rType;
805  rDesc.ScriptCode = sCode;
806  rDesc.AddListenerParam.clear();
807 
808  if(!rUnoMacroParamTable.empty())
809  {
810  OUString sSearch = sListener + "-" +sMethod + "-";
811  sal_Int32 nLen = sSearch.getLength();
812  for(const auto & rParam : rUnoMacroParamTable)
813  {
814  if( rParam.startsWith( sSearch ) && rParam.getLength() > nLen )
815  {
816  rDesc.AddListenerParam = rParam.copy(nLen);
817  break;
818  }
819  }
820  }
821  }
822  rEvtMn->registerScriptEvents( nPos, aDescs );
823  return true;
824 }
825 
826 static void lcl_html_getEvents( const OUString& rOption, std::u16string_view rValue,
827  std::vector<OUString>& rUnoMacroTable,
828  std::vector<OUString>& rUnoMacroParamTable )
829 {
830  if( rOption.startsWithIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_sdevent ) )
831  {
832  OUString aEvent = OUString::Concat(rOption.subView( strlen( OOO_STRING_SVTOOLS_HTML_O_sdevent ) )) +
833  "-" + rValue;
834  rUnoMacroTable.push_back(aEvent);
835  }
836  else if( rOption.startsWithIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_sdaddparam ) )
837  {
838  OUString aParam = OUString::Concat(rOption.subView( strlen( OOO_STRING_SVTOOLS_HTML_O_sdaddparam ) )) +
839  "-" + rValue;
840  rUnoMacroParamTable.push_back(aParam);
841  }
842 }
843 
844 uno::Reference< drawing::XShape > SwHTMLParser::InsertControl(
845  const uno::Reference< XFormComponent > & rFComp,
846  const uno::Reference< beans::XPropertySet > & rFCompPropSet,
847  const Size& rSize, sal_Int16 eVertOri, sal_Int16 eHoriOri,
848  SfxItemSet& rCSS1ItemSet, SvxCSS1PropertyInfo& rCSS1PropInfo,
849  const SvxMacroTableDtor& rMacroTable, const std::vector<OUString>& rUnoMacroTable,
850  const std::vector<OUString>& rUnoMacroParamTable, bool bSetFCompPropSet,
851  bool bHidden )
852 {
853  uno::Reference< drawing::XShape > xShape;
854 
855  const uno::Reference< container::XIndexContainer > & rFormComps =
857  Any aAny( &rFComp, cppu::UnoType<XFormComponent>::get());
858  rFormComps->insertByIndex( rFormComps->getCount(), aAny );
859 
860  if( !bHidden )
861  {
862  Any aTmp;
863  sal_Int32 nLeftSpace = 0;
864  sal_Int32 nRightSpace = 0;
865  sal_Int32 nUpperSpace = 0;
866  sal_Int32 nLowerSpace = 0;
867 
868  const uno::Reference< XMultiServiceFactory > & rServiceFactory =
870  if( !rServiceFactory.is() )
871  return xShape;
872 
873  uno::Reference< XInterface > xCreate = rServiceFactory->createInstance( "com.sun.star.drawing.ControlShape" );
874  if( !xCreate.is() )
875  return xShape;
876 
877  xShape.set( xCreate, UNO_QUERY );
878 
879  OSL_ENSURE( xShape.is(), "XShape not received" );
880  awt::Size aTmpSz;
881  aTmpSz.Width = rSize.Width();
882  aTmpSz.Height = rSize.Height();
883  xShape->setSize( aTmpSz );
884 
885  uno::Reference< beans::XPropertySet > xShapePropSet( xCreate, UNO_QUERY );
886 
887  // set left/right border
888  if( const SvxLRSpaceItem* pLRItem = rCSS1ItemSet.GetItemIfSet( RES_LR_SPACE ) )
889  {
890  // Flatten first line indent
891  SvxLRSpaceItem aLRItem( *pLRItem );
892  aLRItem.SetTextFirstLineOffset( 0 );
893  if( rCSS1PropInfo.m_bLeftMargin )
894  {
895  nLeftSpace = convertTwipToMm100( aLRItem.GetLeft() );
896  rCSS1PropInfo.m_bLeftMargin = false;
897  }
898  if( rCSS1PropInfo.m_bRightMargin )
899  {
900  nRightSpace = convertTwipToMm100( aLRItem.GetRight() );
901  rCSS1PropInfo.m_bRightMargin = false;
902  }
903  rCSS1ItemSet.ClearItem( RES_LR_SPACE );
904  }
905  if( nLeftSpace || nRightSpace )
906  {
907  Any aAny2;
908  aAny2 <<= nLeftSpace;
909  xShapePropSet->setPropertyValue("LeftMargin", aAny2 );
910 
911  aAny2 <<= nRightSpace;
912  xShapePropSet->setPropertyValue("RightMargin", aAny2 );
913  }
914 
915  // set upper/lower border
916  if( const SvxULSpaceItem *pULItem = rCSS1ItemSet.GetItemIfSet( RES_UL_SPACE ) )
917  {
918  // Flatten first line indent
919  if( rCSS1PropInfo.m_bTopMargin )
920  {
921  nUpperSpace = convertTwipToMm100( pULItem->GetUpper() );
922  rCSS1PropInfo.m_bTopMargin = false;
923  }
924  if( rCSS1PropInfo.m_bBottomMargin )
925  {
926  nLowerSpace = convertTwipToMm100( pULItem->GetLower() );
927  rCSS1PropInfo.m_bBottomMargin = false;
928  }
929 
930  rCSS1ItemSet.ClearItem( RES_UL_SPACE );
931  }
932  if( nUpperSpace || nLowerSpace )
933  {
934  uno::Any aAny2;
935  aAny2 <<= nUpperSpace;
936  xShapePropSet->setPropertyValue("TopMargin", aAny2 );
937 
938  aAny2 <<= nLowerSpace;
939  xShapePropSet->setPropertyValue("BottomMargin", aAny2 );
940  }
941 
942  uno::Reference< beans::XPropertySetInfo > xPropSetInfo =
943  rFCompPropSet->getPropertySetInfo();
944  OUString sPropName = "BackgroundColor";
945  const SvxBrushItem* pBrushItem = rCSS1ItemSet.GetItemIfSet( RES_BACKGROUND );
946  if( pBrushItem && xPropSetInfo->hasPropertyByName( sPropName ) )
947  {
948  const Color &rColor = pBrushItem->GetColor();
950  if( rColor != COL_TRANSPARENT )
951  {
953  aTmp <<= rColor;
954  rFCompPropSet->setPropertyValue( sPropName, aTmp );
955  }
956 
957  }
958 
959  sPropName = "TextColor";
960  const SvxColorItem* pColorItem = rCSS1ItemSet.GetItemIfSet( RES_CHRATR_COLOR );
961  if( pColorItem && xPropSetInfo->hasPropertyByName( sPropName ) )
962  {
963  aTmp <<= static_cast<sal_Int32>(pColorItem->GetValue().GetRGBColor());
964  rFCompPropSet->setPropertyValue( sPropName, aTmp );
965  }
966 
967  sPropName = "FontHeight";
968  const SvxFontHeightItem* pFontHeightItem = rCSS1ItemSet.GetItemIfSet( RES_CHRATR_FONTSIZE );
969  if( pFontHeightItem && xPropSetInfo->hasPropertyByName( sPropName ) )
970  {
971  float fVal = static_cast< float >( pFontHeightItem->GetHeight() / 20.0 );
972  aTmp <<= fVal;
973  rFCompPropSet->setPropertyValue( sPropName, aTmp );
974  }
975 
976  if( const SvxFontItem* pFontItem = rCSS1ItemSet.GetItemIfSet( RES_CHRATR_FONT ) )
977  {
978  sPropName = "FontName";
979  if( xPropSetInfo->hasPropertyByName( sPropName ) )
980  {
981  aTmp <<= pFontItem->GetFamilyName();
982  rFCompPropSet->setPropertyValue( sPropName, aTmp );
983  }
984  sPropName = "FontStyleName";
985  if( xPropSetInfo->hasPropertyByName( sPropName ) )
986  {
987  aTmp <<= pFontItem->GetStyleName();
988  rFCompPropSet->setPropertyValue( sPropName, aTmp );
989  }
990  sPropName = "FontFamily";
991  if( xPropSetInfo->hasPropertyByName( sPropName ) )
992  {
993  aTmp <<= static_cast<sal_Int16>(pFontItem->GetFamily()) ;
994  rFCompPropSet->setPropertyValue( sPropName, aTmp );
995  }
996  sPropName = "FontCharset";
997  if( xPropSetInfo->hasPropertyByName( sPropName ) )
998  {
999  aTmp <<= static_cast<sal_Int16>(pFontItem->GetCharSet()) ;
1000  rFCompPropSet->setPropertyValue( sPropName, aTmp );
1001  }
1002  sPropName = "FontPitch";
1003  if( xPropSetInfo->hasPropertyByName( sPropName ) )
1004  {
1005  aTmp <<= static_cast<sal_Int16>(pFontItem->GetPitch()) ;
1006  rFCompPropSet->setPropertyValue( sPropName, aTmp );
1007  }
1008  }
1009 
1010  sPropName = "FontWeight";
1011  const SvxWeightItem* pWeightItem = rCSS1ItemSet.GetItemIfSet( RES_CHRATR_WEIGHT );
1012  if( pWeightItem && xPropSetInfo->hasPropertyByName( sPropName ) )
1013  {
1014  float fVal = vcl::unohelper::ConvertFontWeight(
1015  pWeightItem->GetWeight() );
1016  aTmp <<= fVal;
1017  rFCompPropSet->setPropertyValue( sPropName, aTmp );
1018  }
1019 
1020  sPropName = "FontSlant";
1021  const SvxPostureItem* pPostureItem = rCSS1ItemSet.GetItemIfSet( RES_CHRATR_POSTURE );
1022  if( pPostureItem && xPropSetInfo->hasPropertyByName( sPropName ) )
1023  {
1024  aTmp <<= static_cast<sal_Int16>(pPostureItem->GetPosture());
1025  rFCompPropSet->setPropertyValue( sPropName, aTmp );
1026  }
1027 
1028  sPropName = "FontUnderline";
1029  const SvxUnderlineItem* pUnderlineItem = rCSS1ItemSet.GetItemIfSet( RES_CHRATR_UNDERLINE );
1030  if( pUnderlineItem && xPropSetInfo->hasPropertyByName( sPropName ) )
1031  {
1032  aTmp <<= static_cast<sal_Int16>(pUnderlineItem->GetLineStyle());
1033  rFCompPropSet->setPropertyValue( sPropName, aTmp );
1034  }
1035 
1036  sPropName = "FontStrikeout";
1037  const SvxCrossedOutItem* pCrossedOutItem = rCSS1ItemSet.GetItemIfSet( RES_CHRATR_CROSSEDOUT );
1038  if( pCrossedOutItem && xPropSetInfo->hasPropertyByName( sPropName ) )
1039  {
1040  aTmp <<= static_cast<sal_Int16>(pCrossedOutItem->GetStrikeout());
1041  rFCompPropSet->setPropertyValue( sPropName, aTmp );
1042  }
1043 
1044  uno::Reference< text::XTextRange > xTextRg;
1045  text::TextContentAnchorType nAnchorType = text::TextContentAnchorType_AS_CHARACTER;
1046  bool bSetPos = false, bSetSurround = false;
1047  sal_Int32 nXPos = 0, nYPos = 0;
1048  text::WrapTextMode nSurround = text::WrapTextMode_NONE;
1049  if( SVX_CSS1_POS_ABSOLUTE == rCSS1PropInfo.m_ePosition &&
1050  SVX_CSS1_LTYPE_TWIP == rCSS1PropInfo.m_eLeftType &&
1051  SVX_CSS1_LTYPE_TWIP == rCSS1PropInfo.m_eTopType )
1052  {
1053  const SwStartNode *pFlySttNd =
1055 
1056  if( pFlySttNd )
1057  {
1058  nAnchorType = text::TextContentAnchorType_AT_FRAME;
1059  SwPaM aPaM( *pFlySttNd );
1060 
1061  uno::Reference< text::XText > xDummyTextRef; // dirty, but works according to OS...
1062  xTextRg = new SwXTextRange( aPaM, xDummyTextRef );
1063  }
1064  else
1065  {
1066  nAnchorType = text::TextContentAnchorType_AT_PAGE;
1067  }
1068  nXPos = convertTwipToMm100( rCSS1PropInfo.m_nLeft ) + nLeftSpace;
1069  nYPos = convertTwipToMm100( rCSS1PropInfo.m_nTop ) + nUpperSpace;
1070  bSetPos = true;
1071 
1072  nSurround = text::WrapTextMode_THROUGH;
1073  bSetSurround = true;
1074  }
1075  else if( SvxAdjust::Left == rCSS1PropInfo.m_eFloat ||
1076  text::HoriOrientation::LEFT == eHoriOri )
1077  {
1078  nAnchorType = text::TextContentAnchorType_AT_PARAGRAPH;
1079  nXPos = nLeftSpace;
1080  nYPos = nUpperSpace;
1081  bSetPos = true;
1082  nSurround = text::WrapTextMode_RIGHT;
1083  bSetSurround = true;
1084  }
1085  else if( text::VertOrientation::NONE != eVertOri )
1086  {
1087  sal_Int16 nVertOri = text::VertOrientation::NONE;
1088  switch( eVertOri )
1089  {
1090  case text::VertOrientation::TOP:
1091  nVertOri = text::VertOrientation::TOP;
1092  break;
1093  case text::VertOrientation::CENTER:
1094  nVertOri = text::VertOrientation::CENTER;
1095  break;
1096  case text::VertOrientation::BOTTOM:
1097  nVertOri = text::VertOrientation::BOTTOM;
1098  break;
1099  case text::VertOrientation::CHAR_TOP:
1100  nVertOri = text::VertOrientation::CHAR_TOP;
1101  break;
1102  case text::VertOrientation::CHAR_CENTER:
1103  nVertOri = text::VertOrientation::CHAR_CENTER;
1104  break;
1105  case text::VertOrientation::CHAR_BOTTOM:
1106  nVertOri = text::VertOrientation::CHAR_BOTTOM;
1107  break;
1108  case text::VertOrientation::LINE_TOP:
1109  nVertOri = text::VertOrientation::LINE_TOP;
1110  break;
1111  case text::VertOrientation::LINE_CENTER:
1112  nVertOri = text::VertOrientation::LINE_CENTER;
1113  break;
1114  case text::VertOrientation::LINE_BOTTOM:
1115  nVertOri = text::VertOrientation::LINE_BOTTOM;
1116  break;
1117  // coverity[dead_error_begin] - following conditions exist to avoid compiler warning
1119  nVertOri = text::VertOrientation::NONE;
1120  break;
1121  }
1122  aTmp <<= nVertOri ;
1123  xShapePropSet->setPropertyValue("VertOrient", aTmp );
1124  }
1125 
1126  aTmp <<= nAnchorType ;
1127  xShapePropSet->setPropertyValue("AnchorType", aTmp );
1128 
1129  if( text::TextContentAnchorType_AT_PAGE == nAnchorType )
1130  {
1131  aTmp <<= sal_Int16(1) ;
1132  xShapePropSet->setPropertyValue("AnchorPageNo", aTmp );
1133  }
1134  else
1135  {
1136  if( !xTextRg.is() )
1137  {
1138  uno::Reference< text::XText > xDummyTextRef; // dirty but works according to OS...
1139  xTextRg = new SwXTextRange( *m_pPam, xDummyTextRef );
1140  }
1141 
1142  aTmp <<= xTextRg;
1143  xShapePropSet->setPropertyValue("TextRange", aTmp );
1144  }
1145 
1146  if( bSetPos )
1147  {
1148  aTmp <<= sal_Int16(text::HoriOrientation::NONE);
1149  xShapePropSet->setPropertyValue("HoriOrient", aTmp );
1150  aTmp <<= nXPos ;
1151  xShapePropSet->setPropertyValue("HoriOrientPosition", aTmp );
1152 
1153  aTmp <<= sal_Int16(text::VertOrientation::NONE);
1154  xShapePropSet->setPropertyValue("VertOrient", aTmp );
1155  aTmp <<= nYPos ;
1156  xShapePropSet->setPropertyValue("VertOrientPosition", aTmp );
1157  }
1158  if( bSetSurround )
1159  {
1160  aTmp <<= nSurround ;
1161  xShapePropSet->setPropertyValue("Surround", aTmp );
1162  }
1163 
1164  m_pFormImpl->GetShapes()->add(xShape);
1165 
1166  // Set ControlModel to ControlShape
1167  uno::Reference< drawing::XControlShape > xControlShape( xShape, UNO_QUERY );
1168  uno::Reference< awt::XControlModel > xControlModel( rFComp, UNO_QUERY );
1169  xControlShape->setControl( xControlModel );
1170  }
1171 
1172  // Since the focus is set at insertion of the controls, focus events will be sent
1173  // To prevent previous JavaScript-Events from being called, these events will only be set retroactively
1174  if( !rMacroTable.empty() || !rUnoMacroTable.empty() )
1175  {
1177  rFormComps->getCount() - 1,
1178  rMacroTable, rUnoMacroTable, rUnoMacroParamTable,
1180  if (bHasEvents)
1182  }
1183 
1184  if( bSetFCompPropSet )
1185  {
1186  m_pFormImpl->SetFCompPropSet( rFCompPropSet );
1187  }
1188 
1189  return xShape;
1190 }
1191 
1192 void SwHTMLParser::NewForm( bool bAppend )
1193 {
1194  // Does a form already exist?
1195  if( m_pFormImpl && m_pFormImpl->GetFormComps().is() )
1196  return;
1197 
1198  if( bAppend )
1199  {
1200  if( m_pPam->GetPoint()->nContent.GetIndex() )
1202  else
1203  AddParSpace();
1204  }
1205 
1206  if( !m_pFormImpl )
1207  m_pFormImpl = new SwHTMLForm_Impl( m_xDoc->GetDocShell() );
1208 
1209  OUString aAction( m_sBaseURL );
1210  OUString sName, sTarget;
1211  FormSubmitEncoding nEncType = FormSubmitEncoding_URL;
1212  FormSubmitMethod nMethod = FormSubmitMethod_GET;
1213  SvxMacroTableDtor aMacroTable;
1214  std::vector<OUString> aUnoMacroTable;
1215  std::vector<OUString> aUnoMacroParamTable;
1216  SvKeyValueIterator *pHeaderAttrs = m_pFormImpl->GetHeaderAttrs();
1217  ScriptType eDfltScriptType = GetScriptType( pHeaderAttrs );
1218  const OUString& rDfltScriptType = GetScriptTypeString( pHeaderAttrs );
1219 
1220  const HTMLOptions& rHTMLOptions = GetOptions();
1221  for (size_t i = rHTMLOptions.size(); i; )
1222  {
1223  const HTMLOption& rOption = rHTMLOptions[--i];
1224  ScriptType eScriptType2 = eDfltScriptType;
1225  SvMacroItemId nEvent = SvMacroItemId::NONE;
1226  bool bSetEvent = false;
1227 
1228  switch( rOption.GetToken() )
1229  {
1230  case HtmlOptionId::ACTION:
1231  aAction = rOption.GetString();
1232  break;
1233  case HtmlOptionId::METHOD:
1234  nMethod = rOption.GetEnum( aHTMLFormMethodTable, nMethod );
1235  break;
1236  case HtmlOptionId::ENCTYPE:
1237  nEncType = rOption.GetEnum( aHTMLFormEncTypeTable, nEncType );
1238  break;
1239  case HtmlOptionId::TARGET:
1240  sTarget = rOption.GetString();
1241  break;
1242  case HtmlOptionId::NAME:
1243  sName = rOption.GetString();
1244  break;
1245 
1246  case HtmlOptionId::SDONSUBMIT:
1247  eScriptType2 = STARBASIC;
1248  [[fallthrough]];
1249  case HtmlOptionId::ONSUBMIT:
1250  nEvent = SvMacroItemId::HtmlOnSubmitForm;
1251  bSetEvent = true;
1252  break;
1253 
1254  case HtmlOptionId::SDONRESET:
1255  eScriptType2 = STARBASIC;
1256  [[fallthrough]];
1257  case HtmlOptionId::ONRESET:
1258  nEvent = SvMacroItemId::HtmlOnResetForm;
1259  bSetEvent = true;
1260  break;
1261 
1262  default:
1264  rOption.GetString(),
1265  aUnoMacroTable, aUnoMacroParamTable );
1266  break;
1267  }
1268 
1269  if( bSetEvent )
1270  {
1271  OUString sEvent( rOption.GetString() );
1272  if( !sEvent.isEmpty() )
1273  {
1274  sEvent = convertLineEnd(sEvent, GetSystemLineEnd());
1275  OUString aScriptType2;
1276  if( EXTENDED_STYPE==eScriptType2 )
1277  aScriptType2 = rDfltScriptType;
1278  aMacroTable.Insert( nEvent, SvxMacro( sEvent, aScriptType2, eScriptType2 ) );
1279  }
1280  }
1281  }
1282 
1283  const uno::Reference< XMultiServiceFactory > & rSrvcMgr =
1285  if( !rSrvcMgr.is() )
1286  return;
1287 
1288  uno::Reference< XInterface > xInt;
1289  uno::Reference<XForm> xForm;
1290  try
1291  {
1292  xInt = rSrvcMgr->createInstance("com.sun.star.form.component.Form");
1293  if (!xInt.is())
1294  return;
1295  xForm.set(xInt, UNO_QUERY);
1296  SAL_WARN_IF(!xForm.is(), "sw", "no XForm for com.sun.star.form.component.Form?");
1297  if (!xForm.is())
1298  return;
1299  }
1300  catch (...)
1301  {
1302  TOOLS_WARN_EXCEPTION("sw", "");
1303  return;
1304  }
1305 
1306  uno::Reference< container::XIndexContainer > xFormComps( xForm, UNO_QUERY );
1307  m_pFormImpl->SetFormComps( xFormComps );
1308 
1309  uno::Reference< beans::XPropertySet > xFormPropSet( xForm, UNO_QUERY );
1310 
1311  Any aTmp;
1312  aTmp <<= sName;
1313  xFormPropSet->setPropertyValue("Name", aTmp );
1314 
1315  if( !aAction.isEmpty() )
1316  {
1318  }
1319  else
1320  {
1321  // use directory at empty URL
1322  INetURLObject aURLObj( m_aPathToFile );
1323  aAction = aURLObj.GetPartBeforeLastName();
1324  }
1325  aTmp <<= aAction;
1326  xFormPropSet->setPropertyValue("TargetURL",
1327  aTmp );
1328 
1329  aTmp <<= nMethod;
1330  xFormPropSet->setPropertyValue("SubmitMethod",
1331  aTmp );
1332 
1333  aTmp <<= nEncType;
1334  xFormPropSet->setPropertyValue("SubmitEncoding", aTmp );
1335 
1336  if( !sTarget.isEmpty() )
1337  {
1338  aTmp <<= sTarget;
1339  xFormPropSet->setPropertyValue( "TargetFrame", aTmp );
1340  }
1341 
1342  const uno::Reference< container::XIndexContainer > & rForms =
1343  m_pFormImpl->GetForms();
1344  Any aAny( &xForm, cppu::UnoType<XForm>::get());
1345  rForms->insertByIndex( rForms->getCount(), aAny );
1346  if( !aMacroTable.empty() )
1347  {
1348  bool bHasEvents = lcl_html_setEvents( m_pFormImpl->GetFormEventManager(),
1349  rForms->getCount() - 1,
1350  aMacroTable, aUnoMacroTable, aUnoMacroParamTable,
1351  rDfltScriptType );
1352  if (bHasEvents)
1354  }
1355 }
1356 
1357 void SwHTMLParser::EndForm( bool bAppend )
1358 {
1359  if( m_pFormImpl && m_pFormImpl->GetFormComps().is() )
1360  {
1361  if( bAppend )
1362  {
1363  if( m_pPam->GetPoint()->nContent.GetIndex() )
1365  else
1366  AddParSpace();
1367  }
1368 
1370  }
1371 }
1372 
1374 {
1375  assert(m_vPendingStack.empty());
1376 
1377  if( !m_pFormImpl || !m_pFormImpl->GetFormComps().is() )
1378  return;
1379 
1380  OUString sImgSrc, aId, aClass, aStyle, sName;
1381  OUString sText;
1382  SvxMacroTableDtor aMacroTable;
1383  std::vector<OUString> aUnoMacroTable;
1384  std::vector<OUString> aUnoMacroParamTable;
1385  sal_uInt16 nSize = 0;
1386  sal_Int16 nMaxLen = 0;
1387  sal_Int16 nChecked = TRISTATE_FALSE;
1388  sal_Int32 nTabIndex = TABINDEX_MAX + 1;
1389  HTMLInputType eType = HTMLInputType::Text;
1390  bool bDisabled = false, bValue = false;
1391  bool bSetGrfWidth = false, bSetGrfHeight = false;
1392  bool bHidden = false;
1393  tools::Long nWidth=0, nHeight=0;
1394  sal_Int16 eVertOri = text::VertOrientation::TOP;
1395  sal_Int16 eHoriOri = text::HoriOrientation::NONE;
1396  SvKeyValueIterator *pHeaderAttrs = m_pFormImpl->GetHeaderAttrs();
1397  ScriptType eDfltScriptType = GetScriptType( pHeaderAttrs );
1398  const OUString& rDfltScriptType = GetScriptTypeString( pHeaderAttrs );
1399 
1400  HtmlOptionId nKeepCRLFToken = HtmlOptionId::VALUE;
1401  const HTMLOptions& rHTMLOptions = GetOptions( &nKeepCRLFToken );
1402  for (size_t i = rHTMLOptions.size(); i; )
1403  {
1404  const HTMLOption& rOption = rHTMLOptions[--i];
1405  ScriptType eScriptType2 = eDfltScriptType;
1406  SvMacroItemId nEvent = SvMacroItemId::NONE;
1407  bool bSetEvent = false;
1408 
1409  switch( rOption.GetToken() )
1410  {
1411  case HtmlOptionId::ID:
1412  aId = rOption.GetString();
1413  break;
1414  case HtmlOptionId::STYLE:
1415  aStyle = rOption.GetString();
1416  break;
1417  case HtmlOptionId::CLASS:
1418  aClass = rOption.GetString();
1419  break;
1420  case HtmlOptionId::TYPE:
1421  eType = rOption.GetInputType();
1422  break;
1423  case HtmlOptionId::NAME:
1424  sName = rOption.GetString();
1425  break;
1426  case HtmlOptionId::VALUE:
1427  sText = rOption.GetString();
1428  bValue = true;
1429  break;
1430  case HtmlOptionId::CHECKED:
1431  nChecked = TRISTATE_TRUE;
1432  break;
1433  case HtmlOptionId::DISABLED:
1434  bDisabled = true;
1435  break;
1436  case HtmlOptionId::MAXLENGTH:
1437  nMaxLen = static_cast<sal_Int16>(rOption.GetNumber());
1438  break;
1439  case HtmlOptionId::SIZE:
1440  nSize = o3tl::narrowing<sal_uInt16>(rOption.GetNumber());
1441  break;
1442  case HtmlOptionId::SRC:
1443  sImgSrc = rOption.GetString();
1444  break;
1445  case HtmlOptionId::WIDTH:
1446  // only save pixel values at first!
1447  nWidth = rOption.GetNumber();
1448  break;
1449  case HtmlOptionId::HEIGHT:
1450  // only save pixel values at first!
1451  nHeight = rOption.GetNumber();
1452  break;
1453  case HtmlOptionId::ALIGN:
1454  eVertOri =
1455  rOption.GetEnum( aHTMLImgVAlignTable, eVertOri );
1456  eHoriOri =
1457  rOption.GetEnum( aHTMLImgHAlignTable, eHoriOri );
1458  break;
1459  case HtmlOptionId::TABINDEX:
1460  // only save pixel values at first!
1461  nTabIndex = rOption.GetNumber();
1462  break;
1463 
1464  case HtmlOptionId::SDONFOCUS:
1465  eScriptType2 = STARBASIC;
1466  [[fallthrough]];
1467  case HtmlOptionId::ONFOCUS:
1468  nEvent = SvMacroItemId::HtmlOnGetFocus;
1469  bSetEvent = true;
1470  break;
1471 
1472  case HtmlOptionId::SDONBLUR: // actually only EDIT
1473  eScriptType2 = STARBASIC;
1474  [[fallthrough]];
1475  case HtmlOptionId::ONBLUR:
1476  nEvent = SvMacroItemId::HtmlOnLoseFocus;
1477  bSetEvent = true;
1478  break;
1479 
1480  case HtmlOptionId::SDONCLICK:
1481  eScriptType2 = STARBASIC;
1482  [[fallthrough]];
1483  case HtmlOptionId::ONCLICK:
1484  nEvent = SvMacroItemId::HtmlOnClick;
1485  bSetEvent = true;
1486  break;
1487 
1488  case HtmlOptionId::SDONCHANGE: // actually only EDIT
1489  eScriptType2 = STARBASIC;
1490  [[fallthrough]];
1491  case HtmlOptionId::ONCHANGE:
1492  nEvent = SvMacroItemId::HtmlOnChange;
1493  bSetEvent = true;
1494  break;
1495 
1496  case HtmlOptionId::SDONSELECT: // actually only EDIT
1497  eScriptType2 = STARBASIC;
1498  [[fallthrough]];
1499  case HtmlOptionId::ONSELECT:
1500  nEvent = SvMacroItemId::HtmlOnSelect;
1501  bSetEvent = true;
1502  break;
1503 
1504  default:
1506  rOption.GetString(),
1507  aUnoMacroTable, aUnoMacroParamTable );
1508  break;
1509  }
1510 
1511  if( bSetEvent )
1512  {
1513  OUString sEvent( rOption.GetString() );
1514  if( !sEvent.isEmpty() )
1515  {
1516  sEvent = convertLineEnd(sEvent, GetSystemLineEnd());
1517  OUString aScriptType2;
1518  if( EXTENDED_STYPE==eScriptType2 )
1519  aScriptType2 = rDfltScriptType;
1520  aMacroTable.Insert( nEvent, SvxMacro( sEvent, aScriptType2, eScriptType2 ) );
1521  }
1522  }
1523  }
1524 
1525  if( HTMLInputType::Image==eType )
1526  {
1527  // Image controls without image URL are ignored (same as MS)
1528  if( sImgSrc.isEmpty() )
1529  return;
1530  }
1531  else
1532  {
1533  // evaluation of ALIGN for all controls is not a good idea as long as
1534  // paragraph bound controls do not influence the height of the cells of a table
1535  eVertOri = text::VertOrientation::TOP;
1536  eHoriOri = text::HoriOrientation::NONE;
1537  }
1538 
1539  // Default is HTMLInputType::Text
1540  const char *pType = "TextField";
1541  bool bKeepCRLFInValue = false;
1542  switch( eType )
1543  {
1544  case HTMLInputType::Checkbox:
1545  pType = "CheckBox";
1546  bKeepCRLFInValue = true;
1547  break;
1548 
1549  case HTMLInputType::Radio:
1550  pType = "RadioButton";
1551  bKeepCRLFInValue = true;
1552  break;
1553 
1554  case HTMLInputType::Password:
1555  bKeepCRLFInValue = true;
1556  break;
1557 
1558  case HTMLInputType::Button:
1559  bKeepCRLFInValue = true;
1560  [[fallthrough]];
1561  case HTMLInputType::Submit:
1562  case HTMLInputType::Reset:
1563  pType = "CommandButton";
1564  break;
1565 
1566  case HTMLInputType::Image:
1567  pType = "ImageButton";
1568  break;
1569 
1570  case HTMLInputType::File:
1571  pType = "FileControl";
1572  break;
1573 
1574  case HTMLInputType::Hidden:
1575  pType = "HiddenControl";
1576  bKeepCRLFInValue = true;
1577  break;
1578  default:
1579  ;
1580  }
1581 
1582  // For some controls CR/LF has to be deleted from VALUE
1583  if( !bKeepCRLFInValue )
1584  {
1585  sText = sText.replaceAll("\r", "").replaceAll("\n", "");
1586  }
1587 
1588  const uno::Reference< XMultiServiceFactory > & rServiceFactory =
1590  if( !rServiceFactory.is() )
1591  return;
1592 
1593  OUString sServiceName = "com.sun.star.form.component." +
1594  OUString::createFromAscii(pType);
1595  uno::Reference< XInterface > xInt =
1596  rServiceFactory->createInstance( sServiceName );
1597  if( !xInt.is() )
1598  return;
1599 
1600  uno::Reference< XFormComponent > xFComp( xInt, UNO_QUERY );
1601  if( !xFComp.is() )
1602  return;
1603 
1604  uno::Reference< beans::XPropertySet > xPropSet( xFComp, UNO_QUERY );
1605 
1606  Any aTmp;
1607  aTmp <<= sName;
1608  xPropSet->setPropertyValue("Name", aTmp );
1609 
1610  if( HTMLInputType::Hidden != eType )
1611  {
1612  if( nTabIndex >= TABINDEX_MIN && nTabIndex <= TABINDEX_MAX )
1613  {
1614  aTmp <<= static_cast<sal_Int16>(nTabIndex) ;
1615  xPropSet->setPropertyValue("TabIndex", aTmp );
1616  }
1617 
1618  if( bDisabled )
1619  {
1620  xPropSet->setPropertyValue("Enabled", Any(false) );
1621  }
1622  }
1623 
1624  aTmp <<= sText;
1625 
1626  Size aSz( 0, 0 ); // defaults
1627  Size aTextSz( 0, 0 ); // Text size
1628  bool bMinWidth = false, bMinHeight = false;
1629  bool bUseSize = false;
1630  switch( eType )
1631  {
1632  case HTMLInputType::Checkbox:
1633  case HTMLInputType::Radio:
1634  {
1635  if( !bValue )
1636  aTmp <<= OUString( OOO_STRING_SVTOOLS_HTML_on );
1637  xPropSet->setPropertyValue("RefValue",
1638  aTmp );
1639  aTmp <<= OUString();
1640  xPropSet->setPropertyValue("Label",
1641  aTmp );
1642  // RadioButton: The DefaultChecked property should only be set
1643  // if the control has been created and activateTabOrder has been called
1644  // because otherwise it would still belong to the previous group.
1645  if( HTMLInputType::Checkbox == eType )
1646  {
1647  aTmp <<= nChecked ;
1648  xPropSet->setPropertyValue("DefaultState", aTmp );
1649  }
1650 
1651  const SvxMacro* pMacro = aMacroTable.Get( SvMacroItemId::HtmlOnClick );
1652  if( pMacro )
1653  {
1654  aMacroTable.Insert( SvMacroItemId::HtmlOnClickItem, *pMacro );
1655  aMacroTable.Erase( SvMacroItemId::HtmlOnClick );
1656  }
1657  // evaluating SIZE shouldn't be necessary here?
1658  bMinWidth = bMinHeight = true;
1659  }
1660  break;
1661 
1662  case HTMLInputType::Image:
1663  {
1664  // SIZE = WIDTH
1665  aSz.setWidth( nSize ? nSize : nWidth );
1666  aSz.setWidth( nWidth );
1667  aSz.setHeight( nHeight );
1668  if( (aSz.Width() || aSz.Height()) && Application::GetDefaultDevice() )
1669  {
1671  ->PixelToLogic( aSz, MapMode( MapUnit::Map100thMM ) );
1672  }
1673  aTmp <<= FormButtonType_SUBMIT;
1674  xPropSet->setPropertyValue("ButtonType", aTmp );
1675 
1676  aTmp <<= sal_Int16(0) ;
1677  xPropSet->setPropertyValue("Border",
1678  aTmp );
1679  }
1680  break;
1681 
1682  case HTMLInputType::Button:
1683  case HTMLInputType::Submit:
1684  case HTMLInputType::Reset:
1685  {
1686  FormButtonType eButtonType;
1687  switch( eType )
1688  {
1689  case HTMLInputType::Button:
1690  eButtonType = FormButtonType_PUSH;
1691  break;
1692  case HTMLInputType::Submit:
1693  eButtonType = FormButtonType_SUBMIT;
1694  if (sText.isEmpty())
1696  break;
1697  case HTMLInputType::Reset:
1698  eButtonType = FormButtonType_RESET;
1699  if (sText.isEmpty())
1701  break;
1702  default:
1703  ;
1704  }
1705  aTmp <<= sText;
1706  xPropSet->setPropertyValue("Label",
1707  aTmp );
1708 
1709  aTmp <<= eButtonType;
1710  xPropSet->setPropertyValue("ButtonType", aTmp );
1711 
1712  bMinWidth = bMinHeight = true;
1713  bUseSize = true;
1714  }
1715  break;
1716 
1717  case HTMLInputType::Password:
1718  case HTMLInputType::Text:
1719  case HTMLInputType::File:
1720  if( HTMLInputType::File != eType )
1721  {
1722  // The VALUE of file control will be ignored for security reasons
1723  xPropSet->setPropertyValue("DefaultText", aTmp );
1724  if( nMaxLen != 0 )
1725  {
1726  aTmp <<= nMaxLen ;
1727  xPropSet->setPropertyValue("MaxTextLen", aTmp );
1728  }
1729  }
1730 
1731  if( HTMLInputType::Password == eType )
1732  {
1733  aTmp <<= sal_Int16('*') ;
1734  xPropSet->setPropertyValue("EchoChar", aTmp );
1735  }
1736 
1737  lcl_html_setFixedFontProperty( xPropSet );
1738 
1739  if( !nSize )
1740  nSize = 20;
1741  aTextSz.setWidth( nSize );
1742  bMinHeight = true;
1743  break;
1744 
1745  case HTMLInputType::Hidden:
1746  xPropSet->setPropertyValue("HiddenValue", aTmp );
1747  bHidden = true;
1748  break;
1749  default:
1750  ;
1751  }
1752 
1753  if( bUseSize && nSize>0 )
1754  {
1756  {
1757  Size aNewSz( nSize, 0 );
1759  ->PixelToLogic( aNewSz, MapMode( MapUnit::Map100thMM ) );
1760  aSz.setWidth( aNewSz.Width() );
1761  OSL_ENSURE( !aTextSz.Width(), "text width is present" );
1762  bMinWidth = false;
1763  }
1764  }
1765 
1766  SfxItemSet aCSS1ItemSet( m_xDoc->GetAttrPool(), m_pCSS1Parser->GetWhichMap() );
1767  SvxCSS1PropertyInfo aCSS1PropInfo;
1768  if( HasStyleOptions( aStyle, aId, aClass ) )
1769  {
1770  ParseStyleOptions( aStyle, aId, aClass, aCSS1ItemSet, aCSS1PropInfo );
1771  if( !aId.isEmpty() )
1772  InsertBookmark( aId );
1773  }
1774 
1775  if( SVX_CSS1_LTYPE_TWIP== aCSS1PropInfo.m_eWidthType )
1776  {
1777  aSz.setWidth( convertTwipToMm100( aCSS1PropInfo.m_nWidth ) );
1778  aTextSz.setWidth( 0 );
1779  bMinWidth = false;
1780  }
1781  if( SVX_CSS1_LTYPE_TWIP== aCSS1PropInfo.m_eHeightType )
1782  {
1783  aSz.setHeight( convertTwipToMm100( aCSS1PropInfo.m_nHeight ) );
1784  aTextSz.setHeight( 0 );
1785  bMinHeight = false;
1786  }
1787 
1788  // Set sensible default values if the image button has no valid size
1789  if( HTMLInputType::Image== eType )
1790  {
1791  if( !aSz.Width() )
1792  {
1794  bSetGrfWidth = true;
1795  if (m_xTable)
1797  }
1798  if( !aSz.Height() )
1799  {
1801  bSetGrfHeight = true;
1802  }
1803  }
1804  if( aSz.Width() < MINFLY )
1805  aSz.setWidth( MINFLY );
1806  if( aSz.Height() < MINFLY )
1807  aSz.setHeight( MINFLY );
1808 
1809  uno::Reference< drawing::XShape > xShape = InsertControl(
1810  xFComp, xPropSet, aSz,
1811  eVertOri, eHoriOri,
1812  aCSS1ItemSet, aCSS1PropInfo,
1813  aMacroTable, aUnoMacroTable,
1814  aUnoMacroParamTable, false,
1815  bHidden );
1816  if( aTextSz.Width() || aTextSz.Height() || bMinWidth || bMinHeight )
1817  {
1818  OSL_ENSURE( !(bSetGrfWidth || bSetGrfHeight), "Adjust graphic size???" );
1819  SetControlSize( xShape, aTextSz, bMinWidth, bMinHeight );
1820  }
1821 
1822  if( HTMLInputType::Radio == eType )
1823  {
1824  aTmp <<= nChecked ;
1825  xPropSet->setPropertyValue("DefaultState", aTmp );
1826  }
1827 
1828  if( HTMLInputType::Image == eType )
1829  {
1830  // Set the URL after inserting the graphic because the Download can
1831  // only register with XModel after the control has been inserted.
1832  aTmp <<= URIHelper::SmartRel2Abs(INetURLObject(m_sBaseURL), sImgSrc, Link<OUString *, bool>(), false);
1833  xPropSet->setPropertyValue("ImageURL",
1834  aTmp );
1835  }
1836 
1837  if( bSetGrfWidth || bSetGrfHeight )
1838  {
1840  new SwHTMLImageWatcher( xShape, bSetGrfWidth, bSetGrfHeight );
1841  pWatcher->start();
1842  }
1843 }
1844 
1846 {
1847  assert(m_vPendingStack.empty());
1848 
1849  OSL_ENSURE( !m_bTextArea, "TextArea in TextArea?" );
1850  OSL_ENSURE( !m_pFormImpl || !m_pFormImpl->GetFCompPropSet().is(),
1851  "TextArea in Control?" );
1852 
1853  if( !m_pFormImpl || !m_pFormImpl->GetFormComps().is() )
1854  {
1855  // Close special treatment for TextArea in the parser
1856  FinishTextArea();
1857  return;
1858  }
1859 
1860  OUString aId, aClass, aStyle;
1861  OUString sName;
1862  sal_Int32 nTabIndex = TABINDEX_MAX + 1;
1863  SvxMacroTableDtor aMacroTable;
1864  std::vector<OUString> aUnoMacroTable;
1865  std::vector<OUString> aUnoMacroParamTable;
1866  sal_uInt16 nRows = 0, nCols = 0;
1867  HTMLWordWrapMode nWrap = HTML_WM_OFF;
1868  bool bDisabled = false;
1869  SvKeyValueIterator *pHeaderAttrs = m_pFormImpl->GetHeaderAttrs();
1870  ScriptType eDfltScriptType = GetScriptType( pHeaderAttrs );
1871  const OUString& rDfltScriptType = GetScriptTypeString( pHeaderAttrs );
1872 
1873  const HTMLOptions& rHTMLOptions = GetOptions();
1874  for (size_t i = rHTMLOptions.size(); i; )
1875  {
1876  const HTMLOption& rOption = rHTMLOptions[--i];
1877  ScriptType eScriptType2 = eDfltScriptType;
1878  SvMacroItemId nEvent = SvMacroItemId::NONE;
1879  bool bSetEvent = false;
1880 
1881  switch( rOption.GetToken() )
1882  {
1883  case HtmlOptionId::ID:
1884  aId = rOption.GetString();
1885  break;
1886  case HtmlOptionId::STYLE:
1887  aStyle = rOption.GetString();
1888  break;
1889  case HtmlOptionId::CLASS:
1890  aClass = rOption.GetString();
1891  break;
1892  case HtmlOptionId::NAME:
1893  sName = rOption.GetString();
1894  break;
1895  case HtmlOptionId::DISABLED:
1896  bDisabled = true;
1897  break;
1898  case HtmlOptionId::ROWS:
1899  nRows = o3tl::narrowing<sal_uInt16>(rOption.GetNumber());
1900  break;
1901  case HtmlOptionId::COLS:
1902  nCols = o3tl::narrowing<sal_uInt16>(rOption.GetNumber());
1903  break;
1904  case HtmlOptionId::WRAP:
1905  nWrap = rOption.GetEnum( aHTMLTextAreaWrapTable, nWrap );
1906  break;
1907 
1908  case HtmlOptionId::TABINDEX:
1909  nTabIndex = rOption.GetSNumber();
1910  break;
1911 
1912  case HtmlOptionId::SDONFOCUS:
1913  eScriptType2 = STARBASIC;
1914  [[fallthrough]];
1915  case HtmlOptionId::ONFOCUS:
1916  nEvent = SvMacroItemId::HtmlOnGetFocus;
1917  bSetEvent = true;
1918  break;
1919 
1920  case HtmlOptionId::SDONBLUR:
1921  eScriptType2 = STARBASIC;
1922  [[fallthrough]];
1923  case HtmlOptionId::ONBLUR:
1924  nEvent = SvMacroItemId::HtmlOnLoseFocus;
1925  bSetEvent = true;
1926  break;
1927 
1928  case HtmlOptionId::SDONCLICK:
1929  eScriptType2 = STARBASIC;
1930  [[fallthrough]];
1931  case HtmlOptionId::ONCLICK:
1932  nEvent = SvMacroItemId::HtmlOnClick;
1933  bSetEvent = true;
1934  break;
1935 
1936  case HtmlOptionId::SDONCHANGE:
1937  eScriptType2 = STARBASIC;
1938  [[fallthrough]];
1939  case HtmlOptionId::ONCHANGE:
1940  nEvent = SvMacroItemId::HtmlOnChange;
1941  bSetEvent = true;
1942  break;
1943 
1944  case HtmlOptionId::SDONSELECT:
1945  eScriptType2 = STARBASIC;
1946  [[fallthrough]];
1947  case HtmlOptionId::ONSELECT:
1948  nEvent = SvMacroItemId::HtmlOnSelect;
1949  bSetEvent = true;
1950  break;
1951 
1952  default:
1954  rOption.GetString(),
1955  aUnoMacroTable, aUnoMacroParamTable );
1956  break;
1957  }
1958 
1959  if( bSetEvent )
1960  {
1961  OUString sEvent( rOption.GetString() );
1962  if( !sEvent.isEmpty() )
1963  {
1964  sEvent = convertLineEnd(sEvent, GetSystemLineEnd());
1965  if( EXTENDED_STYPE==eScriptType2 )
1966  m_aScriptType = rDfltScriptType;
1967  aMacroTable.Insert( nEvent, SvxMacro( sEvent, m_aScriptType, eScriptType2 ) );
1968  }
1969  }
1970  }
1971 
1972  const uno::Reference< lang::XMultiServiceFactory > & rSrvcMgr =
1974  if( !rSrvcMgr.is() )
1975  {
1976  FinishTextArea();
1977  return;
1978  }
1979  uno::Reference< uno::XInterface > xInt = rSrvcMgr->createInstance(
1980  "com.sun.star.form.component.TextField" );
1981  if( !xInt.is() )
1982  {
1983  FinishTextArea();
1984  return;
1985  }
1986 
1987  uno::Reference< XFormComponent > xFComp( xInt, UNO_QUERY );
1988  OSL_ENSURE( xFComp.is(), "no FormComponent?" );
1989 
1990  uno::Reference< beans::XPropertySet > xPropSet( xFComp, UNO_QUERY );
1991 
1992  Any aTmp;
1993  aTmp <<= sName;
1994  xPropSet->setPropertyValue("Name", aTmp );
1995 
1996  aTmp <<= true;
1997  xPropSet->setPropertyValue("MultiLine", aTmp );
1998  xPropSet->setPropertyValue("VScroll", aTmp );
1999  if( HTML_WM_OFF == nWrap )
2000  xPropSet->setPropertyValue("HScroll", aTmp );
2001  if( HTML_WM_HARD == nWrap )
2002  xPropSet->setPropertyValue("HardLineBreaks", aTmp );
2003 
2004  if( nTabIndex >= TABINDEX_MIN && nTabIndex <= TABINDEX_MAX )
2005  {
2006  aTmp <<= static_cast<sal_Int16>(nTabIndex) ;
2007  xPropSet->setPropertyValue("TabIndex", aTmp );
2008  }
2009 
2010  lcl_html_setFixedFontProperty( xPropSet );
2011 
2012  if( bDisabled )
2013  {
2014  xPropSet->setPropertyValue("Enabled", Any(false) );
2015  }
2016 
2017  OSL_ENSURE( m_pFormImpl->GetText().isEmpty(), "Text is not empty!" );
2018 
2019  if( !nCols )
2020  nCols = 20;
2021  if( !nRows )
2022  nRows = 1;
2023 
2024  Size aTextSz( nCols, nRows );
2025 
2026  SfxItemSet aCSS1ItemSet( m_xDoc->GetAttrPool(), m_pCSS1Parser->GetWhichMap() );
2027  SvxCSS1PropertyInfo aCSS1PropInfo;
2028  if( HasStyleOptions( aStyle, aId, aClass ) )
2029  {
2030  ParseStyleOptions( aStyle, aId, aClass, aCSS1ItemSet, aCSS1PropInfo );
2031  if( !aId.isEmpty() )
2032  InsertBookmark( aId );
2033  }
2034 
2035  Size aSz( MINFLY, MINFLY );
2036  if( SVX_CSS1_LTYPE_TWIP== aCSS1PropInfo.m_eWidthType )
2037  {
2038  aSz.setWidth( convertTwipToMm100( aCSS1PropInfo.m_nWidth ) );
2039  aTextSz.setWidth( 0 );
2040  }
2041  if( SVX_CSS1_LTYPE_TWIP== aCSS1PropInfo.m_eHeightType )
2042  {
2043  aSz.setHeight( convertTwipToMm100( aCSS1PropInfo.m_nHeight ) );
2044  aTextSz.setHeight( 0 );
2045  }
2046  if( aSz.Width() < MINFLY )
2047  aSz.setWidth( MINFLY );
2048  if( aSz.Height() < MINFLY )
2049  aSz.setHeight( MINFLY );
2050 
2051  uno::Reference< drawing::XShape > xShape = InsertControl( xFComp, xPropSet, aSz,
2052  text::VertOrientation::TOP, text::HoriOrientation::NONE,
2053  aCSS1ItemSet, aCSS1PropInfo,
2054  aMacroTable, aUnoMacroTable,
2055  aUnoMacroParamTable );
2056  if( aTextSz.Width() || aTextSz.Height() )
2057  SetControlSize( xShape, aTextSz, false, false );
2058 
2059  // create new context
2060  std::unique_ptr<HTMLAttrContext> xCntxt(new HTMLAttrContext(HtmlTokenId::TEXTAREA_ON));
2061 
2062  // temporarily disable PRE/Listing/XMP
2063  SplitPREListingXMP(xCntxt.get());
2064  PushContext(xCntxt);
2065 
2066  m_bTextArea = true;
2067  m_bTAIgnoreNewPara = true;
2068 }
2069 
2071 {
2072  OSL_ENSURE( m_bTextArea, "no TextArea or wrong type" );
2073  OSL_ENSURE( m_pFormImpl && m_pFormImpl->GetFCompPropSet().is(),
2074  "TextArea missing" );
2075 
2076  const uno::Reference< beans::XPropertySet > & rPropSet =
2078 
2079  Any aTmp;
2080  aTmp <<= m_pFormImpl->GetText();
2081  rPropSet->setPropertyValue("DefaultText", aTmp );
2083 
2085 
2086  // get context
2087  std::unique_ptr<HTMLAttrContext> xCntxt(PopContext(HtmlTokenId::TEXTAREA_ON));
2088  if (xCntxt)
2089  {
2090  // end attributes
2091  EndContext(xCntxt.get());
2092  }
2093 
2094  m_bTextArea = false;
2095 }
2096 
2098 {
2099  OSL_ENSURE( m_bTextArea, "no TextArea or wrong type" );
2100  OSL_ENSURE( m_pFormImpl && m_pFormImpl->GetFCompPropSet().is(),
2101  "TextArea missing" );
2102 
2103  OUString& rText = m_pFormImpl->GetText();
2104  switch( nToken)
2105  {
2106  case HtmlTokenId::TEXTTOKEN:
2107  rText += aToken;
2108  break;
2109  case HtmlTokenId::NEWPARA:
2110  if( !m_bTAIgnoreNewPara )
2111  rText += "\n";
2112  break;
2113  default:
2114  rText += "<";
2115  rText += sSaveToken;
2116  if( !aToken.isEmpty() )
2117  {
2118  rText += " ";
2119  rText += aToken;
2120  }
2121  rText += ">";
2122  }
2123 
2124  m_bTAIgnoreNewPara = false;
2125 }
2126 
2128 {
2129  assert(m_vPendingStack.empty());
2130 
2131  OSL_ENSURE( !m_bSelect, "Select in Select?" );
2132  OSL_ENSURE( !m_pFormImpl || !m_pFormImpl->GetFCompPropSet().is(),
2133  "Select in Control?" );
2134 
2135  if( !m_pFormImpl || !m_pFormImpl->GetFormComps().is() )
2136  return;
2137 
2138  OUString aId, aClass, aStyle;
2139  OUString sName;
2140  sal_Int32 nTabIndex = TABINDEX_MAX + 1;
2141  SvxMacroTableDtor aMacroTable;
2142  std::vector<OUString> aUnoMacroTable;
2143  std::vector<OUString> aUnoMacroParamTable;
2144  bool bMultiple = false;
2145  bool bDisabled = false;
2146  m_nSelectEntryCnt = 1;
2147  SvKeyValueIterator *pHeaderAttrs = m_pFormImpl->GetHeaderAttrs();
2148  ScriptType eDfltScriptType = GetScriptType( pHeaderAttrs );
2149  const OUString& rDfltScriptType = GetScriptTypeString( pHeaderAttrs );
2150 
2151  const HTMLOptions& rHTMLOptions = GetOptions();
2152  for (size_t i = rHTMLOptions.size(); i; )
2153  {
2154  const HTMLOption& rOption = rHTMLOptions[--i];
2155  ScriptType eScriptType2 = eDfltScriptType;
2156  SvMacroItemId nEvent = SvMacroItemId::NONE;
2157  bool bSetEvent = false;
2158 
2159  switch( rOption.GetToken() )
2160  {
2161  case HtmlOptionId::ID:
2162  aId = rOption.GetString();
2163  break;
2164  case HtmlOptionId::STYLE:
2165  aStyle = rOption.GetString();
2166  break;
2167  case HtmlOptionId::CLASS:
2168  aClass = rOption.GetString();
2169  break;
2170  case HtmlOptionId::NAME:
2171  sName = rOption.GetString();
2172  break;
2173  case HtmlOptionId::MULTIPLE:
2174  bMultiple = true;
2175  break;
2176  case HtmlOptionId::DISABLED:
2177  bDisabled = true;
2178  break;
2179  case HtmlOptionId::SIZE:
2180  m_nSelectEntryCnt = o3tl::narrowing<sal_uInt16>(rOption.GetNumber());
2181  break;
2182 
2183  case HtmlOptionId::TABINDEX:
2184  nTabIndex = rOption.GetSNumber();
2185  break;
2186 
2187  case HtmlOptionId::SDONFOCUS:
2188  eScriptType2 = STARBASIC;
2189  [[fallthrough]];
2190  case HtmlOptionId::ONFOCUS:
2191  nEvent = SvMacroItemId::HtmlOnGetFocus;
2192  bSetEvent = true;
2193  break;
2194 
2195  case HtmlOptionId::SDONBLUR:
2196  eScriptType2 = STARBASIC;
2197  [[fallthrough]];
2198  case HtmlOptionId::ONBLUR:
2199  nEvent = SvMacroItemId::HtmlOnLoseFocus;
2200  bSetEvent = true;
2201  break;
2202 
2203  case HtmlOptionId::SDONCLICK:
2204  eScriptType2 = STARBASIC;
2205  [[fallthrough]];
2206  case HtmlOptionId::ONCLICK:
2207  nEvent = SvMacroItemId::HtmlOnClick;
2208  bSetEvent = true;
2209  break;
2210 
2211  case HtmlOptionId::SDONCHANGE:
2212  eScriptType2 = STARBASIC;
2213  [[fallthrough]];
2214  case HtmlOptionId::ONCHANGE:
2215  nEvent = SvMacroItemId::HtmlOnChange;
2216  bSetEvent = true;
2217  break;
2218 
2219  default:
2221  rOption.GetString(),
2222  aUnoMacroTable, aUnoMacroParamTable );
2223  break;
2224  }
2225 
2226  if( bSetEvent )
2227  {
2228  OUString sEvent( rOption.GetString() );
2229  if( !sEvent.isEmpty() )
2230  {
2231  sEvent = convertLineEnd(sEvent, GetSystemLineEnd());
2232  if( EXTENDED_STYPE==eScriptType2 )
2233  m_aScriptType = rDfltScriptType;
2234  aMacroTable.Insert( nEvent, SvxMacro( sEvent, m_aScriptType, eScriptType2 ) );
2235  }
2236  }
2237  }
2238 
2239  const uno::Reference< lang::XMultiServiceFactory > & rSrvcMgr =
2241  if( !rSrvcMgr.is() )
2242  {
2243  FinishTextArea();
2244  return;
2245  }
2246  uno::Reference< uno::XInterface > xInt = rSrvcMgr->createInstance(
2247  "com.sun.star.form.component.ListBox" );
2248  if( !xInt.is() )
2249  {
2250  FinishTextArea();
2251  return;
2252  }
2253 
2254  uno::Reference< XFormComponent > xFComp( xInt, UNO_QUERY );
2255  OSL_ENSURE(xFComp.is(), "no FormComponent?");
2256 
2257  uno::Reference< beans::XPropertySet > xPropSet( xFComp, UNO_QUERY );
2258 
2259  Any aTmp;
2260  aTmp <<= sName;
2261  xPropSet->setPropertyValue("Name", aTmp );
2262 
2263  if( nTabIndex >= TABINDEX_MIN && nTabIndex <= TABINDEX_MAX )
2264  {
2265  aTmp <<= static_cast<sal_Int16>(nTabIndex) ;
2266  xPropSet->setPropertyValue("TabIndex", aTmp );
2267  }
2268 
2269  if( bDisabled )
2270  {
2271  xPropSet->setPropertyValue("Enabled", Any(false) );
2272  }
2273 
2274  Size aTextSz( 0, 0 );
2275  bool bMinWidth = true, bMinHeight = true;
2276  if( !bMultiple && 1==m_nSelectEntryCnt )
2277  {
2278  xPropSet->setPropertyValue("Dropdown", Any(true) );
2279  }
2280  else
2281  {
2282  if( m_nSelectEntryCnt <= 1 ) // 4 lines is default
2283  m_nSelectEntryCnt = 4;
2284 
2285  if( bMultiple )
2286  {
2287  xPropSet->setPropertyValue("MultiSelection", Any(true) );
2288  }
2289  aTextSz.setHeight( m_nSelectEntryCnt );
2290  bMinHeight = false;
2291  }
2292 
2293  SfxItemSet aCSS1ItemSet( m_xDoc->GetAttrPool(), m_pCSS1Parser->GetWhichMap() );
2294  SvxCSS1PropertyInfo aCSS1PropInfo;
2295  if( HasStyleOptions( aStyle, aId, aClass ) )
2296  {
2297  ParseStyleOptions( aStyle, aId, aClass, aCSS1ItemSet, aCSS1PropInfo );
2298  if( !aId.isEmpty() )
2299  InsertBookmark( aId );
2300  }
2301 
2302  Size aSz( MINFLY, MINFLY );
2303  m_bFixSelectWidth = true;
2304  if( SVX_CSS1_LTYPE_TWIP== aCSS1PropInfo.m_eWidthType )
2305  {
2306  aSz.setWidth( convertTwipToMm100( aCSS1PropInfo.m_nWidth ) );
2307  m_bFixSelectWidth = false;
2308  bMinWidth = false;
2309  }
2310  if( SVX_CSS1_LTYPE_TWIP== aCSS1PropInfo.m_eHeightType )
2311  {
2312  aSz.setHeight( convertTwipToMm100( aCSS1PropInfo.m_nHeight ) );
2313  aTextSz.setHeight( 0 );
2314  bMinHeight = false;
2315  }
2316  if( aSz.Width() < MINFLY )
2317  aSz.setWidth( MINFLY );
2318  if( aSz.Height() < MINFLY )
2319  aSz.setHeight( MINFLY );
2320 
2321  uno::Reference< drawing::XShape > xShape = InsertControl( xFComp, xPropSet, aSz,
2322  text::VertOrientation::TOP, text::HoriOrientation::NONE,
2323  aCSS1ItemSet, aCSS1PropInfo,
2324  aMacroTable, aUnoMacroTable,
2325  aUnoMacroParamTable );
2326  if( m_bFixSelectWidth )
2327  m_pFormImpl->SetShape( xShape );
2328  if( aTextSz.Height() || bMinWidth || bMinHeight )
2329  SetControlSize( xShape, aTextSz, bMinWidth, bMinHeight );
2330 
2331  // create new context
2332  std::unique_ptr<HTMLAttrContext> xCntxt(new HTMLAttrContext(HtmlTokenId::SELECT_ON));
2333 
2334  // temporarily disable PRE/Listing/XMP
2335  SplitPREListingXMP(xCntxt.get());
2336  PushContext(xCntxt);
2337 
2338  m_bSelect = true;
2339 }
2340 
2342 {
2343  assert(m_vPendingStack.empty());
2344 
2345  OSL_ENSURE( m_bSelect, "no Select" );
2346  OSL_ENSURE( m_pFormImpl && m_pFormImpl->GetFCompPropSet().is(),
2347  "no select control" );
2348 
2349  const uno::Reference< beans::XPropertySet > & rPropSet =
2351 
2352  size_t nEntryCnt = m_pFormImpl->GetStringList().size();
2353  if(!m_pFormImpl->GetStringList().empty())
2354  {
2355  Sequence<OUString> aList( static_cast<sal_Int32>(nEntryCnt) );
2356  Sequence<OUString> aValueList( static_cast<sal_Int32>(nEntryCnt) );
2357  OUString *pStrings = aList.getArray();
2358  OUString *pValues = aValueList.getArray();
2359 
2360  for(size_t i = 0; i < nEntryCnt; ++i)
2361  {
2362  OUString sText(m_pFormImpl->GetStringList()[i]);
2363  sText = comphelper::string::stripEnd(sText, ' ');
2364  pStrings[i] = sText;
2365 
2366  sText = m_pFormImpl->GetValueList()[i];
2367  pValues[i] = sText;
2368  }
2369 
2370  rPropSet->setPropertyValue("StringItemList", Any(aList) );
2371 
2372  rPropSet->setPropertyValue("ListSourceType", Any(ListSourceType_VALUELIST) );
2373 
2374  rPropSet->setPropertyValue("ListSource", Any(aValueList) );
2375 
2376  size_t nSelCnt = m_pFormImpl->GetSelectedList().size();
2377  if( !nSelCnt && 1 == m_nSelectEntryCnt && nEntryCnt )
2378  {
2379  // In a dropdown list an entry should always be selected.
2380  m_pFormImpl->GetSelectedList().insert( m_pFormImpl->GetSelectedList().begin(), 0 );
2381  nSelCnt = 1;
2382  }
2383  Sequence<sal_Int16> aSelList( static_cast<sal_Int32>(nSelCnt) );
2384  sal_Int16 *pSels = aSelList.getArray();
2385  for(size_t i = 0; i < nSelCnt; ++i)
2386  {
2387  pSels[i] = static_cast<sal_Int16>(m_pFormImpl->GetSelectedList()[i]);
2388  }
2389  rPropSet->setPropertyValue("DefaultSelection", Any(aSelList) );
2390 
2393  }
2394 
2396 
2397  if( m_bFixSelectWidth )
2398  {
2399  OSL_ENSURE( m_pFormImpl->GetShape().is(), "Shape not saved" );
2400  Size aTextSz( -1, 0 );
2401  SetControlSize( m_pFormImpl->GetShape(), aTextSz, false, false );
2402  }
2403 
2405 
2406  // get context
2407  std::unique_ptr<HTMLAttrContext> xCntxt(PopContext(HtmlTokenId::SELECT_ON));
2408  if (xCntxt)
2409  {
2410  // close attributes
2411  EndContext(xCntxt.get());
2412  }
2413 
2414  m_bSelect = false;
2415 }
2416 
2418 {
2419  OSL_ENSURE( m_bSelect, "no Select" );
2420  OSL_ENSURE( m_pFormImpl && m_pFormImpl->GetFCompPropSet().is(),
2421  "no Select-Control" );
2422 
2423  m_bLBEntrySelected = false;
2424  OUString aValue;
2425 
2426  const HTMLOptions& rHTMLOptions = GetOptions();
2427  for (size_t i = rHTMLOptions.size(); i; )
2428  {
2429  const HTMLOption& rOption = rHTMLOptions[--i];
2430  switch( rOption.GetToken() )
2431  {
2432  case HtmlOptionId::ID:
2433  // leave out for now
2434  break;
2435  case HtmlOptionId::SELECTED:
2436  m_bLBEntrySelected = true;
2437  break;
2438  case HtmlOptionId::VALUE:
2439  aValue = rOption.GetString();
2440  if( aValue.isEmpty() )
2441  aValue = "$$$empty$$$";
2442  break;
2443  default: break;
2444  }
2445  }
2446 
2447  sal_uInt16 nEntryCnt = m_pFormImpl->GetStringList().size();
2448  m_pFormImpl->GetStringList().push_back(OUString());
2449  m_pFormImpl->GetValueList().push_back(aValue);
2450  if( m_bLBEntrySelected )
2451  {
2452  m_pFormImpl->GetSelectedList().push_back( nEntryCnt );
2453  }
2454 }
2455 
2457 {
2458  OSL_ENSURE( m_bSelect, "no select" );
2459  OSL_ENSURE( m_pFormImpl && m_pFormImpl->GetFCompPropSet().is(),
2460  "no select control" );
2461 
2462  if(m_pFormImpl->GetStringList().empty())
2463  return;
2464 
2465  OUString& rText = m_pFormImpl->GetStringList().back();
2466 
2467  if( !aToken.isEmpty() && ' '==aToken[ 0 ] )
2468  {
2469  sal_Int32 nLen = rText.getLength();
2470  if( !nLen || ' '==rText[nLen-1])
2471  aToken.remove( 0, 1 );
2472  }
2473  if( !aToken.isEmpty() )
2474  rText += aToken;
2475 }
2476 
2477 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt16 IncGrfsThatResizeTable()
Definition: htmltab.cxx:3186
OString stripEnd(const OString &rIn, char c)
std::vector< SwPending > m_vPendingStack
Definition: swhtml.hxx:390
bool GetValue() const
Starts a section of nodes in the document model.
Definition: node.hxx:313
void EndSelect()
Definition: htmlform.cxx:2341
constexpr TypedWhichId< SvxCrossedOutItem > RES_CHRATR_CROSSEDOUT(5)
static vcl::Font GetDefaultFont(DefaultFontType nType, LanguageType eLang, GetDefaultFontFlags nFlags, const OutputDevice *pOutDev=nullptr)
void NewTextArea()
Definition: htmlform.cxx:1845
SvxMacro & Insert(SvMacroItemId nEvent, const SvxMacro &rMacro)
bool m_bSelect
Definition: swhtml.hxx:463
SvxCSS1LengthType m_eLeftType
Definition: svxcss1.hxx:137
EnumT GetEnum(const HTMLOptionEnum< EnumT > *pOptEnums, EnumT nDflt=static_cast< EnumT >(0)) const
void SplitPREListingXMP(HTMLAttrContext *pCntxt)
Definition: htmlctxt.cxx:751
sal_Int32 nIndex
HtmlOptionId GetToken() const
SvxCSS1LengthType m_eTopType
Definition: svxcss1.hxx:137
const char * aEventSDOptionTable[]
Definition: htmlform.cxx:162
#define OOO_STRING_SVTOOLS_HTML_O_onsubmit
TOOLS_DLLPUBLIC OString convertLineEnd(const OString &rIn, LineEnd eLineEnd)
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
Marks a position in the document model.
Definition: pam.hxx:36
void SetControlSize(const css::uno::Reference< css::drawing::XShape > &rShape, const Size &rTextSz, bool bMinWidth, bool bMinHeight)
Definition: htmlform.cxx:621
void EndForm(bool bAppend=true)
Definition: htmlform.cxx:1357
const OUString & GetFamilyName() const
static void lcl_html_getEvents(const OUString &rOption, std::u16string_view rValue, std::vector< OUString > &rUnoMacroTable, std::vector< OUString > &rUnoMacroParamTable)
Definition: htmlform.cxx:826
SdrView * GetDrawView()
Definition: vnew.cxx:373
#define OOO_STRING_SVTOOLS_HTML_O_SDonsubmit
OUString m_sText
Definition: htmlform.cxx:206
#define OOO_STRING_SVTOOLS_HTML_O_onblur
OUString GetLanguage() const
void setWidth(tools::Long nWidth)
#define LANGUAGE_ENGLISH_US
std::vector< sal_uInt16 > & GetSelectedList()
Definition: htmlform.cxx:268
sal_uInt16 m_nSelectEntryCnt
Definition: swhtml.hxx:420
const OUString & GetStyleName() const
OUString m_aPathToFile
Definition: swhtml.hxx:356
const uno::Reference< drawing::XShapes > & GetShapes()
Definition: htmlform.cxx:324
void SetShape(const uno::Reference< drawing::XShape > &r)
Definition: htmlform.cxx:251
#define OOO_STRING_SVTOOLS_HTML_O_sdaddparam
SwNodeIndex nNode
Definition: pam.hxx:38
void InsertBookmark(const OUString &rName)
Definition: htmlgrin.cxx:1353
#define MINFLY
Definition: swtypes.hxx:61
long Long
tools::Long GetRight() const
constexpr::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_FONTSIZE(8)
#define MINLAY
Definition: swtypes.hxx:62
HTMLOptionEnum< HTMLWordWrapMode > const aHTMLTextAreaWrapTable[]
Definition: htmlform.cxx:115
HTMLOptionEnum< FormSubmitMethod > const aHTMLFormMethodTable[]
Definition: htmlform.cxx:94
const OUString & GetString() const
Definition: doc.hxx:187
HTMLInputType GetInputType() const
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
constexpr TypedWhichId< SvxUnderlineItem > RES_CHRATR_UNDERLINE(14)
SvMacroItemId
SwNode & GetNode() const
Definition: ndindex.hxx:128
std::vector< sal_uInt16 > m_aSelectedList
Definition: htmlform.cxx:209
SvKeyValueIterator * GetHeaderAttrs() const
Definition: htmlform.cxx:274
OUString m_sBaseURL
Definition: swhtml.hxx:357
const sal_uInt16 TABINDEX_MAX
Definition: htmlform.cxx:92
void NewForm(bool bAppend=true)
Definition: htmlform.cxx:1192
uno::Reference< container::XIndexContainer > m_xFormComps
Definition: htmlform.cxx:202
HTMLOptionEnum< FormSubmitEncoding > const aHTMLFormEncTypeTable[]
Definition: htmlform.cxx:101
TRISTATE_TRUE
uno::Reference< script::XEventAttacherManager > m_xFormEventManager
Definition: htmlform.cxx:199
#define OOO_STRING_SVTOOLS_HTML_O_SDonreset
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_FONT(7)
#define OOO_STRING_SVTOOLS_HTML_WW_off
Color GetRGBColor() const
std::vector< OUString > & GetValueList()
Definition: htmlform.cxx:262
FontItalic GetPosture() const
FontFamily GetFamilyType()
Status
constexpr auto convertTwipToMm100(N n)
static OutputDevice * GetDefaultDevice()
constexpr tools::Long Width() const
SwDocShell * m_pDocShell
Definition: htmlform.cxx:188
void InsertInput()
Definition: htmlform.cxx:1373
uno::Reference< drawing::XShapes > m_xShapes
Definition: htmlform.cxx:195
constexpr auto SFX_INTERFACE_NONE
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(159)
bool m_bFixSelectWidth
Definition: swhtml.hxx:460
void GetDrawPage()
Definition: htmlform.cxx:290
void EndTextArea()
Definition: htmlform.cxx:2070
SwHTMLForm_Impl(SwDocShell *pDSh)
Definition: htmlform.cxx:212
#define OOO_STRING_SVTOOLS_HTML_IT_reset
css::uno::Reference< css::drawing::XShape > InsertControl(const css::uno::Reference< css::form::XFormComponent > &rFormComp, const css::uno::Reference< css::beans::XPropertySet > &rFCompPropSet, const Size &rSize, sal_Int16 eVertOri, sal_Int16 eHoriOri, SfxItemSet &rCSS1ItemSet, SvxCSS1PropertyInfo &rCSS1PropInfo, const SvxMacroTableDtor &rMacroTable, const std::vector< OUString > &rUnoMacroTable, const std::vector< OUString > &rUnoMacroParamTable, bool bSetPropSet=true, bool bHidden=false)
Definition: htmlform.cxx:844
SwIndex nContent
Definition: pam.hxx:39
ScriptType GetScriptType(SvKeyValueIterator *) const
uno::Reference< drawing::XShape > m_xShape
Definition: htmlform.cxx:204
std::vector< OUString > m_aStringList
Definition: htmlform.cxx:207
bool ParseStyleOptions(const OUString &rStyle, const OUString &rId, const OUString &rClass, SfxItemSet &rItemSet, SvxCSS1PropertyInfo &rPropInfo, const OUString *pLang=nullptr, const OUString *pDir=nullptr)
Definition: htmlcss1.cxx:1838
constexpr OUStringLiteral sServiceName
Definition: accdoc.cxx:55
#define OOO_STRING_SVTOOLS_HTML_O_onchange
SvKeyValueIterator * m_pHeaderAttrs
Definition: htmlform.cxx:190
LineEnd GetSystemLineEnd()
std::vector< OUString > m_aValueList
Definition: htmlform.cxx:208
#define OOO_STRING_SVTOOLS_HTML_METHOD_post
const SwTable & GetTable() const
Definition: node.hxx:506
static SvMacroItemId aEventTypeTable[]
Definition: htmlform.cxx:125
#define OOO_STRING_SVTOOLS_HTML_O_sdevent
SwPaM * m_pPam
Definition: swhtml.hxx:393
bool m_bRemoveHidden
Definition: swhtml.hxx:467
const char * sName
#define OOO_STRING_SVTOOLS_HTML_WW_soft
static bool lcl_html_setEvents(const uno::Reference< script::XEventAttacherManager > &rEvtMn, sal_uInt32 nPos, const SvxMacroTableDtor &rMacroTable, const std::vector< OUString > &rUnoMacroTable, const std::vector< OUString > &rUnoMacroParamTable, const OUString &rType)
Definition: htmlform.cxx:737
ImplSVEvent * m_nEventId
Definition: swhtml.hxx:409
constexpr TypedWhichId< SvxWeightItem > RES_CHRATR_WEIGHT(15)
DocumentType eType
const sal_uInt16 TABINDEX_MIN
Definition: htmlform.cxx:91
const Color & GetColor() const
const uno::Reference< container::XIndexContainer > & GetForms()
Definition: htmlform.cxx:303
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:137
void NewSelect()
Definition: htmlform.cxx:2127
sal_uInt16 GetBrowseWidthByTable(const SwDoc &rDoc) const
Calculates available width by the table-frame or static GetBrowseWidth if no layout exists...
Definition: htmltbl.cxx:374
uno::Reference< beans::XPropertySet > m_xFCompPropertySet
Definition: htmlform.cxx:203
bool empty() const
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
Style of a layout element.
Definition: frmfmt.hxx:59
#define TOOLS_WARN_EXCEPTION(area, stream)
bool m_bLBEntrySelected
Definition: swhtml.hxx:446
FontPitch GetPitch()
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:81
int i
uno::Reference< XMultiServiceFactory > m_xServiceFactory
Definition: htmlform.cxx:196
FontWeight GetWeight() const
uno::Reference< script::XEventAttacherManager > m_xControlEventManager
Definition: htmlform.cxx:198
tools::Long m_nTop
Definition: svxcss1.hxx:133
const SwPosition * GetPoint() const
Definition: pam.hxx:208
#define OOO_STRING_SVTOOLS_HTML_O_SDonchange
void NotifyMacroEventRead()
Definition: htmlgrin.cxx:1524
const SwPosition * GetContentAnchor() const
Definition: fmtanchr.hxx:67
sal_Int32 GetSNumber() const
std::unique_ptr< SwCSS1Parser > m_pCSS1Parser
Definition: swhtml.hxx:388
TRISTATE_FALSE
tools::Long GetLeft() const
void AddParSpace()
Definition: swhtml.cxx:2491
#define OOO_STRING_SVTOOLS_HTML_O_SDonblur
void SetTextFirstLineOffset(const short nF, const sal_uInt16 nProp=100)
void DeleteFormImpl()
Definition: htmlform.cxx:587
void EndContext(HTMLAttrContext *pContext)
Definition: htmlctxt.cxx:371
#define OOO_STRING_SVTOOLS_HTML_WW_virtual
std::unique_ptr< HTMLAttrContext > PopContext(HtmlTokenId nToken=HtmlTokenId::NONE)
Definition: htmlcss1.cxx:2100
void Erase(SvMacroItemId nEvent)
css::uno::Reference< css::frame::XModel3 > GetBaseModel() const
OUString & GetText()
Definition: htmlform.cxx:253
SvxCSS1Position m_ePosition
Definition: svxcss1.hxx:121
bool Resize(sal_uInt16 nAbsAvail, bool bRecalc=false, bool bForce=false, sal_uLong nDelay=0)
Recalculation of table widths for available width that has been passed.
Definition: htmltbl.cxx:1695
SfxItemSet * GetItemSet() const
const uno::Reference< container::XIndexContainer > & GetFormComps() const
Definition: htmlform.cxx:226
HTMLInputType
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:139
uno::Reference< drawing::XDrawPage > m_xDrawPage
Definition: htmlform.cxx:193
SvxAdjust m_eFloat
Definition: svxcss1.hxx:119
const char * aEventListenerTable[]
Definition: htmlform.cxx:138
const uno::Reference< script::XEventAttacherManager > & GetFormEventManager()
Definition: htmlform.cxx:354
void SetFCompPropSet(const uno::Reference< beans::XPropertySet > &r)
Definition: htmlform.cxx:243
#define OOO_STRING_SVTOOLS_HTML_ET_multipart
void ReleaseFormComps()
Definition: htmlform.cxx:236
HTMLOptionEnum< sal_Int16 > const aHTMLImgVAlignTable[]
Definition: htmlgrin.cxx:83
sal_uInt32 GetNumber() const
SfxViewFrame * m_pTempViewFrame
Definition: swhtml.hxx:482
HtmlTokenId
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
FontLineStyle GetLineStyle() const
#define OOO_STRING_SVTOOLS_HTML_WW_physical
static void lcl_html_setFixedFontProperty(const uno::Reference< beans::XPropertySet > &rPropSet)
Definition: htmlform.cxx:593
sal_uInt16 Which() const
for Querying of Writer-functions.
Definition: format.hxx:82
constexpr TypedWhichId< SvxColorItem > RES_CHRATR_COLOR(3)
const PropertyValue * pValues
OUString m_aScriptType
Definition: swhtml.hxx:361
sal_uInt32 GetHeight() const
const SvxMacro * Get(SvMacroItemId nEvent) const
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(105)
const uno::Reference< drawing::XShape > & GetShape() const
Definition: htmlform.cxx:250
sal_uInt16 DecGrfsThatResize()
Definition: swtable.hxx:182
constexpr tools::Long HTML_DFLT_IMG_HEIGHT
Definition: swhtml.hxx:65
#define OOO_STRING_SVTOOLS_HTML_ET_url
void InsertSelectText()
Definition: htmlform.cxx:2456
#define OOO_STRING_SVTOOLS_HTML_O_SDonfocus
#define SAL_WARN_IF(condition, area, stream)
constexpr tools::Long Height() const
static SfxViewFrame * LoadHiddenDocument(SfxObjectShell const &i_rDoc, SfxInterfaceId i_nViewId)
OUString GetPartBeforeLastName() const
void InsertTextAreaText(HtmlTokenId nToken)
Definition: htmlform.cxx:2097
vcl::Window * GetWin() const
Definition: viewsh.hxx:338
void EraseValueList()
Definition: htmlform.cxx:263
SwHTMLTableLayout * GetHTMLTableLayout()
Definition: swtable.hxx:177
VCL_DLLPUBLIC float ConvertFontWeight(FontWeight eWeight)
::std::vector< HTMLOption > HTMLOptions
#define OOO_STRING_SVTOOLS_HTML_WW_hard
sal_Int32 GetIndex() const
Definition: index.hxx:91
#define OOO_STRING_SVTOOLS_HTML_O_onclick
::OutputDevice const * GetOutDev() const
tools::Long m_nLeft
Definition: svxcss1.hxx:133
SwHTMLForm_Impl * m_pFormImpl
Definition: swhtml.hxx:399
constexpr tools::Long HTML_DFLT_IMG_WIDTH
Definition: swhtml.hxx:64
#define OOO_STRING_SVTOOLS_HTML_O_onreset
#define OOO_STRING_SVTOOLS_HTML_METHOD_get
std::vector< OUString > & GetStringList()
Definition: htmlform.cxx:256
const uno::Reference< XMultiServiceFactory > & GetServiceFactory()
Definition: htmlform.cxx:277
constexpr TypedWhichId< SvxLRSpaceItem > RES_LR_SPACE(91)
FontStrikeout GetStrikeout() const
css::uno::Reference< css::awt::XControl > GetUnoControl(const SdrView &_rView, const OutputDevice &_rOut) const
FILE * init(int, char **)
bool m_bTextArea
Definition: swhtml.hxx:461
std::shared_ptr< HTMLTable > m_xTable
Definition: swhtml.hxx:398
void EraseSelectedList()
Definition: htmlform.cxx:269
const OUString & GetTokenString() const
#define OOO_STRING_SVTOOLS_HTML_ET_text
SwTableNode * FindTableNode()
Search table node, in which it is.
Definition: node.cxx:358
#define OOO_STRING_SVTOOLS_HTML_IT_submit
HtmlOptionId
void ReleaseFCompPropSet()
Definition: htmlform.cxx:248
void setHeight(tools::Long nHeight)
const SwStartNode * FindFlyStartNode() const
Definition: node.hxx:200
const char * aEventOptionTable[]
Definition: htmlform.cxx:174
const char * aEventMethodTable[]
Definition: htmlform.cxx:150
void InsertSelectOption()
Definition: htmlform.cxx:2417
HTMLOptionEnum< sal_Int16 > const aHTMLImgHAlignTable[]
Definition: htmlgrin.cxx:76
ScriptType
void EraseText()
Definition: htmlform.cxx:254
const OUString & GetScriptTypeString(SvKeyValueIterator *) const
bool AppendTextNode(SwHTMLAppendMode eMode=AM_NORMAL, bool bUpdateNum=true)
Definition: swhtml.cxx:2188
const uno::Reference< beans::XPropertySet > & GetFCompPropSet() const
Definition: htmlform.cxx:238
#define OOO_STRING_SVTOOLS_HTML_on
void PushContext(std::unique_ptr< HTMLAttrContext > &rCntxt)
Definition: swhtml.hxx:572
#define OOO_STRING_SVTOOLS_HTML_O_onfocus
SwViewShell * CallStartAction(SwViewShell *pVSh=nullptr, bool bChkPtr=true)
Definition: swhtml.cxx:2633
rtl::Reference< SwDoc > m_xDoc
Definition: swhtml.hxx:392
void EraseStringList()
Definition: htmlform.cxx:257
SwFrameFormat * GetFrameFormat() const
Definition: unodraw.hxx:258
const OUString & GetMacName() const
#define HTMLTABLE_RESIZE_NOW
Definition: htmltbl.hxx:36
SdrObject * FindSdrObject()
Definition: frmfmt.hxx:140
constexpr TypedWhichId< SvxULSpaceItem > RES_UL_SPACE(92)
const uno::Reference< script::XEventAttacherManager > & GetControlEventManager()
Definition: htmlform.cxx:340
constexpr TypedWhichId< SvxPostureItem > RES_CHRATR_POSTURE(11)
#define OOO_STRING_SVTOOLS_HTML_O_SDonclick
uno::Reference< container::XIndexContainer > m_xForms
Definition: htmlform.cxx:194
void SetFormComps(const uno::Reference< container::XIndexContainer > &r)
Definition: htmlform.cxx:231
AnyEventRef aEvent
rtl_TextEncoding GetCharSet() const
const Color & GetValue() const
static bool HasStyleOptions(std::u16string_view rStyle, std::u16string_view rId, std::u16string_view rClass, const OUString *pLang=nullptr, const OUString *pDir=nullptr)
Definition: swhtml.hxx:1014
bool m_bDetectedRangeSegmentation false
HTMLWordWrapMode
Definition: htmlform.cxx:111
SVL_DLLPUBLIC OUString SmartRel2Abs(INetURLObject const &rTheBaseURIRef, OUString const &rTheRelURIRef, Link< OUString *, bool > const &rMaybeFileHdl=Link< OUString *, bool >(), bool bCheckFileExists=true, bool bIgnoreFragment=false, INetURLObject::EncodeMechanism eEncodeMechanism=INetURLObject::EncodeMechanism::WasEncoded, INetURLObject::DecodeMechanism eDecodeMechanism=INetURLObject::DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, FSysStyle eStyle=FSysStyle::Detect)
OUString aId
SfxMedium * GetMedium() const
bool m_bTAIgnoreNewPara
Definition: swhtml.hxx:447