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 <hintids.hxx>
21 #include <comphelper/string.hxx>
22 #include <vcl/svapp.hxx>
23 #include <vcl/wrkwin.hxx>
24 
25 #include <vcl/unohelp.hxx>
26 #include <svtools/htmlkywd.hxx>
27 #include <svtools/htmltokn.h>
28 #include <svl/urihelper.hxx>
29 #include <sfx2/request.hxx>
30 #include <sfx2/docfile.hxx>
31 #include <sfx2/event.hxx>
32 #include <sfx2/sfxsids.hrc>
33 #include <sfx2/viewfrm.hxx>
34 #include <editeng/lrspitem.hxx>
35 #include <editeng/ulspitem.hxx>
36 #include <editeng/brushitem.hxx>
37 #include <editeng/colritem.hxx>
38 #include <editeng/fontitem.hxx>
39 #include <editeng/fhgtitem.hxx>
40 #include <editeng/wghtitem.hxx>
41 #include <editeng/postitem.hxx>
42 #include <editeng/udlnitem.hxx>
44 #include <svx/svdouno.hxx>
45 #include <svx/fmglob.hxx>
46 #include <cppuhelper/implbase.hxx>
47 #include <com/sun/star/form/ListSourceType.hpp>
48 #include <com/sun/star/form/FormButtonType.hpp>
49 #include <com/sun/star/form/FormSubmitEncoding.hpp>
50 #include <com/sun/star/form/FormSubmitMethod.hpp>
51 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
52 #include <com/sun/star/script/XEventAttacherManager.hpp>
53 #include <com/sun/star/text/WrapTextMode.hpp>
54 #include <com/sun/star/text/HoriOrientation.hpp>
55 #include <com/sun/star/text/VertOrientation.hpp>
56 #include <com/sun/star/text/TextContentAnchorType.hpp>
57 #include <com/sun/star/container/XIndexContainer.hpp>
58 #include <com/sun/star/drawing/XControlShape.hpp>
59 #include <com/sun/star/awt/XTextLayoutConstrains.hpp>
60 #include <com/sun/star/awt/XLayoutConstrains.hpp>
61 #include <com/sun/star/awt/XImageConsumer.hpp>
62 #include <com/sun/star/awt/ImageStatus.hpp>
63 #include <com/sun/star/form/XImageProducerSupplier.hpp>
64 #include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
65 #include <com/sun/star/form/XForm.hpp>
66 #include <doc.hxx>
68 #include <IDocumentUndoRedo.hxx>
69 #include <pam.hxx>
70 #include <swtable.hxx>
71 #include <fmtanchr.hxx>
72 #include <htmltbl.hxx>
73 #include <docsh.hxx>
74 #include <viewsh.hxx>
75 #include <unodraw.hxx>
76 #include <unotextrange.hxx>
77 #include <dcontact.hxx>
78 
79 #include "swcss1.hxx"
80 #include "swhtml.hxx"
81 #include "htmlform.hxx"
82 
83 using namespace ::com::sun::star;
84 using namespace ::com::sun::star::uno;
85 using namespace ::com::sun::star::lang;
86 using namespace ::com::sun::star::form;
87 
88 const sal_uInt16 TABINDEX_MIN = 0;
89 const sal_uInt16 TABINDEX_MAX = 32767;
90 
92 {
93  { OOO_STRING_SVTOOLS_HTML_METHOD_get, FormSubmitMethod_GET },
94  { OOO_STRING_SVTOOLS_HTML_METHOD_post, FormSubmitMethod_POST },
95  { nullptr, FormSubmitMethod(0) }
96 };
97 
99 {
100  { OOO_STRING_SVTOOLS_HTML_ET_url, FormSubmitEncoding_URL },
101  { OOO_STRING_SVTOOLS_HTML_ET_multipart, FormSubmitEncoding_MULTIPART },
102  { OOO_STRING_SVTOOLS_HTML_ET_text, FormSubmitEncoding_TEXT },
103  { nullptr, FormSubmitEncoding(0) }
104 };
105 
107 
109 {
115  { nullptr, HTMLWordWrapMode(0) }
116 };
117 
119 {
120  SvMacroItemId::HtmlOnSubmitForm,
121  SvMacroItemId::HtmlOnResetForm,
122  SvMacroItemId::HtmlOnGetFocus,
123  SvMacroItemId::HtmlOnLoseFocus,
124  SvMacroItemId::HtmlOnClick,
125  SvMacroItemId::HtmlOnClickItem,
126  SvMacroItemId::HtmlOnChange,
127  SvMacroItemId::HtmlOnSelect,
128  SvMacroItemId::NONE
129 };
130 
132 {
133  "XSubmitListener",
134  "XResetListener",
135  "XFocusListener",
136  "XFocusListener",
137  "XApproveActionListener",
138  "XItemListener",
139  "XChangeListener",
140  ""
141 };
142 
144 {
145  "approveSubmit",
146  "approveReset",
147  "focusGained",
148  "focusLost",
149  "approveAction",
150  "itemStateChanged",
151  "changed",
152  ""
153 };
154 
156 {
162  OOO_STRING_SVTOOLS_HTML_O_SDonclick,
164  nullptr
165 };
166 
168 {
174  OOO_STRING_SVTOOLS_HTML_O_onclick,
176  nullptr
177 };
178 
180 {
182 
184 
185  // Cached interfaces
186  uno::Reference< drawing::XDrawPage > m_xDrawPage;
187  uno::Reference< container::XIndexContainer > m_xForms;
188  uno::Reference< drawing::XShapes > m_xShapes;
189  uno::Reference< XMultiServiceFactory > m_xServiceFactory;
190 
191  uno::Reference< script::XEventAttacherManager > m_xControlEventManager;
192  uno::Reference< script::XEventAttacherManager > m_xFormEventManager;
193 
194  // Context information
195  uno::Reference< container::XIndexContainer > m_xFormComps;
196  uno::Reference< beans::XPropertySet > m_xFCompPropertySet;
197  uno::Reference< drawing::XShape > m_xShape;
198 
199  OUString m_sText;
200  std::vector<OUString> m_aStringList;
201  std::vector<OUString> m_aValueList;
202  std::vector<sal_uInt16> m_aSelectedList;
203 
204 public:
205  explicit SwHTMLForm_Impl( SwDocShell *pDSh ) :
206  m_pDocShell( pDSh ),
207  m_pHeaderAttrs( pDSh ? pDSh->GetHeaderAttributes() : nullptr )
208  {
209  OSL_ENSURE( m_pDocShell, "No DocShell, no Controls" );
210  }
211 
212  const uno::Reference< XMultiServiceFactory >& GetServiceFactory();
213  void GetDrawPage();
214  const uno::Reference< drawing::XShapes >& GetShapes();
215  const uno::Reference< script::XEventAttacherManager >& GetControlEventManager();
216  const uno::Reference< script::XEventAttacherManager >& GetFormEventManager();
217  const uno::Reference< container::XIndexContainer >& GetForms();
218 
219  const uno::Reference< container::XIndexContainer >& GetFormComps() const
220  {
221  return m_xFormComps;
222  }
223 
224  void SetFormComps( const uno::Reference< container::XIndexContainer >& r )
225  {
226  m_xFormComps = r;
227  }
228 
229  void ReleaseFormComps() { m_xFormComps = nullptr; m_xControlEventManager = nullptr; }
230 
231  const uno::Reference< beans::XPropertySet >& GetFCompPropSet() const
232  {
233  return m_xFCompPropertySet;
234  }
235 
236  void SetFCompPropSet( const uno::Reference< beans::XPropertySet >& r )
237  {
238  m_xFCompPropertySet = r;
239  }
240 
241  void ReleaseFCompPropSet() { m_xFCompPropertySet = nullptr; }
242 
243  const uno::Reference< drawing::XShape >& GetShape() const { return m_xShape; }
244  void SetShape( const uno::Reference< drawing::XShape >& r ) { m_xShape = r; }
245 
246  OUString& GetText() { return m_sText; }
247  void EraseText() { m_sText.clear(); }
248 
249  std::vector<OUString>& GetStringList() { return m_aStringList; }
251  {
252  m_aStringList.clear();
253  }
254 
255  std::vector<OUString>& GetValueList() { return m_aValueList; }
257  {
258  m_aValueList.clear();
259  }
260 
261  std::vector<sal_uInt16>& GetSelectedList() { return m_aSelectedList; }
263  {
264  m_aSelectedList.clear();
265  }
266 
268 };
269 
270 const uno::Reference< XMultiServiceFactory >& SwHTMLForm_Impl::GetServiceFactory()
271 {
272  if( !m_xServiceFactory.is() && m_pDocShell )
273  {
275  uno::Reference< XMultiServiceFactory >( m_pDocShell->GetBaseModel(),
276  UNO_QUERY );
277  OSL_ENSURE( m_xServiceFactory.is(),
278  "XServiceFactory not received from model" );
279  }
280  return m_xServiceFactory;
281 }
282 
284 {
285  if( !m_xDrawPage.is() && m_pDocShell )
286  {
287  uno::Reference< drawing::XDrawPageSupplier > xTextDoc( m_pDocShell->GetBaseModel(),
288  UNO_QUERY );
289  OSL_ENSURE( xTextDoc.is(),
290  "drawing::XDrawPageSupplier not received from model" );
291  m_xDrawPage = xTextDoc->getDrawPage();
292  OSL_ENSURE( m_xDrawPage.is(), "drawing::XDrawPage not received" );
293  }
294 }
295 
296 const uno::Reference< container::XIndexContainer >& SwHTMLForm_Impl::GetForms()
297 {
298  if( !m_xForms.is() )
299  {
300  GetDrawPage();
301  if( m_xDrawPage.is() )
302  {
303  uno::Reference< XFormsSupplier > xFormsSupplier( m_xDrawPage, UNO_QUERY );
304  OSL_ENSURE( xFormsSupplier.is(),
305  "XFormsSupplier not received from drawing::XDrawPage" );
306 
307  uno::Reference< container::XNameContainer > xNameCont =
308  xFormsSupplier->getForms();
309  m_xForms.set( xNameCont, UNO_QUERY );
310 
311  OSL_ENSURE( m_xForms.is(), "XForms not received" );
312  }
313  }
314  return m_xForms;
315 }
316 
317 const uno::Reference< drawing::XShapes > & SwHTMLForm_Impl::GetShapes()
318 {
319  if( !m_xShapes.is() )
320  {
321  GetDrawPage();
322  if( m_xDrawPage.is() )
323  {
324  m_xShapes.set( m_xDrawPage, UNO_QUERY );
325  OSL_ENSURE( m_xShapes.is(),
326  "XShapes not received from drawing::XDrawPage" );
327  }
328  }
329  return m_xShapes;
330 }
331 
332 const uno::Reference< script::XEventAttacherManager >&
334 {
335  if( !m_xControlEventManager.is() && m_xFormComps.is() )
336  {
338  uno::Reference< script::XEventAttacherManager >( m_xFormComps, UNO_QUERY );
339  OSL_ENSURE( m_xControlEventManager.is(),
340  "uno::Reference< XEventAttacherManager > not received from xFormComps" );
341  }
342 
343  return m_xControlEventManager;
344 }
345 
346 const uno::Reference< script::XEventAttacherManager >&
348 {
349  if( !m_xFormEventManager.is() )
350  {
351  GetForms();
352  if( m_xForms.is() )
353  {
355  uno::Reference< script::XEventAttacherManager >( m_xForms, UNO_QUERY );
356  OSL_ENSURE( m_xFormEventManager.is(),
357  "uno::Reference< XEventAttacherManager > not received from xForms" );
358  }
359  }
360 
361  return m_xFormEventManager;
362 }
363 
365  public cppu::WeakImplHelper< awt::XImageConsumer, XEventListener >
366 {
367  uno::Reference< drawing::XShape > xShape; // the control
368  uno::Reference< XImageProducerSupplier > xSrc;
369  uno::Reference< awt::XImageConsumer > xThis; // reference to self
370  bool const bSetWidth;
371  bool const bSetHeight;
372 
373  void clear();
374 
375 public:
376  SwHTMLImageWatcher( const uno::Reference< drawing::XShape > & rShape,
377  bool bWidth, bool bHeight );
378 
379  // startProduction can not be called in the constructor because it can
380  // destruct itself, hence a separate method.
381  void start() { xSrc->getImageProducer()->startProduction(); }
382 
383  // UNO binding
384 
385  // XImageConsumer
386  virtual void SAL_CALL init( sal_Int32 Width, sal_Int32 Height) override;
387  virtual void SAL_CALL setColorModel(
388  sal_Int16 BitCount, const uno::Sequence< sal_Int32 >& RGBAPal,
389  sal_Int32 RedMask, sal_Int32 GreenMask, sal_Int32 BlueMask,
390  sal_Int32 AlphaMask) override;
391  virtual void SAL_CALL setPixelsByBytes(
392  sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height,
393  const uno::Sequence< sal_Int8 >& ProducerData,
394  sal_Int32 Offset, sal_Int32 Scansize) override;
395  virtual void SAL_CALL setPixelsByLongs(
396  sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height,
397  const uno::Sequence< sal_Int32 >& ProducerData,
398  sal_Int32 Offset, sal_Int32 Scansize) override;
399  virtual void SAL_CALL complete(
400  sal_Int32 Status,
401  const uno::Reference< awt::XImageProducer > & Producer) override;
402 
403  // XEventListener
404  virtual void SAL_CALL disposing( const EventObject& Source ) override;
405 };
406 
408  const uno::Reference< drawing::XShape >& rShape,
409  bool bWidth, bool bHeight ) :
410  xShape( rShape ),
411  bSetWidth( bWidth ), bSetHeight( bHeight )
412 {
413  // Remember the source of the image
414  uno::Reference< drawing::XControlShape > xControlShape( xShape, UNO_QUERY );
415  uno::Reference< awt::XControlModel > xControlModel(
416  xControlShape->getControl() );
417  xSrc.set( xControlModel, UNO_QUERY );
418  OSL_ENSURE( xSrc.is(), "No XImageProducerSupplier" );
419 
420  // Register as Event-Listener on the shape to be able to release it on dispose.
421  uno::Reference< XEventListener > xEvtLstnr = static_cast<XEventListener *>(this);
422  uno::Reference< XComponent > xComp( xShape, UNO_QUERY );
423  xComp->addEventListener( xEvtLstnr );
424 
425  // Lastly we keep a reference to ourselves so we are not destroyed
426  // (should not be necessary since we're still registered elsewhere)
427  xThis = static_cast<awt::XImageConsumer *>(this);
428 
429  // Register at ImageProducer to retrieve the size...
430  xSrc->getImageProducer()->addConsumer( xThis );
431 }
432 
434 {
435  // Unregister on Shape
436  uno::Reference< XEventListener > xEvtLstnr = static_cast<XEventListener *>(this);
437  uno::Reference< XComponent > xComp( xShape, UNO_QUERY );
438  xComp->removeEventListener( xEvtLstnr );
439 
440  // Unregister on ImageProducer
441  uno::Reference<awt::XImageProducer> xProd = xSrc->getImageProducer();
442  if( xProd.is() )
443  xProd->removeConsumer( xThis );
444 }
445 
446 void SwHTMLImageWatcher::init( sal_Int32 Width, sal_Int32 Height )
447 {
448  OSL_ENSURE( bSetWidth || bSetHeight,
449  "Width or height has to be adjusted" );
450 
451  // If no width or height is given, it is initialized to those of
452  // the empty graphic that is available before the stream of a graphic
453  // that is to be displayed asynchronous is available.
454  if( !Width && !Height )
455  return;
456 
457  awt::Size aNewSz;
458  aNewSz.Width = Width;
459  aNewSz.Height = Height;
461  {
462  Size aTmp(aNewSz.Width, aNewSz.Height);
464  ->PixelToLogic( aTmp, MapMode( MapUnit::Map100thMM ) );
465  aNewSz.Width = aTmp.Width();
466  aNewSz.Height = aTmp.Height();
467  }
468 
469  if( !bSetWidth || !bSetHeight )
470  {
471  awt::Size aSz( xShape->getSize() );
472  if( bSetWidth && aNewSz.Height )
473  {
474  aNewSz.Width *= aSz.Height;
475  aNewSz.Width /= aNewSz.Height;
476  aNewSz.Height = aSz.Height;
477  }
478  if( bSetHeight && aNewSz.Width )
479  {
480  aNewSz.Height *= aSz.Width;
481  aNewSz.Height /= aNewSz.Width;
482  aNewSz.Width = aSz.Width;
483  }
484  }
485  if( aNewSz.Width < MINFLY )
486  aNewSz.Width = MINFLY;
487  if( aNewSz.Height < MINFLY )
488  aNewSz.Height = MINFLY;
489 
490  xShape->setSize( aNewSz );
491  if( bSetWidth )
492  {
493  // If the control is anchored to a table, the column have to be recalculated
494 
495  // To get to the SwXShape* we need an interface that is implemented by SwXShape
496 
497  uno::Reference< beans::XPropertySet > xPropSet( xShape, UNO_QUERY );
498  uno::Reference< XUnoTunnel> xTunnel( xPropSet, UNO_QUERY );
499  SwXShape *pSwShape = xTunnel.is() ?
500  reinterpret_cast< SwXShape * >( sal::static_int_cast< sal_IntPtr>(
501  xTunnel->getSomething(SwXShape::getUnoTunnelId()) ))
502  : nullptr;
503 
504  OSL_ENSURE( pSwShape, "Where is SW-Shape?" );
505  if( pSwShape )
506  {
507  SwFrameFormat *pFrameFormat = pSwShape->GetFrameFormat();
508 
509  const SwDoc *pDoc = pFrameFormat->GetDoc();
510  const SwPosition* pAPos = pFrameFormat->GetAnchor().GetContentAnchor();
511  SwTableNode *pTableNd;
512  if (pAPos && nullptr != (pTableNd = pAPos->nNode.GetNode().FindTableNode()))
513  {
514  const bool bLastGrf = !pTableNd->GetTable().DecGrfsThatResize();
515  SwHTMLTableLayout *pLayout =
516  pTableNd->GetTable().GetHTMLTableLayout();
517  if( pLayout )
518  {
519  const sal_uInt16 nBrowseWidth =
520  pLayout->GetBrowseWidthByTable( *pDoc );
521 
522  if ( nBrowseWidth )
523  {
524  pLayout->Resize( nBrowseWidth, true, true,
525  bLastGrf ? HTMLTABLE_RESIZE_NOW
526  : 500 );
527  }
528  }
529  }
530  }
531  }
532 
533  // unregister and delete self
534  clear();
535  uno::Reference< awt::XImageConsumer > xTmp = static_cast<awt::XImageConsumer*>(this);
536  xThis = nullptr;
537 }
538 
540  sal_Int16, const Sequence< sal_Int32 >&, sal_Int32, sal_Int32,
541  sal_Int32, sal_Int32 )
542 {
543 }
544 
546  sal_Int32, sal_Int32, sal_Int32, sal_Int32,
547  const Sequence< sal_Int8 >&, sal_Int32, sal_Int32 )
548 {
549 }
550 
552  sal_Int32, sal_Int32, sal_Int32, sal_Int32,
553  const Sequence< sal_Int32 >&, sal_Int32, sal_Int32 )
554 {
555 }
556 
558  const uno::Reference< awt::XImageProducer >& )
559 {
560  if( awt::ImageStatus::IMAGESTATUS_ERROR == Status || awt::ImageStatus::IMAGESTATUS_ABORTED == Status )
561  {
562  // unregister and delete self
563  clear();
564  uno::Reference< awt::XImageConsumer > xTmp = static_cast<awt::XImageConsumer*>(this);
565  xThis = nullptr;
566  }
567 }
568 
569 void SwHTMLImageWatcher::disposing(const lang::EventObject& evt)
570 {
571  uno::Reference< awt::XImageConsumer > xTmp;
572 
573  // We need to release the shape if it is disposed of
574  if( evt.Source == xShape )
575  {
576  clear();
577  xTmp = static_cast<awt::XImageConsumer*>(this);
578  xThis = nullptr;
579  }
580 }
581 
583 {
584  delete m_pFormImpl;
585  m_pFormImpl = nullptr;
586 }
587 
589  const uno::Reference< beans::XPropertySet >& rPropSet )
590 {
592  DefaultFontType::FIXED, LANGUAGE_ENGLISH_US,
593  GetDefaultFontFlags::OnlyOne ) );
594  Any aTmp;
595  aTmp <<= aFixedFont.GetFamilyName();
596  rPropSet->setPropertyValue("FontName", aTmp );
597 
598  aTmp <<= aFixedFont.GetStyleName();
599  rPropSet->setPropertyValue("FontStyleName",
600  aTmp );
601 
602  aTmp <<= static_cast<sal_Int16>(aFixedFont.GetFamilyType());
603  rPropSet->setPropertyValue("FontFamily", aTmp );
604 
605  aTmp <<= static_cast<sal_Int16>(aFixedFont.GetCharSet());
606  rPropSet->setPropertyValue("FontCharset",
607  aTmp );
608 
609  aTmp <<= static_cast<sal_Int16>(aFixedFont.GetPitch());
610  rPropSet->setPropertyValue("FontPitch", aTmp );
611 
612  aTmp <<= float(10.0);
613  rPropSet->setPropertyValue("FontHeight", aTmp );
614 }
615 
616 void SwHTMLParser::SetControlSize( const uno::Reference< drawing::XShape >& rShape,
617  const Size& rTextSz,
618  bool bMinWidth,
619  bool bMinHeight )
620 {
621  if( !rTextSz.Width() && !rTextSz.Height() && !bMinWidth && !bMinHeight )
622  return;
623 
624  // To get to SwXShape* we need an interface that is implemented by SwXShape
625 
626  uno::Reference< beans::XPropertySet > xPropSet( rShape, UNO_QUERY );
627 
628  SwViewShell *pVSh = m_xDoc->getIDocumentLayoutAccess().GetCurrentViewShell();
629  if( !pVSh && !m_nEventId )
630  {
631  // If there is no view shell by now and the doc shell is an internal
632  // one, no view shell will be created. That for, we have to do that of
633  // our own. This happens if a linked section is inserted or refreshed.
634  SwDocShell *pDocSh = m_xDoc->GetDocShell();
635  if( pDocSh )
636  {
637  if ( pDocSh->GetMedium() )
638  {
639  // if there is no hidden property in the MediaDescriptor it should be removed after loading
640  const SfxBoolItem* pHiddenItem = SfxItemSet::GetItem<SfxBoolItem>(pDocSh->GetMedium()->GetItemSet(), SID_HIDDEN, false);
641  m_bRemoveHidden = ( pHiddenItem == nullptr || !pHiddenItem->GetValue() );
642  }
643 
645  CallStartAction();
646  pVSh = m_xDoc->getIDocumentLayoutAccess().GetCurrentViewShell();
647  // this ridiculous hack also enables Undo, so turn it off again
648  m_xDoc->GetIDocumentUndoRedo().DoUndo(false);
649  }
650  }
651 
652  uno::Reference< XUnoTunnel> xTunnel( xPropSet, UNO_QUERY );
653  SwXShape *pSwShape = xTunnel.is() ?
654  reinterpret_cast< SwXShape *>( sal::static_int_cast< sal_IntPtr >(
655  xTunnel->getSomething(SwXShape::getUnoTunnelId()) ))
656  : nullptr;
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() );
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 void 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;
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 );
810  sSearch += "-" +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 }
824 
825 static void lcl_html_getEvents( const OUString& rOption, const OUString& 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( rOption.copy( strlen( OOO_STRING_SVTOOLS_HTML_O_sdevent ) ) );
832  aEvent += "-" + rValue;
833  rUnoMacroTable.push_back(aEvent);
834  }
835  else if( rOption.startsWithIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_sdaddparam ) )
836  {
837  OUString aParam( rOption.copy( strlen( OOO_STRING_SVTOOLS_HTML_O_sdaddparam ) ) );
838  aParam += "-" + 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.SetTextFirstLineOfst( 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  {
1106  nVertOri = text::VertOrientation::TOP;
1107  break;
1108  case text::VertOrientation::CENTER:
1109  nVertOri = text::VertOrientation::CENTER;
1110  break;
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  }
1196 
1197  if( bSetFCompPropSet )
1198  {
1199  m_pFormImpl->SetFCompPropSet( rFCompPropSet );
1200  }
1201 
1202  return xShape;
1203 }
1204 
1205 void SwHTMLParser::NewForm( bool bAppend )
1206 {
1207  // Does a form already exist?
1208  if( m_pFormImpl && m_pFormImpl->GetFormComps().is() )
1209  return;
1210 
1211  if( bAppend )
1212  {
1213  if( m_pPam->GetPoint()->nContent.GetIndex() )
1215  else
1216  AddParSpace();
1217  }
1218 
1219  if( !m_pFormImpl )
1220  m_pFormImpl = new SwHTMLForm_Impl( m_xDoc->GetDocShell() );
1221 
1222  OUString aAction( m_sBaseURL );
1223  OUString sName, sTarget;
1224  FormSubmitEncoding nEncType = FormSubmitEncoding_URL;
1225  FormSubmitMethod nMethod = FormSubmitMethod_GET;
1226  SvxMacroTableDtor aMacroTable;
1227  std::vector<OUString> aUnoMacroTable;
1228  std::vector<OUString> aUnoMacroParamTable;
1229  SvKeyValueIterator *pHeaderAttrs = m_pFormImpl->GetHeaderAttrs();
1230  ScriptType eDfltScriptType = GetScriptType( pHeaderAttrs );
1231  const OUString& rDfltScriptType = GetScriptTypeString( pHeaderAttrs );
1232 
1233  const HTMLOptions& rHTMLOptions = GetOptions();
1234  for (size_t i = rHTMLOptions.size(); i; )
1235  {
1236  const HTMLOption& rOption = rHTMLOptions[--i];
1237  ScriptType eScriptType2 = eDfltScriptType;
1238  SvMacroItemId nEvent = SvMacroItemId::NONE;
1239  bool bSetEvent = false;
1240 
1241  switch( rOption.GetToken() )
1242  {
1243  case HtmlOptionId::ACTION:
1244  aAction = rOption.GetString();
1245  break;
1246  case HtmlOptionId::METHOD:
1247  nMethod = rOption.GetEnum( aHTMLFormMethodTable, nMethod );
1248  break;
1249  case HtmlOptionId::ENCTYPE:
1250  nEncType = rOption.GetEnum( aHTMLFormEncTypeTable, nEncType );
1251  break;
1252  case HtmlOptionId::TARGET:
1253  sTarget = rOption.GetString();
1254  break;
1255  case HtmlOptionId::NAME:
1256  sName = rOption.GetString();
1257  break;
1258 
1259  case HtmlOptionId::SDONSUBMIT:
1260  eScriptType2 = STARBASIC;
1261  [[fallthrough]];
1262  case HtmlOptionId::ONSUBMIT:
1263  nEvent = SvMacroItemId::HtmlOnSubmitForm;
1264  bSetEvent = true;
1265  break;
1266 
1267  case HtmlOptionId::SDONRESET:
1268  eScriptType2 = STARBASIC;
1269  [[fallthrough]];
1270  case HtmlOptionId::ONRESET:
1271  nEvent = SvMacroItemId::HtmlOnResetForm;
1272  bSetEvent = true;
1273  break;
1274 
1275  default:
1277  rOption.GetString(),
1278  aUnoMacroTable, aUnoMacroParamTable );
1279  break;
1280  }
1281 
1282  if( bSetEvent )
1283  {
1284  OUString sEvent( rOption.GetString() );
1285  if( !sEvent.isEmpty() )
1286  {
1287  sEvent = convertLineEnd(sEvent, GetSystemLineEnd());
1288  OUString aScriptType2;
1289  if( EXTENDED_STYPE==eScriptType2 )
1290  aScriptType2 = rDfltScriptType;
1291  aMacroTable.Insert( nEvent, SvxMacro( sEvent, aScriptType2, eScriptType2 ) );
1292  }
1293  }
1294  }
1295 
1296  const uno::Reference< XMultiServiceFactory > & rSrvcMgr =
1298  if( !rSrvcMgr.is() )
1299  return;
1300 
1301  uno::Reference< XInterface > xInt;
1302  try
1303  {
1304  xInt = rSrvcMgr->createInstance("com.sun.star.form.component.Form");
1305  }
1306  catch (const css::lang::ServiceNotRegisteredException&)
1307  {
1308  }
1309  if( !xInt.is() )
1310  return;
1311 
1312  uno::Reference< XForm > xForm( xInt, UNO_QUERY );
1313  OSL_ENSURE( xForm.is(), "no Form?" );
1314 
1315  uno::Reference< container::XIndexContainer > xFormComps( xForm, UNO_QUERY );
1316  m_pFormImpl->SetFormComps( xFormComps );
1317 
1318  uno::Reference< beans::XPropertySet > xFormPropSet( xForm, UNO_QUERY );
1319 
1320  Any aTmp;
1321  aTmp <<= sName;
1322  xFormPropSet->setPropertyValue("Name", aTmp );
1323 
1324  if( !aAction.isEmpty() )
1325  {
1327  }
1328  else
1329  {
1330  // use directory at empty URL
1331  INetURLObject aURLObj( m_aPathToFile );
1332  aAction = aURLObj.GetPartBeforeLastName();
1333  }
1334  aTmp <<= aAction;
1335  xFormPropSet->setPropertyValue("TargetURL",
1336  aTmp );
1337 
1338  aTmp <<= nMethod;
1339  xFormPropSet->setPropertyValue("SubmitMethod",
1340  aTmp );
1341 
1342  aTmp <<= nEncType;
1343  xFormPropSet->setPropertyValue("SubmitEncoding", aTmp );
1344 
1345  if( !sTarget.isEmpty() )
1346  {
1347  aTmp <<= sTarget;
1348  xFormPropSet->setPropertyValue( "TargetFrame", aTmp );
1349  }
1350 
1351  const uno::Reference< container::XIndexContainer > & rForms =
1352  m_pFormImpl->GetForms();
1353  Any aAny( &xForm, cppu::UnoType<XForm>::get());
1354  rForms->insertByIndex( rForms->getCount(), aAny );
1355  if( !aMacroTable.empty() )
1357  rForms->getCount() - 1,
1358  aMacroTable, aUnoMacroTable, aUnoMacroParamTable,
1359  rDfltScriptType );
1360 }
1361 
1362 void SwHTMLParser::EndForm( bool bAppend )
1363 {
1364  if( m_pFormImpl && m_pFormImpl->GetFormComps().is() )
1365  {
1366  if( bAppend )
1367  {
1368  if( m_pPam->GetPoint()->nContent.GetIndex() )
1370  else
1371  AddParSpace();
1372  }
1373 
1375  }
1376 }
1377 
1379 {
1380  assert(m_vPendingStack.empty());
1381 
1382  if( !m_pFormImpl || !m_pFormImpl->GetFormComps().is() )
1383  return;
1384 
1385  OUString sImgSrc, aId, aClass, aStyle, sName;
1386  OUString sText;
1387  SvxMacroTableDtor aMacroTable;
1388  std::vector<OUString> aUnoMacroTable;
1389  std::vector<OUString> aUnoMacroParamTable;
1390  sal_uInt16 nSize = 0;
1391  sal_Int16 nMaxLen = 0;
1392  sal_Int16 nChecked = TRISTATE_FALSE;
1393  sal_Int32 nTabIndex = TABINDEX_MAX + 1;
1394  HTMLInputType eType = HTMLInputType::Text;
1395  bool bDisabled = false, bValue = false;
1396  bool bSetGrfWidth = false, bSetGrfHeight = false;
1397  bool bHidden = false;
1398  long nWidth=0, nHeight=0;
1399  sal_Int16 eVertOri = text::VertOrientation::TOP;
1400  sal_Int16 eHoriOri = text::HoriOrientation::NONE;
1401  SvKeyValueIterator *pHeaderAttrs = m_pFormImpl->GetHeaderAttrs();
1402  ScriptType eDfltScriptType = GetScriptType( pHeaderAttrs );
1403  const OUString& rDfltScriptType = GetScriptTypeString( pHeaderAttrs );
1404 
1405  HtmlOptionId nKeepCRLFToken = HtmlOptionId::VALUE;
1406  const HTMLOptions& rHTMLOptions = GetOptions( &nKeepCRLFToken );
1407  for (size_t i = rHTMLOptions.size(); i; )
1408  {
1409  const HTMLOption& rOption = rHTMLOptions[--i];
1410  ScriptType eScriptType2 = eDfltScriptType;
1411  SvMacroItemId nEvent = SvMacroItemId::NONE;
1412  bool bSetEvent = false;
1413 
1414  switch( rOption.GetToken() )
1415  {
1416  case HtmlOptionId::ID:
1417  aId = rOption.GetString();
1418  break;
1419  case HtmlOptionId::STYLE:
1420  aStyle = rOption.GetString();
1421  break;
1422  case HtmlOptionId::CLASS:
1423  aClass = rOption.GetString();
1424  break;
1425  case HtmlOptionId::TYPE:
1426  eType = rOption.GetInputType();
1427  break;
1428  case HtmlOptionId::NAME:
1429  sName = rOption.GetString();
1430  break;
1431  case HtmlOptionId::VALUE:
1432  sText = rOption.GetString();
1433  bValue = true;
1434  break;
1435  case HtmlOptionId::CHECKED:
1436  nChecked = TRISTATE_TRUE;
1437  break;
1438  case HtmlOptionId::DISABLED:
1439  bDisabled = true;
1440  break;
1441  case HtmlOptionId::MAXLENGTH:
1442  nMaxLen = static_cast<sal_Int16>(rOption.GetNumber());
1443  break;
1444  case HtmlOptionId::SIZE:
1445  nSize = static_cast<sal_uInt16>(rOption.GetNumber());
1446  break;
1447  case HtmlOptionId::SRC:
1448  sImgSrc = rOption.GetString();
1449  break;
1450  case HtmlOptionId::WIDTH:
1451  // only save pixel values at first!
1452  nWidth = rOption.GetNumber();
1453  break;
1454  case HtmlOptionId::HEIGHT:
1455  // only save pixel values at first!
1456  nHeight = rOption.GetNumber();
1457  break;
1458  case HtmlOptionId::ALIGN:
1459  eVertOri =
1460  rOption.GetEnum( aHTMLImgVAlignTable, eVertOri );
1461  eHoriOri =
1462  rOption.GetEnum( aHTMLImgHAlignTable, eHoriOri );
1463  break;
1464  case HtmlOptionId::TABINDEX:
1465  // only save pixel values at first!
1466  nTabIndex = rOption.GetNumber();
1467  break;
1468 
1469  case HtmlOptionId::SDONFOCUS:
1470  eScriptType2 = STARBASIC;
1471  [[fallthrough]];
1472  case HtmlOptionId::ONFOCUS:
1473  nEvent = SvMacroItemId::HtmlOnGetFocus;
1474  bSetEvent = true;
1475  break;
1476 
1477  case HtmlOptionId::SDONBLUR: // actually only EDIT
1478  eScriptType2 = STARBASIC;
1479  [[fallthrough]];
1480  case HtmlOptionId::ONBLUR:
1481  nEvent = SvMacroItemId::HtmlOnLoseFocus;
1482  bSetEvent = true;
1483  break;
1484 
1485  case HtmlOptionId::SDONCLICK:
1486  eScriptType2 = STARBASIC;
1487  [[fallthrough]];
1488  case HtmlOptionId::ONCLICK:
1489  nEvent = SvMacroItemId::HtmlOnClick;
1490  bSetEvent = true;
1491  break;
1492 
1493  case HtmlOptionId::SDONCHANGE: // actually only EDIT
1494  eScriptType2 = STARBASIC;
1495  [[fallthrough]];
1496  case HtmlOptionId::ONCHANGE:
1497  nEvent = SvMacroItemId::HtmlOnChange;
1498  bSetEvent = true;
1499  break;
1500 
1501  case HtmlOptionId::SDONSELECT: // actually only EDIT
1502  eScriptType2 = STARBASIC;
1503  [[fallthrough]];
1504  case HtmlOptionId::ONSELECT:
1505  nEvent = SvMacroItemId::HtmlOnSelect;
1506  bSetEvent = true;
1507  break;
1508 
1509  default:
1511  rOption.GetString(),
1512  aUnoMacroTable, aUnoMacroParamTable );
1513  break;
1514  }
1515 
1516  if( bSetEvent )
1517  {
1518  OUString sEvent( rOption.GetString() );
1519  if( !sEvent.isEmpty() )
1520  {
1521  sEvent = convertLineEnd(sEvent, GetSystemLineEnd());
1522  OUString aScriptType2;
1523  if( EXTENDED_STYPE==eScriptType2 )
1524  aScriptType2 = rDfltScriptType;
1525  aMacroTable.Insert( nEvent, SvxMacro( sEvent, aScriptType2, eScriptType2 ) );
1526  }
1527  }
1528  }
1529 
1530  if( HTMLInputType::Image==eType )
1531  {
1532  // Image controls without image URL are ignored (same as MS)
1533  if( sImgSrc.isEmpty() )
1534  return;
1535  }
1536  else
1537  {
1538  // evaluation of ALIGN for all controls is not a good idea as long as
1539  // paragraph bound controls do not influence the height of the cells of a table
1540  eVertOri = text::VertOrientation::TOP;
1541  eHoriOri = text::HoriOrientation::NONE;
1542  }
1543 
1544  // Default is HTMLInputType::Text
1545  const sal_Char *pType = "TextField";
1546  bool bKeepCRLFInValue = false;
1547  switch( eType )
1548  {
1549  case HTMLInputType::Checkbox:
1550  pType = "CheckBox";
1551  bKeepCRLFInValue = true;
1552  break;
1553 
1554  case HTMLInputType::Radio:
1555  pType = "RadioButton";
1556  bKeepCRLFInValue = true;
1557  break;
1558 
1559  case HTMLInputType::Password:
1560  bKeepCRLFInValue = true;
1561  break;
1562 
1563  case HTMLInputType::Button:
1564  bKeepCRLFInValue = true;
1565  [[fallthrough]];
1566  case HTMLInputType::Submit:
1567  case HTMLInputType::Reset:
1568  pType = "CommandButton";
1569  break;
1570 
1571  case HTMLInputType::Image:
1572  pType = "ImageButton";
1573  break;
1574 
1575  case HTMLInputType::File:
1576  pType = "FileControl";
1577  break;
1578 
1579  case HTMLInputType::Hidden:
1580  pType = "HiddenControl";
1581  bKeepCRLFInValue = true;
1582  break;
1583  default:
1584  ;
1585  }
1586 
1587  // For some controls CR/LF has to be deleted from VALUE
1588  if( !bKeepCRLFInValue )
1589  {
1590  sText = sText.replaceAll("\r", "").replaceAll("\n", "");
1591  }
1592 
1593  const uno::Reference< XMultiServiceFactory > & rServiceFactory =
1595  if( !rServiceFactory.is() )
1596  return;
1597 
1598  OUString sServiceName("com.sun.star.form.component.");
1599  sServiceName += OUString::createFromAscii(pType);
1600  uno::Reference< XInterface > xInt =
1601  rServiceFactory->createInstance( sServiceName );
1602  if( !xInt.is() )
1603  return;
1604 
1605  uno::Reference< XFormComponent > xFComp( xInt, UNO_QUERY );
1606  if( !xFComp.is() )
1607  return;
1608 
1609  uno::Reference< beans::XPropertySet > xPropSet( xFComp, UNO_QUERY );
1610 
1611  Any aTmp;
1612  aTmp <<= sName;
1613  xPropSet->setPropertyValue("Name", aTmp );
1614 
1615  if( HTMLInputType::Hidden != eType )
1616  {
1617  if( nTabIndex >= TABINDEX_MIN && nTabIndex <= TABINDEX_MAX )
1618  {
1619  aTmp <<= static_cast<sal_Int16>(nTabIndex) ;
1620  xPropSet->setPropertyValue("TabIndex", aTmp );
1621  }
1622 
1623  if( bDisabled )
1624  {
1625  xPropSet->setPropertyValue("Enabled", makeAny(false) );
1626  }
1627  }
1628 
1629  aTmp <<= sText;
1630 
1631  Size aSz( 0, 0 ); // defaults
1632  Size aTextSz( 0, 0 ); // Text size
1633  bool bMinWidth = false, bMinHeight = false;
1634  bool bUseSize = false;
1635  switch( eType )
1636  {
1637  case HTMLInputType::Checkbox:
1638  case HTMLInputType::Radio:
1639  {
1640  if( !bValue )
1641  aTmp <<= OUString( OOO_STRING_SVTOOLS_HTML_on );
1642  xPropSet->setPropertyValue("RefValue",
1643  aTmp );
1644  aTmp <<= OUString();
1645  xPropSet->setPropertyValue("Label",
1646  aTmp );
1647  // RadioButton: The DefaultChecked property should only be set
1648  // if the control has been created and activateTabOrder has been called
1649  // because otherwise it would still belong to the previous group.
1650  if( HTMLInputType::Checkbox == eType )
1651  {
1652  aTmp <<= nChecked ;
1653  xPropSet->setPropertyValue("DefaultState", aTmp );
1654  }
1655 
1656  const SvxMacro* pMacro = aMacroTable.Get( SvMacroItemId::HtmlOnClick );
1657  if( pMacro )
1658  {
1659  aMacroTable.Insert( SvMacroItemId::HtmlOnClickItem, *pMacro );
1660  aMacroTable.Erase( SvMacroItemId::HtmlOnClick );
1661  }
1662  // evaluating SIZE shouldn't be necessary here?
1663  bMinWidth = bMinHeight = true;
1664  }
1665  break;
1666 
1667  case HTMLInputType::Image:
1668  {
1669  // SIZE = WIDTH
1670  aSz.setWidth( nSize ? nSize : nWidth );
1671  aSz.setWidth( nWidth );
1672  aSz.setHeight( nHeight );
1673  if( (aSz.Width() || aSz.Height()) && Application::GetDefaultDevice() )
1674  {
1676  ->PixelToLogic( aSz, MapMode( MapUnit::Map100thMM ) );
1677  }
1678  aTmp <<= FormButtonType_SUBMIT;
1679  xPropSet->setPropertyValue("ButtonType", aTmp );
1680 
1681  aTmp <<= sal_Int16(0) ;
1682  xPropSet->setPropertyValue("Border",
1683  aTmp );
1684  }
1685  break;
1686 
1687  case HTMLInputType::Button:
1688  case HTMLInputType::Submit:
1689  case HTMLInputType::Reset:
1690  {
1691  FormButtonType eButtonType;
1692  switch( eType )
1693  {
1694  case HTMLInputType::Button:
1695  eButtonType = FormButtonType_PUSH;
1696  break;
1697  case HTMLInputType::Submit:
1698  eButtonType = FormButtonType_SUBMIT;
1699  if (sText.isEmpty())
1701  break;
1702  case HTMLInputType::Reset:
1703  eButtonType = FormButtonType_RESET;
1704  if (sText.isEmpty())
1706  break;
1707  default:
1708  ;
1709  }
1710  aTmp <<= sText;
1711  xPropSet->setPropertyValue("Label",
1712  aTmp );
1713 
1714  aTmp <<= eButtonType;
1715  xPropSet->setPropertyValue("ButtonType", aTmp );
1716 
1717  bMinWidth = bMinHeight = true;
1718  bUseSize = true;
1719  }
1720  break;
1721 
1722  case HTMLInputType::Password:
1723  case HTMLInputType::Text:
1724  case HTMLInputType::File:
1725  if( HTMLInputType::File != eType )
1726  {
1727  // The VALUE of file control will be ignored for security reasons
1728  xPropSet->setPropertyValue("DefaultText", aTmp );
1729  if( nMaxLen != 0 )
1730  {
1731  aTmp <<= nMaxLen ;
1732  xPropSet->setPropertyValue("MaxTextLen", aTmp );
1733  }
1734  }
1735 
1736  if( HTMLInputType::Password == eType )
1737  {
1738  aTmp <<= sal_Int16('*') ;
1739  xPropSet->setPropertyValue("EchoChar", aTmp );
1740  }
1741 
1742  lcl_html_setFixedFontProperty( xPropSet );
1743 
1744  if( !nSize )
1745  nSize = 20;
1746  aTextSz.setWidth( nSize );
1747  bMinHeight = true;
1748  break;
1749 
1750  case HTMLInputType::Hidden:
1751  xPropSet->setPropertyValue("HiddenValue", aTmp );
1752  bHidden = true;
1753  break;
1754  default:
1755  ;
1756  }
1757 
1758  if( bUseSize && nSize>0 )
1759  {
1761  {
1762  Size aNewSz( nSize, 0 );
1764  ->PixelToLogic( aNewSz, MapMode( MapUnit::Map100thMM ) );
1765  aSz.setWidth( aNewSz.Width() );
1766  OSL_ENSURE( !aTextSz.Width(), "text width is present" );
1767  bMinWidth = false;
1768  }
1769  }
1770 
1771  SfxItemSet aCSS1ItemSet( m_xDoc->GetAttrPool(), m_pCSS1Parser->GetWhichMap() );
1772  SvxCSS1PropertyInfo aCSS1PropInfo;
1773  if( HasStyleOptions( aStyle, aId, aClass ) )
1774  {
1775  ParseStyleOptions( aStyle, aId, aClass, aCSS1ItemSet, aCSS1PropInfo );
1776  if( !aId.isEmpty() )
1777  InsertBookmark( aId );
1778  }
1779 
1780  if( SVX_CSS1_LTYPE_TWIP== aCSS1PropInfo.m_eWidthType )
1781  {
1782  aSz.setWidth( convertTwipToMm100( aCSS1PropInfo.m_nWidth ) );
1783  aTextSz.setWidth( 0 );
1784  bMinWidth = false;
1785  }
1786  if( SVX_CSS1_LTYPE_TWIP== aCSS1PropInfo.m_eHeightType )
1787  {
1788  aSz.setHeight( convertTwipToMm100( aCSS1PropInfo.m_nHeight ) );
1789  aTextSz.setHeight( 0 );
1790  bMinHeight = false;
1791  }
1792 
1793  // Set sensible default values if the image button has no valid size
1794  if( HTMLInputType::Image== eType )
1795  {
1796  if( !aSz.Width() )
1797  {
1799  bSetGrfWidth = true;
1800  if (m_xTable)
1802  }
1803  if( !aSz.Height() )
1804  {
1806  bSetGrfHeight = true;
1807  }
1808  }
1809  if( aSz.Width() < MINFLY )
1810  aSz.setWidth( MINFLY );
1811  if( aSz.Height() < MINFLY )
1812  aSz.setHeight( MINFLY );
1813 
1814  uno::Reference< drawing::XShape > xShape = InsertControl(
1815  xFComp, xPropSet, aSz,
1816  eVertOri, eHoriOri,
1817  aCSS1ItemSet, aCSS1PropInfo,
1818  aMacroTable, aUnoMacroTable,
1819  aUnoMacroParamTable, false,
1820  bHidden );
1821  if( aTextSz.Width() || aTextSz.Height() || bMinWidth || bMinHeight )
1822  {
1823  OSL_ENSURE( !(bSetGrfWidth || bSetGrfHeight), "Adjust graphic size???" );
1824  SetControlSize( xShape, aTextSz, bMinWidth, bMinHeight );
1825  }
1826 
1827  if( HTMLInputType::Radio == eType )
1828  {
1829  aTmp <<= nChecked ;
1830  xPropSet->setPropertyValue("DefaultState", aTmp );
1831  }
1832 
1833  if( HTMLInputType::Image == eType )
1834  {
1835  // Set the URL after inserting the graphic because the Download can
1836  // only register with XModel after the control has been inserted.
1837  aTmp <<= URIHelper::SmartRel2Abs(INetURLObject(m_sBaseURL), sImgSrc, Link<OUString *, bool>(), false);
1838  xPropSet->setPropertyValue("ImageURL",
1839  aTmp );
1840  }
1841 
1842  if( bSetGrfWidth || bSetGrfHeight )
1843  {
1845  new SwHTMLImageWatcher( xShape, bSetGrfWidth, bSetGrfHeight );
1846  pWatcher->start();
1847  }
1848 }
1849 
1851 {
1852  assert(m_vPendingStack.empty());
1853 
1854  OSL_ENSURE( !m_bTextArea, "TextArea in TextArea?" );
1855  OSL_ENSURE( !m_pFormImpl || !m_pFormImpl->GetFCompPropSet().is(),
1856  "TextArea in Control?" );
1857 
1858  if( !m_pFormImpl || !m_pFormImpl->GetFormComps().is() )
1859  {
1860  // Close special treatment for TextArea in the parser
1861  FinishTextArea();
1862  return;
1863  }
1864 
1865  OUString aId, aClass, aStyle;
1866  OUString sName;
1867  sal_Int32 nTabIndex = TABINDEX_MAX + 1;
1868  SvxMacroTableDtor aMacroTable;
1869  std::vector<OUString> aUnoMacroTable;
1870  std::vector<OUString> aUnoMacroParamTable;
1871  sal_uInt16 nRows = 0, nCols = 0;
1872  HTMLWordWrapMode nWrap = HTML_WM_OFF;
1873  bool bDisabled = false;
1874  SvKeyValueIterator *pHeaderAttrs = m_pFormImpl->GetHeaderAttrs();
1875  ScriptType eDfltScriptType = GetScriptType( pHeaderAttrs );
1876  const OUString& rDfltScriptType = GetScriptTypeString( pHeaderAttrs );
1877 
1878  const HTMLOptions& rHTMLOptions = GetOptions();
1879  for (size_t i = rHTMLOptions.size(); i; )
1880  {
1881  const HTMLOption& rOption = rHTMLOptions[--i];
1882  ScriptType eScriptType2 = eDfltScriptType;
1883  SvMacroItemId nEvent = SvMacroItemId::NONE;
1884  bool bSetEvent = false;
1885 
1886  switch( rOption.GetToken() )
1887  {
1888  case HtmlOptionId::ID:
1889  aId = rOption.GetString();
1890  break;
1891  case HtmlOptionId::STYLE:
1892  aStyle = rOption.GetString();
1893  break;
1894  case HtmlOptionId::CLASS:
1895  aClass = rOption.GetString();
1896  break;
1897  case HtmlOptionId::NAME:
1898  sName = rOption.GetString();
1899  break;
1900  case HtmlOptionId::DISABLED:
1901  bDisabled = true;
1902  break;
1903  case HtmlOptionId::ROWS:
1904  nRows = static_cast<sal_uInt16>(rOption.GetNumber());
1905  break;
1906  case HtmlOptionId::COLS:
1907  nCols = static_cast<sal_uInt16>(rOption.GetNumber());
1908  break;
1909  case HtmlOptionId::WRAP:
1910  nWrap = rOption.GetEnum( aHTMLTextAreaWrapTable, nWrap );
1911  break;
1912 
1913  case HtmlOptionId::TABINDEX:
1914  nTabIndex = rOption.GetSNumber();
1915  break;
1916 
1917  case HtmlOptionId::SDONFOCUS:
1918  eScriptType2 = STARBASIC;
1919  [[fallthrough]];
1920  case HtmlOptionId::ONFOCUS:
1921  nEvent = SvMacroItemId::HtmlOnGetFocus;
1922  bSetEvent = true;
1923  break;
1924 
1925  case HtmlOptionId::SDONBLUR:
1926  eScriptType2 = STARBASIC;
1927  [[fallthrough]];
1928  case HtmlOptionId::ONBLUR:
1929  nEvent = SvMacroItemId::HtmlOnLoseFocus;
1930  bSetEvent = true;
1931  break;
1932 
1933  case HtmlOptionId::SDONCLICK:
1934  eScriptType2 = STARBASIC;
1935  [[fallthrough]];
1936  case HtmlOptionId::ONCLICK:
1937  nEvent = SvMacroItemId::HtmlOnClick;
1938  bSetEvent = true;
1939  break;
1940 
1941  case HtmlOptionId::SDONCHANGE:
1942  eScriptType2 = STARBASIC;
1943  [[fallthrough]];
1944  case HtmlOptionId::ONCHANGE:
1945  nEvent = SvMacroItemId::HtmlOnChange;
1946  bSetEvent = true;
1947  break;
1948 
1949  case HtmlOptionId::SDONSELECT:
1950  eScriptType2 = STARBASIC;
1951  [[fallthrough]];
1952  case HtmlOptionId::ONSELECT:
1953  nEvent = SvMacroItemId::HtmlOnSelect;
1954  bSetEvent = true;
1955  break;
1956 
1957  default:
1959  rOption.GetString(),
1960  aUnoMacroTable, aUnoMacroParamTable );
1961  break;
1962  }
1963 
1964  if( bSetEvent )
1965  {
1966  OUString sEvent( rOption.GetString() );
1967  if( !sEvent.isEmpty() )
1968  {
1969  sEvent = convertLineEnd(sEvent, GetSystemLineEnd());
1970  if( EXTENDED_STYPE==eScriptType2 )
1971  m_aScriptType = rDfltScriptType;
1972  aMacroTable.Insert( nEvent, SvxMacro( sEvent, m_aScriptType, eScriptType2 ) );
1973  }
1974  }
1975  }
1976 
1977  const uno::Reference< lang::XMultiServiceFactory > & rSrvcMgr =
1979  if( !rSrvcMgr.is() )
1980  {
1981  FinishTextArea();
1982  return;
1983  }
1984  uno::Reference< uno::XInterface > xInt = rSrvcMgr->createInstance(
1985  "com.sun.star.form.component.TextField" );
1986  if( !xInt.is() )
1987  {
1988  FinishTextArea();
1989  return;
1990  }
1991 
1992  uno::Reference< XFormComponent > xFComp( xInt, UNO_QUERY );
1993  OSL_ENSURE( xFComp.is(), "no FormComponent?" );
1994 
1995  uno::Reference< beans::XPropertySet > xPropSet( xFComp, UNO_QUERY );
1996 
1997  Any aTmp;
1998  aTmp <<= sName;
1999  xPropSet->setPropertyValue("Name", aTmp );
2000 
2001  aTmp <<= true;
2002  xPropSet->setPropertyValue("MultiLine", aTmp );
2003  xPropSet->setPropertyValue("VScroll", aTmp );
2004  if( HTML_WM_OFF == nWrap )
2005  xPropSet->setPropertyValue("HScroll", aTmp );
2006  if( HTML_WM_HARD == nWrap )
2007  xPropSet->setPropertyValue("HardLineBreaks", aTmp );
2008 
2009  if( nTabIndex >= TABINDEX_MIN && nTabIndex <= TABINDEX_MAX )
2010  {
2011  aTmp <<= static_cast<sal_Int16>(nTabIndex) ;
2012  xPropSet->setPropertyValue("TabIndex", aTmp );
2013  }
2014 
2015  lcl_html_setFixedFontProperty( xPropSet );
2016 
2017  if( bDisabled )
2018  {
2019  xPropSet->setPropertyValue("Enabled", makeAny(false) );
2020  }
2021 
2022  OSL_ENSURE( m_pFormImpl->GetText().isEmpty(), "Text is not empty!" );
2023 
2024  if( !nCols )
2025  nCols = 20;
2026  if( !nRows )
2027  nRows = 1;
2028 
2029  Size aTextSz( nCols, nRows );
2030 
2031  SfxItemSet aCSS1ItemSet( m_xDoc->GetAttrPool(), m_pCSS1Parser->GetWhichMap() );
2032  SvxCSS1PropertyInfo aCSS1PropInfo;
2033  if( HasStyleOptions( aStyle, aId, aClass ) )
2034  {
2035  ParseStyleOptions( aStyle, aId, aClass, aCSS1ItemSet, aCSS1PropInfo );
2036  if( !aId.isEmpty() )
2037  InsertBookmark( aId );
2038  }
2039 
2040  Size aSz( MINFLY, MINFLY );
2041  if( SVX_CSS1_LTYPE_TWIP== aCSS1PropInfo.m_eWidthType )
2042  {
2043  aSz.setWidth( convertTwipToMm100( aCSS1PropInfo.m_nWidth ) );
2044  aTextSz.setWidth( 0 );
2045  }
2046  if( SVX_CSS1_LTYPE_TWIP== aCSS1PropInfo.m_eHeightType )
2047  {
2048  aSz.setHeight( convertTwipToMm100( aCSS1PropInfo.m_nHeight ) );
2049  aTextSz.setHeight( 0 );
2050  }
2051  if( aSz.Width() < MINFLY )
2052  aSz.setWidth( MINFLY );
2053  if( aSz.Height() < MINFLY )
2054  aSz.setHeight( MINFLY );
2055 
2056  uno::Reference< drawing::XShape > xShape = InsertControl( xFComp, xPropSet, aSz,
2058  aCSS1ItemSet, aCSS1PropInfo,
2059  aMacroTable, aUnoMacroTable,
2060  aUnoMacroParamTable );
2061  if( aTextSz.Width() || aTextSz.Height() )
2062  SetControlSize( xShape, aTextSz, false, false );
2063 
2064  // create new context
2065  std::unique_ptr<HTMLAttrContext> xCntxt(new HTMLAttrContext(HtmlTokenId::TEXTAREA_ON));
2066 
2067  // temporarily disable PRE/Listing/XMP
2068  SplitPREListingXMP(xCntxt.get());
2069  PushContext(xCntxt);
2070 
2071  m_bTextArea = true;
2072  m_bTAIgnoreNewPara = true;
2073 }
2074 
2076 {
2077  OSL_ENSURE( m_bTextArea, "no TextArea or wrong type" );
2078  OSL_ENSURE( m_pFormImpl && m_pFormImpl->GetFCompPropSet().is(),
2079  "TextArea missing" );
2080 
2081  const uno::Reference< beans::XPropertySet > & rPropSet =
2083 
2084  Any aTmp;
2085  aTmp <<= m_pFormImpl->GetText();
2086  rPropSet->setPropertyValue("DefaultText", aTmp );
2088 
2090 
2091  // get context
2092  std::unique_ptr<HTMLAttrContext> xCntxt(PopContext(HtmlTokenId::TEXTAREA_ON));
2093  if (xCntxt)
2094  {
2095  // end attributes
2096  EndContext(xCntxt.get());
2097  }
2098 
2099  m_bTextArea = false;
2100 }
2101 
2103 {
2104  OSL_ENSURE( m_bTextArea, "no TextArea or wrong type" );
2105  OSL_ENSURE( m_pFormImpl && m_pFormImpl->GetFCompPropSet().is(),
2106  "TextArea missing" );
2107 
2108  OUString& rText = m_pFormImpl->GetText();
2109  switch( nToken)
2110  {
2111  case HtmlTokenId::TEXTTOKEN:
2112  rText += aToken;
2113  break;
2114  case HtmlTokenId::NEWPARA:
2115  if( !m_bTAIgnoreNewPara )
2116  rText += "\n";
2117  break;
2118  default:
2119  rText += "<";
2120  rText += sSaveToken;
2121  if( !aToken.isEmpty() )
2122  {
2123  rText += " ";
2124  rText += aToken;
2125  }
2126  rText += ">";
2127  }
2128 
2129  m_bTAIgnoreNewPara = false;
2130 }
2131 
2133 {
2134  assert(m_vPendingStack.empty());
2135 
2136  OSL_ENSURE( !m_bSelect, "Select in Select?" );
2137  OSL_ENSURE( !m_pFormImpl || !m_pFormImpl->GetFCompPropSet().is(),
2138  "Select in Control?" );
2139 
2140  if( !m_pFormImpl || !m_pFormImpl->GetFormComps().is() )
2141  return;
2142 
2143  OUString aId, aClass, aStyle;
2144  OUString sName;
2145  sal_Int32 nTabIndex = TABINDEX_MAX + 1;
2146  SvxMacroTableDtor aMacroTable;
2147  std::vector<OUString> aUnoMacroTable;
2148  std::vector<OUString> aUnoMacroParamTable;
2149  bool bMultiple = false;
2150  bool bDisabled = false;
2151  m_nSelectEntryCnt = 1;
2152  SvKeyValueIterator *pHeaderAttrs = m_pFormImpl->GetHeaderAttrs();
2153  ScriptType eDfltScriptType = GetScriptType( pHeaderAttrs );
2154  const OUString& rDfltScriptType = GetScriptTypeString( pHeaderAttrs );
2155 
2156  const HTMLOptions& rHTMLOptions = GetOptions();
2157  for (size_t i = rHTMLOptions.size(); i; )
2158  {
2159  const HTMLOption& rOption = rHTMLOptions[--i];
2160  ScriptType eScriptType2 = eDfltScriptType;
2161  SvMacroItemId nEvent = SvMacroItemId::NONE;
2162  bool bSetEvent = false;
2163 
2164  switch( rOption.GetToken() )
2165  {
2166  case HtmlOptionId::ID:
2167  aId = rOption.GetString();
2168  break;
2169  case HtmlOptionId::STYLE:
2170  aStyle = rOption.GetString();
2171  break;
2172  case HtmlOptionId::CLASS:
2173  aClass = rOption.GetString();
2174  break;
2175  case HtmlOptionId::NAME:
2176  sName = rOption.GetString();
2177  break;
2178  case HtmlOptionId::MULTIPLE:
2179  bMultiple = true;
2180  break;
2181  case HtmlOptionId::DISABLED:
2182  bDisabled = true;
2183  break;
2184  case HtmlOptionId::SIZE:
2185  m_nSelectEntryCnt = static_cast<sal_uInt16>(rOption.GetNumber());
2186  break;
2187 
2188  case HtmlOptionId::TABINDEX:
2189  nTabIndex = rOption.GetSNumber();
2190  break;
2191 
2192  case HtmlOptionId::SDONFOCUS:
2193  eScriptType2 = STARBASIC;
2194  [[fallthrough]];
2195  case HtmlOptionId::ONFOCUS:
2196  nEvent = SvMacroItemId::HtmlOnGetFocus;
2197  bSetEvent = true;
2198  break;
2199 
2200  case HtmlOptionId::SDONBLUR:
2201  eScriptType2 = STARBASIC;
2202  [[fallthrough]];
2203  case HtmlOptionId::ONBLUR:
2204  nEvent = SvMacroItemId::HtmlOnLoseFocus;
2205  bSetEvent = true;
2206  break;
2207 
2208  case HtmlOptionId::SDONCLICK:
2209  eScriptType2 = STARBASIC;
2210  [[fallthrough]];
2211  case HtmlOptionId::ONCLICK:
2212  nEvent = SvMacroItemId::HtmlOnClick;
2213  bSetEvent = true;
2214  break;
2215 
2216  case HtmlOptionId::SDONCHANGE:
2217  eScriptType2 = STARBASIC;
2218  [[fallthrough]];
2219  case HtmlOptionId::ONCHANGE:
2220  nEvent = SvMacroItemId::HtmlOnChange;
2221  bSetEvent = true;
2222  break;
2223 
2224  default:
2226  rOption.GetString(),
2227  aUnoMacroTable, aUnoMacroParamTable );
2228  break;
2229  }
2230 
2231  if( bSetEvent )
2232  {
2233  OUString sEvent( rOption.GetString() );
2234  if( !sEvent.isEmpty() )
2235  {
2236  sEvent = convertLineEnd(sEvent, GetSystemLineEnd());
2237  if( EXTENDED_STYPE==eScriptType2 )
2238  m_aScriptType = rDfltScriptType;
2239  aMacroTable.Insert( nEvent, SvxMacro( sEvent, m_aScriptType, eScriptType2 ) );
2240  }
2241  }
2242  }
2243 
2244  const uno::Reference< lang::XMultiServiceFactory > & rSrvcMgr =
2246  if( !rSrvcMgr.is() )
2247  {
2248  FinishTextArea();
2249  return;
2250  }
2251  uno::Reference< uno::XInterface > xInt = rSrvcMgr->createInstance(
2252  "com.sun.star.form.component.ListBox" );
2253  if( !xInt.is() )
2254  {
2255  FinishTextArea();
2256  return;
2257  }
2258 
2259  uno::Reference< XFormComponent > xFComp( xInt, UNO_QUERY );
2260  OSL_ENSURE(xFComp.is(), "no FormComponent?");
2261 
2262  uno::Reference< beans::XPropertySet > xPropSet( xFComp, UNO_QUERY );
2263 
2264  Any aTmp;
2265  aTmp <<= sName;
2266  xPropSet->setPropertyValue("Name", aTmp );
2267 
2268  if( nTabIndex >= TABINDEX_MIN && nTabIndex <= TABINDEX_MAX )
2269  {
2270  aTmp <<= static_cast<sal_Int16>(nTabIndex) ;
2271  xPropSet->setPropertyValue("TabIndex", aTmp );
2272  }
2273 
2274  if( bDisabled )
2275  {
2276  xPropSet->setPropertyValue("Enabled", makeAny(false) );
2277  }
2278 
2279  Size aTextSz( 0, 0 );
2280  bool bMinWidth = true, bMinHeight = true;
2281  if( !bMultiple && 1==m_nSelectEntryCnt )
2282  {
2283  xPropSet->setPropertyValue("Dropdown", makeAny(true) );
2284  }
2285  else
2286  {
2287  if( m_nSelectEntryCnt <= 1 ) // 4 lines is default
2288  m_nSelectEntryCnt = 4;
2289 
2290  if( bMultiple )
2291  {
2292  xPropSet->setPropertyValue("MultiSelection", makeAny(true) );
2293  }
2294  aTextSz.setHeight( m_nSelectEntryCnt );
2295  bMinHeight = false;
2296  }
2297 
2298  SfxItemSet aCSS1ItemSet( m_xDoc->GetAttrPool(), m_pCSS1Parser->GetWhichMap() );
2299  SvxCSS1PropertyInfo aCSS1PropInfo;
2300  if( HasStyleOptions( aStyle, aId, aClass ) )
2301  {
2302  ParseStyleOptions( aStyle, aId, aClass, aCSS1ItemSet, aCSS1PropInfo );
2303  if( !aId.isEmpty() )
2304  InsertBookmark( aId );
2305  }
2306 
2307  Size aSz( MINFLY, MINFLY );
2308  m_bFixSelectWidth = true;
2309  if( SVX_CSS1_LTYPE_TWIP== aCSS1PropInfo.m_eWidthType )
2310  {
2311  aSz.setWidth( convertTwipToMm100( aCSS1PropInfo.m_nWidth ) );
2312  m_bFixSelectWidth = false;
2313  bMinWidth = false;
2314  }
2315  if( SVX_CSS1_LTYPE_TWIP== aCSS1PropInfo.m_eHeightType )
2316  {
2317  aSz.setHeight( convertTwipToMm100( aCSS1PropInfo.m_nHeight ) );
2318  aTextSz.setHeight( 0 );
2319  bMinHeight = false;
2320  }
2321  if( aSz.Width() < MINFLY )
2322  aSz.setWidth( MINFLY );
2323  if( aSz.Height() < MINFLY )
2324  aSz.setHeight( MINFLY );
2325 
2326  uno::Reference< drawing::XShape > xShape = InsertControl( xFComp, xPropSet, aSz,
2328  aCSS1ItemSet, aCSS1PropInfo,
2329  aMacroTable, aUnoMacroTable,
2330  aUnoMacroParamTable );
2331  if( m_bFixSelectWidth )
2332  m_pFormImpl->SetShape( xShape );
2333  if( aTextSz.Height() || bMinWidth || bMinHeight )
2334  SetControlSize( xShape, aTextSz, bMinWidth, bMinHeight );
2335 
2336  // create new context
2337  std::unique_ptr<HTMLAttrContext> xCntxt(new HTMLAttrContext(HtmlTokenId::SELECT_ON));
2338 
2339  // temporarily disable PRE/Listing/XMP
2340  SplitPREListingXMP(xCntxt.get());
2341  PushContext(xCntxt);
2342 
2343  m_bSelect = true;
2344 }
2345 
2347 {
2348  assert(m_vPendingStack.empty());
2349 
2350  OSL_ENSURE( m_bSelect, "no Select" );
2351  OSL_ENSURE( m_pFormImpl && m_pFormImpl->GetFCompPropSet().is(),
2352  "no select control" );
2353 
2354  const uno::Reference< beans::XPropertySet > & rPropSet =
2356 
2357  size_t nEntryCnt = m_pFormImpl->GetStringList().size();
2358  if(!m_pFormImpl->GetStringList().empty())
2359  {
2360  Sequence<OUString> aList( static_cast<sal_Int32>(nEntryCnt) );
2361  Sequence<OUString> aValueList( static_cast<sal_Int32>(nEntryCnt) );
2362  OUString *pStrings = aList.getArray();
2363  OUString *pValues = aValueList.getArray();
2364 
2365  for(size_t i = 0; i < nEntryCnt; ++i)
2366  {
2367  OUString sText(m_pFormImpl->GetStringList()[i]);
2368  sText = comphelper::string::stripEnd(sText, ' ');
2369  pStrings[i] = sText;
2370 
2371  sText = m_pFormImpl->GetValueList()[i];
2372  pValues[i] = sText;
2373  }
2374 
2375  rPropSet->setPropertyValue("StringItemList", Any(aList) );
2376 
2377  rPropSet->setPropertyValue("ListSourceType", Any(ListSourceType_VALUELIST) );
2378 
2379  rPropSet->setPropertyValue("ListSource", Any(aValueList) );
2380 
2381  size_t nSelCnt = m_pFormImpl->GetSelectedList().size();
2382  if( !nSelCnt && 1 == m_nSelectEntryCnt && nEntryCnt )
2383  {
2384  // In a dropdown list an entry should always be selected.
2385  m_pFormImpl->GetSelectedList().insert( m_pFormImpl->GetSelectedList().begin(), 0 );
2386  nSelCnt = 1;
2387  }
2388  Sequence<sal_Int16> aSelList( static_cast<sal_Int32>(nSelCnt) );
2389  sal_Int16 *pSels = aSelList.getArray();
2390  for(size_t i = 0; i < nSelCnt; ++i)
2391  {
2392  pSels[i] = static_cast<sal_Int16>(m_pFormImpl->GetSelectedList()[i]);
2393  }
2394  rPropSet->setPropertyValue("DefaultSelection", Any(aSelList) );
2395 
2398  }
2399 
2401 
2402  if( m_bFixSelectWidth )
2403  {
2404  OSL_ENSURE( m_pFormImpl->GetShape().is(), "Shape not saved" );
2405  Size aTextSz( -1, 0 );
2406  SetControlSize( m_pFormImpl->GetShape(), aTextSz, false, false );
2407  }
2408 
2410 
2411  // get context
2412  std::unique_ptr<HTMLAttrContext> xCntxt(PopContext(HtmlTokenId::SELECT_ON));
2413  if (xCntxt)
2414  {
2415  // close attributes
2416  EndContext(xCntxt.get());
2417  }
2418 
2419  m_bSelect = false;
2420 }
2421 
2423 {
2424  OSL_ENSURE( m_bSelect, "no Select" );
2425  OSL_ENSURE( m_pFormImpl && m_pFormImpl->GetFCompPropSet().is(),
2426  "no Select-Control" );
2427 
2428  m_bLBEntrySelected = false;
2429  OUString aValue;
2430 
2431  const HTMLOptions& rHTMLOptions = GetOptions();
2432  for (size_t i = rHTMLOptions.size(); i; )
2433  {
2434  const HTMLOption& rOption = rHTMLOptions[--i];
2435  switch( rOption.GetToken() )
2436  {
2437  case HtmlOptionId::ID:
2438  // leave out for now
2439  break;
2440  case HtmlOptionId::SELECTED:
2441  m_bLBEntrySelected = true;
2442  break;
2443  case HtmlOptionId::VALUE:
2444  aValue = rOption.GetString();
2445  if( aValue.isEmpty() )
2446  aValue = "$$$empty$$$";
2447  break;
2448  default: break;
2449  }
2450  }
2451 
2452  sal_uInt16 nEntryCnt = m_pFormImpl->GetStringList().size();
2453  m_pFormImpl->GetStringList().push_back(OUString());
2454  m_pFormImpl->GetValueList().push_back(aValue);
2455  if( m_bLBEntrySelected )
2456  {
2457  m_pFormImpl->GetSelectedList().push_back( nEntryCnt );
2458  }
2459 }
2460 
2462 {
2463  OSL_ENSURE( m_bSelect, "no select" );
2464  OSL_ENSURE( m_pFormImpl && m_pFormImpl->GetFCompPropSet().is(),
2465  "no select control" );
2466 
2467  if(!m_pFormImpl->GetStringList().empty())
2468  {
2469  OUString& rText = m_pFormImpl->GetStringList().back();
2470 
2471  if( !aToken.isEmpty() && ' '==aToken[ 0 ] )
2472  {
2473  sal_Int32 nLen = rText.getLength();
2474  if( !nLen || ' '==rText[nLen-1])
2475  aToken = aToken.replaceAt( 0, 1, "" );
2476  }
2477  if( !aToken.isEmpty() )
2478  rText += aToken;
2479  }
2480 }
2481 
2482 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt16 IncGrfsThatResizeTable()
Definition: htmltab.cxx:3175
long GetLeft() const
std::vector< SwPending > m_vPendingStack
Definition: swhtml.hxx:375
bool GetValue() const
long Width() const
Starts a section of nodes in the document model.
Definition: node.hxx:303
EXTENDED_STYPE
void EndSelect()
Definition: htmlform.cxx:2346
#define RES_CHRATR_WEIGHT
Definition: hintids.hxx:83
static vcl::Font GetDefaultFont(DefaultFontType nType, LanguageType eLang, GetDefaultFontFlags nFlags, const OutputDevice *pOutDev=nullptr)
void NewTextArea()
Definition: htmlform.cxx:1850
SvxMacro & Insert(SvMacroItemId nEvent, const SvxMacro &rMacro)
bool m_bSelect
Definition: swhtml.hxx:448
SvxCSS1LengthType m_eLeftType
Definition: svxcss1.hxx:136
EnumT GetEnum(const HTMLOptionEnum< EnumT > *pOptEnums, EnumT nDflt=static_cast< EnumT >(0)) const
virtual void SAL_CALL complete(sal_Int32 Status, const uno::Reference< awt::XImageProducer > &Producer) override
Definition: htmlform.cxx:557
void SplitPREListingXMP(HTMLAttrContext *pCntxt)
Definition: htmlctxt.cxx:753
OString stripEnd(const OString &rIn, sal_Char c)
HtmlOptionId GetToken() const
SvxCSS1LengthType m_eTopType
Definition: svxcss1.hxx:136
#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:616
void EndForm(bool bAppend=true)
Definition: htmlform.cxx:1362
const OUString & GetFamilyName() const
SdrView * GetDrawView()
Definition: vnew.cxx:376
#define OOO_STRING_SVTOOLS_HTML_O_SDonsubmit
OUString m_sText
Definition: htmlform.cxx:199
#define OOO_STRING_SVTOOLS_HTML_O_onblur
sal_uInt16 GetLower() const
#define RES_CHRATR_FONTSIZE
Definition: hintids.hxx:76
OUString GetLanguage() const
SwDocShell *const m_pDocShell
Definition: htmlform.cxx:181
#define LANGUAGE_ENGLISH_US
std::vector< sal_uInt16 > & GetSelectedList()
Definition: htmlform.cxx:261
sal_uInt16 m_nSelectEntryCnt
Definition: swhtml.hxx:405
std::string GetValue
const OUString & GetStyleName() const
const uno::Reference< drawing::XShapes > & GetShapes()
Definition: htmlform.cxx:317
long Height() const
void SetShape(const uno::Reference< drawing::XShape > &r)
Definition: htmlform.cxx:244
#define OOO_STRING_SVTOOLS_HTML_O_sdaddparam
SwNodeIndex nNode
Definition: pam.hxx:37
void InsertBookmark(const OUString &rName)
Definition: htmlgrin.cxx:1346
bool const bSetHeight
Definition: htmlform.cxx:371
#define MINFLY
Definition: swtypes.hxx:65
#define MINLAY
Definition: swtypes.hxx:66
static HTMLOptionEnum< HTMLWordWrapMode > const aHTMLTextAreaWrapTable[]
Definition: htmlform.cxx:108
static HTMLOptionEnum< FormSubmitMethod > const aHTMLFormMethodTable[]
Definition: htmlform.cxx:91
const OUString & GetString() const
Definition: doc.hxx:185
HTMLInputType GetInputType() const
#define RES_CHRATR_FONT
Definition: hintids.hxx:75
const sal_Char * aEventMethodTable[]
Definition: htmlform.cxx:143
const sal_Char * aEventSDOptionTable[]
Definition: htmlform.cxx:155
SvMacroItemId
SwNode & GetNode() const
Definition: ndindex.hxx:118
std::vector< sal_uInt16 > m_aSelectedList
Definition: htmlform.cxx:202
SvKeyValueIterator * GetHeaderAttrs() const
Definition: htmlform.cxx:267
OUString m_sBaseURL
Definition: swhtml.hxx:342
const sal_uInt16 TABINDEX_MAX
Definition: htmlform.cxx:89
void NewForm(bool bAppend=true)
Definition: htmlform.cxx:1205
uno::Reference< container::XIndexContainer > m_xFormComps
Definition: htmlform.cxx:195
static HTMLOptionEnum< FormSubmitEncoding > const aHTMLFormEncTypeTable[]
Definition: htmlform.cxx:98
FontPitch GetPitch() const
TRISTATE_TRUE
uno::Reference< script::XEventAttacherManager > m_xFormEventManager
Definition: htmlform.cxx:192
#define OOO_STRING_SVTOOLS_HTML_O_SDonreset
#define OOO_STRING_SVTOOLS_HTML_WW_off
FontFamily GetFamily() const
std::vector< OUString > & GetValueList()
Definition: htmlform.cxx:255
FontFamily GetFamilyType()
Status
static OutputDevice * GetDefaultDevice()
void InsertInput()
Definition: htmlform.cxx:1378
uno::Reference< drawing::XShapes > m_xShapes
Definition: htmlform.cxx:188
constexpr::Color COL_TRANSPARENT(0xFF, 0xFF, 0xFF, 0xFF)
constexpr auto SFX_INTERFACE_NONE
bool m_bFixSelectWidth
Definition: swhtml.hxx:445
void GetDrawPage()
Definition: htmlform.cxx:283
void EndTextArea()
Definition: htmlform.cxx:2075
SwHTMLForm_Impl(SwDocShell *pDSh)
Definition: htmlform.cxx:205
#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:197
rtl_TextEncoding GetCharSet() const
std::vector< OUString > m_aStringList
Definition: htmlform.cxx:200
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:1845
char sal_Char
#define OOO_STRING_SVTOOLS_HTML_O_onchange
LineEnd GetSystemLineEnd()
std::vector< OUString > m_aValueList
Definition: htmlform.cxx:201
#define RES_UL_SPACE
Definition: hintids.hxx:197
#define OOO_STRING_SVTOOLS_HTML_METHOD_post
virtual void SAL_CALL setPixelsByLongs(sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, const uno::Sequence< sal_Int32 > &ProducerData, sal_Int32 Offset, sal_Int32 Scansize) override
Definition: htmlform.cxx:551
const SwTable & GetTable() const
Definition: node.hxx:497
static SvMacroItemId aEventTypeTable[]
Definition: htmlform.cxx:118
#define OOO_STRING_SVTOOLS_HTML_O_sdevent
SwPaM * m_pPam
Definition: swhtml.hxx:378
bool m_bRemoveHidden
Definition: swhtml.hxx:452
css::uno::Reference< css::frame::XModel > GetBaseModel() const
#define OOO_STRING_SVTOOLS_HTML_WW_soft
ImplSVEvent * m_nEventId
Definition: swhtml.hxx:394
const OUString & GetStyleName() const
#define RES_BACKGROUND
Definition: hintids.hxx:210
const sal_uInt16 TABINDEX_MIN
Definition: htmlform.cxx:88
#define RES_CHRATR_COLOR
Definition: hintids.hxx:71
static bool HasStyleOptions(const OUString &rStyle, const OUString &rId, const OUString &rClass, const OUString *pLang=nullptr, const OUString *pDir=nullptr)
Definition: swhtml.hxx:992
const uno::Reference< container::XIndexContainer > & GetForms()
Definition: htmlform.cxx:296
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
void NewSelect()
Definition: htmlform.cxx:2132
sal_uInt16 GetBrowseWidthByTable(const SwDoc &rDoc) const
Calculates available width by the table-frame or static GetBrowseWidth if no layout exists...
Definition: htmltbl.cxx:372
uno::Reference< beans::XPropertySet > m_xFCompPropertySet
Definition: htmlform.cxx:196
bool empty() const
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
Style of a layout element.
Definition: frmfmt.hxx:57
bool m_bLBEntrySelected
Definition: swhtml.hxx:431
FontPitch GetPitch()
OUString const m_aPathToFile
Definition: swhtml.hxx:341
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:81
uno::Reference< XMultiServiceFactory > m_xServiceFactory
Definition: htmlform.cxx:189
uno::Reference< script::XEventAttacherManager > m_xControlEventManager
Definition: htmlform.cxx:191
const SwPosition * GetPoint() const
Definition: pam.hxx:207
#define OOO_STRING_SVTOOLS_HTML_O_SDonchange
const SwPosition * GetContentAnchor() const
Definition: fmtanchr.hxx:67
sal_Int32 GetSNumber() const
OUString sName
int i
std::unique_ptr< SwCSS1Parser > m_pCSS1Parser
Definition: swhtml.hxx:373
TRISTATE_FALSE
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unodraw.cxx:847
const sal_Char * aEventOptionTable[]
Definition: htmlform.cxx:167
void AddParSpace()
Definition: swhtml.cxx:2442
#define OOO_STRING_SVTOOLS_HTML_O_SDonblur
void DeleteFormImpl()
Definition: htmlform.cxx:582
const sal_Char * aEventListenerTable[]
Definition: htmlform.cxx:131
void EndContext(HTMLAttrContext *pContext)
Definition: htmlctxt.cxx:369
#define OOO_STRING_SVTOOLS_HTML_WW_virtual
std::unique_ptr< HTMLAttrContext > PopContext(HtmlTokenId nToken=HtmlTokenId::NONE)
Definition: htmlcss1.cxx:2105
void Erase(SvMacroItemId nEvent)
OUString & GetText()
Definition: htmlform.cxx:246
#define RES_CHRATR_UNDERLINE
Definition: hintids.hxx:82
SvxCSS1Position m_ePosition
Definition: svxcss1.hxx:120
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:219
HTMLInputType
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:119
uno::Reference< drawing::XDrawPage > m_xDrawPage
Definition: htmlform.cxx:186
DocumentType const eType
SvxAdjust m_eFloat
Definition: svxcss1.hxx:118
virtual void SAL_CALL disposing(const EventObject &Source) override
Definition: htmlform.cxx:569
const uno::Reference< script::XEventAttacherManager > & GetFormEventManager()
Definition: htmlform.cxx:347
void SetFCompPropSet(const uno::Reference< beans::XPropertySet > &r)
Definition: htmlform.cxx:236
virtual void SAL_CALL init(sal_Int32 Width, sal_Int32 Height) override
Definition: htmlform.cxx:446
#define OOO_STRING_SVTOOLS_HTML_ET_multipart
uno::Reference< XImageProducerSupplier > xSrc
Definition: htmlform.cxx:368
void ReleaseFormComps()
Definition: htmlform.cxx:229
HTMLOptionEnum< sal_Int16 > const aHTMLImgVAlignTable[]
Definition: htmlgrin.cxx:86
sal_uInt32 GetNumber() const
uno::Reference< awt::XImageConsumer > xThis
Definition: htmlform.cxx:369
SfxViewFrame * m_pTempViewFrame
Definition: swhtml.hxx:463
#define RES_LR_SPACE
Definition: hintids.hxx:196
HtmlTokenId
Point PixelToLogic(const Point &rDevicePt) const
#define HTML_DFLT_IMG_WIDTH
Definition: swhtml.hxx:63
#define OOO_STRING_SVTOOLS_HTML_WW_physical
static void lcl_html_setFixedFontProperty(const uno::Reference< beans::XPropertySet > &rPropSet)
Definition: htmlform.cxx:588
sal_uInt16 Which() const
for Querying of Writer-functions.
Definition: format.hxx:78
SvKeyValueIterator *const m_pHeaderAttrs
Definition: htmlform.cxx:183
const OUString & GetFamilyName() const
OUString m_aScriptType
Definition: swhtml.hxx:346
const SvxMacro * Get(SvMacroItemId nEvent) const
void SetTextFirstLineOfst(const short nF, const sal_uInt16 nProp=100)
uno::Reference< drawing::XShape > xShape
Definition: htmlform.cxx:367
const uno::Reference< drawing::XShape > & GetShape() const
Definition: htmlform.cxx:243
sal_uInt16 DecGrfsThatResize()
Definition: swtable.hxx:179
#define OOO_STRING_SVTOOLS_HTML_ET_url
void InsertSelectText()
Definition: htmlform.cxx:2461
#define OOO_STRING_SVTOOLS_HTML_O_SDonfocus
#define RES_DRAWFRMFMT
Definition: hintids.hxx:277
static SfxViewFrame * LoadHiddenDocument(SfxObjectShell const &i_rDoc, SfxInterfaceId i_nViewId)
OUString GetPartBeforeLastName() const
void InsertTextAreaText(HtmlTokenId nToken)
Definition: htmlform.cxx:2102
#define RES_CHRATR_POSTURE
Definition: hintids.hxx:79
static void lcl_html_getEvents(const OUString &rOption, const OUString &rValue, std::vector< OUString > &rUnoMacroTable, std::vector< OUString > &rUnoMacroParamTable)
Definition: htmlform.cxx:825
vcl::Window * GetWin() const
Definition: viewsh.hxx:340
void EraseValueList()
Definition: htmlform.cxx:256
SwHTMLTableLayout * GetHTMLTableLayout()
Definition: swtable.hxx:174
VCL_DLLPUBLIC float ConvertFontWeight(FontWeight eWeight)
::std::vector< HTMLOption > HTMLOptions
#define OOO_STRING_SVTOOLS_HTML_WW_hard
sal_Int32 GetIndex() const
Definition: index.hxx:95
#define OOO_STRING_SVTOOLS_HTML_O_onclick
SwHTMLForm_Impl * m_pFormImpl
Definition: swhtml.hxx:384
#define OOO_STRING_SVTOOLS_HTML_O_onreset
#define OOO_STRING_SVTOOLS_HTML_METHOD_get
std::vector< OUString > & GetStringList()
Definition: htmlform.cxx:249
const uno::Reference< XMultiServiceFactory > & GetServiceFactory()
Definition: htmlform.cxx:270
virtual void SAL_CALL setPixelsByBytes(sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, const uno::Sequence< sal_Int8 > &ProducerData, sal_Int32 Offset, sal_Int32 Scansize) override
Definition: htmlform.cxx:545
css::uno::Reference< css::awt::XControl > GetUnoControl(const SdrView &_rView, const OutputDevice &_rOut) const
bool m_bTextArea
Definition: swhtml.hxx:446
std::shared_ptr< HTMLTable > m_xTable
Definition: swhtml.hxx:383
void EraseSelectedList()
Definition: htmlform.cxx:262
const OUString & GetTokenString() const
#define OOO_STRING_SVTOOLS_HTML_ET_text
long GetRight() const
SwTableNode * FindTableNode()
Search table node, in which it is.
Definition: node.cxx:351
#define OOO_STRING_SVTOOLS_HTML_IT_submit
HtmlOptionId
void ReleaseFCompPropSet()
Definition: htmlform.cxx:241
const SwStartNode * FindFlyStartNode() const
Definition: node.hxx:198
SwHTMLImageWatcher(const uno::Reference< drawing::XShape > &rShape, bool bWidth, bool bHeight)
Definition: htmlform.cxx:407
constexpr sal_Int64 convertTwipToMm100(sal_Int64 n)
#define HTML_DFLT_IMG_HEIGHT
Definition: swhtml.hxx:64
virtual void SAL_CALL setColorModel(sal_Int16 BitCount, const uno::Sequence< sal_Int32 > &RGBAPal, sal_Int32 RedMask, sal_Int32 GreenMask, sal_Int32 BlueMask, sal_Int32 AlphaMask) override
Definition: htmlform.cxx:539
void InsertSelectOption()
Definition: htmlform.cxx:2422
#define RES_CHRATR_CROSSEDOUT
Definition: hintids.hxx:73
HTMLOptionEnum< sal_Int16 > const aHTMLImgHAlignTable[]
Definition: htmlgrin.cxx:79
ScriptType
void EraseText()
Definition: htmlform.cxx:247
const OUString & GetScriptTypeString(SvKeyValueIterator *) const
bool AppendTextNode(SwHTMLAppendMode eMode=AM_NORMAL, bool bUpdateNum=true)
Definition: swhtml.cxx:2139
static void 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
const uno::Reference< beans::XPropertySet > & GetFCompPropSet() const
Definition: htmlform.cxx:231
#define OOO_STRING_SVTOOLS_HTML_on
void PushContext(std::unique_ptr< HTMLAttrContext > &rCntxt)
Definition: swhtml.hxx:551
#define OOO_STRING_SVTOOLS_HTML_O_onfocus
SwViewShell * CallStartAction(SwViewShell *pVSh=nullptr, bool bChkPtr=true)
Definition: swhtml.cxx:2584
rtl::Reference< SwDoc > m_xDoc
Definition: swhtml.hxx:377
void setWidth(long nWidth)
void EraseStringList()
Definition: htmlform.cxx:250
SwFrameFormat * GetFrameFormat() const
Definition: unodraw.hxx:242
STARBASIC
const OUString & GetMacName() const
#define HTMLTABLE_RESIZE_NOW
Definition: htmltbl.hxx:36
SdrObject * FindSdrObject()
Definition: frmfmt.hxx:137
const uno::Reference< script::XEventAttacherManager > & GetControlEventManager()
Definition: htmlform.cxx:333
#define OOO_STRING_SVTOOLS_HTML_O_SDonclick
uno::Reference< container::XIndexContainer > m_xForms
Definition: htmlform.cxx:187
void SetFormComps(const uno::Reference< container::XIndexContainer > &r)
Definition: htmlform.cxx:224
const sal_Char sServiceName[]
Definition: accdoc.cxx:61
rtl_TextEncoding GetCharSet() const
sal_uInt16 GetUpper() const
HTMLWordWrapMode
Definition: htmlform.cxx:106
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)
bool const bSetWidth
Definition: htmlform.cxx:370
void setHeight(long nHeight)
SfxMedium * GetMedium() const
bool m_bTAIgnoreNewPara
Definition: swhtml.hxx:432
css::uno::Any SAL_CALL makeAny(const SharedUNOComponent< INTERFACE, COMPONENT > &value)