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