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