update dev300-m58
[ooovba.git] / svx / source / editeng / eertfpar.cxx
blob65c1b6c51606dfb072f6ad939409e9a3d934cf0d
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: eertfpar.cxx,v $
10 * $Revision: 1.16 $
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_svx.hxx"
34 #include <eeng_pch.hxx>
36 #include <eertfpar.hxx>
37 #include <impedit.hxx>
38 #include <svtools/intitem.hxx>
39 #include <svx/escpitem.hxx>
40 #include <svx/fhgtitem.hxx>
41 #include "fontitem.hxx"
42 #include <svx/flditem.hxx>
44 #include <svtools/rtftoken.h>
46 // alle Werte auf default; wird nach einlesen der Bitmap aufgerufen !
47 void SvxRTFPictureType::ResetValues()
48 { // setze alle Werte RTF-Defaults
49 eStyle = RTF_BITMAP;
50 nMode = HEX_MODE;
51 nType = nGoalWidth = nGoalHeight = 0;
52 nWidth = nHeight = nWidthBytes = 0;
53 uPicLen = 0;
54 nBitsPerPixel = nPlanes = 1;
55 nScalX = nScalY = 100; // Skalierung in Prozent
56 nCropT = nCropB = nCropL = nCropR = 0;
59 ImportInfo::ImportInfo( ImportState eSt, SvParser* pPrsrs, const ESelection& rSel )
60 : aSelection( rSel )
62 pParser = pPrsrs,
63 eState = eSt;
65 nToken = 0;
66 nTokenValue = 0;
67 pAttrs = NULL;
70 ImportInfo::~ImportInfo()
74 EditRTFParser::EditRTFParser( SvStream& rIn, EditSelection aSel, SfxItemPool& rAttrPool, ImpEditEngine* pImpEE )
75 : SvxRTFParser( rAttrPool, rIn, 0 ), aRTFMapMode( MAP_TWIP )
78 pImpEditEngine = pImpEE;
79 aCurSel = aSel;
80 eDestCharSet = RTL_TEXTENCODING_DONTKNOW;
81 nDefFont = 0;
82 nDefTab = 0;
83 nLastAction = 0;
84 nDefFontHeight = 0;
86 SetInsPos( EditPosition( pImpEditEngine, &aCurSel ) );
88 // Umwandeln der Twips-Werte...
89 SetCalcValue( TRUE );
90 SetChkStyleAttr( pImpEE->GetStatus().DoImportRTFStyleSheets() );
91 SetNewDoc( FALSE ); // damit die Pool-Defaults nicht
92 // ueberschrieben werden...
93 aEditMapMode = MapMode( pImpEE->GetRefDevice()->GetMapMode().GetMapUnit() );
96 EditRTFParser::~EditRTFParser()
100 SvParserState __EXPORT EditRTFParser::CallParser()
102 DBG_ASSERT( !aCurSel.HasRange(), "Selection bei CallParser!" );
103 // Den Teil, in den importiert wird, vom Rest abtrennen.
104 // Diese Mimik sollte fuer alle Imports verwendet werden.
105 // aStart1PaM: Letzte Position vor dem importierten Inhalt
106 // aEnd1PaM: Erste Position nach dem importierten Inhalt
107 // aStart2PaM: Erste Position des importierten Inhaltes
108 // aEnd2PaM: Letzte Position des importierten Inhaltes
109 EditPaM aStart1PaM( aCurSel.Min().GetNode(), aCurSel.Min().GetIndex() );
110 aCurSel = pImpEditEngine->ImpInsertParaBreak( aCurSel );
111 EditPaM aStart2PaM = aCurSel.Min();
112 // Sinnvoll oder nicht?:
113 aStart2PaM.GetNode()->GetContentAttribs().GetItems().ClearItem();
114 AddRTFDefaultValues( aStart2PaM, aStart2PaM );
115 EditPaM aEnd1PaM( pImpEditEngine->ImpInsertParaBreak( aCurSel.Max() ) );
116 // aCurCel zeigt jetzt auf den Zwischenraum
118 if ( pImpEditEngine->aImportHdl.IsSet() )
120 ImportInfo aImportInfo( RTFIMP_START, this, pImpEditEngine->CreateESel( aCurSel ) );
121 pImpEditEngine->aImportHdl.Call( &aImportInfo );
124 SvParserState _eState = SvxRTFParser::CallParser();
126 if ( pImpEditEngine->aImportHdl.IsSet() )
128 ImportInfo aImportInfo( RTFIMP_END, this, pImpEditEngine->CreateESel( aCurSel ) );
129 pImpEditEngine->aImportHdl.Call( &aImportInfo );
132 if ( nLastAction == ACTION_INSERTPARABRK )
134 ContentNode* pCurNode = aCurSel.Max().GetNode();
135 USHORT nPara = pImpEditEngine->GetEditDoc().GetPos( pCurNode );
136 ContentNode* pPrevNode = pImpEditEngine->GetEditDoc().SaveGetObject( nPara-1 );
137 DBG_ASSERT( pPrevNode, "Ungueltiges RTF-Dokument ?!" );
138 EditSelection aSel;
139 aSel.Min() = EditPaM( pPrevNode, pPrevNode->Len() );
140 aSel.Max() = EditPaM( pCurNode, 0 );
141 aCurSel.Max() = pImpEditEngine->ImpDeleteSelection( aSel );
143 EditPaM aEnd2PaM( aCurSel.Max() );
144 //AddRTFDefaultValues( aStart2PaM, aEnd2PaM );
145 BOOL bOnlyOnePara = ( aEnd2PaM.GetNode() == aStart2PaM.GetNode() );
146 // Den Brocken wieder einfuegen...
147 // Problem: Absatzattribute duerfen ggf. nicht uebernommen werden
148 // => Zeichenattribute machen.
150 BOOL bSpecialBackward = aStart1PaM.GetNode()->Len() ? FALSE : TRUE;
151 if ( bOnlyOnePara || aStart1PaM.GetNode()->Len() )
152 pImpEditEngine->ParaAttribsToCharAttribs( aStart2PaM.GetNode() );
153 aCurSel.Min() = pImpEditEngine->ImpConnectParagraphs(
154 aStart1PaM.GetNode(), aStart2PaM.GetNode(), bSpecialBackward );
155 bSpecialBackward = aEnd1PaM.GetNode()->Len() ? TRUE : FALSE;
156 // wenn bOnlyOnePara, dann ist der Node beim Connect verschwunden.
157 if ( !bOnlyOnePara && aEnd1PaM.GetNode()->Len() )
158 pImpEditEngine->ParaAttribsToCharAttribs( aEnd2PaM.GetNode() );
159 aCurSel.Max() = pImpEditEngine->ImpConnectParagraphs(
160 ( bOnlyOnePara ? aStart1PaM.GetNode() : aEnd2PaM.GetNode() ),
161 aEnd1PaM.GetNode(), bSpecialBackward );
163 return _eState;
166 void EditRTFParser::AddRTFDefaultValues( const EditPaM& rStart, const EditPaM& rEnd )
168 // Problem: DefFont und DefFontHeight
169 Size aSz( 12, 0 );
170 MapMode aPntMode( MAP_POINT );
171 MapMode _aEditMapMode( pImpEditEngine->GetRefDevice()->GetMapMode().GetMapUnit() );
172 aSz = pImpEditEngine->GetRefDevice()->LogicToLogic( aSz, &aPntMode, &_aEditMapMode );
173 SvxFontHeightItem aFontHeightItem( aSz.Width(), 100, EE_CHAR_FONTHEIGHT );
174 Font aDefFont( GetDefFont() );
175 SvxFontItem aFontItem( aDefFont.GetFamily(), aDefFont.GetName(),
176 aDefFont.GetStyleName(), aDefFont.GetPitch(), aDefFont.GetCharSet(), EE_CHAR_FONTINFO );
178 USHORT nStartPara = pImpEditEngine->GetEditDoc().GetPos( rStart.GetNode() );
179 USHORT nEndPara = pImpEditEngine->GetEditDoc().GetPos( rEnd.GetNode() );
180 for ( USHORT nPara = nStartPara; nPara <= nEndPara; nPara++ )
182 ContentNode* pNode = pImpEditEngine->GetEditDoc().SaveGetObject( nPara );
183 DBG_ASSERT( pNode, "AddRTFDefaultValues - Kein Absatz ?!" );
184 if ( !pNode->GetContentAttribs().HasItem( EE_CHAR_FONTINFO ) )
185 pNode->GetContentAttribs().GetItems().Put( aFontItem );
186 if ( !pNode->GetContentAttribs().HasItem( EE_CHAR_FONTHEIGHT ) )
187 pNode->GetContentAttribs().GetItems().Put( aFontHeightItem );
191 void __EXPORT EditRTFParser::NextToken( int nToken )
193 switch( nToken )
195 case RTF_DEFF:
197 nDefFont = USHORT(nTokenValue);
199 break;
200 case RTF_DEFTAB:
202 nDefTab = USHORT(nTokenValue);
204 break;
205 case RTF_CELL:
207 aCurSel = pImpEditEngine->ImpInsertParaBreak( aCurSel );
209 break;
210 case RTF_LINE:
212 aCurSel = pImpEditEngine->InsertLineBreak( aCurSel );
214 break;
215 case RTF_FIELD:
217 ReadField();
219 break;
220 case RTF_PGDSCTBL: // #i29453# ignore \*\pgdsctbl destination
221 case RTF_LISTTEXT:
223 SkipGroup();
225 break;
226 default:
228 SvxRTFParser::NextToken( nToken );
229 if ( nToken == RTF_STYLESHEET )
230 CreateStyleSheets();
232 break;
234 if ( pImpEditEngine->aImportHdl.IsSet() )
236 ImportInfo aImportInfo( RTFIMP_NEXTTOKEN, this, pImpEditEngine->CreateESel( aCurSel ) );
237 aImportInfo.nToken = nToken;
238 aImportInfo.nTokenValue = short(nTokenValue);
239 pImpEditEngine->aImportHdl.Call( &aImportInfo );
243 void __EXPORT EditRTFParser::UnknownAttrToken( int nToken, SfxItemSet* )
245 // fuer Tokens, die im ReadAttr nicht ausgewertet werden
246 // Eigentlich nur fuer Calc (RTFTokenHdl), damit RTF_INTBL
247 if ( pImpEditEngine->aImportHdl.IsSet() )
249 ImportInfo aImportInfo( RTFIMP_UNKNOWNATTR, this, pImpEditEngine->CreateESel( aCurSel ) );
250 aImportInfo.nToken = nToken;
251 aImportInfo.nTokenValue = short(nTokenValue);
252 pImpEditEngine->aImportHdl.Call( &aImportInfo );
256 void __EXPORT EditRTFParser::InsertText()
258 String aText( aToken );
259 if ( pImpEditEngine->aImportHdl.IsSet() )
261 ImportInfo aImportInfo( RTFIMP_INSERTTEXT, this, pImpEditEngine->CreateESel( aCurSel ) );
262 aImportInfo.aText = aText;
263 pImpEditEngine->aImportHdl.Call( &aImportInfo );
265 aCurSel = pImpEditEngine->ImpInsertText( aCurSel, aText );
266 nLastAction = ACTION_INSERTTEXT;
269 void __EXPORT EditRTFParser::InsertPara()
271 if ( pImpEditEngine->aImportHdl.IsSet() )
273 ImportInfo aImportInfo( RTFIMP_INSERTPARA, this, pImpEditEngine->CreateESel( aCurSel ) );
274 pImpEditEngine->aImportHdl.Call( &aImportInfo );
276 aCurSel = pImpEditEngine->ImpInsertParaBreak( aCurSel );
277 nLastAction = ACTION_INSERTPARABRK;
280 void __EXPORT EditRTFParser::MovePos( int bForward )
282 if( bForward )
283 aCurSel = pImpEditEngine->CursorRight( aCurSel.Max(), ::com::sun::star::i18n::CharacterIteratorMode::SKIPCHARACTER );
284 else
285 aCurSel = pImpEditEngine->CursorLeft( aCurSel.Max(), ::com::sun::star::i18n::CharacterIteratorMode::SKIPCHARACTER );
288 void __EXPORT EditRTFParser::SetEndPrevPara( SvxNodeIdx*& rpNodePos,
289 USHORT& rCntPos )
291 // Gewollt ist: von der aktuellen Einfuegeposition den vorherigen
292 // Absatz bestimmen und von dem das Ende setzen.
293 // Dadurch wird "\pard" immer auf den richtigen Absatz
294 // angewendet.
296 ContentNode* pN = aCurSel.Max().GetNode();
297 USHORT nCurPara = pImpEditEngine->GetEditDoc().GetPos( pN );
298 DBG_ASSERT( nCurPara != 0, "Absatz gleich 0: SetEnfPrevPara" );
299 if ( nCurPara )
300 nCurPara--;
301 ContentNode* pPrevNode = pImpEditEngine->GetEditDoc().SaveGetObject( nCurPara );
302 DBG_ASSERT( pPrevNode, "pPrevNode = 0!" );
303 rpNodePos = new EditNodeIdx( pImpEditEngine, pPrevNode );
304 rCntPos = pPrevNode->Len();
307 int __EXPORT EditRTFParser::IsEndPara( SvxNodeIdx* pNd, USHORT nCnt ) const
309 return ( nCnt == ( ((EditNodeIdx*)pNd)->GetNode()->Len()) );
312 void __EXPORT EditRTFParser::SetAttrInDoc( SvxRTFItemStackType &rSet )
314 ContentNode* pSttNode = ((EditNodeIdx&)rSet.GetSttNode()).GetNode();
315 ContentNode* pEndNode = ((EditNodeIdx&)rSet.GetEndNode()).GetNode();
317 EditPaM aStartPaM( pSttNode, rSet.GetSttCnt() );
318 EditPaM aEndPaM( pEndNode, rSet.GetEndCnt() );
320 // ggf. noch das Escapemant-Item umbiegen:
321 const SfxPoolItem* pItem;
323 // #i66167# adapt font heights to destination MapUnit if necessary
324 const MapUnit eDestUnit = ( MapUnit )( pImpEditEngine->GetEditDoc().GetItemPool().GetMetric(0) );
325 const MapUnit eSrcUnit = aRTFMapMode.GetMapUnit();
326 if (eDestUnit != eSrcUnit)
328 USHORT aFntHeightIems[3] = { EE_CHAR_FONTHEIGHT, EE_CHAR_FONTHEIGHT_CJK, EE_CHAR_FONTHEIGHT_CTL };
329 for (int i = 0; i < 2; ++i)
331 if (SFX_ITEM_SET == rSet.GetAttrSet().GetItemState( aFntHeightIems[i], FALSE, &pItem ))
333 UINT32 nHeight = ((SvxFontHeightItem*)pItem)->GetHeight();
334 long nNewHeight;
335 nNewHeight = pImpEditEngine->GetRefDevice()->LogicToLogic( (long)nHeight, eSrcUnit, eDestUnit );
337 SvxFontHeightItem aFntHeightItem( nNewHeight, ((SvxFontHeightItem*)pItem)->GetProp(), aFntHeightIems[i] );
338 rSet.GetAttrSet().Put( aFntHeightItem );
343 if( SFX_ITEM_SET == rSet.GetAttrSet().GetItemState( EE_CHAR_ESCAPEMENT, FALSE, &pItem ))
345 // die richtige
346 long nEsc = ((SvxEscapementItem*)pItem)->GetEsc();
348 if( ( DFLT_ESC_AUTO_SUPER != nEsc ) && ( DFLT_ESC_AUTO_SUB != nEsc ) )
350 nEsc *= 10; //HalPoints => Twips wurde in RTFITEM.CXX unterschlagen!
351 SvxFont aFont;
352 pImpEditEngine->SeekCursor( aStartPaM.GetNode(), aStartPaM.GetIndex()+1, aFont );
353 nEsc = nEsc * 100 / aFont.GetSize().Height();
355 SvxEscapementItem aEscItem( (short) nEsc, ((SvxEscapementItem*)pItem)->GetProp(), EE_CHAR_ESCAPEMENT );
356 rSet.GetAttrSet().Put( aEscItem );
360 if ( pImpEditEngine->aImportHdl.IsSet() )
362 EditSelection aSel( aStartPaM, aEndPaM );
363 ImportInfo aImportInfo( RTFIMP_SETATTR, this, pImpEditEngine->CreateESel( aSel ) );
364 aImportInfo.pAttrs = &rSet;
365 pImpEditEngine->aImportHdl.Call( &aImportInfo );
368 ContentNode* pSN = aStartPaM.GetNode();
369 ContentNode* pEN = aEndPaM.GetNode();
370 USHORT nStartNode = pImpEditEngine->GetEditDoc().GetPos( pSN );
371 USHORT nEndNode = pImpEditEngine->GetEditDoc().GetPos( pEN );
372 sal_Int16 nOutlLevel = 0xff;
374 if ( rSet.StyleNo() && pImpEditEngine->GetStyleSheetPool() && pImpEditEngine->GetStatus().DoImportRTFStyleSheets() )
376 SvxRTFStyleType* pS = GetStyleTbl().Get( rSet.StyleNo() );
377 DBG_ASSERT( pS, "Vorlage in RTF nicht definiert!" );
378 if ( pS )
380 pImpEditEngine->SetStyleSheet( EditSelection( aStartPaM, aEndPaM ), (SfxStyleSheet*)pImpEditEngine->GetStyleSheetPool()->Find( pS->sName, SFX_STYLE_FAMILY_ALL ) );
381 nOutlLevel = pS->nOutlineNo;
385 // Wenn ein Attribut von 0 bis aktuelle Absatzlaenge geht,
386 // soll es ein Absatz-Attribut sein!
388 // Achtung: Selektion kann ueber mehrere Absaetze gehen.
389 // Alle vollstaendigen Absaetze sind Absatzattribute...
390 for ( USHORT z = nStartNode+1; z < nEndNode; z++ )
392 DBG_ASSERT( pImpEditEngine->GetEditDoc().SaveGetObject( z ), "Node existiert noch nicht(RTF)" );
393 pImpEditEngine->SetParaAttribs( z, rSet.GetAttrSet() );
396 if ( aStartPaM.GetNode() != aEndPaM.GetNode() )
398 // Den Rest des StartNodes...
399 if ( aStartPaM.GetIndex() == 0 )
400 pImpEditEngine->SetParaAttribs( nStartNode, rSet.GetAttrSet() );
401 else
402 pImpEditEngine->SetAttribs( EditSelection( aStartPaM, EditPaM( aStartPaM.GetNode(), aStartPaM.GetNode()->Len() ) ), rSet.GetAttrSet() );
404 // Den Anfang des EndNodes....
405 if ( aEndPaM.GetIndex() == aEndPaM.GetNode()->Len() )
406 pImpEditEngine->SetParaAttribs( nEndNode, rSet.GetAttrSet() );
407 else
408 pImpEditEngine->SetAttribs( EditSelection( EditPaM( aEndPaM.GetNode(), 0 ), aEndPaM ), rSet.GetAttrSet() );
410 else
412 if ( ( aStartPaM.GetIndex() == 0 ) && ( aEndPaM.GetIndex() == aEndPaM.GetNode()->Len() ) )
414 // #96298# When settings char attribs as para attribs, we must merge with existing attribs, not overwrite the ItemSet!
415 SfxItemSet aAttrs = pImpEditEngine->GetParaAttribs( nStartNode );
416 aAttrs.Put( rSet.GetAttrSet() );
417 pImpEditEngine->SetParaAttribs( nStartNode, aAttrs );
419 else
421 pImpEditEngine->SetAttribs( EditSelection( aStartPaM, aEndPaM ), rSet.GetAttrSet() );
425 // OutlLevel...
426 if ( nOutlLevel != 0xff )
428 for ( USHORT n = nStartNode; n <= nEndNode; n++ )
430 ContentNode* pNode = pImpEditEngine->GetEditDoc().SaveGetObject( n );
431 pNode->GetContentAttribs().GetItems().Put( SfxInt16Item( EE_PARA_OUTLLEVEL, nOutlLevel ) );
436 SvxRTFStyleType* EditRTFParser::FindStyleSheet( const XubString& rName )
438 SvxRTFStyleType* pS = GetStyleTbl().First();
439 while ( pS && ( pS->sName != rName ) )
440 pS = GetStyleTbl().Next();
442 return pS;
445 SfxStyleSheet* EditRTFParser::CreateStyleSheet( SvxRTFStyleType* pRTFStyle )
447 // Prueffen, ob so eine Vorlage existiert....
448 // dann wird sie auch nicht geaendert!
449 SfxStyleSheet* pStyle = (SfxStyleSheet*)pImpEditEngine->GetStyleSheetPool()->Find( pRTFStyle->sName, SFX_STYLE_FAMILY_ALL );
450 if ( pStyle )
451 return pStyle;
453 String aName( pRTFStyle->sName );
454 String aParent;
455 if ( pRTFStyle->nBasedOn )
457 SvxRTFStyleType* pS = GetStyleTbl().Get( pRTFStyle->nBasedOn );
458 if ( pS && ( pS !=pRTFStyle ) )
459 aParent = pS->sName;
462 pStyle = (SfxStyleSheet*) &pImpEditEngine->GetStyleSheetPool()->Make( aName, SFX_STYLE_FAMILY_PARA );
464 // 1) Items konvertieren und uebernehmen...
465 ConvertAndPutItems( pStyle->GetItemSet(), pRTFStyle->aAttrSet );
467 // 2) Solange Parent nicht im Pool, auch diesen kreieren...
468 if ( aParent.Len() && ( aParent != aName ) )
470 SfxStyleSheet* pS = (SfxStyleSheet*)pImpEditEngine->GetStyleSheetPool()->Find( aParent, SFX_STYLE_FAMILY_ALL );
471 if ( !pS )
473 // Wenn nirgendwo gefunden, aus RTF erzeugen...
474 SvxRTFStyleType* _pRTFStyle = FindStyleSheet( aParent );
475 if ( _pRTFStyle )
476 pS = CreateStyleSheet( _pRTFStyle );
478 // 2b) ItemSet mit Parent verknuepfen...
479 if ( pS )
480 pStyle->GetItemSet().SetParent( &pS->GetItemSet() );
482 return pStyle;
485 void EditRTFParser::CreateStyleSheets()
487 // der SvxRTFParser hat jetzt die Vorlagen erzeugt...
488 if ( pImpEditEngine->GetStyleSheetPool() && pImpEditEngine->GetStatus().DoImportRTFStyleSheets() )
490 SvxRTFStyleType* pRTFStyle = GetStyleTbl().First();
491 while ( pRTFStyle )
493 CreateStyleSheet( pRTFStyle );
495 pRTFStyle = GetStyleTbl().Next();
500 void __EXPORT EditRTFParser::CalcValue()
502 const MapUnit eDestUnit = static_cast< MapUnit >( aEditMapMode.GetMapUnit() );
503 const MapUnit eSrcUnit = aRTFMapMode.GetMapUnit();
504 if (eDestUnit != eSrcUnit)
505 nTokenValue = OutputDevice::LogicToLogic( (long)nTokenValue, eSrcUnit, eDestUnit );
508 void EditRTFParser::ReadField()
510 // Aus SwRTFParser::ReadField()
511 int _nOpenBrakets = 1; // die erste wurde schon vorher erkannt
512 BOOL bFldInst = FALSE;
513 BOOL bFldRslt = FALSE;
514 String aFldInst;
515 String aFldRslt;
517 while( _nOpenBrakets && IsParserWorking() )
519 switch( GetNextToken() )
521 case '}':
523 _nOpenBrakets--;
524 if ( _nOpenBrakets == 1 )
526 bFldInst = FALSE;
527 bFldRslt = FALSE;
530 break;
532 case '{': _nOpenBrakets++;
533 break;
535 case RTF_FIELD: SkipGroup();
536 break;
538 case RTF_FLDINST: bFldInst = TRUE;
539 break;
541 case RTF_FLDRSLT: bFldRslt = TRUE;
542 break;
544 case RTF_TEXTTOKEN:
546 if ( bFldInst )
547 aFldInst += aToken;
548 else if ( bFldRslt )
549 aFldRslt += aToken;
551 break;
554 if ( aFldInst.Len() )
556 String aHyperLinkMarker( RTL_CONSTASCII_USTRINGPARAM( "HYPERLINK " ) );
557 if ( aFldInst.CompareIgnoreCaseToAscii( aHyperLinkMarker, aHyperLinkMarker.Len() ) == COMPARE_EQUAL )
559 aFldInst.Erase( 0, aHyperLinkMarker.Len() );
560 aFldInst.EraseLeadingChars();
561 aFldInst.EraseTrailingChars();
562 aFldInst.Erase( 0, 1 ); // "
563 aFldInst.Erase( aFldInst.Len()-1, 1 ); // "
565 if ( !aFldRslt.Len() )
566 aFldRslt = aFldInst;
568 SvxFieldItem aField( SvxURLField( aFldInst, aFldRslt, SVXURLFORMAT_REPR ), EE_FEATURE_FIELD );
569 aCurSel = pImpEditEngine->InsertField( aCurSel, aField );
570 pImpEditEngine->UpdateFields();
571 nLastAction = ACTION_INSERTTEXT;
575 SkipToken( -1 ); // die schliesende Klammer wird "oben" ausgewertet
578 void EditRTFParser::SkipGroup()
580 int _nOpenBrakets = 1; // die erste wurde schon vorher erkannt
582 while( _nOpenBrakets && IsParserWorking() )
584 switch( GetNextToken() )
586 case '}':
588 _nOpenBrakets--;
590 break;
592 case '{':
594 _nOpenBrakets++;
596 break;
600 SkipToken( -1 ); // die schliesende Klammer wird "oben" ausgewertet
603 ULONG __EXPORT EditNodeIdx::GetIdx() const
605 return pImpEditEngine->GetEditDoc().GetPos( pNode );
608 SvxNodeIdx* __EXPORT EditNodeIdx::Clone() const
610 return new EditNodeIdx( pImpEditEngine, pNode );
613 SvxPosition* __EXPORT EditPosition::Clone() const
615 return new EditPosition( pImpEditEngine, pCurSel );
618 SvxNodeIdx* __EXPORT EditPosition::MakeNodeIdx() const
620 return new EditNodeIdx( pImpEditEngine, pCurSel->Max().GetNode() );
623 ULONG __EXPORT EditPosition::GetNodeIdx() const
625 ContentNode* pN = pCurSel->Max().GetNode();
626 return pImpEditEngine->GetEditDoc().GetPos( pN );
629 USHORT __EXPORT EditPosition::GetCntIdx() const
631 return pCurSel->Max().GetIndex();