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