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 = SfxItemSet::GetItem<SfxBoolItem>(pDocSh->GetMedium()->GetItemSet(), 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 if( const SvxLRSpaceItem* pLRItem = rCSS1ItemSet.GetItemIfSet( RES_LR_SPACE ) )
890 {
891 // Flatten first line indent
892 SvxLRSpaceItem aLRItem( *pLRItem );
893 aLRItem.SetTextFirstLineOffset( 0 );
894 if( rCSS1PropInfo.m_bLeftMargin )
895 {
896 nLeftSpace = convertTwipToMm100( aLRItem.GetLeft() );
897 rCSS1PropInfo.m_bLeftMargin = false;
898 }
899 if( rCSS1PropInfo.m_bRightMargin )
900 {
901 nRightSpace = convertTwipToMm100( aLRItem.GetRight() );
902 rCSS1PropInfo.m_bRightMargin = false;
903 }
904 rCSS1ItemSet.ClearItem( RES_LR_SPACE );
905 }
906 if( nLeftSpace || nRightSpace )
907 {
908 Any aAny2;
909 aAny2 <<= nLeftSpace;
910 xShapePropSet->setPropertyValue("LeftMargin", aAny2 );
911
912 aAny2 <<= nRightSpace;
913 xShapePropSet->setPropertyValue("RightMargin", aAny2 );
914 }
915
916 // set upper/lower border
917 if( const SvxULSpaceItem *pULItem = rCSS1ItemSet.GetItemIfSet( RES_UL_SPACE ) )
918 {
919 // Flatten first line indent
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 const SvxBrushItem* pBrushItem = rCSS1ItemSet.GetItemIfSet( RES_BACKGROUND );
947 if( pBrushItem && xPropSetInfo->hasPropertyByName( sPropName ) )
948 {
949 const Color &rColor = pBrushItem->GetColor();
951 if( rColor != COL_TRANSPARENT )
952 {
954 aTmp <<= rColor;
955 rFCompPropSet->setPropertyValue( sPropName, aTmp );
956 }
957
958 }
959
960 sPropName = "TextColor";
961 const SvxColorItem* pColorItem = rCSS1ItemSet.GetItemIfSet( RES_CHRATR_COLOR );
962 if( pColorItem && xPropSetInfo->hasPropertyByName( sPropName ) )
963 {
964 aTmp <<= static_cast<sal_Int32>(pColorItem->GetValue().GetRGBColor());
965 rFCompPropSet->setPropertyValue( sPropName, aTmp );
966 }
967
968 sPropName = "FontHeight";
969 const SvxFontHeightItem* pFontHeightItem = rCSS1ItemSet.GetItemIfSet( RES_CHRATR_FONTSIZE );
970 if( pFontHeightItem && xPropSetInfo->hasPropertyByName( sPropName ) )
971 {
972 float fVal = static_cast< float >( pFontHeightItem->GetHeight() / 20.0 );
973 aTmp <<= fVal;
974 rFCompPropSet->setPropertyValue( sPropName, aTmp );
975 }
976
977 if( const SvxFontItem* pFontItem = rCSS1ItemSet.GetItemIfSet( RES_CHRATR_FONT ) )
978 {
979 sPropName = "FontName";
980 if( xPropSetInfo->hasPropertyByName( sPropName ) )
981 {
982 aTmp <<= pFontItem->GetFamilyName();
983 rFCompPropSet->setPropertyValue( sPropName, aTmp );
984 }
985 sPropName = "FontStyleName";
986 if( xPropSetInfo->hasPropertyByName( sPropName ) )
987 {
988 aTmp <<= pFontItem->GetStyleName();
989 rFCompPropSet->setPropertyValue( sPropName, aTmp );
990 }
991 sPropName = "FontFamily";
992 if( xPropSetInfo->hasPropertyByName( sPropName ) )
993 {
994 aTmp <<= static_cast<sal_Int16>(pFontItem->GetFamily()) ;
995 rFCompPropSet->setPropertyValue( sPropName, aTmp );
996 }
997 sPropName = "FontCharset";
998 if( xPropSetInfo->hasPropertyByName( sPropName ) )
999 {
1000 aTmp <<= static_cast<sal_Int16>(pFontItem->GetCharSet()) ;
1001 rFCompPropSet->setPropertyValue( sPropName, aTmp );
1002 }
1003 sPropName = "FontPitch";
1004 if( xPropSetInfo->hasPropertyByName( sPropName ) )
1005 {
1006 aTmp <<= static_cast<sal_Int16>(pFontItem->GetPitch()) ;
1007 rFCompPropSet->setPropertyValue( sPropName, aTmp );
1008 }
1009 }
1010
1011 sPropName = "FontWeight";
1012 const SvxWeightItem* pWeightItem = rCSS1ItemSet.GetItemIfSet( RES_CHRATR_WEIGHT );
1013 if( pWeightItem && xPropSetInfo->hasPropertyByName( sPropName ) )
1014 {
1016 pWeightItem->GetWeight() );
1017 aTmp <<= fVal;
1018 rFCompPropSet->setPropertyValue( sPropName, aTmp );
1019 }
1020
1021 sPropName = "FontSlant";
1022 const SvxPostureItem* pPostureItem = rCSS1ItemSet.GetItemIfSet( RES_CHRATR_POSTURE );
1023 if( pPostureItem && xPropSetInfo->hasPropertyByName( sPropName ) )
1024 {
1025 aTmp <<= static_cast<sal_Int16>(pPostureItem->GetPosture());
1026 rFCompPropSet->setPropertyValue( sPropName, aTmp );
1027 }
1028
1029 sPropName = "FontUnderline";
1030 const SvxUnderlineItem* pUnderlineItem = rCSS1ItemSet.GetItemIfSet( RES_CHRATR_UNDERLINE );
1031 if( pUnderlineItem && xPropSetInfo->hasPropertyByName( sPropName ) )
1032 {
1033 aTmp <<= static_cast<sal_Int16>(pUnderlineItem->GetLineStyle());
1034 rFCompPropSet->setPropertyValue( sPropName, aTmp );
1035 }
1036
1037 sPropName = "FontStrikeout";
1038 const SvxCrossedOutItem* pCrossedOutItem = rCSS1ItemSet.GetItemIfSet( RES_CHRATR_CROSSEDOUT );
1039 if( pCrossedOutItem && xPropSetInfo->hasPropertyByName( sPropName ) )
1040 {
1041 aTmp <<= static_cast<sal_Int16>(pCrossedOutItem->GetStrikeout());
1042 rFCompPropSet->setPropertyValue( sPropName, aTmp );
1043 }
1044
1045 uno::Reference< text::XTextRange > xTextRg;
1046 text::TextContentAnchorType nAnchorType = text::TextContentAnchorType_AS_CHARACTER;
1047 bool bSetPos = false, bSetSurround = false;
1048 sal_Int32 nXPos = 0, nYPos = 0;
1049 text::WrapTextMode nSurround = text::WrapTextMode_NONE;
1050 if( SVX_CSS1_POS_ABSOLUTE == rCSS1PropInfo.m_ePosition &&
1051 SVX_CSS1_LTYPE_TWIP == rCSS1PropInfo.m_eLeftType &&
1052 SVX_CSS1_LTYPE_TWIP == rCSS1PropInfo.m_eTopType )
1053 {
1054 const SwStartNode *pFlySttNd =
1056
1057 if( pFlySttNd )
1058 {
1059 nAnchorType = text::TextContentAnchorType_AT_FRAME;
1060 SwPaM aPaM( *pFlySttNd );
1061
1062 uno::Reference< text::XText > xDummyTextRef; // dirty, but works according to OS...
1063 xTextRg = new SwXTextRange( aPaM, xDummyTextRef );
1064 }
1065 else
1066 {
1067 nAnchorType = text::TextContentAnchorType_AT_PAGE;
1068 }
1069 nXPos = convertTwipToMm100( rCSS1PropInfo.m_nLeft ) + nLeftSpace;
1070 nYPos = convertTwipToMm100( rCSS1PropInfo.m_nTop ) + nUpperSpace;
1071 bSetPos = true;
1072
1073 nSurround = text::WrapTextMode_THROUGH;
1074 bSetSurround = true;
1075 }
1076 else if( SvxAdjust::Left == rCSS1PropInfo.m_eFloat ||
1077 text::HoriOrientation::LEFT == eHoriOri )
1078 {
1079 nAnchorType = text::TextContentAnchorType_AT_PARAGRAPH;
1080 nXPos = nLeftSpace;
1081 nYPos = nUpperSpace;
1082 bSetPos = true;
1083 nSurround = text::WrapTextMode_RIGHT;
1084 bSetSurround = true;
1085 }
1086 else if( text::VertOrientation::NONE != eVertOri )
1087 {
1088 sal_Int16 nVertOri = text::VertOrientation::NONE;
1089 switch( eVertOri )
1090 {
1091 case text::VertOrientation::TOP:
1092 nVertOri = text::VertOrientation::TOP;
1093 break;
1094 case text::VertOrientation::CENTER:
1095 nVertOri = text::VertOrientation::CENTER;
1096 break;
1097 case text::VertOrientation::BOTTOM:
1098 nVertOri = text::VertOrientation::BOTTOM;
1099 break;
1100 case text::VertOrientation::CHAR_TOP:
1101 nVertOri = text::VertOrientation::CHAR_TOP;
1102 break;
1103 case text::VertOrientation::CHAR_CENTER:
1104 nVertOri = text::VertOrientation::CHAR_CENTER;
1105 break;
1106 case text::VertOrientation::CHAR_BOTTOM:
1107 nVertOri = text::VertOrientation::CHAR_BOTTOM;
1108 break;
1109 case text::VertOrientation::LINE_TOP:
1110 nVertOri = text::VertOrientation::LINE_TOP;
1111 break;
1112 case text::VertOrientation::LINE_CENTER:
1113 nVertOri = text::VertOrientation::LINE_CENTER;
1114 break;
1115 case text::VertOrientation::LINE_BOTTOM:
1116 nVertOri = text::VertOrientation::LINE_BOTTOM;
1117 break;
1118 // coverity[dead_error_begin] - following conditions exist to avoid compiler warning
1120 nVertOri = text::VertOrientation::NONE;
1121 break;
1122 }
1123 aTmp <<= nVertOri ;
1124 xShapePropSet->setPropertyValue("VertOrient", aTmp );
1125 }
1126
1127 aTmp <<= nAnchorType ;
1128 xShapePropSet->setPropertyValue("AnchorType", aTmp );
1129
1130 if( text::TextContentAnchorType_AT_PAGE == nAnchorType )
1131 {
1132 aTmp <<= sal_Int16(1) ;
1133 xShapePropSet->setPropertyValue("AnchorPageNo", aTmp );
1134 }
1135 else
1136 {
1137 if( !xTextRg.is() )
1138 {
1139 uno::Reference< text::XText > xDummyTextRef; // dirty but works according to OS...
1140 xTextRg = new SwXTextRange( *m_pPam, xDummyTextRef );
1141 }
1142
1143 aTmp <<= xTextRg;
1144 xShapePropSet->setPropertyValue("TextRange", aTmp );
1145 }
1146
1147 if( bSetPos )
1148 {
1149 aTmp <<= sal_Int16(text::HoriOrientation::NONE);
1150 xShapePropSet->setPropertyValue("HoriOrient", aTmp );
1151 aTmp <<= nXPos ;
1152 xShapePropSet->setPropertyValue("HoriOrientPosition", aTmp );
1153
1154 aTmp <<= sal_Int16(text::VertOrientation::NONE);
1155 xShapePropSet->setPropertyValue("VertOrient", aTmp );
1156 aTmp <<= nYPos ;
1157 xShapePropSet->setPropertyValue("VertOrientPosition", aTmp );
1158 }
1159 if( bSetSurround )
1160 {
1161 aTmp <<= nSurround ;
1162 xShapePropSet->setPropertyValue("Surround", aTmp );
1163 }
1164
1165 m_pFormImpl->GetShapes()->add(xShape);
1166
1167 // Set ControlModel to ControlShape
1168 uno::Reference< drawing::XControlShape > xControlShape( xShape, UNO_QUERY );
1169 uno::Reference< awt::XControlModel > xControlModel( rFComp, UNO_QUERY );
1170 xControlShape->setControl( xControlModel );
1171 }
1172
1173 // Since the focus is set at insertion of the controls, focus events will be sent
1174 // To prevent previous JavaScript-Events from being called, these events will only be set retroactively
1175 if( !rMacroTable.empty() || !rUnoMacroTable.empty() )
1176 {
1178 rFormComps->getCount() - 1,
1179 rMacroTable, rUnoMacroTable, rUnoMacroParamTable,
1181 if (bHasEvents)
1183 }
1184
1185 if( bSetFCompPropSet )
1186 {
1187 m_pFormImpl->SetFCompPropSet( rFCompPropSet );
1188 }
1189
1190 return xShape;
1191}
1192
1193void SwHTMLParser::NewForm( bool bAppend )
1194{
1195 // Does a form already exist?
1196 if( m_pFormImpl && m_pFormImpl->GetFormComps().is() )
1197 return;
1198
1199 if( bAppend )
1200 {
1201 if( m_pPam->GetPoint()->GetContentIndex() )
1203 else
1204 AddParSpace();
1205 }
1206
1207 if( !m_pFormImpl )
1208 m_pFormImpl = new SwHTMLForm_Impl( m_xDoc->GetDocShell() );
1209
1210 OUString aAction( m_sBaseURL );
1211 OUString sName, sTarget;
1212 FormSubmitEncoding nEncType = FormSubmitEncoding_URL;
1213 FormSubmitMethod nMethod = FormSubmitMethod_GET;
1214 SvxMacroTableDtor aMacroTable;
1215 std::vector<OUString> aUnoMacroTable;
1216 std::vector<OUString> aUnoMacroParamTable;
1218 ScriptType eDfltScriptType = GetScriptType( pHeaderAttrs );
1219 const OUString& rDfltScriptType = GetScriptTypeString( pHeaderAttrs );
1220
1221 const HTMLOptions& rHTMLOptions = GetOptions();
1222 for (size_t i = rHTMLOptions.size(); i; )
1223 {
1224 const HTMLOption& rOption = rHTMLOptions[--i];
1225 ScriptType eScriptType2 = eDfltScriptType;
1226 SvMacroItemId nEvent = SvMacroItemId::NONE;
1227 bool bSetEvent = false;
1228
1229 switch( rOption.GetToken() )
1230 {
1231 case HtmlOptionId::ACTION:
1232 aAction = rOption.GetString();
1233 break;
1234 case HtmlOptionId::METHOD:
1235 nMethod = rOption.GetEnum( aHTMLFormMethodTable, nMethod );
1236 break;
1237 case HtmlOptionId::ENCTYPE:
1238 nEncType = rOption.GetEnum( aHTMLFormEncTypeTable, nEncType );
1239 break;
1240 case HtmlOptionId::TARGET:
1241 sTarget = rOption.GetString();
1242 break;
1243 case HtmlOptionId::NAME:
1244 sName = rOption.GetString();
1245 break;
1246
1247 case HtmlOptionId::SDONSUBMIT:
1248 eScriptType2 = STARBASIC;
1249 [[fallthrough]];
1250 case HtmlOptionId::ONSUBMIT:
1251 nEvent = SvMacroItemId::HtmlOnSubmitForm;
1252 bSetEvent = true;
1253 break;
1254
1255 case HtmlOptionId::SDONRESET:
1256 eScriptType2 = STARBASIC;
1257 [[fallthrough]];
1258 case HtmlOptionId::ONRESET:
1259 nEvent = SvMacroItemId::HtmlOnResetForm;
1260 bSetEvent = true;
1261 break;
1262
1263 default:
1265 rOption.GetString(),
1266 aUnoMacroTable, aUnoMacroParamTable );
1267 break;
1268 }
1269
1270 if( bSetEvent )
1271 {
1272 OUString sEvent( rOption.GetString() );
1273 if( !sEvent.isEmpty() )
1274 {
1275 sEvent = convertLineEnd(sEvent, GetSystemLineEnd());
1276 OUString aScriptType2;
1277 if( EXTENDED_STYPE==eScriptType2 )
1278 aScriptType2 = rDfltScriptType;
1279 aMacroTable.Insert( nEvent, SvxMacro( sEvent, aScriptType2, eScriptType2 ) );
1280 }
1281 }
1282 }
1283
1284 const uno::Reference< XMultiServiceFactory > & rSrvcMgr =
1286 if( !rSrvcMgr.is() )
1287 return;
1288
1289 uno::Reference< XInterface > xInt;
1290 uno::Reference<XForm> xForm;
1291 try
1292 {
1293 xInt = rSrvcMgr->createInstance("com.sun.star.form.component.Form");
1294 if (!xInt.is())
1295 return;
1296 xForm.set(xInt, UNO_QUERY);
1297 SAL_WARN_IF(!xForm.is(), "sw", "no XForm for com.sun.star.form.component.Form?");
1298 if (!xForm.is())
1299 return;
1300 }
1301 catch (...)
1302 {
1303 TOOLS_WARN_EXCEPTION("sw", "");
1304 return;
1305 }
1306
1307 uno::Reference< container::XIndexContainer > xFormComps( xForm, UNO_QUERY );
1308 m_pFormImpl->SetFormComps( xFormComps );
1309
1310 uno::Reference< beans::XPropertySet > xFormPropSet( xForm, UNO_QUERY );
1311
1312 Any aTmp;
1313 aTmp <<= sName;
1314 xFormPropSet->setPropertyValue("Name", aTmp );
1315
1316 if( !aAction.isEmpty() )
1317 {
1319 }
1320 else
1321 {
1322 // use directory at empty URL
1323 INetURLObject aURLObj( m_aPathToFile );
1324 aAction = aURLObj.GetPartBeforeLastName();
1325 }
1326 aTmp <<= aAction;
1327 xFormPropSet->setPropertyValue("TargetURL",
1328 aTmp );
1329
1330 aTmp <<= nMethod;
1331 xFormPropSet->setPropertyValue("SubmitMethod",
1332 aTmp );
1333
1334 aTmp <<= nEncType;
1335 xFormPropSet->setPropertyValue("SubmitEncoding", aTmp );
1336
1337 if( !sTarget.isEmpty() )
1338 {
1339 aTmp <<= sTarget;
1340 xFormPropSet->setPropertyValue( "TargetFrame", aTmp );
1341 }
1342
1343 const uno::Reference< container::XIndexContainer > & rForms =
1345 Any aAny( &xForm, cppu::UnoType<XForm>::get());
1346 rForms->insertByIndex( rForms->getCount(), aAny );
1347 if( !aMacroTable.empty() )
1348 {
1350 rForms->getCount() - 1,
1351 aMacroTable, aUnoMacroTable, aUnoMacroParamTable,
1352 rDfltScriptType );
1353 if (bHasEvents)
1355 }
1356}
1357
1358void SwHTMLParser::EndForm( bool bAppend )
1359{
1360 if( m_pFormImpl && m_pFormImpl->GetFormComps().is() )
1361 {
1362 if( bAppend )
1363 {
1364 if( m_pPam->GetPoint()->GetContentIndex() )
1366 else
1367 AddParSpace();
1368 }
1369
1371 }
1372}
1373
1375{
1376 assert(m_vPendingStack.empty());
1377
1378 if( !m_pFormImpl || !m_pFormImpl->GetFormComps().is() )
1379 return;
1380
1381 OUString sImgSrc, aId, aClass, aStyle, sName;
1382 OUString sText;
1383 SvxMacroTableDtor aMacroTable;
1384 std::vector<OUString> aUnoMacroTable;
1385 std::vector<OUString> aUnoMacroParamTable;
1386 sal_uInt16 nSize = 0;
1387 sal_Int16 nMaxLen = 0;
1388 sal_Int16 nChecked = TRISTATE_FALSE;
1389 sal_Int32 nTabIndex = TABINDEX_MAX + 1;
1390 HTMLInputType eType = HTMLInputType::Text;
1391 bool bDisabled = false, bValue = false;
1392 bool bSetGrfWidth = false, bSetGrfHeight = false;
1393 bool bHidden = false;
1394 tools::Long nWidth=0, nHeight=0;
1395 sal_Int16 eVertOri = text::VertOrientation::TOP;
1396 sal_Int16 eHoriOri = text::HoriOrientation::NONE;
1398 ScriptType eDfltScriptType = GetScriptType( pHeaderAttrs );
1399 const OUString& rDfltScriptType = GetScriptTypeString( pHeaderAttrs );
1400
1401 HtmlOptionId nKeepCRLFToken = HtmlOptionId::VALUE;
1402 const HTMLOptions& rHTMLOptions = GetOptions( &nKeepCRLFToken );
1403 for (size_t i = rHTMLOptions.size(); i; )
1404 {
1405 const HTMLOption& rOption = rHTMLOptions[--i];
1406 ScriptType eScriptType2 = eDfltScriptType;
1407 SvMacroItemId nEvent = SvMacroItemId::NONE;
1408 bool bSetEvent = false;
1409
1410 switch( rOption.GetToken() )
1411 {
1412 case HtmlOptionId::ID:
1413 aId = rOption.GetString();
1414 break;
1415 case HtmlOptionId::STYLE:
1416 aStyle = rOption.GetString();
1417 break;
1418 case HtmlOptionId::CLASS:
1419 aClass = rOption.GetString();
1420 break;
1421 case HtmlOptionId::TYPE:
1422 eType = rOption.GetInputType();
1423 break;
1424 case HtmlOptionId::NAME:
1425 sName = rOption.GetString();
1426 break;
1427 case HtmlOptionId::VALUE:
1428 sText = rOption.GetString();
1429 bValue = true;
1430 break;
1431 case HtmlOptionId::CHECKED:
1432 nChecked = TRISTATE_TRUE;
1433 break;
1434 case HtmlOptionId::DISABLED:
1435 bDisabled = true;
1436 break;
1437 case HtmlOptionId::MAXLENGTH:
1438 nMaxLen = static_cast<sal_Int16>(rOption.GetNumber());
1439 break;
1440 case HtmlOptionId::SIZE:
1441 nSize = o3tl::narrowing<sal_uInt16>(rOption.GetNumber());
1442 break;
1443 case HtmlOptionId::SRC:
1444 sImgSrc = rOption.GetString();
1445 break;
1446 case HtmlOptionId::WIDTH:
1447 // only save pixel values at first!
1448 nWidth = rOption.GetNumber();
1449 break;
1450 case HtmlOptionId::HEIGHT:
1451 // only save pixel values at first!
1452 nHeight = rOption.GetNumber();
1453 break;
1454 case HtmlOptionId::ALIGN:
1455 eVertOri =
1456 rOption.GetEnum( aHTMLImgVAlignTable, eVertOri );
1457 eHoriOri =
1458 rOption.GetEnum( aHTMLImgHAlignTable, eHoriOri );
1459 break;
1460 case HtmlOptionId::TABINDEX:
1461 // only save pixel values at first!
1462 nTabIndex = rOption.GetNumber();
1463 break;
1464
1465 case HtmlOptionId::SDONFOCUS:
1466 eScriptType2 = STARBASIC;
1467 [[fallthrough]];
1468 case HtmlOptionId::ONFOCUS:
1469 nEvent = SvMacroItemId::HtmlOnGetFocus;
1470 bSetEvent = true;
1471 break;
1472
1473 case HtmlOptionId::SDONBLUR: // actually only EDIT
1474 eScriptType2 = STARBASIC;
1475 [[fallthrough]];
1476 case HtmlOptionId::ONBLUR:
1477 nEvent = SvMacroItemId::HtmlOnLoseFocus;
1478 bSetEvent = true;
1479 break;
1480
1481 case HtmlOptionId::SDONCLICK:
1482 eScriptType2 = STARBASIC;
1483 [[fallthrough]];
1484 case HtmlOptionId::ONCLICK:
1485 nEvent = SvMacroItemId::HtmlOnClick;
1486 bSetEvent = true;
1487 break;
1488
1489 case HtmlOptionId::SDONCHANGE: // actually only EDIT
1490 eScriptType2 = STARBASIC;
1491 [[fallthrough]];
1492 case HtmlOptionId::ONCHANGE:
1493 nEvent = SvMacroItemId::HtmlOnChange;
1494 bSetEvent = true;
1495 break;
1496
1497 case HtmlOptionId::SDONSELECT: // actually only EDIT
1498 eScriptType2 = STARBASIC;
1499 [[fallthrough]];
1500 case HtmlOptionId::ONSELECT:
1501 nEvent = SvMacroItemId::HtmlOnSelect;
1502 bSetEvent = true;
1503 break;
1504
1505 default:
1507 rOption.GetString(),
1508 aUnoMacroTable, aUnoMacroParamTable );
1509 break;
1510 }
1511
1512 if( bSetEvent )
1513 {
1514 OUString sEvent( rOption.GetString() );
1515 if( !sEvent.isEmpty() )
1516 {
1517 sEvent = convertLineEnd(sEvent, GetSystemLineEnd());
1518 OUString aScriptType2;
1519 if( EXTENDED_STYPE==eScriptType2 )
1520 aScriptType2 = rDfltScriptType;
1521 aMacroTable.Insert( nEvent, SvxMacro( sEvent, aScriptType2, eScriptType2 ) );
1522 }
1523 }
1524 }
1525
1526 if( HTMLInputType::Image==eType )
1527 {
1528 // Image controls without image URL are ignored (same as MS)
1529 if( sImgSrc.isEmpty() )
1530 return;
1531 }
1532 else
1533 {
1534 // evaluation of ALIGN for all controls is not a good idea as long as
1535 // paragraph bound controls do not influence the height of the cells of a table
1536 eVertOri = text::VertOrientation::TOP;
1537 eHoriOri = text::HoriOrientation::NONE;
1538 }
1539
1540 // Default is HTMLInputType::Text
1541 const char *pType = "TextField";
1542 bool bKeepCRLFInValue = false;
1543 switch( eType )
1544 {
1545 case HTMLInputType::Checkbox:
1546 pType = "CheckBox";
1547 bKeepCRLFInValue = true;
1548 break;
1549
1550 case HTMLInputType::Radio:
1551 pType = "RadioButton";
1552 bKeepCRLFInValue = true;
1553 break;
1554
1555 case HTMLInputType::Password:
1556 bKeepCRLFInValue = true;
1557 break;
1558
1559 case HTMLInputType::Button:
1560 bKeepCRLFInValue = true;
1561 [[fallthrough]];
1562 case HTMLInputType::Submit:
1563 case HTMLInputType::Reset:
1564 pType = "CommandButton";
1565 break;
1566
1567 case HTMLInputType::Image:
1568 pType = "ImageButton";
1569 break;
1570
1571 case HTMLInputType::File:
1572 pType = "FileControl";
1573 break;
1574
1575 case HTMLInputType::Hidden:
1576 pType = "HiddenControl";
1577 bKeepCRLFInValue = true;
1578 break;
1579 default:
1580 ;
1581 }
1582
1583 // For some controls CR/LF has to be deleted from VALUE
1584 if( !bKeepCRLFInValue )
1585 {
1586 sText = sText.replaceAll("\r", "").replaceAll("\n", "");
1587 }
1588
1589 const uno::Reference< XMultiServiceFactory > & rServiceFactory =
1591 if( !rServiceFactory.is() )
1592 return;
1593
1594 OUString sServiceName = "com.sun.star.form.component." +
1595 OUString::createFromAscii(pType);
1596 uno::Reference< XInterface > xInt =
1597 rServiceFactory->createInstance( sServiceName );
1598 if( !xInt.is() )
1599 return;
1600
1601 uno::Reference< XFormComponent > xFComp( xInt, UNO_QUERY );
1602 if( !xFComp.is() )
1603 return;
1604
1605 uno::Reference< beans::XPropertySet > xPropSet( xFComp, UNO_QUERY );
1606
1607 Any aTmp;
1608 aTmp <<= sName;
1609 xPropSet->setPropertyValue("Name", aTmp );
1610
1611 if( HTMLInputType::Hidden != eType )
1612 {
1613 if( nTabIndex >= TABINDEX_MIN && nTabIndex <= TABINDEX_MAX )
1614 {
1615 aTmp <<= static_cast<sal_Int16>(nTabIndex) ;
1616 xPropSet->setPropertyValue("TabIndex", aTmp );
1617 }
1618
1619 if( bDisabled )
1620 {
1621 xPropSet->setPropertyValue("Enabled", Any(false) );
1622 }
1623 }
1624
1625 aTmp <<= sText;
1626
1627 Size aSz( 0, 0 ); // defaults
1628 Size aTextSz( 0, 0 ); // Text size
1629 bool bMinWidth = false, bMinHeight = false;
1630 bool bUseSize = false;
1631 switch( eType )
1632 {
1633 case HTMLInputType::Checkbox:
1634 case HTMLInputType::Radio:
1635 {
1636 if( !bValue )
1637 aTmp <<= OUString( OOO_STRING_SVTOOLS_HTML_on );
1638 xPropSet->setPropertyValue("RefValue",
1639 aTmp );
1640 aTmp <<= OUString();
1641 xPropSet->setPropertyValue("Label",
1642 aTmp );
1643 // RadioButton: The DefaultChecked property should only be set
1644 // if the control has been created and activateTabOrder has been called
1645 // because otherwise it would still belong to the previous group.
1646 if( HTMLInputType::Checkbox == eType )
1647 {
1648 aTmp <<= nChecked ;
1649 xPropSet->setPropertyValue("DefaultState", aTmp );
1650 }
1651
1652 const SvxMacro* pMacro = aMacroTable.Get( SvMacroItemId::HtmlOnClick );
1653 if( pMacro )
1654 {
1655 aMacroTable.Insert( SvMacroItemId::HtmlOnClickItem, *pMacro );
1656 aMacroTable.Erase( SvMacroItemId::HtmlOnClick );
1657 }
1658 // evaluating SIZE shouldn't be necessary here?
1659 bMinWidth = bMinHeight = true;
1660 }
1661 break;
1662
1663 case HTMLInputType::Image:
1664 {
1665 // SIZE = WIDTH
1666 aSz.setWidth( nSize ? nSize : nWidth );
1667 aSz.setWidth( nWidth );
1668 aSz.setHeight( nHeight );
1669 if( (aSz.Width() || aSz.Height()) && Application::GetDefaultDevice() )
1670 {
1672 ->PixelToLogic( aSz, MapMode( MapUnit::Map100thMM ) );
1673 }
1674 aTmp <<= FormButtonType_SUBMIT;
1675 xPropSet->setPropertyValue("ButtonType", aTmp );
1676
1677 aTmp <<= sal_Int16(0) ;
1678 xPropSet->setPropertyValue("Border",
1679 aTmp );
1680 }
1681 break;
1682
1683 case HTMLInputType::Button:
1684 case HTMLInputType::Submit:
1685 case HTMLInputType::Reset:
1686 {
1687 FormButtonType eButtonType;
1688 switch( eType )
1689 {
1690 case HTMLInputType::Button:
1691 eButtonType = FormButtonType_PUSH;
1692 break;
1693 case HTMLInputType::Submit:
1694 eButtonType = FormButtonType_SUBMIT;
1695 if (sText.isEmpty())
1697 break;
1698 case HTMLInputType::Reset:
1699 eButtonType = FormButtonType_RESET;
1700 if (sText.isEmpty())
1702 break;
1703 default:
1704 ;
1705 }
1706 aTmp <<= sText;
1707 xPropSet->setPropertyValue("Label",
1708 aTmp );
1709
1710 aTmp <<= eButtonType;
1711 xPropSet->setPropertyValue("ButtonType", aTmp );
1712
1713 bMinWidth = bMinHeight = true;
1714 bUseSize = true;
1715 }
1716 break;
1717
1718 case HTMLInputType::Password:
1719 case HTMLInputType::Text:
1720 case HTMLInputType::File:
1721 if( HTMLInputType::File != eType )
1722 {
1723 // The VALUE of file control will be ignored for security reasons
1724 xPropSet->setPropertyValue("DefaultText", aTmp );
1725 if( nMaxLen != 0 )
1726 {
1727 aTmp <<= nMaxLen ;
1728 xPropSet->setPropertyValue("MaxTextLen", aTmp );
1729 }
1730 }
1731
1732 if( HTMLInputType::Password == eType )
1733 {
1734 aTmp <<= sal_Int16('*') ;
1735 xPropSet->setPropertyValue("EchoChar", aTmp );
1736 }
1737
1739
1740 if( !nSize )
1741 nSize = 20;
1742 aTextSz.setWidth( nSize );
1743 bMinHeight = true;
1744 break;
1745
1746 case HTMLInputType::Hidden:
1747 xPropSet->setPropertyValue("HiddenValue", aTmp );
1748 bHidden = true;
1749 break;
1750 default:
1751 ;
1752 }
1753
1754 if( bUseSize && nSize>0 )
1755 {
1757 {
1758 Size aNewSz( nSize, 0 );
1760 ->PixelToLogic( aNewSz, MapMode( MapUnit::Map100thMM ) );
1761 aSz.setWidth( aNewSz.Width() );
1762 OSL_ENSURE( !aTextSz.Width(), "text width is present" );
1763 bMinWidth = false;
1764 }
1765 }
1766
1767 SfxItemSet aCSS1ItemSet( m_xDoc->GetAttrPool(), m_pCSS1Parser->GetWhichMap() );
1768 SvxCSS1PropertyInfo aCSS1PropInfo;
1769 if( HasStyleOptions( aStyle, aId, aClass ) )
1770 {
1771 ParseStyleOptions( aStyle, aId, aClass, aCSS1ItemSet, aCSS1PropInfo );
1772 if( !aId.isEmpty() )
1773 InsertBookmark( aId );
1774 }
1775
1776 if( SVX_CSS1_LTYPE_TWIP== aCSS1PropInfo.m_eWidthType )
1777 {
1778 aSz.setWidth( convertTwipToMm100( aCSS1PropInfo.m_nWidth ) );
1779 aTextSz.setWidth( 0 );
1780 bMinWidth = false;
1781 }
1782 if( SVX_CSS1_LTYPE_TWIP== aCSS1PropInfo.m_eHeightType )
1783 {
1784 aSz.setHeight( convertTwipToMm100( aCSS1PropInfo.m_nHeight ) );
1785 aTextSz.setHeight( 0 );
1786 bMinHeight = false;
1787 }
1788
1789 // Set sensible default values if the image button has no valid size
1790 if( HTMLInputType::Image== eType )
1791 {
1792 if( !aSz.Width() )
1793 {
1795 bSetGrfWidth = true;
1796 if (m_xTable)
1798 }
1799 if( !aSz.Height() )
1800 {
1802 bSetGrfHeight = true;
1803 }
1804 }
1805 if( aSz.Width() < MINFLY )
1806 aSz.setWidth( MINFLY );
1807 if( aSz.Height() < MINFLY )
1808 aSz.setHeight( MINFLY );
1809
1810 uno::Reference< drawing::XShape > xShape = InsertControl(
1811 xFComp, xPropSet, aSz,
1812 eVertOri, eHoriOri,
1813 aCSS1ItemSet, aCSS1PropInfo,
1814 aMacroTable, aUnoMacroTable,
1815 aUnoMacroParamTable, false,
1816 bHidden );
1817 if( aTextSz.Width() || aTextSz.Height() || bMinWidth || bMinHeight )
1818 {
1819 OSL_ENSURE( !(bSetGrfWidth || bSetGrfHeight), "Adjust graphic size???" );
1820 SetControlSize( xShape, aTextSz, bMinWidth, bMinHeight );
1821 }
1822
1823 if( HTMLInputType::Radio == eType )
1824 {
1825 aTmp <<= nChecked ;
1826 xPropSet->setPropertyValue("DefaultState", aTmp );
1827 }
1828
1829 if( HTMLInputType::Image == eType )
1830 {
1831 // Set the URL after inserting the graphic because the Download can
1832 // only register with XModel after the control has been inserted.
1833 aTmp <<= URIHelper::SmartRel2Abs(INetURLObject(m_sBaseURL), sImgSrc, Link<OUString *, bool>(), false);
1834 xPropSet->setPropertyValue("ImageURL",
1835 aTmp );
1836 }
1837
1838 if( bSetGrfWidth || bSetGrfHeight )
1839 {
1841 new SwHTMLImageWatcher( xShape, bSetGrfWidth, bSetGrfHeight );
1842 pWatcher->start();
1843 }
1844}
1845
1847{
1848 assert(m_vPendingStack.empty());
1849
1850 OSL_ENSURE( !m_bTextArea, "TextArea in TextArea?" );
1851 OSL_ENSURE( !m_pFormImpl || !m_pFormImpl->GetFCompPropSet().is(),
1852 "TextArea in Control?" );
1853
1854 if( !m_pFormImpl || !m_pFormImpl->GetFormComps().is() )
1855 {
1856 // Close special treatment for TextArea in the parser
1857 FinishTextArea();
1858 return;
1859 }
1860
1861 OUString aId, aClass, aStyle;
1862 OUString sName;
1863 sal_Int32 nTabIndex = TABINDEX_MAX + 1;
1864 SvxMacroTableDtor aMacroTable;
1865 std::vector<OUString> aUnoMacroTable;
1866 std::vector<OUString> aUnoMacroParamTable;
1867 sal_uInt16 nRows = 0, nCols = 0;
1868 HTMLWordWrapMode nWrap = HTML_WM_OFF;
1869 bool bDisabled = false;
1871 ScriptType eDfltScriptType = GetScriptType( pHeaderAttrs );
1872 const OUString& rDfltScriptType = GetScriptTypeString( pHeaderAttrs );
1873
1874 const HTMLOptions& rHTMLOptions = GetOptions();
1875 for (size_t i = rHTMLOptions.size(); i; )
1876 {
1877 const HTMLOption& rOption = rHTMLOptions[--i];
1878 ScriptType eScriptType2 = eDfltScriptType;
1879 SvMacroItemId nEvent = SvMacroItemId::NONE;
1880 bool bSetEvent = false;
1881
1882 switch( rOption.GetToken() )
1883 {
1884 case HtmlOptionId::ID:
1885 aId = rOption.GetString();
1886 break;
1887 case HtmlOptionId::STYLE:
1888 aStyle = rOption.GetString();
1889 break;
1890 case HtmlOptionId::CLASS:
1891 aClass = rOption.GetString();
1892 break;
1893 case HtmlOptionId::NAME:
1894 sName = rOption.GetString();
1895 break;
1896 case HtmlOptionId::DISABLED:
1897 bDisabled = true;
1898 break;
1899 case HtmlOptionId::ROWS:
1900 nRows = o3tl::narrowing<sal_uInt16>(rOption.GetNumber());
1901 break;
1902 case HtmlOptionId::COLS:
1903 nCols = o3tl::narrowing<sal_uInt16>(rOption.GetNumber());
1904 break;
1905 case HtmlOptionId::WRAP:
1906 nWrap = rOption.GetEnum( aHTMLTextAreaWrapTable, nWrap );
1907 break;
1908
1909 case HtmlOptionId::TABINDEX:
1910 nTabIndex = rOption.GetSNumber();
1911 break;
1912
1913 case HtmlOptionId::SDONFOCUS:
1914 eScriptType2 = STARBASIC;
1915 [[fallthrough]];
1916 case HtmlOptionId::ONFOCUS:
1917 nEvent = SvMacroItemId::HtmlOnGetFocus;
1918 bSetEvent = true;
1919 break;
1920
1921 case HtmlOptionId::SDONBLUR:
1922 eScriptType2 = STARBASIC;
1923 [[fallthrough]];
1924 case HtmlOptionId::ONBLUR:
1925 nEvent = SvMacroItemId::HtmlOnLoseFocus;
1926 bSetEvent = true;
1927 break;
1928
1929 case HtmlOptionId::SDONCLICK:
1930 eScriptType2 = STARBASIC;
1931 [[fallthrough]];
1932 case HtmlOptionId::ONCLICK:
1933 nEvent = SvMacroItemId::HtmlOnClick;
1934 bSetEvent = true;
1935 break;
1936
1937 case HtmlOptionId::SDONCHANGE:
1938 eScriptType2 = STARBASIC;
1939 [[fallthrough]];
1940 case HtmlOptionId::ONCHANGE:
1941 nEvent = SvMacroItemId::HtmlOnChange;
1942 bSetEvent = true;
1943 break;
1944
1945 case HtmlOptionId::SDONSELECT:
1946 eScriptType2 = STARBASIC;
1947 [[fallthrough]];
1948 case HtmlOptionId::ONSELECT:
1949 nEvent = SvMacroItemId::HtmlOnSelect;
1950 bSetEvent = true;
1951 break;
1952
1953 default:
1955 rOption.GetString(),
1956 aUnoMacroTable, aUnoMacroParamTable );
1957 break;
1958 }
1959
1960 if( bSetEvent )
1961 {
1962 OUString sEvent( rOption.GetString() );
1963 if( !sEvent.isEmpty() )
1964 {
1965 sEvent = convertLineEnd(sEvent, GetSystemLineEnd());
1966 if( EXTENDED_STYPE==eScriptType2 )
1967 m_aScriptType = rDfltScriptType;
1968 aMacroTable.Insert( nEvent, SvxMacro( sEvent, m_aScriptType, eScriptType2 ) );
1969 }
1970 }
1971 }
1972
1973 const uno::Reference< lang::XMultiServiceFactory > & rSrvcMgr =
1975 if( !rSrvcMgr.is() )
1976 {
1977 FinishTextArea();
1978 return;
1979 }
1980 uno::Reference< uno::XInterface > xInt = rSrvcMgr->createInstance(
1981 "com.sun.star.form.component.TextField" );
1982 if( !xInt.is() )
1983 {
1984 FinishTextArea();
1985 return;
1986 }
1987
1988 uno::Reference< XFormComponent > xFComp( xInt, UNO_QUERY );
1989 OSL_ENSURE( xFComp.is(), "no FormComponent?" );
1990
1991 uno::Reference< beans::XPropertySet > xPropSet( xFComp, UNO_QUERY );
1992
1993 Any aTmp;
1994 aTmp <<= sName;
1995 xPropSet->setPropertyValue("Name", aTmp );
1996
1997 aTmp <<= true;
1998 xPropSet->setPropertyValue("MultiLine", aTmp );
1999 xPropSet->setPropertyValue("VScroll", aTmp );
2000 if( HTML_WM_OFF == nWrap )
2001 xPropSet->setPropertyValue("HScroll", aTmp );
2002 if( HTML_WM_HARD == nWrap )
2003 xPropSet->setPropertyValue("HardLineBreaks", aTmp );
2004
2005 if( nTabIndex >= TABINDEX_MIN && nTabIndex <= TABINDEX_MAX )
2006 {
2007 aTmp <<= static_cast<sal_Int16>(nTabIndex) ;
2008 xPropSet->setPropertyValue("TabIndex", aTmp );
2009 }
2010
2012
2013 if( bDisabled )
2014 {
2015 xPropSet->setPropertyValue("Enabled", Any(false) );
2016 }
2017
2018 OSL_ENSURE( m_pFormImpl->GetText().isEmpty(), "Text is not empty!" );
2019
2020 if( !nCols )
2021 nCols = 20;
2022 if( !nRows )
2023 nRows = 1;
2024
2025 Size aTextSz( nCols, nRows );
2026
2027 SfxItemSet aCSS1ItemSet( m_xDoc->GetAttrPool(), m_pCSS1Parser->GetWhichMap() );
2028 SvxCSS1PropertyInfo aCSS1PropInfo;
2029 if( HasStyleOptions( aStyle, aId, aClass ) )
2030 {
2031 ParseStyleOptions( aStyle, aId, aClass, aCSS1ItemSet, aCSS1PropInfo );
2032 if( !aId.isEmpty() )
2033 InsertBookmark( aId );
2034 }
2035
2036 Size aSz( MINFLY, MINFLY );
2037 if( SVX_CSS1_LTYPE_TWIP== aCSS1PropInfo.m_eWidthType )
2038 {
2039 aSz.setWidth( convertTwipToMm100( aCSS1PropInfo.m_nWidth ) );
2040 aTextSz.setWidth( 0 );
2041 }
2042 if( SVX_CSS1_LTYPE_TWIP== aCSS1PropInfo.m_eHeightType )
2043 {
2044 aSz.setHeight( convertTwipToMm100( aCSS1PropInfo.m_nHeight ) );
2045 aTextSz.setHeight( 0 );
2046 }
2047 if( aSz.Width() < MINFLY )
2048 aSz.setWidth( MINFLY );
2049 if( aSz.Height() < MINFLY )
2050 aSz.setHeight( MINFLY );
2051
2052 uno::Reference< drawing::XShape > xShape = InsertControl( xFComp, xPropSet, aSz,
2053 text::VertOrientation::TOP, text::HoriOrientation::NONE,
2054 aCSS1ItemSet, aCSS1PropInfo,
2055 aMacroTable, aUnoMacroTable,
2056 aUnoMacroParamTable );
2057 if( aTextSz.Width() || aTextSz.Height() )
2058 SetControlSize( xShape, aTextSz, false, false );
2059
2060 // create new context
2061 std::unique_ptr<HTMLAttrContext> xCntxt(new HTMLAttrContext(HtmlTokenId::TEXTAREA_ON));
2062
2063 // temporarily disable PRE/Listing/XMP
2064 SplitPREListingXMP(xCntxt.get());
2065 PushContext(xCntxt);
2066
2067 m_bTextArea = true;
2068 m_bTAIgnoreNewPara = true;
2069}
2070
2072{
2073 OSL_ENSURE( m_bTextArea, "no TextArea or wrong type" );
2074 OSL_ENSURE( m_pFormImpl && m_pFormImpl->GetFCompPropSet().is(),
2075 "TextArea missing" );
2076
2077 const uno::Reference< beans::XPropertySet > & rPropSet =
2079
2080 Any aTmp;
2081 aTmp <<= m_pFormImpl->GetText();
2082 rPropSet->setPropertyValue("DefaultText", aTmp );
2084
2086
2087 // get context
2088 std::unique_ptr<HTMLAttrContext> xCntxt(PopContext(HtmlTokenId::TEXTAREA_ON));
2089 if (xCntxt)
2090 {
2091 // end attributes
2092 EndContext(xCntxt.get());
2093 }
2094
2095 m_bTextArea = false;
2096}
2097
2099{
2100 OSL_ENSURE( m_bTextArea, "no TextArea or wrong type" );
2101 OSL_ENSURE( m_pFormImpl && m_pFormImpl->GetFCompPropSet().is(),
2102 "TextArea missing" );
2103
2104 OUString& rText = m_pFormImpl->GetText();
2105 switch( nToken)
2106 {
2107 case HtmlTokenId::TEXTTOKEN:
2108 rText += aToken;
2109 break;
2110 case HtmlTokenId::NEWPARA:
2111 if( !m_bTAIgnoreNewPara )
2112 rText += "\n";
2113 break;
2114 default:
2115 rText += "<";
2116 rText += sSaveToken;
2117 if( !aToken.isEmpty() )
2118 {
2119 rText += " ";
2120 rText += aToken;
2121 }
2122 rText += ">";
2123 }
2124
2125 m_bTAIgnoreNewPara = false;
2126}
2127
2129{
2130 assert(m_vPendingStack.empty());
2131
2132 OSL_ENSURE( !m_bSelect, "Select in Select?" );
2133 OSL_ENSURE( !m_pFormImpl || !m_pFormImpl->GetFCompPropSet().is(),
2134 "Select in Control?" );
2135
2136 if( !m_pFormImpl || !m_pFormImpl->GetFormComps().is() )
2137 return;
2138
2139 OUString aId, aClass, aStyle;
2140 OUString sName;
2141 sal_Int32 nTabIndex = TABINDEX_MAX + 1;
2142 SvxMacroTableDtor aMacroTable;
2143 std::vector<OUString> aUnoMacroTable;
2144 std::vector<OUString> aUnoMacroParamTable;
2145 bool bMultiple = false;
2146 bool bDisabled = false;
2149 ScriptType eDfltScriptType = GetScriptType( pHeaderAttrs );
2150 const OUString& rDfltScriptType = GetScriptTypeString( pHeaderAttrs );
2151
2152 const HTMLOptions& rHTMLOptions = GetOptions();
2153 for (size_t i = rHTMLOptions.size(); i; )
2154 {
2155 const HTMLOption& rOption = rHTMLOptions[--i];
2156 ScriptType eScriptType2 = eDfltScriptType;
2157 SvMacroItemId nEvent = SvMacroItemId::NONE;
2158 bool bSetEvent = false;
2159
2160 switch( rOption.GetToken() )
2161 {
2162 case HtmlOptionId::ID:
2163 aId = rOption.GetString();
2164 break;
2165 case HtmlOptionId::STYLE:
2166 aStyle = rOption.GetString();
2167 break;
2168 case HtmlOptionId::CLASS:
2169 aClass = rOption.GetString();
2170 break;
2171 case HtmlOptionId::NAME:
2172 sName = rOption.GetString();
2173 break;
2174 case HtmlOptionId::MULTIPLE:
2175 bMultiple = true;
2176 break;
2177 case HtmlOptionId::DISABLED:
2178 bDisabled = true;
2179 break;
2180 case HtmlOptionId::SIZE:
2181 m_nSelectEntryCnt = o3tl::narrowing<sal_uInt16>(rOption.GetNumber());
2182 break;
2183
2184 case HtmlOptionId::TABINDEX:
2185 nTabIndex = rOption.GetSNumber();
2186 break;
2187
2188 case HtmlOptionId::SDONFOCUS:
2189 eScriptType2 = STARBASIC;
2190 [[fallthrough]];
2191 case HtmlOptionId::ONFOCUS:
2192 nEvent = SvMacroItemId::HtmlOnGetFocus;
2193 bSetEvent = true;
2194 break;
2195
2196 case HtmlOptionId::SDONBLUR:
2197 eScriptType2 = STARBASIC;
2198 [[fallthrough]];
2199 case HtmlOptionId::ONBLUR:
2200 nEvent = SvMacroItemId::HtmlOnLoseFocus;
2201 bSetEvent = true;
2202 break;
2203
2204 case HtmlOptionId::SDONCLICK:
2205 eScriptType2 = STARBASIC;
2206 [[fallthrough]];
2207 case HtmlOptionId::ONCLICK:
2208 nEvent = SvMacroItemId::HtmlOnClick;
2209 bSetEvent = true;
2210 break;
2211
2212 case HtmlOptionId::SDONCHANGE:
2213 eScriptType2 = STARBASIC;
2214 [[fallthrough]];
2215 case HtmlOptionId::ONCHANGE:
2216 nEvent = SvMacroItemId::HtmlOnChange;
2217 bSetEvent = true;
2218 break;
2219
2220 default:
2222 rOption.GetString(),
2223 aUnoMacroTable, aUnoMacroParamTable );
2224 break;
2225 }
2226
2227 if( bSetEvent )
2228 {
2229 OUString sEvent( rOption.GetString() );
2230 if( !sEvent.isEmpty() )
2231 {
2232 sEvent = convertLineEnd(sEvent, GetSystemLineEnd());
2233 if( EXTENDED_STYPE==eScriptType2 )
2234 m_aScriptType = rDfltScriptType;
2235 aMacroTable.Insert( nEvent, SvxMacro( sEvent, m_aScriptType, eScriptType2 ) );
2236 }
2237 }
2238 }
2239
2240 const uno::Reference< lang::XMultiServiceFactory > & rSrvcMgr =
2242 if( !rSrvcMgr.is() )
2243 {
2244 FinishTextArea();
2245 return;
2246 }
2247 uno::Reference< uno::XInterface > xInt = rSrvcMgr->createInstance(
2248 "com.sun.star.form.component.ListBox" );
2249 if( !xInt.is() )
2250 {
2251 FinishTextArea();
2252 return;
2253 }
2254
2255 uno::Reference< XFormComponent > xFComp( xInt, UNO_QUERY );
2256 OSL_ENSURE(xFComp.is(), "no FormComponent?");
2257
2258 uno::Reference< beans::XPropertySet > xPropSet( xFComp, UNO_QUERY );
2259
2260 Any aTmp;
2261 aTmp <<= sName;
2262 xPropSet->setPropertyValue("Name", aTmp );
2263
2264 if( nTabIndex >= TABINDEX_MIN && nTabIndex <= TABINDEX_MAX )
2265 {
2266 aTmp <<= static_cast<sal_Int16>(nTabIndex) ;
2267 xPropSet->setPropertyValue("TabIndex", aTmp );
2268 }
2269
2270 if( bDisabled )
2271 {
2272 xPropSet->setPropertyValue("Enabled", Any(false) );
2273 }
2274
2275 Size aTextSz( 0, 0 );
2276 bool bMinWidth = true, bMinHeight = true;
2277 if( !bMultiple && 1==m_nSelectEntryCnt )
2278 {
2279 xPropSet->setPropertyValue("Dropdown", Any(true) );
2280 }
2281 else
2282 {
2283 if( m_nSelectEntryCnt <= 1 ) // 4 lines is default
2285
2286 if( bMultiple )
2287 {
2288 xPropSet->setPropertyValue("MultiSelection", Any(true) );
2289 }
2290 aTextSz.setHeight( m_nSelectEntryCnt );
2291 bMinHeight = false;
2292 }
2293
2294 SfxItemSet aCSS1ItemSet( m_xDoc->GetAttrPool(), m_pCSS1Parser->GetWhichMap() );
2295 SvxCSS1PropertyInfo aCSS1PropInfo;
2296 if( HasStyleOptions( aStyle, aId, aClass ) )
2297 {
2298 ParseStyleOptions( aStyle, aId, aClass, aCSS1ItemSet, aCSS1PropInfo );
2299 if( !aId.isEmpty() )
2300 InsertBookmark( aId );
2301 }
2302
2303 Size aSz( MINFLY, MINFLY );
2304 m_bFixSelectWidth = true;
2305 if( SVX_CSS1_LTYPE_TWIP== aCSS1PropInfo.m_eWidthType )
2306 {
2307 aSz.setWidth( convertTwipToMm100( aCSS1PropInfo.m_nWidth ) );
2308 m_bFixSelectWidth = false;
2309 bMinWidth = false;
2310 }
2311 if( SVX_CSS1_LTYPE_TWIP== aCSS1PropInfo.m_eHeightType )
2312 {
2313 aSz.setHeight( convertTwipToMm100( aCSS1PropInfo.m_nHeight ) );
2314 aTextSz.setHeight( 0 );
2315 bMinHeight = false;
2316 }
2317 if( aSz.Width() < MINFLY )
2318 aSz.setWidth( MINFLY );
2319 if( aSz.Height() < MINFLY )
2320 aSz.setHeight( MINFLY );
2321
2322 uno::Reference< drawing::XShape > xShape = InsertControl( xFComp, xPropSet, aSz,
2323 text::VertOrientation::TOP, text::HoriOrientation::NONE,
2324 aCSS1ItemSet, aCSS1PropInfo,
2325 aMacroTable, aUnoMacroTable,
2326 aUnoMacroParamTable );
2327 if( m_bFixSelectWidth )
2328 m_pFormImpl->SetShape( xShape );
2329 if( aTextSz.Height() || bMinWidth || bMinHeight )
2330 SetControlSize( xShape, aTextSz, bMinWidth, bMinHeight );
2331
2332 // create new context
2333 std::unique_ptr<HTMLAttrContext> xCntxt(new HTMLAttrContext(HtmlTokenId::SELECT_ON));
2334
2335 // temporarily disable PRE/Listing/XMP
2336 SplitPREListingXMP(xCntxt.get());
2337 PushContext(xCntxt);
2338
2339 m_bSelect = true;
2340}
2341
2343{
2344 assert(m_vPendingStack.empty());
2345
2346 OSL_ENSURE( m_bSelect, "no Select" );
2347 OSL_ENSURE( m_pFormImpl && m_pFormImpl->GetFCompPropSet().is(),
2348 "no select control" );
2349
2350 const uno::Reference< beans::XPropertySet > & rPropSet =
2352
2353 size_t nEntryCnt = m_pFormImpl->GetStringList().size();
2354 if(!m_pFormImpl->GetStringList().empty())
2355 {
2356 Sequence<OUString> aList( static_cast<sal_Int32>(nEntryCnt) );
2357 Sequence<OUString> aValueList( static_cast<sal_Int32>(nEntryCnt) );
2358 OUString *pStrings = aList.getArray();
2359 OUString *pValues = aValueList.getArray();
2360
2361 for(size_t i = 0; i < nEntryCnt; ++i)
2362 {
2363 OUString sText(m_pFormImpl->GetStringList()[i]);
2364 sText = comphelper::string::stripEnd(sText, ' ');
2365 pStrings[i] = sText;
2366
2367 sText = m_pFormImpl->GetValueList()[i];
2368 pValues[i] = sText;
2369 }
2370
2371 rPropSet->setPropertyValue("StringItemList", Any(aList) );
2372
2373 rPropSet->setPropertyValue("ListSourceType", Any(ListSourceType_VALUELIST) );
2374
2375 rPropSet->setPropertyValue("ListSource", Any(aValueList) );
2376
2377 size_t nSelCnt = m_pFormImpl->GetSelectedList().size();
2378 if( !nSelCnt && 1 == m_nSelectEntryCnt && nEntryCnt )
2379 {
2380 // In a dropdown list an entry should always be selected.
2381 m_pFormImpl->GetSelectedList().insert( m_pFormImpl->GetSelectedList().begin(), 0 );
2382 nSelCnt = 1;
2383 }
2384 Sequence<sal_Int16> aSelList( static_cast<sal_Int32>(nSelCnt) );
2385 sal_Int16 *pSels = aSelList.getArray();
2386 for(size_t i = 0; i < nSelCnt; ++i)
2387 {
2388 pSels[i] = static_cast<sal_Int16>(m_pFormImpl->GetSelectedList()[i]);
2389 }
2390 rPropSet->setPropertyValue("DefaultSelection", Any(aSelList) );
2391
2394 }
2395
2397
2398 if( m_bFixSelectWidth )
2399 {
2400 OSL_ENSURE( m_pFormImpl->GetShape().is(), "Shape not saved" );
2401 Size aTextSz( -1, 0 );
2402 SetControlSize( m_pFormImpl->GetShape(), aTextSz, false, false );
2403 }
2404
2406
2407 // get context
2408 std::unique_ptr<HTMLAttrContext> xCntxt(PopContext(HtmlTokenId::SELECT_ON));
2409 if (xCntxt)
2410 {
2411 // close attributes
2412 EndContext(xCntxt.get());
2413 }
2414
2415 m_bSelect = false;
2416}
2417
2419{
2420 OSL_ENSURE( m_bSelect, "no Select" );
2421 OSL_ENSURE( m_pFormImpl && m_pFormImpl->GetFCompPropSet().is(),
2422 "no Select-Control" );
2423
2424 m_bLBEntrySelected = false;
2425 OUString aValue;
2426
2427 const HTMLOptions& rHTMLOptions = GetOptions();
2428 for (size_t i = rHTMLOptions.size(); i; )
2429 {
2430 const HTMLOption& rOption = rHTMLOptions[--i];
2431 switch( rOption.GetToken() )
2432 {
2433 case HtmlOptionId::ID:
2434 // leave out for now
2435 break;
2436 case HtmlOptionId::SELECTED:
2437 m_bLBEntrySelected = true;
2438 break;
2439 case HtmlOptionId::VALUE:
2440 aValue = rOption.GetString();
2441 if( aValue.isEmpty() )
2442 aValue = "$$$empty$$$";
2443 break;
2444 default: break;
2445 }
2446 }
2447
2448 sal_uInt16 nEntryCnt = m_pFormImpl->GetStringList().size();
2449 m_pFormImpl->GetStringList().push_back(OUString());
2450 m_pFormImpl->GetValueList().push_back(aValue);
2451 if( m_bLBEntrySelected )
2452 {
2453 m_pFormImpl->GetSelectedList().push_back( nEntryCnt );
2454 }
2455}
2456
2458{
2459 OSL_ENSURE( m_bSelect, "no select" );
2460 OSL_ENSURE( m_pFormImpl && m_pFormImpl->GetFCompPropSet().is(),
2461 "no select control" );
2462
2463 if(m_pFormImpl->GetStringList().empty())
2464 return;
2465
2466 OUString& rText = m_pFormImpl->GetStringList().back();
2467
2468 if( !aToken.isEmpty() && ' '==aToken[ 0 ] )
2469 {
2470 sal_Int32 nLen = rText.getLength();
2471 if( !nLen || ' '==rText[nLen-1])
2472 aToken.remove( 0, 1 );
2473 }
2474 if( !aToken.isEmpty() )
2475 rText += aToken;
2476}
2477
2478/* 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)
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
tools::Long GetRight() const
tools::Long GetLeft() const
void SetTextFirstLineOffset(const short nF, const sal_uInt16 nProp=100)
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:195
SwNode * GetAnchorNode() const
Definition: atrfrm.cxx:1606
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:62
SdrObject * FindSdrObject()
Definition: frmfmt.hxx:141
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:402
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:424
void PushContext(std::unique_ptr< HTMLAttrContext > &rCntxt)
Definition: swhtml.hxx:579
void NewTextArea()
Definition: htmlform.cxx:1846
bool m_bSelect
Definition: swhtml.hxx:467
std::unique_ptr< HTMLAttrContext > PopContext(HtmlTokenId nToken=HtmlTokenId::NONE)
Definition: htmlcss1.cxx:2100
bool m_bRemoveHidden
Definition: swhtml.hxx:471
SwHTMLForm_Impl * m_pFormImpl
Definition: swhtml.hxx:403
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:1358
void EndSelect()
Definition: htmlform.cxx:2342
void NewSelect()
Definition: htmlform.cxx:2128
OUString m_aPathToFile
Definition: swhtml.hxx:360
bool m_bTAIgnoreNewPara
Definition: swhtml.hxx:451
OUString m_aScriptType
Definition: swhtml.hxx:365
SwViewShell * CallStartAction(SwViewShell *pVSh=nullptr, bool bChkPtr=true)
Definition: swhtml.cxx:2636
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:1019
ImplSVEvent * m_nEventId
Definition: swhtml.hxx:413
SwPaM * m_pPam
Definition: swhtml.hxx:397
rtl::Reference< SwDoc > m_xDoc
Definition: swhtml.hxx:396
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:1838
void InsertSelectOption()
Definition: htmlform.cxx:2418
std::unique_ptr< SwCSS1Parser > m_pCSS1Parser
Definition: swhtml.hxx:392
void AddParSpace()
Definition: swhtml.cxx:2494
void InsertSelectText()
Definition: htmlform.cxx:2457
void SplitPREListingXMP(HTMLAttrContext *pCntxt)
Definition: htmlctxt.cxx:752
void NotifyMacroEventRead()
Definition: htmlgrin.cxx:1562
std::vector< SwPending > m_vPendingStack
Definition: swhtml.hxx:394
SfxViewFrame * m_pTempViewFrame
Definition: swhtml.hxx:486
bool AppendTextNode(SwHTMLAppendMode eMode=AM_NORMAL, bool bUpdateNum=true)
Definition: swhtml.cxx:2192
void EndTextArea()
Definition: htmlform.cxx:2071
void InsertTextAreaText(HtmlTokenId nToken)
Definition: htmlform.cxx:2098
void EndContext(HTMLAttrContext *pContext)
Definition: htmlctxt.cxx:372
bool m_bTextArea
Definition: swhtml.hxx:465
sal_uInt16 IncGrfsThatResizeTable()
Definition: htmltab.cxx:3181
void InsertInput()
Definition: htmlform.cxx:1374
bool m_bLBEntrySelected
Definition: swhtml.hxx:450
bool m_bFixSelectWidth
Definition: swhtml.hxx:464
OUString m_sBaseURL
Definition: swhtml.hxx:361
void DeleteFormImpl()
Definition: htmlform.cxx:588
void NewForm(bool bAppend=true)
Definition: htmlform.cxx:1193
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:187
const SwPosition * GetPoint() const
Definition: pam.hxx:261
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:185
SwHTMLTableLayout * GetHTMLTableLayout()
Definition: swtable.hxx:180
vcl::Window * GetWin() const
Definition: viewsh.hxx:346
SdrView * GetDrawView()
Definition: vnew.cxx:373
SwFrameFormat * GetFrameFormat() const
Definition: unodraw.hxx:255
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
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< SvxULSpaceItem > RES_UL_SPACE(92)
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(159)
constexpr TypedWhichId< SvxPostureItem > RES_CHRATR_POSTURE(11)
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_FONT(7)
constexpr TypedWhichId< SvxLRSpaceItem > RES_LR_SPACE(91)
constexpr TypedWhichId< SvxColorItem > RES_CHRATR_COLOR(3)
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(105)
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
const char * sName
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:80
sal_Int32 GetContentIndex() const
Definition: pam.hxx:84
@ 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:204
constexpr tools::Long HTML_DFLT_IMG_WIDTH
Definition: swhtml.hxx:68
#define MINLAY
Definition: swtypes.hxx:62
#define MINFLY
Definition: swtypes.hxx:61