Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <hintids.hxx>
21 : #include <comphelper/string.hxx>
22 : #include <vcl/svapp.hxx>
23 : #include <vcl/wrkwin.hxx>
24 :
25 : #include <toolkit/helper/vclunohelper.hxx>
26 : #include <svtools/htmlkywd.hxx>
27 : #include <svtools/htmltokn.h>
28 : #include <svl/urihelper.hxx>
29 : #include <sfx2/request.hxx>
30 : #include <sfx2/docfile.hxx>
31 : #include <sfx2/viewfrm.hxx>
32 : #include <editeng/lrspitem.hxx>
33 : #include <editeng/ulspitem.hxx>
34 : #include <editeng/brushitem.hxx>
35 : #include <editeng/colritem.hxx>
36 : #include <editeng/fontitem.hxx>
37 : #include <editeng/fhgtitem.hxx>
38 : #include <editeng/wghtitem.hxx>
39 : #include <editeng/postitem.hxx>
40 : #include <editeng/udlnitem.hxx>
41 : #include <editeng/crossedoutitem.hxx>
42 : #include <svx/svdouno.hxx>
43 : #include <svx/fmglob.hxx>
44 : #include <com/sun/star/form/ListSourceType.hpp>
45 : #include <com/sun/star/form/FormButtonType.hpp>
46 : #include <com/sun/star/form/FormSubmitEncoding.hpp>
47 : #include <com/sun/star/form/FormSubmitMethod.hpp>
48 : #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
49 : #include <com/sun/star/script/XEventAttacherManager.hpp>
50 : #include <com/sun/star/text/WrapTextMode.hpp>
51 : #include <com/sun/star/text/HoriOrientation.hpp>
52 : #include <com/sun/star/text/VertOrientation.hpp>
53 : #include <com/sun/star/text/TextContentAnchorType.hpp>
54 : #include <com/sun/star/container/XIndexContainer.hpp>
55 : #include <com/sun/star/drawing/XControlShape.hpp>
56 : #include <com/sun/star/awt/XTextLayoutConstrains.hpp>
57 : #include <com/sun/star/awt/XLayoutConstrains.hpp>
58 : #include <com/sun/star/awt/XImageConsumer.hpp>
59 : #include <com/sun/star/awt/ImageStatus.hpp>
60 : #include <com/sun/star/form/XImageProducerSupplier.hpp>
61 : #include <com/sun/star/form/XForm.hpp>
62 : #include <doc.hxx>
63 : #include <pam.hxx>
64 : #include <swtable.hxx>
65 : #include <fmtanchr.hxx>
66 : #include <htmltbl.hxx>
67 : #include <docsh.hxx>
68 : #include <viewsh.hxx>
69 : #include <unodraw.hxx>
70 : #include <unotextrange.hxx>
71 : #include "dcontact.hxx"
72 :
73 : #include "swcss1.hxx"
74 : #include "swhtml.hxx"
75 : #include "htmlform.hxx"
76 :
77 : using namespace ::com::sun::star;
78 : using namespace ::com::sun::star::uno;
79 : using namespace ::com::sun::star::lang;
80 : using namespace ::com::sun::star::form;
81 :
82 : const sal_uInt16 TABINDEX_MIN = 0;
83 : const sal_uInt16 TABINDEX_MAX = 32767;
84 :
85 : static HTMLOptionEnum aHTMLFormMethodTable[] =
86 : {
87 : { OOO_STRING_SVTOOLS_HTML_METHOD_get, FormSubmitMethod_GET },
88 : { OOO_STRING_SVTOOLS_HTML_METHOD_post, FormSubmitMethod_POST },
89 : { 0, 0 }
90 : };
91 :
92 : static HTMLOptionEnum aHTMLFormEncTypeTable[] =
93 : {
94 : { OOO_STRING_SVTOOLS_HTML_ET_url, FormSubmitEncoding_URL },
95 : { OOO_STRING_SVTOOLS_HTML_ET_multipart, FormSubmitEncoding_MULTIPART },
96 : { OOO_STRING_SVTOOLS_HTML_ET_text, FormSubmitEncoding_TEXT },
97 : { 0, 0 }
98 : };
99 :
100 : enum HTMLWordWrapMode { HTML_WM_OFF, HTML_WM_HARD, HTML_WM_SOFT };
101 :
102 : static HTMLOptionEnum aHTMLTextAreaWrapTable[] =
103 : {
104 : { OOO_STRING_SVTOOLS_HTML_WW_off, HTML_WM_OFF },
105 : { OOO_STRING_SVTOOLS_HTML_WW_hard, HTML_WM_HARD },
106 : { OOO_STRING_SVTOOLS_HTML_WW_soft, HTML_WM_SOFT },
107 : { OOO_STRING_SVTOOLS_HTML_WW_physical,HTML_WM_HARD },
108 : { OOO_STRING_SVTOOLS_HTML_WW_virtual, HTML_WM_SOFT },
109 : { 0, 0 }
110 : };
111 :
112 : HTMLEventType aEventTypeTable[] =
113 : {
114 : HTML_ET_ONSUBMITFORM,
115 : HTML_ET_ONRESETFORM,
116 : HTML_ET_ONGETFOCUS,
117 : HTML_ET_ONLOSEFOCUS,
118 : HTML_ET_ONCLICK,
119 : HTML_ET_ONCLICK_ITEM,
120 : HTML_ET_ONCHANGE,
121 : HTML_ET_ONSELECT,
122 : HTML_ET_END
123 : };
124 :
125 : const sal_Char * aEventListenerTable[] =
126 : {
127 : "XSubmitListener",
128 : "XResetListener",
129 : "XFocusListener",
130 : "XFocusListener",
131 : "XApproveActionListener",
132 : "XItemListener",
133 : "XChangeListener",
134 : ""
135 : };
136 :
137 : const sal_Char * aEventMethodTable[] =
138 : {
139 : "approveSubmit",
140 : "approveReset",
141 : "focusGained",
142 : "focusLost",
143 : "approveAction",
144 : "itemStateChanged",
145 : "changed",
146 : ""
147 : };
148 :
149 : const sal_Char * aEventSDOptionTable[] =
150 : {
151 : OOO_STRING_SVTOOLS_HTML_O_SDonsubmit,
152 : OOO_STRING_SVTOOLS_HTML_O_SDonreset,
153 : OOO_STRING_SVTOOLS_HTML_O_SDonfocus,
154 : OOO_STRING_SVTOOLS_HTML_O_SDonblur,
155 : OOO_STRING_SVTOOLS_HTML_O_SDonclick,
156 : OOO_STRING_SVTOOLS_HTML_O_SDonclick,
157 : OOO_STRING_SVTOOLS_HTML_O_SDonchange,
158 : 0
159 : };
160 :
161 : const sal_Char * aEventOptionTable[] =
162 : {
163 : OOO_STRING_SVTOOLS_HTML_O_onsubmit,
164 : OOO_STRING_SVTOOLS_HTML_O_onreset,
165 : OOO_STRING_SVTOOLS_HTML_O_onfocus,
166 : OOO_STRING_SVTOOLS_HTML_O_onblur,
167 : OOO_STRING_SVTOOLS_HTML_O_onclick,
168 : OOO_STRING_SVTOOLS_HTML_O_onclick,
169 : OOO_STRING_SVTOOLS_HTML_O_onchange,
170 : 0
171 : };
172 :
173 1 : class SwHTMLForm_Impl
174 : {
175 : SwDocShell *pDocSh;
176 :
177 : SvKeyValueIterator *pHeaderAttrs;
178 :
179 : // gecachte Interfaces
180 : uno::Reference< drawing::XDrawPage > xDrawPage;
181 : uno::Reference< container::XIndexContainer > xForms;
182 : uno::Reference< drawing::XShapes > xShapes;
183 : uno::Reference< XMultiServiceFactory > xServiceFactory;
184 :
185 : uno::Reference< script::XEventAttacherManager > xControlEventManager;
186 : uno::Reference< script::XEventAttacherManager > xFormEventManager;
187 :
188 : // Kontext-Informationen
189 : uno::Reference< container::XIndexContainer > xFormComps;
190 : uno::Reference< beans::XPropertySet > xFCompPropSet;
191 : uno::Reference< drawing::XShape > xShape;
192 :
193 : OUString sText;
194 : std::vector<OUString> aStringList;
195 : std::vector<OUString> aValueList;
196 : std::vector<sal_uInt16> aSelectedList;
197 :
198 : public:
199 1 : SwHTMLForm_Impl( SwDocShell *pDSh ) :
200 : pDocSh( pDSh ),
201 1 : pHeaderAttrs( pDSh ? pDSh->GetHeaderAttributes() : 0 )
202 : {
203 : OSL_ENSURE( pDocSh, "Keine DocShell, keine Controls" );
204 1 : }
205 :
206 : const uno::Reference< XMultiServiceFactory >& GetServiceFactory();
207 : const uno::Reference< drawing::XDrawPage >& GetDrawPage();
208 : const uno::Reference< drawing::XShapes >& GetShapes();
209 : const uno::Reference< script::XEventAttacherManager >& GetControlEventManager();
210 : const uno::Reference< script::XEventAttacherManager >& GetFormEventManager();
211 : const uno::Reference< container::XIndexContainer >& GetForms();
212 :
213 11 : const uno::Reference< container::XIndexContainer >& GetFormComps() const
214 : {
215 11 : return xFormComps;
216 : }
217 :
218 2 : void SetFormComps( const uno::Reference< container::XIndexContainer >& r )
219 : {
220 2 : xFormComps = r;
221 2 : }
222 :
223 2 : void ReleaseFormComps() { xFormComps = 0; xControlEventManager = 0; }
224 :
225 0 : const uno::Reference< beans::XPropertySet >& GetFCompPropSet() const
226 : {
227 0 : return xFCompPropSet;
228 : }
229 :
230 0 : void SetFCompPropSet( const uno::Reference< beans::XPropertySet >& r )
231 : {
232 0 : xFCompPropSet = r;
233 0 : }
234 :
235 0 : void ReleaseFCompPropSet() { xFCompPropSet = 0; }
236 :
237 0 : const uno::Reference< drawing::XShape >& GetShape() const { return xShape; }
238 0 : void SetShape( const uno::Reference< drawing::XShape >& r ) { xShape = r; }
239 : void ReleaseShape() { xShape = 0; }
240 :
241 0 : OUString& GetText() { return sText; }
242 0 : void EraseText() { sText = aEmptyOUStr; }
243 :
244 0 : std::vector<OUString>& GetStringList() { return aStringList; }
245 0 : void EraseStringList()
246 : {
247 0 : aStringList.clear();
248 0 : }
249 :
250 0 : std::vector<OUString>& GetValueList() { return aValueList; }
251 0 : void EraseValueList()
252 : {
253 0 : aValueList.clear();
254 0 : }
255 :
256 0 : std::vector<sal_uInt16>& GetSelectedList() { return aSelectedList; }
257 0 : void EraseSelectedList()
258 : {
259 0 : aSelectedList.clear();
260 0 : }
261 :
262 6 : SvKeyValueIterator *GetHeaderAttrs() const { return pHeaderAttrs; }
263 : };
264 :
265 8 : const uno::Reference< XMultiServiceFactory >& SwHTMLForm_Impl::GetServiceFactory()
266 : {
267 8 : if( !xServiceFactory.is() && pDocSh )
268 : {
269 2 : xServiceFactory =
270 : uno::Reference< XMultiServiceFactory >( pDocSh->GetBaseModel(),
271 1 : UNO_QUERY );
272 : OSL_ENSURE( xServiceFactory.is(),
273 : "XServiceFactory nicht vom Model erhalten" );
274 : }
275 8 : return xServiceFactory;
276 : }
277 :
278 2 : const uno::Reference< drawing::XDrawPage >& SwHTMLForm_Impl::GetDrawPage()
279 : {
280 2 : if( !xDrawPage.is() && pDocSh )
281 : {
282 : uno::Reference< drawing::XDrawPageSupplier > xTxtDoc( pDocSh->GetBaseModel(),
283 1 : UNO_QUERY );
284 : OSL_ENSURE( xTxtDoc.is(),
285 : "drawing::XDrawPageSupplier nicht vom XModel erhalten" );
286 1 : xDrawPage = xTxtDoc->getDrawPage();
287 1 : OSL_ENSURE( xDrawPage.is(), "drawing::XDrawPage nicht erhalten" );
288 : }
289 2 : return xDrawPage;
290 : }
291 :
292 2 : const uno::Reference< container::XIndexContainer >& SwHTMLForm_Impl::GetForms()
293 : {
294 2 : if( !xForms.is() )
295 : {
296 1 : GetDrawPage();
297 1 : if( xDrawPage.is() )
298 : {
299 1 : uno::Reference< XFormsSupplier > xFormsSupplier( xDrawPage, UNO_QUERY );
300 : OSL_ENSURE( xFormsSupplier.is(),
301 : "XFormsSupplier nicht vom drawing::XDrawPage erhalten" );
302 :
303 : uno::Reference< container::XNameContainer > xNameCont =
304 2 : xFormsSupplier->getForms();
305 2 : xForms = uno::Reference< container::XIndexContainer >( xNameCont,
306 1 : UNO_QUERY );
307 :
308 1 : OSL_ENSURE( xForms.is(), "XForms nicht erhalten" );
309 : }
310 : }
311 2 : return xForms;
312 : }
313 :
314 2 : const uno::Reference< drawing::XShapes > & SwHTMLForm_Impl::GetShapes()
315 : {
316 2 : if( !xShapes.is() )
317 : {
318 1 : GetDrawPage();
319 1 : if( xDrawPage.is() )
320 : {
321 1 : xShapes = uno::Reference< drawing::XShapes >( xDrawPage, UNO_QUERY );
322 : OSL_ENSURE( xShapes.is(),
323 : "XShapes nicht vom drawing::XDrawPage erhalten" );
324 : }
325 : }
326 2 : return xShapes;
327 : }
328 :
329 : const uno::Reference< script::XEventAttacherManager >&
330 0 : SwHTMLForm_Impl::GetControlEventManager()
331 : {
332 0 : if( !xControlEventManager.is() && xFormComps.is() )
333 : {
334 0 : xControlEventManager =
335 0 : uno::Reference< script::XEventAttacherManager >( xFormComps, UNO_QUERY );
336 : OSL_ENSURE( xControlEventManager.is(),
337 : "uno::Reference< XEventAttacherManager > nicht von xFormComps erhalten" );
338 : }
339 :
340 0 : return xControlEventManager;
341 : }
342 :
343 : const uno::Reference< script::XEventAttacherManager >&
344 0 : SwHTMLForm_Impl::GetFormEventManager()
345 : {
346 0 : if( !xFormEventManager.is() )
347 : {
348 0 : GetForms();
349 0 : if( xForms.is() )
350 : {
351 0 : xFormEventManager =
352 0 : uno::Reference< script::XEventAttacherManager >( xForms, UNO_QUERY );
353 : OSL_ENSURE( xFormEventManager.is(),
354 : "uno::Reference< XEventAttacherManager > nicht von xForms erhalten" );
355 : }
356 : }
357 :
358 0 : return xFormEventManager;
359 : }
360 :
361 : class SwHTMLImageWatcher :
362 : public cppu::WeakImplHelper2< awt::XImageConsumer, XEventListener >
363 : {
364 : uno::Reference< drawing::XShape > xShape; // das control
365 : uno::Reference< XImageProducerSupplier > xSrc;
366 : uno::Reference< awt::XImageConsumer > xThis; // man selbst
367 : sal_Bool bSetWidth;
368 : sal_Bool bSetHeight;
369 :
370 : void clear();
371 :
372 : public:
373 : SwHTMLImageWatcher( const uno::Reference< drawing::XShape > & rShape,
374 : sal_Bool bWidth, sal_Bool bHeight );
375 : virtual ~SwHTMLImageWatcher();
376 :
377 : // startProduction darf nicht im Konstruktor gerufen werden, weil
378 : // wir und ggf. selbst zerstoeren ... Deshlab eine eigene Methode.
379 0 : void start() { xSrc->getImageProducer()->startProduction(); }
380 :
381 : // UNO Anbindung
382 :
383 : // XImageConsumer
384 : virtual void SAL_CALL init( sal_Int32 Width, sal_Int32 Height)
385 : throw( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
386 : virtual void SAL_CALL setColorModel(
387 : sal_Int16 BitCount, const uno::Sequence< sal_Int32 >& RGBAPal,
388 : sal_Int32 RedMask, sal_Int32 GreenMask, sal_Int32 BlueMask,
389 : sal_Int32 AlphaMask)
390 : throw( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
391 : virtual void SAL_CALL setPixelsByBytes(
392 : sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height,
393 : const uno::Sequence< sal_Int8 >& ProducerData,
394 : sal_Int32 Offset, sal_Int32 Scansize)
395 : throw( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
396 : virtual void SAL_CALL setPixelsByLongs(
397 : sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height,
398 : const uno::Sequence< sal_Int32 >& ProducerData,
399 : sal_Int32 Offset, sal_Int32 Scansize)
400 : throw( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
401 : virtual void SAL_CALL complete(
402 : sal_Int32 Status,
403 : const uno::Reference< awt::XImageProducer > & Producer)
404 : throw( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
405 :
406 : // XEventListener
407 : virtual void SAL_CALL disposing( const EventObject& Source ) throw ( uno::RuntimeException, std::exception) SAL_OVERRIDE;
408 : };
409 :
410 0 : SwHTMLImageWatcher::SwHTMLImageWatcher(
411 : const uno::Reference< drawing::XShape >& rShape,
412 : sal_Bool bWidth, sal_Bool bHeight ) :
413 : xShape( rShape ),
414 0 : bSetWidth( bWidth ), bSetHeight( bHeight )
415 : {
416 : // Die Quelle des Images merken
417 0 : uno::Reference< drawing::XControlShape > xControlShape( xShape, UNO_QUERY );
418 : uno::Reference< awt::XControlModel > xControlModel(
419 0 : xControlShape->getControl() );
420 0 : xSrc = uno::Reference< XImageProducerSupplier >( xControlModel, UNO_QUERY );
421 : OSL_ENSURE( xSrc.is(), "Kein XImageProducerSupplier" );
422 :
423 : // Als Event-Listener am Shape anmelden, damit wir es beim dispose
424 : // loslassen ko"onnen ...
425 0 : uno::Reference< XEventListener > xEvtLstnr = (XEventListener *)this;
426 0 : uno::Reference< XComponent > xComp( xShape, UNO_QUERY );
427 0 : xComp->addEventListener( xEvtLstnr );
428 :
429 : // Zum Schluss halten wir noch eine Referenz auf uns selbst, damit
430 : // wir am Leben bleiben ... (eigentlich sollte das nicht neotig sein,
431 : // weil wir ja noch an diversen anderen Stellen angemeldet sind)
432 0 : xThis = (awt::XImageConsumer *)this;
433 :
434 : // und am ImageProducer anmelden, um die Groesse zu erehalten ...
435 0 : xSrc->getImageProducer()->addConsumer( xThis );
436 0 : }
437 :
438 0 : SwHTMLImageWatcher::~SwHTMLImageWatcher()
439 : {
440 0 : }
441 :
442 0 : void SwHTMLImageWatcher::clear()
443 : {
444 : // Am Shape als Event-Listener abmelden
445 0 : uno::Reference< XEventListener > xEvtLstnr = (XEventListener *)this;
446 0 : uno::Reference< XComponent > xComp( xShape, UNO_QUERY );
447 0 : xComp->removeEventListener( xEvtLstnr );
448 :
449 : // Am ImageProducer abmelden
450 0 : uno::Reference<awt::XImageProducer> xProd = xSrc->getImageProducer();
451 0 : if( xProd.is() )
452 0 : xProd->removeConsumer( xThis );
453 0 : }
454 :
455 0 : void SwHTMLImageWatcher::init( sal_Int32 Width, sal_Int32 Height )
456 : throw( uno::RuntimeException, std::exception )
457 : {
458 : OSL_ENSURE( bSetWidth || bSetHeight,
459 : "Breite oder Hoehe muss angepasst werden" );
460 :
461 : // Wenn keine Breite oder Hoehe angegeben ist, ist das das init von
462 : // der leeren Grafik, die angezeigt wird, bevor der Stream einer
463 : // asynchron anzuzeigenden Grfik verfuegbar ist.
464 0 : if( !Width && !Height )
465 0 : return;
466 :
467 0 : awt::Size aNewSz;
468 0 : aNewSz.Width = Width;
469 0 : aNewSz.Height = Height;
470 0 : if( Application::GetDefaultDevice() )
471 : {
472 0 : Size aTmp(aNewSz.Width, aNewSz.Height);
473 : aTmp = Application::GetDefaultDevice()
474 0 : ->PixelToLogic( aTmp, MapMode( MAP_100TH_MM ) );
475 0 : aNewSz.Width = aTmp.Width();
476 0 : aNewSz.Height = aTmp.Height();
477 : }
478 :
479 0 : if( !bSetWidth || !bSetHeight )
480 : {
481 0 : awt::Size aSz( xShape->getSize() );
482 0 : if( bSetWidth && aNewSz.Height )
483 : {
484 0 : aNewSz.Width *= aSz.Height;
485 0 : aNewSz.Width /= aNewSz.Height;
486 0 : aNewSz.Height = aSz.Height;
487 : }
488 0 : if( bSetHeight && aNewSz.Width )
489 : {
490 0 : aNewSz.Height *= aSz.Width;
491 0 : aNewSz.Height /= aNewSz.Width;
492 0 : aNewSz.Width = aSz.Width;
493 : }
494 : }
495 0 : if( aNewSz.Width < MINFLY )
496 0 : aNewSz.Width = MINFLY;
497 0 : if( aNewSz.Height < MINFLY )
498 0 : aNewSz.Height = MINFLY;
499 :
500 0 : xShape->setSize( aNewSz );
501 0 : if( bSetWidth )
502 : {
503 : // Wenn das Control in einer Tabelle verankert ist, muesen
504 : // die Tabellen-Spalten neu berechnet werden
505 :
506 : // Um an den SwXShape* zu gelangen, brauchen wir ein Interface,
507 : // das auch vom SwXShape implementiert wird.
508 :
509 0 : uno::Reference< beans::XPropertySet > xPropSet( xShape, UNO_QUERY );
510 0 : uno::Reference< XUnoTunnel> xTunnel( xPropSet, UNO_QUERY );
511 0 : SwXShape *pSwShape = xTunnel.is() ?
512 : reinterpret_cast< SwXShape * >( sal::static_int_cast< sal_IntPtr>(
513 0 : xTunnel->getSomething(SwXShape::getUnoTunnelId()) ))
514 0 : : 0;
515 :
516 : OSL_ENSURE( pSwShape, "Wo ist das SW-Shape?" );
517 0 : if( pSwShape )
518 : {
519 0 : SwFrmFmt *pFrmFmt = pSwShape->GetFrmFmt();
520 :
521 0 : const SwDoc *pDoc = pFrmFmt->GetDoc();
522 0 : const SwPosition* pAPos = pFrmFmt->GetAnchor().GetCntntAnchor();
523 : SwNode *pANd;
524 : SwTableNode *pTblNd;
525 0 : if( pAPos &&
526 0 : 0 != (pANd = & pAPos->nNode.GetNode()) &&
527 : 0 != (pTblNd = pANd->FindTableNode()) )
528 : {
529 0 : const sal_Bool bLastGrf = !pTblNd->GetTable().DecGrfsThatResize();
530 : SwHTMLTableLayout *pLayout =
531 0 : pTblNd->GetTable().GetHTMLTableLayout();
532 0 : if( pLayout )
533 : {
534 : const sal_uInt16 nBrowseWidth =
535 0 : pLayout->GetBrowseWidthByTable( *pDoc );
536 :
537 0 : if ( nBrowseWidth )
538 : {
539 : pLayout->Resize( nBrowseWidth, sal_True, sal_True,
540 : bLastGrf ? HTMLTABLE_RESIZE_NOW
541 0 : : 500 );
542 : }
543 : }
544 : }
545 0 : }
546 : }
547 :
548 : // uns selbst abmelden und loeschen
549 0 : clear();
550 0 : uno::Reference< awt::XImageConsumer > xTmp = (awt::XImageConsumer*)this;
551 0 : xThis = 0;
552 : }
553 :
554 0 : void SwHTMLImageWatcher::setColorModel(
555 : sal_Int16, const Sequence< sal_Int32 >&, sal_Int32, sal_Int32,
556 : sal_Int32, sal_Int32 )
557 : throw( uno::RuntimeException, std::exception )
558 : {
559 0 : }
560 :
561 0 : void SwHTMLImageWatcher::setPixelsByBytes(
562 : sal_Int32, sal_Int32, sal_Int32, sal_Int32,
563 : const Sequence< sal_Int8 >&, sal_Int32, sal_Int32 )
564 : throw( uno::RuntimeException, std::exception )
565 : {
566 0 : }
567 :
568 0 : void SwHTMLImageWatcher::setPixelsByLongs(
569 : sal_Int32, sal_Int32, sal_Int32, sal_Int32,
570 : const Sequence< sal_Int32 >&, sal_Int32, sal_Int32 )
571 : throw( uno::RuntimeException, std::exception )
572 : {
573 0 : }
574 :
575 0 : void SwHTMLImageWatcher::complete( sal_Int32 Status,
576 : const uno::Reference< awt::XImageProducer >& )
577 : throw( uno::RuntimeException, std::exception )
578 : {
579 0 : if( awt::ImageStatus::IMAGESTATUS_ERROR == Status || awt::ImageStatus::IMAGESTATUS_ABORTED == Status )
580 : {
581 : // uns selbst abmelden und loeschen
582 0 : clear();
583 0 : uno::Reference< awt::XImageConsumer > xTmp = (awt::XImageConsumer*)this;
584 0 : xThis = 0;
585 : }
586 0 : }
587 :
588 0 : void SwHTMLImageWatcher::disposing(const lang::EventObject& evt) throw ( uno::RuntimeException, std::exception)
589 : {
590 0 : uno::Reference< awt::XImageConsumer > xTmp;
591 :
592 : // Wenn das Shape verschwindet soll muessen wir es loslassen
593 0 : uno::Reference< drawing::XShape > xTmpShape;
594 0 : if( evt.Source == xShape )
595 : {
596 0 : clear();
597 0 : xTmp = (awt::XImageConsumer*)this;
598 0 : xThis = 0;
599 0 : }
600 0 : }
601 :
602 6 : void SwHTMLParser::DeleteFormImpl()
603 : {
604 6 : delete pFormImpl;
605 6 : pFormImpl = 0;
606 6 : }
607 :
608 1 : static void lcl_html_setFixedFontProperty(
609 : const uno::Reference< beans::XPropertySet >& rPropSet )
610 : {
611 : Font aFixedFont( OutputDevice::GetDefaultFont(
612 : DEFAULTFONT_FIXED, LANGUAGE_ENGLISH_US,
613 1 : DEFAULTFONT_FLAGS_ONLYONE ) );
614 2 : Any aTmp;
615 1 : aTmp <<= OUString( aFixedFont.GetName() );
616 1 : rPropSet->setPropertyValue("FontName", aTmp );
617 :
618 1 : aTmp <<= OUString( aFixedFont.GetStyleName() );
619 1 : rPropSet->setPropertyValue("FontStyleName",
620 1 : aTmp );
621 :
622 1 : aTmp <<= (sal_Int16) aFixedFont.GetFamily();
623 1 : rPropSet->setPropertyValue("FontFamily", aTmp );
624 :
625 1 : aTmp <<= (sal_Int16) aFixedFont.GetCharSet();
626 1 : rPropSet->setPropertyValue("FontCharset",
627 1 : aTmp );
628 :
629 1 : aTmp <<= (sal_Int16) aFixedFont.GetPitch();
630 1 : rPropSet->setPropertyValue("FontPitch", aTmp );
631 :
632 1 : float fVal(10.);
633 1 : aTmp.setValue( &fVal, ::getCppuType(&fVal ));
634 2 : rPropSet->setPropertyValue("FontHeight", aTmp );
635 1 : }
636 :
637 : class SwHTMLFormPendingStackData_Impl: public SwPendingStackData
638 : {
639 : uno::Reference< drawing::XShape > xShape;
640 : Size aTextSz;
641 : sal_Bool bMinWidth;
642 : sal_Bool bMinHeight;
643 :
644 : public:
645 : SwHTMLFormPendingStackData_Impl(
646 : const uno::Reference< drawing::XShape > & rShape, const Size& rTextSz,
647 : sal_Bool bMinW, sal_Bool bMinH ) :
648 : xShape( rShape ),
649 : aTextSz( rTextSz ),
650 : bMinWidth( bMinW ),
651 : bMinHeight( bMinH )
652 : {}
653 :
654 0 : const uno::Reference< drawing::XShape >& GetShape() const { return xShape; }
655 0 : const Size& GetTextSize() const { return aTextSz; }
656 0 : sal_Bool IsMinWidth() const { return bMinWidth; }
657 0 : sal_Bool IsMinHeight() const { return bMinHeight; }
658 : };
659 :
660 0 : void SwHTMLParser::SetPendingControlSize()
661 : {
662 : OSL_ENSURE( pPendStack, "Wo ist der Pending Stack?" );
663 : SwHTMLFormPendingStackData_Impl *pData =
664 0 : (SwHTMLFormPendingStackData_Impl *)pPendStack->pData;
665 :
666 0 : SwPendingStack* pTmp = pPendStack->pNext;
667 0 : delete pPendStack;
668 0 : pPendStack = pTmp;
669 : OSL_ENSURE( !pPendStack, "Wo kommt der Pending-Stack her?" );
670 :
671 0 : SetControlSize( pData->GetShape(), pData->GetTextSize(),
672 0 : pData->IsMinWidth(), pData->IsMinHeight() );
673 0 : delete pData;
674 0 : }
675 :
676 2 : void SwHTMLParser::SetControlSize( const uno::Reference< drawing::XShape >& rShape,
677 : const Size& rTextSz,
678 : sal_Bool bMinWidth,
679 : sal_Bool bMinHeight )
680 : {
681 2 : if( !rTextSz.Width() && !rTextSz.Height() && !bMinWidth && !bMinHeight )
682 2 : return;
683 :
684 : // Um an den SwXShape* zu gelangen, brauchen wir ein Interface,
685 : // das auch vom SwXShape implementiert wird.
686 2 : uno::Reference< beans::XPropertySet > xPropSet( rShape, UNO_QUERY );
687 :
688 : SwViewShell *pVSh;
689 2 : pDoc->GetEditShell( &pVSh );
690 2 : if( !pVSh && !nEventId )
691 : {
692 : // If there is no view shell by now and the doc shell is an internal
693 : // one, no view shell will be created. That for, we have to do that of
694 : // our own. This happens if a linked section is inserted or refreshed.
695 1 : SwDocShell *pDocSh = pDoc->GetDocShell();
696 1 : if( pDocSh )
697 : {
698 1 : if ( pDocSh->GetMedium() )
699 : {
700 : // if there is no hidden property in the MediaDescriptor it should be removed after loading
701 1 : SFX_ITEMSET_ARG( pDocSh->GetMedium()->GetItemSet(), pHiddenItem, SfxBoolItem, SID_HIDDEN, false );
702 1 : bRemoveHidden = ( pHiddenItem == NULL || !pHiddenItem->GetValue() );
703 : }
704 :
705 1 : pTempViewFrame = SfxViewFrame::LoadHiddenDocument( *pDocSh, 0 );
706 1 : CallStartAction();
707 1 : pDoc->GetEditShell( &pVSh );
708 : }
709 : }
710 :
711 4 : uno::Reference< XUnoTunnel> xTunnel( xPropSet, UNO_QUERY );
712 2 : SwXShape *pSwShape = xTunnel.is() ?
713 : reinterpret_cast< SwXShape *>( sal::static_int_cast< sal_IntPtr >(
714 2 : xTunnel->getSomething(SwXShape::getUnoTunnelId()) ))
715 4 : : 0;
716 :
717 : OSL_ENSURE( pSwShape, "Wo ist das SW-Shape?" );
718 :
719 : // es muss ein Draw-Format sein
720 2 : SwFrmFmt *pFrmFmt = pSwShape ? pSwShape->GetFrmFmt() : NULL ;
721 : OSL_ENSURE( pFrmFmt && RES_DRAWFRMFMT == pFrmFmt->Which(), "Kein DrawFrmFmt" );
722 :
723 : // Schauen, ob es ein SdrObject dafuer gibt
724 2 : const SdrObject *pObj = pFrmFmt ? pFrmFmt->FindSdrObject() : NULL;
725 : OSL_ENSURE( pObj, "SdrObject nicht gefunden" );
726 : OSL_ENSURE( pObj && FmFormInventor == pObj->GetObjInventor(), "falscher Inventor" );
727 :
728 2 : const SdrView* pDrawView = pVSh ? pVSh->GetDrawView() : 0;
729 :
730 2 : SdrUnoObj *pFormObj = PTR_CAST( SdrUnoObj, pObj );
731 4 : uno::Reference< awt::XControl > xControl;
732 2 : if ( pDrawView && pVSh->GetWin() && pFormObj )
733 2 : xControl = pFormObj->GetUnoControl( *pDrawView, *pVSh->GetWin() );
734 :
735 2 : awt::Size aSz( rShape->getSize() );
736 2 : awt::Size aNewSz( 0, 0 );
737 :
738 : // #i71248# ensure we got a XControl before apllying corrections
739 2 : if(xControl.is())
740 : {
741 2 : if( bMinWidth || bMinHeight )
742 : {
743 2 : uno::Reference< awt::XLayoutConstrains > xLC( xControl, UNO_QUERY );
744 2 : awt::Size aTmpSz( xLC->getPreferredSize() );
745 2 : if( bMinWidth )
746 1 : aNewSz.Width = aTmpSz.Width;
747 2 : if( bMinHeight )
748 2 : aNewSz.Height = aTmpSz.Height;
749 : }
750 2 : if( rTextSz.Width() || rTextSz.Height())
751 : {
752 1 : uno::Reference< awt::XTextLayoutConstrains > xLC( xControl, UNO_QUERY );
753 : OSL_ENSURE( xLC.is(), "kein XTextLayoutConstrains" );
754 1 : if( xLC.is() )
755 : {
756 1 : awt::Size aTmpSz( rTextSz.Width(), rTextSz.Height() );
757 1 : if( -1 == rTextSz.Width() )
758 : {
759 0 : aTmpSz.Width = 0;
760 0 : aTmpSz.Height = nSelectEntryCnt;
761 : }
762 1 : aTmpSz = xLC->getMinimumSize( static_cast< sal_Int16 >(aTmpSz.Width), static_cast< sal_Int16 >(aTmpSz.Height) );
763 1 : if( rTextSz.Width() )
764 1 : aNewSz.Width = aTmpSz.Width;
765 1 : if( rTextSz.Height() )
766 0 : aNewSz.Height = aTmpSz.Height;
767 1 : }
768 : }
769 : }
770 :
771 2 : if( Application::GetDefaultDevice() )
772 : {
773 2 : Size aTmpSz( aNewSz.Width, aNewSz.Height );
774 : aTmpSz = Application::GetDefaultDevice()
775 2 : ->PixelToLogic( aTmpSz, MapMode( MAP_100TH_MM ) );
776 2 : aNewSz.Width = aTmpSz.Width();
777 2 : aNewSz.Height = aTmpSz.Height();
778 : }
779 2 : if( aNewSz.Width )
780 : {
781 2 : if( aNewSz.Width < MINLAY )
782 0 : aNewSz.Width = MINLAY;
783 2 : aSz.Width = aNewSz.Width;
784 : }
785 2 : if( aNewSz.Height )
786 : {
787 2 : if( aNewSz.Height < MINLAY )
788 0 : aNewSz.Height = MINLAY;
789 2 : aSz.Height = aNewSz.Height;
790 : }
791 :
792 4 : rShape->setSize( aSz );
793 : }
794 :
795 0 : static void lcl_html_setEvents(
796 : const uno::Reference< script::XEventAttacherManager > & rEvtMn,
797 : sal_uInt32 nPos, const SvxMacroTableDtor& rMacroTbl,
798 : const std::vector<OUString>& rUnoMacroTbl,
799 : const std::vector<OUString>& rUnoMacroParamTbl,
800 : const OUString& rType )
801 : {
802 : // Erstmal muss die Anzahl der Events ermittelt werden ...
803 0 : sal_Int32 nEvents = 0;
804 : sal_uInt16 i;
805 :
806 0 : for( i = 0; HTML_ET_END != aEventTypeTable[i]; i++ )
807 : {
808 0 : const SvxMacro *pMacro = rMacroTbl.Get( aEventTypeTable[i] );
809 : // Solange nicht alle Events implementiert sind, enthaelt die
810 : // Tabelle auch Leerstrings!
811 0 : if( pMacro && aEventListenerTable[i] )
812 0 : nEvents++;
813 : }
814 0 : for( i=0; i< rUnoMacroTbl.size(); i++ )
815 : {
816 0 : const OUString& rStr(rUnoMacroTbl[i]);
817 0 : sal_Int32 nIndex = 0;
818 0 : if( rStr.getToken( 0, '-', nIndex ).isEmpty() || -1 == nIndex )
819 0 : continue;
820 0 : if( rStr.getToken( 0, '-', nIndex ).isEmpty() || -1 == nIndex )
821 0 : continue;
822 0 : if( nIndex < rStr.getLength() )
823 0 : nEvents++;
824 : }
825 :
826 0 : if( 0==nEvents )
827 0 : return;
828 :
829 0 : Sequence<script::ScriptEventDescriptor> aDescs( nEvents );
830 0 : script::ScriptEventDescriptor* pDescs = aDescs.getArray();
831 0 : sal_Int32 nEvent = 0;
832 :
833 0 : for( i=0; HTML_ET_END != aEventTypeTable[i]; i++ )
834 : {
835 0 : const SvxMacro *pMacro = rMacroTbl.Get( aEventTypeTable[i] );
836 0 : if( pMacro && aEventListenerTable[i] )
837 : {
838 0 : script::ScriptEventDescriptor& rDesc = pDescs[nEvent++];
839 0 : rDesc.ListenerType =
840 0 : OUString::createFromAscii(aEventListenerTable[i]);
841 0 : rDesc.EventMethod = OUString::createFromAscii(aEventMethodTable[i]);
842 0 : rDesc.ScriptType = pMacro->GetLanguage();
843 0 : rDesc.ScriptCode = pMacro->GetMacName();
844 : }
845 : }
846 :
847 0 : for( i=0; i< rUnoMacroTbl.size(); ++i )
848 : {
849 0 : const OUString& rStr = rUnoMacroTbl[i];
850 0 : sal_Int32 nIndex = 0;
851 0 : OUString sListener( rStr.getToken( 0, '-', nIndex ) );
852 0 : if( sListener.isEmpty() || -1 == nIndex )
853 0 : continue;
854 :
855 0 : OUString sMethod( rStr.getToken( 0, '-', nIndex ) );
856 0 : if( sMethod.isEmpty() || -1 == nIndex )
857 0 : continue;
858 :
859 0 : OUString sCode( rStr.copy( nIndex ) );
860 0 : if( sCode.isEmpty() )
861 0 : continue;
862 :
863 0 : script::ScriptEventDescriptor& rDesc = pDescs[nEvent++];
864 0 : rDesc.ListenerType = sListener;
865 0 : rDesc.EventMethod = sMethod;
866 0 : rDesc.ScriptType = rType;
867 0 : rDesc.ScriptCode = sCode;
868 0 : rDesc.AddListenerParam = "";
869 :
870 0 : if(!rUnoMacroParamTbl.empty())
871 : {
872 0 : OUString sSearch( sListener );
873 0 : sSearch += "-" +sMethod + "-";
874 0 : sal_Int32 nLen = sSearch.getLength();
875 0 : for(size_t j = 0; j < rUnoMacroParamTbl.size(); ++j)
876 : {
877 0 : const OUString& rParam = rUnoMacroParamTbl[j];
878 0 : if( rParam.startsWith( sSearch ) && rParam.getLength() > nLen )
879 : {
880 0 : rDesc.AddListenerParam = rParam.copy(nLen);
881 0 : break;
882 : }
883 0 : }
884 : }
885 0 : }
886 0 : rEvtMn->registerScriptEvents( nPos, aDescs );
887 : }
888 :
889 5 : static void lcl_html_getEvents( const OUString& rOption, const OUString& rValue,
890 : std::vector<OUString>& rUnoMacroTbl,
891 : std::vector<OUString>& rUnoMacroParamTbl )
892 : {
893 5 : if( rOption.startsWithIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_sdevent ) )
894 : {
895 0 : OUString aEvent( rOption.copy( strlen( OOO_STRING_SVTOOLS_HTML_O_sdevent ) ) );
896 0 : aEvent += "-" + rValue;
897 0 : rUnoMacroTbl.push_back(aEvent);
898 : }
899 5 : else if( rOption.startsWithIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_sdaddparam ) )
900 : {
901 0 : OUString aParam( rOption.copy( strlen( OOO_STRING_SVTOOLS_HTML_O_sdaddparam ) ) );
902 0 : aParam += "-" + rValue;
903 0 : rUnoMacroParamTbl.push_back(aParam);
904 : }
905 5 : }
906 :
907 4 : uno::Reference< drawing::XShape > SwHTMLParser::InsertControl(
908 : const uno::Reference< XFormComponent > & rFComp,
909 : const uno::Reference< beans::XPropertySet > & rFCompPropSet,
910 : const Size& rSize, sal_Int16 eVertOri, sal_Int16 eHoriOri,
911 : SfxItemSet& rCSS1ItemSet, SvxCSS1PropertyInfo& rCSS1PropInfo,
912 : const SvxMacroTableDtor& rMacroTbl, const std::vector<OUString>& rUnoMacroTbl,
913 : const std::vector<OUString>& rUnoMacroParamTbl, sal_Bool bSetFCompPropSet,
914 : sal_Bool bHidden )
915 : {
916 4 : uno::Reference< drawing::XShape > xShape;
917 :
918 : const uno::Reference< container::XIndexContainer > & rFormComps =
919 4 : pFormImpl->GetFormComps();
920 8 : Any aAny( &rFComp, ::getCppuType( (uno::Reference< XFormComponent>*)0 ) );
921 4 : rFormComps->insertByIndex( rFormComps->getCount(), aAny );
922 :
923 4 : if( !bHidden )
924 : {
925 2 : Any aTmp;
926 2 : sal_uInt16 nLeftSpace = 0, nRightSpace = 0,
927 2 : nUpperSpace = 0, nLowerSpace = 0;
928 :
929 : const uno::Reference< XMultiServiceFactory > & rServiceFactory =
930 2 : pFormImpl->GetServiceFactory();
931 2 : if( !rServiceFactory.is() )
932 0 : return xShape;
933 :
934 : uno::Reference< XInterface > xCreate =
935 2 : rServiceFactory ->createInstance(
936 4 : OUString("com.sun.star.drawing.ControlShape"));
937 2 : if( !xCreate.is() )
938 0 : return xShape;
939 :
940 2 : xShape = uno::Reference< drawing::XShape >( xCreate, UNO_QUERY );
941 :
942 : OSL_ENSURE( xShape.is(), "XShape nicht erhalten" );
943 2 : awt::Size aTmpSz;
944 2 : aTmpSz.Width = rSize.Width();
945 2 : aTmpSz.Height = rSize.Height();
946 2 : xShape->setSize( aTmpSz );
947 :
948 4 : uno::Reference< beans::XPropertySet > xShapePropSet( xCreate, UNO_QUERY );
949 :
950 : // linken/rechten Rand setzen
951 : const SfxPoolItem *pItem;
952 2 : if( SFX_ITEM_SET==rCSS1ItemSet.GetItemState( RES_LR_SPACE, true,
953 2 : &pItem ) )
954 : {
955 : // Ggf. den Erstzeilen-Einzug noch plaetten
956 0 : const SvxLRSpaceItem *pLRItem = (const SvxLRSpaceItem *)pItem;
957 0 : SvxLRSpaceItem aLRItem( *pLRItem );
958 0 : aLRItem.SetTxtFirstLineOfst( 0 );
959 0 : if( rCSS1PropInfo.bLeftMargin )
960 : {
961 0 : nLeftSpace = static_cast< sal_uInt16 >(TWIP_TO_MM100( aLRItem.GetLeft() ));
962 0 : rCSS1PropInfo.bLeftMargin = sal_False;
963 : }
964 0 : if( rCSS1PropInfo.bRightMargin )
965 : {
966 0 : nRightSpace = static_cast< sal_uInt16 >(TWIP_TO_MM100( aLRItem.GetRight() ));
967 0 : rCSS1PropInfo.bRightMargin = sal_False;
968 : }
969 0 : rCSS1ItemSet.ClearItem( RES_LR_SPACE );
970 : }
971 2 : if( nLeftSpace || nRightSpace )
972 : {
973 0 : Any aAny2;
974 0 : aAny2 <<= (sal_Int32)nLeftSpace;
975 0 : xShapePropSet->setPropertyValue(
976 0 : OUString("LeftMargin"), aAny2 );
977 :
978 0 : aAny2 <<= (sal_Int32)nRightSpace;
979 0 : xShapePropSet->setPropertyValue(
980 0 : OUString("RightMargin"), aAny2 );
981 : }
982 :
983 : // oberen/unteren Rand setzen
984 2 : if( SFX_ITEM_SET==rCSS1ItemSet.GetItemState( RES_UL_SPACE, true,
985 2 : &pItem ) )
986 : {
987 : // Ggf. den Erstzeilen-Einzug noch plaetten
988 0 : const SvxULSpaceItem *pULItem = (const SvxULSpaceItem *)pItem;
989 0 : if( rCSS1PropInfo.bTopMargin )
990 : {
991 0 : nUpperSpace = TWIP_TO_MM100_UNSIGNED( pULItem->GetUpper() );
992 0 : rCSS1PropInfo.bTopMargin = sal_False;
993 : }
994 0 : if( rCSS1PropInfo.bBottomMargin )
995 : {
996 0 : nLowerSpace = TWIP_TO_MM100_UNSIGNED( pULItem->GetLower() );
997 0 : rCSS1PropInfo.bBottomMargin = sal_False;
998 : }
999 :
1000 0 : rCSS1ItemSet.ClearItem( RES_UL_SPACE );
1001 : }
1002 2 : if( nUpperSpace || nLowerSpace )
1003 : {
1004 0 : uno::Any aAny2;
1005 0 : aAny2 <<= (sal_Int32)nUpperSpace;
1006 0 : xShapePropSet->setPropertyValue(
1007 0 : OUString("TopMargin"), aAny2 );
1008 :
1009 0 : aAny2 <<= (sal_Int32)nLowerSpace;
1010 0 : xShapePropSet->setPropertyValue(
1011 0 : OUString("BottomMargin"), aAny2 );
1012 : }
1013 :
1014 : uno::Reference< beans::XPropertySetInfo > xPropSetInfo =
1015 4 : rFCompPropSet->getPropertySetInfo();
1016 4 : OUString sPropName = "BackgroundColor";
1017 2 : if( SFX_ITEM_SET==rCSS1ItemSet.GetItemState( RES_BACKGROUND, true,
1018 2 : &pItem ) &&
1019 0 : xPropSetInfo->hasPropertyByName( sPropName ) )
1020 : {
1021 0 : const Color &rColor = ((const SvxBrushItem *)pItem)->GetColor();
1022 : /// copy color, if color is not "no fill"/"auto fill"
1023 0 : if( rColor.GetColor() != COL_TRANSPARENT )
1024 : {
1025 : /// copy complete color with transparency
1026 0 : aTmp <<= static_cast<sal_Int32>(rColor.GetColor());
1027 0 : rFCompPropSet->setPropertyValue( sPropName, aTmp );
1028 : }
1029 :
1030 : }
1031 :
1032 2 : sPropName = "TextColor";
1033 2 : if( SFX_ITEM_SET==rCSS1ItemSet.GetItemState( RES_CHRATR_COLOR, true,
1034 2 : &pItem ) &&
1035 0 : xPropSetInfo->hasPropertyByName( sPropName ) )
1036 : {
1037 0 : aTmp <<= (sal_Int32)((const SvxColorItem *)pItem)->GetValue()
1038 0 : .GetRGBColor();
1039 0 : rFCompPropSet->setPropertyValue( sPropName, aTmp );
1040 : }
1041 :
1042 2 : sPropName = "FontHeight";
1043 2 : if( SFX_ITEM_SET==rCSS1ItemSet.GetItemState( RES_CHRATR_FONTSIZE,
1044 2 : true, &pItem ) &&
1045 0 : xPropSetInfo->hasPropertyByName( sPropName ) )
1046 : {
1047 : float fVal = static_cast< float >(
1048 0 : (((SvxFontHeightItem *)pItem)->GetHeight()) / 20.0 );
1049 0 : aTmp.setValue( &fVal, ::getCppuType(&fVal));
1050 0 : rFCompPropSet->setPropertyValue( sPropName, aTmp );
1051 : }
1052 :
1053 2 : if( SFX_ITEM_SET==rCSS1ItemSet.GetItemState( RES_CHRATR_FONT, true,
1054 2 : &pItem ) )
1055 : {
1056 0 : const SvxFontItem *pFontItem = (SvxFontItem *)pItem;
1057 0 : sPropName = "FontName";
1058 0 : if( xPropSetInfo->hasPropertyByName( sPropName ) )
1059 : {
1060 0 : aTmp <<= OUString( pFontItem->GetFamilyName() );
1061 0 : rFCompPropSet->setPropertyValue( sPropName, aTmp );
1062 : }
1063 0 : sPropName = "FontStyleName";
1064 0 : if( xPropSetInfo->hasPropertyByName( sPropName ) )
1065 : {
1066 0 : aTmp <<= OUString( pFontItem->GetStyleName() );
1067 0 : rFCompPropSet->setPropertyValue( sPropName, aTmp );
1068 : }
1069 0 : sPropName = "FontFamily";
1070 0 : if( xPropSetInfo->hasPropertyByName( sPropName ) )
1071 : {
1072 0 : aTmp <<= (sal_Int16)pFontItem->GetFamily() ;
1073 0 : rFCompPropSet->setPropertyValue( sPropName, aTmp );
1074 : }
1075 0 : sPropName = "FontCharset";
1076 0 : if( xPropSetInfo->hasPropertyByName( sPropName ) )
1077 : {
1078 0 : aTmp <<= (sal_Int16)pFontItem->GetCharSet() ;
1079 0 : rFCompPropSet->setPropertyValue( sPropName, aTmp );
1080 : }
1081 0 : sPropName = "FontPitch";
1082 0 : if( xPropSetInfo->hasPropertyByName( sPropName ) )
1083 : {
1084 0 : aTmp <<= (sal_Int16)pFontItem->GetPitch() ;
1085 0 : rFCompPropSet->setPropertyValue( sPropName, aTmp );
1086 : }
1087 : }
1088 :
1089 2 : sPropName = "FontWeight";
1090 2 : if( SFX_ITEM_SET==rCSS1ItemSet.GetItemState( RES_CHRATR_WEIGHT,
1091 2 : true, &pItem ) &&
1092 0 : xPropSetInfo->hasPropertyByName( sPropName ) )
1093 : {
1094 : float fVal = VCLUnoHelper::ConvertFontWeight(
1095 0 : ((SvxWeightItem *)pItem)->GetWeight() );
1096 0 : aTmp.setValue( &fVal, ::getCppuType(&fVal));
1097 0 : rFCompPropSet->setPropertyValue( sPropName, aTmp );
1098 : }
1099 :
1100 2 : sPropName = "FontSlant";
1101 2 : if( SFX_ITEM_SET==rCSS1ItemSet.GetItemState( RES_CHRATR_POSTURE,
1102 2 : true, &pItem ) &&
1103 0 : xPropSetInfo->hasPropertyByName( sPropName ) )
1104 : {
1105 0 : aTmp <<= (sal_Int16)((SvxPostureItem *)pItem)->GetPosture();
1106 0 : rFCompPropSet->setPropertyValue( sPropName, aTmp );
1107 : }
1108 :
1109 2 : sPropName = "FontUnderline";
1110 2 : if( SFX_ITEM_SET==rCSS1ItemSet.GetItemState( RES_CHRATR_UNDERLINE,
1111 2 : true, &pItem ) &&
1112 0 : xPropSetInfo->hasPropertyByName( sPropName ) )
1113 : {
1114 0 : aTmp <<= (sal_Int16)((SvxUnderlineItem *)pItem)->GetLineStyle();
1115 0 : rFCompPropSet->setPropertyValue( sPropName, aTmp );
1116 : }
1117 :
1118 2 : sPropName = "FontStrikeout";
1119 2 : if( SFX_ITEM_SET==rCSS1ItemSet.GetItemState( RES_CHRATR_CROSSEDOUT,
1120 2 : true, &pItem ) &&
1121 0 : xPropSetInfo->hasPropertyByName( sPropName ) )
1122 : {
1123 0 : aTmp <<= (sal_Int16)((SvxCrossedOutItem *)pItem)->GetStrikeout();
1124 0 : rFCompPropSet->setPropertyValue( sPropName, aTmp );
1125 : }
1126 :
1127 4 : uno::Reference< text::XTextRange > xTxtRg;
1128 2 : sal_Int16 nAnchorType = text::TextContentAnchorType_AS_CHARACTER;
1129 2 : sal_Bool bSetPos = sal_False, bSetSurround = sal_False;
1130 2 : sal_Int32 nXPos = 0, nYPos = 0;
1131 2 : sal_Int16 nSurround = text::WrapTextMode_NONE;
1132 2 : if( SVX_CSS1_POS_ABSOLUTE == rCSS1PropInfo.ePosition &&
1133 0 : SVX_CSS1_LTYPE_TWIP == rCSS1PropInfo.eLeftType &&
1134 0 : SVX_CSS1_LTYPE_TWIP == rCSS1PropInfo.eTopType )
1135 : {
1136 : const SwStartNode *pFlySttNd =
1137 0 : pPam->GetPoint()->nNode.GetNode().FindFlyStartNode();
1138 :
1139 0 : if( pFlySttNd )
1140 : {
1141 0 : nAnchorType = text::TextContentAnchorType_AT_FRAME;
1142 0 : SwPaM aPaM( *pFlySttNd );
1143 :
1144 0 : uno::Reference< text::XText > xDummyTxtRef; // unsauber, aber laut OS geht das ...
1145 0 : xTxtRg = new SwXTextRange( aPaM, xDummyTxtRef );
1146 : }
1147 : else
1148 : {
1149 0 : nAnchorType = text::TextContentAnchorType_AT_PAGE;
1150 : }
1151 0 : nXPos = TWIP_TO_MM100( rCSS1PropInfo.nLeft ) + nLeftSpace;
1152 0 : nYPos = TWIP_TO_MM100( rCSS1PropInfo.nTop ) + nUpperSpace;
1153 0 : bSetPos = sal_True;
1154 :
1155 0 : nSurround = text::WrapTextMode_THROUGHT;
1156 0 : bSetSurround = sal_True;
1157 : }
1158 2 : else if( SVX_ADJUST_LEFT == rCSS1PropInfo.eFloat ||
1159 : text::HoriOrientation::LEFT == eHoriOri )
1160 : {
1161 0 : nAnchorType = text::TextContentAnchorType_AT_PARAGRAPH;
1162 0 : nXPos = nLeftSpace;
1163 0 : nYPos = nUpperSpace;
1164 0 : bSetPos = sal_True;
1165 0 : nSurround = text::WrapTextMode_RIGHT;
1166 0 : bSetSurround = sal_True;
1167 : }
1168 2 : else if( text::VertOrientation::NONE != eVertOri )
1169 : {
1170 2 : sal_Int16 nVertOri = text::VertOrientation::NONE;
1171 2 : switch( eVertOri )
1172 : {
1173 : case text::VertOrientation::NONE:
1174 0 : nVertOri = text::VertOrientation::NONE;
1175 0 : break;
1176 : case text::VertOrientation::TOP:
1177 2 : nVertOri = text::VertOrientation::TOP;
1178 2 : break;
1179 : case text::VertOrientation::CENTER:
1180 0 : nVertOri = text::VertOrientation::CENTER;
1181 0 : break;
1182 : case text::VertOrientation::BOTTOM:
1183 0 : nVertOri = text::VertOrientation::BOTTOM;
1184 0 : break;
1185 : case text::VertOrientation::CHAR_TOP:
1186 0 : nVertOri = text::VertOrientation::CHAR_TOP;
1187 0 : break;
1188 : case text::VertOrientation::CHAR_CENTER:
1189 0 : nVertOri = text::VertOrientation::CHAR_CENTER;
1190 0 : break;
1191 : case text::VertOrientation::CHAR_BOTTOM:
1192 0 : nVertOri = text::VertOrientation::CHAR_BOTTOM;
1193 0 : break;
1194 : case text::VertOrientation::LINE_TOP:
1195 0 : nVertOri = text::VertOrientation::LINE_TOP;
1196 0 : break;
1197 : case text::VertOrientation::LINE_CENTER:
1198 0 : nVertOri = text::VertOrientation::LINE_CENTER;
1199 0 : break;
1200 : case text::VertOrientation::LINE_BOTTOM:
1201 0 : nVertOri = text::VertOrientation::LINE_BOTTOM;
1202 0 : break;
1203 : }
1204 2 : aTmp <<= (sal_Int16)nVertOri ;
1205 2 : xShapePropSet->setPropertyValue(
1206 2 : OUString("VertOrient"), aTmp );
1207 : }
1208 :
1209 2 : aTmp <<= (sal_Int16)nAnchorType ;
1210 2 : xShapePropSet->setPropertyValue(
1211 2 : OUString("AnchorType"), aTmp );
1212 :
1213 2 : if( text::TextContentAnchorType_AT_PAGE == nAnchorType )
1214 : {
1215 0 : aTmp <<= (sal_Int16) 1 ;
1216 0 : xShapePropSet->setPropertyValue(
1217 0 : OUString("AnchorPageNo"), aTmp );
1218 : }
1219 : else
1220 : {
1221 2 : if( !xTxtRg.is() )
1222 : {
1223 2 : uno::Reference< text::XText > xDummyTxtRef; // unsauber, aber laut OS geht das ...
1224 2 : xTxtRg = new SwXTextRange( *pPam, xDummyTxtRef );
1225 : }
1226 :
1227 : aTmp.setValue( &xTxtRg,
1228 2 : ::getCppuType((uno::Reference< text::XTextRange>*)0));
1229 2 : xShapePropSet->setPropertyValue(
1230 2 : OUString("TextRange"), aTmp );
1231 : }
1232 :
1233 2 : if( bSetPos )
1234 : {
1235 0 : aTmp <<= (sal_Int16)text::HoriOrientation::NONE;
1236 0 : xShapePropSet->setPropertyValue(
1237 0 : OUString("HoriOrient"), aTmp );
1238 0 : aTmp <<= (sal_Int32)nXPos ;
1239 0 : xShapePropSet->setPropertyValue(
1240 0 : OUString("HoriOrientPosition"), aTmp );
1241 :
1242 0 : aTmp <<= (sal_Int16)text::VertOrientation::NONE;
1243 0 : xShapePropSet->setPropertyValue(
1244 0 : OUString("VertOrient"), aTmp );
1245 0 : aTmp <<= (sal_Int32)nYPos ;
1246 0 : xShapePropSet->setPropertyValue(
1247 0 : OUString("VertOrientPosition"), aTmp );
1248 : }
1249 2 : if( bSetSurround )
1250 : {
1251 0 : aTmp <<= (sal_Int16)nSurround ;
1252 0 : xShapePropSet->setPropertyValue(
1253 0 : OUString("Surround"), aTmp );
1254 : }
1255 :
1256 2 : pFormImpl->GetShapes()->add(xShape);
1257 :
1258 : // Das Control-Model am Control-Shape setzen
1259 2 : uno::Reference< drawing::XControlShape > xControlShape( xShape, UNO_QUERY );
1260 4 : uno::Reference< awt::XControlModel > xControlModel( rFComp, UNO_QUERY );
1261 6 : xControlShape->setControl( xControlModel );
1262 : }
1263 :
1264 : // Da beim Einfuegen der Controls der Fokus gesetzt wird, werden
1265 : // auch schon Fokus-Events verschickt. Damit die nicht evtl. schon
1266 : // vorhendene JavaSCript-Eents rufen, werden die Events nachtraeglich
1267 : // gesetzt.
1268 4 : if( !rMacroTbl.empty() || !rUnoMacroTbl.empty() )
1269 : {
1270 0 : lcl_html_setEvents( pFormImpl->GetControlEventManager(),
1271 0 : rFormComps->getCount() - 1,
1272 : rMacroTbl, rUnoMacroTbl, rUnoMacroParamTbl,
1273 0 : GetScriptTypeString(pFormImpl->GetHeaderAttrs()) );
1274 : }
1275 :
1276 4 : if( bSetFCompPropSet )
1277 : {
1278 0 : pFormImpl->SetFCompPropSet( rFCompPropSet );
1279 : }
1280 :
1281 4 : return xShape;
1282 : }
1283 :
1284 2 : void SwHTMLParser::NewForm( sal_Bool bAppend )
1285 : {
1286 : // Gibt es schon eine Form?
1287 2 : if( pFormImpl && pFormImpl->GetFormComps().is() )
1288 0 : return;
1289 :
1290 2 : if( bAppend )
1291 : {
1292 2 : if( pPam->GetPoint()->nContent.GetIndex() )
1293 0 : AppendTxtNode( AM_SPACE );
1294 : else
1295 2 : AddParSpace();
1296 : }
1297 :
1298 2 : if( !pFormImpl )
1299 1 : pFormImpl = new SwHTMLForm_Impl( pDoc->GetDocShell() );
1300 :
1301 2 : OUString aAction( sBaseURL );
1302 4 : OUString sName, sTarget;
1303 2 : sal_uInt16 nEncType = FormSubmitEncoding_URL;
1304 2 : sal_uInt16 nMethod = FormSubmitMethod_GET;
1305 4 : SvxMacroTableDtor aMacroTbl;
1306 4 : std::vector<OUString> aUnoMacroTbl;
1307 4 : std::vector<OUString> aUnoMacroParamTbl;
1308 2 : SvKeyValueIterator *pHeaderAttrs = pFormImpl->GetHeaderAttrs();
1309 2 : ScriptType eDfltScriptType = GetScriptType( pHeaderAttrs );
1310 2 : const OUString& rDfltScriptType = GetScriptTypeString( pHeaderAttrs );
1311 :
1312 2 : const HTMLOptions& rHTMLOptions = GetOptions();
1313 10 : for (size_t i = rHTMLOptions.size(); i; )
1314 : {
1315 6 : const HTMLOption& rOption = rHTMLOptions[--i];
1316 6 : ScriptType eScriptType2 = eDfltScriptType;
1317 6 : sal_uInt16 nEvent = 0;
1318 6 : sal_Bool bSetEvent = sal_False;
1319 :
1320 6 : switch( rOption.GetToken() )
1321 : {
1322 : case HTML_O_ACTION:
1323 0 : aAction = rOption.GetString();
1324 0 : break;
1325 : case HTML_O_METHOD:
1326 2 : nMethod = rOption.GetEnum( aHTMLFormMethodTable, nMethod );
1327 2 : break;
1328 : case HTML_O_ENCTYPE:
1329 0 : nEncType = rOption.GetEnum( aHTMLFormEncTypeTable, nEncType );
1330 0 : break;
1331 : case HTML_O_TARGET:
1332 0 : sTarget = rOption.GetString();
1333 0 : break;
1334 : case HTML_O_NAME:
1335 0 : sName = rOption.GetString();
1336 0 : break;
1337 :
1338 : case HTML_O_SDONSUBMIT:
1339 0 : eScriptType2 = STARBASIC;
1340 : //fallthrough
1341 : case HTML_O_ONSUBMIT:
1342 0 : nEvent = HTML_ET_ONSUBMITFORM;
1343 0 : bSetEvent = sal_True;
1344 0 : break;
1345 :
1346 : case HTML_O_SDONRESET:
1347 0 : eScriptType2 = STARBASIC;
1348 : //fallthrough
1349 : case HTML_O_ONRESET:
1350 0 : nEvent = HTML_ET_ONRESETFORM;
1351 0 : bSetEvent = sal_True;
1352 0 : break;
1353 :
1354 : default:
1355 4 : lcl_html_getEvents( rOption.GetTokenString(),
1356 4 : rOption.GetString(),
1357 4 : aUnoMacroTbl, aUnoMacroParamTbl );
1358 4 : break;
1359 : }
1360 :
1361 6 : if( bSetEvent )
1362 : {
1363 0 : OUString sEvent( rOption.GetString() );
1364 0 : if( !sEvent.isEmpty() )
1365 : {
1366 0 : sEvent = convertLineEnd(sEvent, GetSystemLineEnd());
1367 0 : OUString aScriptType2;
1368 0 : if( EXTENDED_STYPE==eScriptType2 )
1369 0 : aScriptType2 = rDfltScriptType;
1370 0 : aMacroTbl.Insert( nEvent, SvxMacro( sEvent, aScriptType2, eScriptType2 ) );
1371 0 : }
1372 : }
1373 : }
1374 :
1375 : const uno::Reference< XMultiServiceFactory > & rSrvcMgr =
1376 2 : pFormImpl->GetServiceFactory();
1377 2 : if( !rSrvcMgr.is() )
1378 0 : return;
1379 :
1380 2 : uno::Reference< XInterface > xInt = rSrvcMgr->createInstance(
1381 2 : OUString("com.sun.star.form.component.Form") );
1382 2 : if( !xInt.is() )
1383 0 : return;
1384 :
1385 4 : uno::Reference< XForm > xForm( xInt, UNO_QUERY );
1386 : OSL_ENSURE( xForm.is(), "keine Form?" );
1387 :
1388 4 : uno::Reference< container::XIndexContainer > xFormComps( xForm, UNO_QUERY );
1389 2 : pFormImpl->SetFormComps( xFormComps );
1390 :
1391 4 : uno::Reference< beans::XPropertySet > xFormPropSet( xForm, UNO_QUERY );
1392 :
1393 4 : Any aTmp;
1394 2 : aTmp <<= OUString(sName);
1395 2 : xFormPropSet->setPropertyValue("Name", aTmp );
1396 :
1397 2 : if( !aAction.isEmpty() )
1398 : {
1399 2 : aAction = URIHelper::SmartRel2Abs(INetURLObject(sBaseURL), aAction, Link(), false);
1400 : }
1401 : else
1402 : {
1403 : // Bei leerer URL das Directory nehmen
1404 0 : INetURLObject aURLObj( aPathToFile );
1405 0 : aAction = aURLObj.GetPartBeforeLastName();
1406 : }
1407 2 : aTmp <<= OUString(aAction);
1408 2 : xFormPropSet->setPropertyValue("TargetURL",
1409 2 : aTmp );
1410 :
1411 2 : FormSubmitMethod eMethod = (FormSubmitMethod)nMethod;
1412 2 : aTmp.setValue( &eMethod, ::getCppuType((const FormSubmitMethod*)0) );
1413 2 : xFormPropSet->setPropertyValue("SubmitMethod",
1414 2 : aTmp );
1415 :
1416 2 : FormSubmitEncoding eEncType = (FormSubmitEncoding)nEncType;
1417 2 : aTmp.setValue( &eEncType, ::getCppuType((const FormSubmitEncoding*)0) );
1418 2 : xFormPropSet->setPropertyValue(
1419 2 : OUString("SubmitEncoding"), aTmp );
1420 :
1421 2 : if( !sTarget.isEmpty() )
1422 : {
1423 0 : aTmp <<= sTarget;
1424 0 : xFormPropSet->setPropertyValue( OUString("TargetFrame"), aTmp );
1425 : }
1426 :
1427 : const uno::Reference< container::XIndexContainer > & rForms =
1428 2 : pFormImpl->GetForms();
1429 4 : Any aAny( &xForm, ::getCppuType((uno::Reference< XForm>*)0) );
1430 2 : rForms->insertByIndex( rForms->getCount(), aAny );
1431 2 : if( !aMacroTbl.empty() )
1432 0 : lcl_html_setEvents( pFormImpl->GetFormEventManager(),
1433 0 : rForms->getCount() - 1,
1434 : aMacroTbl, aUnoMacroTbl, aUnoMacroParamTbl,
1435 4 : rDfltScriptType );
1436 : }
1437 :
1438 2 : void SwHTMLParser::EndForm( sal_Bool bAppend )
1439 : {
1440 2 : if( pFormImpl && pFormImpl->GetFormComps().is() )
1441 : {
1442 2 : if( bAppend )
1443 : {
1444 2 : if( pPam->GetPoint()->nContent.GetIndex() )
1445 0 : AppendTxtNode( AM_SPACE );
1446 : else
1447 2 : AddParSpace();
1448 : }
1449 :
1450 2 : pFormImpl->ReleaseFormComps();
1451 : }
1452 2 : }
1453 :
1454 4 : void SwHTMLParser::InsertInput()
1455 : {
1456 4 : if( pPendStack )
1457 : {
1458 0 : SetPendingControlSize();
1459 0 : return;
1460 : }
1461 :
1462 4 : if( !pFormImpl || !pFormImpl->GetFormComps().is() )
1463 0 : return;
1464 :
1465 8 : OUString sImgSrc, aId, aClass, aStyle, sName;
1466 8 : OUString sText;
1467 8 : SvxMacroTableDtor aMacroTbl;
1468 8 : std::vector<OUString> aUnoMacroTbl;
1469 8 : std::vector<OUString> aUnoMacroParamTbl;
1470 4 : sal_uInt16 nSize = 0;
1471 4 : sal_Int16 nMaxLen = 0;
1472 4 : sal_Int16 nChecked = TRISTATE_FALSE;
1473 4 : sal_Int32 nTabIndex = TABINDEX_MAX + 1;
1474 4 : HTMLInputType eType = HTML_IT_TEXT;
1475 4 : sal_Bool bDisabled = sal_False, bValue = sal_False;
1476 4 : sal_Bool bSetGrfWidth = sal_False, bSetGrfHeight = sal_False;
1477 4 : sal_Bool bHidden = sal_False;
1478 4 : long nWidth=0, nHeight=0;
1479 4 : sal_Int16 eVertOri = text::VertOrientation::TOP;
1480 4 : sal_Int16 eHoriOri = text::HoriOrientation::NONE;
1481 4 : SvKeyValueIterator *pHeaderAttrs = pFormImpl->GetHeaderAttrs();
1482 4 : ScriptType eDfltScriptType = GetScriptType( pHeaderAttrs );
1483 4 : const OUString& rDfltScriptType = GetScriptTypeString( pHeaderAttrs );
1484 :
1485 4 : sal_uInt16 nKeepCRLFToken = HTML_O_VALUE;
1486 4 : const HTMLOptions& rHTMLOptions = GetOptions( &nKeepCRLFToken );
1487 25 : for (size_t i = rHTMLOptions.size(); i; )
1488 : {
1489 17 : const HTMLOption& rOption = rHTMLOptions[--i];
1490 17 : ScriptType eScriptType2 = eDfltScriptType;
1491 17 : sal_uInt16 nEvent = 0;
1492 17 : sal_Bool bSetEvent = sal_False;
1493 :
1494 17 : switch( rOption.GetToken() )
1495 : {
1496 : case HTML_O_ID:
1497 2 : aId = rOption.GetString();
1498 2 : break;
1499 : case HTML_O_STYLE:
1500 0 : aStyle = rOption.GetString();
1501 0 : break;
1502 : case HTML_O_CLASS:
1503 1 : aClass = rOption.GetString();
1504 1 : break;
1505 : case HTML_O_TYPE:
1506 4 : eType = rOption.GetInputType();
1507 4 : break;
1508 : case HTML_O_NAME:
1509 4 : sName = rOption.GetString();
1510 4 : break;
1511 : case HTML_O_VALUE:
1512 3 : sText = rOption.GetString();
1513 3 : bValue = sal_True;
1514 3 : break;
1515 : case HTML_O_CHECKED:
1516 0 : nChecked = TRISTATE_TRUE;
1517 0 : break;
1518 : case HTML_O_DISABLED:
1519 0 : bDisabled = sal_True;
1520 0 : break;
1521 : case HTML_O_MAXLENGTH:
1522 0 : nMaxLen = (sal_Int16)rOption.GetNumber();
1523 0 : break;
1524 : case HTML_O_SIZE:
1525 0 : nSize = (sal_uInt16)rOption.GetNumber();
1526 0 : break;
1527 : case HTML_O_SRC:
1528 0 : sImgSrc = rOption.GetString();
1529 0 : break;
1530 : case HTML_O_WIDTH:
1531 : // erstmal nur als Pixelwerte merken!
1532 0 : nWidth = rOption.GetNumber();
1533 0 : break;
1534 : case HTML_O_HEIGHT:
1535 : // erstmal nur als Pixelwerte merken!
1536 0 : nHeight = rOption.GetNumber();
1537 0 : break;
1538 : case HTML_O_ALIGN:
1539 : eVertOri =
1540 0 : rOption.GetEnum( aHTMLImgVAlignTable, eVertOri );
1541 : eHoriOri =
1542 0 : rOption.GetEnum( aHTMLImgHAlignTable, eHoriOri );
1543 0 : break;
1544 : case HTML_O_TABINDEX:
1545 : // erstmal nur als Pixelwerte merken!
1546 2 : nTabIndex = rOption.GetNumber();
1547 2 : break;
1548 :
1549 : case HTML_O_SDONFOCUS:
1550 0 : eScriptType2 = STARBASIC;
1551 : //fallthrough
1552 : case HTML_O_ONFOCUS:
1553 0 : nEvent = HTML_ET_ONGETFOCUS;
1554 0 : bSetEvent = sal_True;
1555 0 : break;
1556 :
1557 : case HTML_O_SDONBLUR: // eigtl. nur EDIT
1558 0 : eScriptType2 = STARBASIC;
1559 : //fallthrough
1560 : case HTML_O_ONBLUR:
1561 0 : nEvent = HTML_ET_ONLOSEFOCUS;
1562 0 : bSetEvent = sal_True;
1563 0 : break;
1564 :
1565 : case HTML_O_SDONCLICK:
1566 0 : eScriptType2 = STARBASIC;
1567 : //fallthrough
1568 : case HTML_O_ONCLICK:
1569 0 : nEvent = HTML_ET_ONCLICK;
1570 0 : bSetEvent = sal_True;
1571 0 : break;
1572 :
1573 : case HTML_O_SDONCHANGE: // eigtl. nur EDIT
1574 0 : eScriptType2 = STARBASIC;
1575 : //fallthrough
1576 : case HTML_O_ONCHANGE:
1577 0 : nEvent = HTML_ET_ONCHANGE;
1578 0 : bSetEvent = sal_True;
1579 0 : break;
1580 :
1581 : case HTML_O_SDONSELECT: // eigtl. nur EDIT
1582 0 : eScriptType2 = STARBASIC;
1583 : //fallthrough
1584 : case HTML_O_ONSELECT:
1585 0 : nEvent = HTML_ET_ONSELECT;
1586 0 : bSetEvent = sal_True;
1587 0 : break;
1588 :
1589 : default:
1590 1 : lcl_html_getEvents( rOption.GetTokenString(),
1591 1 : rOption.GetString(),
1592 1 : aUnoMacroTbl, aUnoMacroParamTbl );
1593 1 : break;
1594 : }
1595 :
1596 17 : if( bSetEvent )
1597 : {
1598 0 : OUString sEvent( rOption.GetString() );
1599 0 : if( !sEvent.isEmpty() )
1600 : {
1601 0 : sEvent = convertLineEnd(sEvent, GetSystemLineEnd());
1602 0 : OUString aScriptType2;
1603 0 : if( EXTENDED_STYPE==eScriptType2 )
1604 0 : aScriptType2 = rDfltScriptType;
1605 0 : aMacroTbl.Insert( nEvent, SvxMacro( sEvent, aScriptType2, eScriptType2 ) );
1606 0 : }
1607 : }
1608 : }
1609 :
1610 4 : if( HTML_IT_IMAGE==eType )
1611 : {
1612 : // Image-Controls ohne Image-URL werden ignoriert (wie bei MS)
1613 0 : if( sImgSrc.isEmpty() )
1614 0 : return;
1615 : }
1616 : else
1617 : {
1618 : // ALIGN fuer alle Controls auszuwerten ist keine so gute Idee,
1619 : // solange Absatz-gebundene Controls die Hoehe von Tabellen-Zellen
1620 : // nicht beeinflussen
1621 4 : eVertOri = text::VertOrientation::TOP;
1622 4 : eHoriOri = text::HoriOrientation::NONE;
1623 : }
1624 :
1625 : // Defaults entsprechen HTML_IT_TEXT
1626 4 : const sal_Char *pType = "TextField";
1627 4 : sal_Bool bKeepCRLFInValue = sal_False;
1628 4 : switch( eType )
1629 : {
1630 : case HTML_IT_CHECKBOX:
1631 0 : pType = "CheckBox";
1632 0 : bKeepCRLFInValue = sal_True;
1633 0 : break;
1634 :
1635 : case HTML_IT_RADIO:
1636 0 : pType = "RadioButton";
1637 0 : bKeepCRLFInValue = sal_True;
1638 0 : break;
1639 :
1640 : case HTML_IT_PASSWORD:
1641 0 : bKeepCRLFInValue = sal_True;
1642 0 : break;
1643 :
1644 : case HTML_IT_BUTTON:
1645 0 : bKeepCRLFInValue = sal_True;
1646 : case HTML_IT_SUBMIT:
1647 : case HTML_IT_RESET:
1648 1 : pType = "CommandButton";
1649 1 : break;
1650 :
1651 : case HTML_IT_IMAGE:
1652 0 : pType = "ImageButton";
1653 0 : break;
1654 :
1655 : case HTML_IT_FILE:
1656 0 : pType = "FileControl";
1657 0 : break;
1658 :
1659 : case HTML_IT_HIDDEN:
1660 2 : pType = "HiddenControl";
1661 2 : bKeepCRLFInValue = sal_True;
1662 2 : break;
1663 : default:
1664 : ;
1665 : }
1666 :
1667 : // Fuer ein par Controls mussen CR/LF noch aus dem VALUE
1668 : // geloescht werden.
1669 4 : if( !bKeepCRLFInValue )
1670 : {
1671 2 : sText = comphelper::string::remove(sText, '\r');
1672 2 : sText = comphelper::string::remove(sText, '\n');
1673 : }
1674 :
1675 : const uno::Reference< XMultiServiceFactory > & rServiceFactory =
1676 4 : pFormImpl->GetServiceFactory();
1677 4 : if( !rServiceFactory.is() )
1678 0 : return;
1679 :
1680 4 : OUString sServiceName("com.sun.star.form.component.");
1681 4 : sServiceName += OUString::createFromAscii(pType);
1682 : uno::Reference< XInterface > xInt =
1683 8 : rServiceFactory->createInstance( sServiceName );
1684 4 : if( !xInt.is() )
1685 0 : return;
1686 :
1687 8 : uno::Reference< XFormComponent > xFComp( xInt, UNO_QUERY );
1688 4 : if( !xFComp.is() )
1689 0 : return;
1690 :
1691 8 : uno::Reference< beans::XPropertySet > xPropSet( xFComp, UNO_QUERY );
1692 :
1693 8 : Any aTmp;
1694 4 : aTmp <<= OUString(sName);
1695 4 : xPropSet->setPropertyValue("Name", aTmp );
1696 :
1697 4 : if( HTML_IT_HIDDEN != eType )
1698 : {
1699 2 : if( nTabIndex >= TABINDEX_MIN && nTabIndex <= TABINDEX_MAX )
1700 : {
1701 2 : aTmp <<= (sal_Int16) (sal_Int16)nTabIndex ;
1702 2 : xPropSet->setPropertyValue("TabIndex", aTmp );
1703 : }
1704 :
1705 2 : if( bDisabled )
1706 : {
1707 0 : sal_Bool bFalse = sal_False;
1708 0 : aTmp.setValue(&bFalse, ::getBooleanCppuType() );
1709 0 : xPropSet->setPropertyValue("Enabled", aTmp );
1710 : }
1711 : }
1712 :
1713 4 : aTmp <<= sText;
1714 :
1715 4 : Size aSz( 0, 0 ); // defaults
1716 4 : Size aTextSz( 0, 0 ); // Text-Size
1717 4 : sal_Bool bMinWidth = sal_False, bMinHeight = sal_False;
1718 4 : sal_Bool bUseSize = sal_False;
1719 4 : switch( eType )
1720 : {
1721 : case HTML_IT_CHECKBOX:
1722 : case HTML_IT_RADIO:
1723 : {
1724 0 : if( !bValue )
1725 0 : aTmp <<= OUString( OOO_STRING_SVTOOLS_HTML_on );
1726 0 : xPropSet->setPropertyValue("RefValue",
1727 0 : aTmp );
1728 0 : aTmp <<= OUString();
1729 0 : xPropSet->setPropertyValue("Label",
1730 0 : aTmp );
1731 : // Beim RadioButton darf die DefaultChecked-Property
1732 : // erst gesetzt werden, wenn das Control angelegt und ein
1733 : // activateTabOrder gerufen wurde, weil es sonst noch zu der
1734 : // vorhergehenden Gruppe gehoert.
1735 0 : if( HTML_IT_CHECKBOX == eType )
1736 : {
1737 0 : aTmp <<= (sal_Int16) nChecked ;
1738 0 : xPropSet->setPropertyValue(
1739 0 : OUString("DefaultState"), aTmp );
1740 : }
1741 :
1742 0 : const SvxMacro* pMacro = aMacroTbl.Get( HTML_ET_ONCLICK );
1743 0 : if( pMacro )
1744 : {
1745 0 : aMacroTbl.Insert( HTML_ET_ONCLICK_ITEM, *pMacro );
1746 0 : aMacroTbl.Erase( HTML_ET_ONCLICK );
1747 : }
1748 : // SIZE auszuwerten duerfte hier keinen Sinn machen???
1749 0 : bMinWidth = bMinHeight = sal_True;
1750 : }
1751 0 : break;
1752 :
1753 : case HTML_IT_IMAGE:
1754 : {
1755 : // SIZE = WIDTH
1756 0 : aSz.Width() = nSize ? nSize : nWidth;
1757 0 : aSz.Width() = nWidth;
1758 0 : aSz.Height() = nHeight;
1759 0 : if( (aSz.Width() || aSz.Height()) && Application::GetDefaultDevice() )
1760 : {
1761 : aSz = Application::GetDefaultDevice()
1762 0 : ->PixelToLogic( aSz, MapMode( MAP_100TH_MM ) );
1763 : }
1764 0 : FormButtonType eButtonType = FormButtonType_SUBMIT;
1765 : aTmp.setValue( &eButtonType,
1766 0 : ::getCppuType((const FormButtonType*)0));
1767 0 : xPropSet->setPropertyValue(
1768 0 : OUString("ButtonType"), aTmp );
1769 :
1770 0 : aTmp <<= (sal_Int16) 0 ;
1771 0 : xPropSet->setPropertyValue("Border",
1772 0 : aTmp );
1773 : }
1774 0 : break;
1775 :
1776 : case HTML_IT_BUTTON:
1777 : case HTML_IT_SUBMIT:
1778 : case HTML_IT_RESET:
1779 : {
1780 : FormButtonType eButtonType;
1781 1 : switch( eType )
1782 : {
1783 : case HTML_IT_BUTTON:
1784 0 : eButtonType = FormButtonType_PUSH;
1785 0 : break;
1786 : case HTML_IT_SUBMIT:
1787 1 : eButtonType = FormButtonType_SUBMIT;
1788 1 : if (sText.isEmpty())
1789 0 : sText = OOO_STRING_SVTOOLS_HTML_IT_submit;
1790 1 : break;
1791 : case HTML_IT_RESET:
1792 0 : eButtonType = FormButtonType_RESET;
1793 0 : if (sText.isEmpty())
1794 0 : sText = OOO_STRING_SVTOOLS_HTML_IT_reset;
1795 0 : break;
1796 : default:
1797 : ;
1798 : }
1799 1 : aTmp <<= sText;
1800 1 : xPropSet->setPropertyValue("Label",
1801 1 : aTmp );
1802 :
1803 : aTmp.setValue( &eButtonType,
1804 1 : ::getCppuType((const FormButtonType*)0));
1805 1 : xPropSet->setPropertyValue(
1806 1 : OUString("ButtonType"), aTmp );
1807 :
1808 1 : bMinWidth = bMinHeight = sal_True;
1809 1 : bUseSize = sal_True;
1810 : }
1811 1 : break;
1812 :
1813 : case HTML_IT_PASSWORD:
1814 : case HTML_IT_TEXT:
1815 : case HTML_IT_FILE:
1816 1 : if( HTML_IT_FILE != eType )
1817 : {
1818 : // Beim File-Control wird der VALUE aus Sicherheitsgruenden ignoriert.
1819 1 : xPropSet->setPropertyValue(
1820 1 : OUString("DefaultText"), aTmp );
1821 1 : if( nMaxLen != 0 )
1822 : {
1823 0 : aTmp <<= (sal_Int16) nMaxLen ;
1824 0 : xPropSet->setPropertyValue(
1825 0 : OUString("MaxTextLen"), aTmp );
1826 : }
1827 : }
1828 :
1829 1 : if( HTML_IT_PASSWORD == eType )
1830 : {
1831 0 : aTmp <<= (sal_Int16)'*' ;
1832 0 : xPropSet->setPropertyValue("EchoChar",
1833 0 : aTmp );
1834 : }
1835 :
1836 1 : lcl_html_setFixedFontProperty( xPropSet );
1837 :
1838 1 : if( !nSize )
1839 1 : nSize = 20;
1840 1 : aTextSz.Width() = nSize;
1841 1 : bMinHeight = sal_True;
1842 1 : break;
1843 :
1844 : case HTML_IT_HIDDEN:
1845 2 : xPropSet->setPropertyValue("HiddenValue",
1846 2 : aTmp );
1847 2 : bHidden = sal_True;
1848 2 : break;
1849 : default:
1850 : ;
1851 : }
1852 :
1853 4 : if( bUseSize && nSize>0 )
1854 : {
1855 0 : if( Application::GetDefaultDevice() )
1856 : {
1857 0 : Size aNewSz( nSize, 0 );
1858 : aNewSz = Application::GetDefaultDevice()
1859 0 : ->PixelToLogic( aNewSz, MapMode( MAP_100TH_MM ) );
1860 0 : aSz.Width() = aNewSz.Width();
1861 : OSL_ENSURE( !aTextSz.Width(), "Text-Breite ist gegeben" );
1862 0 : bMinWidth = sal_False;
1863 : }
1864 : }
1865 :
1866 4 : SfxItemSet aCSS1ItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
1867 8 : SvxCSS1PropertyInfo aCSS1PropInfo;
1868 4 : if( HasStyleOptions( aStyle, aId, aClass ) )
1869 : {
1870 2 : ParseStyleOptions( aStyle, aId, aClass, aCSS1ItemSet, aCSS1PropInfo );
1871 2 : if( !aId.isEmpty() )
1872 2 : InsertBookmark( aId );
1873 : }
1874 :
1875 4 : if( SVX_CSS1_LTYPE_TWIP== aCSS1PropInfo.eWidthType )
1876 : {
1877 0 : aSz.Width() = TWIP_TO_MM100( aCSS1PropInfo.nWidth );
1878 0 : aTextSz.Width() = 0;
1879 0 : bMinWidth = sal_False;
1880 : }
1881 4 : if( SVX_CSS1_LTYPE_TWIP== aCSS1PropInfo.eHeightType )
1882 : {
1883 0 : aSz.Height() = TWIP_TO_MM100( aCSS1PropInfo.nHeight );
1884 0 : aTextSz.Height() = 0;
1885 0 : bMinHeight = sal_False;
1886 : }
1887 :
1888 : // Beim Image-Button bei nicht gegebern Groesse einen sinnvollen Default
1889 : // setzen
1890 4 : if( HTML_IT_IMAGE== eType )
1891 : {
1892 0 : if( !aSz.Width() )
1893 : {
1894 0 : aSz.Width() = HTML_DFLT_IMG_WIDTH;
1895 0 : bSetGrfWidth = sal_True;
1896 0 : if( pTable != 0 )
1897 0 : IncGrfsThatResizeTable();
1898 : }
1899 0 : if( !aSz.Height() )
1900 : {
1901 0 : aSz.Height() = HTML_DFLT_IMG_HEIGHT;
1902 0 : bSetGrfHeight = sal_True;
1903 : }
1904 : }
1905 4 : if( aSz.Width() < MINFLY )
1906 4 : aSz.Width() = MINFLY;
1907 4 : if( aSz.Height() < MINFLY )
1908 4 : aSz.Height() = MINFLY;
1909 :
1910 : uno::Reference< drawing::XShape > xShape = InsertControl(
1911 : xFComp, xPropSet, aSz,
1912 : eVertOri, eHoriOri,
1913 : aCSS1ItemSet, aCSS1PropInfo,
1914 : aMacroTbl, aUnoMacroTbl,
1915 : aUnoMacroParamTbl, sal_False,
1916 8 : bHidden );
1917 4 : if( aTextSz.Width() || aTextSz.Height() || bMinWidth || bMinHeight )
1918 : {
1919 : OSL_ENSURE( !(bSetGrfWidth || bSetGrfHeight), "Grafikgroesse anpassen???" );
1920 2 : SetControlSize( xShape, aTextSz, bMinWidth, bMinHeight );
1921 : }
1922 :
1923 4 : if( HTML_IT_RADIO == eType )
1924 : {
1925 0 : aTmp <<= (sal_Int16) nChecked ;
1926 0 : xPropSet->setPropertyValue("DefaultState", aTmp );
1927 : }
1928 :
1929 4 : if( HTML_IT_IMAGE == eType )
1930 : {
1931 : // Die URL erst nach dem Einfuegen setzen, weil sich der
1932 : // Download der Grafik erst dann am XModel anmelden kann,
1933 : // wenn das Control eingefuegt ist.
1934 0 : aTmp <<= OUString( URIHelper::SmartRel2Abs(INetURLObject(sBaseURL), sImgSrc, Link(), false));
1935 0 : xPropSet->setPropertyValue("ImageURL",
1936 0 : aTmp );
1937 : }
1938 :
1939 4 : if( bSetGrfWidth || bSetGrfHeight )
1940 : {
1941 : SwHTMLImageWatcher* pWatcher =
1942 0 : new SwHTMLImageWatcher( xShape, bSetGrfWidth, bSetGrfHeight );
1943 0 : uno::Reference< awt::XImageConsumer > xCons = pWatcher;
1944 0 : pWatcher->start();
1945 12 : }
1946 : }
1947 :
1948 0 : void SwHTMLParser::NewTextArea()
1949 : {
1950 0 : if( pPendStack )
1951 : {
1952 0 : SetPendingControlSize();
1953 0 : return;
1954 : }
1955 :
1956 : OSL_ENSURE( !bTextArea, "TextArea in TextArea???" );
1957 : OSL_ENSURE( !pFormImpl || !pFormImpl->GetFCompPropSet().is(),
1958 : "TextArea in Control???" );
1959 :
1960 0 : if( !pFormImpl || !pFormImpl->GetFormComps().is() )
1961 : {
1962 : // Spezialbehandlung fuer TextArea auch untem im Parser beenden
1963 0 : FinishTextArea();
1964 0 : return;
1965 : }
1966 :
1967 0 : OUString aId, aClass, aStyle;
1968 0 : OUString sName;
1969 0 : sal_Int32 nTabIndex = TABINDEX_MAX + 1;
1970 0 : SvxMacroTableDtor aMacroTbl;
1971 0 : std::vector<OUString> aUnoMacroTbl;
1972 0 : std::vector<OUString> aUnoMacroParamTbl;
1973 0 : sal_uInt16 nRows = 0, nCols = 0;
1974 0 : sal_uInt16 nWrap = HTML_WM_OFF;
1975 0 : sal_Bool bDisabled = sal_False;
1976 0 : SvKeyValueIterator *pHeaderAttrs = pFormImpl->GetHeaderAttrs();
1977 0 : ScriptType eDfltScriptType = GetScriptType( pHeaderAttrs );
1978 0 : const OUString& rDfltScriptType = GetScriptTypeString( pHeaderAttrs );
1979 :
1980 0 : const HTMLOptions& rHTMLOptions = GetOptions();
1981 0 : for (size_t i = rHTMLOptions.size(); i; )
1982 : {
1983 0 : const HTMLOption& rOption = rHTMLOptions[--i];
1984 0 : ScriptType eScriptType2 = eDfltScriptType;
1985 0 : sal_uInt16 nEvent = 0;
1986 0 : sal_Bool bSetEvent = sal_False;
1987 :
1988 0 : switch( rOption.GetToken() )
1989 : {
1990 : case HTML_O_ID:
1991 0 : aId = rOption.GetString();
1992 0 : break;
1993 : case HTML_O_STYLE:
1994 0 : aStyle = rOption.GetString();
1995 0 : break;
1996 : case HTML_O_CLASS:
1997 0 : aClass = rOption.GetString();
1998 0 : break;
1999 : case HTML_O_NAME:
2000 0 : sName = rOption.GetString();
2001 0 : break;
2002 : case HTML_O_DISABLED:
2003 0 : bDisabled = sal_True;
2004 0 : break;
2005 : case HTML_O_ROWS:
2006 0 : nRows = (sal_uInt16)rOption.GetNumber();
2007 0 : break;
2008 : case HTML_O_COLS:
2009 0 : nCols = (sal_uInt16)rOption.GetNumber();
2010 0 : break;
2011 : case HTML_O_WRAP:
2012 0 : nWrap = rOption.GetEnum( aHTMLTextAreaWrapTable, nWrap );
2013 0 : break;
2014 :
2015 : case HTML_O_TABINDEX:
2016 0 : nTabIndex = rOption.GetSNumber();
2017 0 : break;
2018 :
2019 : case HTML_O_SDONFOCUS:
2020 0 : eScriptType2 = STARBASIC;
2021 : //fallthrough
2022 : case HTML_O_ONFOCUS:
2023 0 : nEvent = HTML_ET_ONGETFOCUS;
2024 0 : bSetEvent = sal_True;
2025 0 : break;
2026 :
2027 : case HTML_O_SDONBLUR:
2028 0 : eScriptType2 = STARBASIC;
2029 : //fallthrough
2030 : case HTML_O_ONBLUR:
2031 0 : nEvent = HTML_ET_ONLOSEFOCUS;
2032 0 : bSetEvent = sal_True;
2033 0 : break;
2034 :
2035 : case HTML_O_SDONCLICK:
2036 0 : eScriptType2 = STARBASIC;
2037 : //fallthrough
2038 : case HTML_O_ONCLICK:
2039 0 : nEvent = HTML_ET_ONCLICK;
2040 0 : bSetEvent = sal_True;
2041 0 : break;
2042 :
2043 : case HTML_O_SDONCHANGE:
2044 0 : eScriptType2 = STARBASIC;
2045 : //fallthrough
2046 : case HTML_O_ONCHANGE:
2047 0 : nEvent = HTML_ET_ONCHANGE;
2048 0 : bSetEvent = sal_True;
2049 0 : break;
2050 :
2051 : case HTML_O_SDONSELECT:
2052 0 : eScriptType2 = STARBASIC;
2053 : //fallthrough
2054 : case HTML_O_ONSELECT:
2055 0 : nEvent = HTML_ET_ONSELECT;
2056 0 : bSetEvent = sal_True;
2057 0 : break;
2058 :
2059 : default:
2060 0 : lcl_html_getEvents( rOption.GetTokenString(),
2061 0 : rOption.GetString(),
2062 0 : aUnoMacroTbl, aUnoMacroParamTbl );
2063 0 : break;
2064 : }
2065 :
2066 0 : if( bSetEvent )
2067 : {
2068 0 : OUString sEvent( rOption.GetString() );
2069 0 : if( !sEvent.isEmpty() )
2070 : {
2071 0 : sEvent = convertLineEnd(sEvent, GetSystemLineEnd());
2072 0 : if( EXTENDED_STYPE==eScriptType2 )
2073 0 : aScriptType = rDfltScriptType;
2074 0 : aMacroTbl.Insert( nEvent, SvxMacro( sEvent, aScriptType, eScriptType2 ) );
2075 0 : }
2076 : }
2077 : }
2078 :
2079 : const uno::Reference< lang::XMultiServiceFactory > & rSrvcMgr =
2080 0 : pFormImpl->GetServiceFactory();
2081 0 : if( !rSrvcMgr.is() )
2082 : {
2083 0 : FinishTextArea();
2084 0 : return;
2085 : }
2086 0 : uno::Reference< uno::XInterface > xInt = rSrvcMgr->createInstance(
2087 0 : OUString("com.sun.star.form.component.TextField") );
2088 0 : if( !xInt.is() )
2089 : {
2090 0 : FinishTextArea();
2091 0 : return;
2092 : }
2093 :
2094 0 : uno::Reference< XFormComponent > xFComp( xInt, UNO_QUERY );
2095 : OSL_ENSURE( xFComp.is(), "keine FormComponent?" );
2096 :
2097 0 : uno::Reference< beans::XPropertySet > xPropSet( xFComp, UNO_QUERY );
2098 :
2099 0 : Any aTmp;
2100 0 : aTmp <<= OUString(sName);
2101 0 : xPropSet->setPropertyValue("Name", aTmp );
2102 :
2103 0 : sal_Bool bTrue = sal_True;
2104 0 : aTmp.setValue( &bTrue, ::getBooleanCppuType() );
2105 0 : xPropSet->setPropertyValue("MultiLine",
2106 0 : aTmp );
2107 0 : xPropSet->setPropertyValue("VScroll", aTmp );
2108 0 : if( HTML_WM_OFF == nWrap )
2109 0 : xPropSet->setPropertyValue("HScroll",
2110 0 : aTmp );
2111 0 : if( HTML_WM_HARD == nWrap )
2112 0 : xPropSet->setPropertyValue(
2113 0 : OUString("HardLineBreaks"), aTmp );
2114 :
2115 0 : if( nTabIndex >= TABINDEX_MIN && nTabIndex <= TABINDEX_MAX )
2116 : {
2117 0 : aTmp <<= (sal_Int16)nTabIndex ;
2118 0 : xPropSet->setPropertyValue("TabIndex",
2119 0 : aTmp );
2120 : }
2121 :
2122 0 : lcl_html_setFixedFontProperty( xPropSet );
2123 :
2124 0 : if( bDisabled )
2125 : {
2126 0 : sal_Bool bFalse = sal_False;
2127 0 : aTmp.setValue( &bFalse, ::getBooleanCppuType() );
2128 0 : xPropSet->setPropertyValue("Enabled",
2129 0 : aTmp );
2130 : }
2131 :
2132 : OSL_ENSURE( pFormImpl->GetText().isEmpty(), "Text ist nicht leer!" );
2133 :
2134 0 : if( !nCols )
2135 0 : nCols = 20;
2136 0 : if( !nRows )
2137 0 : nRows = 1;
2138 :
2139 0 : Size aTextSz( nCols, nRows );
2140 :
2141 0 : SfxItemSet aCSS1ItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
2142 0 : SvxCSS1PropertyInfo aCSS1PropInfo;
2143 0 : if( HasStyleOptions( aStyle, aId, aClass ) )
2144 : {
2145 0 : ParseStyleOptions( aStyle, aId, aClass, aCSS1ItemSet, aCSS1PropInfo );
2146 0 : if( !aId.isEmpty() )
2147 0 : InsertBookmark( aId );
2148 : }
2149 :
2150 0 : Size aSz( MINFLY, MINFLY );
2151 0 : if( SVX_CSS1_LTYPE_TWIP== aCSS1PropInfo.eWidthType )
2152 : {
2153 0 : aSz.Width() = TWIP_TO_MM100( aCSS1PropInfo.nWidth );
2154 0 : aTextSz.Width() = 0;
2155 : }
2156 0 : if( SVX_CSS1_LTYPE_TWIP== aCSS1PropInfo.eHeightType )
2157 : {
2158 0 : aSz.Height() = TWIP_TO_MM100( aCSS1PropInfo.nHeight );
2159 0 : aTextSz.Height() = 0;
2160 : }
2161 0 : if( aSz.Width() < MINFLY )
2162 0 : aSz.Width() = MINFLY;
2163 0 : if( aSz.Height() < MINFLY )
2164 0 : aSz.Height() = MINFLY;
2165 :
2166 : uno::Reference< drawing::XShape > xShape = InsertControl( xFComp, xPropSet, aSz,
2167 : text::VertOrientation::TOP, text::HoriOrientation::NONE,
2168 : aCSS1ItemSet, aCSS1PropInfo,
2169 : aMacroTbl, aUnoMacroTbl,
2170 0 : aUnoMacroParamTbl );
2171 0 : if( aTextSz.Width() || aTextSz.Height() )
2172 0 : SetControlSize( xShape, aTextSz, sal_False, sal_False );
2173 :
2174 : // einen neuen Kontext anlegen
2175 0 : _HTMLAttrContext *pCntxt = new _HTMLAttrContext( HTML_TEXTAREA_ON );
2176 :
2177 : // und PRE/Listing/XMP voruebergehend aussetzen
2178 0 : SplitPREListingXMP( pCntxt );
2179 0 : PushContext( pCntxt );
2180 :
2181 0 : bTextArea = true;
2182 0 : bTAIgnoreNewPara = true;
2183 : }
2184 :
2185 0 : void SwHTMLParser::EndTextArea()
2186 : {
2187 : OSL_ENSURE( bTextArea, "keine TextArea oder falscher Typ" );
2188 : OSL_ENSURE( pFormImpl && pFormImpl->GetFCompPropSet().is(),
2189 : "TextArea fehlt" );
2190 :
2191 : const uno::Reference< beans::XPropertySet > & rPropSet =
2192 0 : pFormImpl->GetFCompPropSet();
2193 :
2194 0 : Any aTmp;
2195 0 : aTmp <<= pFormImpl->GetText();
2196 0 : rPropSet->setPropertyValue("DefaultText",
2197 0 : aTmp );
2198 0 : pFormImpl->EraseText();
2199 :
2200 0 : pFormImpl->ReleaseFCompPropSet();
2201 :
2202 : // den Kontext holen
2203 0 : _HTMLAttrContext *pCntxt = PopContext( HTML_TEXTAREA_ON );
2204 0 : if( pCntxt )
2205 : {
2206 : // und ggf. die Attribute beenden
2207 0 : EndContext( pCntxt );
2208 0 : delete pCntxt;
2209 : }
2210 :
2211 0 : bTextArea = false;
2212 0 : }
2213 :
2214 0 : void SwHTMLParser::InsertTextAreaText( sal_uInt16 nToken )
2215 : {
2216 : OSL_ENSURE( bTextArea, "keine TextArea oder falscher Typ" );
2217 : OSL_ENSURE( pFormImpl && pFormImpl->GetFCompPropSet().is(),
2218 : "TextArea fehlt" );
2219 :
2220 0 : OUString& rText = pFormImpl->GetText();
2221 0 : switch( nToken)
2222 : {
2223 : case HTML_TEXTTOKEN:
2224 0 : rText += aToken;
2225 0 : break;
2226 : case HTML_NEWPARA:
2227 0 : if( !bTAIgnoreNewPara )
2228 0 : rText += "\n"; // das ist hier richtig!!!
2229 0 : break;
2230 : default:
2231 0 : rText += "<";
2232 0 : rText += sSaveToken;
2233 0 : if( !aToken.isEmpty() )
2234 : {
2235 0 : rText += " ";
2236 0 : rText += aToken;
2237 : }
2238 0 : rText += ">";
2239 : }
2240 :
2241 0 : bTAIgnoreNewPara = false;
2242 0 : }
2243 :
2244 0 : void SwHTMLParser::NewSelect()
2245 : {
2246 0 : if( pPendStack )
2247 : {
2248 0 : SetPendingControlSize();
2249 0 : return;
2250 : }
2251 :
2252 : OSL_ENSURE( !bSelect, "Select in Select???" );
2253 : OSL_ENSURE( !pFormImpl || !pFormImpl->GetFCompPropSet().is(),
2254 : "Select in Control???" );
2255 :
2256 0 : if( !pFormImpl || !pFormImpl->GetFormComps().is() )
2257 0 : return;
2258 :
2259 0 : OUString aId, aClass, aStyle;
2260 0 : OUString sName;
2261 0 : sal_Int32 nTabIndex = TABINDEX_MAX + 1;
2262 0 : SvxMacroTableDtor aMacroTbl;
2263 0 : std::vector<OUString> aUnoMacroTbl;
2264 0 : std::vector<OUString> aUnoMacroParamTbl;
2265 0 : sal_Bool bMultiple = sal_False;
2266 0 : sal_Bool bDisabled = sal_False;
2267 0 : nSelectEntryCnt = 1;
2268 0 : SvKeyValueIterator *pHeaderAttrs = pFormImpl->GetHeaderAttrs();
2269 0 : ScriptType eDfltScriptType = GetScriptType( pHeaderAttrs );
2270 0 : const OUString& rDfltScriptType = GetScriptTypeString( pHeaderAttrs );
2271 :
2272 0 : const HTMLOptions& rHTMLOptions = GetOptions();
2273 0 : for (size_t i = rHTMLOptions.size(); i; )
2274 : {
2275 0 : const HTMLOption& rOption = rHTMLOptions[--i];
2276 0 : ScriptType eScriptType2 = eDfltScriptType;
2277 0 : sal_uInt16 nEvent = 0;
2278 0 : sal_Bool bSetEvent = sal_False;
2279 :
2280 0 : switch( rOption.GetToken() )
2281 : {
2282 : case HTML_O_ID:
2283 0 : aId = rOption.GetString();
2284 0 : break;
2285 : case HTML_O_STYLE:
2286 0 : aStyle = rOption.GetString();
2287 0 : break;
2288 : case HTML_O_CLASS:
2289 0 : aClass = rOption.GetString();
2290 0 : break;
2291 : case HTML_O_NAME:
2292 0 : sName = rOption.GetString();
2293 0 : break;
2294 : case HTML_O_MULTIPLE:
2295 0 : bMultiple = sal_True;
2296 0 : break;
2297 : case HTML_O_DISABLED:
2298 0 : bDisabled = sal_True;
2299 0 : break;
2300 : case HTML_O_SIZE:
2301 0 : nSelectEntryCnt = (sal_uInt16)rOption.GetNumber();
2302 0 : break;
2303 :
2304 : case HTML_O_TABINDEX:
2305 0 : nTabIndex = rOption.GetSNumber();
2306 0 : break;
2307 :
2308 : case HTML_O_SDONFOCUS:
2309 0 : eScriptType2 = STARBASIC;
2310 : case HTML_O_ONFOCUS:
2311 0 : nEvent = HTML_ET_ONGETFOCUS;
2312 0 : bSetEvent = sal_True;
2313 0 : break;
2314 :
2315 : case HTML_O_SDONBLUR:
2316 0 : eScriptType2 = STARBASIC;
2317 : case HTML_O_ONBLUR:
2318 0 : nEvent = HTML_ET_ONLOSEFOCUS;
2319 0 : bSetEvent = sal_True;
2320 0 : break;
2321 :
2322 : case HTML_O_SDONCLICK:
2323 0 : eScriptType2 = STARBASIC;
2324 : case HTML_O_ONCLICK:
2325 0 : nEvent = HTML_ET_ONCLICK;
2326 0 : bSetEvent = sal_True;
2327 0 : break;
2328 :
2329 : case HTML_O_SDONCHANGE:
2330 0 : eScriptType2 = STARBASIC;
2331 : case HTML_O_ONCHANGE:
2332 0 : nEvent = HTML_ET_ONCHANGE;
2333 0 : bSetEvent = sal_True;
2334 0 : break;
2335 :
2336 : default:
2337 0 : lcl_html_getEvents( rOption.GetTokenString(),
2338 0 : rOption.GetString(),
2339 0 : aUnoMacroTbl, aUnoMacroParamTbl );
2340 0 : break;
2341 : }
2342 :
2343 0 : if( bSetEvent )
2344 : {
2345 0 : OUString sEvent( rOption.GetString() );
2346 0 : if( !sEvent.isEmpty() )
2347 : {
2348 0 : sEvent = convertLineEnd(sEvent, GetSystemLineEnd());
2349 0 : if( EXTENDED_STYPE==eScriptType2 )
2350 0 : aScriptType = rDfltScriptType;
2351 0 : aMacroTbl.Insert( nEvent, SvxMacro( sEvent, aScriptType, eScriptType2 ) );
2352 0 : }
2353 : }
2354 : }
2355 :
2356 : const uno::Reference< lang::XMultiServiceFactory > & rSrvcMgr =
2357 0 : pFormImpl->GetServiceFactory();
2358 0 : if( !rSrvcMgr.is() )
2359 : {
2360 0 : FinishTextArea();
2361 0 : return;
2362 : }
2363 0 : uno::Reference< uno::XInterface > xInt = rSrvcMgr->createInstance(
2364 0 : OUString("com.sun.star.form.component.ListBox") );
2365 0 : if( !xInt.is() )
2366 : {
2367 0 : FinishTextArea();
2368 0 : return;
2369 : }
2370 :
2371 0 : uno::Reference< XFormComponent > xFComp( xInt, UNO_QUERY );
2372 : OSL_ENSURE(xFComp.is(), "keine FormComponent?");
2373 :
2374 0 : uno::Reference< beans::XPropertySet > xPropSet( xFComp, UNO_QUERY );
2375 :
2376 0 : Any aTmp;
2377 0 : aTmp <<= OUString(sName);
2378 0 : xPropSet->setPropertyValue("Name", aTmp );
2379 :
2380 0 : if( nTabIndex >= TABINDEX_MIN && nTabIndex <= TABINDEX_MAX )
2381 : {
2382 0 : aTmp <<= (sal_Int16)nTabIndex ;
2383 0 : xPropSet->setPropertyValue("TabIndex",
2384 0 : aTmp );
2385 : }
2386 :
2387 0 : if( bDisabled )
2388 : {
2389 0 : sal_Bool bFalse = sal_False;
2390 0 : aTmp.setValue( &bFalse, ::getBooleanCppuType() );
2391 0 : xPropSet->setPropertyValue("Enabled",
2392 0 : aTmp );
2393 : }
2394 :
2395 0 : Size aTextSz( 0, 0 );
2396 0 : sal_Bool bMinWidth = sal_True, bMinHeight = sal_True;
2397 0 : if( !bMultiple && 1==nSelectEntryCnt )
2398 : {
2399 0 : sal_Bool bTrue = sal_True;
2400 0 : aTmp.setValue( &bTrue, ::getBooleanCppuType() );
2401 0 : xPropSet->setPropertyValue("Dropdown",
2402 0 : aTmp );
2403 : }
2404 : else
2405 : {
2406 0 : if( nSelectEntryCnt <= 1 ) // 4 Zeilen als default
2407 0 : nSelectEntryCnt = 4;
2408 :
2409 0 : if( bMultiple )
2410 : {
2411 0 : sal_Bool bTrue = sal_True;
2412 0 : aTmp.setValue( &bTrue, ::getBooleanCppuType() );
2413 0 : xPropSet->setPropertyValue(
2414 0 : OUString("MultiSelection"), aTmp );
2415 : }
2416 0 : aTextSz.Height() = nSelectEntryCnt;
2417 0 : bMinHeight = sal_False;
2418 : }
2419 :
2420 0 : SfxItemSet aCSS1ItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
2421 0 : SvxCSS1PropertyInfo aCSS1PropInfo;
2422 0 : if( HasStyleOptions( aStyle, aId, aClass ) )
2423 : {
2424 0 : ParseStyleOptions( aStyle, aId, aClass, aCSS1ItemSet, aCSS1PropInfo );
2425 0 : if( !aId.isEmpty() )
2426 0 : InsertBookmark( aId );
2427 : }
2428 :
2429 0 : Size aSz( MINFLY, MINFLY );
2430 0 : bFixSelectWidth = bFixSelectHeight = true;
2431 0 : if( SVX_CSS1_LTYPE_TWIP== aCSS1PropInfo.eWidthType )
2432 : {
2433 0 : aSz.Width() = TWIP_TO_MM100( aCSS1PropInfo.nWidth );
2434 0 : bFixSelectWidth = false;
2435 0 : bMinWidth = sal_False;
2436 : }
2437 0 : if( SVX_CSS1_LTYPE_TWIP== aCSS1PropInfo.eHeightType )
2438 : {
2439 0 : aSz.Height() = TWIP_TO_MM100( aCSS1PropInfo.nHeight );
2440 0 : aTextSz.Height() = sal_False;
2441 0 : bMinHeight = sal_False;
2442 : }
2443 0 : if( aSz.Width() < MINFLY )
2444 0 : aSz.Width() = MINFLY;
2445 0 : if( aSz.Height() < MINFLY )
2446 0 : aSz.Height() = MINFLY;
2447 :
2448 : uno::Reference< drawing::XShape > xShape = InsertControl( xFComp, xPropSet, aSz,
2449 : text::VertOrientation::TOP, text::HoriOrientation::NONE,
2450 : aCSS1ItemSet, aCSS1PropInfo,
2451 : aMacroTbl, aUnoMacroTbl,
2452 0 : aUnoMacroParamTbl );
2453 0 : if( bFixSelectWidth )
2454 0 : pFormImpl->SetShape( xShape );
2455 0 : if( aTextSz.Height() || bMinWidth || bMinHeight )
2456 0 : SetControlSize( xShape, aTextSz, bMinWidth, bMinHeight );
2457 :
2458 : // einen neuen Kontext anlegen
2459 0 : _HTMLAttrContext *pCntxt = new _HTMLAttrContext( HTML_SELECT_ON );
2460 :
2461 : // und PRE/Listing/XMP voruebergehend aussetzen
2462 0 : SplitPREListingXMP( pCntxt );
2463 0 : PushContext( pCntxt );
2464 :
2465 0 : bSelect = true;
2466 : }
2467 :
2468 0 : void SwHTMLParser::EndSelect()
2469 : {
2470 0 : if( pPendStack )
2471 : {
2472 0 : SetPendingControlSize();
2473 0 : return;
2474 : }
2475 :
2476 : OSL_ENSURE( bSelect, "keine Select" );
2477 : OSL_ENSURE( pFormImpl && pFormImpl->GetFCompPropSet().is(),
2478 : "kein Select-Control" );
2479 :
2480 : const uno::Reference< beans::XPropertySet > & rPropSet =
2481 0 : pFormImpl->GetFCompPropSet();
2482 :
2483 0 : size_t nEntryCnt = pFormImpl->GetStringList().size();
2484 0 : if(!pFormImpl->GetStringList().empty())
2485 : {
2486 0 : Sequence<OUString> aList( (sal_Int32)nEntryCnt );
2487 0 : Sequence<OUString> aValueList( (sal_Int32)nEntryCnt );
2488 0 : OUString *pStrings = aList.getArray();
2489 0 : OUString *pValues = aValueList.getArray();
2490 :
2491 0 : for(size_t i = 0; i < nEntryCnt; ++i)
2492 : {
2493 0 : OUString sText(pFormImpl->GetStringList()[i]);
2494 0 : sText = comphelper::string::stripEnd(sText, ' ');
2495 0 : pStrings[i] = sText;
2496 :
2497 0 : sText = pFormImpl->GetValueList()[i];
2498 0 : pValues[i] = sText;
2499 0 : }
2500 :
2501 0 : Any aAny( &aList, ::getCppuType((uno::Sequence<OUString>*)0) );
2502 :
2503 0 : rPropSet->setPropertyValue(
2504 0 : OUString("StringItemList"), aAny );
2505 :
2506 0 : aAny <<= ListSourceType_VALUELIST;
2507 0 : rPropSet->setPropertyValue(
2508 0 : OUString("ListSourceType"), aAny );
2509 :
2510 0 : aAny.setValue( &aValueList, ::getCppuType((uno::Sequence<OUString>*)0) );
2511 :
2512 0 : rPropSet->setPropertyValue("ListSource",
2513 0 : aAny );
2514 :
2515 0 : size_t nSelCnt = pFormImpl->GetSelectedList().size();
2516 0 : if( !nSelCnt && 1 == nSelectEntryCnt && nEntryCnt )
2517 : {
2518 : // In einer DropDown-Listbox sollte immer ein Eintrag selektiert
2519 : // sein.
2520 0 : pFormImpl->GetSelectedList().insert( pFormImpl->GetSelectedList().begin(), 0 );
2521 0 : nSelCnt = 1;
2522 : }
2523 0 : Sequence<sal_Int16> aSelList( (sal_Int32)nSelCnt );
2524 0 : sal_Int16 *pSels = aSelList.getArray();
2525 0 : for(size_t i = 0; i < nSelCnt; ++i)
2526 : {
2527 0 : pSels[i] = (sal_Int16)pFormImpl->GetSelectedList()[i];
2528 : }
2529 : aAny.setValue( &aSelList,
2530 0 : ::getCppuType((uno::Sequence<sal_Int16>*)0) );
2531 :
2532 0 : rPropSet->setPropertyValue(
2533 0 : OUString("DefaultSelection"), aAny );
2534 :
2535 0 : pFormImpl->EraseStringList();
2536 0 : pFormImpl->EraseValueList();
2537 : }
2538 :
2539 0 : pFormImpl->EraseSelectedList();
2540 :
2541 0 : if( bFixSelectWidth )
2542 : {
2543 : OSL_ENSURE( pFormImpl->GetShape().is(), "Kein Shape gemerkt" );
2544 0 : Size aTextSz( -1, 0 );
2545 0 : SetControlSize( pFormImpl->GetShape(), aTextSz, sal_False, sal_False );
2546 : }
2547 :
2548 0 : pFormImpl->ReleaseFCompPropSet();
2549 :
2550 : // den Kontext holen
2551 0 : _HTMLAttrContext *pCntxt = PopContext( HTML_SELECT_ON );
2552 0 : if( pCntxt )
2553 : {
2554 : // und ggf. die Attribute beenden
2555 0 : EndContext( pCntxt );
2556 0 : delete pCntxt;
2557 : }
2558 :
2559 0 : bSelect = false;
2560 : }
2561 :
2562 0 : void SwHTMLParser::InsertSelectOption()
2563 : {
2564 : OSL_ENSURE( bSelect, "keine Select" );
2565 : OSL_ENSURE( pFormImpl && pFormImpl->GetFCompPropSet().is(),
2566 : "kein Select-Control" );
2567 :
2568 0 : bLBEntrySelected = false;
2569 0 : OUString aValue;
2570 :
2571 0 : const HTMLOptions& rHTMLOptions = GetOptions();
2572 0 : for (size_t i = rHTMLOptions.size(); i; )
2573 : {
2574 0 : const HTMLOption& rOption = rHTMLOptions[--i];
2575 0 : switch( rOption.GetToken() )
2576 : {
2577 : case HTML_O_ID:
2578 : // erstmal weglassen!!!
2579 0 : break;
2580 : case HTML_O_SELECTED:
2581 0 : bLBEntrySelected = true;
2582 0 : break;
2583 : case HTML_O_VALUE:
2584 0 : aValue = rOption.GetString();
2585 0 : if( aValue.isEmpty() )
2586 0 : aValue = "$$$empty$$$";
2587 0 : break;
2588 : }
2589 : }
2590 :
2591 0 : sal_uInt16 nEntryCnt = pFormImpl->GetStringList().size();
2592 0 : pFormImpl->GetStringList().push_back(aEmptyOUStr);
2593 0 : pFormImpl->GetValueList().push_back(aValue);
2594 0 : if( bLBEntrySelected )
2595 : {
2596 0 : pFormImpl->GetSelectedList().push_back( nEntryCnt );
2597 0 : }
2598 0 : }
2599 :
2600 0 : void SwHTMLParser::InsertSelectText()
2601 : {
2602 : OSL_ENSURE( bSelect, "keine Select" );
2603 : OSL_ENSURE( pFormImpl && pFormImpl->GetFCompPropSet().is(),
2604 : "kein Select-Control" );
2605 :
2606 0 : if(!pFormImpl->GetStringList().empty())
2607 : {
2608 0 : OUString& rText = pFormImpl->GetStringList().back();
2609 :
2610 0 : if( !aToken.isEmpty() && ' '==aToken[ 0 ] )
2611 : {
2612 0 : sal_Int32 nLen = rText.getLength();
2613 0 : if( !nLen || ' '==rText[nLen-1])
2614 0 : aToken = aToken.replaceAt( 0, 1, "" );
2615 : }
2616 0 : if( !aToken.isEmpty() )
2617 0 : rText += aToken;
2618 : }
2619 0 : }
2620 :
2621 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|