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