merge the formfield patch from ooo-build
[ooovba.git] / sw / source / filter / html / htmlfld.cxx
blob0017b15db77be9aa36285d642b5e56589b6d91cc
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: htmlfld.cxx,v $
10 * $Revision: 1.17 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
36 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
37 #include <com/sun/star/document/XDocumentProperties.hpp>
39 #include "docsh.hxx"
40 #include <svtools/htmltokn.h>
41 #include <svtools/zformat.hxx>
42 #include <svtools/useroptions.hxx>
43 #include <fmtfld.hxx>
44 #include <ndtxt.hxx>
45 #include <doc.hxx>
46 #include <fldbas.hxx>
47 #include <docufld.hxx>
48 #include <flddat.hxx>
49 #include <htmlfld.hxx>
50 #include <swhtml.hxx>
52 using namespace nsSwDocInfoSubType;
53 using namespace ::com::sun::star;
55 struct HTMLNumFmtTblEntry
57 const sal_Char *pName;
58 NfIndexTableOffset eFmt;
61 static HTMLOptionEnum __FAR_DATA aHTMLFldTypeTable[] =
63 { OOO_STRING_SW_HTML_FT_author, RES_AUTHORFLD },
64 { OOO_STRING_SW_HTML_FT_sender, RES_EXTUSERFLD },
65 { "DATE", RES_DATEFLD },
66 { "TIME", RES_TIMEFLD },
67 { OOO_STRING_SW_HTML_FT_datetime,RES_DATETIMEFLD },
68 { OOO_STRING_SW_HTML_FT_page, RES_PAGENUMBERFLD },
69 { OOO_STRING_SW_HTML_FT_docinfo, RES_DOCINFOFLD },
70 { OOO_STRING_SW_HTML_FT_docstat, RES_DOCSTATFLD },
71 { OOO_STRING_SW_HTML_FT_filename,RES_FILENAMEFLD },
72 { 0, 0 }
75 static HTMLNumFmtTblEntry __FAR_DATA aHTMLDateFldFmtTable[] =
77 { "SSYS", NF_DATE_SYSTEM_SHORT },
78 { "LSYS", NF_DATE_SYSTEM_LONG },
79 { "DMY", NF_DATE_SYS_DDMMYY, },
80 { "DMYY", NF_DATE_SYS_DDMMYYYY, },
81 { "DMMY", NF_DATE_SYS_DMMMYY, },
82 { "DMMYY", NF_DATE_SYS_DMMMYYYY, },
83 { "DMMMY", NF_DATE_DIN_DMMMMYYYY },
84 { "DMMMYY", NF_DATE_DIN_DMMMMYYYY },
85 { "DDMMY", NF_DATE_SYS_NNDMMMYY },
86 { "DDMMMY", NF_DATE_SYS_NNDMMMMYYYY },
87 { "DDMMMYY", NF_DATE_SYS_NNDMMMMYYYY },
88 { "DDDMMMY", NF_DATE_SYS_NNNNDMMMMYYYY },
89 { "DDDMMMYY", NF_DATE_SYS_NNNNDMMMMYYYY },
90 { "MY", NF_DATE_SYS_MMYY },
91 { "MD", NF_DATE_DIN_MMDD },
92 { "YMD", NF_DATE_DIN_YYMMDD },
93 { "YYMD", NF_DATE_DIN_YYYYMMDD },
94 { 0, NF_NUMERIC_START }
97 static HTMLNumFmtTblEntry __FAR_DATA aHTMLTimeFldFmtTable[] =
99 { "SYS", NF_TIME_HHMMSS },
100 { "SSMM24", NF_TIME_HHMM },
101 { "SSMM12", NF_TIME_HHMMAMPM },
102 { 0, NF_NUMERIC_START }
105 static HTMLOptionEnum __FAR_DATA aHTMLPageNumFldFmtTable[] =
107 { OOO_STRING_SW_HTML_FF_uletter, SVX_NUM_CHARS_UPPER_LETTER },
108 { OOO_STRING_SW_HTML_FF_lletter, SVX_NUM_CHARS_LOWER_LETTER },
109 { OOO_STRING_SW_HTML_FF_uroman, SVX_NUM_ROMAN_UPPER },
110 { OOO_STRING_SW_HTML_FF_lroman, SVX_NUM_ROMAN_LOWER },
111 { OOO_STRING_SW_HTML_FF_arabic, SVX_NUM_ARABIC },
112 { OOO_STRING_SW_HTML_FF_none, SVX_NUM_NUMBER_NONE },
113 { OOO_STRING_SW_HTML_FF_char, SVX_NUM_CHAR_SPECIAL },
114 { OOO_STRING_SW_HTML_FF_page, SVX_NUM_PAGEDESC },
115 { OOO_STRING_SW_HTML_FF_ulettern, SVX_NUM_CHARS_UPPER_LETTER_N },
116 { OOO_STRING_SW_HTML_FF_llettern, SVX_NUM_CHARS_LOWER_LETTER_N },
117 { 0, 0 }
121 static HTMLOptionEnum __FAR_DATA aHTMLExtUsrFldSubTable[] =
123 { OOO_STRING_SW_HTML_FS_company, EU_COMPANY },
124 { OOO_STRING_SW_HTML_FS_firstname, EU_FIRSTNAME },
125 { OOO_STRING_SW_HTML_FS_name, EU_NAME },
126 { OOO_STRING_SW_HTML_FS_shortcut, EU_SHORTCUT },
127 { OOO_STRING_SW_HTML_FS_street, EU_STREET },
128 { OOO_STRING_SW_HTML_FS_country, EU_COUNTRY },
129 { OOO_STRING_SW_HTML_FS_zip, EU_ZIP },
130 { OOO_STRING_SW_HTML_FS_city, EU_CITY },
131 { OOO_STRING_SW_HTML_FS_title, EU_TITLE },
132 { OOO_STRING_SW_HTML_FS_position, EU_POSITION },
133 { OOO_STRING_SW_HTML_FS_pphone, EU_PHONE_PRIVATE },
134 { OOO_STRING_SW_HTML_FS_cphone, EU_PHONE_COMPANY },
135 { OOO_STRING_SW_HTML_FS_fax, EU_FAX },
136 { OOO_STRING_SW_HTML_FS_email, EU_EMAIL },
137 { OOO_STRING_SW_HTML_FS_state, EU_STATE },
138 { 0, 0 }
141 static HTMLOptionEnum __FAR_DATA aHTMLAuthorFldFmtTable[] =
143 { OOO_STRING_SW_HTML_FF_name, AF_NAME },
144 { OOO_STRING_SW_HTML_FF_shortcut, AF_SHORTCUT },
145 { 0, 0 }
148 static HTMLOptionEnum __FAR_DATA aHTMLPageNumFldSubTable[] =
150 { OOO_STRING_SW_HTML_FS_random, PG_RANDOM },
151 { OOO_STRING_SW_HTML_FS_next, PG_NEXT },
152 { OOO_STRING_SW_HTML_FS_prev, PG_PREV },
153 { 0, 0 }
156 // UGLY: these are extensions of nsSwDocInfoSubType (in inc/docufld.hxx)
157 // these are necessary for importing document info fields written by
158 // older versions of OOo (< 3.0) which did not have DI_CUSTOM fields
159 const SwDocInfoSubType DI_INFO1 = DI_SUBTYPE_END + 1;
160 const SwDocInfoSubType DI_INFO2 = DI_SUBTYPE_END + 2;
161 const SwDocInfoSubType DI_INFO3 = DI_SUBTYPE_END + 3;
162 const SwDocInfoSubType DI_INFO4 = DI_SUBTYPE_END + 4;
164 static HTMLOptionEnum __FAR_DATA aHTMLDocInfoFldSubTable[] =
166 { OOO_STRING_SW_HTML_FS_title, DI_TITEL },
167 { OOO_STRING_SW_HTML_FS_theme, DI_THEMA },
168 { OOO_STRING_SW_HTML_FS_keys, DI_KEYS },
169 { OOO_STRING_SW_HTML_FS_comment, DI_COMMENT },
170 { "INFO1", DI_INFO1 },
171 { "INFO2", DI_INFO2 },
172 { "INFO3", DI_INFO3 },
173 { "INFO4", DI_INFO4 },
174 { OOO_STRING_SW_HTML_FS_custom, DI_CUSTOM },
175 { OOO_STRING_SW_HTML_FS_create, DI_CREATE },
176 { OOO_STRING_SW_HTML_FS_change, DI_CHANGE },
177 { 0, 0 }
180 static HTMLOptionEnum __FAR_DATA aHTMLDocInfoFldFmtTable[] =
182 { OOO_STRING_SW_HTML_FF_author, DI_SUB_AUTHOR },
183 { OOO_STRING_SW_HTML_FF_time, DI_SUB_TIME },
184 { OOO_STRING_SW_HTML_FF_date, DI_SUB_DATE },
185 { 0, 0 }
188 static HTMLOptionEnum __FAR_DATA aHTMLDocStatFldSubTable[] =
190 { OOO_STRING_SW_HTML_FS_page, DS_PAGE },
191 { OOO_STRING_SW_HTML_FS_para, DS_PARA },
192 { OOO_STRING_SW_HTML_FS_word, DS_WORD },
193 { OOO_STRING_SW_HTML_FS_char, DS_CHAR },
194 { OOO_STRING_SW_HTML_FS_tbl, DS_TBL },
195 { OOO_STRING_SW_HTML_FS_grf, DS_GRF },
196 { OOO_STRING_SW_HTML_FS_ole, DS_OLE },
197 { 0, 0 }
200 static HTMLOptionEnum __FAR_DATA aHTMLFileNameFldFmtTable[] =
202 { OOO_STRING_SW_HTML_FF_name, FF_NAME },
203 { OOO_STRING_SW_HTML_FF_pathname, FF_PATHNAME },
204 { OOO_STRING_SW_HTML_FF_path, FF_PATH },
205 { OOO_STRING_SW_HTML_FF_name_noext, FF_NAME_NOEXT },
206 { 0, 0 }
209 /* \f */
211 USHORT SwHTMLParser::GetNumType( const String& rStr, USHORT nDfltType )
213 USHORT nType = nDfltType;
214 const HTMLOptionEnum *pOptEnums = aHTMLPageNumFldFmtTable;
215 while( pOptEnums->pName )
216 if( !rStr.EqualsIgnoreCaseAscii( pOptEnums->pName ) )
217 pOptEnums++;
218 else
219 break;
221 if( pOptEnums->pName )
222 nType = pOptEnums->nValue;
224 return nType;
228 void SwHTMLParser::NewField()
230 BOOL bKnownType = FALSE, bFixed = FALSE,
231 bHasNumFmt = FALSE, bHasNumValue = FALSE;
232 USHORT nType = 0;
233 String aValue, aNumFmt, aNumValue, aName;
234 const HTMLOption *pSubOption=0, *pFmtOption=0;
236 const HTMLOptions *pHTMLOptions = GetOptions();
237 USHORT i;
239 for( i = pHTMLOptions->Count(); i; )
241 const HTMLOption *pOption = (*pHTMLOptions)[--i];
242 switch( pOption->GetToken() )
244 case HTML_O_TYPE:
245 bKnownType = pOption->GetEnum( nType, aHTMLFldTypeTable );
246 break;
247 case HTML_O_SUBTYPE:
248 pSubOption = pOption;
249 break;
250 case HTML_O_FORMAT:
251 pFmtOption = pOption;
252 break;
253 case HTML_O_NAME:
254 aName = pOption->GetString();
255 break;
256 case HTML_O_VALUE:
257 aValue = pOption->GetString();
258 break;
259 case HTML_O_SDNUM:
260 aNumFmt = pOption->GetString();
261 bHasNumFmt = TRUE;
262 break;
263 case HTML_O_SDVAL:
264 aNumValue = pOption->GetString();
265 bHasNumValue = TRUE;
266 break;
267 case HTML_O_SDFIXED:
268 bFixed = TRUE;
269 break;
273 if( !bKnownType )
274 return;
276 // Autor und Absender werden nur als als variables Feld eingefuegt,
277 // wenn man das Dok selbst als letztes geaendert hat oder es noch
278 // niemend geandert hat und man das Dok erstellt hat. Sonst
279 // wird ein Fixed-Feld daraus gemacht.
280 if( !bFixed &&
281 (RES_EXTUSERFLD == (RES_FIELDS)nType ||
282 RES_AUTHORFLD == (RES_FIELDS)nType) )
284 SvtUserOptions aOpt;
285 const String& rUser = aOpt.GetFullName();
286 SwDocShell *pDocShell(pDoc->GetDocShell());
287 DBG_ASSERT(pDocShell, "no SwDocShell");
288 if (pDocShell) {
289 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
290 pDocShell->GetModel(), uno::UNO_QUERY_THROW);
291 uno::Reference<document::XDocumentProperties> xDocProps(
292 xDPS->getDocumentProperties());
293 DBG_ASSERT(xDocProps.is(), "Doc has no DocumentProperties");
294 const String& rChanged = xDocProps->getModifiedBy();
295 const String& rCreated = xDocProps->getAuthor();
296 if( !rUser.Len() ||
297 (rChanged.Len() ? rUser != rChanged : rUser != rCreated) )
298 bFixed = TRUE;
302 USHORT nWhich = nType;
303 if( RES_DATEFLD==nType || RES_TIMEFLD==nType )
304 nWhich = RES_DATETIMEFLD;
306 SwFieldType* pType = pDoc->GetSysFldType( nWhich );
307 SwField *pFld = 0;
308 BOOL bInsOnEndTag = FALSE;
310 switch( (RES_FIELDS)nType )
312 case RES_EXTUSERFLD:
313 if( pSubOption )
315 USHORT nSub;
316 ULONG nFmt = 0;
317 if( bFixed )
319 nFmt |= AF_FIXED;
320 bInsOnEndTag = TRUE;
322 if( pSubOption->GetEnum( nSub, aHTMLExtUsrFldSubTable ) )
323 pFld = new SwExtUserField( (SwExtUserFieldType*)pType,
324 nSub, nFmt );
326 break;
328 case RES_AUTHORFLD:
330 USHORT nFmt = AF_NAME;
331 if( pFmtOption )
332 pFmtOption->GetEnum( nFmt, aHTMLAuthorFldFmtTable );
333 if( bFixed )
335 nFmt |= AF_FIXED;
336 bInsOnEndTag = TRUE;
339 pFld = new SwAuthorField( (SwAuthorFieldType *)pType, nFmt );
341 break;
343 case RES_DATEFLD:
344 case RES_TIMEFLD:
346 ULONG nNumFmt = 0;
347 ULONG nTime = Time().GetTime(), nDate = Date().GetDate();
348 USHORT nSub = 0;
349 BOOL bValidFmt = FALSE;
350 HTMLNumFmtTblEntry * pFmtTbl;
352 if( RES_DATEFLD==nType )
354 nSub = DATEFLD;
355 pFmtTbl = aHTMLDateFldFmtTable;
356 if( aValue.Len() )
357 nDate = (ULONG)aValue.ToInt32();
359 else
361 nSub = TIMEFLD;
362 pFmtTbl = aHTMLTimeFldFmtTable;
363 if( aValue.Len() )
364 nTime = (ULONG)aValue.ToInt32();
366 if( aValue.Len() )
367 nSub |= FIXEDFLD;
369 SvNumberFormatter *pFormatter = pDoc->GetNumberFormatter();
370 if( pFmtOption )
372 const String& rFmt = pFmtOption->GetString();
373 for( USHORT k = 0; pFmtTbl[k].pName; k++ )
375 if( rFmt.EqualsIgnoreCaseAscii( pFmtTbl[k].pName ) )
377 nNumFmt = pFormatter->GetFormatIndex(
378 pFmtTbl[k].eFmt, LANGUAGE_SYSTEM);
379 bValidFmt = TRUE;
380 break;
384 if( !bValidFmt )
385 nNumFmt = pFormatter->GetFormatIndex( pFmtTbl[i].eFmt,
386 LANGUAGE_SYSTEM);
388 pFld = new SwDateTimeField( (SwDateTimeFieldType *)pType,
389 nSub, nNumFmt );
391 if (nSub & FIXEDFLD)
392 ((SwDateTimeField *)pFld)->SetDateTime( DateTime(Date(nDate), Time(nTime)) );
394 break;
396 case RES_DATETIMEFLD:
397 if( bHasNumFmt )
399 USHORT nSub = 0;
401 SvNumberFormatter *pFormatter = pDoc->GetNumberFormatter();
402 sal_uInt32 nNumFmt;
403 LanguageType eLang;
404 double dValue = GetTableDataOptionsValNum(
405 nNumFmt, eLang, aNumValue, aNumFmt,
406 *pDoc->GetNumberFormatter() );
407 short nFmtType = pFormatter->GetType( nNumFmt );
408 switch( nFmtType )
410 case NUMBERFORMAT_DATE: nSub = DATEFLD; break;
411 case NUMBERFORMAT_TIME: nSub = TIMEFLD; break;
414 if( nSub )
416 if( bHasNumValue )
417 nSub |= FIXEDFLD;
419 pFld = new SwDateTimeField( (SwDateTimeFieldType *)pType,
420 nSub, nNumFmt );
421 if( bHasNumValue )
422 ((SwDateTimeField *)pFld)->SetValue( dValue );
425 break;
427 case RES_PAGENUMBERFLD:
428 if( pSubOption )
430 USHORT nSub;
431 if( pSubOption->GetEnum( nSub, aHTMLPageNumFldSubTable ) )
433 USHORT nFmt = SVX_NUM_PAGEDESC;
434 if( pFmtOption )
435 pFmtOption->GetEnum( nFmt, aHTMLPageNumFldFmtTable );
437 short nOff = 0;
439 if( (SvxExtNumType)nFmt!=SVX_NUM_CHAR_SPECIAL && aValue.Len() )
440 nOff = (short)aValue.ToInt32();
441 else if( (SwPageNumSubType)nSub == PG_NEXT )
442 nOff = 1;
443 else if( (SwPageNumSubType)nSub == PG_PREV )
444 nOff = -1;
446 if( (SvxExtNumType)nFmt==SVX_NUM_CHAR_SPECIAL &&
447 (SwPageNumSubType)nSub==PG_RANDOM )
448 nFmt = SVX_NUM_PAGEDESC;
450 pFld = new SwPageNumberField( (SwPageNumberFieldType *)pType, nSub, nFmt, nOff );
451 if( (SvxExtNumType)nFmt==SVX_NUM_CHAR_SPECIAL )
452 ((SwPageNumberField *)pFld)->SetUserString( aValue );
455 break;
457 case RES_DOCINFOFLD:
458 if( pSubOption )
460 USHORT nSub;
461 if( pSubOption->GetEnum( nSub, aHTMLDocInfoFldSubTable ) )
463 USHORT nExtSub = 0;
464 if( DI_CREATE==(SwDocInfoSubType)nSub ||
465 DI_CHANGE==(SwDocInfoSubType)nSub )
467 nExtSub = DI_SUB_AUTHOR;
468 if( pFmtOption )
469 pFmtOption->GetEnum( nExtSub, aHTMLDocInfoFldFmtTable );
470 nSub |= nExtSub;
473 sal_uInt32 nNumFmt = 0;
474 double dValue = 0;
475 if( bHasNumFmt && (DI_SUB_DATE==nExtSub || DI_SUB_TIME==nExtSub) )
477 LanguageType eLang;
478 dValue = GetTableDataOptionsValNum(
479 nNumFmt, eLang, aNumValue, aNumFmt,
480 *pDoc->GetNumberFormatter() );
481 bFixed &= bHasNumValue;
483 else
484 bHasNumValue = FALSE;
486 if( nSub >= DI_INFO1 && nSub <= DI_INFO4 && aName.Len() == 0 )
488 // backward compatibility for OOo 2:
489 // map to names stored in AddMetaUserDefined
490 aName = m_InfoNames[nSub - DI_INFO1];
491 nSub = DI_CUSTOM;
494 if( bFixed )
496 nSub |= DI_SUB_FIXED;
497 bInsOnEndTag = TRUE;
500 pFld = new SwDocInfoField( (SwDocInfoFieldType *)pType,
501 nSub, aName, nNumFmt );
502 if( bHasNumValue )
503 ((SwDocInfoField*)pFld)->SetValue( dValue );
506 break;
508 case RES_DOCSTATFLD:
509 if( pSubOption )
511 USHORT nSub;
512 if( pSubOption->GetEnum( nSub, aHTMLDocStatFldSubTable ) )
514 USHORT nFmt = SVX_NUM_ARABIC;
515 if( pFmtOption )
516 pFmtOption->GetEnum( nFmt, aHTMLPageNumFldFmtTable );
517 pFld = new SwDocStatField( (SwDocStatFieldType *)pType,
518 nSub, nFmt );
519 bUpdateDocStat |= (DS_PAGE != nFmt);
522 break;
524 case RES_FILENAMEFLD:
526 USHORT nFmt = FF_NAME;
527 if( pFmtOption )
528 pFmtOption->GetEnum( nFmt, aHTMLFileNameFldFmtTable );
529 if( bFixed )
531 nFmt |= FF_FIXED;
532 bInsOnEndTag = TRUE;
535 pFld = new SwFileNameField( (SwFileNameFieldType *)pType, nFmt );
537 break;
538 default:
542 if( pFld )
544 if( bInsOnEndTag )
546 pField = pFld;
548 else
550 pDoc->InsertPoolItem( *pPam, SwFmtFld(*pFld), 0 );
551 delete pFld;
553 bInField = TRUE;
557 void SwHTMLParser::EndField()
559 if( pField )
561 switch( pField->Which() )
563 case RES_DOCINFOFLD:
564 ASSERT( ((SwDocInfoField*)pField)->IsFixed(),
565 "DokInfo-Feld haette nicht gemerkt werden muessen" );
566 ((SwDocInfoField*)pField)->SetExpansion( aContents );
567 break;
569 case RES_EXTUSERFLD:
570 ASSERT( ((SwExtUserField*)pField)->IsFixed(),
571 "ExtUser-Feld haette nicht gemerkt werden muessen" );
572 ((SwExtUserField*)pField)->SetExpansion( aContents );
573 break;
575 case RES_AUTHORFLD:
576 ASSERT( ((SwAuthorField*)pField)->IsFixed(),
577 "Author-Feld haette nicht gemerkt werden muessen" );
578 ((SwAuthorField*)pField)->SetExpansion( aContents );
579 break;
581 case RES_FILENAMEFLD:
582 ASSERT( ((SwFileNameField*)pField)->IsFixed(),
583 "FileName-Feld haette nicht gemerkt werden muessen" );
584 ((SwFileNameField*)pField)->SetExpansion( aContents );
585 break;
588 pDoc->InsertPoolItem( *pPam, SwFmtFld(*pField), 0 );
589 delete pField;
590 pField = 0;
593 bInField = FALSE;
594 aContents.Erase();
597 void SwHTMLParser::InsertFieldText()
599 if( pField )
601 // das aktuelle Textstueck an den Text anhaengen
602 aContents += aToken;
606 void SwHTMLParser::InsertCommentText( const sal_Char *pTag )
608 BOOL bEmpty = aContents.Len() == 0;
609 if( !bEmpty )
610 aContents += '\n';
612 aContents += aToken;
613 if( bEmpty && pTag )
615 String aTmp( aContents );
616 aContents.AssignAscii( "HTML: <" );
617 aContents.AppendAscii( pTag );
618 aContents.Append( '>' );
619 aContents.Append( aTmp );
623 void SwHTMLParser::InsertComment( const String& rComment, const sal_Char *pTag )
625 String aComment( rComment );
626 if( pTag )
628 aComment.AppendAscii( "</" );
629 aComment.AppendAscii( pTag );
630 aComment.Append( '>' );
633 // MIB 24.06.97: Wenn ein PostIt nach einen Space eingefuegt
634 // werden soll, fuegen wir es vor dem Space ein. Dann gibt es
635 // weniger Probleme beim Formatieren (bug #40483#)
636 xub_StrLen nPos = pPam->GetPoint()->nContent.GetIndex();
637 SwTxtNode *pTxtNd = pPam->GetNode()->GetTxtNode();
638 BOOL bMoveFwd = FALSE;
639 if( nPos>0 && pTxtNd && ' '==pTxtNd->GetTxt().GetChar(nPos-1) )
641 bMoveFwd = TRUE;
643 ULONG nNodeIdx = pPam->GetPoint()->nNode.GetIndex();
644 xub_StrLen nIdx = pPam->GetPoint()->nContent.GetIndex();
645 for( USHORT i = aSetAttrTab.Count(); i > 0; )
647 _HTMLAttr *pAttr = aSetAttrTab[--i];
648 if( pAttr->GetSttParaIdx() != nNodeIdx ||
649 pAttr->GetSttCnt() != nIdx )
650 break;
652 if( RES_TXTATR_FIELD == pAttr->pItem->Which() &&
653 RES_SCRIPTFLD == ((const SwFmtFld *)pAttr->pItem)->GetFld()
654 ->GetTyp()->Which() )
656 bMoveFwd = FALSE;
657 break;
661 if( bMoveFwd )
662 pPam->Move( fnMoveBackward );
665 SwPostItField aPostItFld(
666 (SwPostItFieldType*)pDoc->GetSysFldType( RES_POSTITFLD ),
667 aEmptyStr, aComment, DateTime() );
668 InsertAttr( SwFmtFld( aPostItFld ) );
670 if( bMoveFwd )
671 pPam->Move( fnMoveForward );