Update to m13
[ooovba.git] / applied_patches / 0736-field-patch.diff
blob1df877ea44e9779554b444e63fb0f33e060e97d9
1 diff --git offapi/com/sun/star/text/XFormField.idl offapi/com/sun/star/text/XFormField.idl
2 index 3ef65fa..755fafa 100644
3 --- offapi/com/sun/star/text/XFormField.idl
4 +++ offapi/com/sun/star/text/XFormField.idl
5 @@ -9,14 +9,13 @@
7 interface XFormField: com::sun::star::uno::XInterface
9 - short getType();
10 - short getRes();
11 - string getDescription( );
13 - void setType([in] short fieldType );
14 - void setRes([in] short res );
15 - void setDescription([in] string description );
17 + string getFieldType();
18 + void setFieldType([in] string fieldType);
20 + short getParamCount();
21 + string getParamName([in] short i);
22 + string getParamValue([in] short i);
23 + void addParam([in] string name, [in] string value, [in] boolean replaceExisting);
26 }; }; }; };
27 diff --git svtools/source/config/fltrcfg.cxx svtools/source/config/fltrcfg.cxx
28 index be0c379..243eea1 100644
29 --- svtools/source/config/fltrcfg.cxx
30 +++ svtools/source/config/fltrcfg.cxx
31 @@ -312,7 +312,7 @@ const Sequence<OUString>& SvtFilterOptions::GetPropertyNames()
32 "Export/EnablePowerPointPreview", // 8
33 "Export/EnableExcelPreview", // 9
34 "Export/EnableWordPreview", // 10
35 - "Import/ImportWWFieldsAsEnhancedFields" // 11
36 + "Import/ImportWWFieldsAsEnhancedFields" // 11
38 OUString* pNames = aNames.getArray();
39 for(int i = 0; i < nCount; i++)
40 @@ -525,8 +525,7 @@ void SvtFilterOptions::SetWriter2WinWord( BOOL bFlag )
42 BOOL SvtFilterOptions::IsUseEnhancedFields() const
44 - return false; // disable for now;
45 -// return pImp->IsFlag( FILTERCFG_USE_ENHANCED_FIELDS );
46 + return pImp->IsFlag( FILTERCFG_USE_ENHANCED_FIELDS );
49 void SvtFilterOptions::SetUseEnhancedFields( BOOL bFlag )
50 diff --git sw/inc/bookmrk.hxx sw/inc/bookmrk.hxx
51 index 6f1c5ae..89499c2 100644
52 --- sw/inc/bookmrk.hxx
53 +++ sw/inc/bookmrk.hxx
54 @@ -54,6 +54,7 @@ struct SwPosition; // fwd Decl. wg. UI
56 class SwBookmark : public SwModify
58 + friend class SwDoc;
59 SwPosition *pPos1, *pPos2; // wird im CTOR gesetzt, im DTOR geloescht
60 // pPos1 is always != 0, pPos2 may be 0
61 SwServerObjectRef refObj; // falls DataServer -> Pointer gesetzt
62 @@ -81,6 +82,9 @@ public:
63 // Beim Loeschen von Text werden Bookmarks mitgeloescht!
64 virtual ~SwBookmark();
66 + const SwPosition& GetPos() const { return *pPos1; }
67 + const SwPosition* GetOtherPos() const { return pPos2; }
69 // --> OD 2007-10-10 #i81002#
70 // made virtual and thus no longer inline
71 virtual const SwPosition& GetBookmarkPos() const;
72 @@ -101,6 +105,8 @@ public:
73 BOOL IsEqualPos( const SwBookmark &rBM ) const;
75 BOOL IsFormFieldMark() const { return IDocumentBookmarkAccess::FORM_FIELDMARK_TEXT == eMarkType || IDocumentBookmarkAccess::FORM_FIELDMARK_NO_TEXT == eMarkType; }
76 + BOOL IsTabbedFormFieldMark() const;
78 BOOL IsBookMark() const { return IDocumentBookmarkAccess::BOOKMARK == eMarkType || IDocumentBookmarkAccess::FORM_FIELDMARK_TEXT == eMarkType || IDocumentBookmarkAccess::FORM_FIELDMARK_NO_TEXT == eMarkType; }
79 // // --> OD 2007-10-17 #TESTING#
80 // BOOL IsBookMark() const
81 @@ -153,55 +159,37 @@ public:
83 class SW_DLLPUBLIC SwFieldBookmark : public SwBookmark
85 +public:
86 + typedef std::pair< ::rtl::OUString, ::rtl::OUString > ParamPair_t;
87 private:
88 - int fftype; // Type: 0 = Text, 1 = Check Box, 2 = List
89 - int ffres;
90 - bool ffprot;
91 - bool ffsize; // 0 = Auto, 1=Exact (see ffhps)
92 - int fftypetxt; // Type of text field: 0 = Regular text, 1 = Number, 2 = Date, 3 = Current date, 4 = Current time, 5 = Calculation
93 - bool ffrecalc;
94 - int ffmaxlen; // Number of characters for text field. Zero means unlimited.
95 - int ffhps; // Check box size (half-point sizes).
97 - String ffname;
98 - String ffhelptext;
99 + ::rtl::OUString m_type;
100 + std::vector<ParamPair_t> m_params;
102 public:
103 SwFieldBookmark(const SwPosition& aPos,
104 const KeyCode& rCode,
105 const String& rName, const String& rShortName,
106 - IDocumentBookmarkAccess::BookmarkType eMark);
108 - void SetFieldType(int fftype);
109 - int GetFieldType();
111 - void SetChecked(bool checked);
112 - bool IsChecked();
114 - void SetFFName(String aNewName) {
115 - this->ffname=aNewName;
118 - String GetFFName()
120 - return ffname;
123 - int GetFFRes() {
124 - return ffres;
127 - void SetFFRes(int nNew) {
128 - this->ffres=nNew;
131 - void SetFFHelpText(String newffhelptext) {
132 - this->ffhelptext=newffhelptext;
135 - String GetFFHelpText() {
136 - return ffhelptext;
138 + IDocumentBookmarkAccess::BookmarkType eMark);
140 + virtual ~SwFieldBookmark();
142 + void setTypeName(const ::rtl::OUString &typeName);
143 + void invalidate();
144 + SwPosition getSelectionStart();
145 + SwPosition getSelectionEnd();
147 + // field specific stuff
148 + bool isTabbed() const;
150 + // generic methods
151 + bool isType(const char *type) const;
152 + rtl::OUString getTypeName();
153 + void addParam(::rtl::OUString paramName, ::rtl::OUString paramValue, bool replaceExisting=true);
154 + void addParam(const char* paramName, int value);
155 + int getNumOfParams();
156 + ParamPair_t getParam(int pos);
157 + ParamPair_t getParam(const char *name, const char *defaultValue=NULL);
158 + void addParams(std::vector<ParamPair_t> &params);
161 class SwUNOMark: public SwBookmark
162 diff --git sw/inc/crsrsh.hxx sw/inc/crsrsh.hxx
163 index 5711e92..6455596 100644
164 --- sw/inc/crsrsh.hxx
165 +++ sw/inc/crsrsh.hxx
166 @@ -112,7 +112,8 @@ struct SwContentAtPos
167 SW_REFMARK = 0x0100,
168 SW_NUMLABEL = 0x0200, // #i23726#
169 SW_CONTENT_CHECK = 0x0400, // --> FME 2005-05-13 #i43742# <--
170 - SW_SMARTTAG = 0x0800
171 + SW_SMARTTAG = 0x0800,
172 + SW_FORMCTRL = 0x1000
173 #ifndef PRODUCT
174 ,SW_CURR_ATTRS = 0x4000 // nur zum Debuggen
175 ,SW_TABLEBOXVALUE = 0x8000 // nur zum Debuggen
176 @@ -124,6 +125,7 @@ struct SwContentAtPos
177 const SfxPoolItem* pAttr;
178 const SwRedline* pRedl;
179 SwCntntNode * pNode; // #i23726#
180 + const SwFieldBookmark* pFldBookmark;
181 } aFnd;
183 int nDist; // #i23726#
184 diff --git sw/inc/doc.hxx sw/inc/doc.hxx
185 index f8cd224..25de567 100644
186 --- sw/inc/doc.hxx
187 +++ sw/inc/doc.hxx
188 @@ -786,6 +786,14 @@ public:
189 virtual void makeUniqueBookmarkName( /*[in/out]*/String& rName );
190 virtual sal_uInt16 getBookmarkCount( /*[in]*/ bool bBkmrk ) const;
191 virtual SwBookmark& getBookmark( /*[in]*/sal_uInt16 nPos, /*[in]*/bool bBkmrk );
193 + SwFieldBookmark *makeFieldBookmark(/*[in]*/const SwPaM& rPaM,
194 + /*[in]*/ const String& rName,
195 + /*[in]*/ const rtl::OUString &rType);
196 + SwFieldBookmark *makeNoTextFieldBookmark(/*[in]*/const SwPaM& rPaM,
197 + /*[in]*/ const String& rName,
198 + /*[in]*/ const rtl::OUString &rType);
200 virtual String getCrossRefBookmarkName(
201 /*[in]*/const SwTxtNode& rTxtNode,
202 /*[in]*/const CrossReferenceBookmarkSubType nCrossRefType ) const;
203 diff --git sw/inc/ecmaflds.hxx sw/inc/ecmaflds.hxx
204 new file mode 100644
205 index 0000000..23276b1
206 --- /dev/null
207 +++ sw/inc/ecmaflds.hxx
208 @@ -0,0 +1,68 @@
209 +/*************************************************************************
211 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
212 + *
213 + * Copyright 2008 by Sun Microsystems, Inc.
215 + * OpenOffice.org - a multi-platform office productivity suite
217 + * $RCSfile: $
218 + * $Revision: $
220 + * This file is part of OpenOffice.org.
222 + * OpenOffice.org is free software: you can redistribute it and/or modify
223 + * it under the terms of the GNU Lesser General Public License version 3
224 + * only, as published by the Free Software Foundation.
226 + * OpenOffice.org is distributed in the hope that it will be useful,
227 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
228 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
229 + * GNU Lesser General Public License version 3 for more details
230 + * (a copy is included in the LICENSE file that accompanied this code).
232 + * You should have received a copy of the GNU Lesser General Public License
233 + * version 3 along with OpenOffice.org. If not, see
234 + * <http://www.openoffice.org/license.html>
235 + * for a copy of the LGPLv3 License.
237 + ************************************************************************/
238 +/* and also:
239 + * Author: Florian Reuter <freuter@novell.com>
240 + * Copyright 2008 by Novell, Inc.
242 +#ifndef _ECMAFLDS_HXX
243 +#define _ECMAFLDS_HXX
246 +#define ECMA_FORMTEXT "ecma.office-open-xml.field.FORMTEXT"
247 +#define ECMA_FORMTEXT_NAME "name"
248 +#define ECMA_FORMTEXT_HELPTEXT "helpText"
249 +#define ECMA_FORMTEXT_STATUSTEXT "statusText"
250 +#define ECMA_FORMTEXT_DEFAULT "default"
251 +#define ECMA_FORMTEXT_FORMAT "format"
252 +#define ECMA_FORMTEXT_MAXLENGTH "maxLength"
253 +#define ECMA_FORMTEXT_TYPE "type"
255 +#define ECMA_FORMCHECKBOX "ecma.office-open-xml.field.FORMCHECKBOX"
256 +#define ECMA_FORMCHECKBOX_NAME "name"
257 +#define ECMA_FORMCHECKBOX_HELPTEXT "helpText"
258 +#define ECMA_FORMCHECKBOX_STATUSTEXT "statusText"
259 +#define ECMA_FORMCHECKBOX_CHECKED "checked"
260 +#define ECMA_FORMCHECKBOX_DEFAULT "default"
261 +#define ECMA_FORMCHECKBOX_SIZE "size"
262 +#define ECMA_FORMCHECKBOX_SIZEAUTO "sizeAuto"
265 +#define ECMA_FORMDROPDOWN "ecma.office-open-xml.field.FORMDROPDOWN"
266 +#define ECMA_FORMDROPDOWN_DEFAULT "default"
267 +#define ECMA_FORMDROPDOWN_LISTENTRY "listEntry"
268 +#define ECMA_FORMDROPDOWN_RESULT "result"
270 +#define ECMA_TOC "ecma.office-open-xml.field.TOC"
272 +#define ECMA_HYPERLINK "ecma.office-open-xml.field.HYPERLINK"
274 +#define ECMA_PAGEREF "ecma.office-open-xml.field.PAGEREF"
276 +#endif /* _ECMAFLDS_HXX */
277 diff --git sw/inc/editsh.hxx sw/inc/editsh.hxx
278 index 27649d4..e292e4d 100644
279 --- sw/inc/editsh.hxx
280 +++ sw/inc/editsh.hxx
281 @@ -415,6 +415,9 @@ public:
282 const SwTOXType* GetTOXType(TOXTypes eTyp, USHORT nId) const;
283 void InsertTOXType(const SwTOXType& rTyp);
285 + // new field stuff
286 + BOOL UpdateField(SwFieldBookmark &fieldBM);
288 //AutoMark file
289 const String& GetTOIAutoMarkURL() const;
290 void SetTOIAutoMarkURL(const String& rSet);
291 diff --git sw/inc/hintids.hxx sw/inc/hintids.hxx
292 index 6834eb2..45c0675 100644
293 --- sw/inc/hintids.hxx
294 +++ sw/inc/hintids.hxx
295 @@ -44,12 +44,8 @@
296 #define CH_TXT_ATR_FIELDEND ((sal_Unicode)0x05)
297 #define CH_TXT_ATR_SUBST_FIELDSTART ("[")
298 #define CH_TXT_ATR_SUBST_FIELDEND ("]")
299 -//#define CH_TXT_ATR_FORMELEMENT ((sal_Unicode)'#')
300 #define CH_TXT_ATR_FORMELEMENT ((sal_Unicode)0x06)
302 -#define FIELD_BOOKMARK_PREFIX "__"
303 -#define FIELD_FORM_BOOKMARK_PREFIX "__FORM"
307 * Hier kommen erst mal die enums fuer die Hints
309 diff --git sw/inc/pam.hxx sw/inc/pam.hxx
310 index 1aee1ac..bce0297 100644
311 --- sw/inc/pam.hxx
312 +++ sw/inc/pam.hxx
313 @@ -262,6 +262,7 @@ public:
314 DECL_FIXEDMEMPOOL_NEWDEL(SwPaM);
316 String GetTxt() const;
317 + void Invalidate();
321 diff --git sw/inc/unoobj.hxx sw/inc/unoobj.hxx
322 index ed924c1..5c8829d 100644
323 --- sw/inc/unoobj.hxx
324 +++ sw/inc/unoobj.hxx
325 @@ -648,6 +648,7 @@ public:
326 SwXFieldmark(bool isReplacementObject, SwBookmark* pBkm = 0, SwDoc* pDoc = 0);
328 virtual void attachToRange(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange)throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
330 virtual ::rtl::OUString SAL_CALL getDescription(void) throw( ::com::sun::star::uno::RuntimeException );
331 virtual ::sal_Int16 SAL_CALL getType( ) throw (::com::sun::star::uno::RuntimeException);
332 virtual ::sal_Int16 SAL_CALL getRes( ) throw (::com::sun::star::uno::RuntimeException);
333 @@ -655,7 +656,15 @@ public:
334 virtual void SAL_CALL setType( ::sal_Int16 fieldType ) throw (::com::sun::star::uno::RuntimeException);
335 virtual void SAL_CALL setRes( ::sal_Int16 res ) throw (::com::sun::star::uno::RuntimeException);
336 virtual void SAL_CALL setDescription( const ::rtl::OUString& description ) throw (::com::sun::star::uno::RuntimeException);
339 + virtual ::rtl::OUString SAL_CALL getFieldType(void) throw( ::com::sun::star::uno::RuntimeException );
340 + virtual void SAL_CALL setFieldType( const ::rtl::OUString& description ) throw (::com::sun::star::uno::RuntimeException);
342 + virtual ::sal_Int16 SAL_CALL getParamCount( ) throw (::com::sun::star::uno::RuntimeException);
343 + virtual ::rtl::OUString SAL_CALL getParamName(::sal_Int16 i) throw( ::com::sun::star::uno::RuntimeException );
344 + virtual ::rtl::OUString SAL_CALL getParamValue(::sal_Int16 i) throw( ::com::sun::star::uno::RuntimeException );
345 + virtual void SAL_CALL addParam( const ::rtl::OUString& name, const ::rtl::OUString& value, ::sal_Bool replaceExisting ) throw (::com::sun::star::uno::RuntimeException);
346 // virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException);
349 diff --git sw/source/core/crsr/crstrvl.cxx sw/source/core/crsr/crstrvl.cxx
350 index 0429ba3..a5618e7 100644
351 --- sw/source/core/crsr/crstrvl.cxx
352 +++ sw/source/core/crsr/crstrvl.cxx
353 @@ -1175,6 +1175,16 @@ BOOL SwCrsrShell::GetContentAtPos( const Point& rPt,
357 + if( !bRet && SwContentAtPos::SW_FORMCTRL & rCntntAtPos.eCntntAtPos )
359 + SwFieldBookmark* pFldBookmark=GetDoc()->getFormFieldBookmarkFor( aPos) ;
360 + if( bCrsrFoundExact && pTxtNd && pFldBookmark) {
361 + rCntntAtPos.eCntntAtPos = SwContentAtPos::SW_FORMCTRL;
362 + rCntntAtPos.aFnd.pFldBookmark = pFldBookmark;
363 + bRet=TRUE;
367 if( !bRet && SwContentAtPos::SW_FTN & rCntntAtPos.eCntntAtPos )
369 if( aTmpState.bFtnNoInfo )
370 diff --git sw/source/core/crsr/pam.cxx sw/source/core/crsr/pam.cxx
371 index 15cf4d9..7d67f22 100644
372 --- sw/source/core/crsr/pam.cxx
373 +++ sw/source/core/crsr/pam.cxx
374 @@ -56,6 +56,7 @@
375 #include <ndtxt.hxx> // #111827#
377 #include <bookmrk.hxx>
378 +#include <hints.hxx>
380 // fuer den dummen ?MSC-? Compiler
381 inline xub_StrLen GetSttOrEnd( BOOL bCondition, const SwCntntNode& rNd )
382 @@ -768,16 +769,29 @@ BOOL SwPaM::HasReadonlySel( bool bFormView ) const
385 // TODO: Form Protection when Enhanced Fields are enabled
386 -// if( !bRet )
387 -// {
388 -// const SwDoc *pDoc=GetDoc();
389 -// SwBookmark *pA = ( pDoc && pPoint ? pDoc->getFieldBookmarkFor( *pPoint ) : NULL );
390 -// SwBookmark *pB = ( pDoc && pMark ? pDoc->getFieldBookmarkFor( *pMark ) : pA );
391 -// bRet = ( pA != pB );
392 -// bool bProtectForm = pDoc->get( IDocumentSettingAccess::PROTECT_FORM );
393 -// if( bProtectForm )
394 -// bRet |= ( pA==NULL || pB==NULL );
395 -// }
396 + if (!bRet) {
397 + const SwDoc *pDoc=GetDoc();
398 + SwBookmark *pA=(pDoc&&pPoint?pDoc->getFieldBookmarkFor(*pPoint):NULL);
399 + /* debugging stuff, will remove later
400 + if (pA) {
401 + rtl::OUString s(pA->GetName());
402 + rtl::OString aOString = ::rtl::OUStringToOString (s, RTL_TEXTENCODING_UTF8);
403 + printf("IN BOOKMARK(A): %s\n", aOString.getStr());
405 + */
406 + SwBookmark *pB=(pDoc&&pMark?pDoc->getFieldBookmarkFor(*pMark):pA);
407 + /* debugging stuff, will remove later
408 + if (pB) {
409 + rtl::OUString s(pB->GetName());
410 + rtl::OString aOString = ::rtl::OUStringToOString (s, RTL_TEXTENCODING_UTF8);
411 + printf("IN BOOKMARK(B): %s\n", aOString.getStr());
413 + */
414 + bRet = (pA!=pB);
415 + bool bProtectForm=pDoc->get(IDocumentSettingAccess::PROTECT_FORM );
416 + if (bProtectForm)
417 + bRet|=(pA==NULL || pB==NULL);
419 return bRet;
422 @@ -1155,6 +1169,18 @@ BOOL SwPaM::Overlap(const SwPaM & a, const SwPaM & b)
423 return !(*b.End() <= *a.Start() || *a.End() <= *b.End());
426 +void SwPaM::Invalidate()
428 + const SwNode *_pNd=this->GetNode();
429 + const SwTxtNode *_pTxtNd=(_pNd!=NULL?_pNd->GetTxtNode():NULL);
430 + if (_pTxtNd!=NULL) {
431 + //pretent we've added a char to force layout to recalc the portion...
432 + SwInsChr aHint(_pTxtNd->GetIndex());
433 + SwModify *_pModify=(SwModify*)_pTxtNd;
434 + _pModify->Modify( 0, &aHint);
438 BOOL SwPaM::LessThan(const SwPaM & a, const SwPaM & b)
440 return (*a.Start() < *b.Start()) || (*a.Start() == *b.Start() && *a.End() < *b.End());
441 diff --git sw/source/core/doc/docbm.cxx sw/source/core/doc/docbm.cxx
442 index 59dd2a6..4545785 100644
443 --- sw/source/core/doc/docbm.cxx
444 +++ sw/source/core/doc/docbm.cxx
445 @@ -63,6 +63,7 @@
446 // --> OD 2007-10-23 #i81002#
447 #include <ndtxt.hxx>
448 // <--
449 +#include "ecmaflds.hxx"
451 SV_IMPL_OP_PTRARR_SORT(SwBookmarks, SwBookmarkPtr)
453 @@ -88,6 +89,23 @@ SV_IMPL_OP_PTRARR_SORT(SwBookmarks, SwBookmarkPtr)
454 } while((_pStartShell=(ViewShell*)_pStartShell->GetNext())!= pEShell ); \
457 +static void lcl_docbm_FixPosition( SwPosition& rPos )
459 + // make sure the position has 1) the proper node, and 2) a proper index
460 + SwTxtNode* pTxtNode = rPos.nNode.GetNode().GetTxtNode();
462 + if( rPos.nContent.GetIndex() > ( pTxtNode == NULL ? 0 : pTxtNode->Len() ) )
464 + DBG_ERROR( "illegal position" );
465 + xub_StrLen nLen = rPos.nContent.GetIndex();
466 + if( pTxtNode == NULL )
467 + nLen = 0;
468 + else if( nLen >= pTxtNode->Len() )
469 + nLen = pTxtNode->Len();
470 + rPos.nContent.Assign( pTxtNode, nLen );
475 /** IDocumentBookmarkAccess ssc
477 @@ -96,28 +114,27 @@ const SwBookmarks& SwDoc::getBookmarks() const
478 return *pBookmarkTbl;
482 SwBookmark* SwDoc::makeBookmark( /*[in]*/const SwPaM& rPaM, /*[in]*/const KeyCode& rCode,
483 /*[in]*/ const String& rName, /*[in]*/const String& rShortName,
484 /*[in]*/IDocumentBookmarkAccess::BookmarkType eMark )
486 SwBookmark *pBM( 0 );
487 - if (FORM_FIELDMARK_TEXT == eMark || FORM_FIELDMARK_NO_TEXT == eMark /* rName.CompareToAscii(FIELD_BOOKMARK_PREFIX, strlen(FIELD_BOOKMARK_PREFIX))==0 */)
489 - pBM = new SwFieldBookmark(*rPaM.GetPoint(), rCode, rName, rShortName, eMark);
490 - if( rPaM.HasMark() )
491 - pBM->SetOtherBookmarkPos( rPaM.GetMark() );
492 - else
493 - pBM->SetOtherBookmarkPos( &pBM->GetBookmarkPos() );
495 - // TODO: lcl_FixPosition( *pBM->pPos1 );
496 - // TODO: lcl_FixPosition( *pBM->pPos2 );
497 - if( *pBM->GetOtherBookmarkPos() < pBM->GetBookmarkPos() )
499 - SwPosition _pos( pBM->GetBookmarkPos() );
500 - pBM->SetBookmarkPos( pBM->GetOtherBookmarkPos() );
501 - pBM->SetOtherBookmarkPos( &_pos );
503 - //ASSERT(*pBM->pPos1<=*pBM->pPos2, "");
504 + if (FORM_FIELDMARK_TEXT == eMark || FORM_FIELDMARK_NO_TEXT == eMark) {
505 + pBM = new SwFieldBookmark(*rPaM.GetPoint(), rCode, rName, rShortName, eMark);
506 + if( rPaM.HasMark() )
507 + pBM->pPos2 = new SwPosition( *rPaM.GetMark() );
508 + else
509 + pBM->pPos2 = new SwPosition( *pBM->pPos1 );
511 + lcl_docbm_FixPosition( *pBM->pPos1 );
512 + lcl_docbm_FixPosition( *pBM->pPos2 );
513 + if (*pBM->pPos2<*pBM->pPos1) {
514 + SwPosition *_pos=pBM->pPos1;
515 + pBM->pPos1=pBM->pPos2;
516 + pBM->pPos2=_pos;
518 + ASSERT(*PBM->pPos1<=*pBM->pPos2, "");
520 else if( MARK == eMark )
522 @@ -146,7 +163,7 @@ SwBookmark* SwDoc::makeBookmark( /*[in]*/const SwPaM& rPaM, /*[in]*/const KeyCod
523 // }
524 // // <--
525 else if( BOOKMARK == eMark || DDE_BOOKMARK == eMark)
528 // --> OD 2007-09-26 #i81002#
529 pBM = new SwBookmark( rPaM, rCode, rName, rShortName);
530 if ( eMark == DDE_BOOKMARK )
531 @@ -154,7 +171,7 @@ SwBookmark* SwDoc::makeBookmark( /*[in]*/const SwPaM& rPaM, /*[in]*/const KeyCod
532 pBM->SetType( eMark );
534 // <--
537 // --> OD 2007-10-17 #i81002#
538 else if ( eMark == CROSSREF_BOOKMARK )
540 @@ -176,53 +193,56 @@ SwBookmark* SwDoc::makeBookmark( /*[in]*/const SwPaM& rPaM, /*[in]*/const KeyCod
541 "<SwDoc::makeBookmark(..)> - creation of cross-reference bookmark with invalid PaM" );
544 - else
546 + // <--
547 + else
549 // --> OD 2007-09-26 #i81002#
550 pBM = new SwUNOMark( rPaM, rCode, rName, rShortName);
551 // <--
555 // --> OD 2007-10-18 #i81002#
556 if ( pBM )
558 - if (FORM_FIELDMARK_TEXT == eMark || FORM_FIELDMARK_NO_TEXT == eMark /* pBM->GetName().CompareToAscii(FIELD_BOOKMARK_PREFIX, strlen(FIELD_BOOKMARK_PREFIX))==0 */)
560 - StartUndo(UNDO_UI_REPLACE, NULL);
561 - //ASSERT(*PBM->pPos1<=*pBM->pPos2, "Bookmark positions not normalized!!!!");
562 - const SwTxtNode* pStartTxtNode=this->GetNodes()[pBM->GetBookmarkPos().nNode]->GetTxtNode();
563 - const SwTxtNode* pEndTxtNode=this->GetNodes()[pBM->GetOtherBookmarkPos()->nNode]->GetTxtNode();
564 - sal_Unicode ch_start=pStartTxtNode->GetTxt().GetChar(pBM->GetBookmarkPos().nContent.GetIndex());
565 - sal_Unicode ch_end=pEndTxtNode->GetTxt().GetChar(pBM->GetOtherBookmarkPos()->nContent.GetIndex()-1);
566 - bool form=(IDocumentBookmarkAccess::FORM_FIELDMARK_NO_TEXT==eMark); /*(pBM->GetName().CompareToAscii(FIELD_FORM_BOOKMARK_PREFIX, strlen(FIELD_FORM_BOOKMARK_PREFIX))==0);*/
567 - if (form)
569 - if (ch_start!=CH_TXT_ATR_FORMELEMENT)
571 - const SwPaM rRg(pBM->GetBookmarkPos());
572 - Insert(rRg, CH_TXT_ATR_FORMELEMENT);
573 - SwPosition aTmp( pBM->GetBookmarkPos() );
574 - aTmp.nContent--;
575 - pBM->SetBookmarkPos( &aTmp );
578 - else
580 - if (ch_start!=CH_TXT_ATR_FIELDSTART)
582 - const SwPaM rRg(pBM->GetBookmarkPos());
583 - Insert(rRg, CH_TXT_ATR_FIELDSTART);
584 - SwPosition aTmp( pBM->GetBookmarkPos() );
585 - aTmp.nContent--;
586 - pBM->SetBookmarkPos( &aTmp );
588 - if (ch_end!=CH_TXT_ATR_FIELDEND)
590 - const SwPaM rRg(*pBM->GetOtherBookmarkPos());
591 - Insert(rRg, CH_TXT_ATR_FIELDEND);
594 - }
595 + if (FORM_FIELDMARK_TEXT == eMark || FORM_FIELDMARK_NO_TEXT == eMark ) {
596 + StartUndo(UNDO_UI_REPLACE, NULL);
597 + ASSERT(*PBM->pPos1<=*pBM->pPos2, "Bookmark positions not normalized!!!!");
598 + const SwTxtNode* pStartTxtNode=this->GetNodes()[pBM->GetPos().nNode]->GetTxtNode();
599 + const SwTxtNode* pEndTxtNode=this->GetNodes()[pBM->GetOtherPos()->nNode]->GetTxtNode();
600 + xub_StrLen ch_start_pos=pBM->GetPos().nContent.GetIndex();
601 + xub_StrLen ch_end_pos=pBM->GetOtherPos()->nContent.GetIndex();
602 + if (ch_end_pos==0 || ch_end_pos<=ch_start_pos) {
603 + ch_end_pos=ch_start_pos;
604 + } else {
605 + ch_end_pos--;
607 + sal_Unicode ch_start=pStartTxtNode->GetTxt().GetChar(ch_start_pos);
608 + sal_Unicode ch_end=pEndTxtNode->GetTxt().GetChar(ch_end_pos);
609 + bool form=(IDocumentBookmarkAccess::FORM_FIELDMARK_NO_TEXT==eMark);
610 + if (form) {
611 + if (1 || ch_start!=CH_TXT_ATR_FORMELEMENT) {
612 + const SwPaM rRg(*pBM->pPos1);
613 + Insert(rRg, CH_TXT_ATR_FORMELEMENT);
614 + pBM->pPos1->nContent--;
616 + } else {
617 + if (1 || ch_start!=CH_TXT_ATR_FIELDSTART) {
618 + const SwPaM rRg(*pBM->pPos1);
619 + Insert(rRg, CH_TXT_ATR_FIELDSTART);
620 + pBM->pPos1->nContent--;
622 + if (1 || ch_end!=CH_TXT_ATR_FIELDEND) {
623 + const SwPaM rRg(*pBM->pPos2);
624 + Insert(rRg, CH_TXT_ATR_FIELDEND);
627 + } else {
628 + // fix bookmark positions if they are invalid
629 + lcl_docbm_FixPosition( *pBM->pPos1 );
630 + if( pBM->pPos2 != NULL )
631 + lcl_docbm_FixPosition( *pBM->pPos2 );
634 if ( !pBookmarkTbl->Insert( pBM ) )
635 delete pBM, pBM = 0;
636 else
637 @@ -241,12 +261,38 @@ SwBookmark* SwDoc::makeBookmark( /*[in]*/const SwPaM& rPaM, /*[in]*/const KeyCod
638 SetModified();
641 - if (FORM_FIELDMARK_TEXT == eMark || FORM_FIELDMARK_NO_TEXT == eMark /*pBM->GetName().CompareToAscii(FIELD_BOOKMARK_PREFIX, strlen(FIELD_BOOKMARK_PREFIX))==0*/)
642 - EndUndo(UNDO_UI_REPLACE, NULL);
643 + if (FORM_FIELDMARK_TEXT == eMark || FORM_FIELDMARK_NO_TEXT == eMark ) {
644 + EndUndo(UNDO_UI_REPLACE, NULL);
647 return pBM;
651 +SwFieldBookmark *SwDoc::makeFieldBookmark(/*[in]*/const SwPaM& rPaM,
652 + /*[in]*/ const String& rName,
653 + /*[in]*/ const rtl::OUString &rType)
655 + SwFieldBookmark *pFieldmark=(SwFieldBookmark*)makeBookmark(rPaM, KeyCode(), rName, String(), IDocumentBookmarkAccess::FORM_FIELDMARK_TEXT);
656 + pFieldmark->setTypeName(rType);
657 + if (1) {
658 + rtl::OString aName8 = ::rtl::OUStringToOString (rName, RTL_TEXTENCODING_UTF8);
659 + rtl::OString aType8 = ::rtl::OUStringToOString (rType, RTL_TEXTENCODING_UTF8);
660 + /* printf("makeFieldBookmark(\"%s\", \"%s\")\n", aName8.getStr(), aType8.getStr()); */
662 + return pFieldmark;
665 +SwFieldBookmark *SwDoc::makeNoTextFieldBookmark(/*[in]*/const SwPaM& rPaM,
666 + /*[in]*/ const String& rName,
667 + /*[in]*/ const rtl::OUString &rType)
669 + SwFieldBookmark *pFieldmark=(SwFieldBookmark*)makeBookmark(rPaM, KeyCode(), rName, String(), IDocumentBookmarkAccess::FORM_FIELDMARK_NO_TEXT);
670 + pFieldmark->setTypeName(rType);
671 + return pFieldmark;
675 SwBookmark* SwDoc::getFieldBookmarkFor(const SwPosition &pos) const
677 //@TODO make impl recursive
678 @@ -255,7 +301,7 @@ SwBookmark* SwDoc::getFieldBookmarkFor(const SwPosition &pos) const
680 SwBookmark *pBM=(*pBookmarkTbl)[static_cast<USHORT>(nCount)];
681 if (pBM->GetOtherBookmarkPos()!=NULL
682 - && FORM_FIELDMARK_TEXT==pBM->GetType() /* pBM->GetName().CompareToAscii(FIELD_BOOKMARK_PREFIX, strlen(FIELD_BOOKMARK_PREFIX))==0 */
683 + && FORM_FIELDMARK_TEXT==pBM->GetType()
684 && pBM->GetBookmarkPos()<pos
685 && pos < *(pBM->GetOtherBookmarkPos()))
686 return pBM;
687 @@ -286,7 +332,7 @@ SwBookmark* SwDoc::getNextFieldBookmarkFor(const SwPosition &pos) const
688 SwBookmark *pBM=NULL;
689 while(i<nCount
690 && ((pBM=(*pBookmarkTbl)[i])==NULL
691 - || !pBM->IsFormFieldMark() /* pBM->GetName().CompareToAscii(FIELD_BOOKMARK_PREFIX, strlen(FIELD_BOOKMARK_PREFIX))!=0 */
692 + || !pBM->IsTabbedFormFieldMark()
693 || pos >= pBM->GetBookmarkPos() ))
694 i++;
696 @@ -296,7 +342,7 @@ SwBookmark* SwDoc::getNextFieldBookmarkFor(const SwPosition &pos) const
698 i=0;
699 while(i<nCount
700 - && ((pBM=(*pBookmarkTbl)[i])==NULL || !pBM->IsFormFieldMark() /*pBM->GetName().CompareToAscii(FIELD_BOOKMARK_PREFIX, strlen(FIELD_BOOKMARK_PREFIX))!=0*/ ))
701 + && ((pBM=(*pBookmarkTbl)[i])==NULL || !pBM->IsTabbedFormFieldMark() ))
702 i++;
703 return (i<nCount?pBM:NULL);
705 @@ -309,7 +355,7 @@ SwBookmark* SwDoc::getPrevFieldBookmarkFor(const SwPosition &pos) const
706 SwBookmark *pBM=NULL;
707 while(i>=0
708 && ((pBM=(*pBookmarkTbl)[static_cast<USHORT>(i)])==NULL
709 - || !pBM->IsFormFieldMark() /*pBM->GetName().CompareToAscii(FIELD_BOOKMARK_PREFIX, strlen(FIELD_BOOKMARK_PREFIX))!=0*/
710 + || !pBM->IsTabbedFormFieldMark()
711 || pBM->GetOtherBookmarkPos()==NULL
712 || pos <= *pBM->GetOtherBookmarkPos()))
713 i--;
714 @@ -320,7 +366,7 @@ SwBookmark* SwDoc::getPrevFieldBookmarkFor(const SwPosition &pos) const
716 i=nCount-1;
717 while(i>=0
718 - && ((pBM=(*pBookmarkTbl)[static_cast<USHORT>(i)])==NULL || !pBM->IsFormFieldMark() /*pBM->GetName().CompareToAscii(FIELD_BOOKMARK_PREFIX, strlen(FIELD_BOOKMARK_PREFIX))!=0*/ ))
719 + && ((pBM=(*pBookmarkTbl)[static_cast<USHORT>(i)])==NULL || !pBM->IsTabbedFormFieldMark() ))
720 i--;
721 return (i>=0?pBM:NULL);
723 @@ -1299,45 +1345,6 @@ void _RestoreCntntIdx( SwDoc* pDoc, SvULongs& rSaveArr,
727 -SwFieldBookmark::SwFieldBookmark(const SwPosition& aPos,
728 - const KeyCode& rCode,
729 - const String& rName, const String& rShortName,
730 - IDocumentBookmarkAccess::BookmarkType eMark)
731 - : SwBookmark(aPos, rCode, rName, rShortName),
732 - fftype(0), // Type: 0 = Text, 1 = Check Box, 2 = List
733 - ffres(0),
734 - ffprot(0),
735 - ffsize(0), // 0 = Auto, 1=Exact (see ffhps)
736 - fftypetxt(0), // Type of text field: 0 = Regular text, 1 = Number, 2 = Date, 3 = Current date, 4 = Current time, 5 = Calculation
737 - ffrecalc(0),
738 - ffmaxlen(0), // Number of characters for text field. Zero means unlimited.
739 - ffhps(24) // Check box size (half-point sizes).
741 - eMarkType = eMark;
744 -void SwFieldBookmark::SetChecked(bool checked)
746 - ASSERT(fftype==1, "This method is for checkboxes only...");
747 - ffres=(checked?1:0);
750 -bool SwFieldBookmark::IsChecked()
752 - ASSERT(fftype==1, "This method is for checkboxes only...");
753 - return ffres!=0;
756 -void SwFieldBookmark::SetFieldType(int newfftype)
758 - this->fftype=newfftype;
761 -int SwFieldBookmark::GetFieldType()
763 - return fftype;
766 void _RestoreCntntIdx( SvULongs& rSaveArr, const SwNode& rNd,
767 xub_StrLen nLen, xub_StrLen nChkLen )
769 @@ -1581,3 +1588,118 @@ namespace bookmarkfunc
772 // <--
776 +SwFieldBookmark::SwFieldBookmark(const SwPosition& aPos,
777 + const KeyCode& rCode,
778 + const String& rName, const String& rShortName,
779 + IDocumentBookmarkAccess::BookmarkType eMark)
780 + : SwBookmark(aPos, rCode, rName, rShortName)
782 + eMarkType = eMark;
785 +SwFieldBookmark::~SwFieldBookmark()
790 +void SwFieldBookmark::invalidate()
792 + SwPaM aPaM(this->GetPos(), *this->GetOtherPos());
793 + aPaM.Invalidate();
796 +SwPosition SwFieldBookmark::getSelectionStart()
798 + SwPosition aPos=GetPos();
799 + aPos.nContent++;
800 + return aPos;
803 +SwPosition SwFieldBookmark::getSelectionEnd()
805 + SwPosition aPos=*GetOtherPos();
806 + aPos.nContent--;
807 + return aPos;
811 +void SwFieldBookmark::setTypeName(const ::rtl::OUString &typeName)
813 + m_type=typeName;
816 +BOOL SwBookmark::IsTabbedFormFieldMark() const
818 + return IsFormFieldMark() && ((const SwFieldBookmark*)this)->isTabbed();
821 +bool SwFieldBookmark::isTabbed() const
823 + return isType(ECMA_FORMTEXT) || isType(ECMA_FORMCHECKBOX) || isType(ECMA_FORMDROPDOWN);
826 +bool SwFieldBookmark::isType(const char *type) const
828 + return m_type.compareToAscii(type)==0;
831 +rtl::OUString SwFieldBookmark::getTypeName() {
832 + return m_type;
835 +void SwFieldBookmark::addParam(::rtl::OUString paramName, ::rtl::OUString paramValue, bool replaceExisting)
837 + if (replaceExisting) {
838 + bool replaced=false;
839 + const int len=m_params.size();
840 + for(int i=0;i<len;i++) {
841 + if (m_params[i].first.compareTo(paramName)==0) {
842 + m_params[i]=ParamPair_t(paramName, paramValue);
843 + replaced=true;
846 + if (!replaced) {
847 + m_params.push_back(ParamPair_t(paramName, paramValue));
849 + } else {
850 + m_params.push_back(ParamPair_t(paramName, paramValue));
854 +void SwFieldBookmark::addParam(const char* paramName, int value)
856 + rtl::OUString sName=rtl::OUString::createFromAscii(paramName);
857 + rtl::OUString sValue=::rtl::OUString::valueOf((sal_Int32)value);
858 + addParam(sName, sValue);
861 +void SwFieldBookmark::addParams(std::vector<ParamPair_t> &params)
863 + for(std::vector<ParamPair_t>::iterator i=params.begin();i!=params.end();i++) {
864 + m_params.push_back(*i);
868 +int SwFieldBookmark::getNumOfParams()
870 + return m_params.size();
873 +SwFieldBookmark::ParamPair_t SwFieldBookmark::getParam(int pos)
875 + return m_params[pos];
878 +SwFieldBookmark::ParamPair_t SwFieldBookmark::getParam(const char *name, const char *defaultValue)
880 + for(std::vector<ParamPair_t>::iterator i=m_params.begin();i!=m_params.end();i++) {
881 + if (i->first.compareToAscii(name)==0) {
882 + return *i;
885 + return ParamPair_t(rtl::OUString(), (defaultValue? ::rtl::OUString::createFromAscii(defaultValue) : ::rtl::OUString()));
888 diff --git sw/source/core/edit/edtox.cxx sw/source/core/edit/edtox.cxx
889 index 8cb1e7c..efd7bca 100644
890 --- sw/source/core/edit/edtox.cxx
891 +++ sw/source/core/edit/edtox.cxx
892 @@ -60,6 +60,9 @@
893 #ifndef _STATSTR_HRC
894 #include <statstr.hrc>
895 #endif
896 +#include <bookmrk.hxx>
897 +#include <ecmaflds.hxx>
900 using namespace ::com::sun::star;
901 using namespace ::com::sun::star::i18n;
902 @@ -232,6 +235,19 @@ BOOL SwEditShell::UpdateTableOf( const SwTOXBase& rTOX, const SfxItemSet* pSet )
903 return bRet;
906 +BOOL SwEditShell::UpdateField(SwFieldBookmark &fieldBM)
908 +// SwDocShell* pDocSh = pDoc->GetDocShell();
909 + //@TODO implement me...; add undo etc...
910 + if (pDoc && fieldBM.GetOtherBookmarkPos()!=NULL) {
911 + SwPaM aPaM(fieldBM.getSelectionStart(), fieldBM.getSelectionEnd());
912 + pDoc->Delete(aPaM);
913 + pDoc->Insert(aPaM, String::CreateFromAscii("Implement me ;-)"), false);
915 + return TRUE;
919 /*--------------------------------------------------------------------
920 Beschreibung: Aktuelles Verzeichnis vor oder in dem der Cursor
921 steht
922 diff --git sw/source/core/text/inftxt.cxx sw/source/core/text/inftxt.cxx
923 index 4899f73..af9d8d1 100644
924 --- sw/source/core/text/inftxt.cxx
925 +++ sw/source/core/text/inftxt.cxx
926 @@ -1146,13 +1146,15 @@ void SwTxtPaintInfo::DrawCheckBox( const SwFieldFormPortion &rPor, bool checked)
927 SwRect aIntersect;
928 CalcRect( rPor, &aIntersect, 0 );
929 if ( aIntersect.HasArea() ) {
930 - if (OnWin()) {
931 - OutputDevice* pOutDev = (OutputDevice*)GetOut();
932 - pOutDev->Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
933 - pOutDev->SetLineColor( Color(220, 233, 245));
934 - pOutDev->SetFillColor( Color(220, 233, 245));
935 - pOutDev->DrawRect( aIntersect.SVRect() );
936 - pOutDev->Pop();
937 + if (OnWin() && SwViewOption::IsFieldShadings() && !GetOpt().IsPagePreview()) {
938 + OutputDevice* pOut_ = (OutputDevice*)GetOut();
939 + pOut_->Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
940 + pOut_->SetFillColor( SwViewOption::GetFieldShadingsColor() );
941 + pOut_->SetLineColor();
942 +// pOut_->SetLineColor( Color(220, 233, 245));
943 +// pOut_->SetFillColor( Color(220, 233, 245));
944 + pOut_->DrawRect( aIntersect.SVRect() );
945 + pOut_->Pop();
947 const int delta=10;
948 Rectangle r(aIntersect.Left()+delta, aIntersect.Top()+delta, aIntersect.Right()-delta, aIntersect.Bottom()-delta);
949 @@ -1204,31 +1206,30 @@ void SwTxtPaintInfo::_DrawBackBrush( const SwLinePortion &rPor ) const
951 SwRect aIntersect;
952 CalcRect( rPor, &aIntersect, 0 );
953 - SwTxtNode *pNd = pFrm->GetTxtNode();
954 - SwBookmark *pBM=NULL;
955 - if ( aIntersect.HasArea() )
957 - if (pNd)
959 - const SwDoc *doc=pNd->GetDoc();
960 - if (doc!=NULL)
962 - SwIndex aIndex( pNd, GetIdx() );
963 - SwPosition aPosition(*pNd, aIndex);
964 - pBM=doc->getFieldBookmarkFor(aPosition);
967 - bool bIsStartMark=(1==GetLen() && CH_TXT_ATR_FIELDSTART==GetTxt().GetChar(GetIdx()));
968 - if (OnWin() && (pBM!=NULL || bIsStartMark))
970 - OutputDevice* pOutDev = (OutputDevice*)GetOut();
971 - pOutDev->Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
972 - pOutDev->SetLineColor( Color(220, 233, 245));
973 - pOutDev->SetFillColor( Color(220, 233, 245));
974 - pOutDev->DrawRect( aIntersect.SVRect() );
975 - pOutDev->Pop();
978 + SwTxtNode *pNd = pFrm->GetTxtNode();
979 + SwBookmark *pBM=NULL;
980 + if ( aIntersect.HasArea() )
982 + if (pNd) {
983 + const SwDoc *doc=pNd->GetDoc();
984 + if (doc!=NULL) {
985 + SwIndex aIndex( pNd, GetIdx() );
986 + SwPosition aPosition(*pNd, aIndex);
987 + pBM=doc->getFieldBookmarkFor(aPosition);
990 + bool bIsStartMark=(1==GetLen() && CH_TXT_ATR_FIELDSTART==GetTxt().GetChar(GetIdx()));
991 + if (OnWin() && (pBM!=NULL || bIsStartMark) && SwViewOption::IsFieldShadings() && !GetOpt().IsPagePreview()) {
992 + OutputDevice* pOut_ = (OutputDevice*)GetOut();
993 + pOut_->Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
994 + pOut_->SetFillColor( SwViewOption::GetFieldShadingsColor() );
995 + pOut_->SetLineColor();
996 +// pOut_->SetLineColor( Color(220, 233, 245));
997 +// pOut_->SetFillColor( Color(220, 233, 245));
998 + pOut_->DrawRect( aIntersect.SVRect() );
999 + pOut_->Pop();
1003 if( !pFnt->GetBackColor() ) return;
1005 diff --git sw/source/core/text/portxt.cxx sw/source/core/text/portxt.cxx
1006 index d18ea63..bb05bd9 100644
1007 --- sw/source/core/text/portxt.cxx
1008 +++ sw/source/core/text/portxt.cxx
1009 @@ -55,6 +55,7 @@
1010 #include <bookmrk.hxx>
1011 #include <pam.hxx>
1012 #include <doc.hxx>
1013 +#include <ecmaflds.hxx>
1015 #if OSL_DEBUG_LEVEL > 1
1016 const sal_Char *GetLangName( const MSHORT nLang );
1017 @@ -781,36 +782,72 @@ sal_Bool SwFieldMarkPortion::Format( SwTxtFormatInfo & )
1018 return ret;
1021 +namespace ecma {
1022 + static int getCurrentListIndex(SwFieldBookmark *pBM, ::rtl::OUString *currentText=NULL) {
1023 + int currentIndex=pBM->getParam(ECMA_FORMDROPDOWN_RESULT, "0").second.toInt32();
1024 + int idx=0;
1025 + for(int i=0;i<pBM->getNumOfParams();i++) {
1026 + SwFieldBookmark::ParamPair_t p=pBM->getParam(i);
1027 + if (p.first.compareToAscii(ECMA_FORMDROPDOWN_LISTENTRY)==0) {
1028 + if (idx==currentIndex) {
1029 + if (currentText!=NULL) *currentText=p.second;
1030 + break;
1031 + } else
1032 + idx++;
1033 + }
1034 + }
1035 + return idx;
1037 +} /* ecma */
1039 void SwFieldFormPortion::Paint( const SwTxtPaintInfo &rInf ) const
1041 -// SwTxtPortion::Paint(rInf);
1042 SwTxtNode *pNd=const_cast<SwTxtNode*>(rInf.GetTxtFrm()->GetTxtNode());
1043 const SwDoc *doc=pNd->GetDoc();
1044 SwIndex aIndex( pNd, rInf.GetIdx() );
1045 SwPosition aPosition(*pNd, aIndex);
1046 SwFieldBookmark *pBM=doc->getFormFieldBookmarkFor(aPosition);
1047 ASSERT(pBM!=NULL, "Where is my form field bookmark???");
1048 - bool checked=(pBM!=NULL?pBM->IsChecked():false);
1049 - rInf.DrawCheckBox( *this , checked);
1050 -// const XubString aTxt = XubString::CreateFromAscii("[ ]");
1051 -// rInf.DrawText( aTxt, *this, 0, aTxt.Len(), false );
1052 + if (pBM!=NULL) {
1053 + if (pBM->isType(ECMA_FORMCHECKBOX)==1) { // a checkbox...
1054 + bool checked=pBM->getParam(ECMA_FORMCHECKBOX_CHECKED).second.compareToAscii("on")==0;
1055 + rInf.DrawCheckBox( *this , checked);
1056 + } else if (pBM->isType(ECMA_FORMDROPDOWN)) { // a list...
1057 + rtl::OUString aTxt;
1058 + int index=ecma::getCurrentListIndex(pBM, &aTxt);
1059 + rInf.DrawViewOpt( *this, POR_FLD );
1060 + rInf.DrawText( aTxt, *this, 0, aTxt.getLength(), false );
1061 + } else {
1062 + assert(0); // unknown type...
1067 sal_Bool SwFieldFormPortion::Format( SwTxtFormatInfo &rInf )
1069 sal_Bool ret=0;
1070 -// ret=SwTxtPortion::Format(rInf);
1072 + SwTxtNode *pNd=const_cast<SwTxtNode*>(rInf.GetTxtFrm()->GetTxtNode());
1073 + const SwDoc *doc=pNd->GetDoc();
1074 + SwIndex aIndex( pNd, rInf.GetIdx() );
1075 + SwPosition aPosition(*pNd, aIndex);
1076 + SwFieldBookmark *pBM=doc->getFormFieldBookmarkFor(aPosition);
1077 + ASSERT(pBM!=NULL, "Where is my form field bookmark???");
1078 + if (pBM!=NULL) {
1079 + if (pBM->isType(ECMA_FORMCHECKBOX)) {
1080 Width(rInf.GetTxtHeight());
1081 Height(rInf.GetTxtHeight());
1082 SetAscent(rInf.GetAscent());
1083 - //int h=rInf.GetTxtHeight();
1086 - Height(100);
1087 - SetAscent(100);
1089 + } else if (pBM->isType(ECMA_FORMDROPDOWN)) {
1090 + ::rtl::OUString aTxt;
1091 + ecma::getCurrentListIndex(pBM, &aTxt);
1092 + SwPosSize aPosSize=rInf.GetTxtSize(aTxt);
1093 + Width(aPosSize.Width());
1094 + Height(aPosSize.Height());
1095 + SetAscent(rInf.GetAscent());
1096 + } else {
1097 + assert(0); // unknown type...
1098 + }
1100 return ret;
1103 diff --git sw/source/core/unocore/unobkm.cxx sw/source/core/unocore/unobkm.cxx
1104 index 26f40ec..755e6f8 100644
1105 --- sw/source/core/unocore/unobkm.cxx
1106 +++ sw/source/core/unocore/unobkm.cxx
1107 @@ -7,7 +7,7 @@
1108 * OpenOffice.org - a multi-platform office productivity suite
1110 * $RCSfile: unobkm.cxx,v $
1111 - * $Revision: 1.17 $
1112 + * $Revision: 1.16 $
1114 * This file is part of OpenOffice.org.
1116 @@ -134,14 +134,15 @@ void SwXBookmark::attachToRangeEx(const uno::Reference< text::XTextRange > & xTe
1117 m_aName = C2S("Bookmark");
1118 // --> OD 2007-10-23 #i81002#
1119 // determine bookmark type due to its proposed name
1120 - if( eMark == IDocumentBookmarkAccess::BOOKMARK &&
1121 - pDoc->isCrossRefBookmarkName( m_aName ) )
1122 - eMark = IDocumentBookmarkAccess::CROSSREF_BOOKMARK;
1123 + IDocumentBookmarkAccess::BookmarkType eBkmkType =
1124 + pDoc->isCrossRefBookmarkName( m_aName )
1125 + ? IDocumentBookmarkAccess::CROSSREF_BOOKMARK
1126 + : eMark;
1127 // <--
1128 if( USHRT_MAX != pDoc->findBookmark(m_aName) )
1129 pDoc->makeUniqueBookmarkName( m_aName );
1130 KeyCode aCode;
1131 - pBkm = pDoc->makeBookmark( aPam, aCode, m_aName, aEmptyStr, eMark);
1132 + pBkm = pDoc->makeBookmark( aPam, aCode, m_aName, aEmptyStr, eBkmkType);
1133 // --> OD 2007-10-23 #i81002#
1134 // Check, if bookmark has been created.
1135 // E.g., the creation of a cross-reference bookmark is suppress,
1136 @@ -164,109 +165,87 @@ void SwXBookmark::attachToRangeEx(const uno::Reference< text::XTextRange > & xTe
1139 void SwXBookmark::attachToRange(const uno::Reference< text::XTextRange > & xTextRange)
1140 - throw( lang::IllegalArgumentException, uno::RuntimeException )
1141 + throw( lang::IllegalArgumentException, uno::RuntimeException )
1143 attachToRangeEx(xTextRange, IDocumentBookmarkAccess::BOOKMARK);
1146 -SwXFieldmark::SwXFieldmark(bool _isReplacementObject, SwBookmark* pBkm, SwDoc* pDc)
1147 - : SwXFieldmark_BASE(pBkm, pDc)
1148 - , isReplacementObject(_isReplacementObject)
1149 -{ }
1152 -void SwXFieldmark::attachToRange(const uno::Reference< text::XTextRange > & xTextRange)
1153 - throw( lang::IllegalArgumentException, uno::RuntimeException )
1154 +SwXFieldmark::SwXFieldmark(bool _isReplacementObject, SwBookmark* pBkm, SwDoc* pDc) : SwXFieldmark_BASE(pBkm, pDc),
1155 +isReplacementObject(_isReplacementObject)
1157 - attachToRangeEx(xTextRange, (isReplacementObject?IDocumentBookmarkAccess::FORM_FIELDMARK_NO_TEXT:IDocumentBookmarkAccess::FORM_FIELDMARK_TEXT));
1160 -::rtl::OUString SwXFieldmark::getDescription(void) throw( ::com::sun::star::uno::RuntimeException )
1161 +::rtl::OUString SwXFieldmark::getFieldType(void) throw( ::com::sun::star::uno::RuntimeException )
1163 vos::OGuard aGuard(Application::GetSolarMutex());
1164 SwFieldBookmark* pBkm = (SwFieldBookmark*)GetBookmark();
1165 - OUString sRet;
1166 if(pBkm)
1167 - sRet = pBkm->GetFFHelpText();
1168 - /* //@TODO implement...
1169 - else if(bIsDescriptor)
1170 - sRet = m_aName;
1171 - */
1172 + return pBkm->getTypeName();
1173 else
1174 throw uno::RuntimeException();
1175 - return sRet;
1178 -::sal_Int16 SAL_CALL SwXFieldmark::getType( ) throw (::com::sun::star::uno::RuntimeException)
1179 +void SwXFieldmark::setFieldType( const ::rtl::OUString& fieldType ) throw (::com::sun::star::uno::RuntimeException)
1181 vos::OGuard aGuard(Application::GetSolarMutex());
1182 SwFieldBookmark* pBkm = (SwFieldBookmark*)GetBookmark();
1183 - ::sal_Int16 sRet;
1184 - if(pBkm)
1185 - sRet = static_cast<sal_Int16>(pBkm->GetFieldType());
1186 - /* //@TODO implement...
1187 - else if(bIsDescriptor)
1188 - sRet = m_aName;
1189 - */
1190 + if (pBkm)
1191 + pBkm->setTypeName(fieldType);
1192 else
1193 - throw uno::RuntimeException();
1194 - return sRet;
1195 + throw uno::RuntimeException();
1198 -::sal_Int16 SAL_CALL SwXFieldmark::getRes( ) throw (::com::sun::star::uno::RuntimeException)
1199 +::sal_Int16 SwXFieldmark::getParamCount( ) throw (::com::sun::star::uno::RuntimeException)
1201 vos::OGuard aGuard(Application::GetSolarMutex());
1202 SwFieldBookmark* pBkm = (SwFieldBookmark*)GetBookmark();
1203 - ::sal_Int16 sRet;
1204 if(pBkm)
1205 - sRet = static_cast<sal_Int16>(pBkm->GetFFRes());
1206 - /* //@TODO implement...
1207 - else if(bIsDescriptor)
1208 - sRet = m_aName;
1209 - */
1210 + return pBkm->getNumOfParams();
1211 else
1212 throw uno::RuntimeException();
1213 - return sRet;
1217 -void SAL_CALL SwXFieldmark::setType( ::sal_Int16 fieldType ) throw (::com::sun::star::uno::RuntimeException)
1218 +::rtl::OUString SwXFieldmark::getParamName(::sal_Int16 i) throw( ::com::sun::star::uno::RuntimeException )
1220 vos::OGuard aGuard(Application::GetSolarMutex());
1221 SwFieldBookmark* pBkm = (SwFieldBookmark*)GetBookmark();
1222 - if (pBkm)
1223 - pBkm->SetFieldType(fieldType);
1224 + if(pBkm)
1225 + return pBkm->getParam(i).first;
1226 else
1227 throw uno::RuntimeException();
1230 -void SAL_CALL SwXFieldmark::setRes( ::sal_Int16 res ) throw (::com::sun::star::uno::RuntimeException)
1231 +::rtl::OUString SwXFieldmark::getParamValue(::sal_Int16 i) throw( ::com::sun::star::uno::RuntimeException )
1233 vos::OGuard aGuard(Application::GetSolarMutex());
1234 SwFieldBookmark* pBkm = (SwFieldBookmark*)GetBookmark();
1235 - if (pBkm)
1236 - pBkm->SetFFRes(res);
1237 + if(pBkm)
1238 + return pBkm->getParam(i).second;
1239 else
1240 throw uno::RuntimeException();
1243 -void SAL_CALL SwXFieldmark::setDescription( const ::rtl::OUString& description ) throw (::com::sun::star::uno::RuntimeException)
1244 +void SwXFieldmark::addParam( const ::rtl::OUString& name, const ::rtl::OUString& value, ::sal_Bool replaceExisting ) throw (::com::sun::star::uno::RuntimeException)
1246 vos::OGuard aGuard(Application::GetSolarMutex());
1247 SwFieldBookmark* pBkm = (SwFieldBookmark*)GetBookmark();
1248 if (pBkm)
1249 - pBkm->SetFFHelpText(description);
1250 + pBkm->addParam(name, value, replaceExisting);
1251 else
1252 - throw uno::RuntimeException();
1253 + throw uno::RuntimeException();
1257 +void SwXFieldmark::attachToRange(const uno::Reference< text::XTextRange > & xTextRange)
1258 + throw( lang::IllegalArgumentException, uno::RuntimeException )
1260 + attachToRangeEx(xTextRange, (isReplacementObject?IDocumentBookmarkAccess::FORM_FIELDMARK_NO_TEXT:IDocumentBookmarkAccess::FORM_FIELDMARK_TEXT));
1265 ::com::sun::star::uno::Any SAL_CALL SwXFieldmark::queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
1267 - return SwXBookmark::queryInterface(rType);
1268 + return SwXBookmark::queryInterface(rType);
1272 diff --git sw/source/core/unocore/unoportenum.cxx sw/source/core/unocore/unoportenum.cxx
1273 index fc11495..c4160ba 100644
1274 --- sw/source/core/unocore/unoportenum.cxx
1275 +++ sw/source/core/unocore/unoportenum.cxx
1276 @@ -653,15 +653,7 @@ void lcl_FillBookmarkArray(SwDoc& rDoc,SwUnoCrsr& rUnoCrsr, SwXBookmarkPortion_I
1277 for( sal_uInt16 n = 0; n < nArrLen; ++n )
1279 SwBookmark* pMark = rMarks.GetObject( n );
1280 - /*
1281 - if (pMark!=NULL && pMark->GetName().CompareToAscii(FIELD_BOOKMARK_PREFIX, strlen(FIELD_BOOKMARK_PREFIX))==0) {
1282 - continue;
1285 - if (pMark!=NULL && pMark->GetName().CompareToAscii(FIELD_FORM_BOOKMARK_PREFIX, strlen(FIELD_FORM_BOOKMARK_PREFIX))==0) {
1286 - continue;
1288 - */
1289 if (pMark!=NULL && pMark->IsFormFieldMark())
1291 continue;
1292 diff --git sw/source/filter/ww8/wrtw8nds.cxx sw/source/filter/ww8/wrtw8nds.cxx
1293 index ab8ff01..a8f5157 100644
1294 --- sw/source/filter/ww8/wrtw8nds.cxx
1295 +++ sw/source/filter/ww8/wrtw8nds.cxx
1296 @@ -112,6 +112,45 @@ using namespace sw::util;
1297 using namespace sw::types;
1298 using namespace nsFieldFlags;
1301 +static String lcl_getFieldCode(SwFieldBookmark* pFieldmark) {
1302 + ASSERT(pFieldmark!=NULL, "where is my fieldmark???");
1303 + if (pFieldmark->isType(ECMA_FORMTEXT)) {
1304 + return String::CreateFromAscii(" FORMTEXT ");
1305 + } else if (pFieldmark->isType(ECMA_FORMDROPDOWN)) {
1306 + return String::CreateFromAscii(" FORMDROPDOWN ");
1307 + } else if (pFieldmark->isType(ECMA_FORMCHECKBOX)) {
1308 + return String::CreateFromAscii(" FORMCHECKBOX ");
1309 + } else if (pFieldmark->isType(ECMA_TOC)) {
1310 + return String::CreateFromAscii(" TOC ");
1311 + } else if (pFieldmark->isType(ECMA_HYPERLINK)) {
1312 + return String::CreateFromAscii(" HYPERLINK ");
1313 + } else if (pFieldmark->isType(ECMA_PAGEREF)) {
1314 + return String::CreateFromAscii(" PAGEREF ");
1315 + } else {
1316 + return pFieldmark->getTypeName();
1320 +ww::eField lcl_getFieldId(SwFieldBookmark* pFieldmark) {
1321 + ASSERT(pFieldmark!=NULL, "where is my fieldmark???");
1322 + if (pFieldmark->isType(ECMA_FORMTEXT)) {
1323 + return ww::eFORMTEXT;
1324 + } else if (pFieldmark->isType(ECMA_FORMDROPDOWN)) {
1325 + return ww::eFORMDROPDOWN;
1326 + } else if (pFieldmark->isType(ECMA_FORMCHECKBOX)) {
1327 + return ww::eFORMCHECKBOX;
1328 + } else if (pFieldmark->isType(ECMA_TOC)) {
1329 + return ww::eTOC;
1330 + } else if (pFieldmark->isType(ECMA_HYPERLINK)) {
1331 + return ww::eHYPERLINK;
1332 + } else if (pFieldmark->isType(ECMA_PAGEREF)) {
1333 + return ww::ePAGEREF;
1334 + } else {
1335 + return ww::eUNKNOWN;
1336 + }
1339 /* \f */
1341 WW8_AttrIter::WW8_AttrIter(SwWW8Writer& rWr)
1342 @@ -288,19 +327,17 @@ xub_StrLen WW8_SwAttrIter::SearchNext( xub_StrLen nStartPos )
1344 xub_StrLen nPos;
1345 xub_StrLen nMinPos = STRING_MAXLEN;
1346 + xub_StrLen i=0;
1348 const String aTxt = rNd.GetTxt();
1349 xub_StrLen pos = aTxt.Search(CH_TXT_ATR_FIELDSTART, nStartPos);
1350 - if( pos==STRING_NOTFOUND )
1352 - pos = aTxt.Search(CH_TXT_ATR_FIELDEND, nStartPos);
1353 - if( pos==STRING_NOTFOUND )
1354 - pos = aTxt.Search(CH_TXT_ATR_FORMELEMENT, nStartPos);
1356 - if( pos!=STRING_NOTFOUND )
1357 + if (pos==STRING_NOTFOUND)
1358 + pos=aTxt.Search(CH_TXT_ATR_FIELDEND, nStartPos);
1359 + if (pos==STRING_NOTFOUND)
1360 + pos=aTxt.Search(CH_TXT_ATR_FORMELEMENT, nStartPos);
1361 + if (pos!=STRING_NOTFOUND)
1362 nMinPos=pos;
1364 - xub_StrLen i=0;
1366 // first the redline, then the attributes
1367 if( pCurRedline )
1369 @@ -1558,36 +1595,49 @@ Writer& OutWW8_SwTxtNode( Writer& rWrt, SwCntntNode& rNode )
1370 ASSERT(pFieldmark!=NULL, "Looks like this doc is broken...; where is the Fieldmark for the FIELDSTART??");
1372 if (pFieldmark!=NULL) {
1373 - rWW8Wrt.AppendBookmark( pFieldmark->GetName(), 1);
1374 + if (pFieldmark->isType(ECMA_FORMTEXT)) {
1375 + rWW8Wrt.AppendBookmark( pFieldmark->GetName(), 0);
1377 + rWW8Wrt.OutField(NULL, lcl_getFieldId(pFieldmark), lcl_getFieldCode(pFieldmark), WRITEFIELD_START | WRITEFIELD_CMD_START);
1378 + if (pFieldmark->isType(ECMA_FORMTEXT)) {
1379 + rWW8Wrt.WriteFormData( *pFieldmark );
1381 + if (pFieldmark->isType(ECMA_HYPERLINK)) {
1382 + rWW8Wrt.WriteHyperlinkData( *pFieldmark );
1384 + rWW8Wrt.OutField(NULL, lcl_getFieldId(pFieldmark), String(), WRITEFIELD_CMD_END);
1386 - rWW8Wrt.OutField(NULL, ww::eFORMTEXT, String::CreateFromAscii(" FORMTEXT "), WRITEFIELD_START | WRITEFIELD_CMD_START);
1387 - if (pFieldmark!=NULL) {
1388 - rWW8Wrt.WriteFormData( *pFieldmark );
1390 - rWW8Wrt.OutField(NULL, ww::eFORMTEXT, String(), WRITEFIELD_CMD_END);
1391 } else if (ch==CH_TXT_ATR_FIELDEND) {
1392 SwPosition aPosition( *pNd, SwIndex( (SwTxtNode*)pNd, nAktPos ) );
1393 SwFieldBookmark* pFieldmark=(SwFieldBookmark*)rWW8Wrt.pDoc->getFieldBookmarkFor( aPosition );
1394 ASSERT(pFieldmark!=NULL, "Looks like this doc is broken...; where is the Fieldmark for the FIELDSTART??");
1395 - rWW8Wrt.OutField(NULL, ww::eFORMTEXT, String(), WRITEFIELD_CLOSE);
1396 if (pFieldmark!=NULL) {
1397 - rWW8Wrt.AppendBookmark( pFieldmark->GetName(), 0);
1398 + rWW8Wrt.OutField(NULL, lcl_getFieldId(pFieldmark), String(), WRITEFIELD_CLOSE);
1399 + if (pFieldmark->isType(ECMA_FORMTEXT)) {
1401 + rWW8Wrt.AppendBookmark( pFieldmark->GetName(), 0);
1404 } else if (ch==CH_TXT_ATR_FORMELEMENT) {
1405 SwPosition aPosition( *pNd, SwIndex( (SwTxtNode*)pNd, nAktPos ) );
1406 SwFieldBookmark* pFieldmark=rWW8Wrt.pDoc->getFormFieldBookmarkFor( aPosition );
1407 ASSERT(pFieldmark!=NULL, "Looks like this doc is broken...; where is the Fieldmark for the FIELDSTART??");
1408 if (pFieldmark!=NULL) {
1409 - rWW8Wrt.AppendBookmark( pFieldmark->GetName(), 1);
1411 - rWW8Wrt.OutField(NULL, ww::eFORMCHECKBOX, String::CreateFromAscii(" FORMCHECKBOX "), WRITEFIELD_START | WRITEFIELD_CMD_START);
1412 - if (pFieldmark!=NULL) {
1414 - rWW8Wrt.WriteFormData( *pFieldmark );
1416 - rWW8Wrt.OutField(NULL, ww::eFORMCHECKBOX, String(), WRITEFIELD_CMD_END | WRITEFIELD_CLOSE);
1417 - if (pFieldmark!=NULL) {
1418 - rWW8Wrt.AppendBookmark( pFieldmark->GetName(), 0);
1419 + /* printf("export FROMELEMENT: pFieldmark->isType(ECMA_FORMDROPDOWN)=%i, pFieldmark->isType(ECMA_FORMCHECKBOX)=%i\n", pFieldmark->isType(ECMA_FORMDROPDOWN), pFieldmark->isType(ECMA_FORMCHECKBOX)); */
1420 + if (pFieldmark->isType(ECMA_FORMDROPDOWN) || pFieldmark->isType(ECMA_FORMCHECKBOX)) {
1421 + rWW8Wrt.AppendBookmark( pFieldmark->GetName(), 0);
1424 + /* printf("lcl_getFieldId(pFieldmark)=%i\n",lcl_getFieldId(pFieldmark)); */
1425 + rWW8Wrt.OutField(NULL, lcl_getFieldId(pFieldmark), lcl_getFieldCode(pFieldmark), WRITEFIELD_START | WRITEFIELD_CMD_START);
1426 + if (pFieldmark->isType(ECMA_FORMCHECKBOX) || pFieldmark->isType(ECMA_FORMDROPDOWN)) {
1427 + rWW8Wrt.WriteFormData( *pFieldmark );
1430 + rWW8Wrt.OutField(NULL, lcl_getFieldId(pFieldmark), String(), WRITEFIELD_CMD_END | WRITEFIELD_CLOSE);
1431 + if (pFieldmark->isType(ECMA_FORMDROPDOWN) || pFieldmark->isType(ECMA_FORMCHECKBOX)) {
1432 + rWW8Wrt.AppendBookmark( pFieldmark->GetName(), 0);
1436 nLen-=static_cast<USHORT>(ofs);
1437 diff --git sw/source/filter/ww8/wrtww8.cxx sw/source/filter/ww8/wrtww8.cxx
1438 index ca1d344..0d99564 100644
1439 --- sw/source/filter/ww8/wrtww8.cxx
1440 +++ sw/source/filter/ww8/wrtww8.cxx
1441 @@ -101,6 +101,7 @@
1442 #include "writerwordglue.hxx"
1444 #include <IDocumentBookmarkAccess.hxx>
1445 +#include <ecmaflds.hxx>
1447 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
1448 #include <com/sun/star/document/XDocumentProperties.hpp>
1449 @@ -2303,7 +2304,7 @@ void SwWW8Writer::OutWW8TableBackgrounds
1451 void SwWW8Writer::WriteText()
1453 -#ifdef DEBUG
1454 +#ifndef NDEBUG
1455 ::std::clog << "<WriteText>" << ::std::endl;
1456 ::std::clog << dbg_out(pCurPam->GetDoc()->GetNodes()) << ::std::endl;
1457 #endif
1458 @@ -3183,8 +3184,19 @@ void SwWW8Writer::WriteFormData(SwFieldBookmark &rFieldmark)
1459 ASSERT(bWrtWW8, "No 95 export yet");
1460 if (!bWrtWW8) return;
1462 - int type=rFieldmark.GetFieldType();
1463 - const String ffname=rFieldmark.GetFFName();
1464 + ASSERT(rFieldmark.isType(ECMA_FORMTEXT) || rFieldmark.isType(ECMA_FORMDROPDOWN) || rFieldmark.isType(ECMA_FORMCHECKBOX), "Unknown field type!!!");
1465 + if (!(rFieldmark.isType(ECMA_FORMTEXT) || rFieldmark.isType(ECMA_FORMDROPDOWN) || rFieldmark.isType(ECMA_FORMCHECKBOX)))
1466 + return;
1468 + /* printf("write form data\n"); */
1470 + int type=0;
1471 + if (rFieldmark.isType(ECMA_FORMCHECKBOX))
1472 + type=1;
1473 + if (rFieldmark.isType(ECMA_FORMDROPDOWN))
1474 + type=2;
1476 + const String ffname=rFieldmark.getParam("name").second;
1478 ULONG nDataStt = pDataStrm->Tell();
1479 pChpPlc->AppendFkpEntry( Strm().Tell() );
1480 @@ -3206,13 +3218,29 @@ void SwWW8Writer::WriteFormData(SwFieldBookmark &rFieldmark)
1481 sal_uInt8 aFldHeader[] =
1483 0xFF, 0xFF, 0xFF, 0xFF, // Unicode Marker...
1484 - 0, 0, 0, 0//, 0, 0, 0, 0
1485 + 0, 0, 0, 0, 0, 0 //, 0, 0
1488 aFldHeader[4] |= (type & 0x03);
1489 - int ffres=rFieldmark.GetFFRes();
1490 + int ffres=0;
1491 + if (type==1) { // checkbox
1492 + ffres=rFieldmark.getParam(ECMA_FORMCHECKBOX_CHECKED).second.compareToAscii("on")==0;
1493 + } else if (type==2) { // drop down
1494 + ffres=rFieldmark.getParam(ECMA_FORMDROPDOWN_RESULT, "0").second.toInt32();
1497 aFldHeader[4] |= ((ffres<<2) & 0x7C);
1500 + std::vector< ::rtl::OUString > aListItems;
1501 + if (type==2) {
1502 + aFldHeader[5] |= 0x80; // ffhaslistbox
1503 + for(int i=0;i<rFieldmark.getNumOfParams();i++) {
1504 + if (rFieldmark.getParam(i).first.compareToAscii(ECMA_FORMDROPDOWN_LISTENTRY)==0)
1505 + aListItems.push_back(rFieldmark.getParam(i).second);
1509 const String ffdeftext;
1510 const String ffformat;
1511 const String ffhelptext;
1512 @@ -3220,6 +3248,7 @@ void SwWW8Writer::WriteFormData(SwFieldBookmark &rFieldmark)
1513 const String ffentrymcr;
1514 const String ffexitmcr;
1517 const sal_uInt8 aFldData[] =
1519 0,0,0,0, // len of struct
1520 @@ -3239,6 +3268,15 @@ void SwWW8Writer::WriteFormData(SwFieldBookmark &rFieldmark)
1521 +2*ffstattext.Len()+4
1522 +2*ffentrymcr.Len()+4
1523 +2*ffexitmcr.Len()+4;
1524 + if (type==2) {
1525 + slen+=2; // for 0xFF, 0xFF
1526 + slen+=4; // for num of list items
1527 + const int items=aListItems.size();
1528 + for(int i=0;i<items;i++) {
1529 + String item=aListItems[i];
1530 + slen+=2*item.Len()+2;
1533 #ifdef OSL_BIGENDIAN
1534 slen=SWAPLONG(slen);
1535 #endif // OSL_BIGENDIAN
1536 @@ -3249,14 +3287,14 @@ void SwWW8Writer::WriteFormData(SwFieldBookmark &rFieldmark)
1538 len=sizeof(aFldHeader);
1539 assert(len==8);
1540 - pDataStrm->Write( aFldHeader, len);
1541 + pDataStrm->Write( aFldHeader, len);
1543 - WriteString_xstz( *pDataStrm, ffname, true); // Form field name
1544 + WriteString_xstz( *pDataStrm, ffname, true); // Form field name
1546 if (type==0) {
1547 - WriteString_xstz( *pDataStrm, ffdeftext, true);
1548 + WriteString_xstz( *pDataStrm, ffdeftext, true);
1549 } else {
1550 - pDataStrm->WriteNumber((sal_uInt16)0);
1551 + *pDataStrm<<(sal_uInt16)0;
1553 WriteString_xstz( *pDataStrm, ffformat, true);
1554 WriteString_xstz( *pDataStrm, ffhelptext, true);
1555 @@ -3264,13 +3302,23 @@ void SwWW8Writer::WriteFormData(SwFieldBookmark &rFieldmark)
1556 WriteString_xstz( *pDataStrm, ffentrymcr, true);
1557 WriteString_xstz( *pDataStrm, ffexitmcr, true);
1558 if (type==2) {
1559 - // 0xFF, 0xFF
1560 - // sal_uInt32 number of strings
1561 - // (sal_uInt16 len; sal_uInt16 unicode char[len])*num of strings
1562 + *pDataStrm<<(sal_uInt16)0xFFFF;
1563 + const int items=aListItems.size();
1564 + *pDataStrm<<(sal_uInt32)items;
1565 + for(int i=0;i<items;i++) {
1566 + String item=aListItems[i];
1567 + WriteString_xstz( *pDataStrm, item, false);
1573 +void SwWW8Writer::WriteHyperlinkData(SwFieldBookmark &rFieldmark)
1575 + //@TODO implement me !!!
1579 void SwWW8Writer::OutWW8_TableNodeInfoInner(ww8::WW8TableNodeInfoInner::Pointer_t pNodeInfoInner)
1581 SVBT16 nStyle;
1582 diff --git sw/source/filter/ww8/wrtww8.hxx sw/source/filter/ww8/wrtww8.hxx
1583 index d11049f..757126c 100644
1584 --- sw/source/filter/ww8/wrtww8.hxx
1585 +++ sw/source/filter/ww8/wrtww8.hxx
1586 @@ -733,7 +733,8 @@ public:
1587 void CollectOutlineBookmarks(const SwDoc &rDoc);
1588 void AddBookmark(String sBkmkName);
1590 - void WriteFormData(SwFieldBookmark &rFieldmark);
1591 + void WriteFormData(SwFieldBookmark &rFieldmark);
1592 + void WriteHyperlinkData(SwFieldBookmark &rFieldmark);
1593 WW8_WrPlcFld* CurrentFieldPlc() const;
1594 private:
1595 //No copying
1596 diff --git sw/source/filter/ww8/ww8par.cxx sw/source/filter/ww8/ww8par.cxx
1597 index 385de9b..68be371 100644
1598 --- sw/source/filter/ww8/ww8par.cxx
1599 +++ sw/source/filter/ww8/ww8par.cxx
1600 @@ -1685,7 +1685,6 @@ WW8ReaderSave::WW8ReaderSave(SwWW8ImplReader* pRdr ,WW8_CP nStartCp) :
1601 maOldApos.push_back(false);
1602 maOldApos.swap(pRdr->maApos);
1603 maOldFieldStack.swap(pRdr->maFieldStack);
1604 - maFieldCtxStack.swap(pRdr->maNewFieldCtxStack);
1607 void WW8ReaderSave::Restore( SwWW8ImplReader* pRdr )
1608 @@ -1732,7 +1731,6 @@ void WW8ReaderSave::Restore( SwWW8ImplReader* pRdr )
1609 pRdr->pPlcxMan->RestoreAllPLCFx(maPLCFxSave);
1610 pRdr->maApos.swap(maOldApos);
1611 pRdr->maFieldStack.swap(maOldFieldStack);
1612 - pRdr->maNewFieldCtxStack.swap(maFieldCtxStack);
1615 void SwWW8ImplReader::Read_HdFtFtnText( const SwNodeIndex* pSttIdx,
1616 @@ -2750,22 +2748,6 @@ bool SwWW8ImplReader::ReadChar(long nPosCp, long nCpOfs)
1617 case 0x15:
1618 if( !bSpec ) // Juristenparagraph
1619 cInsert = '\xa7';
1620 - else { //0x15 is special --> so it's our field end mark...; hmmm what about field marks not handled by us??, maybe a problem with nested fields; probably an area of bugs... [well release quick and release often....]
1621 - if (!maNewFieldCtxStack.empty() && pPaM!=NULL && pPaM->GetPoint()!=NULL) {
1622 - WW8NewFieldCtx *pFieldCtx=maNewFieldCtxStack.back();
1623 - maNewFieldCtxStack.pop_back();
1624 - SwPosition aEndPos = *pPaM->GetPoint();
1625 - SwPaM aFldPam( pFieldCtx->GetPtNode(), pFieldCtx->GetPtCntnt(), aEndPos.nNode, aEndPos.nContent.GetIndex());
1626 - SwFieldBookmark *pFieldmark=(SwFieldBookmark*)rDoc.makeBookmark(aFldPam, KeyCode(), pFieldCtx->GetBookmarkName(), String(), IDocumentBookmarkAccess::FORM_FIELDMARK_TEXT);
1627 - ASSERT(pFieldmark!=NULL, "hmmm; why was the bookmark not created?");
1628 - if (pFieldmark!=NULL) {
1629 - pFieldmark->SetFieldType(0); // 0==Text
1630 - // set field data here...
1631 - pFieldCtx->SetCurrentFieldParamsTo(*pFieldmark);
1633 - delete pFieldCtx;
1636 break;
1637 case 0x9:
1638 cInsert = '\x9'; // Tab
1639 @@ -3580,7 +3562,14 @@ void wwSectionManager::InsertSegments()
1641 bool bInsertSection = (aIter != aStart) ? (aIter->IsContinous() && bThisAndPreviousAreCompatible): false;
1642 bool bInsertPageDesc = !bInsertSection;
1643 - bool bProtected = !bUseEnhFields && SectionIsProtected(*aIter); // do we really need this ?? I guess I have a different logic in editshell which disales this...
1644 + bool bProtected = SectionIsProtected(*aIter); // do we really need this ?? I guess I have a different logic in editshell which disales this...
1645 + if (bUseEnhFields && mrReader.pWDop->fProtEnabled && aIter->IsNotProtected()) {
1646 + // here we have the special case that the whole document is protected, with the execption of this section.
1647 + // I want to address this when I do the section rework, so for the moment we disable the overall protection then...
1648 + mrReader.rDoc.set(IDocumentSettingAccess::PROTECT_FORM, false );
1652 if (bInsertPageDesc)
1655 diff --git sw/source/filter/ww8/ww8par.hxx sw/source/filter/ww8/ww8par.hxx
1656 index 840dfdf..d8a789d 100644
1657 --- sw/source/filter/ww8/ww8par.hxx
1658 +++ sw/source/filter/ww8/ww8par.hxx
1659 @@ -61,6 +61,8 @@
1660 #include "ww8scan.hxx" // WW8Fib
1661 #include "ww8glsy.hxx"
1662 #include "../inc/msfilter.hxx"
1663 +#include <ecmaflds.hxx>
1664 +#include <bookmrk.hxx>
1666 class SwDoc;
1667 class SwPaM;
1668 @@ -362,6 +364,8 @@ namespace sw
1669 Position(const SwPosition &rPos);
1670 Position(const Position &rPos);
1671 operator SwPosition() const;
1672 + SwNodeIndex GetPtNode() { return maPtNode; };
1673 + xub_StrLen GetPtCntnt() { return mnPtCntnt; };
1677 @@ -369,40 +373,31 @@ namespace sw
1678 class FieldEntry
1680 public:
1681 - sw::hack::Position maStartPos;
1682 - sal_uInt16 mnFieldId;
1683 - FieldEntry(SwPosition &rPos, sal_uInt16 nFieldId) throw();
1684 - FieldEntry(const FieldEntry &rOther) throw();
1685 - FieldEntry &operator=(const FieldEntry &rOther) throw();
1686 - void Swap(FieldEntry &rOther) throw();
1688 + typedef ::std::vector<SwFieldBookmark::ParamPair_t> Params_t;
1690 -class WW8NewFieldCtx
1692 private:
1693 - SwNodeIndex maPtNode;
1694 - xub_StrLen mnPtCntnt;
1695 ::rtl::OUString sBookmarkName;
1696 ::rtl::OUString sBookmarkType;
1697 - typedef ::std::pair< ::rtl::OUString, ::rtl::OUString> Param_t;
1698 - typedef ::std::vector< Param_t > Params_t;
1699 Params_t maParams;
1700 - SwPaM * mpPaM;
1702 public:
1703 - WW8NewFieldCtx(SwPosition &aStartPos, ::rtl::OUString sBookmarkName, ::rtl::OUString sBookmarkType);
1704 - ~WW8NewFieldCtx();
1705 + sw::hack::Position maStartPos;
1706 + sal_uInt16 mnFieldId;
1707 + FieldEntry(SwPosition &rPos, sal_uInt16 nFieldId) throw();
1708 + FieldEntry(const FieldEntry &rOther) throw();
1709 + FieldEntry &operator=(const FieldEntry &rOther) throw();
1710 + void Swap(FieldEntry &rOther) throw();
1712 - SwNodeIndex GetPtNode() { return maPtNode; };
1713 - xub_StrLen GetPtCntnt() { return mnPtCntnt; };
1714 - ::rtl::OUString GetBookmarkName();
1715 - ::rtl::OUString GetBookmarkType();
1716 - void AddParam(::rtl::OUString name, ::rtl::OUString value);
1717 - void SetCurrentFieldParamsTo(SwFieldBookmark &rFieldBookmark);
1718 + SwNodeIndex GetPtNode() { return maStartPos.GetPtNode(); };
1719 + xub_StrLen GetPtCntnt() { return maStartPos.GetPtCntnt(); };
1721 + ::rtl::OUString GetBookmarkName();
1722 + ::rtl::OUString GetBookmarkType();
1723 + void SetBookmarkName(::rtl::OUString bookmarkName);
1724 + void SetBookmarkType(::rtl::OUString bookmarkType);
1725 + void AddParam(::rtl::OUString name, ::rtl::OUString value);
1726 + Params_t &getParams();
1730 //-----------------------------------------
1731 // Mini-Merker fuer einige Flags
1732 //-----------------------------------------
1733 @@ -435,7 +430,6 @@ private:
1734 bool mbWasParaEnd;
1735 bool mbHasBorder;
1736 bool mbFirstPara;
1737 - std::deque<WW8NewFieldCtx *> maFieldCtxStack;
1738 public:
1739 WW8ReaderSave(SwWW8ImplReader* pRdr, WW8_CP nStart=-1);
1740 void Restore(SwWW8ImplReader* pRdr);
1741 @@ -890,9 +884,6 @@ private:
1742 std::deque<FieldEntry> maFieldStack;
1743 typedef std::deque<FieldEntry>::const_iterator mycFieldIter;
1745 - typedef std::deque<WW8NewFieldCtx *> WW8NewFieldCtxStack_t;
1746 - WW8NewFieldCtxStack_t maNewFieldCtxStack;
1749 A stack of open footnotes. Should only be one in it at any time.
1751 diff --git sw/source/filter/ww8/ww8par3.cxx sw/source/filter/ww8/ww8par3.cxx
1752 index a83e3cb..7ce8b98 100644
1753 --- sw/source/filter/ww8/ww8par3.cxx
1754 +++ sw/source/filter/ww8/ww8par3.cxx
1755 @@ -96,6 +96,7 @@
1757 #include <bookmrk.hxx>
1758 #include <svtools/fltrcfg.hxx>
1759 +#include <ecmaflds.hxx>
1761 #include <stdio.h>
1763 @@ -103,49 +104,6 @@ using namespace com::sun::star;
1764 using namespace sw::util;
1765 using namespace sw::types;
1767 -WW8NewFieldCtx::WW8NewFieldCtx(SwPosition &aStartPos, ::rtl::OUString _sBookmarkName, ::rtl::OUString _sBookmarkType)
1768 -: maPtNode(aStartPos.nNode), mnPtCntnt(aStartPos.nContent.GetIndex()),
1769 - sBookmarkName(_sBookmarkName),
1770 - sBookmarkType(_sBookmarkType), mpPaM(NULL)
1775 -WW8NewFieldCtx::~WW8NewFieldCtx()
1777 - if (mpPaM) delete mpPaM;
1780 -::rtl::OUString WW8NewFieldCtx::GetBookmarkName()
1782 - return sBookmarkName;
1785 -::rtl::OUString WW8NewFieldCtx::GetBookmarkType()
1787 - return sBookmarkType;
1790 -void WW8NewFieldCtx::AddParam(::rtl::OUString name, ::rtl::OUString value)
1792 - maParams.push_back( Param_t(name, value) );
1795 -void WW8NewFieldCtx::SetCurrentFieldParamsTo(SwFieldBookmark &rFieldBookmark)
1797 - for(Params_t::iterator i=maParams.begin();i!=maParams.end();i++) {
1798 - ::rtl::OUString aName=i->first;
1799 - ::rtl::OUString aValue=i->second;
1800 - if (aName.compareToAscii("Description")==0) {
1801 - rFieldBookmark.SetFFHelpText(aValue);
1802 - } else if (aName.compareToAscii("Name")==0) {
1803 - rFieldBookmark.SetFFName(aValue);
1804 - } else if (aName.compareToAscii("Result")==0) {
1805 - rFieldBookmark.SetFFRes( aValue.toInt32() );
1810 //-----------------------------------------
1811 // UNO-Controls
1812 //-----------------------------------------
1813 @@ -222,10 +180,10 @@ eF_ResT SwWW8ImplReader::Read_F_FormTextBox( WW8FieldDesc* pF, String& rStr )
1816 if (aBookmarkName.Len()>0) {
1817 - WW8NewFieldCtx *pFieldCtx=new WW8NewFieldCtx(*pPaM->GetPoint(), aBookmarkName, ::rtl::OUString::createFromAscii("ecma.office-open-xml.field.FORMTEXT"));
1818 - maNewFieldCtxStack.push_back(pFieldCtx);
1819 - pFieldCtx->AddParam(::rtl::OUString::createFromAscii("Description"), aFormula.sToolTip);
1820 - pFieldCtx->AddParam(::rtl::OUString::createFromAscii("Name"), aFormula.sTitle);
1821 + maFieldStack.back().SetBookmarkName(aBookmarkName);
1822 + maFieldStack.back().SetBookmarkType(::rtl::OUString::createFromAscii(ECMA_FORMTEXT));
1823 + maFieldStack.back().AddParam(::rtl::OUString::createFromAscii("Description"), aFormula.sToolTip);
1824 + maFieldStack.back().AddParam(::rtl::OUString::createFromAscii("Name"), aFormula.sTitle);
1826 return FLD_TEXT;
1828 @@ -269,15 +227,14 @@ eF_ResT SwWW8ImplReader::Read_F_FormCheckBox( WW8FieldDesc* pF, String& rStr )
1831 if (aBookmarkName.Len()>0) {
1832 - SwFieldBookmark *pFieldmark=(SwFieldBookmark*)rDoc.makeBookmark(*pPaM, KeyCode(), aBookmarkName, String(), IDocumentBookmarkAccess::FORM_FIELDMARK_NO_TEXT);
1833 - ASSERT(pFieldmark!=NULL, "hmmm; why was the bookmark not created?");
1834 - if (pFieldmark!=NULL) {
1835 - pFieldmark->SetFieldType(1); // 0==Checkbox
1836 - pFieldmark->SetFFName(aFormula.sTitle);
1837 - pFieldmark->SetFFHelpText(aFormula.sToolTip);
1838 - pFieldmark->SetChecked(aFormula.nChecked!=0);
1839 - // set field data here...
1841 + SwFieldBookmark *pFieldmark=(SwFieldBookmark*)rDoc.makeNoTextFieldBookmark(*pPaM, aBookmarkName, rtl::OUString::createFromAscii(ECMA_FORMCHECKBOX));
1842 + ASSERT(pFieldmark!=NULL, "hmmm; why was the bookmark not created?");
1843 + if (pFieldmark!=NULL) {
1844 + pFieldmark->addParam(rtl::OUString::createFromAscii(ECMA_FORMCHECKBOX_NAME), aFormula.sTitle);
1845 + pFieldmark->addParam(rtl::OUString::createFromAscii(ECMA_FORMCHECKBOX_HELPTEXT), aFormula.sToolTip);
1846 + pFieldmark->addParam(rtl::OUString::createFromAscii(ECMA_FORMCHECKBOX_CHECKED), ::rtl::OUString::createFromAscii(aFormula.nChecked!=0?"on":"off"));
1847 + // set field data here...
1850 return FLD_OK;
1852 @@ -290,24 +247,70 @@ eF_ResT SwWW8ImplReader::Read_F_FormListBox( WW8FieldDesc* pF, String& rStr)
1853 if (0x01 == rStr.GetChar(writer_cast<xub_StrLen>(pF->nLCode-1)))
1854 ImportFormulaControl(aFormula,pF->nSCode+pF->nLCode-1, WW8_CT_DROPDOWN);
1856 - SwDropDownField aFld(
1857 - (SwDropDownFieldType*)rDoc.GetSysFldType(RES_DROPDOWN));
1858 + const SvtFilterOptions* pOpt = SvtFilterOptions::Get();
1859 + sal_Bool bUseEnhFields=(pOpt && pOpt->IsUseEnhancedFields());
1861 - aFld.SetName(aFormula.sTitle);
1862 - aFld.SetHelp(aFormula.sHelp);
1863 - aFld.SetToolTip(aFormula.sToolTip);
1864 + if (!bUseEnhFields) {
1865 + SwDropDownField aFld(
1866 + (SwDropDownFieldType*)rDoc.GetSysFldType(RES_DROPDOWN));
1868 - if (!aFormula.maListEntries.empty())
1870 - aFld.SetItems(aFormula.maListEntries);
1871 - int nIndex = aFormula.fDropdownIndex < aFormula.maListEntries.size()
1872 - ? aFormula.fDropdownIndex : 0;
1873 - aFld.SetSelectedItem(aFormula.maListEntries[nIndex]);
1875 + aFld.SetName(aFormula.sTitle);
1876 + aFld.SetHelp(aFormula.sHelp);
1877 + aFld.SetToolTip(aFormula.sToolTip);
1879 + if (!aFormula.maListEntries.empty())
1881 + aFld.SetItems(aFormula.maListEntries);
1882 + int nIndex = aFormula.fDropdownIndex < aFormula.maListEntries.size()
1883 + ? aFormula.fDropdownIndex : 0;
1884 + aFld.SetSelectedItem(aFormula.maListEntries[nIndex]);
1887 + rDoc.Insert(*pPaM, SwFmtFld(aFld), 0);
1888 + return FLD_OK;
1889 + } else {
1890 + //@TODO fix: copy pasting here!!!!!!!!!!!!!!
1891 + //REVIEW: don't let this throught.... sometime I forget to get rid of my proof of concept stuff. Please kindly remind me!!!!!
1893 + String aBookmarkName;
1894 + WW8PLCFx_Book* pB = pPlcxMan->GetBook();
1895 + if (pB!=NULL) {
1896 + WW8_CP currentCP=pF->nSCode;
1897 + WW8_CP currentLen=pF->nLen;
1899 + USHORT bkmFindIdx;
1900 + String aBookmarkFind=pB->GetBookmark(currentCP-1, currentCP+currentLen-1, bkmFindIdx);
1902 + if (aBookmarkFind.Len()>0) {
1903 + pB->SetStatus(bkmFindIdx, BOOK_FIELD); // mark as consumed by field
1904 + if (aBookmarkFind.Len()>0) {
1905 + aBookmarkName=aBookmarkFind;
1910 - rDoc.Insert(*pPaM, SwFmtFld(aFld), 0);
1911 + if (pB!=NULL && aBookmarkName.Len()==0) {
1912 + aBookmarkName=pB->GetUniqueBookmarkName(aFormula.sTitle);
1915 + if (aBookmarkName.Len()>0) {
1916 + SwFieldBookmark *pFieldmark=(SwFieldBookmark*)rDoc.makeNoTextFieldBookmark(*pPaM, aBookmarkName, ::rtl::OUString::createFromAscii(ECMA_FORMDROPDOWN));
1917 + ASSERT(pFieldmark!=NULL, "hmmm; why was the bookmark not created?");
1918 + if (pFieldmark!=NULL) {
1919 + rtl::OUString sListEntry=rtl::OUString::createFromAscii(ECMA_FORMDROPDOWN_LISTENTRY);
1920 + std::vector<String>::iterator it=aFormula.maListEntries.begin();
1921 + for(;it!=aFormula.maListEntries.end();it++) {
1922 + pFieldmark->addParam(sListEntry, *it, false);
1924 + int nIndex = aFormula.fDropdownIndex < aFormula.maListEntries.size() ? aFormula.fDropdownIndex : 0;
1925 + pFieldmark->addParam(ECMA_FORMDROPDOWN_RESULT, nIndex);
1926 + // set field data here...
1930 + return FLD_OK;
1933 - return FLD_OK;
1936 void SwWW8ImplReader::DeleteFormImpl()
1937 @@ -2124,11 +2127,18 @@ bool SwWW8ImplReader::ImportFormulaControl(WW8FormulaControl &aFormula,
1939 if((aPic.lcb > 0x3A) && !pDataStream->GetError() )
1941 - pDataStream->Seek( nPicLocFc + aPic.cbHeader );
1942 +#if 0 // some debug fun; remove this later...
1943 int len=aPic.lcb-aPic.cbHeader;
1944 char *pBuf=(char*)malloc(len);
1945 pDataStream->Read( pBuf, len);
1946 + static int _h=0;
1947 + char fname[255];
1948 + sprintf(fname, "data%03i.data", _h++);
1949 + FILE *out=fopen(fname, "wb");
1950 + fwrite(pBuf, len, 1, out);
1951 + fclose(out);
1952 pDataStream->Seek( nPicLocFc + aPic.cbHeader );
1953 +#endif
1954 aFormula.FormulaRead(nWhich,pDataStream);
1955 bRet = true;
1957 diff --git sw/source/filter/ww8/ww8par5.cxx sw/source/filter/ww8/ww8par5.cxx
1958 index 423e566..d878125 100644
1959 --- sw/source/filter/ww8/ww8par5.cxx
1960 +++ sw/source/filter/ww8/ww8par5.cxx
1961 @@ -96,9 +96,12 @@
1962 #include "ww8par2.hxx"
1963 #include "writerhelper.hxx"
1964 #include "fields.hxx"
1965 +#include <svtools/fltrcfg.hxx>
1967 #include <algorithm> // #i24377#
1969 +//#define WW_NATIVE_TOC 0
1971 #define MAX_FIELDLEN 64000
1973 #define WW8_TOX_LEVEL_DELIM ':'
1974 @@ -329,9 +332,11 @@ long SwWW8ImplReader::Read_Book(WW8PLCFManResult*)
1976 //"_Toc*" and "_Hlt*" are unnecessary
1977 const String* pName = pB->GetName();
1978 +#if !defined(WW_NATIVE_TOC)
1979 if( !pName || pName->EqualsIgnoreCaseAscii( "_Toc", 0, 4 )
1980 || pName->EqualsIgnoreCaseAscii( "_Hlt", 0, 4 ) )
1981 return 0;
1982 +#endif
1984 //JP 16.11.98: ToUpper darf auf keinen Fall gemacht werden, weil der
1985 //Bookmark- name ein Hyperlink-Ziel sein kann!
1986 @@ -673,6 +678,9 @@ sal_uInt16 SwWW8ImplReader::End_Field()
1987 if (!pF || !pF->EndPosIsFieldEnd())
1988 return nRet;
1990 + const SvtFilterOptions* pOpt = SvtFilterOptions::Get();
1991 + sal_Bool bUseEnhFields=(pOpt && pOpt->IsUseEnhancedFields());
1993 ASSERT(!maFieldStack.empty(), "Empty field stack\n");
1994 if (!maFieldStack.empty())
1996 @@ -684,9 +692,38 @@ sal_uInt16 SwWW8ImplReader::End_Field()
1997 nRet = maFieldStack.back().mnFieldId;
1998 switch (nRet)
2000 + case 70:
2001 + if (bUseEnhFields && pPaM!=NULL && pPaM->GetPoint()!=NULL) {
2002 + SwPosition aEndPos = *pPaM->GetPoint();
2003 + SwPaM aFldPam( maFieldStack.back().GetPtNode(), maFieldStack.back().GetPtCntnt(), aEndPos.nNode, aEndPos.nContent.GetIndex());
2004 + SwFieldBookmark *pFieldmark=(SwFieldBookmark*)rDoc.makeFieldBookmark(aFldPam, maFieldStack.back().GetBookmarkName(), ::rtl::OUString::createFromAscii(ECMA_FORMTEXT));
2005 + ASSERT(pFieldmark!=NULL, "hmmm; why was the bookmark not created?");
2006 + if (pFieldmark!=NULL) {
2007 + pFieldmark->addParams(maFieldStack.back().getParams());
2010 + break;
2011 +#if defined(WW_NATIVE_TOC)
2012 + case 8: // TOX_INDEX
2013 + case 13: // TOX_CONTENT
2014 + case 88: // HYPERLINK
2015 + case 37: // REF
2016 + if (pPaM!=NULL && pPaM->GetPoint()!=NULL) {
2018 + SwPosition aEndPos = *pPaM->GetPoint();
2019 + SwPaM aFldPam( maFieldStack.back().GetPtNode(), maFieldStack.back().GetPtCntnt(), aEndPos.nNode, aEndPos.nContent.GetIndex());
2020 + SwFieldBookmark *pFieldmark=(SwFieldBookmark*)rDoc.makeFieldBookmark(aFldPam, maFieldStack.back().GetBookmarkName(), maFieldStack.back().GetBookmarkType());
2021 + ASSERT(pFieldmark!=NULL, "hmmm; why was the bookmark not created?");
2022 + if (pFieldmark!=NULL) {
2023 + pFieldmark->addParams(maFieldStack.back().getParams());
2026 + break;
2027 +#else
2028 case 88:
2029 pCtrlStck->SetAttr(*pPaM->GetPoint(),RES_TXTATR_INETFMT);
2030 break;
2031 +#endif
2032 case 36:
2033 case 68:
2034 //Move outside the section associated with this type of field
2035 @@ -704,6 +741,10 @@ bool AcceptableNestedField(sal_uInt16 nFieldCode)
2037 switch (nFieldCode)
2039 +#if defined(WW_NATIVE_TOC)
2040 + case 8: // allow recursive field in TOC...
2041 + case 13: // allow recursive field in TOC...
2042 +#endif
2043 case 36:
2044 case 68:
2045 case 79:
2046 @@ -742,6 +783,36 @@ FieldEntry &FieldEntry::operator=(const FieldEntry &rOther) throw()
2047 return *this;
2050 +::rtl::OUString FieldEntry::GetBookmarkName()
2052 + return sBookmarkName;
2055 +::rtl::OUString FieldEntry::GetBookmarkType()
2057 + return sBookmarkType;
2060 +void FieldEntry::SetBookmarkName(::rtl::OUString bookmarkName)
2062 + sBookmarkName=bookmarkName;
2065 +void FieldEntry::SetBookmarkType(::rtl::OUString bookmarkType)
2067 + sBookmarkType=bookmarkType;
2070 +void FieldEntry::AddParam(::rtl::OUString name, ::rtl::OUString value)
2072 + maParams.push_back( SwFieldBookmark::ParamPair_t(name, value) );
2075 +FieldEntry::Params_t &FieldEntry::getParams() {
2076 + return maParams;
2080 // Read_Field liest ein Feld ein oder, wenn es nicht gelesen werden kann,
2081 // wird 0 zurueckgegeben, so dass das Feld vom Aufrufer textuell gelesen wird.
2082 // Returnwert: Gesamtlaenge des Feldes ( zum UEberlesen )
2083 @@ -2066,6 +2137,17 @@ eF_ResT SwWW8ImplReader::Read_F_PgRef( WW8FieldDesc*, String& rStr )
2085 String sName(GetMappedBookmark(sOrigName));
2087 +#if defined(WW_NATIVE_TOC)
2088 + if (1) {
2089 + ::rtl::OUString aBookmarkName=::rtl::OUString::createFromAscii("_REF");
2090 + maFieldStack.back().SetBookmarkName(aBookmarkName);
2091 + maFieldStack.back().SetBookmarkType(::rtl::OUString::createFromAscii(ECMA_PAGEREF));
2092 + maFieldStack.back().AddParam(rtl::OUString(), sName);
2093 + return FLD_TEXT;
2095 +#endif
2098 SwGetRefField aFld(
2099 (SwGetRefFieldType*)rDoc.GetSysFldType( RES_GETREFFLD ), sName,
2100 REF_BOOKMARK, 0, REF_PAGE );
2101 @@ -2729,6 +2811,16 @@ bool wwSectionManager::WillHavePageDescHere(SwNodeIndex aIdx) const
2103 eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, String& rStr )
2105 +#if defined(WW_NATIVE_TOC)
2106 + if (1) {
2107 + ::rtl::OUString aBookmarkName=::rtl::OUString::createFromAscii("_TOC");
2108 + maFieldStack.back().SetBookmarkName(aBookmarkName);
2109 + maFieldStack.back().SetBookmarkType(::rtl::OUString::createFromAscii(ECMA_TOC));
2110 +// maFieldStack.back().AddParam(::rtl::OUString::createFromAscii("Description"), aFormula.sToolTip);
2111 + return FLD_TEXT;
2113 +#endif
2115 if (pF->nLRes < 3)
2116 return FLD_TEXT; // ignore (#i25440#)
2118 @@ -3246,6 +3338,16 @@ eF_ResT SwWW8ImplReader::Read_F_Shape(WW8FieldDesc* /*pF*/, String& /*rStr*/)
2120 eF_ResT SwWW8ImplReader::Read_F_Hyperlink( WW8FieldDesc* /*pF*/, String& rStr )
2122 +#if defined(WW_NATIVE_TOC)
2123 + if (1) {
2124 + ::rtl::OUString aBookmarkName=::rtl::OUString::createFromAscii("_HYPERLINK");
2125 + maFieldStack.back().SetBookmarkName(aBookmarkName);
2126 + maFieldStack.back().SetBookmarkType(::rtl::OUString::createFromAscii(ECMA_HYPERLINK));
2127 +// maFieldStack.back().AddParam(::rtl::OUString::createFromAscii("Description"), aFormula.sToolTip);
2128 + return FLD_TEXT;
2130 +#endif
2132 String sURL, sTarget, sMark;
2133 bool bDataImport = false;
2134 //HYPERLINk "filename" [switches]
2135 diff --git sw/source/ui/docvw/edtwin.cxx sw/source/ui/docvw/edtwin.cxx
2136 index f1a5502..2a2b289 100644
2137 --- sw/source/ui/docvw/edtwin.cxx
2138 +++ sw/source/ui/docvw/edtwin.cxx
2139 @@ -152,6 +152,7 @@
2141 #include <bookmrk.hxx>
2142 #include <doc.hxx>
2143 +#include <ecmaflds.hxx>
2145 #include "PostItMgr.hxx"
2146 #include "postit.hxx"
2147 @@ -2238,21 +2239,31 @@ KEYINPUT_CHECKTABLE_INSDEL:
2148 SwFieldBookmark *fieldBM=rSh.IsInFormFieldBookmark(); //$flr refactor!!!
2149 ASSERT(fieldBM!=NULL, "Where is my FieldBookmark??");
2150 if (fieldBM!=NULL) {
2151 - fieldBM->SetChecked(!fieldBM->IsChecked());
2152 - SwDocShell* pDocSh = rView.GetDocShell();
2153 - SwDoc *pDoc=pDocSh->GetDoc();
2154 - ASSERT(fieldBM->GetOtherBookmarkPos()!=NULL, "where is the otherpos?");
2155 - if (fieldBM->GetOtherBookmarkPos()!=NULL) {
2156 - SwPaM aPaM(fieldBM->GetBookmarkPos(), *fieldBM->GetOtherBookmarkPos());
2157 - if (0) {
2158 - rSh.StartAllAction(); //$flr TODO: understand why this not works
2159 - pDoc->SetModified(aPaM);
2160 - rSh.EndAllAction();
2161 - } else {
2162 - rSh.CalcLayout(); // workaround
2163 + if (fieldBM->isType(ECMA_FORMCHECKBOX)) {
2164 + bool isChecked=fieldBM->getParam(ECMA_FORMCHECKBOX_CHECKED).second.compareToAscii("on")==0;
2165 + /* printf("checked-before=%i\n", isChecked); */
2166 + isChecked=!isChecked; // swap it...
2167 + /* printf("checked-after=%i\n", isChecked); */
2168 + fieldBM->addParam(rtl::OUString::createFromAscii(ECMA_FORMCHECKBOX_CHECKED), rtl::OUString::createFromAscii(isChecked?"on":"off"));
2169 + /* printf("checked-after-add=%i\n", fieldBM->getParam(ECMA_FORMCHECKBOX_CHECKED).second.compareToAscii("on")==0); */
2170 + fieldBM->invalidate();
2172 + if (fieldBM->isType(ECMA_FORMDROPDOWN)) {
2173 + int currentIndex=fieldBM->getParam(ECMA_FORMDROPDOWN_RESULT, "0").second.toInt32();
2174 + int entries=0;
2175 + for(int i=0;i<fieldBM->getNumOfParams();i++) {
2176 + SwFieldBookmark::ParamPair_t p=fieldBM->getParam(i);
2177 + if (p.first.compareToAscii(ECMA_FORMDROPDOWN_LISTENTRY)==0)
2178 + entries++;
2180 + currentIndex++;
2181 + if (currentIndex>=entries) {
2182 + currentIndex=0;
2184 + fieldBM->addParam(ECMA_FORMDROPDOWN_RESULT, currentIndex);
2185 + fieldBM->invalidate();
2186 + rSh.InvalidateWindows(rView.GetVisArea());
2190 // rSh.Overwrite(String('X'));
2191 eKeyState = KS_Ende;
2192 @@ -4192,7 +4203,7 @@ void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt)
2194 SwContentAtPos aCntntAtPos( SwContentAtPos::SW_CLICKFIELD |
2195 SwContentAtPos::SW_INETATTR |
2196 - SwContentAtPos::SW_SMARTTAG );
2197 + SwContentAtPos::SW_SMARTTAG | SwContentAtPos::SW_FORMCTRL);
2199 if( rSh.GetContentAtPos( aDocPt, aCntntAtPos, TRUE ) )
2201 @@ -4213,7 +4224,29 @@ void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt)
2202 if ( bExecSmarttags && SwSmartTagMgr::Get().IsSmartTagsEnabled() )
2203 rView.ExecSmartTagPopup( aDocPt );
2205 - else // if ( SwContentAtPos::SW_INETATTR == aCntntAtPos.eCntntAtPos )
2206 + else if ( SwContentAtPos::SW_FORMCTRL == aCntntAtPos.eCntntAtPos )
2208 + ASSERT( aCntntAtPos.aFnd.pFldBookmark!=NULL, "where is my field ptr???");
2209 + if ( aCntntAtPos.aFnd.pFldBookmark!=NULL) {
2210 + SwFieldBookmark *fieldBM=const_cast<SwFieldBookmark *>(aCntntAtPos.aFnd.pFldBookmark);
2211 + SwDocShell* pDocSh = rView.GetDocShell();
2212 + SwDoc *pDoc=pDocSh->GetDoc();
2213 + if (fieldBM->isType(ECMA_FORMCHECKBOX)) {
2214 + bool isChecked=fieldBM->getParam(ECMA_FORMCHECKBOX_CHECKED).second.compareToAscii("on")==0;
2215 + isChecked=!isChecked; // swap it...
2216 + fieldBM->addParam(rtl::OUString::createFromAscii(ECMA_FORMCHECKBOX_CHECKED), rtl::OUString::createFromAscii(isChecked?"on":"off"));
2217 + fieldBM->invalidate();
2218 + rSh.InvalidateWindows(rView.GetVisArea());
2219 + } else if (fieldBM->isType(ECMA_FORMDROPDOWN)) {
2220 + rView.ExecFieldPopup( aDocPt, fieldBM );
2221 + fieldBM->invalidate();
2222 + rSh.InvalidateWindows(rView.GetVisArea());
2223 + } else {
2224 + // unknown type..
2228 + else // if ( SwContentAtPos::SW_INETATTR == aCntntAtPos.eCntntAtPos )
2230 if ( bExecHyperlinks )
2231 rSh.ClickToINetAttr( *(SwFmtINetFmt*)aCntntAtPos.aFnd.pAttr, nFilter );
2232 diff --git sw/source/ui/inc/view.hxx sw/source/ui/inc/view.hxx
2233 index 8a64224..dc4eaef 100644
2234 --- sw/source/ui/inc/view.hxx
2235 +++ sw/source/ui/inc/view.hxx
2236 @@ -94,6 +94,7 @@ struct SwConversionArgs;
2237 class Graphic;
2238 class GraphicFilter;
2239 class SwPostItMgr;
2240 +class SwFieldBookmark;
2242 namespace com{ namespace sun { namespace star {
2243 namespace view{ class XSelectionSupplier; }
2244 @@ -465,7 +466,7 @@ public:
2246 DECL_LINK( SpellError, LanguageType * );
2247 BOOL ExecSpellPopup( const Point& rPt );
2249 + BOOL ExecFieldPopup( const Point& rPt, SwFieldBookmark *fieldBM );
2250 // SMARTTAGS
2251 BOOL ExecSmartTagPopup( const Point& rPt );
2253 diff --git sw/source/ui/inc/wrtsh.hxx sw/source/ui/inc/wrtsh.hxx
2254 index 0115b26..de13eb9 100644
2255 --- sw/source/ui/inc/wrtsh.hxx
2256 +++ sw/source/ui/inc/wrtsh.hxx
2257 @@ -319,6 +319,9 @@ typedef BOOL (SwWrtShell:: *FNSimpleMove)();
2258 void InsertTableOf(const SwTOXBase& rTOX, const SfxItemSet* pSet = 0);
2259 BOOL UpdateTableOf(const SwTOXBase& rTOX, const SfxItemSet* pSet = 0);
2261 + // new fields
2262 + BOOL UpdateField(SwFieldBookmark &fieldBM);
2264 // Numerierung und Bullets
2266 Turns on numbering or bullets.
2267 diff --git sw/source/ui/uiview/viewling.cxx sw/source/ui/uiview/viewling.cxx
2268 index 8c30848..319b1e0 100644
2269 --- sw/source/ui/uiview/viewling.cxx
2270 +++ sw/source/ui/uiview/viewling.cxx
2271 @@ -114,6 +114,8 @@
2272 #include <svx/dialogs.hrc>
2274 #include <unomid.h>
2275 +#include <bookmrk.hxx>
2276 +#include <ecmaflds.hxx>
2278 #include <memory>
2280 @@ -931,3 +933,138 @@ sal_Bool SwView::ExecSmartTagPopup( const Point& rPt )
2281 return bRet;
2286 +class SwFieldPopup : public PopupMenu
2288 +public:
2289 + SwFieldPopup() {
2290 + InsertItem(1, ::rtl::OUString::createFromAscii("Hello"));
2294 +class SwFieldListBox : public ListBox
2296 +public:
2297 + SwFieldListBox(Window* pParent) : ListBox(pParent /*, WB_DROPDOWN*/) {
2300 + void *GetImplWin() {
2301 + return NULL; //FIXME!!!
2302 +// return mpImplWin;
2305 +protected:
2306 + virtual void LoseFocus() {
2307 +// printf("ListBox: lose focus!!\n");
2308 + ListBox::LoseFocus();
2309 + }
2311 + virtual void Select() {
2312 +// printf("SELECT!!! IsTravelSelect=%i\n", IsTravelSelect());
2313 + ListBox::Select();
2317 +class SwFieldDialog : public Dialog
2319 +private:
2320 + SwFieldListBox aListBox;
2321 + Edit aText;
2322 + int selection;
2324 + DECL_LINK( MyListBoxHandler, ListBox * );
2326 +public:
2327 + SwFieldDialog(Window* parent, SwFieldBookmark *fieldBM) : Dialog(parent, WB_BORDER | WB_SYSTEMWINDOW | WB_NOSHADOW ), aListBox(this), aText(this, WB_RIGHT | WB_READONLY), selection(-1) {
2329 + assert(fieldBM!=NULL);
2330 + if (fieldBM!=NULL) {
2331 + int items=fieldBM->getNumOfParams();
2332 + for(int i=0;i<items;i++) {
2333 + SwFieldBookmark::ParamPair_t p=fieldBM->getParam(i);
2334 + if (p.first.compareToAscii(ECMA_FORMDROPDOWN_LISTENTRY)==0) {
2335 + aListBox.InsertEntry(p.second);
2339 + Size lbSize=aListBox.GetOptimalSize(WINDOWSIZE_PREFERRED);
2340 + lbSize.Width()+=50;
2341 + lbSize.Height()+=20;
2342 + aListBox.SetSizePixel(lbSize);
2343 + aListBox.SetSelectHdl( LINK( this, SwFieldDialog, MyListBoxHandler ) );
2344 + aListBox.Show();
2345 + aText.SetText(rtl::OUString::createFromAscii("Cancel"));
2346 + Size tSize=aText.GetOptimalSize(WINDOWSIZE_PREFERRED);
2347 + aText.SetSizePixel(Size(lbSize.Width(), tSize.Height()));
2348 + aText.SetPosPixel(Point(0, lbSize.Height()));
2349 + aText.Show();
2350 + SetSizePixel(Size(lbSize.Width(), lbSize.Height()+tSize.Height()));
2351 +// SetSizePixel(Size(200, 200));
2354 + int getSelection() {
2355 + return selection;
2357 +protected:
2358 + /*
2359 + virtual void LoseFocus() {
2360 + printf("lose focus!!\n");
2361 + Dialog::LoseFocus();
2362 + printf("close:\n");
2363 + EndDialog(8);
2365 + */
2367 + virtual long PreNotify( NotifyEvent& rNEvt ) {
2368 + if (rNEvt.GetType() == EVENT_LOSEFOCUS && aListBox.GetImplWin()==rNEvt.GetWindow()) {
2369 + EndDialog(8);
2370 + return 1;
2372 + if (rNEvt.GetType() == EVENT_KEYINPUT) {
2373 +// printf("PreNotify::KEYINPUT\n");
2375 + return Dialog::PreNotify(rNEvt);
2379 +IMPL_LINK( SwFieldDialog, MyListBoxHandler, ListBox *, pBox )
2381 +// printf("### DROP DOWN SELECT... IsTravelSelect=%i\n", pBox->IsTravelSelect());
2382 + if (pBox->IsTravelSelect()) {
2383 + return 0;
2384 + } else {
2385 + this->selection=pBox->GetSelectEntryPos();
2386 + EndDialog(9); //@TODO have meaningfull returns...
2387 + return 1;
2392 +BOOL SwView::ExecFieldPopup( const Point& rPt, SwFieldBookmark *fieldBM )
2394 + sal_Bool bRet = sal_False;
2395 + const sal_Bool bOldViewLock = pWrtShell->IsViewLocked();
2396 + pWrtShell->LockView( sal_True );
2397 + pWrtShell->Push();
2400 + bRet=sal_True;
2401 + const Point aPixPos = GetEditWin().LogicToPixel( rPt );
2403 + SwFieldDialog aFldDlg(pEditWin, fieldBM);
2404 + aFldDlg.SetPosPixel(pEditWin->OutputToScreenPixel(aPixPos));
2406 + short ret=aFldDlg.Execute();
2407 + int selection=aFldDlg.getSelection();
2408 + if (selection>=0) {
2409 + fieldBM->addParam(ECMA_FORMDROPDOWN_RESULT, selection);
2413 + pWrtShell->Pop( sal_False );
2414 + pWrtShell->LockView( bOldViewLock );
2416 + return bRet;
2419 diff --git sw/source/ui/wrtsh/wrtsh1.cxx sw/source/ui/wrtsh/wrtsh1.cxx
2420 index c49dd4b..efc2e7a 100644
2421 --- sw/source/ui/wrtsh/wrtsh1.cxx
2422 +++ sw/source/ui/wrtsh/wrtsh1.cxx
2423 @@ -1727,6 +1727,12 @@ SwWrtShell::SwWrtShell( SwWrtShell& rSh, Window *_pWin, SwView &rShell )
2425 SetSfxViewShell( (SfxViewShell *)&rShell );
2426 SetFlyMacroLnk( LINK(this, SwWrtShell, ExecFlyMac) );
2428 + // place the cursor on the first field...
2429 + SwBookmark *pBM=NULL;
2430 + if (IsFormProtected() && (pBM=GetNextFieldBookmark())!=NULL) {
2431 + GotoFieldBookmark(pBM);
2436 diff --git sw/source/ui/wrtsh/wrtsh2.cxx sw/source/ui/wrtsh/wrtsh2.cxx
2437 index 8b21ccd..10b7603 100644
2438 --- sw/source/ui/wrtsh/wrtsh2.cxx
2439 +++ sw/source/ui/wrtsh/wrtsh2.cxx
2440 @@ -248,6 +248,13 @@ BOOL SwWrtShell::UpdateTableOf(const SwTOXBase& rTOX, const SfxItemSet* pSet)
2441 return bResult;
2444 +BOOL SwWrtShell::UpdateField(SwFieldBookmark &fieldBM)
2446 + return SwEditShell::UpdateField(fieldBM);
2451 // ein Klick aus das angegebene Feld. Der Cursor steht auf diesem.
2452 // Fuehre die vor definierten Aktionen aus.
2454 diff --git xmloff/source/text/XMLTextMarkImportContext.cxx xmloff/source/text/XMLTextMarkImportContext.cxx
2455 index 2dece10..21bd4cc 100644
2456 --- xmloff/source/text/XMLTextMarkImportContext.cxx
2457 +++ xmloff/source/text/XMLTextMarkImportContext.cxx
2458 @@ -50,6 +50,7 @@
2460 #include <com/sun/star/text/XFormField.hpp>
2462 +#include <../../../sw/inc/ecmaflds.hxx> // HACKYYYYYYYYY
2464 using ::rtl::OUString;
2465 using ::rtl::OUStringBuffer;
2466 @@ -136,6 +137,33 @@ static SvXMLEnumMapEntry __READONLY_DATA lcl_aMarkTypeMap[] =
2467 { XML_TOKEN_INVALID, 0 },
2471 +static const char *lcl_getFormFieldmarkName(rtl::OUString &name)
2473 + static const char sCheckbox[]=ECMA_FORMCHECKBOX;
2474 + static const char sFormDropDown[]=ECMA_FORMDROPDOWN;
2475 + if (name.compareToAscii("msoffice.field.FORMCHECKBOX")==0)
2476 + return sCheckbox;
2477 + else if (name.compareToAscii(ECMA_FORMCHECKBOX)==0)
2478 + return sCheckbox;
2479 + if (name.compareToAscii(ECMA_FORMDROPDOWN)==0)
2480 + return sFormDropDown;
2481 + else
2482 + return NULL;
2485 +static rtl::OUString lcl_getFieldmarkName(rtl::OUString &name)
2487 + static const char sFormtext[]=ECMA_FORMTEXT;
2488 + if (name.compareToAscii("msoffice.field.FORMTEXT")==0)
2489 + return rtl::OUString::createFromAscii(sFormtext);
2490 + else if (name.compareToAscii(ECMA_FORMTEXT)==0)
2491 + return rtl::OUString::createFromAscii(sFormtext);
2492 + else
2493 + return name;
2497 void XMLTextMarkImportContext::StartElement(
2498 const Reference<XAttributeList> & xAttrList)
2500 @@ -187,7 +215,8 @@ void XMLTextMarkImportContext::EndElement()
2501 case TypeFieldmark:
2502 case TypeBookmark:
2504 - bool bImportAsField=((lcl_MarkType)nTmp==TypeFieldmark && sFieldName.compareToAscii("msoffice.field.FORMCHECKBOX")==0); // for now only import FORMCHECKBOX boxes
2505 + const char *formFieldmarkName=lcl_getFormFieldmarkName(sFieldName);
2506 + bool bImportAsField=((lcl_MarkType)nTmp==TypeFieldmark && formFieldmarkName!=NULL); //@TODO handle abbreviation cases..
2507 // export point bookmark
2508 Reference<XInterface> xIfc=CreateAndInsertMark(GetImport(),
2509 (bImportAsField?sAPI_formfieldmark:sAPI_bookmark),
2510 @@ -198,10 +227,8 @@ void XMLTextMarkImportContext::EndElement()
2511 if (xIfc.is() && bImportAsField) {
2512 // setup fieldmark...
2513 Reference< ::com::sun::star::text::XFormField> xFormField(xIfc, UNO_QUERY);
2514 - xFormField->setType(1); // Checkbox...
2515 + xFormField->setFieldType(rtl::OUString::createFromAscii(formFieldmarkName));
2516 if (xFormField.is() && rHelper.hasCurrentFieldCtx()) {
2517 -// xFormField->setDescription(::rtl::OUString::createFromAscii("HELLO CHECKBOX"));
2518 -// xFormField->setRes(1);
2519 rHelper.setCurrentFieldParamsTo(xFormField);
2522 @@ -248,10 +275,6 @@ void XMLTextMarkImportContext::EndElement()
2523 xInsertionCursor, UNO_QUERY);
2525 bool bImportAsField=((lcl_MarkType)nTmp==TypeFieldmarkEnd && rHelper.hasCurrentFieldCtx());
2526 - if (bImportAsField) {
2527 - ::rtl::OUString currentFieldType=rHelper.getCurrentFieldType();
2528 - bImportAsField=currentFieldType.compareToAscii("msoffice.field.FORMTEXT")==0; // for now only import FORMTEXT boxes
2531 // insert reference
2532 Reference<XInterface> xIfc=CreateAndInsertMark(GetImport(),
2533 @@ -264,10 +287,12 @@ void XMLTextMarkImportContext::EndElement()
2534 if (xIfc.is() && bImportAsField) {
2535 // setup fieldmark...
2536 Reference< ::com::sun::star::text::XFormField> xFormField(xIfc, UNO_QUERY);
2537 - xFormField->setType(0); // Text
2538 if (xFormField.is() && rHelper.hasCurrentFieldCtx()) {
2539 - rHelper.setCurrentFieldParamsTo(xFormField);
2540 -// xFormField->setDescription(::rtl::OUString::createFromAscii("HELLO"));
2541 + rtl::OUString givenTypeName=rHelper.getCurrentFieldType();
2542 + rtl::OUString fieldmarkTypeName=lcl_getFieldmarkName(givenTypeName);
2544 + xFormField->setFieldType(fieldmarkTypeName);
2545 + rHelper.setCurrentFieldParamsTo(xFormField);
2548 rHelper.popFieldCtx();
2549 diff --git xmloff/source/text/txtimp.cxx xmloff/source/text/txtimp.cxx
2550 index b7f7b23..2112e57 100644
2551 --- xmloff/source/text/txtimp.cxx
2552 +++ xmloff/source/text/txtimp.cxx
2553 @@ -2272,14 +2272,10 @@ void XMLTextImportHelper::setCurrentFieldParamsTo(::com::sun::star::uno::Referen
2554 if (!aFieldStack.empty() && xFormField.is()) {
2555 field_params_t &params=aFieldStack.top().second;
2556 for (field_params_t::iterator i=params.begin();i!=params.end();i++) {
2557 - rtl::OUString name=i->first;
2558 - rtl::OUString value=i->second;
2559 - if (name.compareToAscii("Description")==0){
2560 - xFormField->setDescription(value);
2561 - } else if (name.compareToAscii("Result")==0){
2562 - xFormField->setRes((sal_Int16)value.toInt32());
2565 + rtl::OString aOString1 = ::rtl::OUStringToOString (i->first, RTL_TEXTENCODING_UTF8);
2566 + rtl::OString aOString2 = ::rtl::OUStringToOString (i->second, RTL_TEXTENCODING_UTF8);
2567 + /* printf("param[\"%s\"]=\"%s\"\n", aOString1.getStr(), aOString2.getStr()); */
2568 + xFormField->addParam(i->first, i->second, false);
2572 diff --git xmloff/source/text/txtparae.cxx xmloff/source/text/txtparae.cxx
2573 index 7e75658..d5454fc 100644
2574 --- xmloff/source/text/txtparae.cxx
2575 +++ xmloff/source/text/txtparae.cxx
2576 @@ -2321,14 +2321,16 @@ void XMLTextParagraphExport::exportTextRangeEnumeration(
2578 Reference< ::com::sun::star::text::XFormField > xFormField(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
2579 if (xFormField.is()) {
2580 - GetExport().AddAttribute(XML_NAMESPACE_FIELD, XML_TYPE, ::rtl::OUString::createFromAscii("msoffice.field.FORMTEXT"));
2581 + GetExport().AddAttribute(XML_NAMESPACE_FIELD, XML_TYPE, xFormField->getFieldType());
2583 GetExport().StartElement(XML_NAMESPACE_FIELD, XML_FIELDMARK_START, sal_False);
2584 if (xFormField.is()) {
2585 - GetExport().AddAttribute(XML_NAMESPACE_FIELD, XML_NAME, ::rtl::OUString::createFromAscii("Description"));
2586 - GetExport().AddAttribute(XML_NAMESPACE_FIELD, XML_VALUE, xFormField->getDescription());
2587 + for(sal_Int16 i=0;i<xFormField->getParamCount();i++) {
2588 + GetExport().AddAttribute(XML_NAMESPACE_FIELD, XML_NAME, xFormField->getParamName(i));
2589 + GetExport().AddAttribute(XML_NAMESPACE_FIELD, XML_VALUE, xFormField->getParamValue(i));
2590 GetExport().StartElement(XML_NAMESPACE_FIELD, XML_PARAM, sal_False);
2591 GetExport().EndElement(XML_NAMESPACE_FIELD, XML_PARAM, sal_False);
2594 GetExport().EndElement(XML_NAMESPACE_FIELD, XML_FIELDMARK_START, sal_False);
2596 @@ -2345,27 +2347,16 @@ void XMLTextParagraphExport::exportTextRangeEnumeration(
2598 Reference< ::com::sun::star::text::XFormField > xFormField(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
2599 if (xFormField.is()) {
2600 - sal_Int16 fftype=xFormField->getType();
2601 - switch (fftype) {
2602 - case 1:
2603 - GetExport().AddAttribute(XML_NAMESPACE_FIELD, XML_TYPE, ::rtl::OUString::createFromAscii("msoffice.field.FORMCHECKBOX"));
2604 - break;
2605 - default:
2606 - DBG_ASSERT(false, "hey ---- add your export stuff here!!");
2607 - break;
2609 + GetExport().AddAttribute(XML_NAMESPACE_FIELD, XML_TYPE, xFormField->getFieldType());
2611 GetExport().StartElement(XML_NAMESPACE_FIELD, XML_FIELDMARK, sal_False);
2612 if (xFormField.is()) {
2613 - GetExport().AddAttribute(XML_NAMESPACE_FIELD, XML_NAME, ::rtl::OUString::createFromAscii("Description"));
2614 - GetExport().AddAttribute(XML_NAMESPACE_FIELD, XML_VALUE, xFormField->getDescription());
2615 - GetExport().StartElement(XML_NAMESPACE_FIELD, XML_PARAM, sal_False);
2616 - GetExport().EndElement(XML_NAMESPACE_FIELD, XML_PARAM, sal_False);
2618 - GetExport().AddAttribute(XML_NAMESPACE_FIELD, XML_NAME, ::rtl::OUString::createFromAscii("Result"));
2619 - GetExport().AddAttribute(XML_NAMESPACE_FIELD, XML_VALUE, ::rtl::OUString::valueOf((sal_Int32 )xFormField->getRes()));
2620 + for(sal_Int16 i=0;i<xFormField->getParamCount();i++) {
2621 + GetExport().AddAttribute(XML_NAMESPACE_FIELD, XML_NAME, xFormField->getParamName(i));
2622 + GetExport().AddAttribute(XML_NAMESPACE_FIELD, XML_VALUE, xFormField->getParamValue(i));
2623 GetExport().StartElement(XML_NAMESPACE_FIELD, XML_PARAM, sal_False);
2624 GetExport().EndElement(XML_NAMESPACE_FIELD, XML_PARAM, sal_False);
2627 GetExport().EndElement(XML_NAMESPACE_FIELD, XML_FIELDMARK, sal_False);