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