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