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