summaryrefslogtreecommitdiff
path: root/sw/source/filter/rtf
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2012-12-10 10:02:46 +0100
committerMiklos Vajna <vmiklos@suse.cz>2012-12-10 10:05:22 +0100
commit3514ad82c4200be292ef6eaa1e94c5c6a41884e4 (patch)
treef2c826c9789aaba62f22d5b2eacbc4265826d10d /sw/source/filter/rtf
parent9aec18854afb1ec2d28c334861924ad6eacf26af (diff)
sw: unused SwRTFParser
Change-Id: Iaabd3d992f5e8cd8166afd3520fa8552b6219e27
Diffstat (limited to 'sw/source/filter/rtf')
-rw-r--r--sw/source/filter/rtf/rtffld.cxx958
-rw-r--r--sw/source/filter/rtf/rtffly.cxx1451
-rw-r--r--sw/source/filter/rtf/rtfnum.cxx998
-rw-r--r--sw/source/filter/rtf/rtftbl.cxx928
-rw-r--r--sw/source/filter/rtf/swparrtf.cxx3971
-rw-r--r--sw/source/filter/rtf/swparrtf.hxx238
6 files changed, 0 insertions, 8544 deletions
diff --git a/sw/source/filter/rtf/rtffld.cxx b/sw/source/filter/rtf/rtffld.cxx
index b7e06308251a..6afe16666f08 100644
--- a/sw/source/filter/rtf/rtffld.cxx
+++ b/sw/source/filter/rtf/rtffld.cxx
@@ -78,113 +78,6 @@ enum RTF_FLD_TYPES {
RTFFLD_INCLUDETEXT
};
-static RTF_FLD_TYPES _WhichFld( String& rName, String& rNext )
-{
- // Strings sind PascalStrings; Laenge steht an 1. Stellen, dadurch wird
- // sich der Aufruf von strlen erspart!!!
- sal_Char const sTOC[]= "\x03""toc";
- sal_Char const sIMPORT[]= "\x06""import";
- sal_Char const sINDEX[]= "\x05""index";
- sal_Char const sSYMBOL[]= "\x06""symbol";
- sal_Char const sPAGE[]= "\x04""page";
- sal_Char const sNUMPAGES[]= "\x08""numpages";
- sal_Char const sDATE[]= "\x04""date";
- sal_Char const sTIME[]= "\x04""time";
- sal_Char const sDATA[]= "\x04""data";
- sal_Char const sMERGEFLD[]= "\x0A""mergefield";
- sal_Char const sIMPORT2[]= "\x0E""includepicture";
- sal_Char const sHYPERLINK[]= "\x09""hyperlink";
- sal_Char const sREF[]= "\x03""ref";
- sal_Char const sPAGEREF[]= "\x07""pageref";
- sal_Char const sEQ[]= "\x02""eq";
- sal_Char const sINCLUDETEXT[]="\x0B""includetext";
-
- struct _Dummy_RTF_FLD_TYPES
- {
- RTF_FLD_TYPES eFldType;
- const sal_Char* pFldNm;
- };
- const _Dummy_RTF_FLD_TYPES aFldNmArr[RTFFLD_INCLUDETEXT + 1] = {
- {RTFFLD_TOC, sTOC},
- {RTFFLD_IMPORT, sIMPORT},
- {RTFFLD_INDEX, sINDEX},
- {RTFFLD_SYMBOL, sSYMBOL},
- {RTFFLD_PAGE, sPAGE},
- {RTFFLD_NUMPAGES, sNUMPAGES},
- {RTFFLD_DATE, sDATE},
- {RTFFLD_TIME, sTIME},
- {RTFFLD_DATA, sDATA},
- {RTFFLD_MERGEFLD, sMERGEFLD},
- {RTFFLD_IMPORT, sIMPORT2},
- {RTFFLD_HYPERLINK, sHYPERLINK},
- {RTFFLD_REF, sREF},
- {RTFFLD_PAGEREF, sPAGEREF},
- {RTFFLD_EQ, sEQ},
- {RTFFLD_INCLUDETEXT, sINCLUDETEXT}
- };
-
-
- if( !rName.Len() )
- return RTFFLD_UNKNOWN;
-
- String sNm(comphelper::string::stripStart(rName, ' ').getToken(0, ' '));
- OSL_ENSURE( sNm.Len(), "Feldname hat keine Laenge!" );
- if( !sNm.Len() )
- return RTFFLD_UNKNOWN;
-
- xub_StrLen nTokenStt = rName.Search( sNm );
- sNm.ToLowerAscii();
-
- for (size_t n = 0; n < sizeof(aFldNmArr) / sizeof(aFldNmArr[0]); ++n)
- {
- const sal_Char* pCmp = aFldNmArr[n].pFldNm;
- int nLen = *pCmp++;
- xub_StrLen nFndPos = sNm.SearchAscii( pCmp );
- if( STRING_NOTFOUND != nFndPos &&
- ( !nFndPos || !isalpha(sNm.GetChar( static_cast< xub_StrLen >(nFndPos-1) )) ) &&
- ( nFndPos+nLen == sNm.Len() || !isalpha(sNm.GetChar( static_cast< xub_StrLen >(nFndPos+nLen) ) ) ) )
- {
- rName = rName.Copy( nFndPos, static_cast< xub_StrLen >(nLen) );
- nFndPos += nTokenStt + static_cast< xub_StrLen >(nLen);
- while ((nFndPos < rNext.Len()) && (rNext.GetChar(nFndPos) == ' '))
- {
- ++nFndPos;
- }
- rNext.Erase( 0, nFndPos );
- rNext = comphelper::string::stripEnd(rNext, ' ');
- return aFldNmArr[n].eFldType;
- }
- }
- return RTFFLD_UNKNOWN; // nichts gefunden.
-}
-
-static sal_uInt16 CheckNumberFmtStr( const String& rNStr )
-{
- const static sal_Char* aNumberTypeTab[] =
- {
- "\x0A""ALPHABETIC", /* CHARS_UPPER_LETTER*/
- "\x0A""alphabetic", /* CHARS_LOWER_LETTER*/
- "\x05""ROMAN", /* ROMAN_UPPER */
- "\x05""roman", /* ROMAN_LOWER */
- "\x06""ARABIC", /* ARABIC */
- "\x04""NONE", /* NUMBER_NONE */
- "\x04""CHAR", /* CHAR_SPECIAL */
- "\x04""PAGE" /* PAGEDESC */
- };
-
- OSL_ENSURE(sizeof(aNumberTypeTab) / sizeof(sal_Char *)
- >= SVX_NUM_PAGEDESC - SVX_NUM_CHARS_UPPER_LETTER, "impossible");
-
- for (sal_uInt16 n = SVX_NUM_CHARS_UPPER_LETTER; n <= SVX_NUM_PAGEDESC; ++n)
- {
- const sal_Char* pCmp = aNumberTypeTab[n - SVX_NUM_CHARS_UPPER_LETTER];
- int nLen = *pCmp++;
- if( rNStr.EqualsAscii( pCmp, 0, static_cast< xub_StrLen >(nLen) ))
- return static_cast< sal_uInt16 >(2 <= n ? n : (n + SVX_NUM_CHARS_UPPER_LETTER_N));
- }
- return SVX_NUM_PAGEDESC; // default-Wert
-}
-
class RtfFieldSwitch
{
String sParam;
@@ -368,855 +261,4 @@ static void lcl_ScanEquationField( const String& rStr, RTF_EquationData& rData,
}
}
-int SwRTFParser::MakeFieldInst( String& rFieldStr )
-{
- // sicher den Original-String fuer die FeldNamen (User/Datenbank)
- String aSaveStr( rFieldStr );
- SwFieldType * pFldType;
- int nRet = _WhichFld(rFieldStr, aSaveStr);
-
- //Strip Mergeformat from fields
- xub_StrLen nPos=0;
- while (STRING_NOTFOUND != ( nPos = aSaveStr.SearchAscii("\\*", nPos)))
- {
- xub_StrLen nStartDel = nPos;
- nPos += 2;
- while ((nPos < aSaveStr.Len()) && (aSaveStr.GetChar(nPos) == ' '))
- {
- ++nPos;
- }
- if (aSaveStr.EqualsIgnoreCaseAscii("MERGEFORMAT", nPos, 11))
- {
- xub_StrLen nNoDel = (nPos + 11 ) - nStartDel;
- aSaveStr.Erase(nStartDel, nNoDel);
- nPos -= (nStartDel - nPos);
- }
- }
-
- nPos = 0;
- switch (nRet)
- {
- case RTFFLD_INCLUDETEXT:
- break;
- case RTFFLD_IMPORT:
- {
-
- aSaveStr = comphelper::string::strip(aSaveStr, ' ');
- if( aSaveStr.Len() )
- {
- sal_Unicode c = aSaveStr.GetChar( 0 );
- if( '"' == c || '\'' == c )
- {
- aSaveStr.Erase( 0, 1 );
- aSaveStr = aSaveStr.GetToken( 0, c );
- }
-
- rFieldStr = URIHelper::SmartRel2Abs(
- INetURLObject(GetBaseURL()), aSaveStr,
- URIHelper::GetMaybeFileHdl() );
- }
-
- }
- break;
-
- case RTFFLD_NUMPAGES:
- {
- SwDocStatField aFld( (SwDocStatFieldType*)pDoc->GetSysFldType( RES_DOCSTATFLD ),
- DS_PAGE, SVX_NUM_ARABIC );
- if( STRING_NOTFOUND != ( nPos = aSaveStr.SearchAscii( "\\*" )) )
- {
- nPos += 2;
- while ((nPos < aSaveStr.Len()) &&
- (aSaveStr.GetChar(nPos) == ' '))
- { nPos++; }
- aSaveStr.Erase( 0, nPos );
-
- // steht jetzt geanu auf dem Format-Namen
- aFld.ChangeFormat( CheckNumberFmtStr( aSaveStr ));
- }
- pDoc->InsertPoolItem( *pPam, SwFmtFld( aFld ), 0 );
- SkipGroup();
- }
- break;
-
- case RTFFLD_PAGE:
- {
- pFldType = pDoc->GetSysFldType( RES_PAGENUMBERFLD );
- SwPageNumberField aPF( (SwPageNumberFieldType*)pFldType,
- PG_RANDOM, SVX_NUM_ARABIC);
- if( STRING_NOTFOUND != ( nPos = aSaveStr.SearchAscii( "\\*" )) )
- {
- nPos += 2;
- while ((nPos < aSaveStr.Len()) &&
- (aSaveStr.GetChar(nPos) == ' '))
- { nPos++; }
- aSaveStr.Erase( 0, nPos );
-
- // steht jetzt geanu auf dem Format-Namen
- aPF.ChangeFormat( CheckNumberFmtStr( aSaveStr ));
- }
- pDoc->InsertPoolItem( *pPam, SwFmtFld( aPF ), 0 );
- SkipGroup(); // ueberlese den Rest
- }
- break;
- case RTFFLD_DATE:
- case RTFFLD_TIME:
- {
- if( STRING_NOTFOUND == ( nPos = aSaveStr.SearchAscii( "\\@" )) )
- {
- // es fehlt die Format - Angabe: defaulten auf Datum
- pFldType = pDoc->GetSysFldType( RES_DATETIMEFLD );
- pDoc->InsertPoolItem( *pPam, SwFmtFld( SwDateTimeField(
- static_cast<SwDateTimeFieldType*>(pFldType), DATEFLD)), 0);
- }
- else
- {
- // versuche aus dem Formatstring zu erkennen, ob es ein
- // Datum oder Zeit oder Datum & Zeit Field ist
- // nur das Format interressiert
- aSaveStr.Erase( 0, aSaveStr.Search( '\"' )+1 );
- // alles hinter dem Format interressiert auch nicht mehr.
- aSaveStr.Erase( aSaveStr.Search( '\"' ) );
- aSaveStr.SearchAndReplaceAscii( "AM", aEmptyStr );
- aSaveStr.SearchAndReplaceAscii( "PM", aEmptyStr );
-
- // Put the word date and time formatter stuff in a common area
- // and get the rtf filter to use it
- SwField *pFld = 0;
- short nNumFmtType = NUMBERFORMAT_UNDEFINED;
- sal_uLong nFmtIdx = NUMBERFORMAT_UNDEFINED;
-
- sal_uInt16 rLang(0);
- RES_CHRATR eLang = maPageDefaults.mbRTLdoc ? RES_CHRATR_CTL_LANGUAGE : RES_CHRATR_LANGUAGE;
- const SvxLanguageItem *pLang = (SvxLanguageItem*)&pDoc->GetAttrPool().GetDefaultItem( static_cast< sal_uInt16 >(eLang) );
- rLang = pLang ? pLang->GetValue() : LANGUAGE_ENGLISH_US;
-
- SvNumberFormatter* pFormatter = pDoc->GetNumberFormatter();
- bool bHijri = false;
-
- if( pFormatter )
- {
- nFmtIdx = sw::ms::MSDateTimeFormatToSwFormat(aSaveStr, pFormatter, rLang, bHijri, rLang);
- if (nFmtIdx)
- nNumFmtType = pFormatter->GetType(nFmtIdx);
- }
-
- pFldType = pDoc->GetSysFldType( RES_DATETIMEFLD );
-
- if(nNumFmtType & NUMBERFORMAT_DATE)
- pFld = new SwDateTimeField( (SwDateTimeFieldType*)pFldType, DATEFLD, nFmtIdx );
- else if(nNumFmtType == NUMBERFORMAT_TIME)
- pFld = new SwDateTimeField( (SwDateTimeFieldType*)pFldType, TIMEFLD, nFmtIdx );
-
- if( pFld )
- {
- pDoc->InsertPoolItem( *pPam, SwFmtFld( *pFld ), 0);
- delete pFld;
- }
- }
- SkipGroup(); // ueberlese den Rest
- }
- break;
-
- case RTFFLD_DATA:
- {
- // Datenbank-FileName: nur der Filename interressiert
- // Zur Zeit werden nur SDF-Files verarbeitet, also suche nach
- // der Extension
-
- // im SWG geben die DATA Felder den Namen der Datenbank
- // an. Dieser kann als Field oder als DBInfo interpretiert
- // werden:
- // \\data -> Datenbank-Name als Field
- // DATA -> Datenbank-Info
- bool const bField = rFieldStr.Len() && rFieldStr.GetChar(0) != 'D';
-
- // nur der Name interressiert
- if( STRING_NOTFOUND != (nPos = aSaveStr.Search( '.' )) )
- aSaveStr.Erase( nPos );
- SwDBData aData;
- aData.sDataSource = aSaveStr;
- if( bField )
- {
- pFldType = pDoc->GetSysFldType( RES_DBNAMEFLD );
- pDoc->InsertPoolItem( *pPam, SwFmtFld( SwDBNameField(
- static_cast<SwDBNameFieldType*>(pFldType), SwDBData())), 0);
- }
- else
- pDoc->ChgDBData( aData ); // MS: Keine DBInfo verwenden
- SkipGroup(); // ueberlese den Rest
- }
- break;
- case RTFFLD_MERGEFLD:
- {
- // ein Datenbank - Feld: nur der Name interressiert
- // bis zum Ende vom String ist das der Feldname
- SwDBFieldType aTmp( pDoc, aSaveStr, SwDBData() ); //
- SwDBField aDBFld( (SwDBFieldType*)pDoc->InsertFldType( aTmp ));
-
- aDBFld.ChangeFormat( UF_STRING );
- pDoc->InsertPoolItem(*pPam, SwFmtFld( aDBFld ), 0);
- SkipGroup(); // ueberlese den Rest
- }
- break;
-
- case RTFFLD_SYMBOL:
- {
- // loesche fuehrende Blanks
- if( IsNewGroup() )
- GetAttrSet();
- SetNewGroup( sal_True );
-
- SfxItemSet& rSet = GetAttrSet();
-
- sal_Bool bCharIns = sal_False;
- RtfFieldSwitch aRFS( aSaveStr );
- while( !aRFS.IsAtEnd() )
- {
- String sParam;
- sal_Unicode cKey = aRFS.GetSwitch( sParam );
- if( sParam.Len() )
- switch( cKey )
- {
- case 0:
- if( !bCharIns )
- {
- sal_Unicode cChar = (sal_Unicode)sParam.ToInt32();
- if( cChar )
- {
- pDoc->InsertString( *pPam, rtl::OUString(cChar) );
- bCharIns = sal_True;
- }
- }
- break;
-
- case 'f': case 'F':
- // Font setzen
- {
- SvxRTFFontTbl& rTbl = GetFontTbl();
-
- for( SvxRTFFontTbl::iterator it = rTbl.begin();
- it != rTbl.end(); ++it )
- {
- Font* pFont = it->second;
- if( pFont->GetName() == sParam )
- {
- rSet.Put( SvxFontItem(
- pFont->GetFamily(),
- sParam,
- pFont->GetStyleName(),
- pFont->GetPitch(),
- pFont->GetCharSet(),
- RES_CHRATR_FONT ));
- break;
- }
- }
- }
- break;
- case 'h': case 'H':
- //??
- break;
- case 's': case 'S':
- // Fontsize setzen
- {
- const sal_uInt16 nVal = (sal_uInt16)(sParam.ToInt32() * 20);
- rSet.Put( SvxFontHeightItem( nVal,
- 100, RES_CHRATR_FONTSIZE ));
- }
- break;
- }
- }
-
- if( !IsNewGroup() ) AttrGroupEnd();
- SetNewGroup( sal_False );
-
- SkipGroup(); // ueberlese den Rest
- }
- break;
-
- case RTFFLD_HYPERLINK:
- rFieldStr.Erase();
- if( aSaveStr.Len() )
- {
- // return String ist URL, # Mark, \1 Frame
- String sMark, sFrame;
- RtfFieldSwitch aRFS( aSaveStr );
- while( !aRFS.IsAtEnd() )
- {
- String sParam;
- sal_Unicode cKey = aRFS.GetSwitch( sParam );
- if( sParam.Len() )
- switch( cKey )
- {
- case 0:
- if( !rFieldStr.Len() )
- rFieldStr = URIHelper::SmartRel2Abs(
- INetURLObject(GetBaseURL()), sParam,
- URIHelper::GetMaybeFileHdl() );
- break;
-
- case 'l': case 'L': sMark = sParam; break;
- case 't': case 'T': sFrame = sParam; break;
- }
- }
-
- if( sMark.Len() )
- ( rFieldStr += INET_MARK_TOKEN ) += sMark;
- if( sFrame.Len() )
- ( rFieldStr += '\1' ) += sFrame;
- }
- break;
-
- case RTFFLD_EQ:
- rFieldStr.Erase();
- if( aSaveStr.Len() )
- {
- RTF_EquationData aData;
- ::lcl_ScanEquationField( aSaveStr, aData, 0 );
-
- // is it a ruby attr?
- if( aData.sText.Len() && aData.sFontName.Len() &&
- aData.nFontSize && aData.sUp.Len() && !aData.sDown.Len() )
- {
- //Translate and apply
- switch( aData.nJustificationCode )
- {
- case 0: aData.nJustificationCode = 1; break;
- case 1: aData.nJustificationCode = 3; break;
- case 2: aData.nJustificationCode = 4; break;
- case 4: aData.nJustificationCode = 2; break;
- default: aData.nJustificationCode = 0; break;
- }
-
- SwFmtRuby aRuby( aData.sUp );
- SwCharFmt * pCharFmt = NULL;
-
- if ( aData.nStyleNo != -1)
- {
- std::map<sal_Int32,SwCharFmt*>::iterator iter = aCharFmtTbl.find(aData.nStyleNo);
-
- if (iter != aCharFmtTbl.end())
- pCharFmt = iter->second;
- }
-
- if( !pCharFmt )
- {
- //Make a guess at which of asian of western we should be setting
- sal_uInt16 nScript;
- if (pBreakIt->GetBreakIter().is())
- nScript = pBreakIt->GetBreakIter()->getScriptType( aData.sUp, 0);
- else
- nScript = i18n::ScriptType::ASIAN;
-
- sal_uInt16 nFntHWhich = GetWhichOfScript( RES_CHRATR_FONTSIZE, nScript ),
- nFntWhich = GetWhichOfScript( RES_CHRATR_FONT, nScript );
-
- //Check to see if we already have a ruby charstyle that this fits
- for(sal_uInt16 i=0; i < aRubyCharFmts.size(); ++i )
- {
- SwCharFmt *pFmt = aRubyCharFmts[i];
- const SvxFontHeightItem &rF = (const SvxFontHeightItem &)
- pFmt->GetFmtAttr( nFntHWhich );
- if( rF.GetHeight() == sal_uInt16(aData.nFontSize * 10 ))
- {
- const SvxFontItem &rFI = (const SvxFontItem &)
- pFmt->GetFmtAttr( nFntWhich );
- if( rFI.GetFamilyName().Equals( aData.sFontName ))
- {
- pCharFmt = pFmt;
- break;
- }
- }
- }
-
- //Create a new char style if necessary
- if( !pCharFmt )
- {
- String sNm;
- //Take this as the base name
- SwStyleNameMapper::FillUIName( RES_POOLCHR_RUBYTEXT, sNm );
- sNm += String::CreateFromInt32( aRubyCharFmts.size() + 1 );
- pCharFmt = pDoc->MakeCharFmt( sNm,
- ( SwCharFmt*)pDoc->GetDfltCharFmt() );
-
- SvxFontHeightItem aHeightItem( aData.nFontSize * 10, 100, RES_CHRATR_FONTSIZE );
- aHeightItem.SetWhich( nFntHWhich );
-
- SvxFontItem aFontItem( FAMILY_DONTKNOW, aData.sFontName,
- aEmptyStr, PITCH_DONTKNOW, RTL_TEXTENCODING_DONTKNOW, nFntWhich );
-
- pCharFmt->SetFmtAttr( aHeightItem );
- pCharFmt->SetFmtAttr( aFontItem );
- aRubyCharFmts.push_back( pCharFmt );
- }
- }
-
- //Set the charstyle and justification
- aRuby.SetCharFmtName( pCharFmt->GetName() );
- aRuby.SetCharFmtId( pCharFmt->GetPoolFmtId() );
- aRuby.SetAdjustment( (sal_uInt16)aData.nJustificationCode );
-
- // im FieldStr steht der anzuzeigenden Text, im
- pDoc->InsertString( *pPam, aData.sText );
- pPam->SetMark();
- pPam->GetMark()->nContent -= aData.sText.Len();
- pDoc->InsertPoolItem( *pPam, aRuby,
- nsSetAttrMode::SETATTR_DONTEXPAND );
- pPam->DeleteMark();
- }
- // or a combined character field?
- else if( aData.sUp.Len() && aData.sDown.Len() &&
- !aData.sText.Len() && !aData.sFontName.Len() &&
- !aData.nFontSize )
- {
- String sFld( aData.sUp );
- sFld += aData.sDown;
- SwCombinedCharField aFld((SwCombinedCharFieldType*)pDoc->
- GetSysFldType( RES_COMBINED_CHARS ), sFld );
- pDoc->InsertPoolItem( *pPam, SwFmtFld( aFld ), 0);
-
- }
- SkipGroup(); // ueberlese den Rest
- }
- break;
-
- case RTFFLD_PAGEREF:
- {
- String sOrigBkmName;
- RtfFieldSwitch aRFS( aSaveStr );
- while( !aRFS.IsAtEnd() )
- {
- String sParam;
- sal_Unicode cKey = aRFS.GetSwitch( sParam );
- switch( cKey )
- {
- // In the case of pageref the only parameter we are
- // interested in, is the name of the bookmark
- case 0:
- if( !sOrigBkmName.Len() ) // get name of bookmark
- sOrigBkmName = sParam;
- break;
- }
- }
- SwGetRefField aFld(
- (SwGetRefFieldType*)pDoc->GetSysFldType( RES_GETREFFLD ),
- sOrigBkmName,REF_BOOKMARK,0,REF_PAGE);
-
- if(!bNestedField)
- {
- pDoc->InsertPoolItem( *pPam, SwFmtFld( aFld ), 0 );
- }
- else
- bNestedField = false;
- }
- break;
-
- case RTFFLD_REF:
- {
- String sOrigBkmName;
- REFERENCEMARK eFormat = REF_CONTENT;
-
- RtfFieldSwitch aRFS( aSaveStr );
- while( !aRFS.IsAtEnd() )
- {
- String sParam;
- sal_Unicode cKey = aRFS.GetSwitch( sParam );
- switch( cKey )
- {
- case 0:
- if( !sOrigBkmName.Len() ) // get name of bookmark
- sOrigBkmName = sParam;
- break;
-
- /* References to numbers in Word could be either to a numbered
- paragraph or to a chapter number. However Word does not seem to
- have the capability we do, of refering to the chapter number some
- other bookmark is in. As a result, cross-references to chapter
- numbers in a word document will be cross-references to a numbered
- paragraph, being the chapter heading paragraph. As it happens, our
- cross-references to numbered paragraphs will do the right thing
- when the target is a numbered chapter heading, so there is no need
- for us to use the REF_CHAPTER bookmark format on import.
- */
- case 'n':
- eFormat = REF_NUMBER_NO_CONTEXT;
- break;
- case 'r':
- eFormat = REF_NUMBER;
- break;
- case 'w':
- eFormat = REF_NUMBER_FULL_CONTEXT;
- break;
-
- case 'p':
- eFormat = REF_UPDOWN;
- break;
- }
- }
- SwGetRefField aFld(
- (SwGetRefFieldType*)pDoc->GetSysFldType( RES_GETREFFLD ),
- sOrigBkmName,REF_BOOKMARK,0,eFormat);
- pDoc->InsertPoolItem( *pPam, SwFmtFld( aFld ), 0 );
- }
- break;
-
- case RTFFLD_TOC:
- case RTFFLD_INDEX:
- break;
-
- default:
- {
- // keines von den bekannten Feldern, also eine neues UserField
- aSaveStr = comphelper::string::strip(aSaveStr, ' ');
- SwUserFieldType aTmp( pDoc, aSaveStr );
- SwUserField aUFld( (SwUserFieldType*)pDoc->InsertFldType( aTmp ));
- aUFld.ChangeFormat( UF_STRING );
- pDoc->InsertPoolItem( *pPam, SwFmtFld( aUFld ), 0);
- nRet = RTFFLD_UNKNOWN;
- }
- break;
- }
- return nRet;
-}
-
-
-void SwRTFParser::ReadXEField()
-{
- bReadSwFly = false; //#it may be that any uses of this need to be removed and replaced
- int nNumOpenBrakets = 1;
- rtl::OUStringBuffer sFieldStr;
- sal_uInt8 cCh;
-
- int nToken;
- while (nNumOpenBrakets && IsParserWorking())
- {
- switch (nToken = GetNextToken())
- {
- case '}':
- {
- --nNumOpenBrakets;
-
- if (sFieldStr.getLength())
- {
- String sXE(sFieldStr.makeStringAndClear());
- sXE.Insert('\"', 0);
- sXE.Append('\"');
-
- // we have to make sure the hidden text flag is not on
- // otherwise the index will not see this index mark
- SfxItemSet& rSet = GetAttrSet();
- const SfxPoolItem* pItem;
- if( SFX_ITEM_SET == rSet.GetItemState( RES_CHRATR_HIDDEN, sal_True, &pItem ) )
- {
- SvxCharHiddenItem aCharHidden(*(SvxCharHiddenItem*)pItem);
- aCharHidden.SetValue(sal_False);
- rSet.Put(aCharHidden);
- }
-
- sw::ms::ImportXE(*pDoc, *pPam, sXE);
- }
- }
- break;
-
- case '{':
- if( RTF_IGNOREFLAG != GetNextToken() )
- SkipToken( -1 );
- // Unknown und alle bekannten nicht ausgewerteten Gruppen
- // sofort ueberspringen
- else if( RTF_UNKNOWNCONTROL != GetNextToken() )
- SkipToken( -2 );
- else
- {
- // gleich herausfiltern
- ReadUnknownData();
- if( '}' != GetNextToken() )
- eState = SVPAR_ERROR;
- break;
- }
- ++nNumOpenBrakets;
- break;
-
- case RTF_U:
- {
- if( nTokenValue )
- sFieldStr.append(static_cast<sal_Unicode>(nTokenValue));
- else
- sFieldStr.append(aToken);
- }
- break;
-
- case RTF_LINE: cCh = '\n'; goto INSINGLECHAR;
- case RTF_TAB: cCh = '\t'; goto INSINGLECHAR;
- case RTF_SUBENTRYINDEX: cCh = ':'; goto INSINGLECHAR;
- case RTF_EMDASH: cCh = 151; goto INSINGLECHAR;
- case RTF_ENDASH: cCh = 150; goto INSINGLECHAR;
- case RTF_BULLET: cCh = 149; goto INSINGLECHAR;
- case RTF_LQUOTE: cCh = 145; goto INSINGLECHAR;
- case RTF_RQUOTE: cCh = 146; goto INSINGLECHAR;
- case RTF_LDBLQUOTE: cCh = 147; goto INSINGLECHAR;
- case RTF_RDBLQUOTE: cCh = 148; goto INSINGLECHAR;
-INSINGLECHAR:
- //convert single byte from MS1252 to unicode and append
- sFieldStr.append(rtl::OUString(
- reinterpret_cast<const sal_Char*>(&cCh), 1,
- RTL_TEXTENCODING_MS_1252));
- break;
-
- // kein Break, aToken wird als Text gesetzt
- case RTF_TEXTTOKEN:
- sFieldStr.append(aToken);
- break;
-
- case RTF_BKMK_KEY:
- case RTF_TC:
- case RTF_NEXTFILE:
- case RTF_TEMPLATE:
- case RTF_SHPRSLT:
- SkipGroup();
- break;
-
- case RTF_PAR:
- sFieldStr.append(static_cast<sal_Unicode>('\x0a'));
- break;
- default:
- SvxRTFParser::NextToken( nToken );
- break;
- }
- }
-
- SkipToken( -1 ); // die schliesende Klammer wird "oben" ausgewertet
-}
-
-
-void SwRTFParser::ReadField()
-{
- bReadSwFly = false; //#it may be that any uses of this need to be removed and replaced
- int nRet = 0;
- int nNumOpenBrakets = 1; // die erste wurde schon vorher erkannt !!
- int bFldInst = sal_False, bFldRslt = sal_False;
- String sFieldStr, sFieldNm;
- sal_Unicode cCh;
-
- int nToken;
- while (nNumOpenBrakets && IsParserWorking())
- {
- switch (nToken = GetNextToken())
- {
- case '}':
- {
- --nNumOpenBrakets;
- if( 1 != nNumOpenBrakets || !bFldInst )
- break;
-
- if( !bFldRslt )
- {
- // FieldInst vollstaendig eingelesen, was ist es denn?
- nRet = MakeFieldInst( sFieldStr );
- switch ( nRet )
- {
- case RTFFLD_INCLUDETEXT:
- case RTFFLD_TOC:
- case RTFFLD_INDEX:
- // erstmal Index/Inhaltsverzeichniss ueberspringen
- // und als normalen Text einfuegen. Spaeter mal auch dem
- // SwPaM darum aufspannen.
- return ;
-
- case RTFFLD_IMPORT:
- case RTFFLD_HYPERLINK:
- sFieldNm = sFieldStr;
- break;
- }
- sFieldStr.Erase();
- }
- else if (RTFFLD_UNKNOWN == nRet)
- {
- // FieldResult wurde eingelesen
- if (SwTxtNode* pTxtNd = pPam->GetPoint()->nNode.GetNode().GetTxtNode())
- {
- SwTxtAttr* const pFldAttr =
- pTxtNd->GetTxtAttrForCharAt(
- pPam->GetPoint()->nContent.GetIndex()-1 );
-
- if (pFldAttr)
- {
- const SwField *pFld = pFldAttr->GetFld().GetFld();
- SwFieldType *pTyp = pFld ? pFld->GetTyp() : 0;
- OSL_ENSURE(pTyp->Which() == RES_USERFLD, "expected a user field");
- if (pTyp->Which() == RES_USERFLD)
- {
- SwUserFieldType *pUsrTyp = (SwUserFieldType*)pTyp;
- pUsrTyp->SetContent(sFieldStr);
- }
- }
- }
- }
- else if( sFieldNm.Len() )
- {
- switch ( nRet )
- {
- case RTFFLD_IMPORT:
- // Grafik einfuegen
- InsPicture( sFieldNm );
- nRet = INT_MAX;
- break;
- case RTFFLD_HYPERLINK:
- if( sFieldStr.Len() )
- {
- if(sNestedFieldStr.Len())
- sFieldStr.Insert(sNestedFieldStr);
-
- sNestedFieldStr.Erase();
- // im FieldStr steht der anzuzeigenden Text, im
- pDoc->InsertString( *pPam, sFieldStr );
-
- String sTarget( sFieldNm.GetToken( 1, '\1' ));
- if( sTarget.Len() )
- sFieldNm.Erase( sFieldNm.Len() - sTarget.Len() -1 );
-
- // oder ueber den Stack setzen??
- pPam->SetMark();
- pPam->GetMark()->nContent -= sFieldStr.Len();
- pDoc->InsertPoolItem( *pPam,
- SwFmtINetFmt( sFieldNm, sTarget ),
- nsSetAttrMode::SETATTR_DONTEXPAND );
- pPam->DeleteMark();
-
- // #i117947#: insert result only once in case
- // field result is followed by invalid tokens
- sFieldStr.Erase();
- }
- break;
- }
- }
- else if(bNestedField)
- {
- if(nRet == RTFFLD_PAGEREF)
- {
- // Nasty hack to get a pageref within a hyperlink working
- sNestedFieldStr = sFieldStr;
- }
-
- }
-
- }
- break;
-
- case '{':
- if( RTF_IGNOREFLAG != GetNextToken() )
- SkipToken( -1 );
- // Unknown und alle bekannten nicht ausgewerteten Gruppen
- // sofort ueberspringen
- else if( RTF_UNKNOWNCONTROL != GetNextToken() )
- SkipToken( -2 );
- else
- {
- // gleich herausfiltern
- ReadUnknownData();
- if( '}' != GetNextToken() )
- eState = SVPAR_ERROR;
- break;
- }
- ++nNumOpenBrakets;
- break;
-
- case RTF_DATAFIELD:
- SkipGroup();
- break;
-
- case RTF_FIELD:
- bNestedField = true;
- ReadField();
- break;
-
- case RTF_FLDINST:
- bFldInst = sal_True;
- break;
-
- case RTF_FLDRSLT:
- bFldRslt = sal_True;
- break;
-
- case RTF_U:
- {
- if( nTokenValue )
- sFieldStr += (sal_Unicode)nTokenValue;
- else
- sFieldStr += aToken;
- }
- break;
-
- case RTF_LINE: cCh = '\n'; goto INSINGLECHAR;
- case RTF_TAB: cCh = '\t'; goto INSINGLECHAR;
- case RTF_SUBENTRYINDEX: cCh = ':'; goto INSINGLECHAR;
- case RTF_EMDASH: cCh = 0x2014; goto INSINGLECHAR;
- case RTF_ENDASH: cCh = 0x2013; goto INSINGLECHAR;
- case RTF_BULLET: cCh = 0x2022; goto INSINGLECHAR;
- case RTF_LQUOTE: cCh = 0x2018; goto INSINGLECHAR;
- case RTF_RQUOTE: cCh = 0x2019; goto INSINGLECHAR;
- case RTF_LDBLQUOTE: cCh = 0x201C; goto INSINGLECHAR;
- case RTF_RDBLQUOTE: cCh = 0x201D; goto INSINGLECHAR;
-INSINGLECHAR:
- sFieldStr += cCh;
- break;
-
- // kein Break, aToken wird als Text gesetzt
- case RTF_TEXTTOKEN:
- sFieldStr += aToken;
- break;
-
- case RTF_PICT: // Pic-Daten einlesen!
- if( RTFFLD_IMPORT == nRet )
- {
- Graphic aGrf;
- SvxRTFPictureType aPicType;
- if( ReadBmpData( aGrf, aPicType ) )
- {
- InsPicture( sFieldNm, &aGrf, &aPicType );
- nRet = INT_MAX;
- }
- SkipGroup();
- }
- break;
-
- case RTF_BKMK_KEY:
- case RTF_XE:
- case RTF_TC:
- case RTF_NEXTFILE:
- case RTF_TEMPLATE:
- case RTF_SHPRSLT:
- SkipGroup();
- break;
-
- case RTF_CS:
- // we write every time "EQ "
- if( bFldInst && 0 == sFieldStr.SearchAscii( "EQ " ))
- {
- // insert behind the EQ the "\*cs<NO> " string. This is utilize
- // in the MakeFieldInst
- String sTmp;
- (sTmp.AssignAscii( "\\* cs" )
- += String::CreateFromInt32( nTokenValue )) += ' ';
- sFieldStr.Insert( sTmp, 3 );
- }
- break;
- case RTF_FFNAME:
- case RTF_FORMFIELD:
- break;
- case RTF_PAR:
- sFieldStr.Append('\x0a');
- break;
- default:
- SvxRTFParser::NextToken( nToken );
- break;
- }
- }
-
- // Grafik einfuegen
- if (RTFFLD_IMPORT == nRet && sFieldNm.Len())
- InsPicture( sFieldNm );
-
- SkipToken( -1 ); // die schliesende Klammer wird "oben" ausgewertet
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/rtf/rtffly.cxx b/sw/source/filter/rtf/rtffly.cxx
index f6ec1f6696fe..5e19830514bc 100644
--- a/sw/source/filter/rtf/rtffly.cxx
+++ b/sw/source/filter/rtf/rtffly.cxx
@@ -139,1455 +139,4 @@ void SwFlySave::SetFlySize( const SwTableNode& rTblNd )
aFlySet.Put( SwFmtFrmSize( rSz.GetHeightSizeType(), nWidth, rSz.GetHeight() ));
}
-static sal_Bool lcl_HasBreakAttrs( const SwCntntNode& rNd )
-{
- sal_Bool bRet = sal_False;
- const SfxItemSet& rSet = rNd.GetSwAttrSet();
- const SfxPoolItem* pItem;
- if( SFX_ITEM_SET == rSet.GetItemState( RES_BREAK, sal_True, &pItem ) &&
- SVX_BREAK_NONE != ((SvxFmtBreakItem*)pItem)->GetBreak() )
- bRet = sal_True;
- else if( SFX_ITEM_SET == rSet.GetItemState( RES_PAGEDESC, sal_True, &pItem )&&
- 0 != ((SwFmtPageDesc*)pItem)->GetPageDesc() )
- bRet = sal_True;
- return bRet;
-}
-
-
-static void lcl_CpyBreakAttrs( SwCntntNode* pSrcNd, SwCntntNode* pDstNd,
- SwNodeIndex* pNewIdx )
-{
- const SfxItemSet* pSet;
- if( pSrcNd && pDstNd && 0 != ( pSet = pSrcNd->GetpSwAttrSet() ) )
- {
- const SfxPoolItem *pDescItem, *pBreakItem;
-
- if( SFX_ITEM_SET != pSet->GetItemState( RES_BREAK,
- sal_False, &pBreakItem ) )
- pBreakItem = 0;
-
- if( SFX_ITEM_SET != pSet->GetItemState( RES_PAGEDESC,
- sal_False, &pDescItem ) )
- pDescItem = 0;
-
- if( pDescItem || pBreakItem )
- {
- if( lcl_HasBreakAttrs( *pDstNd ))
- {
- SwPosition aPos( *pDstNd, SwIndex( pDstNd ));
- aPos.nNode--;
- pDstNd->GetDoc()->AppendTxtNode( aPos );
- if( pNewIdx )
- *pNewIdx = aPos.nNode;
-
- SwCntntNode* pOldNd = pDstNd;
- pDstNd = aPos.nNode.GetNode().GetCntntNode();
- pDstNd->ChgFmtColl( pOldNd->GetFmtColl() );
- if( pDstNd->HasSwAttrSet() )
- {
- SfxItemSet aSet( *pDstNd->GetpSwAttrSet() );
- aSet.ClearItem( RES_BREAK );
- aSet.ClearItem( RES_PAGEDESC );
- pDstNd->SetAttr( aSet );
- }
- }
- if( pBreakItem )
- {
- pDstNd->SetAttr( *pBreakItem );
- pSrcNd->ResetAttr( RES_BREAK );
- }
- if( pDescItem )
- {
- pDstNd->SetAttr( *pDescItem );
- pSrcNd->ResetAttr( RES_PAGEDESC );
- }
- }
- }
-}
-
-void SwRTFParser::SetFlysInDoc()
-{
- // !! von Oben abarbeiten, CntntPos ist kein Index !
- SwNodes & rNds = pDoc->GetNodes();
- typedef std::pair<SwFlyFrmFmt*, SwFmtAnchor> frameEntry;
- typedef std::deque<frameEntry> rtfframesAtIndex;
- typedef std::map<const SwNode*, rtfframesAtIndex> rtfFmtMap;
- rtfFmtMap aPrevFmts;
-
- SwFrmFmt* pParent = pDoc->GetFrmFmtFromPool( RES_POOLFRM_FRAME );
- for( sal_uInt16 n = 0; n < aFlyArr.size(); ++n )
- {
- SwFlySave* pFlySave = aFlyArr[ n ];
-
- OSL_ENSURE( !pFlySave->nSttNd.GetNode().FindFlyStartNode(),
- "Content vom Fly steht in einem Fly" );
- OSL_ENSURE( pFlySave->nSttNd.GetIndex() <= pFlySave->nEndNd.GetIndex(),
- "Fly hat falschen Bereich" );
-
-
-
- // wenn ein DropCap ist, dann Text im Node belassen,
- // am Absatz das Absatz Attribut setzen. Ggfs noch die FontSize zuruecksetzen,
- // damit das DropCap nicht zu gross wird.
- if( pFlySave->nDropAnchor )
- {
- SwTxtNode* pSttNd = pFlySave->nSttNd.GetNode().GetTxtNode();
- SwTxtNode* pEndNd = pFlySave->nEndNd.GetNode().GetTxtNode();
- if( pSttNd && pEndNd &&
- pSttNd->GetIndex() + 1 == pEndNd->GetIndex()
- && pSttNd->GetTxt().Len()>0 /* #i38227# leave drop caps with no content as fly frames */ )
- {
- sal_uLong nPos = pSttNd->GetIndex();
- SwDoc * pDoc1 = pSttNd->GetDoc();
-
- sal_Bool bJoined;
- {
- SwPaM aTmp( *pSttNd, pSttNd->GetTxt().Len(), *pEndNd, 0 );
- bJoined = pDoc1->DeleteAndJoin( aTmp );
- }
-
- SwTxtNode * pNd = (pDoc1->GetNodes()[nPos])->GetTxtNode();
-
- if( bJoined && pNd != NULL)
- {
- SwFmtDrop aDropCap;
- aDropCap.GetLines() = (sal_uInt8)pFlySave->nDropLines;
- aDropCap.GetChars() = 1;
-
- SwIndex aIdx( pEndNd );
- pNd->RstAttr( aIdx, 1, RES_CHRATR_FONTSIZE );
- pNd->SetAttr( aDropCap );
- }
- delete pFlySave;
- continue;
- }
- }
-
- // liegt Ende und Start vom Naechsten im gleichen Node, dann muss
- // gesplittet werden
- if (((static_cast<size_t>(n) + 1) < aFlyArr.size()) &&
- pFlySave->nEndCnt &&
- pFlySave->nEndNd == aFlyArr[ n + 1 ]->nSttNd )
- {
- SwCntntNode *const pCNd = pFlySave->nEndNd.GetNode().GetCntntNode();
- if( pCNd )
- {
- SwPosition aPos( pFlySave->nEndNd,
- SwIndex( pCNd, pFlySave->nEndCnt ));
- pDoc->SplitNode( aPos, false );
- pFlySave->nEndNd--;
- }
- else
- pFlySave->nEndCnt = 0;
- }
-
- // verschiebe den Inhalt von diesem Anchor in den Auto-TextBereich
- // und erzeuge dadurch den richtigen SwG-Rahmen
- SwNodeRange aRg(pFlySave->nSttNd, 0, pFlySave->nEndNd, 0);
- //Make a new section, unless there is no content at all
- const bool bMakeEmptySection = aRg.aStart < aRg.aEnd || ((aRg.aStart == aRg.aEnd) && pFlySave->nEndCnt);
-
- {
- // Nur TextNodes koennen in Tabellen stehen !!
- const SwNode* pNd = &pFlySave->nSttNd.GetNode();
- if( pNd->IsNoTxtNode() )
- {
- // die Size muss noch korrigiert werden!
- nAktPageDesc = 0; // Standart PageDesc
- if( SFX_ITEM_SET != pFlySave->aFlySet.GetItemState(
- RES_FRM_SIZE, sal_False ) )
- _SetPictureSize( *(SwNoTxtNode*)pNd, aRg.aStart,
- pFlySave->aFlySet );
- if( 0 != ( pNd = pNd->FindTableNode() ) )
- pFlySave->SetFlySize( *(SwTableNode*)pNd );
- }
- else
- {
- // Take care for table nodes
- pNd = pNd->GetNodes()[ pNd->GetIndex() - 2 ]->GetTableNode();
- if( pNd ) // if the table starts imediately before aRg -> expand aRg
- aRg.aStart = *pNd;
-
- if( bMakeEmptySection )
- {
- pNd = &aRg.aEnd.GetNode();
- sal_uLong nSectEnd = pNd->EndOfSectionIndex()+1;
-
- if (!pNd->IsTableNode() && 0 !=(pNd = pNd->FindTableNode())
- && (pNd->GetIndex() >= aRg.aStart.GetNode().GetIndex()) )
- {
- const SwNode* pTblBxNd;
-
- // Ende der Tabelle ist hinter dieser Box ??
- if( pNd->EndOfSectionIndex() == nSectEnd )
- aRg.aEnd = nSectEnd+1;
- // is the end in the first box of the table, then
- // move before the table (Bug 67663)
- // but the range must not become emtpy, i.e. aStart==aEnd
- // because otherwise we will get a crash (126506) later on
- else if( 0 != ( pTblBxNd = aRg.aEnd.GetNode().
- FindTableBoxStartNode()) &&
- pTblBxNd->GetIndex() - 1 == pNd->GetIndex() &&
- &aRg.aStart.GetNode() != pNd )
- aRg.aEnd = *pNd;
- else
- {
- // Tabelle ist noch groesser, also splitte sie hier.
- rNds.SplitTable( aRg.aEnd, sal_True );
- aRg.aEnd = pNd->EndOfSectionIndex() + 1;
- }
- }
- }
- }
- }
-
- // vorm verschieben muss sich der Index auf die alte Position
- // gemerkt werden, der Index wird mit verschoben !!!
-
- SwNodeIndex aTmpIdx( rNds.GetEndOfAutotext() );
- SwStartNode* pSttNd = bMakeEmptySection
- ? rNds.MakeEmptySection( aTmpIdx, SwFlyStartNode )
- : rNds.MakeTextSection( aTmpIdx, SwFlyStartNode,
- (SwTxtFmtColl*)pDoc->GetDfltTxtFmtColl() );
-
- // das ist die Verankerungs-Position (fuers Layout!)
- pFlySave->nSttNd = aRg.aStart.GetIndex()-1;
- if( bMakeEmptySection )
- {
- // check: the move does not clear the surrounded section. If all
- // nodes moved away, then create a new TxtNode
- {
- // i76403: an empty selection is not a good idea
- if( aRg.aStart == aRg.aEnd && aRg.aStart.GetNode().GetTxtNode() )
- aRg.aEnd++;
- SwNodeIndex aPrev( aRg.aStart, -1 );
- if( aPrev.GetNode().IsStartNode() &&
- aPrev.GetNode().EndOfSectionNode() == &aRg.aEnd.GetNode())
- {
- // create new txtnode, because the section does never be empty
- pDoc->GetNodes().MakeTxtNode( aRg.aEnd,
- (SwTxtFmtColl*)pDoc->GetDfltTxtFmtColl() );
- aRg.aEnd--;
- }
- }
- aTmpIdx = *pSttNd->EndOfSectionNode();
- pDoc->MoveNodeRange( aRg, aTmpIdx,
- IDocumentContentOperations::DOC_MOVEDEFAULT );
- }
-
- // patch from cmc for #i52542#
- if (pSttNd->GetIndex() + 1 == pSttNd->EndOfSectionIndex())
- {
- OSL_ENSURE(!this, "nothing in this frame, not legal");
- delete pFlySave;
- continue;
- }
-
- pFlySave->aFlySet.Put( SwFmtCntnt( pSttNd ));
-
- CalculateFlySize( pFlySave->aFlySet, pFlySave->nSttNd,
- pFlySave->nPageWidth );
-
- // THIS >>>>>
- // if the section only contains one Node and this has a
- // border or backgorund, then put it to the frame
- // Not in our own RTF-Format!
- // <<<<< DOES NOT MAKE SENSE TO ME (flr)
- // Added support for transparent frames.
- if( pSttNd->GetIndex() + 1 != pSttNd->EndOfSectionIndex() &&
- !bSwPageDesc )
- {
- SwCntntNode* pSrcNd = pDoc->GetNodes()[ pSttNd->GetIndex() + 1 ]->GetCntntNode();
- SfxItemSet aTmpSet( pDoc->GetAttrPool(),
- RES_BACKGROUND, RES_BOX );
- const SvxBrushItem* pBackgroundBrush = (const SvxBrushItem*)pFlySave->aFlySet.GetItem(RES_BACKGROUND, sal_False);
- if( pSrcNd && pSrcNd->HasSwAttrSet() )
- aTmpSet.Put( *pSrcNd->GetpSwAttrSet() );
- if (pBackgroundBrush)
- {
- aTmpSet.Put(*pBackgroundBrush, RES_BACKGROUND);
- }
- else
- {
- pBackgroundBrush = (const SvxBrushItem*)aTmpSet.GetItem(RES_BACKGROUND, sal_False);
- if (pBackgroundBrush)
- {
- Color& rBackgroundColor = const_cast<SvxBrushItem*>(pBackgroundBrush)->GetColor();
- rBackgroundColor.SetTransparency(0xFE);
- }
- else
- {
- Color aColor = Color(0xff, 0xff, 0xff);
- aColor.SetTransparency( 0xFE);
- SvxBrushItem aBrush(aColor, RES_BACKGROUND);
- aTmpSet.Put(aBrush, RES_BACKGROUND);
- }
- }
- // Topic 6.
- pFlySave->aFlySet.Put( aTmpSet );
- if( pSrcNd && pSrcNd->HasSwAttrSet() )
- {
- pSrcNd->ResetAttr( RES_BACKGROUND, RES_BOX );
- }
- }
-
- SwFlyFrmFmt* pFmt = pDoc->MakeFlyFrmFmt( aEmptyStr, pParent );
- pFmt->SetFmtAttr( pFlySave->aFlySet );
- const SwFmtAnchor& rAnchor = pFmt->GetAnchor();
- if (FLY_AS_CHAR != rAnchor.GetAnchorId())
- {
- // korrigiere noch den Absatz, ist immer der vorhergehende !
- // wenn es diesen gibt! (DocAnfang!)
-
- // that is wrong. The anchor is ever the NEXT!
- // there are an Bug in the ExportFilter which will
- // be fixed in the Version 517 - by SWG-Export
- // the fly will be after the paragraph - but in RTF
- // the flys will be before the paragraph.
- if( !bSwPageDesc || 5430 < GetVersionNo() )
- pFlySave->nSttNd++;
-
- {
- // Seitenumbrueche in den Bodybereich verschieben!
- SwCntntNode* pSrcNd = aRg.aStart.GetNode().GetCntntNode();
- SwCntntNode* pDstNd = pFlySave->nSttNd.GetNode().GetCntntNode();
- if( !pDstNd )
- pDstNd = pDoc->GetNodes().GoNext( &pFlySave->nSttNd );
-
- ::lcl_CpyBreakAttrs( pSrcNd, pDstNd, &pFlySave->nSttNd );
- }
-
- const SwNodeIndex aSttNd(*pSttNd);
- SwNodeIndex aEndNd(*pSttNd->EndOfSectionNode());
- aEndNd--;
-
- SwPosition aPos( pFlySave->nSttNd );
- SwFmtAnchor aAnchor(rAnchor);
- aAnchor.SetAnchor(&aPos);
-
- const SwNode *pCurrentAnchor = &(pFlySave->nSttNd.GetNode());
- aPrevFmts[pCurrentAnchor].push_back(frameEntry(pFmt, aAnchor));
-
- while (aEndNd > aSttNd)
- {
- typedef rtfframesAtIndex::iterator myIter;
- rtfframesAtIndex &rDeque = aPrevFmts[&(aEndNd.GetNode())];
- myIter aEnd = rDeque.end();
- for (myIter aIter = rDeque.begin(); aIter != aEnd; ++aIter)
- {
- aIter->second.SetAnchor(&aPos);
- // #i27767# - push on front to keep order of objects
- // for the correct object positioning
- // aPrevFmts[pCurrentAnchor].push_back(*aIter);
- aPrevFmts[pCurrentAnchor].push_front(*aIter);
- }
- rDeque.clear();
- aEndNd--;
- }
- }
-
- // Create draw contact object, which also creates a <SdrObject> instance,
- // in order to set the order number.
- // The order number is assumed to be the order of the text flow.
- SwFlyDrawContact* pContact =
- new SwFlyDrawContact( pFmt,
- pFmt->GetDoc()->GetOrCreateDrawModel() );
- pContact->GetMaster()->SetOrdNum( n );
-
- delete pFlySave;
- }
-
- typedef rtfFmtMap::reverse_iterator myriter;
- myriter aEnd = aPrevFmts.rend();
- for(myriter aIter = aPrevFmts.rbegin(); aIter != aEnd; ++aIter)
- {
- rtfframesAtIndex &rDeque = aIter->second;
- typedef rtfframesAtIndex::iterator myIter;
- myIter aQEnd = rDeque.end();
- for (myIter aQIter = rDeque.begin(); aQIter != aQEnd; ++aQIter)
- {
- frameEntry &rEntry = *aQIter;
- SwFlyFrmFmt *pFrm = rEntry.first;
- SwFmtAnchor &rAnchor = rEntry.second;
- pFrm->SetFmtAttr(rAnchor);
- }
- }
-
- aFlyArr.clear();
-}
-
-// clips the text box to the min or max position if it is outside our min or max boundry
-long SwRTFParser::GetSafePos(long nPos)
-{
- if(nPos > SHRT_MAX)
- nPos = SHRT_MAX;
- else if(nPos < SHRT_MIN)
- nPos = SHRT_MIN;
-
- return nPos;
-}
-
-void SwRTFParser::ReadFly( int nToken, SfxItemSet* pSet )
-{
- // ein Set fuer die FrmFmt-Attribute
- SfxItemSet aSet( pDoc->GetAttrPool(), RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
- if( !IsNewDoc() )
- Reader::ResetFrmFmtAttrs( aSet );
-
- // der Fly beginnt immer in einem neuen Absatz
- if( pPam->GetPoint()->nContent.GetIndex() )
- InsertPara();
-
- // RTF-Defaults setzen:
- // #i27767#
- SwFmtAnchor aAnchor( FLY_AT_PARA );
- SwFmtHoriOrient aHori( 0, text::HoriOrientation::LEFT, text::RelOrientation::FRAME );
- SwFmtVertOrient aVert( 0, text::VertOrientation::TOP, text::RelOrientation::FRAME );
-
- SvxFrameDirectionItem aFrmDir( FRMDIR_HORI_LEFT_TOP, RES_FRAMEDIR );
-
- sal_uInt16 nCols = USHRT_MAX, nColSpace = USHRT_MAX, nAktCol = 0;
- std::vector<sal_uInt16> aColumns;
-
- sal_Bool bChkDropCap = 0 == pSet;
- sal_uInt16 nDropCapLines = 0, nDropCapAnchor = 0;
- int nNumOpenBrakets = GetOpenBrakets();
-
- if( !pSet )
- {
- pSet = &aSet;
- }
- else
- {
- // die Werte aus dem uebergebenen!
- aAnchor = (SwFmtAnchor&)pSet->Get( RES_ANCHOR );
- aHori = (SwFmtHoriOrient&)pSet->Get( RES_HORI_ORIENT );
- aVert = (SwFmtVertOrient&)pSet->Get( RES_VERT_ORIENT );
- }
-
- // dann sammel mal alle Attribute zusammen
- int bWeiter = sal_True;
- int nAppliedProps=0;
- do {
- sal_uInt16 nVal = sal_uInt16(nTokenValue);
- /*
- #i5263#
- Assume that a property genuinely contributes towards creating a frame,
- and if turns out to be a non contributing one reduce the count.
- */
- ++nAppliedProps;
- switch( nToken )
- {
- case RTF_ABSW:
- {
- SwFmtFrmSize aSz( ATT_MIN_SIZE, nTokenValue, 0 );
- const SfxPoolItem* pItem;
- if( SFX_ITEM_SET == pSet->GetItemState( RES_FRM_SIZE, sal_True,
- &pItem ))
- {
- aSz.SetHeightSizeType( ((SwFmtFrmSize*)pItem)->GetHeightSizeType() );
- aSz.SetHeight( ((SwFmtFrmSize*)pItem)->GetHeight() );
- }
- if( MINFLY > nTokenValue ) nTokenValue = MINFLY;
- aSet.Put( aSz );
- }
- break;
- case RTF_ABSH:
- {
- SwFmtFrmSize aSz( ATT_MIN_SIZE, 0, MINFLY );
- const SfxPoolItem* pItem;
- if( SFX_ITEM_SET == pSet->GetItemState( RES_FRM_SIZE, sal_True,
- &pItem ))
- {
- aSz.SetWidth( ((SwFmtFrmSize*)pItem)->GetWidth() );
- }
-
- if( 0 > nTokenValue )
- {
- nTokenValue = -nTokenValue;
- aSz.SetHeightSizeType( ATT_FIX_SIZE );
- }
- if( MINFLY > nTokenValue ) nTokenValue = MINFLY;
- aSz.SetHeight( nTokenValue );
- aSet.Put( aSz );
- }
- break;
-
- case RTF_NOWRAP:
- {
- pSet->Put( SwFmtSurround( SURROUND_NONE ));
- }
- break;
- case RTF_DXFRTEXT:
- {
- SvxULSpaceItem aUL( RES_UL_SPACE );
- SvxLRSpaceItem aLR( RES_LR_SPACE );
- aUL.SetUpper( nVal ); aUL.SetLower( nVal );
- aLR.SetLeft( nVal ); aLR.SetRight( nVal );
- pSet->Put( aUL );
- pSet->Put( aLR );
- }
- break;
-
- case RTF_DFRMTXTX:
- {
- SvxLRSpaceItem aLR( RES_LR_SPACE );
- aLR.SetLeft( nVal ); aLR.SetRight( nVal );
- pSet->Put( aLR );
- }
- break;
- case RTF_DFRMTXTY:
- {
- SvxULSpaceItem aUL( RES_UL_SPACE );
- aUL.SetUpper( nVal ); aUL.SetLower( nVal );
- pSet->Put( aUL );
- }
- break;
-
- case RTF_POSNEGX:
- case RTF_POSX: aHori.SetHoriOrient( text::HoriOrientation::NONE );
- aHori.SetPos( GetSafePos((long)nTokenValue) );
- break;
- case RTF_POSXC: aHori.SetHoriOrient( text::HoriOrientation::CENTER ); break;
- case RTF_POSXI: aHori.SetHoriOrient( text::HoriOrientation::LEFT );
- aHori.SetPosToggle( sal_True );
- break;
- case RTF_POSXO: aHori.SetHoriOrient( text::HoriOrientation::RIGHT );
- aHori.SetPosToggle( sal_True );
- break;
- case RTF_POSXL: aHori.SetHoriOrient( text::HoriOrientation::LEFT ); break;
- case RTF_POSXR: aHori.SetHoriOrient( text::HoriOrientation::RIGHT ); break;
-
- case RTF_POSNEGY:
- case RTF_POSY: aVert.SetVertOrient( text::VertOrientation::NONE );
- aVert.SetPos( GetSafePos((long)nTokenValue) );
- break;
- case RTF_POSYT: aVert.SetVertOrient( text::VertOrientation::TOP ); break;
- case RTF_POSYB: aVert.SetVertOrient( text::VertOrientation::BOTTOM ); break;
- case RTF_POSYC: aVert.SetVertOrient( text::VertOrientation::CENTER ); break;
-
- case RTF_PHMRG: aHori.SetRelationOrient( text::RelOrientation::PAGE_PRINT_AREA ); break;
- case RTF_PVMRG: aVert.SetRelationOrient( text::RelOrientation::PAGE_PRINT_AREA ); break;
- case RTF_PHPG: aHori.SetRelationOrient( text::RelOrientation::PAGE_FRAME ); break;
- case RTF_PVPG: aVert.SetRelationOrient( text::RelOrientation::PAGE_FRAME );break;
- case RTF_PHCOL: aHori.SetRelationOrient( text::RelOrientation::FRAME ); break;
- case RTF_PVPARA: aVert.SetRelationOrient( text::RelOrientation::FRAME ); break;
-
- case RTF_POSYIL:
- break;
- case RTF_ABSLOCK:
- /*
- #i5263#
- Not sufficient to make a frame at least word won't do it with just
- an abslock
- */
- --nAppliedProps;
- break;
- case RTF_FRMTXLRTB:
- aFrmDir.SetValue( FRMDIR_HORI_LEFT_TOP );
- break;
- case RTF_FRMTXTBRL:
- aFrmDir.SetValue( FRMDIR_HORI_RIGHT_TOP );
- break;
- case RTF_FRMTXLRTBV:
- aFrmDir.SetValue( FRMDIR_VERT_TOP_LEFT );
- break;
- case RTF_FRMTXTBRLV:
- aFrmDir.SetValue( FRMDIR_VERT_TOP_RIGHT );
- break;
-
- case RTF_DROPCAPLI: // Dropcaps !!
- if( bChkDropCap )
- {
- nDropCapLines = sal_uInt16( nTokenValue );
- if( !nDropCapAnchor )
- nDropCapAnchor = 1;
- }
- break;
- case RTF_DROPCAPT:
- if( bChkDropCap )
- {
- nDropCapAnchor = sal_uInt16( nTokenValue );
- if( !nDropCapLines )
- nDropCapLines = 3;
- }
- break;
-
-
- // fuer die "alten" Writer - haben die Spaltigkeit falsch heraus-
- // geschrieben
- case RTF_COLS: nCols = sal_uInt16( nTokenValue ); break;
- case RTF_COLSX: nColSpace = sal_uInt16( nTokenValue ); break;
- case RTF_COLNO:
- nAktCol = sal_uInt16( nTokenValue );
- if( RTF_COLW == GetNextToken() )
- {
- sal_uInt16 nWidth = sal_uInt16( nTokenValue ), nSpace = 0;
- if( RTF_COLSR == GetNextToken() )
- nSpace = sal_uInt16( nTokenValue );
- else
- SkipToken( -1 ); // wieder zurueck
-
- if( --nAktCol == ( aColumns.size() / 2 ) )
- {
- aColumns.push_back( nWidth + nSpace );
- aColumns.push_back( nSpace );
- }
- }
- break;
-
- case '{':
- {
- short nSkip = 0;
- if( RTF_IGNOREFLAG != ( nToken = GetNextToken() ))
- {
- if( RTF_SHADINGDEF == (nToken & ~0xff) )
- {
- ReadBackgroundAttr( nToken, aSet );
- GetNextToken(); // Klammer ueberlesen
- }
- else
- nSkip = -1;
- }
- else if( RTF_APOCTL ==
- ((nToken = GetNextToken() ) & ~(0xff | RTF_SWGDEFS)) )
- {
- bReadSwFly = true; // alles kommt in den akt. Fly
- SvxLRSpaceItem aLR( RES_LR_SPACE );
- SvxULSpaceItem aUL( RES_UL_SPACE );
- nCols = USHRT_MAX; // neu aufsetzen
- nColSpace = USHRT_MAX;
- do {
- nVal = sal_uInt16(nTokenValue);
- switch( nToken )
- {
- // Swg-Frame-Tokens
- case RTF_FLYPRINT:
- {
- pSet->Put( SvxPrintItem( RES_PRINT, sal_False ));
- }
- break;
- case RTF_FLYOPAQUE:
- {
- pSet->Put( SvxOpaqueItem( RES_OPAQUE, sal_False ));
- }
- break;
-
- case RTF_FLYPRTCTD:
- {
- RTFProtect aP( (sal_uInt8)nTokenValue );
- SvxProtectItem aProtectItem( RES_PROTECT );
- aProtectItem.SetCntntProtect( aP.GetCntnt() );
- aProtectItem.SetSizeProtect( aP.GetSize() );
- aProtectItem.SetPosProtect( aP.GetPos() );
- pSet->Put( aProtectItem );
- }
- break;
-
- case RTF_FLYMAINCNT:
- {
- RTFSurround aMC( (sal_uInt8)nTokenValue );
- SwFmtSurround aSurr( (SwSurround)aMC.GetOrder());
- if( aMC.GetGoldCut() )
- aSurr.SetSurround( SURROUND_IDEAL );
- pSet->Put( aSurr );
- }
- break;
- case RTF_FLYVERT:
- {
- RTFVertOrient aVO( nVal );
- aVert.SetVertOrient( aVO.GetOrient() );
- aVert.SetRelationOrient( aVO.GetRelation() );
- }
- break;
- case RTF_FLYHORZ:
- {
- RTFHoriOrient aHO( nVal );
- aHori.SetHoriOrient( aHO.GetOrient() );
- aHori.SetRelationOrient( aHO.GetRelation() );
- }
- break;
- case RTF_FLYOUTLEFT: aLR.SetLeft( nVal ); break;
- case RTF_FLYOUTRIGHT: aLR.SetRight( nVal ); break;
- case RTF_FLYOUTUPPER: aUL.SetUpper( nVal ); break;
- case RTF_FLYOUTLOWER: aUL.SetLower( nVal ); break;
- case RTF_FLYANCHOR:
- switch( GetNextToken() )
- {
- case RTF_FLY_PAGE:
- aAnchor.SetType( FLY_AT_PAGE );
- aAnchor.SetPageNum( sal_uInt16(nTokenValue));
- aAnchor.SetAnchor( 0 );
- break;
-
- case RTF_FLY_CNTNT:
- {
- SwNodeIndex aIdx( pPam->GetPoint()->nNode );
- pDoc->GetNodes().GoPrevious( &aIdx );
- SwPosition aPos( aIdx );
- aAnchor.SetType( FLY_AT_PARA );
- aAnchor.SetAnchor( &aPos );
- }
- break;
-
-// die Bindung an die Spalte gibt es nicht mehr !!
-// case RTF_FLY_COLUMN:
- }
- break;
- case RTF_COLS: nCols = sal_uInt16( nTokenValue ); break;
- case RTF_COLSX: nColSpace = sal_uInt16( nTokenValue ); break;
- case RTF_COLNO:
- nAktCol = sal_uInt16( nTokenValue );
- if( RTF_COLW == GetNextToken() )
- {
- sal_uInt16 nWidth = sal_uInt16( nTokenValue ), nSpace = 0;
- if( RTF_COLSR == GetNextToken() )
- nSpace = sal_uInt16( nTokenValue );
- else
- SkipToken( -1 ); // wieder zurueck
-
- if( --nAktCol == ( aColumns.size() / 2 ) )
- {
- aColumns.push_back( nWidth + nSpace );
- aColumns.push_back( nSpace );
- }
- }
- break;
-
- case '{':
- if( RTF_BRDBOX == ( nToken = GetNextToken() ) )
- ReadBorderAttr( nToken, aSet );
- else if( RTF_SHADINGDEF == (nToken & ~0xff ) )
- ReadBackgroundAttr( nToken, aSet );
- else if( RTF_IGNOREFLAG == nToken )
- {
- int bSkipGrp = sal_True;
- switch( nToken = GetNextToken() )
- {
- case RTF_SHADOW:
- case RTF_BRDBOX:
- ReadAttr( SkipToken( -2 ), &aSet );
- bSkipGrp = sal_False;
- break;
-
- case RTF_BRDRT:
- case RTF_BRDRB:
- case RTF_BRDRR:
- case RTF_BRDRL:
- bSkipGrp = sal_False;
- ReadBorderAttr( SkipToken( -2 ), aSet );
- break;
- }
-
- // keine weitere Klammer mehr ueberlesen!!!
- if( !bSkipGrp )
- break;
-
- SkipGroup();
- }
- else
- SkipGroup();
- GetNextToken(); // Klammer ueberlesen
- break;
- }
- } while( IsParserWorking() &&
- '}' != ( nToken = GetNextToken() ));
-
- if( aUL.GetUpper() || aUL.GetLower() )
- pSet->Put( aUL );
- if( aLR.GetLeft() || aLR.GetRight() )
- pSet->Put( aLR );
- }
- else if( RTF_BRDBOX == nToken )
- ReadBorderAttr( nToken, aSet );
- else if( RTF_SHADOW == nToken )
- ReadAttr( SkipToken( -2 ), &aSet );
- else if( RTF_SHADINGDEF == (nToken & ~0xff ) )
- ReadBackgroundAttr( nToken, aSet );
- else if( RTF_UNKNOWNCONTROL == nToken )
- SkipGroup();
- else
- nSkip = -2;
-
- if( nSkip )
- {
- nToken = SkipToken( nSkip );
- bWeiter = sal_False;
- }
- }
- break;
-
- default:
- --nAppliedProps; //Not sufficient to make a frame
- bWeiter = sal_False;
- }
-
- if( bWeiter )
- nToken = GetNextToken();
- } while( bWeiter && IsParserWorking() );
-
- pSet->Put( aAnchor );
- pSet->Put( aHori );
- pSet->Put( aVert );
-
- // #i27767# - set wrapping style influence
- // #i35017# - constant name has changed
- pSet->Put( SwFmtWrapInfluenceOnObjPos(
- text::WrapInfluenceOnPosition::ONCE_SUCCESSIVE ));
-
- SwFmtFollowTextFlow aFollowTextFlow( sal_False );
- pSet->Put( aFollowTextFlow );
-
- if( !( aFrmDir == pSet->Get( RES_FRAMEDIR )) )
- pSet->Put( aFrmDir );
-
- if( nCols && USHRT_MAX != nCols )
- {
- SwFmtCol aCol;
- if( USHRT_MAX == nColSpace )
- nColSpace = 720;
-
- sal_uLong nWidth = USHRT_MAX;
- aCol.Init( nCols, nColSpace, sal_uInt16( nWidth ) );
- if( nCols == ( aColumns.size() / 2 ) )
- {
- for( sal_uInt16 n = 0, i = 0; n < aColumns.size(); n += 2, ++i )
- {
- SwColumn* pCol = &aCol.GetColumns()[ i ];
- sal_uLong nTmp = aColumns[ n ];
- nTmp *= USHRT_MAX;
- nTmp /= nWidth;
- pCol->SetWishWidth( sal_uInt16(nTmp) );
- }
- }
- pSet->Put( aCol );
- }
-
- if( pSet != &aSet ) // wurde der Set uebergeben, dann wars das
- return ;
-
- // ein neues FlyFormat anlegen oder das alte benutzen ?
- // (teste ob es die selben Attribute besitzt!)
- SwFlySave* pFlySave = 0;
- sal_uInt16 nFlyArrCnt = aFlyArr.size();
- /*
- #i5263#
- There were not enough frame properties found to actually justify creating
- an absolutely positioned frame.
- */
- if (nAppliedProps)
- {
- if( !nFlyArrCnt ||
- !( pFlySave = aFlyArr[ nFlyArrCnt-1 ])->IsEqualFly( *pPam, aSet ))
- {
- pFlySave = new SwFlySave( *pPam, aSet );
- Size aPgSize;
- GetPageSize( aPgSize );
- pFlySave->nPageWidth = aPgSize.Width();
-
- if( nDropCapAnchor )
- {
- pFlySave->nDropAnchor = nDropCapAnchor;
- pFlySave->nDropLines = nDropCapLines;
- }
- if (nFlyArrCnt >0){
- SwFlySave* pFlySavePrev = aFlyArr[nFlyArrCnt-1];
- if (pFlySave->nSttNd.GetIndex() < pFlySavePrev->nEndNd.GetIndex())
- {
- pFlySavePrev->nEndNd=pFlySave->nSttNd;
- }
- }
- aFlyArr.push_back( pFlySave );
- nFlyArrCnt++;
- // #i83368# - reset
- mbReadCellWhileReadSwFly = false;
- }
- }
-
- SetPardTokenRead( sal_False );
- const SwTableNode* pTblNd = pPam->GetNode()->FindTableNode();
-
- while( !IsPardTokenRead() && IsParserWorking() )
- {
- if( RTF_PARD == nToken || nNumOpenBrakets > GetOpenBrakets() )
- break;
-
- NextToken( nToken );
-
- if( !IsPardTokenRead() )
- {
- // Added support for transparent frames.
- if (nToken == RTF_CBPAT && nFlyArrCnt > 0)
- {
- sal_uInt16 _index=sal_uInt16(nTokenValue);
- const Color& rColor = GetColor(_index);
- SvxBrushItem aBrush(rColor, RES_BACKGROUND);
- SwFlySave* pFS = aFlyArr[nFlyArrCnt-1];
- pFS->aFlySet.Put(aBrush, RES_BACKGROUND);
- }
-
- nToken = GetNextToken();
-
- // BUG 22036: kommt zwischen Fly-Attributen ein unbekanntes,
- // dann erzeuge nie 2 FlyFrames, sondern fasse
- // beide zusammen !!!
- while( RTF_APOCTL == ( nToken & ~(0xff | RTF_SWGDEFS) ))
- {
- if( RTF_FLY_INPARA == nToken )
- break;
-
- if( RTF_IGNOREFLAG == SkipToken( -1 ) )
- {
- if( '{' == SkipToken( -1 ) )
- nToken = '{';
- else
- SkipToken( 2 );
- }
- else
- SkipToken( 1 );
-
- ReadFly( nToken, pFlySave ? &pFlySave->aFlySet : 0);
- nToken = GetNextToken();
- }
- }
- }
-
- /*
- #i5263#
- There were enough frame properties found to actually justify creating
- an absolutely positioned frame.
- */
- if (!nAppliedProps)
- {
- bReadSwFly = false;
- SkipToken( -1 );
- return;
- }
-
- if( pTblNd && !pPam->GetPoint()->nContent.GetIndex() &&
- pTblNd->EndOfSectionIndex() + 1 ==
- pPam->GetPoint()->nNode.GetIndex() )
- {
- // nicht mehr in der Tabelle, sondern dahinter ?
- // Dann aber wieder zurueck in die Tabelle
- pPam->Move( fnMoveBackward );
- }
- else
- pTblNd = 0;
-
- // wurde garnichts eingefuegt?
- if( !pTblNd &&
- pPam->GetPoint()->nNode == pFlySave->nSttNd &&
- !pPam->GetPoint()->nContent.GetIndex() )
- {
- // dann zerstoere den FlySave wieder.
- delete aFlyArr[ --nFlyArrCnt ];
- aFlyArr.erase( aFlyArr.begin() + nFlyArrCnt );
-
- // Remove the properties that have been parsed before in the paragraph
- GetAttrStack().pop_back();
- }
- else
- {
- sal_Bool bMovePaM = 0 != pTblNd;
-
- pFlySave->nEndNd = pPam->GetPoint()->nNode;
- pFlySave->nEndCnt = pPam->GetPoint()->nContent.GetIndex();
-
- if( bMovePaM )
- pPam->Move( fnMoveForward );
-
- pTblNd = pFlySave->nSttNd.GetNode().FindTableNode();
- if( pTblNd && !pFlySave->nEndCnt &&
- pTblNd == pFlySave->nEndNd.GetNode().FindTableNode() )
- {
- // dann teste mal, ob das \pard nicht zu spaet kam und
- // eigentlich in die vorherige Zelle gehoert
- const SwStartNode* pSttBoxNd = pFlySave->nSttNd.GetNode().
- FindTableBoxStartNode(),
- * pEndBoxNd = pFlySave->nEndNd.GetNode().
- FindTableBoxStartNode();
- if( pSttBoxNd && pEndBoxNd &&
- bMovePaM ? ( pSttBoxNd == pEndBoxNd )
- : ( pSttBoxNd->EndOfSectionIndex() + 1 ==
- pEndBoxNd->GetIndex() &&
- pEndBoxNd->GetIndex() + 1 ==
- pFlySave->nEndNd.GetIndex() ))
- {
- // dann gehoert das Ende in die vorherige Box!
- SwPosition aPos( *pPam->GetPoint() );
- pPam->GetPoint()->nNode = *pSttBoxNd->EndOfSectionNode();
- pPam->Move( fnMoveBackward, fnGoNode );
-
- DelLastNode();
-
- pPam->GetPoint()->nNode = *pSttBoxNd->EndOfSectionNode();
- pPam->Move( fnMoveBackward, fnGoNode );
-
- pFlySave->nEndNd = pPam->GetPoint()->nNode;
- pFlySave->nEndCnt = pPam->GetPoint()->nContent.GetIndex();
-
- *pPam->GetPoint() = aPos;
- }
- }
- else if( !bReadSwFly && !pFlySave->nEndCnt &&
- pFlySave->nSttNd.GetIndex() + 1 == pFlySave->nEndNd.GetIndex() &&
- pFlySave->nSttNd.GetNode().IsTxtNode() )
- {
-
- SwTxtNode* pTxtNd = pFlySave->nSttNd.GetNode().GetTxtNode();
- SwTxtFlyCnt* pFlyCnt = 0;
- if( 1 == pTxtNd->GetTxt().Len() &&
- 0 != (pFlyCnt = static_cast<SwTxtFlyCnt*>(
- pTxtNd->GetTxtAttrForCharAt(0, RES_TXTATR_FLYCNT))) &&
- pFlyCnt->GetFlyCnt().GetFrmFmt() )
- {
- // then move the content into the surrounded fly
- SwFrmFmt* pFlyFmt = pFlyCnt->GetFlyCnt().GetFrmFmt();
- const SwNodeIndex* pFlySNd = pFlyFmt->GetCntnt().GetCntntIdx();
- SwNodeRange aRg( *pFlySNd, 1,
- *pFlySNd->GetNode().EndOfSectionNode(), 0 );
-
- // merge the itemsets
- SwFmtFrmSize aSz1( (SwFmtFrmSize&)pFlyFmt->GetAttrSet().
- Get( RES_FRM_SIZE ));
- SwFmtFrmSize aSz2( (SwFmtFrmSize&)pFlySave->aFlySet.
- Get( RES_FRM_SIZE ));
- // if
- if( !aRg.aStart.GetNode().IsNoTxtNode() ||
- !aSz1.GetHeight() || !aSz1.GetWidth() ||
- !aSz2.GetHeight() || !aSz2.GetWidth() ||
- ( aSz1.GetHeight() == aSz2.GetHeight() &&
- aSz1.GetWidth() == aSz2.GetWidth() ) )
- {
- SfxItemSet aDiffs( pFlyFmt->GetAttrSet() );
- aDiffs.ClearItem( RES_ANCHOR );
- aDiffs.ClearItem( RES_FRM_SIZE );
- aDiffs.ClearItem( RES_CNTNT );
- aDiffs.Differentiate( pFlySave->aFlySet );
- pFlySave->aFlySet.Put( aDiffs );
-
- sal_Bool bSet = sal_False;
- if( aSz1.GetHeight() && !aSz2.GetHeight() )
- {
- bSet = sal_True;
- aSz2.SetHeight( aSz1.GetHeight() );
- }
- if( aSz1.GetWidth() && !aSz2.GetWidth() )
- {
- bSet = sal_True;
- aSz2.SetWidth( aSz1.GetWidth() );
- }
- if( bSet )
- pFlySave->aFlySet.Put( aSz2 );
-
- // move any PageBreak/Desc Attr to the next Para
- {
- SwCntntNode* pSrcNd = pFlySave->nSttNd.GetNode().GetCntntNode();
- SwCntntNode* pDstNd = pFlySave->nEndNd.GetNode().GetCntntNode();
-
- ::lcl_CpyBreakAttrs( pSrcNd, pDstNd, &pFlySave->nEndNd );
- }
-
- // create new txtnode, because the section does never be empty
- pDoc->GetNodes().MakeTxtNode( aRg.aStart,
- (SwTxtFmtColl*)pDoc->GetDfltTxtFmtColl() );
-
- SwNodeIndex aTmp( pFlySave->nSttNd, +1 );
- pDoc->MoveNodeRange( aRg, aTmp,
- IDocumentContentOperations::DOC_MOVEDEFAULT );
-
- // now delete the redundant txtnode
- pDoc->GetNodes().Delete( pFlySave->nSttNd, 1 );
- }
- }
- }
- }
-
- bReadSwFly = false;
- SkipToken( -1 );
-}
-
-
-void SwRTFParser::InsPicture( const String& rGrfNm, const Graphic* pGrf,
- const SvxRTFPictureType* pPicType )
-{
- // kennzeichen fuer Swg-Dokumente:
- // (dann ist das FlyFmt fuer die Grafik!)
- SwGrfNode * pGrfNd;
- // #i83368# - Assure that graphic node is enclosed by fly frame node.
- if ( bReadSwFly && !mbReadCellWhileReadSwFly )
- {
- OSL_ENSURE(!aFlyArr.empty(),
- "SwRTFParser::InsPicture: fly array empty.");
- if (!aFlyArr.empty())
- {
- // erzeuge nur einen normalen GrafikNode und ersetze diesen gegen
- // den vorhandenen Textnode
- SwNodeIndex& rIdx = pPam->GetPoint()->nNode;
- pGrfNd = pDoc->GetNodes().MakeGrfNode( rIdx,
- rGrfNm, aEmptyStr, // Name der Graphic !!
- pGrf,
- (SwGrfFmtColl*)pDoc->GetDfltGrfFmtColl() );
-
- if( pGrfAttrSet )
- pGrfNd->SetAttr( *pGrfAttrSet );
-
- SwFlySave* pFlySave = aFlyArr[ aFlyArr.size()-1 ];
- pFlySave->nSttNd = rIdx.GetIndex() - 1;
-
- if( 1 < aFlyArr.size() )
- {
- pFlySave = aFlyArr[ aFlyArr.size() - 2 ];
- if( pFlySave->nEndNd == rIdx )
- pFlySave->nEndNd = rIdx.GetIndex() - 1;
- }
- }
- }
- else
- {
- // wenn normale RTF-Grafik, dann steht diese im Textfluss !
- SwAttrSet aFlySet( pDoc->GetAttrPool(), RES_OPAQUE, RES_ANCHOR );
- const SwPosition* pPos = pPam->GetPoint();
-
- SwFmtAnchor aAnchor( FLY_AS_CHAR );
- aAnchor.SetAnchor( pPos );
- aFlySet.Put( aAnchor );
- aFlySet.Put( SwFmtVertOrient( 0, text::VertOrientation::TOP ));
-
- if (pDoc->IsInHeaderFooter(pPos->nNode))
- {
- SvxOpaqueItem aOpaqueItem(RES_OPAQUE, sal_False);
- SwFmtSurround aSurroundItem(SURROUND_THROUGHT);
- aFlySet.Put(aOpaqueItem);
- aFlySet.Put(aSurroundItem);
- }
-
- SwFlyFrmFmt* pFlyFmt = pDoc->Insert( *pPam,
- rGrfNm, aEmptyStr, // Name der Graphic !!
- pGrf,
- &aFlySet, // Attribute fuer den FlyFrm
- pGrfAttrSet, NULL ); // Attribute fuer die Grafik
-
- pGrfNd = pDoc->GetNodes()[ pFlyFmt->GetCntnt().GetCntntIdx()->
- GetIndex()+1 ]->GetGrfNode();
-
- _SetPictureSize( *pGrfNd, pPos->nNode,
- (SfxItemSet&)pFlyFmt->GetAttrSet(),
- pPicType );
- if( pPicType )
- {
- PictPropertyNameValuePairs::const_iterator aIt = pPicType->aPropertyPairs.begin();
- PictPropertyNameValuePairs::const_iterator aEnd = pPicType->aPropertyPairs.end();
- while( aIt != aEnd)
- {
- if( aIt->first == "wzDescription" )
- {
- SwXFrame::GetOrCreateSdrObject( pFlyFmt );
- pDoc->SetFlyFrmDescription( *(pFlyFmt), aIt->second );
- }
- else if( aIt->first == "wzName" )
- {
- SwXFrame::GetOrCreateSdrObject( pFlyFmt );
- pDoc->SetFlyFrmTitle( *(pFlyFmt), aIt->second );
- }
- ++aIt;
- }
- }
-
- }
-
- if( pGrfAttrSet )
- DELETEZ( pGrfAttrSet );
-}
-
-void SwRTFParser::_SetPictureSize( const SwNoTxtNode& rNd,
- const SwNodeIndex& rAnchor,
- SfxItemSet& rSet,
- const SvxRTFPictureType* pPicType )
-{
- Size aSize( ((SwNoTxtNode&)rNd).GetTwipSize() );
- if( pPicType )
- {
- if( rNd.IsGrfNode() )
- {
- if( SvxRTFPictureType::WIN_METAFILE != pPicType->eStyle &&
- pPicType->nGoalWidth && pPicType->nGoalHeight )
- {
- aSize.Width() = pPicType->nGoalWidth;
- aSize.Height() =pPicType->nGoalHeight;
- }
- else if( SvxRTFPictureType::MAC_QUICKDRAW == pPicType->eStyle )
- {
- // IMMER auf 72 DPI bezogen, also 1pt == 20 Twip !!
- aSize.Width() = pPicType->nWidth * 20;
- aSize.Height() = pPicType->nHeight * 20;
- }
- else
- {
- // von 100TH_MM nach TWIP umrechenen!
- // When \picwgoal resp \pichgoal are present, then use them.
- // The values of \picwgoal and \picwgoal are already given in twips.
- aSize.Width() = (pPicType->nGoalWidth?pPicType->nGoalWidth:(pPicType->nWidth*144)/254);
- aSize.Height() = (pPicType->nGoalHeight?pPicType->nGoalHeight:(pPicType->nHeight*144)/254);
- }
- ((SwGrfNode&)rNd).SetTwipSize( aSize );
- }
-
- if( 100 != pPicType->nScalX )
- aSize.Width() = (((long)pPicType->nScalX) * ( aSize.Width() -
- ( pPicType->nCropL + pPicType->nCropR ))) / 100L;
-
- if( 100 != pPicType->nScalY )
- aSize.Height() = (((long)pPicType->nScalY) * ( aSize.Height() -
- ( pPicType->nCropT + pPicType->nCropB ))) / 100L;
- }
-
- //steht der Fly etwa in einer Tabelle ?
- const SwNode* pAnchorNd = & rAnchor.GetNode();
- const SwTableNode* pTblNd = pAnchorNd->FindTableNode();
- if( pTblNd )
- {
- // Box feststellen:
- const SwTableBox* pBox = pTblNd->GetTable().GetTblBox(
- pAnchorNd->StartOfSectionIndex() );
- if( pBox )
- {
- long nBoxWidth = pBox->GetFrmFmt()->GetFrmSize().GetWidth();
- if( aSize.Width() > nBoxWidth )
- aSize.Width() = nBoxWidth;
- }
- }
-
- // if no size exist, then the size is set by the swapin of the graphic.
- SwGrfNode* pGrfNd;
- if( !aSize.Width() && !aSize.Height() &&
- 0 != (pGrfNd = (SwGrfNode*)rNd.GetGrfNode() ) && pGrfNd->IsGrfLink() )
- pGrfNd->SetChgTwipSize( sal_True );
-
- // min. Werte einhalten !!
- if( aSize.Width() < MINFLY )
- aSize.Width() = MINFLY;
- if( aSize.Height() < MINFLY)
- aSize.Height() = MINFLY;
-
- if( pPicType )
- {
- sal_Bool bChg = sal_False;
- SwCropGrf aCrop;
-
- if( pPicType->nCropT )
- {
- aCrop.SetTop( pPicType->nCropT );
- bChg = sal_True;
- }
- if( pPicType->nCropB )
- {
- aCrop.SetBottom( pPicType->nCropB );
- bChg = sal_True;
- }
- if( pPicType->nCropL )
- {
- aCrop.SetLeft( pPicType->nCropL );
- bChg = sal_True;
- }
- if( pPicType->nCropR )
- {
- aCrop.SetRight( pPicType->nCropR );
- bChg = sal_True;
- }
-
- if( bChg )
- {
- // dann mal an die CropWerte an die GrafikSize anpassen.
- ((SwNoTxtNode&)rNd).SetAttr( aCrop );
- }
- }
- rSet.Put( SwFmtFrmSize( ATT_FIX_SIZE, aSize.Width(), aSize.Height() ));
-}
-
-void SwRTFParser::GetPageSize( Size& rSize )
-{
- OSL_ENSURE(!maSegments.empty(), "not possible");
- if (maSegments.empty())
- {
- rSize.Width() = 12240 - 1800 - 1800;
- rSize.Height() = 15840 - 1440 - 1440;
- return;
- }
-
- const rtfSection &rSect = maSegments.back();
-
- rSize.Width() = rSect.maPageInfo.mnPgwsxn - rSect.maPageInfo.mnMarglsxn - rSect.maPageInfo.mnMargrsxn;
- rSize.Height() = rSect.maPageInfo.mnPghsxn - rSect.maPageInfo.mnMargtsxn - rSect.maPageInfo.mnMargbsxn;
-
- long nCols = rSect.NoCols();
- if (1 < nCols)
- {
- rSize.Width() /= nCols;
- rSize.Height() /= nCols;
- }
-}
-
-void SwRTFParser::ReadBitmapData()
-{
- Graphic aGrf;
- SvxRTFPictureType aPicType;
- if( ReadBmpData( aGrf, aPicType ) )
- InsPicture( aEmptyStr, &aGrf, &aPicType );
-}
-
-#ifdef READ_OLE_OBJECT
-void SwRTFParser::ReadOLEData()
-{
- SvCacheStream aTmpFile( 0xA000 );
- Graphic aGrf;
- SvxRTFPictureType aPicType, aOleType;
-
- int nToken, bValidOle = sal_True, bWeiter = sal_True;
- int nOpenBrakets = 1; // die erste wurde schon vorher erkannt !!
-
- String* pStr = 0;
- String sObjClass, sObjName, sObjData;
-
- while( nOpenBrakets && IsParserWorking() && bWeiter && bValidOle )
- {
- nToken = GetNextToken();
- sal_uInt16 nVal = sal_uInt16( nTokenValue );
- switch( nToken )
- {
- case '}': --nOpenBrakets; pStr = 0; break;
- case '{':
- {
- if( RTF_IGNOREFLAG != GetNextToken() )
- nToken = SkipToken( -1 );
- else if( RTF_UNKNOWNCONTROL != GetNextToken() )
- nToken = SkipToken( -2 );
- else
- {
- // gleich herausfiltern
- ReadUnknownData();
- nToken = GetNextToken();
- if( '}' != nToken )
- eState = SVPAR_ERROR;
- break;
- }
- ++nOpenBrakets;
- }
- break;
-
- case RTF_OBJECT:
- case RTF_OBJEMB: // default ist embedded
- case RTF_LINKSELF: // ??
- case RTF_OBJLOCK: // ??
- case RTF_OBJUPDATE: // ??
- case RTF_OBJTIME: // ??
- case RTF_OBJSETSIZE:
- case RTF_OBJALIGN:
- case RTF_OBJTRANSY:
- case RTF_OBJATTPH:
- break;
-
- case RTF_OBJLINK: // ?? welche Daten sind das ??
- case RTF_OBJAUTLINK: // ?? -""- ??
- case RTF_OBJSUB:
- case RTF_OBJPUB:
- case RTF_OBJICEMB:
- case RTF_OBJOCX:
- case RTF_OBJHTML:
- case RTF_OBJALIAS:
- case RTF_OBJSECT:
- bValidOle = sal_False; // diese Typen koennen wir nicht
- break;
-
- case RTF_OBJCLASS:
- // Daten lesen
- pStr = &sObjClass;
- break;
-
- case RTF_OBJNAME:
- // Daten lesen
- pStr = &sObjName;
- break;
-
- case RTF_OBJDATA:
- pStr = &sObjData;
- break;
-
- case RTF_RESULT:
- {
- // hier weitermachen, wenn das OLE-Object ungueltig ist
- bWeiter = sal_False;
- }
- break;
- case RTF_RSLTBMP: // diese sollten wir ignorieren
- case RTF_RSLTMERGE:
- case RTF_RSLTPICT:
- case RTF_RSLTRTF:
- case RTF_RSLTTXT:
- break;
-
- case RTF_OBJW: aOleType.nWidth = nVal; break;
- case RTF_OBJH: aOleType.nHeight = nVal; break;
- case RTF_OBJCROPT: aOleType.nCropT = (short)nTokenValue; break;
- case RTF_OBJCROPB: aOleType.nCropB = (short)nTokenValue; break;
- case RTF_OBJCROPL: aOleType.nCropL = (short)nTokenValue; break;
- case RTF_OBJCROPR: aOleType.nCropR = (short)nTokenValue; break;
- case RTF_OBJSCALEX: aOleType.nScalX = nVal; break;
- case RTF_OBJSCALEY: aOleType.nScalY = nVal; break;
-
- case RTF_TEXTTOKEN:
- if( 1 < nOpenBrakets && pStr )
- {
- if( pStr == &sObjData )
- {
- xub_StrLen nHexLen = HexToBin( aToken );
- if( STRING_NOTFOUND != nHexLen )
- bValidOle = sal_False;
- else
- {
- aTmpFile.Write( (sal_Char*)aToken.GetBuffer(), nHexLen );
- bValidOle = 0 == aTmpFile.GetError();
- }
- }
- else
- *pStr += aToken;
- }
- break;
- }
- }
-
- if( bValidOle )
- {
- bValidOle = sal_False; // erstmal
- }
-
- if( !bWeiter ) // dann stehen wir noch im Result
- {
- // ist das Ole-Object Ok?
- // -> dann solange SkipGroup rufen, bis zur letzten
- // schliessenden Klammer
- // ansonsten alle Token verarbeiten, bis zur letzten
- // schliessenden Klammer
-
- bWeiter = sal_True;
- while( nOpenBrakets && IsParserWorking() && bWeiter )
- {
- switch( nToken = GetNextToken() )
- {
- case '}': --nOpenBrakets; break;
- case '{': ++nOpenBrakets; break;
- }
- if( nOpenBrakets && !bValidOle )
- NextToken( nToken );
- }
- }
-
- if( !bValidOle && '}' != nToken )
- SkipGroup();
-
- SkipToken( -1 ); // die schliesende Klammer wird "oben" ausgewertet
-}
-#endif
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/rtf/rtfnum.cxx b/sw/source/filter/rtf/rtfnum.cxx
index c22a85cbced4..54f47b95ac86 100644
--- a/sw/source/filter/rtf/rtfnum.cxx
+++ b/sw/source/filter/rtf/rtfnum.cxx
@@ -50,18 +50,6 @@
#define RTF_NUMRULE_NAME "RTF_Num"
-static void lcl_ExpandNumFmts( SwNumRule& rRule )
-{
- // dann noch das NumFormat in alle Ebenen setzen
- for( sal_uInt8 n = 1; n < MAXLEVEL; ++n )
- if( !rRule.GetNumFmt( n ) )
- {
- SwNumFmt aNumFmt( rRule.Get( 0 ));
- aNumFmt.SetIndentAt( aNumFmt.GetIndentAt() * ( n + 1 ) );
- rRule.Set( n, aNumFmt );
- }
-}
-
SfxItemSet& GetNumChrFmt( SwDoc& rDoc, SwNumRule& rRule, sal_uInt8 nNumLvl )
{
SwCharFmt* pChrFmt = rRule.Get( nNumLvl ).GetCharFmt();
@@ -77,990 +65,4 @@ SfxItemSet& GetNumChrFmt( SwDoc& rDoc, SwNumRule& rRule, sal_uInt8 nNumLvl )
return (SfxItemSet&)pChrFmt->GetAttrSet();
}
-void SwRTFParser::ReadListLevel( SwNumRule& rRule, sal_uInt8 nNumLvl )
-{
- int nToken;
- int nNumOpenBrakets = 1; // die erste wurde schon vorher erkannt !!
- int nLvlTxtLevel = 0, nLvlNumberLevel = 0;
- String sLvlText, sLvlNumber;
- SwNumFmt* pCurNumFmt;
- SvxNumberFormat::LabelFollowedBy eFollowedBy = SvxNumberFormat::NOTHING;
-
- if( MAXLEVEL >= nNumLvl )
- {
- pCurNumFmt = (SwNumFmt*)rRule.GetNumFmt( nNumLvl );
- pCurNumFmt->SetIndentAt( 0 );
- pCurNumFmt->SetFirstLineIndent( 0 );
- }
- else
- pCurNumFmt = 0;
-
- while( nNumOpenBrakets && IsParserWorking() )
- {
- switch( ( nToken = GetNextToken() ))
- {
- case '}':
- if( nNumOpenBrakets )
- {
- if( nLvlTxtLevel == nNumOpenBrakets )
- {
- if( DelCharAtEnd( sLvlText, ';' ).Len() &&
- sLvlText.Len() && sLvlText.Len() ==
- (sal_uInt16)(sLvlText.GetChar( 0 )) + 1 )
- sLvlText.Erase( 0, 1 );
- nLvlTxtLevel = 0;
- }
- if( nLvlNumberLevel == nNumOpenBrakets )
- {
- DelCharAtEnd( sLvlNumber, ';' );
- nLvlNumberLevel = 0;
- }
- }
- --nNumOpenBrakets;
- break;
-
- case '{':
- {
- if( RTF_IGNOREFLAG != GetNextToken() )
- nToken = SkipToken( -1 );
- // Unknown und alle bekannten nicht ausgewerteten Gruppen
- // sofort ueberspringen
- else if( RTF_UNKNOWNCONTROL != ( nToken = GetNextToken() ))
- nToken = SkipToken( -2 );
- else
- {
- // gleich herausfiltern
- ReadUnknownData();
- nToken = GetNextToken();
- if( '}' != nToken )
- eState = SVPAR_ERROR;
- break;
- }
- ++nNumOpenBrakets;
- }
- break;
-
- case RTF_LEVELNFC:
- {
- sal_Int16 eType = SVX_NUM_ARABIC;
- switch( nTokenValue )
- {
- case 1: eType = SVX_NUM_ROMAN_UPPER; break;
- case 2: eType = SVX_NUM_ROMAN_LOWER; break;
- case 3: eType = SVX_NUM_CHARS_UPPER_LETTER_N; break;
- case 4: eType = SVX_NUM_CHARS_LOWER_LETTER_N; break;
- case 255:
- case 23: eType = SVX_NUM_CHAR_SPECIAL; break;
- }
- if( pCurNumFmt )
- pCurNumFmt->SetNumberingType(eType);
- }
- break;
-
- case RTF_LEVELJC:
- {
- SvxAdjust eAdj = SVX_ADJUST_LEFT;
- switch( nTokenValue )
- {
- case 1: eAdj = SVX_ADJUST_CENTER; break;
- case 2: eAdj = SVX_ADJUST_RIGHT; break;
- }
- if( pCurNumFmt )
- pCurNumFmt->SetNumAdjust( eAdj );
- }
- break;
-
- case RTF_LEVELSTARTAT:
- if( pCurNumFmt && -1 != nTokenValue )
- pCurNumFmt->SetStart( sal_uInt16( nTokenValue ));
- break;
-
- case RTF_LEVELTEXT:
- nLvlTxtLevel = nNumOpenBrakets;
- break;
-
- case RTF_LEVELNUMBERS:
- nLvlNumberLevel = nNumOpenBrakets;
- break;
-
-
- case RTF_TEXTTOKEN:
- if( nLvlTxtLevel == nNumOpenBrakets )
- sLvlText += aToken;
- else if( nLvlNumberLevel == nNumOpenBrakets )
- sLvlNumber += aToken;
- break;
-
- case RTF_LEVELFOLLOW:
- /* removed; waiting for swnum02 to be integrated! */
- switch (nTokenValue)
- {
- case 0:
- eFollowedBy = SvxNumberFormat::LISTTAB;
- break;
- case 1:
- eFollowedBy = SvxNumberFormat::SPACE;
- break;
- }
- break;
-
- case RTF_LEVELOLD:
- case RTF_LEVELPREV:
- case RTF_LEVELPREVSPACE:
- case RTF_LEVELINDENT:
- case RTF_LEVELSPACE:
- case RTF_LEVELLEGAL:
- case RTF_LEVELNORESTART:
- break;
-
- default:
- if( pCurNumFmt && (
- RTF_CHRFMT == (nToken & ~(0xff | RTF_SWGDEFS) ) ||
- RTF_PARFMT == (nToken & ~(0xff | RTF_SWGDEFS) ) ))
- {
- SfxItemSet aSet( pDoc->GetAttrPool(), aTxtNodeSetRange );
- // put the current CharFmtAttr into the set
- SfxItemSet& rCFmtSet = GetNumChrFmt( *pDoc, rRule, nNumLvl );
- aSet.Put( rCFmtSet );
- // and put the current "LRSpace" into the set
- {
- SvxLRSpaceItem aLR( RES_LR_SPACE );
- aLR.SetTxtLeft( pCurNumFmt->GetIndentAt() );
- aLR.SetTxtFirstLineOfst(pCurNumFmt->GetFirstLineIndent());
- aSet.Put( aLR );
- }
-
- ReadAttr( nToken, &aSet );
-
- //#i24880# Word appears to ignore char background for numbering
- aSet.ClearItem(RES_CHRATR_BACKGROUND);
-
- // put all CharFmt Items into the charfmt
- rCFmtSet.Put( aSet );
-
- // test for LRSpace Item. If exist then set all relevant
- // values on the numrule format
- const SfxPoolItem* pItem;
- if( SFX_ITEM_SET == aSet.GetItemState( RES_LR_SPACE,
- sal_False, &pItem ))
- {
- const SvxLRSpaceItem& rLR = *(SvxLRSpaceItem*)pItem;
- pCurNumFmt->SetListtabPos( rLR.GetTxtLeft( ) );
- pCurNumFmt->SetIndentAt( rLR.GetTxtLeft() );
- pCurNumFmt->SetFirstLineIndent( rLR.GetTxtFirstLineOfst());
- }
-
- // dann aus der Vorlage den Font holen
- if( SVX_NUM_CHAR_SPECIAL == pCurNumFmt->GetNumberingType() )
- pCurNumFmt->SetBulletFont( FindFontOfItem(
- pCurNumFmt->GetCharFmt()->GetFont() ) );
- }
- break;
- }
- }
-
- if( IsParserWorking() && pCurNumFmt )
- {
- // dann erzeuge mal die Pre/Postfix-Strings
- if( sLvlText.Len() &&
- SVX_NUM_CHAR_SPECIAL == pCurNumFmt->GetNumberingType() )
- {
- pCurNumFmt->SetBulletChar( sLvlText.GetChar( 0 ) );
- // dann aus der Vorlage den Font holen
- if( pCurNumFmt->GetCharFmt() )
- pCurNumFmt->SetBulletFont( FindFontOfItem(
- pCurNumFmt->GetCharFmt()->GetFont() ) );
- }
- else if( sLvlNumber.Len() && sLvlText.Len() )
- {
- // in sLvlText steht der Text, in sLvlNumber die Position
- // der Ebenen in sLvlText
- pCurNumFmt->SetPrefix(
- sLvlText.Copy( 0, sal_uInt16( sLvlNumber.GetChar( 0 ))-1 ));
- pCurNumFmt->SetSuffix( sLvlText.Copy(
- sal_uInt16( sLvlNumber.GetChar( sLvlNumber.Len()-1 )) ));
- // wieviele Levels stehen im String?
- pCurNumFmt->SetIncludeUpperLevels( (sal_uInt8)sLvlNumber.Len() );
- }
- else
- {
- pCurNumFmt->SetNumberingType(SVX_NUM_NUMBER_NONE);
- pCurNumFmt->SetSuffix( sLvlText );
- }
-
- /* removed; waiting for swnum02 to be integrated!*/
- pCurNumFmt->SetLabelFollowedBy( eFollowedBy );
- if (eFollowedBy == SvxNumberFormat::LISTTAB && !pCurNumFmt->IsItemize())
- {
- pCurNumFmt->SetIndentAt(0);
- pCurNumFmt->SetFirstLineIndent(0);
- }
- }
-
- SkipToken( -1 );
-}
-
-void SwRTFParser::ReadListTable()
-{
- int nToken;
- int nNumOpenBrakets = 1; // die erste wurde schon vorher erkannt !!
- bNewNumList = sal_True;
-
- sal_uInt8 nNumLvl = 0;
- SwNumRule* pCurRule = 0;
- SwListEntry aEntry;
-
- while( nNumOpenBrakets && IsParserWorking() )
- {
- switch( ( nToken = GetNextToken() ))
- {
- case '}': if( --nNumOpenBrakets && IsParserWorking() )
- {
- // Style konnte vollstaendig gelesen werden,
- // also ist das noch ein stabiler Status
- SaveState( RTF_LISTTABLE );
- if( 1 == nNumOpenBrakets )
- {
- if( aEntry.nListId )
- aListArr.push_back( aEntry );
- aEntry.Clear();
- }
- }
- break;
-
- case '{':
- {
- if( RTF_IGNOREFLAG != GetNextToken() )
- nToken = SkipToken( -1 );
- // Unknown und alle bekannten nicht ausgewerteten Gruppen
- // sofort ueberspringen
- else if( RTF_UNKNOWNCONTROL != ( nToken = GetNextToken() ))
- nToken = SkipToken( -2 );
- else
- {
- // gleich herausfiltern
- ReadUnknownData();
- nToken = GetNextToken();
- if( '}' != nToken )
- eState = SVPAR_ERROR;
- break;
- }
- ++nNumOpenBrakets;
- }
- break;
-
- case RTF_LIST:
- {
- if( pCurRule && pCurRule->IsContinusNum() )
- lcl_ExpandNumFmts( *pCurRule );
-
- String sTmp(rtl::OUString(RTF_NUMRULE_NAME " 1"));
- aEntry.nListDocPos = pDoc->MakeNumRule( sTmp, 0, false, SvxNumberFormat::LABEL_ALIGNMENT );
- pCurRule = pDoc->GetNumRuleTbl()[ aEntry.nListDocPos ];
- // #i91400#
- pCurRule->SetName( pDoc->GetUniqueNumRuleName( &sTmp, false ),
- *pDoc );
-
- pCurRule->SetAutoRule( sal_False );
- nNumLvl = (sal_uInt8)-1;
- }
- break;
-
- case RTF_LISTID: aEntry.nListId = nTokenValue; break;
- case RTF_LISTTEMPLATEID: aEntry.nListTemplateId = nTokenValue; break;
-
- case RTF_LISTRESTARTHDN:
- break;
- case RTF_LISTNAME:
- if (nNextCh=='}') break; // empty listnames
- if( RTF_TEXTTOKEN == GetNextToken() )
- {
- String sTmp( DelCharAtEnd( aToken, ';' ));
- if( sTmp.Len() && !pDoc->FindNumRulePtr( sTmp ))
- {
- // #i91400#
- pCurRule->SetName( sTmp, *pDoc );
- }
- }
- SkipGroup();
- break;
-
- case RTF_LISTSIMPLE:
- pCurRule->SetContinusNum( sal_True );
- break;
-
- case RTF_LISTLEVEL:
- {
- if( ++nNumLvl < MAXLEVEL )
- pCurRule->Set( nNumLvl, pCurRule->Get( nNumLvl ));
- ReadListLevel( *pCurRule, nNumLvl );
- }
- break;
- }
- }
-
- if( pCurRule && pCurRule->IsContinusNum() )
- lcl_ExpandNumFmts( *pCurRule );
-
- SkipToken( -1 ); // die schliesende Klammer wird "oben" ausgewertet
-}
-
-static sal_Bool lcl_IsEqual( SwNumRule* pOrigRule, SwNumRule* pRule )
-{
- sal_Bool bRet = 0;
- if( pOrigRule && pRule )
- {
- bRet = pOrigRule->GetRuleType() == pRule->GetRuleType() &&
- pOrigRule->IsContinusNum() == pRule->IsContinusNum() &&
- pOrigRule->IsAbsSpaces() == pRule->IsAbsSpaces();
- if( bRet )
- for( sal_uInt8 n = 0; bRet && n < MAXLEVEL; ++n )
- {
- const SwNumFmt* pOFmt = pOrigRule->GetNumFmt( n ),
- * pFmt = pRule->GetNumFmt( n );
- if( pFmt && pOFmt )
- {
- SwCharFmt* pOCFmt = pOFmt->GetCharFmt(),
- * pCFmt = pFmt->GetCharFmt();
- if( pOCFmt && pCFmt )
- {
- bRet = 0 != (pCFmt->GetAttrSet() == pOCFmt->GetAttrSet());
- }
- else
- bRet = !pCFmt && !pOCFmt;
- if( bRet )
- {
- ((SwNumFmt*)pOFmt)->SetCharFmt( 0 );
- ((SwNumFmt*)pFmt)->SetCharFmt( 0 );
- bRet = *pOFmt == *pFmt;
- ((SwNumFmt*)pOFmt)->SetCharFmt( pOCFmt );
- ((SwNumFmt*)pFmt)->SetCharFmt( pCFmt );
- }
- }
- else
- bRet = !pFmt && !pOFmt;
- }
- }
- return bRet;
-}
-
-void SwRTFParser::ReadListOverrideTable()
-{
- int nToken;
- int nNumOpenBrakets = 1; // die erste wurde schon vorher erkannt !!
- SwListEntry aEntry;
- SwNumRule* pRule = 0, *pOrigRule = 0;
- sal_uInt8 nNumLvl = 0;
- sal_Bool bOverrideFormat = sal_False, bOverrideStart = sal_False;
-
- while( nNumOpenBrakets && IsParserWorking() )
- {
- switch( ( nToken = GetNextToken() ))
- {
- case '}':
- if( --nNumOpenBrakets && IsParserWorking() )
- {
- // Style konnte vollstaendig gelesen werden,
- // also ist das noch ein stabiler Status
- SaveState( RTF_LISTOVERRIDETABLE );
-
- if( 1 == nNumOpenBrakets )
- {
- bOverrideFormat = sal_False, bOverrideStart = sal_False;
- if( pRule )
- {
- if( lcl_IsEqual( pOrigRule, pRule ))
- {
- // no changes on the rule -> use the original rule
- aEntry.nListDocPos = pDoc->FindNumRule(
- pOrigRule->GetName() );
- // delete the temp Rule
- RemoveUnusedNumRule( pRule );
- }
- else if( pRule->IsContinusNum() )
- lcl_ExpandNumFmts( *pRule );
- }
-
- if( aEntry.nListId && aEntry.nListNo )
- {
- int nMatch=-1;
- for( size_t n = aListArr.size(); n; )
- {
- if( aListArr[ --n ].nListId == aEntry.nListId)
- {
- nMatch=n;
- break;
- }
- }
- if(nMatch>=0)
- {
- sal_uInt16 nMatch2 = static_cast< sal_uInt16 >(nMatch);
- if (!aListArr[nMatch2].nListNo )
- {
- aListArr[nMatch2].nListNo = aEntry.nListNo;
- }
- else
- {
- aEntry.nListDocPos=aListArr[nMatch2].nListDocPos;
- aEntry.nListTemplateId=aListArr[nMatch2].nListTemplateId;
- aListArr.push_back( aEntry );
- }
- if(pOrigRule)
- aListArr[nMatch2].nListDocPos = aEntry.nListDocPos;
- }
- }
- aEntry.Clear();
- pOrigRule = 0;
- pRule = 0;
- }
- }
- break;
-
- case '{':
- {
- if( RTF_IGNOREFLAG != GetNextToken() )
- nToken = SkipToken( -1 );
- // Unknown und alle bekannten nicht ausgewerteten Gruppen
- // sofort ueberspringen
- else if( RTF_UNKNOWNCONTROL != ( nToken = GetNextToken() ))
- nToken = SkipToken( -2 );
- else
- {
- // gleich herausfiltern
- ReadUnknownData();
- nToken = GetNextToken();
- if( '}' != nToken )
- eState = SVPAR_ERROR;
- break;
- }
- ++nNumOpenBrakets;
- }
- break;
-
- case RTF_LISTOVERRIDE: aEntry.Clear(); break;
- case RTF_LISTID: aEntry.nListId = nTokenValue; break;
- case RTF_LS: aEntry.nListNo = nTokenValue; break;
- case RTF_LISTOVERRIDECOUNT:
- if( nTokenValue )
- {
- pRule = 0;
- // dann erzeugen wir mal schnell eine Kopie von der NumRule,
- // denn diese wird jetzt mal kurz veraendert.
- if( aEntry.nListId )
- for( size_t n = 0; n < aListArr.size(); ++n )
- if( aListArr[ n ].nListId == aEntry.nListId )
- {
- pRule = pDoc->GetNumRuleTbl()[
- aListArr[ n ].nListDocPos ];
- pOrigRule = pRule;
-
- String sTmp(rtl::OUString(RTF_NUMRULE_NAME " 1"));
- aEntry.nListDocPos = pDoc->MakeNumRule( sTmp, pRule );
- pRule = pDoc->GetNumRuleTbl()[ aEntry.nListDocPos ];
- // #i91400#
- pRule->SetName( pDoc->GetUniqueNumRuleName( &sTmp, false ),
- *pDoc );
-
- pRule->SetAutoRule( sal_False );
- nNumLvl = (sal_uInt8)-1;
- aListArr.push_back( aEntry );
- break;
- }
-
- }
- break;
-
- case RTF_LISTLEVEL:
- if( pRule && bOverrideFormat )
- {
- if( ++nNumLvl < MAXLEVEL )
- pRule->Set( nNumLvl, pRule->Get( nNumLvl ));
- ReadListLevel( *pRule, nNumLvl );
- }
- break;
-
- case RTF_LEVELSTARTAT:
- if( pRule && bOverrideStart )
- {
- }
- break;
-
- case RTF_LISTOVERRIDESTART:
- bOverrideStart = sal_True;
- break;
-
- case RTF_LISTOVERRIDEFORMAT:
- bOverrideFormat = sal_True;
- break;
-
- case RTF_LFOLEVEL:
- // was fehlt noch?
- break;
- }
- }
-
- // search the outline numrule and set it into the doc
- if( !GetStyleTbl().empty() )
- {
- if( !bStyleTabValid )
- MakeStyleTab();
-
- const SfxPoolItem* pItem( 0 );
- std::map<sal_Int32,SwTxtFmtColl*>::const_iterator iterColl;
- sal_uInt16 nRulePos( USHRT_MAX );
- const SwNumRule *pNumRule = 0;
- for (SvxRTFStyleTbl::iterator it = GetStyleTbl().begin();
- it != GetStyleTbl().end(); ++it)
- {
- SvxRTFStyleType* pStyle = it->second;
- if ( MAXLEVEL > pStyle->nOutlineNo )
- {
- iterColl = aTxtCollTbl.find( it->first );
- if ( iterColl != aTxtCollTbl.end() )
- {
- const SfxItemState eItemState =
- iterColl->second->GetItemState( RES_PARATR_NUMRULE, sal_False, &pItem );
- if ( eItemState == SFX_ITEM_SET )
- {
- nRulePos = pDoc->FindNumRule( ((SwNumRuleItem*)pItem)->GetValue() );
- if ( nRulePos != USHRT_MAX )
- {
- pNumRule = pDoc->GetNumRuleTbl()[ nRulePos ];
- if ( pNumRule->IsAutoRule() &&
- pNumRule != pDoc->GetOutlineNumRule() )
- {
- pDoc->SetOutlineNumRule( *pNumRule );
- pDoc->DelNumRule( pNumRule->GetName() );
- // now pNumRule pointer is invalid !!!
-
- // now decrement all position in the listtable, which will
- // behind the doc-rule position
- for( size_t n = aListArr.size(); n; )
- {
- SwListEntry& rEntry = aListArr[ --n ];
- if( rEntry.nListDocPos == nRulePos )
- aListArr.erase( aListArr.begin()+n );
- else if( rEntry.nListDocPos > nRulePos )
- --rEntry.nListDocPos;
- }
- break;
- }
- }
- }
- }
- }
-
- pStyle->aAttrSet.ClearItem( FN_PARAM_NUM_LEVEL );
- }
- }
-
- SkipToken( -1 ); // die schliesende Klammer wird "oben" ausgewertet
-}
-
-SwNumRule* SwRTFParser::GetNumRuleOfListNo( long nListNo, sal_Bool bRemoveFromList )
-{
- SwNumRule* pRet = 0;
- SwListEntry* pEntry;
- for( size_t n = aListArr.size(); n; )
- if( ( pEntry = &aListArr[ --n ])->nListNo == nListNo )
- {
- if( bRemoveFromList )
- aListArr.erase( aListArr.begin()+n );
- else
- {
- pEntry->bRuleUsed = sal_True;
- pRet = pDoc->GetNumRuleTbl()[ pEntry->nListDocPos ];
- }
- break;
- }
- return pRet;
-}
-
-void SwRTFParser::RemoveUnusedNumRule( SwNumRule* pRule )
-{
- if( pRule )
- {
- for ( sal_uInt8 nLvl = 0; nLvl < MAXLEVEL; ++nLvl )
- {
- SwNumFmt& rNFmt = (SwNumFmt&)pRule->Get( nLvl );
- SwCharFmt* pCFmt = rNFmt.GetCharFmt();
- if( pCFmt )
- {
- rNFmt.ForgetCharFmt();
- if( !pCFmt->GetDepends() )
- pDoc->DelCharFmt( pCFmt );
- }
- }
- pDoc->DelNumRule( pRule->GetName() );
- }
-#if OSL_DEBUG_LEVEL > 0
- else
- {
- OSL_ENSURE( pRule, "NumRulePointer 0 kann nicht geloescht werden" );
- }
-#endif
-}
-
-void SwRTFParser::RemoveUnusedNumRules()
-{
- SwListEntry* pEntry;
- std::set<SwNumRule*> aDelArr;
- size_t n;
- for( n = aListArr.size(); n; )
- {
- if( !( pEntry = &aListArr[ --n ])->bRuleUsed )
- {
- // really *NOT* used by anyone else?
- sal_Bool unused=sal_True;
- for(size_t j = 0; j < aListArr.size(); ++j)
- {
- if (aListArr[n].nListNo==aListArr[j].nListNo)
- unused&=!aListArr[j].bRuleUsed;
- }
- if (unused)
- {
- SwNumRule* p = pDoc->GetNumRuleTbl()[pEntry->nListDocPos];
- // dont delete named char formats
- if( aDelArr.find( p ) == aDelArr.end() &&
- p->GetName().EqualsAscii( RTF_NUMRULE_NAME, 0,
- sizeof( RTF_NUMRULE_NAME )) )
- aDelArr.insert( p );
- }
- }
- }
-
- while( !aDelArr.empty() )
- {
- RemoveUnusedNumRule( *aDelArr.begin() );
- aDelArr.erase( aDelArr.begin() );
- }
-}
-
-const Font* SwRTFParser::FindFontOfItem( const SvxFontItem& rItem ) const
-{
- SvxRTFFontTbl& rFntTbl = ((SwRTFParser*)this)->GetFontTbl();
- for (SvxRTFFontTbl::iterator it = rFntTbl.begin(); it != rFntTbl.end(); ++it)
- {
- const Font* pFnt = it->second;
- if( pFnt->GetFamily() == rItem.GetFamily() &&
- pFnt->GetName() == rItem.GetFamilyName() &&
- pFnt->GetStyleName() == rItem.GetStyleName() &&
- pFnt->GetPitch() == rItem.GetPitch() &&
- pFnt->GetCharSet() == rItem.GetCharSet() )
- return pFnt;
- }
- return 0;
-}
-
-
-SwNumRule *SwRTFParser::ReadNumSecLevel( int nToken )
-{
- // lese die \pnseclvl - Gruppe
- // nTokenValue gibt schon den richtigen Level vor 1 - 9!
- sal_uInt8 nLevel = 0;
- long nListNo = 0;
- sal_Bool bContinus = sal_True;
-
- if( RTF_PNSECLVL == nToken )
- {
- // suche die Rule - steht unter Nummer 3
- nListNo = 3;
- bContinus = sal_False;
- nLevel = MAXLEVEL <= (unsigned long) nTokenValue ? MAXLEVEL - 1
- : (!nTokenValue ? 0 : sal_uInt8( nTokenValue - 1 ));
- }
- else
- {
- switch( nToken = GetNextToken() )
- {
- case RTF_PNLVL: nListNo = 3;
- bContinus = sal_False;
- nLevel = MAXLEVEL <= (unsigned long) nTokenValue
- ? MAXLEVEL - 1
- : (!nTokenValue ? 0 : sal_uInt8( nTokenValue-1 ));
- break;
-
- case RTF_PNLVLBODY:
- nListNo = 2;
- break;
- case RTF_PNLVLBLT:
- nListNo = 1;
- break;
- case RTF_PNLVLCONT:
- SkipGroup();
- return 0;
- default:
- SkipGroup();
- return 0;
- }
- }
-
- // suche die Rule - steht unter Nummer 3
- sal_uInt16 nNewFlag = static_cast< sal_uInt16 >(1 << nListNo);
- SwNumRule* pCurRule = GetNumRuleOfListNo( nListNo,
- 0 != ( nNewNumSectDef & nNewFlag ) );
- if( !pCurRule )
- {
- // dann muessen wir die mal anlegen
- nNewNumSectDef &= ~nNewFlag;
- String sTmp(rtl::OUString(RTF_NUMRULE_NAME " 1"));
- SwListEntry aEntry( nListNo, 0, pDoc->MakeNumRule( sTmp ));
- aEntry.nListNo = nListNo;
- aListArr.push_back( aEntry );
- pCurRule = pDoc->GetNumRuleTbl()[ aEntry.nListDocPos ];
- // #i91400#
- pCurRule->SetName( pDoc->GetUniqueNumRuleName( &sTmp, false ), *pDoc );
-
- pCurRule->SetAutoRule( sal_False );
- pCurRule->SetContinusNum( bContinus );
- }
-
- if( !pCurRule->GetNumFmt( nLevel ))
- pCurRule->Set( nLevel, pCurRule->Get( nLevel ));
- SwNumFmt* pCurNumFmt = (SwNumFmt*)pCurRule->GetNumFmt( nLevel );
- if( RTF_PNLVLBLT == nToken )
- pCurNumFmt->SetNumberingType(SVX_NUM_CHAR_SPECIAL);
- pCurNumFmt->SetSuffix( aEmptyStr );
- pCurNumFmt->SetPrefix( aEmptyStr );
- pCurNumFmt->SetNumberingType(SVX_NUM_NUMBER_NONE);
-
- if( bStyleTabValid && RTF_PNSECLVL != nToken )
- {
- // dann den akt. Lvl und Rule am Absatz setzen.
- // Dieses muss aber in den vorherigen "Kontext", sprich in den vor
- // der Klammer offenen Attrset. Darum das SetNewGroup davor und dahinter
- SetNewGroup( sal_False );
- GetAttrSet().Put( SfxUInt16Item( FN_PARAM_NUM_LEVEL, nLevel ));
- GetAttrSet().Put( SwNumRuleItem( pCurRule->GetName() ));
- SetNewGroup( sal_True );
- }
-
- FontUnderline eUnderline;
- int nNumOpenBrakets = 1; // die erste wurde schon vorher erkannt !!
- while( nNumOpenBrakets && IsParserWorking() )
- {
- switch( ( nToken = GetNextToken() ))
- {
- case '}':
- if( --nNumOpenBrakets && IsParserWorking() )
- {
- // Style konnte vollstaendig gelesen werden,
- // also ist das noch ein stabiler Status
- SaveState( RTF_PNSECLVL );
- }
- break;
-
- case '{':
- {
- if( RTF_IGNOREFLAG != GetNextToken() )
- nToken = SkipToken( -1 );
- // Unknown und alle bekannten nicht ausgewerteten Gruppen
- // sofort ueberspringen
- else if( RTF_UNKNOWNCONTROL != ( nToken = GetNextToken() ))
- nToken = SkipToken( -2 );
- else
- {
- // gleich herausfiltern
- ReadUnknownData();
- nToken = GetNextToken();
- if( '}' != nToken )
- eState = SVPAR_ERROR;
- break;
- }
- ++nNumOpenBrakets;
- }
- break;
-
- case RTF_PNCARD:
- case RTF_PNORD:
- case RTF_PNORDT:
- case RTF_PNDEC: pCurNumFmt->SetNumberingType(SVX_NUM_ARABIC); break;
- case RTF_PNUCLTR: pCurNumFmt->SetNumberingType(SVX_NUM_CHARS_UPPER_LETTER_N); break;
- case RTF_PNUCRM: pCurNumFmt->SetNumberingType(SVX_NUM_ROMAN_UPPER); break;
- case RTF_PNLCLTR: pCurNumFmt->SetNumberingType(SVX_NUM_CHARS_LOWER_LETTER_N); break;
- case RTF_PNLCRM: pCurNumFmt->SetNumberingType(SVX_NUM_ROMAN_LOWER); break;
-
- case RTF_PNF:
- {
- const Font& rSVFont = GetFont( sal_uInt16(nTokenValue) );
- GetNumChrFmt( *pDoc, *pCurRule, nLevel ).Put(
- SvxFontItem( rSVFont.GetFamily(),
- rSVFont.GetName(), rSVFont.GetStyleName(),
- rSVFont.GetPitch(), rSVFont.GetCharSet(),
- RES_CHRATR_FONT ));
- if( SVX_NUM_CHAR_SPECIAL == pCurNumFmt->GetNumberingType() )
- pCurNumFmt->SetBulletFont( &rSVFont );
- }
- break;
- case RTF_PNFS:
- {
- if( -1 == nTokenValue )
- nTokenValue = 240;
- else
- nTokenValue *= 10;
- GetNumChrFmt( *pDoc, *pCurRule, nLevel ).Put(
- SvxFontHeightItem( (const sal_uInt16)nTokenValue, 100, RES_CHRATR_FONTSIZE ));
- }
- break;
-
- case RTF_PNB:
- {
- GetNumChrFmt( *pDoc, *pCurRule, nLevel ).Put( SvxWeightItem(
- nTokenValue ? WEIGHT_BOLD : WEIGHT_NORMAL, RES_CHRATR_WEIGHT ));
- }
- break;
-
- case RTF_PNI:
- {
- GetNumChrFmt( *pDoc, *pCurRule, nLevel ).Put( SvxPostureItem(
- nTokenValue ? ITALIC_NORMAL : ITALIC_NONE, RES_CHRATR_POSTURE ));
- }
- break;
-
- case RTF_PNCAPS:
- case RTF_PNSCAPS:
- {
- GetNumChrFmt( *pDoc, *pCurRule, nLevel ).Put( SvxCaseMapItem(
- nTokenValue ? SVX_CASEMAP_KAPITAELCHEN
- : SVX_CASEMAP_NOT_MAPPED, RES_CHRATR_CASEMAP ));
- }
- break;
- case RTF_PNSTRIKE:
- {
- GetNumChrFmt( *pDoc, *pCurRule, nLevel ).Put( SvxCrossedOutItem(
- nTokenValue ? STRIKEOUT_SINGLE : STRIKEOUT_NONE, RES_CHRATR_CROSSEDOUT ));
- }
- break;
-
- case RTF_PNCF:
- {
- GetNumChrFmt( *pDoc, *pCurRule, nLevel ).Put( SvxColorItem(
- GetColor( sal_uInt16(nTokenValue) ), RES_CHRATR_COLOR ));
- }
- break;
-
-
- case RTF_PNUL:
- eUnderline = nTokenValue ? UNDERLINE_SINGLE : UNDERLINE_NONE;
- goto NUMATTR_SETUNDERLINE;
- case RTF_PNULD:
- eUnderline = UNDERLINE_DOTTED;
- goto NUMATTR_SETUNDERLINE;
- case RTF_PNULDB:
- eUnderline = UNDERLINE_DOUBLE;
- goto NUMATTR_SETUNDERLINE;
- case RTF_PNULNONE:
- eUnderline = UNDERLINE_NONE;
- goto NUMATTR_SETUNDERLINE;
- case RTF_PNULW:
- {
- GetNumChrFmt( *pDoc, *pCurRule, nLevel ).Put(
- SvxWordLineModeItem( sal_True, RES_CHRATR_WORDLINEMODE ));
- }
- eUnderline = UNDERLINE_SINGLE;
- goto NUMATTR_SETUNDERLINE;
-
-NUMATTR_SETUNDERLINE:
- {
- GetNumChrFmt( *pDoc, *pCurRule, nLevel ).Put(
- SvxUnderlineItem( eUnderline, RES_CHRATR_UNDERLINE ));
- }
- break;
-
- case RTF_PNINDENT:
- if( 0 > short( nTokenValue ) )
- nTokenValue = - (short)nTokenValue;
- pCurNumFmt->SetFirstLineIndent( - nTokenValue );
- pCurNumFmt->SetIndentAt( (nLevel + 1 ) * nTokenValue );
- break;
- case RTF_PNSP:
- pCurNumFmt->SetCharTextDistance( sal_uInt16( nTokenValue ));
- break;
-
- case RTF_PNPREV:
- if( nLevel )
- {
- sal_uInt8 nPrev = 2, nLast = nLevel;
- while( nLast && 1 < pCurRule->Get( --nLast ).GetIncludeUpperLevels() )
- ++nPrev;
- pCurNumFmt->SetIncludeUpperLevels( nPrev );
- }
- break;
-
- case RTF_PNQC: pCurNumFmt->SetNumAdjust( SVX_ADJUST_CENTER ); break;
- case RTF_PNQL: pCurNumFmt->SetNumAdjust( SVX_ADJUST_LEFT ); break;
- case RTF_PNQR: pCurNumFmt->SetNumAdjust( SVX_ADJUST_RIGHT ); break;
-
- case RTF_PNSTART:
- pCurNumFmt->SetStart( sal_uInt16( nTokenValue ));
- break;
-
- case RTF_PNNUMONCE:
- case RTF_PNACROSS:
- case RTF_PNHANG:
- case RTF_PNRESTART: break;
-
- case RTF_PNTXTA:
- {
- String sTmp;
- GetTextToEndGroup( sTmp );
- if( SVX_NUM_CHAR_SPECIAL == pCurNumFmt->GetNumberingType() )
- {
- pCurNumFmt->SetBulletChar( sTmp.GetChar( 0 ) );
- if( pCurNumFmt->GetCharFmt() )
- pCurNumFmt->SetBulletFont( FindFontOfItem(
- pCurNumFmt->GetCharFmt()->GetFont() ) );
- sTmp.Erase();
- }
- pCurNumFmt->SetSuffix( sTmp );
- }
- break;
-
- case RTF_PNTXTB:
- {
- String sTmp;
- pCurNumFmt->SetPrefix( GetTextToEndGroup( sTmp ) );
- }
- break;
- }
- }
-
- // falls vollstaendige Numerierung an ist und das Zeichen davor ein
- // Punkt ist, dann will RTF den Punkt als Trenner zwischen den Ebenen
- // haben - das haben wir aber schon als default
- if( 1 < pCurNumFmt->GetIncludeUpperLevels() &&
- 1 == pCurNumFmt->GetPrefix().getLength() &&
- '.' == pCurNumFmt->GetPrefix()[0] &&
- SVX_NUM_CHAR_SPECIAL != pCurNumFmt->GetNumberingType() )
- pCurNumFmt->SetPrefix( aEmptyStr );
-
- // falls das ein nicht numerierter Absatz mit ein Prefix-Text mit
- // einem Zeichen ist, dann setze den als Bulletzeichen
- if( pCurNumFmt->GetCharFmt() && SVX_NUM_NUMBER_NONE == pCurNumFmt->GetNumberingType() &&
- 3 == nListNo && 1 == pCurNumFmt->GetPrefix().getLength() )
- {
- SwCharFmt* pChFmt = pCurNumFmt->GetCharFmt();
- pCurNumFmt->SetNumberingType(SVX_NUM_CHAR_SPECIAL);
- pCurNumFmt->SetBulletFont( FindFontOfItem( pChFmt->GetFont() ) );
-
- pCurNumFmt->SetBulletChar( pCurNumFmt->GetPrefix()[0] );
- pCurNumFmt->SetPrefix( aEmptyStr );
-
- // den Font oder sogar das gesamte CharFormat loeschen?
- if( SFX_ITEM_SET == pChFmt->GetItemState( RES_CHRATR_FONT, sal_False ))
- {
- if( 1 == pChFmt->GetAttrSet().Count() )
- {
- pCurNumFmt->SetCharFmt( 0 );
- pDoc->DelCharFmt( pChFmt );
- }
- else
- pChFmt->ResetFmtAttr( RES_CHRATR_FONT );
- }
- }
-
- SkipToken( -1 ); // die schliesende Klammer wird "oben" ausgewertet
- return pCurRule;
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/rtf/rtftbl.cxx b/sw/source/filter/rtf/rtftbl.cxx
deleted file mode 100644
index ae920d449e7d..000000000000
--- a/sw/source/filter/rtf/rtftbl.cxx
+++ /dev/null
@@ -1,928 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-
-#include <hintids.hxx>
-#include <editeng/lrspitem.hxx>
-#include <editeng/boxitem.hxx>
-#include <editeng/frmdiritem.hxx>
-#include <svtools/rtftoken.h>
-#include <fmtfsize.hxx>
-#include <fmtpdsc.hxx>
-#include <ndtxt.hxx>
-#include <doc.hxx>
-#include <pam.hxx>
-#include <swparrtf.hxx>
-#include <swtable.hxx>
-#include <tblsel.hxx>
-#include <swtblfmt.hxx>
-#include <wrtswtbl.hxx>
-#include <tblenum.hxx>
-#include <frmatr.hxx>
-#include <fmtrowsplt.hxx>
-#include <vector>
-
-using namespace ::com::sun::star;
-
-typedef std::vector<SwTableBoxFmt*> SwBoxFrmFmts;
-
-class SwShareBoxFmts;
-extern void _DeleteBox( SwTable& rTbl, SwTableBox* pBox, SwUndo* = 0,
- bool = true, const bool = true, SwShareBoxFmts* = 0 );
-
-struct Row
-{
- bool mbUseLeftRowPad, mbUseRightRowPad, mbUseTopRowPad, mbUseBottomRowPad;
- long mnLeftRowPad, mnRightRowPad, mnTopRowPad, mnBottomRowPad;
- sal_uInt16 mnBrdDist;
- Row() :
- mbUseLeftRowPad(false), mbUseRightRowPad(false),
- mbUseTopRowPad(false), mbUseBottomRowPad(false),
- mnLeftRowPad(0), mnRightRowPad(0), mnTopRowPad(0), mnBottomRowPad(0),
- mnBrdDist(MIN_BORDER_DIST)
- {}
-};
-
-static void SetRowBorder(SfxItemSet& rSet, const Row &rRow)
-{
- SvxBoxItem aBox((const SvxBoxItem&)rSet.Get(RES_BOX, false));
- aBox.SetDistance( static_cast< sal_uInt16 >(rRow.mbUseLeftRowPad ? rRow.mnLeftRowPad : rRow.mnBrdDist),
- BOX_LINE_LEFT);
-
- aBox.SetDistance( static_cast< sal_uInt16 >(rRow.mbUseRightRowPad ? rRow.mnRightRowPad : rRow.mnBrdDist),
- BOX_LINE_RIGHT);
-
- aBox.SetDistance( static_cast< sal_uInt16 >(rRow.mbUseTopRowPad ? rRow.mnTopRowPad : 0),
- BOX_LINE_TOP);
-
- aBox.SetDistance( static_cast< sal_uInt16 >(rRow.mbUseBottomRowPad ? rRow.mnBottomRowPad : 0),
- BOX_LINE_BOTTOM);
-
- rSet.Put(aBox);
-}
-
-void rtfSections::PrependedInlineNode(const SwPosition &rPos,
- const SwNode &rNode)
-{
- OSL_ENSURE(!mrReader.IsNewDoc() || !maSegments.empty(),
- "should not be possible, must be at least one segment in a new document");
- if ((!maSegments.empty()) && (maSegments.back().maStart == rPos.nNode))
- maSegments.back().maStart = SwNodeIndex(rNode);
-}
-
-bool SwRTFParser::IsBorderToken(int nToken)
-{
- /*
- i30222 i28983
- Our ability to sense border tokens is broken rtftoken.h is
- organised in a way that ignores some border tokens. ReadBorderAttr
- still doesn't support the more exotic borders but at least this
- won't cause the parser to prematuerely exit the table
- */
- bool bResult = false;
-
- bResult = (nToken >= RTF_BRDRDASHD && nToken <= RTF_BRDRTHTNMG) ||
- (nToken >= RTF_BRDRTNTHSG && nToken <= RTF_BRDRWAVY);
-
- return bResult;
-}
-
-void SwRTFParser::ReadTable( int nToken )
-{
- nInsTblRow = USHRT_MAX;
-
- if (CantUseTables())
- {
- // alle Tabellen-Tokens ueberlesen
- nToken = GetNextToken(); // RTF_TROWD ueberlesen
- do {
- if( RTF_TABLEDEF != (nToken & ~(0xff | RTF_SWGDEFS)) &&
- RTF_UNKNOWNCONTROL != nToken )
- {
- SkipToken( -1 );
- break;
- }
- nToken = GetNextToken();
- } while( IsParserWorking() );
- return ;
- }
-
- // verhinder Tabelle in Tabelle/Footnote
- SwTwips nTblSz = 0;
- int bReadNewCell = sal_False, bChkExistTbl = sal_False;
-
-
- enum Limits {eMAXCELLS=64000};
-
- std::vector<bool> aMergeBackup(aMergeBoxes);
-
- // kein TROWD aber ein TabellenToken -> zwischen TROWD und Tab.Token
- // waren andere Zeichen (siehe Bug 27445.rtf)
- if( RTF_TROWD == nToken || !pTableNode )
- {
- if( RTF_TROWD == nToken )
- nToken = GetNextToken(); // RTF_TROWD ueberlesen
-
- // Flag for delete merged boxes
- aMergeBoxes.clear();
- aMergeBoxes.push_back(false);
- m_nCurrentBox = 0;
-
- // wenn schon in einer Tabellen, dann splitte oder benutze
- // die bisherigen Boxen weiter
- bChkExistTbl = 0 != pPam->GetPoint()->nNode.GetNode().FindTableNode();
- }
- else
- {
- bReadNewCell = sal_True;
- SwTableLines& rLns = pTableNode->GetTable().GetTabLines();
- SwTableLine* pLine = rLns.back();
- // very robust to avoid crashes like bug 127425 + crash reports 118743
- if( pLine )
- {
- sal_uInt16 nTmpBox = m_nCurrentBox;
- if( nTmpBox > pLine->GetTabBoxes().size() )
- nTmpBox = pLine->GetTabBoxes().size();
-
- for (sal_uInt16 n = nTmpBox; n; )
- {
- const SwTableBox *pTmp = pLine->GetTabBoxes()[ --n ];
- if( pTmp )
- {
- const SwFrmFmt* pTmpFmt = pTmp->GetFrmFmt();
- if( pTmpFmt )
- nTblSz += pTmpFmt->GetFrmSize().GetWidth();
- }
- }
- }
- }
-
-
- sal_Int16 eAdjust = text::HoriOrientation::LEFT; // default fuer Tabellen
- SwTwips nLSpace = 0;
- Row aRow;
-
- bool bUseLeftCellPad = false, bUseRightCellPad = false,
- bUseTopCellPad = false, bUseBottomCellPad = false;
- long nLeftCellPad = 0, nRightCellPad = 0, nTopCellPad = 0,
- nBottomCellPad = 0;
-
- sal_Int16 eVerOrient = text::VertOrientation::NONE;
- long nLineHeight = 0;
- if (aMergeBoxes.empty()) // can this actually happen?
- {
- OSL_ASSERT(false);
- aMergeBoxes.push_back(sal_False);
- }
- SwBoxFrmFmts aBoxFmts;
- SwTableBoxFmt* pBoxFmt = pDoc->MakeTableBoxFmt();
- SvxFrameDirection eDir = FRMDIR_HORI_LEFT_TOP;
- bool bCantSplit = false;
-
- int bWeiter = sal_True;
- do {
- switch( nToken )
- {
- case RTF_TRPADDFL:
- aRow.mbUseLeftRowPad = (nTokenValue == 3) ? true : false;
- break;
- case RTF_TRPADDFT:
- aRow.mbUseTopRowPad = (nTokenValue == 3) ? true : false;
- break;
- case RTF_TRPADDFR:
- aRow.mbUseRightRowPad = (nTokenValue == 3) ? true : false;
- break;
- case RTF_TRPADDFB:
- aRow.mbUseBottomRowPad = (nTokenValue == 3) ? true : false;
- break;
- case RTF_TRPADDL:
- aRow.mnLeftRowPad = nTokenValue;
- break;
- case RTF_TRPADDT:
- aRow.mnTopRowPad = nTokenValue;
- break;
- case RTF_TRPADDR:
- aRow.mnRightRowPad = nTokenValue;
- break;
- case RTF_TRPADDB:
- aRow.mnBottomRowPad = nTokenValue;
- break;
-
- case RTF_CLPADFL:
- bUseLeftCellPad = (nTokenValue == 3) ? true : false;
- break;
- case RTF_CLPADFT:
- bUseTopCellPad = (nTokenValue == 3) ? true : false;
- break;
- case RTF_CLPADFR:
- bUseRightCellPad = (nTokenValue == 3) ? true : false;
- break;
- case RTF_CLPADFB:
- bUseBottomCellPad = (nTokenValue == 3) ? true : false;
- break;
- case RTF_CLPADL:
- nLeftCellPad = nTokenValue;
- break;
- case RTF_CLPADT:
- nTopCellPad = nTokenValue;
- break;
- case RTF_CLPADR:
- nRightCellPad = nTokenValue;
- break;
- case RTF_CLPADB:
- nBottomCellPad = nTokenValue;
- break;
-
- case RTF_TRRH:
- nLineHeight = nTokenValue;
- break;
-
- case RTF_CLMRG:
- // would crash later on reading \cellx (#i112657#):
- // the first cell cannot be merged with earlier ones.
- if (aMergeBoxes.size() > 1)
- {
- aMergeBoxes.back() = sal_True;
- }
- break;
-
- case RTF_CELLX:
- if (!bTrowdRead && (aMergeBoxes.size() < (SAL_MAX_UINT16 - 1)))
- {
- SwTableBoxFmt* pFmt = pBoxFmt;
- SwTwips nSize = nTokenValue - nTblSz;
- if( aMergeBoxes.back() )
- {
- // neue Zellen lesen und noch keine Formate vorhanden,
- // dann benutze das der vorhergebende
- if( bReadNewCell && aBoxFmts.empty() )
- {
- SwTableLines& rLns = pTableNode->GetTable().GetTabLines();
- SwTableLine* pLine = rLns.back();
- if (m_nCurrentBox != 0)
- {
- --m_nCurrentBox;
- }
- if (m_nCurrentBox < pLine->GetTabBoxes().size())
- {
- pFmt = static_cast<SwTableBoxFmt*>(
- pLine->GetTabBoxes()[m_nCurrentBox]->GetFrmFmt());
- }
- }
- else
- pFmt = aBoxFmts.back();
-
- // #i73790# - method renamed
- pBoxFmt->ResetAllFmtAttr();
-
- nSize += pFmt->GetFrmSize().GetWidth();
- }
- else
- {
- //
- if (nSize<=2*aRow.mnBrdDist) {
- aRow.mnRightRowPad=0;
- aRow.mbUseRightRowPad=sal_True;
- }
- SetRowBorder((SfxItemSet&)pBoxFmt->GetAttrSet(), aRow);
- aBoxFmts.push_back( pBoxFmt );
- pBoxFmt = pDoc->MakeTableBoxFmt();
- }
-
- if( !nSize )
- nSize = COL_DFLT_WIDTH;
- pFmt->SetFmtAttr( SwFmtFrmSize( ATT_VAR_SIZE, nSize, 0 ));
- nTblSz = nTokenValue;
- aMergeBoxes.push_back(sal_False);
-
- SvxBoxItem aBox(pFmt->GetBox());
-
- if (bUseRightCellPad)
- aBox.SetDistance( static_cast< sal_uInt16 >(nRightCellPad), BOX_LINE_RIGHT);
- if (bUseBottomCellPad)
- aBox.SetDistance( static_cast< sal_uInt16 >(nBottomCellPad), BOX_LINE_BOTTOM);
-
- //Yes, these are the wrong way around, there appears to
- //be a bug in word where these are swapped.
- if (bUseLeftCellPad)
- aBox.SetDistance( static_cast< sal_uInt16 >(nLeftCellPad), BOX_LINE_TOP);
- if (bUseTopCellPad)
- aBox.SetDistance( static_cast< sal_uInt16 >(nTopCellPad), BOX_LINE_LEFT);
-
-
- pFmt->SetFmtAttr(aBox);
-
- bUseLeftCellPad = false;
- bUseRightCellPad = false;
- bUseTopCellPad = false;
- bUseBottomCellPad = false;
- }
- break;
-
- case RTF_TRGAPH:
- //bug: RTF: wrong internal table cell margin imported (A13)
- aRow.mnBrdDist = (nTokenValue>0?(sal_uInt16)nTokenValue:0); // filter out negative values of \trgaph
- break;
-
- case RTF_TRQL: eAdjust = text::HoriOrientation::LEFT; break;
- case RTF_TRQR: eAdjust = text::HoriOrientation::RIGHT; break;
- case RTF_TRQC: eAdjust = text::HoriOrientation::CENTER; break;
-
- // mit text::VertOrientation::TOP kommt der Dialog nicht klar!
- case RTF_CLVERTALT: eVerOrient = text::VertOrientation::NONE; break;
-
- case RTF_CLVERTALC: eVerOrient = text::VertOrientation::CENTER; break;
- case RTF_CLVERTALB: eVerOrient = text::VertOrientation::BOTTOM; break;
-
- case RTF_TRLEFT:
- if( text::HoriOrientation::LEFT == eAdjust )
- eAdjust = text::HoriOrientation::LEFT_AND_WIDTH;
- nLSpace = nTokenValue;
- nTblSz = nTokenValue;
- break;
-
- case RTF_TRHDR:
- nRowsToRepeat++;
- break;
-
- case RTF_CLTXLRTB:
- case RTF_CLTXTBRL:
- case RTF_INTBL: // das wissen wir !
- case RTF_CLMGF:
- case RTF_CLVMGF:
- case RTF_CLVMRG:
- break;
- case RTF_LTRROW:
- eDir = FRMDIR_HORI_LEFT_TOP;
- break;
- case RTF_RTLROW:
- eDir = FRMDIR_HORI_RIGHT_TOP;
- break;
- case RTF_TRBRDRB:
- case RTF_TRBRDRH:
- case RTF_TRBRDRL:
- case RTF_TRBRDRR:
- case RTF_TRBRDRT:
- case RTF_TRBRDRV:
- break;
- case RTF_TRKEEP:
- bCantSplit = true;
- break;
-
- default:
- if( ( nToken & ~(0xff | RTF_TABLEDEF)) == RTF_SHADINGDEF )
- {
- if( aMergeBoxes.back() )
- break;
- ReadBackgroundAttr( nToken,
- (SfxItemSet&)pBoxFmt->GetAttrSet(), sal_True );
- }
- else if( ( nToken & ~(0xff | RTF_TABLEDEF) ) == RTF_BRDRDEF ||
- IsBorderToken(nToken))
- {
- if( aMergeBoxes.back() )
- break;
-
- SfxItemSet& rSet = (SfxItemSet&)pBoxFmt->GetAttrSet();
- if(!IsBorderToken( nToken ))
- ReadBorderAttr( nToken, rSet, sal_True );
- else
- NextToken( nToken );
- }
- else if( RTF_TABLEDEF != (nToken & ~(0xff | RTF_SWGDEFS)) )
- {
- if( RTF_UNKNOWNCONTROL == nToken )
- NextToken( nToken );
- else
- bWeiter = sal_False;
- }
- break;
- }
-
- if( text::VertOrientation::NONE != eVerOrient )
- {
- if( !aMergeBoxes.back() )
- pBoxFmt->SetFmtAttr( SwFmtVertOrient( 0, eVerOrient ));
- eVerOrient = text::VertOrientation::NONE;
- }
- if( bWeiter )
- nToken = GetNextToken();
- } while( bWeiter && IsParserWorking() );
-
- // das letzte temp. BoxFmt loeschen
- delete pBoxFmt;
-
- // It has been recognized as not single box
- if( m_nCurrentBox == aMergeBoxes.size()-1 || ( bReadNewCell && !pTableNode ))
- {
- aMergeBoxes.insert(aMergeBoxes.begin(), aMergeBackup.begin(), aMergeBackup.end());
- return;
- }
-
- nTblSz -= nLSpace;
-
- int bNewTbl = sal_True;
- SwTableLine* pNewLine;
- bTrowdRead=true;
-
- // lege eine neue Tabelle an oder erweiter die aktuelle um eine neue Line
- // oder Box !
- SwNode* pNd;
-
- if( bChkExistTbl )
- {
- // es ist eine Tabelle vorhanden, teste mal ob die weiter benutzt
- // werden kann oder ob sie abgesplittet und neu gefuellt werden
- // muss.
- pTableNode = pPam->GetNode()->FindTableNode();
-
- // Cursor kann nur in der letzten Line stehen
-
- // das Attribut darf nicht ueber das Modify an der
- // Tabelle gesetzt werden, denn sonst werden alle
- // Boxen wieder auf 0 zurueck gesetzt !!!!!
- SwFrmFmt* pFmt = pTableNode->GetTable().GetFrmFmt();
- const SwFmtFrmSize& rTblSz = pFmt->GetFrmSize();
- const SwFmtHoriOrient& rHoriz = pFmt->GetHoriOrient();
-
- const SwTableLines* pLns = &pTableNode->GetTable().GetTabLines();
-
- if( 1 == pLns->size() )
- {
- if( eAdjust != rHoriz.GetHoriOrient() )
- {
- ((SfxItemSet&)pFmt->GetAttrSet()).Put( SwFmtHoriOrient( 0,
- eAdjust ) );
- }
- if( rTblSz.GetWidth() != nTblSz )
- {
- SwFmtFrmSize aSz( rTblSz );
- aSz.SetWidth( nTblSz );
- ((SfxItemSet&)pFmt->GetAttrSet()).Put( aSz );
- }
-
- if( text::HoriOrientation::LEFT_AND_WIDTH == eAdjust &&
- nLSpace != pFmt->GetLRSpace().GetLeft() )
- {
- SvxLRSpaceItem aL( RES_LR_SPACE ); aL.SetLeft( nLSpace );
- ((SfxItemSet&)pFmt->GetAttrSet()).Put( aL );
- }
- }
- else if
- (
- 1 < pLns->size() &&
- (
- rTblSz.GetWidth() != nTblSz ||
- rHoriz.GetHoriOrient() != eAdjust ||
- (
- text::HoriOrientation::LEFT_AND_WIDTH == eAdjust &&
- nLSpace != pFmt->GetLRSpace().GetLeft()
- ) ||
- pTableNode->GetTable().GetTabSortBoxes().size() >= eMAXCELLS
- )
- )
- {
- // Tabelle ab der PaM-Position splitten
- // die vorherige Line!
- pNewLine = (*pLns)[ pLns->size() - 2 ];
- SwTableBox* pBox = pNewLine->GetTabBoxes().front();
- while( ( pLns = &pBox->GetTabLines() )->size() )
- pBox = pLns->front()->GetTabBoxes().front();
-
- SwNodeIndex aTmpIdx( *pBox->GetSttNd() );
- pDoc->GetNodes().SplitTable( aTmpIdx, HEADLINE_NONE, sal_False );
- pTableNode = pPam->GetNode()->FindTableNode();
- pFmt = pTableNode->GetTable().GetFrmFmt();
-
- SwFmtFrmSize aSz( rTblSz );
- aSz.SetWidth( nTblSz );
- ((SfxItemSet&)pFmt->GetAttrSet()).Put( aSz );
- ((SfxItemSet&)pFmt->GetAttrSet()).Put( SwFmtHoriOrient( 0,
- eAdjust ) );
- if( text::HoriOrientation::LEFT_AND_WIDTH == eAdjust && nLSpace )
- {
- SvxLRSpaceItem aL( RES_LR_SPACE ); aL.SetLeft( nLSpace );
- ((SfxItemSet&)pFmt->GetAttrSet()).Put( aL );
- }
- }
-
- pLns = &pTableNode->GetTable().GetTabLines();
- pNewLine = pLns->back();
-
- // jetzt die Boxen abgleichen
- sal_uInt16 nBoxes = Min( pNewLine->GetTabBoxes().size(), aBoxFmts.size() );
- sal_uInt16 n;
-
- for( n = 0; n < nBoxes; ++n )
- {
- SwTableBox* pBox = pNewLine->GetTabBoxes()[ n ];
- *pBox->GetFrmFmt() = *aBoxFmts[ n ];
- delete aBoxFmts[ n ];
- }
- aBoxFmts.erase( aBoxFmts.begin(), aBoxFmts.begin() + n );
-
- if( !aBoxFmts.empty() ) // es muessen noch neue zugefuegt werden
- {
- m_nCurrentBox = n;
- }
- else // es mussen noch Boxen geloescht werden
- {
- // remove ContentIndex of other Bound
- pPam->SetMark(); pPam->DeleteMark();
- while( n < pNewLine->GetTabBoxes().size() )
- _DeleteBox( pTableNode->GetTable(),
- pNewLine->GetTabBoxes()[ n ], 0, false, false );
- }
-
- pOldTblNd = pTableNode;
- bNewTbl = sal_False;
- }
- else
- {
- if( !bReadNewCell && ( pNd = pDoc->GetNodes()[
- pPam->GetPoint()->nNode.GetIndex()-1 ])->IsEndNode() )
- {
- pTableNode = pNd->StartOfSectionNode()->GetTableNode();
- if( pTableNode )
- {
- // dann test mal ob wirklich nur eine neue Line eingefuegt
- // werden soll!
- SwTable &rTable = pTableNode->GetTable();
- SwFrmFmt* pFmt = rTable.GetFrmFmt();
- const SwFmtFrmSize& rTblSz = pFmt->GetFrmSize();
- const SwFmtHoriOrient& rHoriz = pFmt->GetHoriOrient();
- if (
- rTblSz.GetWidth() != nTblSz ||
- rHoriz.GetHoriOrient() != eAdjust ||
- rTable.GetTabSortBoxes().size() >= eMAXCELLS
- )
- {
- pTableNode = 0;
- }
- }
- }
-
- if( pTableNode && !bForceNewTable)
- {
-
- // das Attribut darf nicht ueber das Modify an der
- // Tabelle gesetzt werden, denn sonst werden alle
- // Boxen wieder auf 0 zurueck gesetzt !!!!!
- SwFrmFmt* pFmt = pTableNode->GetTable().GetFrmFmt();
- const SwFmtFrmSize& rTblSz = pFmt->GetFrmSize();
- if( rTblSz.GetWidth() < nTblSz )
- {
- SwFmtFrmSize aSz( rTblSz );
- aSz.SetWidth( nTblSz );
- ((SfxItemSet&)pFmt->GetAttrSet()).Put( aSz );
- }
-
- SwTableLines& rLns = pTableNode->GetTable().GetTabLines();
-
- if( bReadNewCell )
- pNewLine = rLns.back();
- else
- {
- pNewLine = new SwTableLine(
- (SwTableLineFmt*)rLns.back()->GetFrmFmt(),
- aBoxFmts.size(), 0 );
- pNewLine->ClaimFrmFmt();
- pNewLine->GetFrmFmt()->ResetFmtAttr( RES_FRM_SIZE );
- rLns.push_back( pNewLine );
- }
- bNewTbl = sal_False;
- }
- else
- {
- bForceNewTable = false;
- const SwTable *pTable =
- pDoc->InsertTable(
- SwInsertTableOptions( tabopts::HEADLINE_NO_BORDER, 0 ),
- *pPam->GetPoint(), 1, 1, eAdjust, 0, 0, sal_False, sal_False );
- bContainsTablePara=true;
- pTableNode = pTable ? pTable->GetTableNode() : 0;
-
- if (pTableNode)
- {
- maSegments.PrependedInlineNode(*pPam->GetPoint(),
- *pTableNode);
- }
- else
- {
- SkipToken( -1 ); // zum Letzen gueltigen zurueck
- return;
- }
-
- SwTableLines& rLns = pTableNode->GetTable().GetTabLines();
- pNewLine = rLns.back();
-
- SwFrmFmt* pFmt = pTableNode->GetTable().GetFrmFmt();
- SwFmtFrmSize aSz( pFmt->GetFrmSize() );
- aSz.SetWidth( nTblSz );
- ((SfxItemSet&)pFmt->GetAttrSet()).Put( aSz );
- ((SfxItemSet&)pFmt->GetAttrSet()).Put(SvxFrameDirectionItem(eDir, RES_FRAMEDIR));
-
- if( text::HoriOrientation::LEFT_AND_WIDTH == eAdjust && nLSpace )
- {
- SvxLRSpaceItem aL( RES_LR_SPACE ); aL.SetLeft( nLSpace );
- ((SfxItemSet&)pFmt->GetAttrSet()).Put( aL );
- }
-
- m_nCurrentBox = 0;
- pOldTblNd = pTableNode;
- }
- }
-
- if( nLineHeight )
- {
- SwFrmSize eSize;
- if( 0 > nLineHeight )
- eSize = ATT_FIX_SIZE, nLineHeight = -nLineHeight;
- else
- eSize = ATT_MIN_SIZE;
- pNewLine->ClaimFrmFmt()->SetFmtAttr(SwFmtFrmSize(eSize, 0, nLineHeight));
- }
-
- pNewLine->ClaimFrmFmt()->SetFmtAttr(SwFmtRowSplit(!bCantSplit));
-
- if( !aBoxFmts.empty() )
- {
- // setze das default Style
- SwTxtFmtColl* pColl = NULL;
- std::map<sal_Int32,SwTxtFmtColl*>::iterator iter = aTxtCollTbl.find(0);
-
- if( iter == aTxtCollTbl.end() )
- pColl = pDoc->GetTxtCollFromPool( RES_POOLCOLL_STANDARD, false );
- else
- pColl = iter->second;
-
- sal_uInt16 nStt = 0;
- if( bNewTbl )
- {
- SwTableBox* pBox = pNewLine->GetTabBoxes()[0];
- pBoxFmt = (SwTableBoxFmt*)pBox->GetFrmFmt();
- pBox->ForgetFrmFmt();
- delete pBoxFmt;
- pBox->RegisterToFormat( *aBoxFmts[0] );
- SwTxtNode* pTNd = pDoc->GetNodes()[ pBox->GetSttIdx()+1 ]
- ->GetTxtNode();
- OSL_ENSURE( pTNd, "wo ist der Textnode dieser Box?" );
- pTNd->ChgFmtColl( pColl );
- ++nStt;
- nRowsToRepeat=0;
- }
-
- for( ; nStt < aBoxFmts.size(); ++nStt )
- {
- pDoc->GetNodes().InsBoxen( pTableNode, pNewLine,
- aBoxFmts[ nStt ],
- // Formate fuer den TextNode der Box
- pColl, 0,
- m_nCurrentBox + nStt, 1 );
- }
- }
-
- if( bChkExistTbl )
- {
- m_nCurrentBox = 0;
- }
-
- maInsertedTables.InsertTable(*pTableNode, *pPam);
-
- SwNodeIndex aOldIdx(pPam->GetPoint()->nNode);
- SwNodeIdx aOldPos(aOldIdx);
- SwPaM aRg(*pPam);
-
- bool bFailure = true;
- if (pNewLine)
- {
- SwTableBoxes &rBoxes = pNewLine->GetTabBoxes();
- if (SwTableBox* pBox = ((m_nCurrentBox < rBoxes.size())
- ? rBoxes[m_nCurrentBox] : 0))
- {
- if (const SwStartNode *pStart = pBox->GetSttNd())
- {
- if (const SwEndNode *pEnd = pStart->EndOfSectionNode())
- {
- pPam->GetPoint()->nNode = *pEnd;
- pPam->Move( fnMoveBackward, fnGoCntnt );
- bFailure = false;
- }
- }
- }
- }
-
- OSL_ENSURE(!bFailure, "RTF Table failure");
- if (bFailure)
- {
- SkipToken( -1 ); // zum Letzen gueltigen zurueck
- return;
- }
-
- //It might be that there was content at this point which is not already in
- //a table, but which is being followed by properties to place it into the
- //table. If this is the case then move the para/char
- //properties inside the table, and move any content of that paragraph into
- //the table
- bool bInTable = aRg.GetPoint()->nNode.GetNode().FindTableNode();
- if (!bInTable)
- {
- SwNodeIndex aNewIdx(pPam->GetPoint()->nNode);
- SwNodeIdx aNewPos(aNewIdx);
-
- if (aRg.GetPoint()->nContent.GetIndex())
- {
- //If there is content in this node then move it entirely inside the
- //table
- aRg.SetMark();
- aRg.GetMark()->nContent.Assign(aRg.GetCntntNode(), 0);
- pDoc->MoveRange(aRg, *pPam->GetPoint(),
- IDocumentContentOperations::DOC_MOVEDEFAULT);
- }
-
- //Update the attribute stack entries to reflect that the properties
- //which were intended to be inside the tablerow are now left outside
- //the table after the row was placed before the current insertion point
- SvxRTFItemStack& rAttrStk = GetAttrStack();
- for (size_t n = 0; n < rAttrStk.size(); ++n)
- {
- SvxRTFItemStackType* pStk = rAttrStk[n];
- pStk->MoveFullNode(aOldPos, aNewPos);
- }
- }
- SkipToken( -1 ); // zum Letzen gueltigen zurueck
-}
-
-// in die naechste Box dieser Line (opt.: falls es nicht die letzte ist)
-void SwRTFParser::GotoNextBox()
-{
- nInsTblRow = USHRT_MAX;
-
- OSL_ENSURE( pTableNode, "Kein Tabellennode, dann auch keine Box" );
-
- if (!pTableNode)
- return;
-
- SwTableLines& rLns = pTableNode->GetTable().GetTabLines();
- SwTableLine* pLine = rLns.back();
- SwTableBoxes& rBoxes = pLine->GetTabBoxes();
- SwTableBox* pBox = rBoxes.back();
-
- if( ++m_nCurrentBox >= aMergeBoxes.size() )
- m_nCurrentBox = aMergeBoxes.size()-1;
-
- if (!aMergeBoxes[ m_nCurrentBox ])
- {
- int bMove = sal_True;
- if( pBox->GetSttIdx() > pPam->GetPoint()->nNode.GetIndex() )
- {
- sal_uInt16 nRealBox = 0;
- for (sal_uInt16 nTmp = 0; nTmp < m_nCurrentBox; ++nTmp)
- if( !aMergeBoxes[ nTmp ] )
- ++nRealBox;
-
- if( nRealBox < rBoxes.size() )
- {
- pPam->GetPoint()->nNode = *rBoxes[ nRealBox ]->GetSttNd()->EndOfSectionNode();
- pPam->Move( fnMoveBackward, fnGoCntnt );
- bMove = sal_False;
- }
- }
-
- if( bMove && m_nCurrentBox + 1U == aMergeBoxes.size() )
- // dann hinter die Tabelle
- pPam->Move( fnMoveForward, fnGoNode );
- }
- else if (pPam->GetPoint()->nNode.GetNode().IsCntntNode())
- // dann in die vorherige ans Ende
- pPam->Move( fnMoveBackward, fnGoCntnt );
-}
-
-
-void SwRTFParser::NewTblLine()
-{
- nInsTblRow = USHRT_MAX;
-
- // erweiter die aktuelle um eine neue Line
- bool bMakeCopy = false;
- SwNode* pNd = pDoc->GetNodes()[ pPam->GetPoint()->nNode.GetIndex()-1 ];
- if( !pNd->IsEndNode() ||
- !(pNd = pNd->StartOfSectionNode())->IsTableNode() )
- {
- if( !pOldTblNd )
- return ;
-
- bMakeCopy = true;
- pNd = pOldTblNd;
- }
- pTableNode = (SwTableNode*)pNd;
-
- SwTableLines* pLns = &pTableNode->GetTable().GetTabLines();
- SwTableLine* pLine = pLns->back();
- SwTableBoxes& rBoxes = pLine->GetTabBoxes();
- SwTableBox* pBox = rBoxes.back();
-
- if(nRowsToRepeat>0)
- pTableNode->GetTable().SetRowsToRepeat( nRowsToRepeat );
-
- if( !bMakeCopy &&
- 64000 < pTableNode->GetTable().GetTabSortBoxes().size() )
- {
- bMakeCopy = true; // spaetestens jetzt eine neue anfangen!
- }
-
- if( bMakeCopy )
- {
- // und die Selektion kopieren
- SwSelBoxes aBoxes;
- pTableNode->GetTable().SelLineFromBox( pBox, aBoxes );
- pTableNode->GetTable().MakeCopy( pDoc, *pPam->GetPoint(),
- aBoxes, false );
- sal_uLong nNd = pPam->GetPoint()->nNode.GetIndex()-1;
- pTableNode = pDoc->GetNodes()[ nNd ]->FindTableNode();
- pOldTblNd = pTableNode;
-
- nRowsToRepeat=0;
- pTableNode->GetTable().SetRowsToRepeat(nRowsToRepeat);
- pLns = &pTableNode->GetTable().GetTabLines();
- }
- else
- pTableNode->GetTable().AppendRow( pDoc );
-
- pBox = pLns->back()->GetTabBoxes().front();
-
- sal_uLong nOldPos = pPam->GetPoint()->nNode.GetIndex();
- pPam->GetPoint()->nNode = *pBox->GetSttNd();
- pPam->Move( fnMoveForward );
- m_nCurrentBox = 0;
-
- // alle Nodes in den Boxen auf die "default" Vorlage setzten
- {
- SwTxtFmtColl* pColl = NULL;
- std::map<sal_Int32,SwTxtFmtColl*>::iterator iter = aTxtCollTbl.find( 0 );
-
- if( iter == aTxtCollTbl.end() )
- pColl = pDoc->GetTxtCollFromPool( RES_POOLCOLL_STANDARD, false );
- else
- pColl = iter->second;
-
- pPam->SetMark();
-
- pLine = pLns->back();
- pBox = pLine->GetTabBoxes().back();
- pPam->GetPoint()->nNode = *pBox->GetSttNd()->EndOfSectionNode();
- pPam->Move( fnMoveBackward );
- pDoc->SetTxtFmtColl( *pPam, pColl );
- // Bug 73940 - remove ALL attributes (NumRules/Break/etc.)
- {
- SwNodeIndex aIdx( pPam->GetMark()->nNode );
- SwNodeIndex& rEndIdx = pPam->GetPoint()->nNode;
- while( aIdx <= rEndIdx )
- {
- SwCntntNode* pCNd = aIdx.GetNode().GetCntntNode();
- if( pCNd && pCNd->HasSwAttrSet() )
- pCNd->ResetAllAttr();
- ++aIdx;
- }
- }
- pPam->Exchange();
- pPam->DeleteMark();
- }
-
- // all attributes which will be displayed in new Box
- SvxRTFItemStack& rAttrStk = GetAttrStack();
- const SvxRTFItemStackType* pStk;
- for( size_t n = 0; n < rAttrStk.size(); ++n )
- if( ( pStk = rAttrStk[ n ])->GetSttNodeIdx() == sal_uLong(nOldPos) &&
- !pStk->GetSttCnt() )
- ((SvxRTFItemStackType*)pStk)->SetStartPos( SwxPosition( pPam ) );
-}
-
-void SwRTFParser::CheckInsNewTblLine()
-{
- if( USHRT_MAX != nInsTblRow )
- {
- if( nInsTblRow > GetOpenBrakets() || IsPardTokenRead() )
- nInsTblRow = USHRT_MAX;
- else if( !pTableNode ) // Tabelle nicht mehr vorhanden ?
- NewTblLine(); // evt. Line copieren
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/rtf/swparrtf.cxx b/sw/source/filter/rtf/swparrtf.cxx
index 75f0a45050b1..02c7bdf8ff13 100644
--- a/sw/source/filter/rtf/swparrtf.cxx
+++ b/sw/source/filter/rtf/swparrtf.cxx
@@ -225,425 +225,6 @@ extern "C" SAL_DLLPUBLIC_EXPORT Reader* SAL_CALL ImportRTF()
return new SwRTFReader();
}
-SwRTFParser::SwRTFParser(SwDoc* pD,
- uno::Reference<document::XDocumentProperties> i_xDocProps,
- const SwPaM& rCrsr, SvStream& rIn, const String& rBaseURL,
- int bReadNewDoc) :
- SvxRTFParser(pD->GetAttrPool(), rIn, i_xDocProps, bReadNewDoc),
- maParaStyleMapper(*pD),
- maCharStyleMapper(*pD),
- maSegments(*this),
- maInsertedTables(*pD),
- mpBookmarkStart(0),
- mpRedlineStack(0),
- pGrfAttrSet(0),
- pTableNode(0),
- pOldTblNd(0),
- pSttNdIdx(0),
- pRegionEndIdx(0),
- pDoc(pD),
- pRelNumRule(new SwRelNumRuleSpaces(*pD, static_cast< sal_Bool >(bReadNewDoc))),
- pRedlineInsert(0),
- pRedlineDelete(0),
- sBaseURL( rBaseURL ),
- nAktPageDesc(0),
- nAktFirstPageDesc(0),
- m_nCurrentBox(0),
- nInsTblRow(USHRT_MAX),
- nNewNumSectDef(USHRT_MAX),
- nRowsToRepeat(0),
- mbReadCellWhileReadSwFly( false ), // #i83368#
-
- bTrowdRead(0),
- nReadFlyDepth(0),
- nZOrder(0)
-{
- mbIsFootnote = mbReadNoTbl = bReadSwFly = bSwPageDesc = bStyleTabValid =
- bInPgDscTbl = bNewNumList = false;
- bFirstContinue = true;
- bContainsPara = false;
- bContainsTablePara = false;
- bNestedField = false;
- bForceNewTable = false;
-
- pPam = new SwPaM( *rCrsr.GetPoint() );
- SetInsPos( SwxPosition( pPam ) );
- SetChkStyleAttr( 0 != bReadNewDoc );
- SetCalcValue( sal_False );
- SetReadDocInfo( sal_True );
-
- // diese sollen zusaetzlich ueber \pard zurueck gesetzt werden
- sal_uInt16 temp;
- temp = RES_TXTATR_CHARFMT; AddPlainAttr( temp );
- temp = RES_PAGEDESC; AddPardAttr( temp );
- temp = RES_BREAK; AddPardAttr( temp );
- temp = RES_PARATR_NUMRULE; AddPardAttr( temp );
- temp = FN_PARAM_NUM_LEVEL; AddPardAttr( temp );
-}
-
-// Aufruf des Parsers
-SvParserState SwRTFParser::CallParser()
-{
- mbReadNoTbl = false;
- bFirstContinue = true;
-
- rInput.Seek(STREAM_SEEK_TO_BEGIN);
- rInput.ResetError();
-
- mpRedlineStack = new sw::util::RedlineStack(*pDoc);
-
- return SvxRTFParser::CallParser();
-}
-
-static bool lcl_UsedPara(SwPaM &rPam)
-{
- const SwCntntNode* pCNd;
- const SfxItemSet* pSet;
- if( rPam.GetPoint()->nContent.GetIndex() ||
- ( 0 != ( pCNd = rPam.GetCntntNode()) &&
- 0 != ( pSet = pCNd->GetpSwAttrSet()) &&
- ( SFX_ITEM_SET == pSet->GetItemState( RES_BREAK, sal_False ) ||
- SFX_ITEM_SET == pSet->GetItemState( RES_PAGEDESC, sal_False ))))
- return true;
- return false;
-}
-
-void SwRTFParser::Continue( int nToken )
-{
- if( bFirstContinue )
- {
- bFirstContinue = sal_False;
-
- if (IsNewDoc())
- {
- //
- // COMPATIBILITY FLAGS START
- //
- pDoc->set(IDocumentSettingAccess::PARA_SPACE_MAX, true);
- pDoc->set(IDocumentSettingAccess::PARA_SPACE_MAX_AT_PAGES, true);
- pDoc->set(IDocumentSettingAccess::TAB_COMPAT, true);
- pDoc->set(IDocumentSettingAccess::USE_VIRTUAL_DEVICE, true);
- pDoc->set(IDocumentSettingAccess::USE_HIRES_VIRTUAL_DEVICE, true);
- pDoc->set(IDocumentSettingAccess::ADD_FLY_OFFSETS, true);
- pDoc->set(IDocumentSettingAccess::ADD_EXT_LEADING, true);
- pDoc->set(IDocumentSettingAccess::OLD_NUMBERING, false);
- pDoc->set(IDocumentSettingAccess::IGNORE_FIRST_LINE_INDENT_IN_NUMBERING, false );
- pDoc->set(IDocumentSettingAccess::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK, false);
- pDoc->set(IDocumentSettingAccess::OLD_LINE_SPACING, false);
- pDoc->set(IDocumentSettingAccess::ADD_PARA_SPACING_TO_TABLE_CELLS, true);
- pDoc->set(IDocumentSettingAccess::USE_FORMER_OBJECT_POS, false);
- pDoc->set(IDocumentSettingAccess::USE_FORMER_TEXT_WRAPPING, false);
- pDoc->set(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION, true);
- pDoc->set(IDocumentSettingAccess::DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT, false); // #i53199#
-
- pDoc->set(IDocumentSettingAccess::TABLE_ROW_KEEP, true);
- pDoc->set(IDocumentSettingAccess::IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION, true);
- pDoc->set(IDocumentSettingAccess::INVERT_BORDER_SPACING, true);
- //
- // COMPATIBILITY FLAGS END
- //
- }
-
- // einen temporaeren Index anlegen, auf Pos 0 so wird er nicht bewegt!
- pSttNdIdx = new SwNodeIndex( pDoc->GetNodes() );
- if( !IsNewDoc() ) // in ein Dokument einfuegen ?
- {
- const SwPosition* pPos = pPam->GetPoint();
- SwTxtNode* pSttNd = pPos->nNode.GetNode().GetTxtNode();
-
- pDoc->SplitNode( *pPos, false );
-
- *pSttNdIdx = pPos->nNode.GetIndex()-1;
- pDoc->SplitNode( *pPos, false );
-
- SwPaM aInsertionRangePam( *pPos );
-
- pPam->Move( fnMoveBackward );
-
- // split any redline over the insertion point
- aInsertionRangePam.SetMark();
- *aInsertionRangePam.GetPoint() = *pPam->GetPoint();
- aInsertionRangePam.Move( fnMoveBackward );
- pDoc->SplitRedline( aInsertionRangePam );
-
- pDoc->SetTxtFmtColl( *pPam, pDoc->GetTxtCollFromPool
- ( RES_POOLCOLL_STANDARD, false ));
-
- // verhinder das einlesen von Tabellen in Fussnoten / Tabellen
- sal_uLong nNd = pPos->nNode.GetIndex();
- mbReadNoTbl = 0 != pSttNd->FindTableNode() ||
- ( nNd < pDoc->GetNodes().GetEndOfInserts().GetIndex() &&
- pDoc->GetNodes().GetEndOfInserts().StartOfSectionIndex() < nNd );
- }
-
- // Laufbalken anzeigen, aber nur bei synchronem Call
- sal_uLong nCurrPos = rInput.Tell();
- rInput.Seek(STREAM_SEEK_TO_END);
- rInput.ResetError();
- ::StartProgress( STR_STATSTR_W4WREAD, 0, rInput.Tell(), pDoc->GetDocShell());
- rInput.Seek( nCurrPos );
- rInput.ResetError();
- }
-
- SvxRTFParser::Continue( nToken );
-
- if( SVPAR_PENDING == GetStatus() )
- return ; // weiter gehts beim naechsten mal
-
- pRelNumRule->SetNumRelSpaces( *pDoc );
-
- // den Start wieder korrigieren
- if( !IsNewDoc() && pSttNdIdx->GetIndex() )
- {
- //die Flys muessen zuerst zurecht gerueckt werden, denn sonst wird
- // ein am 1. Absatz verankerter Fly falsch eingefuegt
- if( SVPAR_ACCEPTED == eState )
- {
- if( !aFlyArr.empty() )
- SetFlysInDoc();
- pRelNumRule->SetOultineRelSpaces( *pSttNdIdx, pPam->GetPoint()->nNode );
- }
-
- SwTxtNode* pTxtNode = pSttNdIdx->GetNode().GetTxtNode();
- SwNodeIndex aNxtIdx( *pSttNdIdx );
- if( pTxtNode && pTxtNode->CanJoinNext( &aNxtIdx ))
- {
- xub_StrLen nStt = pTxtNode->GetTxt().Len();
- // wenn der Cursor noch in dem Node steht, dann setze in an das Ende
- if( pPam->GetPoint()->nNode == aNxtIdx )
- {
- pPam->GetPoint()->nNode = *pSttNdIdx;
- pPam->GetPoint()->nContent.Assign( pTxtNode, nStt );
- }
-
-#if OSL_DEBUG_LEVEL > 0
- // !!! sollte nicht moeglich sein, oder ??
- OSL_ENSURE( pSttNdIdx->GetIndex()+1 != pPam->GetBound( sal_True ).nNode.GetIndex(),
- "Pam.Bound1 steht noch im Node" );
- OSL_ENSURE( pSttNdIdx->GetIndex()+1 != pPam->GetBound( sal_False ).nNode.GetIndex(),
- "Pam.Bound2 steht noch im Node" );
-
-if( pSttNdIdx->GetIndex()+1 == pPam->GetBound( sal_True ).nNode.GetIndex() )
-{
- xub_StrLen nCntPos = pPam->GetBound( sal_True ).nContent.GetIndex();
- pPam->GetBound( sal_True ).nContent.Assign( pTxtNode,
- pTxtNode->GetTxt().Len() + nCntPos );
-}
-if( pSttNdIdx->GetIndex()+1 == pPam->GetBound( sal_False ).nNode.GetIndex() )
-{
- xub_StrLen nCntPos = pPam->GetBound( sal_False ).nContent.GetIndex();
- pPam->GetBound( sal_False ).nContent.Assign( pTxtNode,
- pTxtNode->GetTxt().Len() + nCntPos );
-}
-#endif
- // Zeichen Attribute beibehalten!
- SwTxtNode* pDelNd = aNxtIdx.GetNode().GetTxtNode();
- if( pTxtNode->GetTxt().Len() )
- pDelNd->FmtToTxtAttr( pTxtNode );
- else
- pTxtNode->ChgFmtColl( pDelNd->GetTxtColl() );
- pTxtNode->JoinNext();
- }
- }
-
- if( SVPAR_ACCEPTED == eState )
- {
- // den letzen Bereich wieder zumachen
- if( pRegionEndIdx )
- {
- // the last section in WW are not a balanced Section.
- if( !GetVersionNo() )
- {
- SwSectionNode* pSectNd = pRegionEndIdx->GetNode().
- StartOfSectionNode()->GetSectionNode();
- if( pSectNd )
- pSectNd->GetSection().GetFmt()->SetFmtAttr(
- SwFmtNoBalancedColumns( sal_True ) );
- }
-
- DelLastNode();
- pPam->GetPoint()->nNode = *pRegionEndIdx;
- pPam->Move( fnMoveForward, fnGoNode );
- delete pRegionEndIdx, pRegionEndIdx = 0;
- }
-
- sal_uInt16 nPageDescOffset = pDoc->GetPageDescCnt();
- maSegments.InsertSegments(IsNewDoc());
- UpdatePageDescs(*pDoc, nPageDescOffset);
- // following garbage collecting code has been moved from the previous
- // procedure UpdatePageDescs to here in order to fix a bug
- rtfSections::myrDummyIter aDEnd = maSegments.maDummyPageNos.rend();
- for (rtfSections::myrDummyIter aI = maSegments.maDummyPageNos.rbegin(); aI != aDEnd; ++aI)
- pDoc->DelPageDesc(*aI);
-
- if( !aFlyArr.empty() )
- SetFlysInDoc();
-
- // jetzt noch den letzten ueberfluessigen Absatz loeschen
- SwPosition* pPos = pPam->GetPoint();
- if( !pPos->nContent.GetIndex() )
- {
- SwTxtNode* pAktNd;
- sal_uLong nNodeIdx = pPos->nNode.GetIndex();
- if( IsNewDoc() )
- {
- SwNode* pTmp = pDoc->GetNodes()[ nNodeIdx -1 ];
- if( pTmp->IsCntntNode() && !pTmp->FindTableNode() )
- {
- // Do not delete the paragraph if it has anchored objects:
- bool bAnchoredObjs = false;
- const SwFrmFmts* pFrmFmts = pDoc->GetSpzFrmFmts();
- if ( pFrmFmts && !pFrmFmts->empty() )
- {
- for ( sal_uInt16 nI = pFrmFmts->size(); nI; --nI )
- {
- const SwFmtAnchor & rAnchor = (*pFrmFmts)[ nI - 1 ]->GetAnchor();
- if ((FLY_AT_PARA == rAnchor.GetAnchorId()) ||
- (FLY_AT_CHAR == rAnchor.GetAnchorId()))
- {
- const SwPosition * pObjPos = rAnchor.GetCntntAnchor();
- if ( pObjPos && nNodeIdx == pObjPos->nNode.GetIndex() )
- {
- bAnchoredObjs = true;
- break;
- }
- }
- }
- }
-
- if ( !bAnchoredObjs )
- DelLastNode();
- }
- }
- else if (0 != (pAktNd = pDoc->GetNodes()[nNodeIdx]->GetTxtNode()))
- {
- if( pAktNd->CanJoinNext( &pPos->nNode ))
- {
- SwTxtNode* pNextNd = pPos->nNode.GetNode().GetTxtNode();
- pPos->nContent.Assign( pNextNd, 0 );
- pPam->SetMark(); pPam->DeleteMark();
- pNextNd->JoinPrev();
- }
- else if( !pAktNd->GetTxt().Len() &&
- pAktNd->StartOfSectionIndex()+2 <
- pAktNd->EndOfSectionIndex() )
- {
- pPos->nContent.Assign( 0, 0 );
- pPam->SetMark(); pPam->DeleteMark();
- pDoc->GetNodes().Delete( pPos->nNode, 1 );
- pPam->Move( fnMoveBackward );
- }
- }
- }
- // nun noch das SplitNode vom Ende aufheben
- else if( !IsNewDoc() )
- {
- if( pPos->nContent.GetIndex() ) // dann gabs am Ende kein \par,
- pPam->Move( fnMoveForward, fnGoNode ); // als zum naechsten Node
- SwTxtNode* pTxtNode = pPos->nNode.GetNode().GetTxtNode();
- SwNodeIndex aPrvIdx( pPos->nNode );
- if( pTxtNode && pTxtNode->CanJoinPrev( &aPrvIdx ) &&
- *pSttNdIdx <= aPrvIdx )
- {
- // eigentlich muss hier ein JoinNext erfolgen, aber alle Cursor
- // usw. sind im pTxtNode angemeldet, so dass der bestehen
- // bleiben MUSS.
-
- // Absatz in Zeichen-Attribute umwandeln, aus dem Prev die
- // Absatzattribute und die Vorlage uebernehmen!
- SwTxtNode* pPrev = aPrvIdx.GetNode().GetTxtNode();
- pTxtNode->ChgFmtColl( pPrev->GetTxtColl() );
- pTxtNode->FmtToTxtAttr( pPrev );
- pTxtNode->ResetAllAttr();
-
- if( pPrev->HasSwAttrSet() )
- pTxtNode->SetAttr( *pPrev->GetpSwAttrSet() );
-
- if( &pPam->GetBound(sal_True).nNode.GetNode() == pPrev )
- pPam->GetBound(sal_True).nContent.Assign( pTxtNode, 0 );
- if( &pPam->GetBound(sal_False).nNode.GetNode() == pPrev )
- pPam->GetBound(sal_False).nContent.Assign( pTxtNode, 0 );
-
- pTxtNode->JoinPrev();
- }
- }
- }
- delete pSttNdIdx, pSttNdIdx = 0;
- delete pRegionEndIdx, pRegionEndIdx = 0;
- RemoveUnusedNumRules();
-
- pDoc->SetUpdateExpFldStat(true);
- pDoc->SetInitDBFields(true);
-
- // Laufbalken bei asynchronen Call nicht einschalten !!!
- ::EndProgress( pDoc->GetDocShell() );
-}
-
-bool rtfSections::SetCols(SwFrmFmt &rFmt, const rtfSection &rSection,
- sal_uInt16 nNettoWidth)
-{
- //sprmSCcolumns - Anzahl der Spalten - 1
- sal_uInt16 nCols = static_cast< sal_uInt16 >(rSection.NoCols());
-
- if (nCols < 2)
- return false; // keine oder bloedsinnige Spalten
-
- SwFmtCol aCol; // Erzeuge SwFmtCol
-
- //sprmSDxaColumns - Default-Abstand 1.25 cm
- sal_uInt16 nColSpace = static_cast< sal_uInt16 >(rSection.StandardColSeperation());
-
- aCol.Init( nCols, nColSpace, nNettoWidth );
-
- // not SFEvenlySpaced
- if (rSection.maPageInfo.maColumns.size())
- {
- aCol._SetOrtho(false);
- sal_uInt16 nWishWidth = 0, nHalfPrev = 0;
- for (sal_uInt16 n=0, i=0;
- (static_cast<size_t>(n)+1) < rSection.maPageInfo.maColumns.size() && i < nCols;
- n += 2, ++i)
- {
- SwColumn* pCol = &aCol.GetColumns()[ i ];
- pCol->SetLeft( nHalfPrev );
- sal_uInt16 nSp = static_cast< sal_uInt16 >(rSection.maPageInfo.maColumns[ n+1 ]);
- nHalfPrev = nSp / 2;
- pCol->SetRight( nSp - nHalfPrev );
- pCol->SetWishWidth( static_cast< sal_uInt16 >(rSection.maPageInfo.maColumns[ n ]) +
- pCol->GetLeft() + pCol->GetRight());
- nWishWidth = nWishWidth + pCol->GetWishWidth();
- }
- aCol.SetWishWidth( nWishWidth );
- }
-
- rFmt.SetFmtAttr(aCol);
- return true;
-}
-
-void rtfSections::SetPage(SwPageDesc &rInPageDesc, SwFrmFmt &rFmt,
- const rtfSection &rSection, bool bIgnoreCols)
-{
- // 1. Orientierung
- rInPageDesc.SetLandscape(rSection.IsLandScape());
-
- // 2. Papiergroesse
- SwFmtFrmSize aSz(rFmt.GetFrmSize());
- aSz.SetWidth(rSection.GetPageWidth());
- aSz.SetHeight(rSection.GetPageHeight());
- rFmt.SetFmtAttr(aSz);
-
- rFmt.SetFmtAttr(
- SvxLRSpaceItem(rSection.GetPageLeft(), rSection.GetPageRight(), 0, 0, RES_LR_SPACE));
-
- if (!bIgnoreCols)
- {
- SetCols(rFmt, rSection, static_cast< sal_uInt16 >(rSection.GetPageWidth() -
- rSection.GetPageLeft() - rSection.GetPageRight()));
- }
-
- rFmt.SetFmtAttr(rSection.maPageInfo.maBox);
-}
-
bool HasHeader(const SwFrmFmt &rFmt)
{
const SfxPoolItem *pHd;
@@ -660,426 +241,6 @@ bool HasFooter(const SwFrmFmt &rFmt)
return false;
}
-void rtfSections::GetPageULData(const rtfSection &rSection, bool bFirst,
- rtfSections::wwULSpaceData& rData)
-{
- short nWWUp = static_cast< short >(rSection.maPageInfo.mnMargtsxn);
- short nWWLo = static_cast< short >(rSection.maPageInfo.mnMargbsxn);
- short nWWHTop = static_cast< short >(rSection.maPageInfo.mnHeadery);
- short nWWFBot = static_cast< short >(rSection.maPageInfo.mnFootery);
-
- if (bFirst)
- {
- if (
- rSection.mpTitlePage && HasHeader(rSection.mpTitlePage->GetMaster())
- )
- {
- rData.bHasHeader = true;
- }
- }
- else
- {
- if (rSection.mpPage &&
- (
- HasHeader(rSection.mpPage->GetMaster())
- || HasHeader(rSection.mpPage->GetLeft())
- )
- )
- {
- rData.bHasHeader = true;
- }
- }
-
- if( rData.bHasHeader )
- {
- rData.nSwUp = nWWHTop; // Header -> umrechnen, see ww8par6.cxx
-
- if ( nWWUp > 0 && nWWUp >= nWWHTop )
- rData.nSwHLo = nWWUp - nWWHTop;
- else
- rData.nSwHLo = 0;
-
- if (rData.nSwHLo < cMinHdFtHeight)
- rData.nSwHLo = cMinHdFtHeight;
- }
- else // kein Header -> Up einfach uebernehmen
- rData.nSwUp = Abs(nWWUp);
-
- if (bFirst)
- {
- if (
- rSection.mpTitlePage &&
- HasFooter(rSection.mpTitlePage->GetMaster())
- )
- {
- rData.bHasFooter = true;
- }
- }
- else
- {
- if (rSection.mpPage &&
- (
- HasFooter(rSection.mpPage->GetMaster())
- || HasFooter(rSection.mpPage->GetLeft())
- )
- )
- {
- rData.bHasFooter = true;
- }
- }
-
- if( rData.bHasFooter )
- {
- rData.nSwLo = nWWFBot; // Footer -> Umrechnen
- if ( nWWLo > 0 && nWWLo >= nWWFBot )
- rData.nSwFUp = nWWLo - nWWFBot;
- else
- rData.nSwFUp = 0;
-
- if (rData.nSwFUp < cMinHdFtHeight)
- rData.nSwFUp = cMinHdFtHeight;
- }
- else // kein Footer -> Lo einfach uebernehmen
- rData.nSwLo = Abs(nWWLo);
-}
-
-void rtfSections::SetPageULSpaceItems(SwFrmFmt &rFmt,
- rtfSections::wwULSpaceData& rData)
-{
- if (rData.bHasHeader) // ... und Header-Lower setzen
- {
- //Kopfzeilenhoehe minimal sezten
- if (SwFrmFmt* pHdFmt = (SwFrmFmt*)rFmt.GetHeader().GetHeaderFmt())
- {
- pHdFmt->SetFmtAttr(SwFmtFrmSize(ATT_MIN_SIZE, 0, rData.nSwHLo));
- SvxULSpaceItem aHdUL(pHdFmt->GetULSpace());
- aHdUL.SetLower( rData.nSwHLo - cMinHdFtHeight );
- pHdFmt->SetFmtAttr(aHdUL);
- pHdFmt->SetFmtAttr(SwHeaderAndFooterEatSpacingItem(
- RES_HEADER_FOOTER_EAT_SPACING, true));
- }
- }
-
- if (rData.bHasFooter) // ... und Footer-Upper setzen
- {
- if (SwFrmFmt* pFtFmt = (SwFrmFmt*)rFmt.GetFooter().GetFooterFmt())
- {
- pFtFmt->SetFmtAttr(SwFmtFrmSize(ATT_MIN_SIZE, 0, rData.nSwFUp));
- SvxULSpaceItem aFtUL(pFtFmt->GetULSpace());
- aFtUL.SetUpper( rData.nSwFUp - cMinHdFtHeight );
- pFtFmt->SetFmtAttr(aFtUL);
- pFtFmt->SetFmtAttr(SwHeaderAndFooterEatSpacingItem(
- RES_HEADER_FOOTER_EAT_SPACING, true));
- }
- }
-
- SvxULSpaceItem aUL(rData.nSwUp, rData.nSwLo, RES_UL_SPACE ); // Page-UL setzen
- rFmt.SetFmtAttr(aUL);
-}
-
-void rtfSections::SetSegmentToPageDesc(const rtfSection &rSection,
- bool bTitlePage, bool bIgnoreCols)
-{
- SwPageDesc &rPage = bTitlePage ? *rSection.mpTitlePage : *rSection.mpPage;
-
- SwFrmFmt &rFmt = rPage.GetMaster();
-
- wwULSpaceData aULData;
- GetPageULData(rSection, bTitlePage, aULData);
- SetPageULSpaceItems(rFmt, aULData);
-
- SetPage(rPage, rFmt, rSection, bIgnoreCols);
-
- UseOnPage ePage = rPage.ReadUseOn();
- if(ePage & nsUseOnPage::PD_ALL)
- {
- SwFrmFmt &rFmtLeft = rPage.GetLeft();
- SetPageULSpaceItems(rFmtLeft, aULData);
- SetPage(rPage, rFmtLeft, rSection, bIgnoreCols);
- }
-
-}
-
-void rtfSections::CopyFrom(const SwPageDesc &rFrom, SwPageDesc &rDest)
-{
- UseOnPage ePage = rFrom.ReadUseOn();
- rDest.WriteUseOn(ePage);
-
- mrReader.pDoc->CopyHeader(rFrom.GetMaster(), rDest.GetMaster());
- SwFrmFmt &rDestFmt = rDest.GetMaster();
- rDestFmt.SetFmtAttr(rFrom.GetMaster().GetHeader());
- mrReader.pDoc->CopyHeader(rFrom.GetLeft(), rDest.GetLeft());
- mrReader.pDoc->CopyFooter(rFrom.GetMaster(), rDest.GetMaster());
- mrReader.pDoc->CopyFooter(rFrom.GetLeft(), rDest.GetLeft());
-}
-
-void rtfSections::MoveFrom(SwPageDesc &rFrom, SwPageDesc &rDest)
-{
- UseOnPage ePage = rFrom.ReadUseOn();
- rDest.WriteUseOn(ePage);
-
- SwFrmFmt &rDestMaster = rDest.GetMaster();
- SwFrmFmt &rFromMaster = rFrom.GetMaster();
- rDestMaster.SetFmtAttr(rFromMaster.GetHeader());
- rDestMaster.SetFmtAttr(rFromMaster.GetFooter());
-
- SwFrmFmt &rDestLeft = rDest.GetLeft();
- SwFrmFmt &rFromLeft = rFrom.GetLeft();
- rDestLeft.SetFmtAttr(rFromLeft.GetHeader());
- rDestLeft.SetFmtAttr(rFromLeft.GetFooter());
-}
-
-void rtfSections::SetHdFt(rtfSection &rSection)
-{
- OSL_ENSURE(rSection.mpPage, "makes no sense to call without a main page");
- if (rSection.mpPage && rSection.maPageInfo.mpPageHdFt)
- {
- if (rSection.maPageInfo.mbPageHdFtUsed)
- {
- MoveFrom(*rSection.maPageInfo.mpPageHdFt, *rSection.mpPage);
- rSection.maPageInfo.mbPageHdFtUsed = false;
- rSection.maPageInfo.mpPageHdFt = rSection.mpPage;
- }
- else
- CopyFrom(*rSection.maPageInfo.mpPageHdFt, *rSection.mpPage);
- }
-
- if (rSection.mpTitlePage && rSection.maPageInfo.mpTitlePageHdFt)
- {
- if (rSection.maPageInfo.mbTitlePageHdFtUsed)
- {
- MoveFrom(*rSection.maPageInfo.mpTitlePageHdFt,
- *rSection.mpTitlePage);
- rSection.maPageInfo.mbTitlePageHdFtUsed = false;
- rSection.maPageInfo.mpTitlePageHdFt = rSection.mpTitlePage;
- }
- else
- {
- CopyFrom(*rSection.maPageInfo.mpTitlePageHdFt,
- *rSection.mpTitlePage);
- }
- }
-}
-
-SwSectionFmt *rtfSections::InsertSection(SwPaM& rMyPaM, rtfSection &rSection)
-{
- SwSectionData aSectionData(CONTENT_SECTION,
- mrReader.pDoc->GetUniqueSectionName());
-
- SfxItemSet aSet( mrReader.pDoc->GetAttrPool(), aFrmFmtSetRange );
-
- sal_uInt8 nRTLPgn = maSegments.empty() ? 0 : maSegments.back().IsBiDi();
- aSet.Put(SvxFrameDirectionItem(
- nRTLPgn ? FRMDIR_HORI_RIGHT_TOP : FRMDIR_HORI_LEFT_TOP, RES_FRAMEDIR));
-
- rSection.mpSection =
- mrReader.pDoc->InsertSwSection( rMyPaM, aSectionData, 0, &aSet );
- OSL_ENSURE(rSection.mpSection, "section not inserted!");
- if (!rSection.mpSection)
- return 0;
-
- SwPageDesc *pPage = 0;
- mySegrIter aEnd = maSegments.rend();
- for (mySegrIter aIter = maSegments.rbegin(); aIter != aEnd; ++aIter)
- {
- pPage = aIter->mpPage;
- if (pPage)
- break;
- }
-
- OSL_ENSURE(pPage, "no page outside this section!");
-
- if (!pPage)
- pPage = &mrReader.pDoc->GetPageDesc(0);
-
- if (!pPage)
- return 0;
-
- SwFrmFmt& rFmt = pPage->GetMaster();
- const SwFmtFrmSize& rSz = rFmt.GetFrmSize();
- const SvxLRSpaceItem& rLR = rFmt.GetLRSpace();
- SwTwips nWidth = rSz.GetWidth();
- long nLeft = rLR.GetTxtLeft();
- long nRight = rLR.GetRight();
-
- SwSectionFmt *pFmt = rSection.mpSection->GetFmt();
- OSL_ENSURE(pFmt, "impossible");
- if (!pFmt)
- return 0;
- SetCols(*pFmt, rSection, (sal_uInt16)(nWidth - nLeft - nRight) );
-
- return pFmt;
-}
-
-void rtfSections::InsertSegments(bool bNewDoc)
-{
- sal_uInt16 nDesc(0);
- mySegIter aEnd = maSegments.end();
- mySegIter aStart = maSegments.begin();
- for (mySegIter aIter = aStart; aIter != aEnd; ++aIter)
- {
- mySegIter aNext = aIter+1;
-
- bool bInsertSection = aIter != aStart ? aIter->IsContinous() : false;
-
- if (!bInsertSection)
- {
- /*
- If a cont section follow this section then we won't be
- creating a page desc with 2+ cols as we cannot host a one
- col section in a 2+ col pagedesc and make it look like
- word. But if the current section actually has columns then
- we are forced to insert a section here as well as a page
- descriptor.
- */
-
- /*
- Note for the future:
- If we want to import "protected sections" the here is
- where we would also test for that and force a section
- insertion if that was true.
- */
- bool bIgnoreCols = false;
- if (aNext != aEnd && aNext->IsContinous())
- {
- bIgnoreCols = true;
- if (aIter->NoCols() > 1)
- bInsertSection = true;
- }
-
- if (aIter->HasTitlePage())
- {
- if (bNewDoc && aIter == aStart)
- {
- aIter->mpTitlePage =
- mrReader.pDoc->GetPageDescFromPool(RES_POOLPAGE_FIRST);
- }
- else
- {
- sal_uInt16 nPos = mrReader.pDoc->MakePageDesc(
- ViewShell::GetShellRes()->GetPageDescName(nDesc, ShellResource::NORMAL_PAGE)
- , 0, false);
- aIter->mpTitlePage = &mrReader.pDoc->GetPageDesc(nPos);
- }
- OSL_ENSURE(aIter->mpTitlePage, "no page!");
- if (!aIter->mpTitlePage)
- continue;
-
- SetSegmentToPageDesc(*aIter, true, bIgnoreCols);
- }
-
- if (!bNewDoc && aIter == aStart)
- continue;
- else if (bNewDoc && aIter == aStart)
- {
- aIter->mpPage =
- mrReader.pDoc->GetPageDescFromPool(RES_POOLPAGE_STANDARD);
- }
- else
- {
- sal_uInt16 nPos = mrReader.pDoc->MakePageDesc(
- ViewShell::GetShellRes()->GetPageDescName(nDesc,
- aIter->HasTitlePage() ? ShellResource::FIRST_PAGE : ShellResource::NORMAL_PAGE),
- aIter->mpTitlePage, false);
- aIter->mpPage = &mrReader.pDoc->GetPageDesc(nPos);
- }
- OSL_ENSURE(aIter->mpPage, "no page!");
- if (!aIter->mpPage)
- continue;
-
- SetHdFt(*aIter);
-
- if (aIter->mpTitlePage)
- SetSegmentToPageDesc(*aIter, true, bIgnoreCols);
- SetSegmentToPageDesc(*aIter, false, bIgnoreCols);
-
- SwFmtPageDesc aPgDesc(aIter->HasTitlePage() ?
- aIter->mpTitlePage : aIter->mpPage);
-
- if (aIter->mpTitlePage)
- aIter->mpTitlePage->SetFollow(aIter->mpPage);
-
- if (aIter->PageRestartNo() ||
- ((aIter == aStart) && aIter->PageStartAt() != 1))
- aPgDesc.SetNumOffset( static_cast< sal_uInt16 >(aIter->PageStartAt()) );
-
- /*
- If its a table here, apply the pagebreak to the table
- properties, otherwise we add it to the para at this
- position
- */
- if (aIter->maStart.GetNode().IsTableNode())
- {
- SwTable& rTable =
- aIter->maStart.GetNode().GetTableNode()->GetTable();
- SwFrmFmt* pApply = rTable.GetFrmFmt();
- OSL_ENSURE(pApply, "impossible");
- if (pApply)
- pApply->SetFmtAttr(aPgDesc);
- }
- else
- {
- SwPosition aPamStart(aIter->maStart);
- aPamStart.nContent.Assign(
- aIter->maStart.GetNode().GetCntntNode(), 0);
- SwPaM aPage(aPamStart);
-
- mrReader.pDoc->InsertPoolItem(aPage, aPgDesc, 0);
- }
- ++nDesc;
- }
-
- SwTxtNode* pTxtNd = 0;
- if (bInsertSection)
- {
- SwPaM aSectPaM(*mrReader.pPam);
- SwNodeIndex aAnchor(aSectPaM.GetPoint()->nNode);
- if (aNext != aEnd)
- {
- aAnchor = aNext->maStart;
- aSectPaM.GetPoint()->nNode = aAnchor;
- aSectPaM.GetPoint()->nContent.Assign(
- aNext->maStart.GetNode().GetCntntNode(), 0);
- aSectPaM.Move(fnMoveBackward);
- }
-
- const SwPosition* pPos = aSectPaM.GetPoint();
- SwTxtNode const*const pSttNd = pPos->nNode.GetNode().GetTxtNode();
- const SwTableNode* pTableNd = pSttNd ? pSttNd->FindTableNode() : 0;
- if (pTableNd)
- {
- pTxtNd =
- mrReader.pDoc->GetNodes().MakeTxtNode(aAnchor,
- mrReader.pDoc->GetTxtCollFromPool( RES_POOLCOLL_TEXT ));
-
- aSectPaM.GetPoint()->nNode = SwNodeIndex(*pTxtNd);
- aSectPaM.GetPoint()->nContent.Assign(
- aSectPaM.GetCntntNode(), 0);
- }
-
- aSectPaM.SetMark();
-
- aSectPaM.GetPoint()->nNode = aIter->maStart;
- aSectPaM.GetPoint()->nContent.Assign(
- aSectPaM.GetCntntNode(), 0);
-
- SwSectionFmt *pRet = InsertSection(aSectPaM, *aIter);
- //The last section if continous is always unbalanced
- if (aNext == aEnd && pRet)
- pRet->SetFmtAttr(SwFmtNoBalancedColumns(true));
- }
-
- if (pTxtNd)
- {
- SwNodeIndex aIdx(*pTxtNd);
- SwPosition aPos(aIdx);
- SwPaM aTest(aPos);
- mrReader.pDoc->DelFullPara(aTest);
- pTxtNd = 0;
- }
- }
-}
-
namespace sw{
namespace util{
@@ -1137,202 +298,6 @@ void InsertedTablesManager::InsertTable(SwTableNode &rTableNode, SwPaM &rPaM)
}
}
-SwRTFParser::~SwRTFParser()
-{
- maInsertedTables.DelAndMakeTblFrms();
- mpRedlineStack->closeall(*pPam->GetPoint());
- delete mpRedlineStack;
-
- delete pSttNdIdx;
- delete pRegionEndIdx;
- delete pPam;
- delete pRelNumRule;
-
- if (pGrfAttrSet)
- DELETEZ( pGrfAttrSet );
-}
-
-//i19718
-void SwRTFParser::ReadShpRslt()
-{
- int nToken;
- while ('}' != (nToken = GetNextToken() ) && IsParserWorking())
- {
- switch(nToken)
- {
- case RTF_PAR:
- break;
- default:
- NextToken(nToken);
- break;
- }
- }
- SkipToken(-1);
-}
-
-void SwRTFParser::ReadShpTxt(String& s)
-{
- int nToken;
- int level=1;
- s.AppendAscii("{\\rtf");
- while (level>0 && IsParserWorking())
- {
- nToken = GetNextToken();
- switch(nToken)
- {
- case RTF_SN:
- case RTF_SV:
- SkipGroup();
- break;
- case RTF_TEXTTOKEN:
- s.Append(aToken);
- break;
- case '{':
- level++;
- s.Append(rtl::OUString("{"));
- break;
- case '}':
- level--;
- s.Append(rtl::OUString("}"));
- break;
- default:
- s.Append(aToken);
- if (bTokenHasValue)
- s.Append(rtl::OUString::valueOf(static_cast<sal_Int64>(nTokenValue)));
- s.Append(rtl::OUString(" "));
- break;
- }
- }
- SkipToken(-1);
-}
-
-/*
- * Very basic support for the Z-line.
- */
-void SwRTFParser::ReadDrawingObject()
-{
- int nToken;
- int level;
- level=1;
- Rectangle aRect;
- ::basegfx::B2DPolygon aPolygon;
- ::basegfx::B2DPoint aPoint;
- bool bPolygonActive(false);
-
- SwFmtHoriOrient aHori( 0, text::HoriOrientation::NONE, text::RelOrientation::PAGE_FRAME );
- SwFmtVertOrient aVert( 0, text::VertOrientation::NONE, text::RelOrientation::PAGE_FRAME );
-
- while (level>0 && IsParserWorking())
- {
- nToken = GetNextToken();
- switch(nToken)
- {
- case '}':
- level--;
- break;
- case '{':
- level++;
- break;
- case RTF_DOBXMARGIN:
- aHori.SetRelationOrient( text::RelOrientation::PAGE_PRINT_AREA );
- break;
- case RTF_DOBYMARGIN:
- aVert.SetRelationOrient( text::RelOrientation::PAGE_PRINT_AREA );
- break;
- case RTF_DPX:
- aRect.setX(nTokenValue);
- break;
- case RTF_DPXSIZE:
- aRect.setWidth(nTokenValue);
- break;
- case RTF_DPY:
- aRect.setY(nTokenValue);
- break;
- case RTF_DPYSIZE:
- aRect.setHeight(nTokenValue);
- break;
- case RTF_DPLINE:
- case RTF_DPPOLYCOUNT:
- bPolygonActive = true;
- break;
- case RTF_DPPTX:
- aPoint.setX(nTokenValue);
- break;
- case RTF_DPPTY:
- aPoint.setY(nTokenValue);
-
- if(bPolygonActive)
- {
- aPolygon.append(aPoint);
- }
-
- break;
- default:
- break;
- }
- }
- SkipToken(-1);
-
- if(bPolygonActive && aPolygon.count())
- {
- SdrPathObj* pStroke = new SdrPathObj(OBJ_PLIN, ::basegfx::B2DPolyPolygon(aPolygon));
- SfxItemSet aFlySet(pDoc->GetAttrPool(), RES_FRMATR_BEGIN, RES_FRMATR_END-1);
- SwFmtSurround aSur( SURROUND_PARALLEL );
- aSur.SetContour( false );
- aSur.SetOutside(true);
- aFlySet.Put( aSur );
- SwFmtFollowTextFlow aFollowTextFlow( sal_False );
- aFlySet.Put( aFollowTextFlow );
-
- SwFmtAnchor aAnchor( FLY_AT_PARA );
- aAnchor.SetAnchor( pPam->GetPoint() );
- aFlySet.Put( aAnchor );
-
- aFlySet.Put( aHori );
- aFlySet.Put( aVert );
-
- pDoc->GetOrCreateDrawModel();
- SdrModel* pDrawModel = pDoc->GetDrawModel();
- SdrPage* pDrawPg = pDrawModel->GetPage(0);
- pDrawPg->InsertObject(pStroke, 0);
-
- pStroke->SetSnapRect(aRect);
-
- pDoc->Insert(*pPam, *pStroke, &aFlySet, NULL);
- }
-}
-
-void SwRTFParser::InsertShpObject(SdrObject* pStroke, int _nZOrder)
-{
- SfxItemSet aFlySet(pDoc->GetAttrPool(), RES_FRMATR_BEGIN, RES_FRMATR_END-1);
- SwFmtSurround aSur( SURROUND_THROUGHT );
- aSur.SetContour( false );
- aSur.SetOutside(true);
- aFlySet.Put( aSur );
- SwFmtFollowTextFlow aFollowTextFlow( sal_False );
- aFlySet.Put( aFollowTextFlow );
-
- SwFmtAnchor aAnchor( FLY_AT_PARA );
- aAnchor.SetAnchor( pPam->GetPoint() );
- aFlySet.Put( aAnchor );
-
-
- SwFmtHoriOrient aHori( 0, text::HoriOrientation::NONE, text::RelOrientation::PAGE_FRAME );
- aFlySet.Put( aHori );
-
- SwFmtVertOrient aVert( 0, text::VertOrientation::NONE, text::RelOrientation::PAGE_FRAME );
- aFlySet.Put( aVert );
-
- aFlySet.Put(SvxOpaqueItem(RES_OPAQUE,false));
-
- pDoc->GetOrCreateDrawModel();
- SdrModel* pDrawModel = pDoc->GetDrawModel();
- SdrPage* pDrawPg = pDrawModel->GetPage(0);
- pDrawPg->InsertObject(pStroke);
- pDrawPg->SetObjectOrdNum(pStroke->GetOrdNum(), _nZOrder);
- pDoc->Insert(*pPam, *pStroke, &aFlySet, NULL);
-}
-
::basegfx::B2DPoint rotate(const ::basegfx::B2DPoint& rStart, const ::basegfx::B2DPoint& rEnd)
{
const ::basegfx::B2DVector aVector(rStart - rEnd);
@@ -1340,931 +305,6 @@ void SwRTFParser::InsertShpObject(SdrObject* pStroke, int _nZOrder)
}
-void SwRTFParser::ReadShapeObject()
-{
- int nToken;
- int level;
- level=1;
- ::basegfx::B2DPoint aPointLeftTop;
- ::basegfx::B2DPoint aPointRightBottom;
- String sn;
- sal_Int32 shapeType=-1;
- Graphic aGrf;
- bool bGrfValid=false;
- bool fFilled=true;
- Color fillColor(255, 255, 255);
- bool fLine=true;
- int lineWidth=9525/360;
- String shpTxt;
- bool bshpTxt=false;
- int txflTextFlow=0;
- ::rtl::OUString sDescription, sName;
-
-
- while (level>0 && IsParserWorking())
- {
- nToken = GetNextToken();
- switch(nToken)
- {
- case '}':
- level--;
- break;
- case '{':
- level++;
- break;
- case RTF_SHPLEFT:
- aPointLeftTop.setX(nTokenValue);
- break;
- case RTF_SHPTOP:
- aPointLeftTop.setY(nTokenValue);
- break;
- case RTF_SHPBOTTOM:
- aPointRightBottom.setY(nTokenValue);
- break;
- case RTF_SHPRIGHT:
- aPointRightBottom.setX(nTokenValue);
- break;
- case RTF_SN:
- nToken = GetNextToken();
- OSL_ENSURE(nToken==RTF_TEXTTOKEN, "expected name");
- sn=aToken;
- break;
- case RTF_SV:
- nToken = GetNextToken();
- if (nToken==RTF_TEXTTOKEN)
- {
- if (sn.EqualsAscii("shapeType"))
- {
- shapeType=aToken.ToInt32();
-
- } else if (sn.EqualsAscii("fFilled"))
- {
- fFilled=aToken.ToInt32();
-
- } else if (sn.EqualsAscii("fLine"))
- {
- fLine=aToken.ToInt32();
- } else if (sn.EqualsAscii("lineWidth"))
- {
- lineWidth=aToken.ToInt32()/360;
-
- } else if (sn.EqualsAscii("fillColor"))
- {
- sal_uInt32 nColor=aToken.ToInt32();
- fillColor=Color( (sal_uInt8)nColor, (sal_uInt8)( nColor >> 8 ), (sal_uInt8)( nColor >> 16 ) );
- }else if (sn.EqualsAscii("txflTextFlow"))
- {
- txflTextFlow=aToken.ToInt32();
- }
- else if (sn.EqualsAscii("wzDescription"))
- {
- sDescription = aToken;
- }
- else if(sn.EqualsAscii("wzName"))
- {
- sName = aToken;
- }
- }
- break;
- case RTF_PICT:
- {
- SvxRTFPictureType aPicType;
- bGrfValid=ReadBmpData( aGrf, aPicType );
- }
- break;
- case RTF_SHPRSLT:
- if (shapeType!=1 && shapeType!=20 && shapeType!=75)
- {
- ReadShpRslt();
- }
- break;
- case RTF_SHPTXT:
- ReadShpTxt(shpTxt);
- bshpTxt=true;
- break;
-
- default:
- break;
- }
- }
- SkipToken(-1);
-
- SdrObject* pSdrObject = 0;
- switch(shapeType)
- {
- case 202: /* Text Box */
- case 1: /* Rectangle */
- {
- ::basegfx::B2DRange aRange(aPointLeftTop);
- aRange.expand(aPointRightBottom);
-
- if (txflTextFlow==2) {
- const ::basegfx::B2DPoint a(rotate(aRange.getMinimum(), aRange.getCenter()));
- const ::basegfx::B2DPoint b(rotate(aRange.getMaximum(), aRange.getCenter()));
-
- aRange.reset();
- aRange.expand(a);
- aRange.expand(b);
- }
-
- const Rectangle aRect(FRound(aRange.getMinX()), FRound(aRange.getMinY()), FRound(aRange.getMaxX()), FRound(aRange.getMaxY()));
- SdrRectObj* pStroke = new SdrRectObj(aRect);
- pSdrObject = pStroke;
- pStroke->SetSnapRect(aRect);
- pDoc->GetOrCreateDrawModel(); // create model
- InsertShpObject(pStroke, this->nZOrder++);
- SfxItemSet aSet(pStroke->GetMergedItemSet());
- if (fFilled)
- {
- aSet.Put(XFillStyleItem(XFILL_SOLID));
- aSet.Put(XFillColorItem( String(), fillColor ) );
- }
- else
- {
- aSet.Put(XFillStyleItem(XFILL_NONE));
- }
- if (!fLine) {
- aSet.Put(XLineStyleItem(XLINE_NONE));
- } else {
- aSet.Put( XLineWidthItem( lineWidth/2 ) ); // lineWidth are in 1000th mm, seems that XLineWidthItem expects 1/2 the line width
- }
-
- pStroke->SetMergedItemSet(aSet);
- if (bshpTxt) {
- SdrOutliner& rOutliner=pDoc->GetDrawModel()->GetDrawOutliner(pStroke);
- rOutliner.Clear();
- rtl::OString bs(rtl::OUStringToOString(shpTxt,
- RTL_TEXTENCODING_ASCII_US));
- SvMemoryStream aStream(const_cast<sal_Char*>(bs.getStr()),
- bs.getLength(), STREAM_READ);
- rOutliner.Read(aStream, rtl::OUString(), EE_FORMAT_RTF);
- OutlinerParaObject* pParaObject=rOutliner.CreateParaObject();
- pStroke->NbcSetOutlinerParaObject(pParaObject);
- rOutliner.Clear();
- }
- if (txflTextFlow==2) {
- long nAngle = 90;
- double a = nAngle*100*nPi180;
- pStroke->Rotate(pStroke->GetCurrentBoundRect().Center(), nAngle*100, sin(a), cos(a) );
-
- }
-
- }
- break;
- case 20: /* Line */
- {
- ::basegfx::B2DPolygon aLine;
- aLine.append(aPointLeftTop);
- aLine.append(aPointRightBottom);
-
- SdrPathObj* pStroke = new SdrPathObj(OBJ_PLIN, ::basegfx::B2DPolyPolygon(aLine));
- pSdrObject = pStroke;
-
- InsertShpObject(pStroke, this->nZOrder++);
- SfxItemSet aSet(pStroke->GetMergedItemSet());
- if (!fLine) {
- aSet.Put(XLineStyleItem(XLINE_NONE));
- } else {
- aSet.Put( XLineWidthItem( lineWidth/2 ) ); // lineWidth are in 1000th mm, seems that XLineWidthItem expects 1/2 the line width
- }
-
- pStroke->SetMergedItemSet(aSet);
- }
- break;
- case 75 : /* Picture */
- if (bGrfValid) {
- ::basegfx::B2DRange aRange(aPointLeftTop);
- aRange.expand(aPointRightBottom);
- const Rectangle aRect(FRound(aRange.getMinX()), FRound(aRange.getMinY()), FRound(aRange.getMaxX()), FRound(aRange.getMaxY()));
-
- SdrRectObj* pStroke = new SdrGrafObj(aGrf);
- pSdrObject = pStroke;
- pStroke->SetSnapRect(aRect);
-
- InsertShpObject(pStroke, this->nZOrder++);
- }
- }
- if( pSdrObject )
- {
- pSdrObject->SetDescription(sDescription);
- pSdrObject->SetTitle(sName);
- }
-}
-
-extern void sw3io_ConvertFromOldField( SwDoc& rDoc, sal_uInt16& rWhich,
- sal_uInt16& rSubType, sal_uLong &rFmt,
- sal_uInt16 nVersion );
-
-sal_uInt16 SwRTFParser::ReadRevTbl()
-{
- int nNumOpenBrakets = 1, nToken; // die erste wurde schon vorher erkannt !!
- sal_uInt16 nAuthorTableIndex = 0;
-
- while( nNumOpenBrakets && IsParserWorking() )
- {
- switch( nToken = GetNextToken() )
- {
- case '}': --nNumOpenBrakets; break;
- case '{':
- {
- if( RTF_IGNOREFLAG != GetNextToken() )
- nToken = SkipToken( -1 );
- else if( RTF_UNKNOWNCONTROL != GetNextToken() )
- nToken = SkipToken( -2 );
- else
- {
- ReadUnknownData();
- nToken = GetNextToken();
- if( '}' != nToken )
- eState = SVPAR_ERROR;
- break;
- }
- ++nNumOpenBrakets;
- }
- break;
-
- case RTF_TEXTTOKEN:
- aToken = comphelper::string::stripEnd(aToken, ';');
-
- sal_uInt16 nSWId = pDoc->InsertRedlineAuthor(aToken);
- // Store matchpair
- m_aAuthorInfos[nAuthorTableIndex] = nSWId;
-
- aRevTbl.push_back(aToken);
- nAuthorTableIndex++;
- break;
- }
- }
- SkipToken( -1 );
- return nAuthorTableIndex;
-}
-
-void SwRTFParser::NextToken( int nToken )
-{
- sal_uInt16 eDateFmt;
-
- switch( nToken )
- {
- case RTF_FOOTNOTE:
- {
- //We can only insert a footnote if we're not inside a footnote. e.g.
- //#i7713#
-
- // in insert mode it's also possible to be inside of a footnote!
- bool bInsertIntoFootnote = false;
- if( !IsNewDoc() )
- {
- SwStartNode* pSttNode = pPam->GetNode()->StartOfSectionNode();
- while(pSttNode && pSttNode->IsSectionNode())
- {
- pSttNode = pSttNode->StartOfSectionNode();
- }
- if( SwFootnoteStartNode == pSttNode->GetStartNodeType() )
- bInsertIntoFootnote = true;
- }
- if (!mbIsFootnote && !bInsertIntoFootnote)
- {
- ReadHeaderFooter( nToken );
- SkipToken( -1 ); // Klammer wieder zurueck
- }
- }
- break;
- case RTF_SWG_PRTDATA:
- ReadPrtData();
- break;
- case RTF_XE:
- ReadXEField();
- break;
- case RTF_FIELD:
- ReadField();
- break;
- case RTF_SHPRSLT:
- ReadShpRslt();
- break;
- case RTF_DO:
- ReadDrawingObject();
- break;
- case RTF_SHP:
- ReadShapeObject();
- break;
- case RTF_SHPPICT:
- case RTF_PICT:
- ReadBitmapData();
- break;
-#ifdef READ_OLE_OBJECT
- case RTF_OBJECT:
- ReadOLEData();
- break;
-#endif
- case RTF_TROWD: ReadTable( nToken ); break;
- case RTF_PGDSCTBL:
- if( !IsNewDoc() )
- SkipPageDescTbl();
- else
- ReadPageDescTbl();
- break;
- case RTF_LISTTABLE: ReadListTable(); break;
- case RTF_LISTOVERRIDETABLE: ReadListOverrideTable(); break;
-
- case RTF_LISTTEXT:
- GetAttrSet().Put( SfxUInt16Item( FN_PARAM_NUM_LEVEL, 0 ));
- SkipGroup();
- break;
-
- case RTF_PN:
- if( bNewNumList )
- SkipGroup();
- else
- {
- bStyleTabValid = sal_True;
- if (SwNumRule* pRule = ReadNumSecLevel( nToken ))
- {
- GetAttrSet().Put( SwNumRuleItem( pRule->GetName() ));
-
- if( SFX_ITEM_SET != GetAttrSet().GetItemState( FN_PARAM_NUM_LEVEL, sal_False ))
- GetAttrSet().Put( SfxUInt16Item( FN_PARAM_NUM_LEVEL, 0 ));
- }
- }
- break;
-
-
- case RTF_BKMKSTART:
- if(RTF_TEXTTOKEN == GetNextToken())
- mpBookmarkStart = new BookmarkPosition(*pPam);
- else
- SkipToken(-1);
-
- SkipGroup();
- break;
-
- case RTF_BKMKEND:
- if(RTF_TEXTTOKEN == GetNextToken())
- {
- const String& sBookmark = aToken;
- KeyCode aEmptyKeyCode;
- if (mpBookmarkStart)
- {
- BookmarkPosition aBookmarkEnd(*pPam);
- SwPaM aBookmarkRegion( mpBookmarkStart->maMkNode, mpBookmarkStart->mnMkCntnt,
- aBookmarkEnd.maMkNode, aBookmarkEnd.mnMkCntnt);
- if (*mpBookmarkStart == aBookmarkEnd)
- aBookmarkRegion.DeleteMark();
- pDoc->getIDocumentMarkAccess()->makeMark(aBookmarkRegion, sBookmark, IDocumentMarkAccess::BOOKMARK);
- }
- delete mpBookmarkStart, mpBookmarkStart = 0;
- }
- else
- SkipToken(-1);
-
- SkipGroup();
- break;
-
-
- case RTF_PNSECLVL:{
- if( bNewNumList)
- SkipGroup();
- else
- ReadNumSecLevel( nToken );
- break;
- }
-
- case RTF_PNTEXT:
- case RTF_NONSHPPICT:
- SkipGroup();
- break;
-
- case RTF_DEFFORMAT:
- case RTF_DEFTAB:
- case RTF_DEFLANG:
- // sind zwar Dok-Controls, werden aber manchmal auch vor der
- // Font/Style/Color-Tabelle gesetzt!
- SvxRTFParser::NextToken( nToken );
- break;
-
- case RTF_PAGE:
- if (pTableNode==NULL) { //A \page command within a table is ignored by Word.
- if (lcl_UsedPara(*pPam))
- InsertPara();
- CheckInsNewTblLine();
- pDoc->InsertPoolItem(*pPam,
- SvxFmtBreakItem(SVX_BREAK_PAGE_BEFORE, RES_BREAK), 0);
- }
- break;
-
- case RTF_SECT:
- ReadSectControls( nToken );
- break;
- case RTF_CELL:
- mbReadCellWhileReadSwFly = bReadSwFly; // #i83368#
- if (CantUseTables())
- InsertPara();
- else
- {
- // Tabelle nicht mehr vorhanden ?
- if (USHRT_MAX != nInsTblRow && !pTableNode)
- NewTblLine(); // evt. Line copieren
- GotoNextBox();
- }
- break;
-
- case RTF_ROW:
- bTrowdRead=false;
- if (!CantUseTables())
- {
- // aus der Line raus
- m_nCurrentBox = 0;
- pTableNode = 0;
- // noch in der Tabelle drin?
- SwNodeIndex& rIdx = pPam->GetPoint()->nNode;
- const SwTableNode* pTblNd = rIdx.GetNode().FindTableNode();
- if( pTblNd )
- {
- // search the end of this row
- const SwStartNode* pBoxStt =
- rIdx.GetNode().FindTableBoxStartNode();
- const SwTableBox* pBox = pTblNd->GetTable().GetTblBox(
- pBoxStt->GetIndex() );
- const SwTableLine* pLn = pBox->GetUpper();
- pBox = pLn->GetTabBoxes().back();
- rIdx = *pBox->GetSttNd()->EndOfSectionNode();
- pPam->Move( fnMoveForward, fnGoNode );
- }
- nInsTblRow = static_cast< sal_uInt16 >(GetOpenBrakets());
- SetPardTokenRead( sal_False );
- SwPaM aTmp(*pPam);
- aTmp.Move( fnMoveBackward, fnGoNode );
- }
- ::SetProgressState( rInput.Tell(), pDoc->GetDocShell() );
- break;
-
- case RTF_INTBL:
- if (!CantUseTables())
- {
- if( !pTableNode ) // Tabelle nicht mehr vorhanden ?
- {
- if (RTF_TROWD != GetNextToken())
- NewTblLine(); // evt. Line copieren
- SkipToken(-1);
- }
- else
- {
- // Crsr nicht mehr in der Tabelle ?
- if( !pPam->GetNode()->FindTableNode() )
- {
- // dann wieder in die letzte Box setzen
- // (kann durch einlesen von Flys geschehen!)
- pPam->GetPoint()->nNode = *pTableNode->EndOfSectionNode();
- pPam->Move( fnMoveBackward );
- }
- }
- }
- break;
-
- case RTF_REVTBL:
- ReadRevTbl();
- break;
-
- case RTF_REVISED:
- pRedlineInsert = new SwFltRedline(nsRedlineType_t::REDLINE_INSERT, 0, DateTime(Date( 0 ), Time( 0 )));
- break;
-
- case RTF_DELETED:
- pRedlineDelete = new SwFltRedline(nsRedlineType_t::REDLINE_DELETE, 0, DateTime(Date( 0 ), Time( 0 )));
- break;
-
- case RTF_REVAUTH:
- if (pRedlineInsert)
- {
- sal_uInt16 nRevAuth = static_cast<sal_uInt16>(nTokenValue);
- pRedlineInsert->nAutorNo = m_aAuthorInfos[nRevAuth];
- }
- break;
-
- case RTF_REVAUTHDEL:
- if(pRedlineDelete)
- {
- sal_uInt16 nRevAuthDel = static_cast<sal_uInt16>(nTokenValue);
- pRedlineDelete->nAutorNo = m_aAuthorInfos[nRevAuthDel];
- }
- break;
-
- case RTF_REVDTTM:
- if (pRedlineInsert != NULL)
- pRedlineInsert->aStamp = msfilter::util::DTTM2DateTime(nTokenValue);
-
- break;
-
- case RTF_REVDTTMDEL:
- pRedlineDelete->aStamp = msfilter::util::DTTM2DateTime(nTokenValue);
- break;
-
-
- case RTF_FLY_INPARA:
- // \pard und plain ueberlesen !
- if( '}' != GetNextToken() && '}' != GetNextToken() )
- {
- // Zeichengebundener Fly in Fly
- ReadHeaderFooter( nToken );
- SetPardTokenRead( sal_False );
- }
- break;
-
- case RTF_PGDSCNO:
- if( IsNewDoc() && bSwPageDesc &&
- sal_uInt16(nTokenValue) < pDoc->GetPageDescCnt() )
- {
- const SwPageDesc* pPgDsc =
- &const_cast<const SwDoc *>(pDoc)
- ->GetPageDesc( sal_uInt16(nTokenValue) );
- CheckInsNewTblLine();
- pDoc->InsertPoolItem(*pPam, SwFmtPageDesc( pPgDsc ), 0);
- }
- break;
-
- case RTF_COLUM:
- pDoc->InsertPoolItem(*pPam,
- SvxFmtBreakItem( SVX_BREAK_COLUMN_BEFORE, RES_BREAK ), 0);
- break;
-
- case RTF_DXFRTEXT: // werden nur im Zusammenhang mit Flys ausgewertet
- case RTF_DFRMTXTX:
- case RTF_DFRMTXTY:
- break;
-
- case RTF_CHDATE: eDateFmt = DF_SHORT; goto SETCHDATEFIELD;
- case RTF_CHDATEA: eDateFmt = DF_SSYS; goto SETCHDATEFIELD;
- case RTF_CHDATEL: eDateFmt = DF_LSYS; goto SETCHDATEFIELD;
-SETCHDATEFIELD:
- {
- sal_uInt16 nSubType = DATEFLD, nWhich = RES_DATEFLD;
- sal_uLong nFormat = eDateFmt;
- sw3io_ConvertFromOldField( *pDoc, nWhich, nSubType, nFormat, 0x0110 );
-
- SwDateTimeField aDateFld( (SwDateTimeFieldType*)
- pDoc->GetSysFldType( RES_DATETIMEFLD ), DATEFLD, nFormat);
- CheckInsNewTblLine();
- pDoc->InsertPoolItem(*pPam, SwFmtFld( aDateFld ), 0);
- }
- break;
-
- case RTF_CHTIME:
- {
- sal_uInt16 nSubType = TIMEFLD, nWhich = RES_TIMEFLD;
- sal_uLong nFormat = TF_SSMM_24;
- sw3io_ConvertFromOldField( *pDoc, nWhich, nSubType, nFormat, 0x0110 );
- SwDateTimeField aTimeFld( (SwDateTimeFieldType*)
- pDoc->GetSysFldType( RES_DATETIMEFLD ), TIMEFLD, nFormat);
- CheckInsNewTblLine();
- pDoc->InsertPoolItem(*pPam, SwFmtFld( aTimeFld ), 0);
- }
- break;
-
- case RTF_CHPGN:
- {
- SwPageNumberField aPageFld( (SwPageNumberFieldType*)
- pDoc->GetSysFldType( RES_PAGENUMBERFLD ),
- PG_RANDOM, SVX_NUM_ARABIC );
- CheckInsNewTblLine();
- pDoc->InsertPoolItem(*pPam, SwFmtFld(aPageFld), 0);
- }
- break;
-
- case RTF_CHFTN:
- bFootnoteAutoNum = sal_True;
- break;
-
- case RTF_NOFPAGES:
- if( IsNewDoc() && nTokenValue && -1 != nTokenValue )
- ((SwDocStat&)pDoc->GetDocStat()).nPage = (sal_uInt16)nTokenValue;
- break;
-
- case RTF_NOFWORDS:
- if( IsNewDoc() && nTokenValue && -1 != nTokenValue )
- ((SwDocStat&)pDoc->GetDocStat()).nWord = (sal_uInt16)nTokenValue;
- break;
- case RTF_NOFCHARS:
- if( IsNewDoc() && nTokenValue && -1 != nTokenValue )
- ((SwDocStat&)pDoc->GetDocStat()).nChar = (sal_uInt16)nTokenValue;
- break;
- case RTF_LYTPRTMET:
- if (IsNewDoc())
- pDoc->set(IDocumentSettingAccess::USE_VIRTUAL_DEVICE, false);
- break;
- case RTF_U:
- {
- CheckInsNewTblLine();
- if( nTokenValue )
- aToken = (sal_Unicode )nTokenValue;
- pDoc->InsertString( *pPam, aToken );
- }
- break;
-
- case RTF_USERPROPS:
- ReadUserProperties(); // #i28758 For now we don't support user properties
- break;
-
-// RTF_SUBENTRYINDEX
-
- default:
- switch( nToken & ~(0xff | RTF_SWGDEFS) )
- {
- case RTF_DOCFMT:
- ReadDocControls( nToken );
- break;
- case RTF_SECTFMT:
- ReadSectControls( nToken );
- break;
- case RTF_APOCTL:
- if (nReadFlyDepth < 10)
- {
- nReadFlyDepth++;
- ReadFly( nToken );
- nReadFlyDepth--;
- }
- break;
-
- case RTF_BRDRDEF | RTF_TABLEDEF:
- case RTF_SHADINGDEF | RTF_TABLEDEF:
- case RTF_TABLEDEF:
- ReadTable( nToken );
- break;
-
- case RTF_INFO:
- ReadInfo();
- break;
-
- default:
- if( USHRT_MAX != nInsTblRow &&
- (nInsTblRow > GetOpenBrakets() || IsPardTokenRead() ))
- nInsTblRow = USHRT_MAX;
-
- SvxRTFParser::NextToken( nToken );
- break;
- }
- }
- if( USHRT_MAX != nInsTblRow &&
- (nInsTblRow > GetOpenBrakets() || IsPardTokenRead() ))
- nInsTblRow = USHRT_MAX;
-}
-
-
-
-void SwRTFParser::InsertText()
-{
- bContainsPara = false;
- // dann fuege den String ein, ohne das Attribute am Ende
- // aufgespannt werden.
- CheckInsNewTblLine();
-
- if(pRedlineInsert)
- mpRedlineStack->open(*pPam->GetPoint(), *pRedlineInsert);
- if(pRedlineDelete)
- mpRedlineStack->open(*pPam->GetPoint(), *pRedlineDelete);
-
- pDoc->InsertString( *pPam, aToken );
-
- if(pRedlineDelete)
- {
- mpRedlineStack->close(*pPam->GetPoint(), pRedlineDelete->eType);
- }
-
- if(pRedlineInsert)
- {
- mpRedlineStack->close(*pPam->GetPoint(), pRedlineInsert->eType);
- }
-
-
-}
-
-
-void SwRTFParser::InsertPara()
-{
- bContainsPara = true;
- CheckInsNewTblLine();
- pDoc->AppendTxtNode(*pPam->GetPoint());
-
- // setze das default Style
- if( !bStyleTabValid )
- MakeStyleTab();
-
- SwTxtFmtColl* pColl = NULL;
- std::map<sal_Int32,SwTxtFmtColl*>::iterator iter = aTxtCollTbl.find(0);
-
- if( iter == aTxtCollTbl.end() )
- pColl = pDoc->GetTxtCollFromPool( RES_POOLCOLL_STANDARD, false );
- else
- pColl = iter->second;
-
- pDoc->SetTxtFmtColl( *pPam, pColl );
-
- ::SetProgressState( rInput.Tell(), pDoc->GetDocShell() );
-}
-
-
-
-void SwRTFParser::MovePos( int bForward )
-{
- if( bForward )
- pPam->Move( fnMoveForward );
- else
- pPam->Move( fnMoveBackward );
-}
-
-int SwRTFParser::IsEndPara( SvxNodeIdx* pNd, xub_StrLen nCnt ) const
-{
- SwCntntNode *pNode = pDoc->GetNodes()[pNd->GetIdx()]->GetCntntNode();
- return pNode && pNode->Len() == nCnt;
-}
-
-bool SwRTFParser::UncompressableStackEntry(const SvxRTFItemStackType &rSet)
- const
-{
- /*
- #i21961#
- Seeing as CHARFMT sets all the properties of the charfmt itself, its not
- good enough to just see it as a single property from the point of
- compressing property sets. If bold and charfmt are in a child, and bold is
- in the parent, removing bold from the child will not result in the same
- thing, if the charfmt removes bold itself for example
- */
- bool bRet = false;
- if (rSet.GetAttrSet().Count())
- {
-
- if (SFX_ITEM_SET ==
- rSet.GetAttrSet().GetItemState(RES_TXTATR_CHARFMT, sal_False))
- {
- bRet = true;
- }
- }
- return bRet;
-}
-
-void SwRTFParser::SetEndPrevPara( SvxNodeIdx*& rpNodePos, xub_StrLen& rCntPos )
-{
- SwNodeIndex aIdx( pPam->GetPoint()->nNode );
- SwCntntNode* pNode = pDoc->GetNodes().GoPrevious( &aIdx );
- if( !pNode )
- {
- OSL_FAIL( "keinen vorherigen ContentNode gefunden" );
- }
-
- rpNodePos = new SwNodeIdx( aIdx );
- rCntPos = pNode->Len();
-}
-
-void SwRTFParser::SetAttrInDoc( SvxRTFItemStackType &rSet )
-{
- sal_uLong nSNd = rSet.GetSttNodeIdx(), nENd = rSet.GetEndNodeIdx();
- xub_StrLen nSCnt = rSet.GetSttCnt(), nECnt = rSet.GetEndCnt();
-
- SwPaM aPam( *pPam->GetPoint() );
-
-#if OSL_DEBUG_LEVEL > 0
- OSL_ENSURE( nSNd <= nENd, "Start groesser als Ende" );
- SwNode* pDebugNd = pDoc->GetNodes()[ nSNd ];
- OSL_ENSURE( pDebugNd->IsCntntNode(), "Start kein ContentNode" );
- pDebugNd = pDoc->GetNodes()[ nENd ];
- OSL_ENSURE( pDebugNd->IsCntntNode(), "Ende kein ContentNode" );
-#endif
-
- SwCntntNode* pCNd = pDoc->GetNodes()[ nSNd ]->GetCntntNode();
- aPam.GetPoint()->nNode = nSNd;
- aPam.GetPoint()->nContent.Assign( pCNd, nSCnt );
- aPam.SetMark();
- if( nENd == nSNd )
- aPam.GetPoint()->nContent = nECnt;
- else
- {
- aPam.GetPoint()->nNode = nENd;
- pCNd = aPam.GetCntntNode();
- aPam.GetPoint()->nContent.Assign( pCNd, nECnt );
- }
-
- // setze ueber den Bereich das entsprechende Style
- if( rSet.StyleNo() )
- {
- // setze jetzt das Style
- if( !bStyleTabValid )
- MakeStyleTab();
-
- std::map<sal_Int32,SwTxtFmtColl*>::iterator iter = aTxtCollTbl.find(rSet.StyleNo());
-
- if (iter != aTxtCollTbl.end())
- pDoc->SetTxtFmtColl( aPam, iter->second, false );
- }
-
- const SfxPoolItem* pItem;
- const SfxPoolItem* pCharFmt;
- if (rSet.GetAttrSet().Count() )
- {
-
- // falls eine Zeichenvorlage im Set steht, deren Attribute
- // aus dem Set loeschen. Sonst sind diese doppelt, was man ja
- // nicht will.
- if( SFX_ITEM_SET == rSet.GetAttrSet().GetItemState(
- RES_TXTATR_CHARFMT, sal_False, &pCharFmt ) &&
- ((SwFmtCharFmt*)pCharFmt)->GetCharFmt() )
- {
- const String& rName = ((SwFmtCharFmt*)pCharFmt)->GetCharFmt()->GetName();
- for (SvxRTFStyleTbl::iterator it = GetStyleTbl().begin(); it != GetStyleTbl().end(); ++it)
- {
- SvxRTFStyleType* pStyle = it->second;
- if( pStyle->bIsCharFmt && pStyle->sName == rName )
- {
- // alle Attribute, die schon vom Style definiert sind, aus dem
- // akt. AttrSet entfernen
- SfxItemSet &rAttrSet = rSet.GetAttrSet(),
- &rStyleSet = pStyle->aAttrSet;
- SfxItemIter aIter( rAttrSet );
- sal_uInt16 nWhich = aIter.GetCurItem()->Which();
- while( sal_True )
- {
- const SfxPoolItem* pI;
- if( SFX_ITEM_SET == rStyleSet.GetItemState(
- nWhich, sal_False, &pI ) && *pI == *aIter.GetCurItem())
- rAttrSet.ClearItem( nWhich ); // loeschen
-
- if( aIter.IsAtEnd() )
- break;
- nWhich = aIter.NextItem()->Which();
- }
- break;
- }
- }
-
- pDoc->InsertPoolItem(aPam, *pCharFmt, 0);
- rSet.GetAttrSet().ClearItem(RES_TXTATR_CHARFMT); //test hack
- }
- if (rSet.GetAttrSet().Count())
- {
- // dann setze ueber diesen Bereich die Attrbiute
- SetSwgValues(rSet.GetAttrSet());
- pDoc->InsertItemSet(aPam, rSet.GetAttrSet(),
- nsSetAttrMode::SETATTR_DONTCHGNUMRULE);
- }
- }
-
- if( SFX_ITEM_SET == rSet.GetAttrSet().GetItemState(
- FN_PARAM_NUM_LEVEL, sal_False, &pItem ))
- {
- // dann ueber den Bereich an den Nodes das NodeNum setzen
- for( sal_uLong n = nSNd; n <= nENd; ++n )
- {
- SwTxtNode* pTxtNd = pDoc->GetNodes()[ n ]->GetTxtNode();
- if( pTxtNd )
- {
- pTxtNd->SetAttrListLevel((sal_uInt8) ((SfxUInt16Item*)pItem)->GetValue());
- // Update vom LR-Space abschalten?
- }
- }
- }
-
- if( SFX_ITEM_SET == rSet.GetAttrSet().GetItemState(
- RES_PARATR_NUMRULE, sal_False, &pItem ))
- {
- const SwNumRule* pRule = pDoc->FindNumRulePtr(
- ((SwNumRuleItem*)pItem)->GetValue() );
- if( pRule && ( pRule->IsContinusNum() || !bNewNumList ))
- {
- // diese Rule hat keinen Level, also muss die Einrueckung
- // erhalten bleiben!
- // dann ueber den Bereich an den Nodes das Flag zuruecksetzen
- for( sal_uLong n = nSNd; n <= nENd; ++n )
- {
- SwTxtNode* pTxtNd = pDoc->GetNodes()[ n ]->GetTxtNode();
- if( pTxtNd )
- {
- // Update vom LR-Space abschalten
- pTxtNd->SetNumLSpace( false );
- }
- }
- }
- }
-
- bool bNoNum = true;
- if (
- (SFX_ITEM_SET == rSet.GetAttrSet().GetItemState(RES_PARATR_NUMRULE))
- || (SFX_ITEM_SET == rSet.GetAttrSet().GetItemState(FN_PARAM_NUM_LEVEL))
- )
- {
- bNoNum = false;
- }
-
- if (bNoNum)
- {
- for( sal_uLong n = nSNd; n <= nENd; ++n )
- {
- SwTxtNode* pTxtNd = pDoc->GetNodes()[ n ]->GetTxtNode();
- if( pTxtNd )
- {
- pTxtNd->SetAttr(
- *GetDfltAttr(RES_PARATR_NUMRULE));
- }
- }
- }
-}
-
DocPageInformation::DocPageInformation()
: maBox( RES_BOX ),
mnPaperw(12240), mnPaperh(15840), mnMargl(1800), mnMargr(1800),
@@ -2310,2017 +350,6 @@ rtfSection::rtfSection(const SwPosition &rPos,
{
}
-void rtfSections::push_back(const rtfSection &rSect)
-{
- if (!maSegments.empty() && (maSegments.back().maStart == rSect.maStart))
- maSegments.pop_back();
- maSegments.push_back(rSect);
-}
-
-// lese alle Dokument-Controls ein
-void SwRTFParser::SetPageInformationAsDefault(const DocPageInformation &rInfo)
-{
- //If we are at the beginning of the document then start the document with
- //a segment with these properties. See #i14982# for this requirement
- rtfSection aSect(*pPam->GetPoint(), SectPageInformation(rInfo));
- if (maSegments.empty() || (maSegments.back().maStart == aSect.maStart))
- maSegments.push_back(aSect);
-
- if (!bSwPageDesc && IsNewDoc())
- {
- SwFmtFrmSize aFrmSize(ATT_FIX_SIZE, rInfo.mnPaperw, rInfo.mnPaperh);
-
- SvxLRSpaceItem aLR( static_cast< sal_uInt16 >(rInfo.mnMargl), static_cast< sal_uInt16 >(rInfo.mnMargr), 0, 0, RES_LR_SPACE );
- SvxULSpaceItem aUL( static_cast< sal_uInt16 >(rInfo.mnMargt), static_cast< sal_uInt16 >(rInfo.mnMargb), RES_UL_SPACE );
-
- UseOnPage eUseOn;
- if (rInfo.mbFacingp)
- eUseOn = UseOnPage(nsUseOnPage::PD_MIRROR | nsUseOnPage::PD_HEADERSHARE | nsUseOnPage::PD_FOOTERSHARE);
- else
- eUseOn = UseOnPage(nsUseOnPage::PD_ALL | nsUseOnPage::PD_HEADERSHARE | nsUseOnPage::PD_FOOTERSHARE);
-
- sal_uInt16 nPgStart = static_cast< sal_uInt16 >(rInfo.mnPgnStart);
-
- SvxFrameDirectionItem aFrmDir(rInfo.mbRTLdoc ?
- FRMDIR_HORI_RIGHT_TOP : FRMDIR_HORI_LEFT_TOP, RES_FRAMEDIR);
-
- // direkt an der Standartseite drehen
- SwPageDesc& rPg = pDoc->GetPageDesc( 0 );
- rPg.WriteUseOn( eUseOn );
-
- if (rInfo.mbLandscape)
- rPg.SetLandscape(true);
-
- SwFrmFmt &rFmt1 = rPg.GetMaster(), &rFmt2 = rPg.GetLeft();
-
- rFmt1.SetFmtAttr( aFrmSize ); rFmt2.SetFmtAttr( aFrmSize );
- rFmt1.SetFmtAttr( aLR ); rFmt2.SetFmtAttr( aLR );
- rFmt1.SetFmtAttr( aUL ); rFmt2.SetFmtAttr( aUL );
- rFmt1.SetFmtAttr( aFrmDir ); rFmt2.SetFmtAttr( aFrmDir );
-
- // StartNummer der Seiten setzen
- if (nPgStart != 1)
- {
- SwFmtPageDesc aPgDsc( &rPg );
- aPgDsc.SetNumOffset( nPgStart );
- pDoc->InsertPoolItem( *pPam, aPgDsc, 0 );
- }
- }
-}
-
-void SwRTFParser::SetBorderLine(SvxBoxItem& rBox, sal_uInt16 nLine)
-{
- int bWeiter = true;
- short nLineThickness = 1;
- short nPageDistance = 0;
- sal_uInt8 nCol = 0;
- short nIdx = 0;
-
- int nToken = GetNextToken();
- do {
- switch( nToken )
- {
- case RTF_BRDRS:
- nIdx = 1;
- break;
-
- case RTF_BRDRDB:
- nIdx = 3;
- break;
-
- case RTF_BRDRTRIPLE:
- nIdx = 10;
- break;
-
- case RTF_BRDRTNTHSG:
- nIdx = 11;
- break;
-
- case RTF_BRDRTHTNSG:
- nIdx = 12;
- break;
-
- case RTF_BRDRTNTHTNSG:
- nIdx = 13;
- break;
-
- case RTF_BRDRTNTHMG:
- nIdx = 14;
- break;
-
- case RTF_BRDRTHTNMG:
- nIdx = 15;
- break;
-
- case RTF_BRDRTNTHTNMG:
- nIdx = 16;
- break;
-
- case RTF_BRDRTNTHLG:
- nIdx = 17;
- break;
-
- case RTF_BRDRTHTNLG:
- nIdx = 18;
- break;
-
- case RTF_BRDRTNTHTNLG:
- nIdx = 19;
- break;
-
- case RTF_BRDRWAVY:
- nIdx = 20;
- break;
-
- case RTF_BRDRWAVYDB:
- nIdx = 21;
- break;
-
- case RTF_BRDREMBOSS:
- nIdx = 24;
- break;
-
- case RTF_BRDRENGRAVE:
- nIdx = 25;
- break;
-
- case RTF_BRSP:
- nPageDistance = static_cast< short >(nTokenValue);
- break;
-
- case RTF_BRDRDOT: // SO does not have dashed or dotted lines
- nIdx = 6;
- break;
- case RTF_BRDRDASH:
- nIdx = 7;
- break;
- case RTF_BRDRDASHSM:
- case RTF_BRDRDASHD:
- case RTF_BRDRDASHDD:
- case RTF_BRDRDASHDOTSTR:
- case RTF_BRDRSH: // shading not supported
- case RTF_BRDRCF: // colors not supported
- break;
-
- case RTF_BRDRW:
- nLineThickness = static_cast< short >(nTokenValue);
- break;
- default:
- bWeiter = false;
- SkipToken(-1);
- break;
- }
- if (bWeiter)
- nToken = GetNextToken();
- } while (bWeiter && IsParserWorking());
-
- GetLineIndex(rBox, nLineThickness, nPageDistance, nCol, nIdx, nLine, nLine, 0);
-}
-
-// lese alle Dokument-Controls ein
-void SwRTFParser::ReadDocControls( int nToken )
-{
- int bWeiter = true;
-
- SwFtnInfo aFtnInfo;
- SwEndNoteInfo aEndInfo;
- bool bSetHyph = false;
-
- sal_Bool bEndInfoChgd = sal_False, bFtnInfoChgd = sal_False;
-
- do {
- sal_uInt16 nValue = sal_uInt16( nTokenValue );
- switch( nToken )
- {
- case RTF_RTLDOC:
- maPageDefaults.mbRTLdoc = true;
- break;
- case RTF_LTRDOC:
- maPageDefaults.mbRTLdoc = false;
- break;
- case RTF_LANDSCAPE:
- maPageDefaults.mbLandscape = true;
- break;
- case RTF_PAPERW:
- if( 0 < nTokenValue )
- maPageDefaults.mnPaperw = nTokenValue;
- break;
- case RTF_PAPERH:
- if( 0 < nTokenValue )
- maPageDefaults.mnPaperh = nTokenValue;
- break;
- case RTF_MARGL:
- if( 0 <= nTokenValue )
- maPageDefaults.mnMargl = nTokenValue;
- break;
- case RTF_MARGR:
- if( 0 <= nTokenValue )
- maPageDefaults.mnMargr = nTokenValue;
- break;
- case RTF_MARGT:
- if( 0 <= nTokenValue )
- maPageDefaults.mnMargt = nTokenValue;
- break;
- case RTF_MARGB:
- if( 0 <= nTokenValue )
- maPageDefaults.mnMargb = nTokenValue;
- break;
- case RTF_FACINGP:
- maPageDefaults.mbFacingp = true;
- break;
- case RTF_PGNSTART:
- maPageDefaults.mnPgnStart = nTokenValue;
- break;
- case RTF_ENDDOC:
- case RTF_ENDNOTES:
- aFtnInfo.ePos = FTNPOS_CHAPTER; bFtnInfoChgd = sal_True;
- break;
- case RTF_FTNTJ:
- case RTF_FTNBJ:
- aFtnInfo.ePos = FTNPOS_PAGE; bFtnInfoChgd = sal_True;
- break;
-
- case RTF_AENDDOC:
- case RTF_AENDNOTES:
- case RTF_AFTNTJ:
- case RTF_AFTNBJ:
- case RTF_AFTNRESTART:
- case RTF_AFTNRSTCONT:
- break; // wir kenn nur am Doc Ende und Doc weite Num.!
-
- case RTF_FTNSTART:
- if( nValue )
- {
- aFtnInfo.nFtnOffset = nValue-1;
- bFtnInfoChgd = sal_True;
- }
- break;
- case RTF_AFTNSTART:
- if( nValue )
- {
- aEndInfo.nFtnOffset = nValue-1;
- bEndInfoChgd = sal_True;
- }
- break;
- case RTF_FTNRSTPG:
- aFtnInfo.eNum = FTNNUM_PAGE; bFtnInfoChgd = sal_True;
- break;
- case RTF_FTNRESTART:
- aFtnInfo.eNum = FTNNUM_CHAPTER; bFtnInfoChgd = sal_True;
- break;
- case RTF_FTNRSTCONT:
- aFtnInfo.eNum = FTNNUM_DOC; bFtnInfoChgd = sal_True;
- break;
-
- case RTF_FTNNAR:
- aFtnInfo.aFmt.SetNumberingType(SVX_NUM_ARABIC); bFtnInfoChgd = sal_True; break;
- case RTF_FTNNALC:
- aFtnInfo.aFmt.SetNumberingType(SVX_NUM_CHARS_LOWER_LETTER_N); bFtnInfoChgd = sal_True; break;
- case RTF_FTNNAUC:
- aFtnInfo.aFmt.SetNumberingType(SVX_NUM_CHARS_UPPER_LETTER_N); bFtnInfoChgd = sal_True; break;
- case RTF_FTNNRLC:
- aFtnInfo.aFmt.SetNumberingType(SVX_NUM_ROMAN_LOWER); bFtnInfoChgd = sal_True; break;
- case RTF_FTNNRUC:
- aFtnInfo.aFmt.SetNumberingType(SVX_NUM_ROMAN_UPPER); bFtnInfoChgd = sal_True; break;
- case RTF_FTNNCHI:
- aFtnInfo.aFmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL); bFtnInfoChgd = sal_True; break;
-
- case RTF_AFTNNAR:
- aEndInfo.aFmt.SetNumberingType(SVX_NUM_ARABIC); bEndInfoChgd = sal_True; break;
- case RTF_AFTNNALC:
- aEndInfo.aFmt.SetNumberingType(SVX_NUM_CHARS_LOWER_LETTER_N);
- bEndInfoChgd = sal_True;
- break;
- case RTF_AFTNNAUC:
- aEndInfo.aFmt.SetNumberingType(SVX_NUM_CHARS_UPPER_LETTER_N);
- bEndInfoChgd = sal_True;
- break;
- case RTF_AFTNNRLC:
- aEndInfo.aFmt.SetNumberingType(SVX_NUM_ROMAN_LOWER);
- bEndInfoChgd = sal_True;
- break;
- case RTF_AFTNNRUC:
- aEndInfo.aFmt.SetNumberingType(SVX_NUM_ROMAN_UPPER);
- bEndInfoChgd = sal_True;
- break;
- case RTF_AFTNNCHI:
- aEndInfo.aFmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
- bEndInfoChgd = sal_True;
- break;
- case RTF_HYPHAUTO:
- if (nTokenValue)
- bSetHyph = true;
- //FOO//
- break;
- case RTF_PGBRDRT:
- SetBorderLine(maPageDefaults.maBox, BOX_LINE_TOP);
- break;
-
- case RTF_PGBRDRB:
- SetBorderLine(maPageDefaults.maBox, BOX_LINE_BOTTOM);
- break;
-
- case RTF_PGBRDRL:
- SetBorderLine(maPageDefaults.maBox, BOX_LINE_LEFT);
- break;
-
- case RTF_PGBRDRR:
- SetBorderLine(maPageDefaults.maBox, BOX_LINE_RIGHT);
- break;
-
- case '{':
- {
- short nSkip = 0;
- if( RTF_IGNOREFLAG != GetNextToken() )
- nSkip = -1;
- else if( RTF_DOCFMT != (( nToken = GetNextToken() )
- & ~(0xff | RTF_SWGDEFS)) )
- nSkip = -2;
- else
- {
- SkipGroup(); // erstmal komplett ueberlesen
- // ueberlese noch die schliessende Klammer
- GetNextToken();
- }
- if( nSkip )
- {
- SkipToken( nSkip ); // Ignore wieder zurueck
- bWeiter = sal_False;
- }
- }
- break;
-
- default:
- if( RTF_DOCFMT == (nToken & ~(0xff | RTF_SWGDEFS)) ||
- RTF_UNKNOWNCONTROL == nToken )
- SvxRTFParser::NextToken( nToken );
- else
- bWeiter = sal_False;
- break;
- }
- if( bWeiter )
- nToken = GetNextToken();
- } while( bWeiter && IsParserWorking() );
-
- if (IsNewDoc())
- {
- if( bEndInfoChgd )
- pDoc->SetEndNoteInfo( aEndInfo );
- if( bFtnInfoChgd )
- pDoc->SetFtnInfo( aFtnInfo );
- }
-
- if (!bSwPageDesc)
- {
- SetPageInformationAsDefault(maPageDefaults);
-
- MakeStyleTab();
-
- SwTxtFmtColl *pColl = NULL;
- std::map<sal_Int32,SwTxtFmtColl*>::iterator iter = aTxtCollTbl.find(0);
-
- if (iter == aTxtCollTbl.end())
- pColl = pDoc->GetTxtCollFromPool(RES_POOLCOLL_STANDARD, false );
- else
- pColl = iter->second;
-
- OSL_ENSURE(pColl, "impossible to have no standard style");
-
- if (pColl)
- {
- if (
- IsNewDoc() && bSetHyph &&
- SFX_ITEM_SET != pColl->GetItemState(RES_PARATR_HYPHENZONE,
- false)
- )
- {
- pColl->SetFmtAttr(SvxHyphenZoneItem(true, RES_PARATR_HYPHENZONE));
- }
-
- pDoc->SetTxtFmtColl( *pPam, pColl );
- }
- }
-
- SkipToken( -1 );
-}
-
-void SwRTFParser::MakeStyleTab()
-{
- // dann erzeuge aus der SvxStyle-Tabelle die Swg-Collections
- if( !GetStyleTbl().empty() )
- {
- sal_uInt16 nValidOutlineLevels = 0;
- if( !IsNewDoc() )
- {
- // search all outlined collections
- const SwTxtFmtColls& rColls = *pDoc->GetTxtFmtColls();
- for( sal_uInt16 n = rColls.size(); n; )
- if( rColls[ --n ]->IsAssignedToListLevelOfOutlineStyle())
- nValidOutlineLevels |= 1 << rColls[ n ]->GetAssignedOutlineStyleLevel();//<-end,zhaojianwei
- }
-
- for (SvxRTFStyleTbl::iterator it = GetStyleTbl().begin(); it != GetStyleTbl().end(); ++it)
- {
- sal_uInt16 nNo = it->first;
- SvxRTFStyleType* pStyle = it->second;
- if( pStyle->bIsCharFmt )
- {
- if(aCharFmtTbl.find( nNo ) == aCharFmtTbl.end())
- // existiert noch nicht, also anlegen
- MakeCharStyle( nNo, *pStyle );
- }
- else if( aTxtCollTbl.find( nNo ) == aTxtCollTbl.end() )
- {
- // existiert noch nicht, also anlegen
- MakeStyle( nNo, *pStyle );
- }
-
- }
- bStyleTabValid = sal_True;
- }
-}
-
-static sal_Bool lcl_SetFmtCol( SwFmt& rFmt, sal_uInt16 nCols, sal_uInt16 nColSpace,
- const std::vector<sal_uInt16>& rColumns )
-{
- sal_Bool bSet = sal_False;
- if( nCols && USHRT_MAX != nCols )
- {
- SwFmtCol aCol;
- if( USHRT_MAX == nColSpace )
- nColSpace = 720;
-
- aCol.Init( nCols, nColSpace, USHRT_MAX );
- if( nCols == ( rColumns.size() / 2 ) )
- {
- aCol._SetOrtho( sal_False );
- sal_uInt16 nWishWidth = 0, nHalfPrev = 0;
- for (sal_uInt16 n = 0, i = 0; static_cast<size_t>(n+1) < rColumns.size(); n += 2, ++i)
- {
- SwColumn* pCol = &aCol.GetColumns()[ i ];
- pCol->SetLeft( nHalfPrev );
- sal_uInt16 nSp = rColumns[ n+1 ];
- nHalfPrev = nSp / 2;
- pCol->SetRight( nSp - nHalfPrev );
- pCol->SetWishWidth( rColumns[ n ] +
- pCol->GetLeft() + pCol->GetRight() );
- nWishWidth = nWishWidth + pCol->GetWishWidth();
- }
- aCol.SetWishWidth( nWishWidth );
- }
- rFmt.SetFmtAttr( aCol );
- bSet = sal_True;
- }
- return bSet;
-}
-
-void SwRTFParser::DoHairyWriterPageDesc(int nToken)
-{
- int bWeiter = sal_True;
- do {
- if( '{' == nToken )
- {
- switch( nToken = GetNextToken() )
- {
- case RTF_IGNOREFLAG:
- if( RTF_SECTFMT != (( nToken = GetNextToken() )
- & ~(0xff | RTF_SWGDEFS)) )
- {
- SkipToken( -2 ); // Ignore und Token wieder zurueck
- bWeiter = sal_False;
- break;
- }
- // kein break, Gruppe ueberspringen
-
- case RTF_FOOTER:
- case RTF_HEADER:
- case RTF_FOOTERR:
- case RTF_HEADERR:
- case RTF_FOOTERL:
- case RTF_HEADERL:
- case RTF_FOOTERF:
- case RTF_HEADERF:
- SkipGroup(); // erstmal komplett ueberlesen
- // ueberlese noch die schliessende Klammer
- GetNextToken();
- break;
-
- default:
- SkipToken( -1 ); // Ignore wieder zurueck
- bWeiter = sal_False;
- break;
- }
- }
- else if( RTF_SECTFMT == (nToken & ~(0xff | RTF_SWGDEFS)) ||
- RTF_UNKNOWNCONTROL == nToken )
- SvxRTFParser::NextToken( nToken );
- else
- bWeiter = sal_False;
- if( bWeiter )
- nToken = GetNextToken();
- } while( bWeiter && IsParserWorking() );
- SkipToken( -1 ); // letztes Token wieder zurueck
- return;
-}
-
-void SwRTFParser::ReadSectControls( int nToken )
-{
- //this is some hairy stuff to try and retain writer style page descriptors
- //in rtf, almost certainy a bad idea, but we've inherited it, so here it
- //stays
- if (bInPgDscTbl)
- {
- DoHairyWriterPageDesc(nToken);
- return;
- }
-
- OSL_ENSURE(!maSegments.empty(), "suspicious to have a section with no "
- "page info, though probably legal");
- if (maSegments.empty())
- {
- maSegments.push_back(rtfSection(*pPam->GetPoint(),
- SectPageInformation(maPageDefaults)));
- }
-
- SectPageInformation aNewSection(maSegments.back().maPageInfo);
-
- bool bNewSection = false;
- bool bNewSectionHeader = false;
- const SwFmtHeader* _pKeepHeader = NULL;
- const SwFmtFooter* _pKeepFooter = NULL;
- int bWeiter = true;
- bool bKeepFooter = false;
- do {
- sal_uInt16 nValue = sal_uInt16( nTokenValue );
- switch( nToken )
- {
- case RTF_SECT:
- bNewSection = true;
- bForceNewTable = true;
- break;
- case RTF_SECTD: {
- //Reset to page defaults
- SwPageDesc* oldPageDesc=aNewSection.mpPageHdFt;
- aNewSection = SectPageInformation(maPageDefaults);
- aNewSection.mpPageHdFt=oldPageDesc;
- _pKeepHeader = NULL;
- _pKeepFooter = NULL;
- } break;
- case RTF_PGWSXN:
- if (0 < nTokenValue)
- aNewSection.mnPgwsxn = nTokenValue;
- break;
- case RTF_PGHSXN:
- if (0 < nTokenValue)
- aNewSection.mnPghsxn = nTokenValue;
- break;
- case RTF_MARGLSXN:
- if (0 <= nTokenValue)
- aNewSection.mnMarglsxn = nTokenValue;
- break;
- case RTF_MARGRSXN:
- if (0 <= nTokenValue)
- aNewSection.mnMargrsxn = nTokenValue;
- break;
- case RTF_MARGTSXN:
- if (0 <= nTokenValue)
- aNewSection.mnMargtsxn = nTokenValue;
- break;
- case RTF_MARGBSXN:
- if (0 <= nTokenValue)
- aNewSection.mnMargbsxn = nTokenValue;
- break;
- case RTF_FACPGSXN:
- aNewSection.mbFacpgsxn = true;
- break;
- case RTF_HEADERY:
- aNewSection.mnHeadery = nTokenValue;
- break;
- case RTF_FOOTERY:
- aNewSection.mnFootery = nTokenValue;
- break;
- case RTF_LNDSCPSXN:
- aNewSection.mbLndscpsxn = true;
- break;
- case RTF_PGNSTARTS:
- aNewSection.mnPgnStarts = nTokenValue;
- break;
- case RTF_PGNDEC:
- aNewSection.maNumType.SetNumberingType(SVX_NUM_ARABIC);
- break;
- case RTF_PGNUCRM:
- aNewSection.maNumType.SetNumberingType(SVX_NUM_ROMAN_UPPER);
- break;
- case RTF_PGNLCRM:
- aNewSection.maNumType.SetNumberingType(SVX_NUM_ROMAN_LOWER);
- break;
- case RTF_PGNUCLTR:
- aNewSection.maNumType.SetNumberingType(
- SVX_NUM_CHARS_UPPER_LETTER_N);
- break;
- case RTF_PGNLCLTR:
- aNewSection.maNumType.SetNumberingType(
- SVX_NUM_CHARS_LOWER_LETTER_N);
- break;
- case RTF_SBKNONE:
- aNewSection.mnBkc = 0;
- break;
- case RTF_SBKCOL:
- aNewSection.mnBkc = 1;
- break;
- case RTF_PGBRDRT:
- SetBorderLine(aNewSection.maBox, BOX_LINE_TOP);
- break;
-
- case RTF_PGBRDRB:
- SetBorderLine(aNewSection.maBox, BOX_LINE_BOTTOM);
- break;
-
- case RTF_PGBRDRL:
- SetBorderLine(aNewSection.maBox, BOX_LINE_LEFT);
- break;
-
- case RTF_PGBRDRR:
- SetBorderLine(aNewSection.maBox, BOX_LINE_RIGHT);
- break;
-
- case RTF_PGBRDROPT:
- case RTF_ENDNHERE:
- case RTF_BINFSXN:
- case RTF_BINSXN:
- case RTF_SBKPAGE:
- case RTF_SBKEVEN:
- case RTF_SBKODD:
- case RTF_LINEBETCOL:
- case RTF_LINEMOD:
- case RTF_LINEX:
- case RTF_LINESTARTS:
- case RTF_LINERESTART:
- case RTF_LINEPAGE:
- case RTF_LINECONT:
- case RTF_GUTTERSXN:
- case RTF_PGNCONT:
- case RTF_PGNRESTART:
- case RTF_PGNX:
- case RTF_PGNY:
- case RTF_VERTALT:
- case RTF_VERTALB:
- case RTF_VERTALC:
- case RTF_VERTALJ:
- break;
- case RTF_TITLEPG:
- aNewSection.mbTitlepg = true;
- break;
- case RTF_HEADER:
- case RTF_HEADERL:
- case RTF_HEADERR:
- if (aNewSection.mpPageHdFt!=NULL)
- {
- _pKeepHeader = NULL;
- bKeepFooter = true; // #i82008
- _pKeepFooter = &aNewSection.mpPageHdFt->GetMaster().GetFooter();
- }
- case RTF_FOOTER:
- case RTF_FOOTERL:
- case RTF_FOOTERR:
- if (aNewSection.mpPageHdFt!=NULL && !bKeepFooter )
- {
- _pKeepFooter = NULL;
- _pKeepHeader = &aNewSection.mpPageHdFt->GetMaster().GetHeader();
- }
- bKeepFooter = false;
- if (!bNewSectionHeader) { // If a header is redefined in a section
- bNewSectionHeader=true; // a new header must be created.
- aNewSection.mpPageHdFt=NULL;
- }
- if (!aNewSection.mpPageHdFt)
- {
- String aName(RTL_CONSTASCII_USTRINGPARAM("rtfHdFt"));
- aName += String::CreateFromInt32(maSegments.size());
- sal_uInt16 nPageNo = pDoc->MakePageDesc(aName);
- aNewSection.mpPageHdFt = &pDoc->GetPageDesc(nPageNo);
- aNewSection.mbPageHdFtUsed = true;
- maSegments.maDummyPageNos.push_back(nPageNo);
- }
- ReadHeaderFooter(nToken, aNewSection.mpPageHdFt);
- if (_pKeepHeader) aNewSection.mpPageHdFt->GetMaster().SetFmtAttr(*_pKeepHeader);
- if (_pKeepFooter) aNewSection.mpPageHdFt->GetMaster().SetFmtAttr(*_pKeepFooter);
- break;
- case RTF_FOOTERF:
- case RTF_HEADERF:
- if (!aNewSection.mpTitlePageHdFt)
- {
- String aTitle(RTL_CONSTASCII_USTRINGPARAM("rtfTitleHdFt"));
- aTitle += String::CreateFromInt32(maSegments.size());
- sal_uInt16 nPageNo = pDoc->MakePageDesc(aTitle);
- aNewSection.mpTitlePageHdFt = &pDoc->GetPageDesc(nPageNo);
- aNewSection.mbTitlePageHdFtUsed = true;
- maSegments.maDummyPageNos.push_back(nPageNo);
- }
- ReadHeaderFooter(nToken, aNewSection.mpTitlePageHdFt);
- break;
- case RTF_COLS:
- aNewSection.mnCols = nTokenValue;
- break;
- case RTF_COLSX:
- aNewSection.mnColsx = nTokenValue;
- break;
- case RTF_COLNO:
- {
- // next token must be either colw or colsr
- unsigned long nAktCol = nValue;
- long nWidth = 0, nSpace = 0;
- int nColToken = GetNextToken();
- if (RTF_COLW == nColToken)
- {
- // next token could be colsr (but not required)
- nWidth = nTokenValue;
- if( RTF_COLSR == GetNextToken() )
- nSpace = nTokenValue;
- else
- SkipToken( -1 ); // put back token
- }
- else if (RTF_COLSR == nColToken)
- {
- // next token must be colw (what sense should it make to have colsr only?!)
- nSpace = nTokenValue;
- if( RTF_COLW == GetNextToken() )
- nWidth = nTokenValue;
- else
- // what should we do if an isolated colsr without colw is found? Doesn't make sense!
- SkipToken( -1 ); // put back token
- }
- else
- break;
-
- if (--nAktCol == (aNewSection.maColumns.size() / 2))
- {
- aNewSection.maColumns.push_back(nWidth);
- aNewSection.maColumns.push_back(nSpace);
- }
- }
- break;
- case RTF_STEXTFLOW:
- aNewSection.mnStextflow = nTokenValue;
- break;
- case RTF_RTLSECT:
- aNewSection.mbRTLsection = true;
- break;
- case RTF_LTRSECT:
- aNewSection.mbRTLsection = false;
- break;
- case '{':
- {
- short nSkip = 0;
- if( RTF_IGNOREFLAG != ( nToken = GetNextToken() ))
- nSkip = -1;
- else if( RTF_SECTFMT != (( nToken = GetNextToken() )
- & ~(0xff | RTF_SWGDEFS)) &&
- ( RTF_DOCFMT != ( nToken & ~(0xff | RTF_SWGDEFS))) )
- nSkip = -2;
- else
- {
- // erstmal komplett ueberlesen
- SkipGroup();
- // ueberlese noch die schliessende Klammer
- GetNextToken();
- }
- if (nSkip)
- {
- bWeiter = ((-1 == nSkip) &&
- (
- RTF_FOOTER == nToken || RTF_HEADER == nToken ||
- RTF_FOOTERR == nToken || RTF_HEADERR == nToken ||
- RTF_FOOTERL == nToken || RTF_HEADERL == nToken ||
- RTF_FOOTERF == nToken || RTF_HEADERF == nToken
- ));
- SkipToken (nSkip); // Ignore wieder zurueck
- }
- }
- break;
- case RTF_PAPERW:
- case RTF_PAPERH:
- case RTF_MARGL:
- case RTF_MARGR:
- case RTF_MARGT:
- case RTF_MARGB:
- case RTF_FACINGP:
- OSL_ENSURE(!this, "why are these tokens found in this section?");
- ReadDocControls( nToken );
- break;
- default:
- if (RTF_DOCFMT == (nToken & ~(0xff | RTF_SWGDEFS)))
- ReadDocControls( nToken );
- else if (RTF_SECTFMT == (nToken & ~(0xff | RTF_SWGDEFS)) ||
- RTF_UNKNOWNCONTROL == nToken)
- {
- SvxRTFParser::NextToken(nToken);
- }
- else
- bWeiter = false;
- break;
- }
-
- if (bWeiter)
- nToken = GetNextToken();
- } while (bWeiter && IsParserWorking());
-
- if (bNewSection || maSegments.empty())
- {
- AttrGroupEnd();
- if(!bContainsPara && !bContainsTablePara) // bContainsTablePara is set in rtftbl.cxx
- pDoc->AppendTxtNode(*pPam->GetPoint());
- bContainsPara = false;
- bContainsTablePara = false;
- maSegments.push_back(rtfSection(*pPam->GetPoint(), aNewSection));
- }
- else //modifying/replacing the current section
- {
- SwPaM aPamStart(maSegments.back().maStart);
- maSegments.pop_back();
- maSegments.push_back(rtfSection(*aPamStart.GetPoint(), aNewSection));
- }
-
- SkipToken(-1);
-}
-
-void SwRTFParser::EnterEnvironment()
-{
-}
-
-
-void SwRTFParser::LeaveEnvironment()
-{
- if(pRedlineDelete)
- {
- delete pRedlineDelete;
- pRedlineDelete = 0;
- }
-
- if(pRedlineInsert)
- {
- delete pRedlineInsert;
- pRedlineInsert = 0;
- }
-}
-
-void SwRTFParser::SkipPageDescTbl()
-{
- // I have to use this glorified SkipGroup because the
- // SvParser SkipGroup uses nNextCh which is not set correctly <groan>
- int nNumOpenBrakets = 1;
-
- while( nNumOpenBrakets && IsParserWorking() )
- {
- switch( GetNextToken() )
- {
- case '}':
- {
- --nNumOpenBrakets;
- }
- break;
-
- case '{':
- {
- nNumOpenBrakets++;
- }
- break;
- }
- }
-
- SkipToken( -1 );
-}
-
-
-#define SETPAGEDESC_DEFAULTS() \
- do {\
- aSz.SetWidth( a4.Width() ); aSz.SetHeight( a4.Height() );\
- aLR.SetLeft( 0 ); aLR.SetRight( 0 ); \
- aUL.SetLower( 0 ); aUL.SetUpper( 0 ); \
- aHLR.SetLeft( 0 ); aHLR.SetRight( 0 ); \
- aHUL.SetLower( 0 ); aHUL.SetUpper( 0 ); \
- aFLR.SetLeft( 0 ); aFLR.SetRight( 0 ); \
- aFUL.SetLower( 0 ); aFUL.SetUpper( 0 ); \
- nCols = USHRT_MAX; nColSpace = USHRT_MAX; nAktCol = 0; \
- aFSz.SetHeightSizeType( ATT_MIN_SIZE ); aFSz.SetHeight( 0 ); \
- aHSz.SetHeightSizeType( ATT_MIN_SIZE ); aHSz.SetHeight( 0 ); \
- } while (0)
-
-void SwRTFParser::ReadPageDescTbl()
-{
- // dann erzeuge aus der SvxStyle-Tabelle die Swg-Collections, damit
- // diese auch in den Headers/Footer benutzt werden koennen!
- MakeStyleTab();
- // das default-Style schon gleich am ersten Node setzen
- SwTxtFmtColl* pColl = NULL;
- std::map<sal_Int32,SwTxtFmtColl*>::iterator iter = aTxtCollTbl.find( 0 );
-
- if( iter == aTxtCollTbl.end() )
- pColl = pDoc->GetTxtCollFromPool( RES_POOLCOLL_STANDARD, false );
- else
- pColl = iter->second;
-
- pDoc->SetTxtFmtColl( *pPam, pColl );
-
- int nToken, bSaveChkStyleAttr = IsChkStyleAttr();
- int nNumOpenBrakets = 1; // die erste wurde schon vorher erkannt !!
-
- SetChkStyleAttr(sal_False); // Attribute nicht gegen die Styles checken
-
- bInPgDscTbl = true;
- sal_uInt16 nPos = 0;
- SwPageDesc* pPg = 0;
- SwFrmFmt* pPgFmt = 0;
-
- SvxULSpaceItem aUL( RES_UL_SPACE ), aHUL( RES_UL_SPACE ), aFUL( RES_UL_SPACE );
- SvxLRSpaceItem aLR( RES_LR_SPACE ), aHLR( RES_LR_SPACE ), aFLR( RES_LR_SPACE );
- Size a4 = SvxPaperInfo::GetPaperSize(PAPER_A4);
- SwFmtFrmSize aSz( ATT_FIX_SIZE, a4.Width(), a4.Height() ); // DIN A4 defaulten
- SwFmtFrmSize aFSz( ATT_MIN_SIZE ), aHSz( ATT_MIN_SIZE );
-
- SvxFrameDirectionItem aFrmDir(FRMDIR_HORI_LEFT_TOP, RES_FRAMEDIR);
-
- sal_uInt16 nCols = USHRT_MAX, nColSpace = USHRT_MAX, nAktCol = 0;
- std::vector<sal_uInt16> aColumns;
- ::std::map< const SwPageDesc*, sal_uInt16 > aFollowMap; //store index of following page descriptors
-
- while( nNumOpenBrakets && IsParserWorking() )
- {
- switch( nToken = GetNextToken() )
- {
- case '{':
- ++nNumOpenBrakets;
- break;
- case '}':
- if (1 == --nNumOpenBrakets)
- {
- OSL_ENSURE(pPgFmt && pPg, "Serious problem here");
- if (pPgFmt && pPg)
- {
- // PageDesc ist fertig, setze am Doc
- pPgFmt->SetFmtAttr(aFrmDir);
- pPgFmt->SetFmtAttr(aLR);
- pPgFmt->SetFmtAttr(aUL);
- pPgFmt->SetFmtAttr(aSz);
- ::lcl_SetFmtCol(*pPgFmt, nCols, nColSpace, aColumns);
- if (pPgFmt->GetHeader().GetHeaderFmt())
- {
- SwFrmFmt* pHFmt =
- (SwFrmFmt*)pPgFmt->GetHeader().GetHeaderFmt();
- pHFmt->SetFmtAttr(aHUL);
- pHFmt->SetFmtAttr(aHLR);
- pHFmt->SetFmtAttr(aHSz);
- }
- if (pPgFmt->GetFooter().GetFooterFmt())
- {
- SwFrmFmt* pFFmt =
- (SwFrmFmt*)pPgFmt->GetFooter().GetFooterFmt();
- pFFmt->SetFmtAttr(aHUL);
- pFFmt->SetFmtAttr(aHLR);
- pFFmt->SetFmtAttr(aHSz);
- }
- if( nPos < pDoc->GetPageDescCnt() )
- pDoc->ChgPageDesc(nPos++, *pPg);
- }
- }
- break;
- case RTF_PGDSC:
- if (nPos) // kein && wg MAC
- {
- if (nPos != pDoc->MakePageDesc(
- String::CreateFromInt32(nTokenValue)))
- {
- OSL_FAIL( "PageDesc an falscher Position" );
- }
- }
- pPg = &pDoc->GetPageDesc(nPos);
- pPg->SetLandscape( sal_False );
- pPgFmt = &pPg->GetMaster();
-
- SETPAGEDESC_DEFAULTS();
- break;
-
- case RTF_PGDSCUSE:
- pPg->WriteUseOn( (UseOnPage)nTokenValue );
- break;
-
- case RTF_PGDSCNXT:
- // store index of follow in map; will be fixed up later
- if( nTokenValue )
- aFollowMap.insert( ::std::pair<const SwPageDesc*, sal_uInt16>( pPg, nTokenValue ));
- else
- pPg->SetFollow( &pDoc->GetPageDesc( 0 ) );
- break;
-
- case RTF_FORMULA: /* Zeichen "\|" !!! */
- pPgFmt->SetFmtAttr( aLR );
- pPgFmt->SetFmtAttr( aUL );
- pPgFmt->SetFmtAttr( aSz );
- ::lcl_SetFmtCol( *pPgFmt, nCols, nColSpace, aColumns );
- if( pPgFmt->GetHeader().GetHeaderFmt() )
- {
- SwFrmFmt* pHFmt = (SwFrmFmt*)pPgFmt->GetHeader().GetHeaderFmt();
- pHFmt->SetFmtAttr( aHUL );
- pHFmt->SetFmtAttr( aHLR );
- pHFmt->SetFmtAttr( aHSz );
- }
- if( pPgFmt->GetFooter().GetFooterFmt() )
- {
- SwFrmFmt* pFFmt = (SwFrmFmt*)pPgFmt->GetFooter().GetFooterFmt();
- pFFmt->SetFmtAttr( aHUL );
- pFFmt->SetFmtAttr( aHLR );
- pFFmt->SetFmtAttr( aHSz );
- }
-
- pPgFmt = &pPg->GetLeft();
-
- SETPAGEDESC_DEFAULTS();
- break;
-
- case RTF_RTLSECT:
- aFrmDir.SetValue(FRMDIR_HORI_RIGHT_TOP);
- break;
-
- case RTF_LTRSECT:
- aFrmDir.SetValue(FRMDIR_HORI_LEFT_TOP);
- break;
-
- // alt: LI/RI/SA/SB, neu: MARG?SXN
- case RTF_MARGLSXN:
- case RTF_LI: aLR.SetLeft( (sal_uInt16)nTokenValue ); break;
- case RTF_MARGRSXN:
- case RTF_RI: aLR.SetRight( (sal_uInt16)nTokenValue ); break;
- case RTF_MARGTSXN:
- case RTF_SA: aUL.SetUpper( (sal_uInt16)nTokenValue ); break;
- case RTF_MARGBSXN:
- case RTF_SB: aUL.SetLower( (sal_uInt16)nTokenValue ); break;
- case RTF_PGWSXN: aSz.SetWidth( nTokenValue ); break;
- case RTF_PGHSXN: aSz.SetHeight( nTokenValue ); break;
-
- case RTF_HEADERY: aHUL.SetUpper( (sal_uInt16)nTokenValue ); break;
- case RTF_HEADER_YB: aHUL.SetLower( (sal_uInt16)nTokenValue ); break;
- case RTF_HEADER_XL: aHLR.SetLeft( (sal_uInt16)nTokenValue ); break;
- case RTF_HEADER_XR: aHLR.SetRight( (sal_uInt16)nTokenValue ); break;
- case RTF_FOOTERY: aFUL.SetLower( (sal_uInt16)nTokenValue ); break;
- case RTF_FOOTER_YT: aFUL.SetUpper( (sal_uInt16)nTokenValue ); break;
- case RTF_FOOTER_XL: aFLR.SetLeft( (sal_uInt16)nTokenValue ); break;
- case RTF_FOOTER_XR: aFLR.SetRight( (sal_uInt16)nTokenValue ); break;
-
- case RTF_HEADER_YH:
- if( 0 > nTokenValue )
- {
- aHSz.SetHeightSizeType( ATT_FIX_SIZE );
- nTokenValue = -nTokenValue;
- }
- aHSz.SetHeight( (sal_uInt16)nTokenValue );
- break;
-
- case RTF_FOOTER_YH:
- if( 0 > nTokenValue )
- {
- aFSz.SetHeightSizeType( ATT_FIX_SIZE );
- nTokenValue = -nTokenValue;
- }
- aFSz.SetHeight( (sal_uInt16)nTokenValue );
- break;
-
-
- case RTF_LNDSCPSXN: pPg->SetLandscape( sal_True ); break;
-
- case RTF_COLS: nCols = (sal_uInt16)nTokenValue; break;
- case RTF_COLSX: nColSpace = (sal_uInt16)nTokenValue; break;
-
- case RTF_COLNO:
- nAktCol = (sal_uInt16)nTokenValue;
- if( RTF_COLW == GetNextToken() )
- {
- sal_uInt16 nWidth = sal_uInt16( nTokenValue ), nSpace = 0;
- if( RTF_COLSR == GetNextToken() )
- nSpace = sal_uInt16( nTokenValue );
- else
- SkipToken( -1 ); // wieder zurueck
-
- if( --nAktCol == ( aColumns.size() / 2 ) )
- {
- aColumns.push_back( nWidth );
- aColumns.push_back( nSpace );
- }
- }
- break;
-
- case RTF_PAGEBB:
- {
- pPgFmt->SetFmtAttr( SvxFmtBreakItem( SVX_BREAK_PAGE_BEFORE, RES_BREAK ) );
- }
- break;
-
- case RTF_HEADER:
- case RTF_HEADERL:
- case RTF_HEADERR:
- case RTF_FOOTER:
- case RTF_FOOTERL:
- case RTF_FOOTERR:
- case RTF_FOOTERF:
- case RTF_HEADERF:
- ReadHeaderFooter(nToken, pPg);
- --nNumOpenBrakets; // Klammer wird im ReadAttr ueberlesen!
- break;
- case RTF_TEXTTOKEN:
- if (!DelCharAtEnd(aToken, ';' ).Len())
- break;
- OSL_ENSURE(pPg, "Unexpected missing pPg");
- if (pPg)
- {
- pPg->SetName(aToken);
-
- // sollte es eine Vorlage aus dem Pool sein ??
- sal_uInt16 n = SwStyleNameMapper::GetPoolIdFromUIName(aToken,
- nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC);
- if (USHRT_MAX != n)
- {
- // dann setze bei der Neuen die entsp. PoolId
- pPg->SetPoolFmtId(n);
- }
- }
- break;
- case RTF_BRDBOX:
- if (3 == nNumOpenBrakets)
- {
- ReadBorderAttr(SkipToken(-2),
- (SfxItemSet&)pPgFmt->GetAttrSet());
- --nNumOpenBrakets; // Klammer wird im ReadAttr ueberlesen!
- }
- break;
- case RTF_SHADOW:
- if( 3 == nNumOpenBrakets )
- {
- ReadAttr( SkipToken( -2 ), (SfxItemSet*)&pPgFmt->GetAttrSet() );
- --nNumOpenBrakets; // Klammer wird im ReadAttr ueberlesen!
- }
- break;
-
-
- default:
- if( (nToken & ~0xff ) == RTF_SHADINGDEF )
- ReadBackgroundAttr( nToken, (SfxItemSet&)pPgFmt->GetAttrSet() );
- break;
- }
- }
-
-
- // setze jetzt noch bei allen die entsprechenden Follows !!
- // Die, die ueber die Tabelle eingelesen wurden und einen
- // Follow definiert haben, ist dieser als Tabposition im
- // Follow schon gesetzt.
- for( nPos = 0; nPos < pDoc->GetPageDescCnt(); ++nPos )
- {
- SwPageDesc* pPgDsc = &pDoc->GetPageDesc( nPos );
- std::map< const SwPageDesc*, sal_uInt16 >::const_iterator aIter =
- aFollowMap.find( pPgDsc );
- if (aIter != aFollowMap.end())
- {
- if ((*aIter).second < pDoc->GetPageDescCnt())
- pPgDsc->SetFollow(& pDoc->GetPageDesc((*aIter).second));
- }
- }
-
- SetChkStyleAttr( bSaveChkStyleAttr );
-
- bInPgDscTbl = false;
- nAktPageDesc = 0;
- nAktFirstPageDesc = 0;
- bSwPageDesc = true;
- SkipToken( -1 );
-}
-
-void SwRTFParser::ReadPrtData()
-{
- while( IsParserWorking() )
- {
- int nToken = GetNextToken();
- if( (RTF_TEXTTOKEN != nToken) && ('}' == nToken) )
- break;
- }
-
- SkipToken( -1 ); // schliessende Klammer wieder zurueck!!
-}
-
-static const SwNodeIndex* SetHeader(SwFrmFmt* pHdFtFmt, sal_Bool bReuseOld)
-{
- OSL_ENSURE(pHdFtFmt, "Impossible, no header");
- const SwFrmFmt* pExisting = bReuseOld ?
- pHdFtFmt->GetHeader().GetHeaderFmt() : 0;
- if (!pExisting)
- {
- //No existing header, create a new one
- pHdFtFmt->SetFmtAttr(SwFmtHeader(sal_True));
- pExisting = pHdFtFmt->GetHeader().GetHeaderFmt();
- }
- return pExisting->GetCntnt().GetCntntIdx();
-}
-
-static const SwNodeIndex* SetFooter(SwFrmFmt* pHdFtFmt, sal_Bool bReuseOld)
-{
- OSL_ENSURE(pHdFtFmt, "Impossible, no footer");
- const SwFrmFmt* pExisting = bReuseOld ?
- pHdFtFmt->GetFooter().GetFooterFmt() : 0;
- if (!pExisting)
- {
- //No exist footer, create a new one
- pHdFtFmt->SetFmtAttr(SwFmtFooter(sal_True));
- pExisting = pHdFtFmt->GetFooter().GetFooterFmt();
- }
- return pExisting->GetCntnt().GetCntntIdx();
-}
-
-
-void SwRTFParser::ReadHeaderFooter( int nToken, SwPageDesc* pPageDesc )
-{
- OSL_ENSURE( RTF_FOOTNOTE == nToken ||
- RTF_FLY_INPARA == nToken ||
- pPageDesc, "PageDesc is missing" );
-
- bool bContainsParaCache = bContainsPara;
- // backup all important data
- SwPosition aSavePos( *pPam->GetPoint() );
- SvxRTFItemStack aSaveStack(GetAttrStack());
- GetAttrStack().clear();
-
- // save the fly array - after read, all flys may be set into
- // the header/footer
- SwFlySaveArr aSaveArray(aFlyArr);
- aSaveArray.reserve(255);
- aFlyArr.clear();
- sal_Bool bSetFlyInDoc = sal_True;
-
- const SwNodeIndex* pSttIdx = 0;
- SwFrmFmt* pHdFtFmt = 0;
- SwTxtAttr* pTxtAttr = 0;
- int bDelFirstChar = sal_False;
- bool bOldIsFootnote = mbIsFootnote;
- sal_Bool bOldGrpStt = sal::static_int_cast< sal_Bool, int >(IsNewGroup());
-
- int nNumOpenBrakets = GetOpenBrakets() - 1;
-
- switch( nToken )
- {
- case RTF_FOOTNOTE:
- {
- bool bIsEndNote = RTF_FTNALT == GetNextToken();
- if (!bIsEndNote)
- SkipToken(-1);
-
- SwTxtNode* pTxtNd = pPam->GetNode()->GetTxtNode();
- SwFmtFtn aFtnNote(bIsEndNote);
- xub_StrLen nPos = pPam->GetPoint()->nContent.GetIndex();
-
- if (nPos && !bFootnoteAutoNum)
- {
- pPam->GetPoint()->nContent--;
- nPos--;
- aFtnNote.SetNumStr(rtl::OUString(pTxtNd->GetTxt().GetChar(nPos)));
- ((String&)pTxtNd->GetTxt()).SetChar( nPos, CH_TXTATR_BREAKWORD );
- bDelFirstChar = sal_True;
- }
-
- pTxtAttr = pTxtNd->InsertItem( aFtnNote, nPos, nPos,
- bDelFirstChar ? nsSetAttrMode::SETATTR_NOTXTATRCHR : 0 );
-
- OSL_ENSURE( pTxtAttr, "konnte die Fussnote nicht einfuegen/finden" );
-
- if( pTxtAttr )
- pSttIdx = ((SwTxtFtn*)pTxtAttr)->GetStartNode();
- mbIsFootnote = true;
-
- // wurde an der Position ein Escapement aufgespannt, so entferne
- // das jetzt. Fussnoten sind bei uns immer hochgestellt.
- SvxRTFItemStackType* pTmp = aSaveStack.empty() ? 0 : aSaveStack.back();
- if( pTmp && pTmp->GetSttNodeIdx() ==
- pPam->GetPoint()->nNode.GetIndex() &&
- pTmp->GetSttCnt() == nPos )
- pTmp->GetAttrSet().ClearItem( RES_CHRATR_ESCAPEMENT );
- }
- break;
-
- case RTF_FLY_INPARA:
- {
- xub_StrLen nPos = pPam->GetPoint()->nContent.GetIndex();
- SfxItemSet aSet( pDoc->GetAttrPool(), RES_FRMATR_BEGIN,
- RES_FRMATR_END-1 );
- aSet.Put( SwFmtAnchor( FLY_AS_CHAR ));
- pHdFtFmt = pDoc->MakeFlySection( FLY_AS_CHAR,
- pPam->GetPoint(), &aSet );
-
- pTxtAttr = pPam->GetNode()->GetTxtNode()->GetTxtAttrForCharAt(
- nPos, RES_TXTATR_FLYCNT );
- OSL_ENSURE( pTxtAttr, "konnte den Fly nicht einfuegen/finden" );
-
- pSttIdx = pHdFtFmt->GetCntnt().GetCntntIdx();
- bSetFlyInDoc = sal_False;
- }
- break;
-
- case RTF_HEADERF:
- case RTF_HEADER:
- pPageDesc->WriteUseOn( (UseOnPage)(pPageDesc->ReadUseOn() | nsUseOnPage::PD_HEADERSHARE) );
- pHdFtFmt = &pPageDesc->GetMaster();
- pSttIdx = SetHeader( pHdFtFmt, sal_False );
- break;
-
- case RTF_HEADERL:
- // we cannot have left or right, must have always both
- pPageDesc->WriteUseOn( (UseOnPage)((pPageDesc->ReadUseOn() & ~nsUseOnPage::PD_HEADERSHARE) | nsUseOnPage::PD_ALL));
- SetHeader( pPageDesc->GetRightFmt(), sal_True );
- pHdFtFmt = pPageDesc->GetLeftFmt();
- pSttIdx = SetHeader(pHdFtFmt, sal_False );
- break;
-
- case RTF_HEADERR:
- // we cannot have left or right, must have always both
- pPageDesc->WriteUseOn( (UseOnPage)((pPageDesc->ReadUseOn() & ~nsUseOnPage::PD_HEADERSHARE) | nsUseOnPage::PD_ALL));
- SetHeader( pPageDesc->GetLeftFmt(), sal_True );
- pHdFtFmt = pPageDesc->GetRightFmt();
- pSttIdx = SetHeader(pHdFtFmt, sal_False );
- break;
-
- case RTF_FOOTERF:
- case RTF_FOOTER:
- pPageDesc->WriteUseOn( (UseOnPage)(pPageDesc->ReadUseOn() | nsUseOnPage::PD_FOOTERSHARE) );
- pHdFtFmt = &pPageDesc->GetMaster();
- pSttIdx = SetFooter(pHdFtFmt, sal_False );
- break;
-
- case RTF_FOOTERL:
- // we cannot have left or right, must have always both
- pPageDesc->WriteUseOn( (UseOnPage)((pPageDesc->ReadUseOn() & ~nsUseOnPage::PD_FOOTERSHARE) | nsUseOnPage::PD_ALL));
- SetFooter( pPageDesc->GetRightFmt(), sal_True );
- pHdFtFmt = pPageDesc->GetLeftFmt();
- pSttIdx = SetFooter(pHdFtFmt, sal_False );
- break;
-
- case RTF_FOOTERR:
- // we cannot have left or right, must have always both
- pPageDesc->WriteUseOn( (UseOnPage)((pPageDesc->ReadUseOn() & ~nsUseOnPage::PD_FOOTERSHARE) | nsUseOnPage::PD_ALL));
- SetFooter( pPageDesc->GetLeftFmt(), sal_True );
- pHdFtFmt = pPageDesc->GetRightFmt();
- pSttIdx = SetFooter(pHdFtFmt, sal_False );
- break;
- }
-
- sal_uInt16 nOldFlyArrCnt = aFlyArr.size();
- if( !pSttIdx )
- SkipGroup();
- else
- {
- // es ist auf jedenfall jetzt ein TextNode im Kopf/Fusszeilen-Bereich
- // vorhanden. Dieser muss jetzt nur noch gefunden und der neue Cursor
- // dort hinein gesetzt werden.
- SwCntntNode *pNode = pDoc->GetNodes()[ pSttIdx->GetIndex()+1 ]->
- GetCntntNode();
-
- // immer ans Ende der Section einfuegen !!
- pPam->GetPoint()->nNode = *pNode->EndOfSectionNode();
- pPam->Move( fnMoveBackward );
-
- SwTxtFmtColl* pColl = NULL;
- std::map<sal_Int32,SwTxtFmtColl*>::iterator iter = aTxtCollTbl.find( 0 );
-
- if( iter == aTxtCollTbl.end() )
- pColl = pDoc->GetTxtCollFromPool( RES_POOLCOLL_STANDARD, false );
- else
- pColl = iter->second;
-
- pDoc->SetTxtFmtColl( *pPam, pColl );
-
- SetNewGroup( sal_True );
-
- while( !( nNumOpenBrakets == GetOpenBrakets() && !GetStackPos()) && IsParserWorking() )
- {
- switch( nToken = GetNextToken() )
- {
- case RTF_U:
- if( bDelFirstChar )
- {
- bDelFirstChar = sal_False;
- nToken = 0;
- }
- break;
-
- case RTF_TEXTTOKEN:
- if( bDelFirstChar )
- {
- if( !aToken.Erase( 0, 1 ).Len() )
- nToken = 0;
- bDelFirstChar = sal_False;
- }
- break;
- }
- if( nToken )
- NextToken( nToken );
- }
-
- SetAllAttrOfStk();
- if( !aFlyArr.empty() && bSetFlyInDoc )
- SetFlysInDoc();
-
- // sollte der letze Node leer sein, dann loesche ihn
- // (\par heisst ja Absatzende und nicht neuer Absatz!)
- DelLastNode();
- }
-
- // vom FlyFmt noch die richtigen Attribute setzen
- if( pTxtAttr && RES_TXTATR_FLYCNT == pTxtAttr->Which() )
- {
- // is add a new fly ?
- if( nOldFlyArrCnt < aFlyArr.size() )
- {
- SwFlySave* pFlySave = aFlyArr.back();
- pFlySave->aFlySet.ClearItem( RES_ANCHOR );
- pHdFtFmt->SetFmtAttr( pFlySave->aFlySet );
- delete aFlyArr.back();
- aFlyArr.pop_back();
- }
- else
- {
- // no, so remove the created textattribute
- SwFrmFmt* pFlyFmt = pTxtAttr->GetFlyCnt().GetFrmFmt();
- // remove the pam from the flynode
- *pPam->GetPoint() = aSavePos;
- pDoc->DelLayoutFmt( pFlyFmt );
- }
- }
-
- bFootnoteAutoNum = sal_False; // default auf aus!
-
- // und alles wieder zurueck
- *pPam->GetPoint() = aSavePos;
- if (mbIsFootnote)
- SetNewGroup( bOldGrpStt ); // Status wieder zurueck
- else
- SetNewGroup( sal_False ); // { - Klammer war kein Group-Start!
- mbIsFootnote = bOldIsFootnote;
- GetAttrStack() = aSaveStack;
-
- std::copy(aSaveArray.begin(), aSaveArray.end(), aFlyArr.begin() );
- aSaveArray.clear();
- bContainsPara = bContainsParaCache;
-}
-
-void SwRTFParser::SetSwgValues( SfxItemSet& rSet )
-{
- const SfxPoolItem* pItem;
- // Escapement korrigieren
- if( SFX_ITEM_SET == rSet.GetItemState( RES_CHRATR_ESCAPEMENT, sal_False, &pItem ))
- {
- /* prozentuale Veraenderung errechnen !
- * Formel : (FontSize * 1/20 ) pts Escapement * 2
- * ----------------------- = ----------------
- * 100% x
- */
-
- // die richtige
- long nEsc = ((SvxEscapementItem*)pItem)->GetEsc();
-
- // automatische Ausrichtung wurde schon richtig berechnet
- if( DFLT_ESC_AUTO_SUPER != nEsc && DFLT_ESC_AUTO_SUB != nEsc )
- {
- const SvxFontHeightItem& rFH = GetSize( rSet );
- nEsc *= 1000L;
- if(rFH.GetHeight()) nEsc /= long(rFH.GetHeight()); // #i77256#
-
- SvxEscapementItem aEsc( (short) nEsc,
- ((SvxEscapementItem*)pItem)->GetProp(), RES_CHRATR_ESCAPEMENT);
- rSet.Put( aEsc );
- }
- }
-
- // TabStops anpassen
- if( SFX_ITEM_SET == rSet.GetItemState( RES_PARATR_TABSTOP, sal_False, &pItem ))
- {
- const SvxLRSpaceItem& rLR = GetLRSpace( rSet );
- SvxTabStopItem aTStop( *(SvxTabStopItem*)pItem );
-
- long nOffset = rLR.GetTxtLeft();
- if( nOffset )
- {
- // Tabs anpassen !!
- for( sal_uInt16 n = 0; n < aTStop.Count(); ++n)
- if( SVX_TAB_ADJUST_DEFAULT != aTStop[n].GetAdjustment() )
- {
- const_cast<SvxTabStop&>(aTStop[n]).GetTabPos() -= nOffset;
- }
-
- // negativer Einzug, dann auf 0 Pos einen Tab setzen
- if( rLR.GetTxtFirstLineOfst() < 0 )
- aTStop.Insert( SvxTabStop() );
- }
-
- if( !aTStop.Count() )
- {
- const SvxTabStopItem& rDflt = (const SvxTabStopItem&)rSet.
- GetPool()->GetDefaultItem(RES_PARATR_TABSTOP);
- if( rDflt.Count() )
- aTStop.Insert( &rDflt, 0 );
- }
- rSet.Put( aTStop );
- }
- else if( SFX_ITEM_SET == rSet.GetItemState( RES_LR_SPACE, sal_False, &pItem )
- && ((SvxLRSpaceItem*)pItem)->GetTxtFirstLineOfst() < 0 )
- {
- // negativer Einzug, dann auf 0 Pos einen Tab setzen
- rSet.Put( SvxTabStopItem( 1, 0, SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP ));
- }
-
- // NumRules anpassen
- if( !bStyleTabValid &&
- SFX_ITEM_SET == rSet.GetItemState( RES_PARATR_NUMRULE, sal_False, &pItem ))
- {
- // dann steht im Namen nur ein Verweis in das ListArray
- SwNumRule* pRule = GetNumRuleOfListNo( ((SwNumRuleItem*)pItem)->
- GetValue().ToInt32() );
- if( pRule )
- rSet.Put( SwNumRuleItem( pRule->GetName() ));
- else
- rSet.ClearItem( RES_PARATR_NUMRULE );
-
- }
-
-}
-
-
-SwTxtFmtColl* SwRTFParser::MakeColl(const String& rName, sal_uInt16 nPos,
- sal_uInt8 nOutlineLevel, bool& rbCollExist)
-{
- if( sal_uInt8(-1) == nOutlineLevel )
- nOutlineLevel = MAXLEVEL;
-
- rbCollExist = false;
- SwTxtFmtColl* pColl;
- String aNm( rName );
- if( !aNm.Len() )
- {
- OSL_ENSURE(!this, "not a bug, but I (cmc) want to see an example of this");
- if( !nPos )
- {
- pColl = pDoc->GetTxtCollFromPool( RES_POOLCOLL_STANDARD, false );
- if(nOutlineLevel < MAXLEVEL )
- pColl->AssignToListLevelOfOutlineStyle( nOutlineLevel );
- else
- pColl->DeleteAssignmentToListLevelOfOutlineStyle();
- return pColl;
- }
-
- // erzeuge einen Namen
- aNm.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "NoName(" ));
- aNm += String::CreateFromInt32( nPos );
- aNm += ')';
- }
- ww::sti eSti = ww::GetCanonicalStiFromEnglishName(rName);
- sw::util::ParaStyleMapper::StyleResult aResult =
- maParaStyleMapper.GetStyle(rName, eSti);
- pColl = aResult.first;
- rbCollExist = aResult.second;
- if (IsNewDoc() && rbCollExist)
- {
- pColl->ResetAllFmtAttr(); // #i73790# - method renamed
- rbCollExist = false;
- }
-
- if (!rbCollExist)
- {
- if(nOutlineLevel < MAXLEVEL)
- pColl->AssignToListLevelOfOutlineStyle( nOutlineLevel );
- else
- pColl->DeleteAssignmentToListLevelOfOutlineStyle();
- }
-
- return pColl;
-}
-
-SwCharFmt* SwRTFParser::MakeCharFmt(const String& rName, sal_uInt16 nPos,
- int& rbCollExist)
-{
- rbCollExist = sal_False;
- SwCharFmt* pFmt;
- String aNm( rName );
- if( !aNm.Len() )
- {
- OSL_ENSURE(!this, "not a bug, but I (cmc) want to see an example of this");
- aNm.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "NoName(" ));
- aNm += String::CreateFromInt32( nPos );
- aNm += ')';
- }
-
- ww::sti eSti = ww::GetCanonicalStiFromEnglishName(rName);
- sw::util::CharStyleMapper::StyleResult aResult =
- maCharStyleMapper.GetStyle(rName, eSti);
- pFmt = aResult.first;
- rbCollExist = aResult.second;
- if (IsNewDoc() && rbCollExist)
- {
- pFmt->ResetAllFmtAttr(); // #i73790# - method renamed
- rbCollExist = false;
- }
- return pFmt;
-}
-
-void SwRTFParser::SetStyleAttr( SfxItemSet& rCollSet,
- const SfxItemSet& rStyleSet,
- const SfxItemSet& rDerivedSet )
-{
- rCollSet.Put( rStyleSet );
- if( rDerivedSet.Count() )
- {
- // suche alle Attribute, die neu gesetzt werden:
- const SfxPoolItem* pItem;
- SfxItemIter aIter( rDerivedSet );
- sal_uInt16 nWhich = aIter.GetCurItem()->Which();
- while( sal_True )
- {
- switch( rStyleSet.GetItemState( nWhich, sal_False, &pItem ) )
- {
- case SFX_ITEM_DEFAULT:
- // auf default zuruecksetzen
- if( RES_FRMATR_END > nWhich )
- rCollSet.Put( rCollSet.GetPool()->GetDefaultItem( nWhich ));
- break;
- case SFX_ITEM_SET:
- if( *pItem == *aIter.GetCurItem() ) // gleiches Attribut?
- // definition kommt aus dem Parent
- rCollSet.ClearItem( nWhich ); // loeschen
- break;
- }
-
- if( aIter.IsAtEnd() )
- break;
- nWhich = aIter.NextItem()->Which();
- }
- }
- // und jetzt noch auf unsere Werte abgleichen
- SetSwgValues( rCollSet );
-}
-
-SwTxtFmtColl* SwRTFParser::MakeStyle( sal_uInt16 nNo, const SvxRTFStyleType& rStyle)
-{
- bool bCollExist;
- SwTxtFmtColl* pColl = MakeColl( rStyle.sName, sal_uInt16(nNo),
- rStyle.nOutlineNo, bCollExist);
- aTxtCollTbl.insert(std::make_pair(nNo,pColl));
-
- // in bestehendes Dok einfuegen, dann keine Ableitung usw. setzen
- if( bCollExist )
- return pColl;
-
- sal_uInt16 nStyleNo = rStyle.nBasedOn;
- if( rStyle.bBasedOnIsSet && nStyleNo != nNo )
- {
- SvxRTFStyleTbl::iterator styleIter = GetStyleTbl().find( nStyleNo );
- SvxRTFStyleType* pDerivedStyle = NULL;
- if ( styleIter != GetStyleTbl().end() )
- pDerivedStyle = styleIter->second;
-
- SwTxtFmtColl* pDerivedColl = NULL;
- std::map<sal_Int32,SwTxtFmtColl*>::iterator iter = aTxtCollTbl.find(nStyleNo);
-
- if(iter == aTxtCollTbl.end() ) // noch nicht vorhanden, also anlegen
- {
- // ist die ueberhaupt als Style vorhanden ?
- pDerivedColl = pDerivedStyle
- ? MakeStyle( nStyleNo, *pDerivedStyle )
- : pDoc->GetTxtCollFromPool( RES_POOLCOLL_STANDARD, false );
- }
- else
- pDerivedColl = iter->second;
-
- if( pColl == pDerivedColl )
- ((SfxItemSet&)pColl->GetAttrSet()).Put( rStyle.aAttrSet );
- else
- {
- pColl->SetDerivedFrom( pDerivedColl );
-
- // setze die richtigen Attribute
- const SfxItemSet* pDerivedSet;
- if( pDerivedStyle )
- pDerivedSet = &pDerivedStyle->aAttrSet;
- else
- pDerivedSet = &pDerivedColl->GetAttrSet();
-
- SetStyleAttr( (SfxItemSet&)pColl->GetAttrSet(),
- rStyle.aAttrSet, *pDerivedSet );
- }
- }
- else
- ((SfxItemSet&)pColl->GetAttrSet()).Put( rStyle.aAttrSet );
-
-
- nStyleNo = rStyle.nNext;
- if( nStyleNo != nNo )
- {
- SwTxtFmtColl* pNext = NULL;
- std::map<sal_Int32,SwTxtFmtColl*>::iterator iter = aTxtCollTbl.find( nStyleNo );
-
- if( iter == aTxtCollTbl.end()) // noch nicht vorhanden, also anlegen
- {
- // ist die ueberhaupt als Style vorhanden ?
- SvxRTFStyleTbl::iterator styleIter = GetStyleTbl().find( nStyleNo );
- if ( styleIter != GetStyleTbl().end() )
- pNext = MakeStyle( nStyleNo, *styleIter->second );
- else
- pNext = pDoc->GetTxtCollFromPool( RES_POOLCOLL_STANDARD, false );
- }
- else
- pNext = iter->second;
-
- pColl->SetNextTxtFmtColl( *pNext );
- }
- return pColl;
-}
-
-SwCharFmt* SwRTFParser::MakeCharStyle( sal_uInt16 nNo, const SvxRTFStyleType& rStyle )
-{
- int bCollExist;
- SwCharFmt* pFmt = MakeCharFmt( rStyle.sName, sal_uInt16(nNo), bCollExist );
- aCharFmtTbl.insert(std::make_pair(nNo,pFmt));
-
- // in bestehendes Dok einfuegen, dann keine Ableitung usw. setzen
- if( bCollExist )
- return pFmt;
-
- sal_uInt16 nStyleNo = rStyle.nBasedOn;
- if( rStyle.bBasedOnIsSet && nStyleNo != nNo )
- {
- SvxRTFStyleTbl::iterator styleIter = GetStyleTbl().find( nStyleNo );
- SvxRTFStyleType* pDerivedStyle = NULL;
- if ( styleIter != GetStyleTbl().end() )
- pDerivedStyle = styleIter->second;
-
- SwCharFmt* pDerivedFmt = NULL;
- std::map<sal_Int32,SwCharFmt*>::iterator iter = aCharFmtTbl.find( nStyleNo );
-
- if(iter == aCharFmtTbl.end()) // noch nicht vorhanden, also anlegen
- {
- // ist die ueberhaupt als Style vorhanden ?
- pDerivedFmt = pDerivedStyle
- ? MakeCharStyle( nStyleNo, *pDerivedStyle )
- : pDoc->GetDfltCharFmt();
- }
- else
- pDerivedFmt = iter->second;
-
- if( pFmt == pDerivedFmt )
- ((SfxItemSet&)pFmt->GetAttrSet()).Put( rStyle.aAttrSet );
- else
- {
- pFmt->SetDerivedFrom( pDerivedFmt );
-
- // setze die richtigen Attribute
- const SfxItemSet* pDerivedSet;
- if( pDerivedStyle )
- pDerivedSet = &pDerivedStyle->aAttrSet;
- else
- pDerivedSet = &pDerivedFmt->GetAttrSet();
-
- SetStyleAttr( (SfxItemSet&)pFmt->GetAttrSet(),
- rStyle.aAttrSet, *pDerivedSet );
- }
- }
- else
- ((SfxItemSet&)pFmt->GetAttrSet()).Put( rStyle.aAttrSet );
-
- return pFmt;
-}
-
-// loesche den letzten Node (Tabelle/Fly/Ftn/..)
-void SwRTFParser::DelLastNode()
-{
- // sollte der letze Node leer sein, dann loesche ihn
- // (\par heisst ja Absatzende und nicht neuer Absatz!)
-
- if( !pPam->GetPoint()->nContent.GetIndex() )
- {
- sal_uLong nNodeIdx = pPam->GetPoint()->nNode.GetIndex();
- SwCntntNode* pCNd = pDoc->GetNodes()[ nNodeIdx ]->GetCntntNode();
- // paragraphs with page break information are not empty!)
- if(const SfxPoolItem* pItem=&(pCNd->GetAttr( RES_PAGEDESC, sal_False)))
- {
- SwFmtPageDesc* pPageDescItem = ((SwFmtPageDesc*)pItem);
- if (pPageDescItem->GetPageDesc()!=NULL)
- return;
- }
-
- if( pCNd && pCNd->StartOfSectionIndex()+2 <
- pCNd->EndOfSectionIndex() )
- {
- if( !GetAttrStack().empty() )
- {
- // Attribut Stack-Eintraege, muessen ans Ende des vorherigen
- // Nodes verschoben werden.
- sal_Bool bMove = sal_False;
- for( size_t n = GetAttrStack().size(); n; )
- {
- SvxRTFItemStackType* pStkEntry = (SvxRTFItemStackType*)
- GetAttrStack()[ --n ];
- if( nNodeIdx == pStkEntry->GetSttNode().GetIdx() )
- {
- if( !bMove )
- {
- pPam->Move( fnMoveBackward );
- bMove = sal_True;
- }
- pStkEntry->SetStartPos( SwxPosition( pPam ) );
- }
- }
- if( bMove )
- pPam->Move( fnMoveForward );
- }
- pPam->GetPoint()->nContent.Assign( 0, 0 );
- pPam->SetMark();
- pPam->DeleteMark();
-
- pDoc->GetNodes().Delete( pPam->GetPoint()->nNode );
- }
- }
-}
-
- // fuer Tokens, die im ReadAttr nicht ausgewertet werden
-void SwRTFParser::UnknownAttrToken( int nToken, SfxItemSet* pSet )
-{
- switch( nToken )
- {
- case RTF_INTBL:
- {
- if( !pTableNode ) // Tabelle nicht mehr vorhanden ?
- NewTblLine(); // evt. Line copieren
- else
- {
- static int _do=0;
- // Crsr nicht mehr in der Tabelle ?
- if( !pPam->GetNode()->FindTableNode() && _do )
- {
- sal_uLong nOldPos = pPam->GetPoint()->nNode.GetIndex();
-
- // dann wieder in die letzte Box setzen
- // (kann durch einlesen von Flys geschehen!)
- pPam->GetPoint()->nNode = *pTableNode->EndOfSectionNode();
- pPam->Move( fnMoveBackward );
-
- // alle Attribute, die schon auf den nachfolgen zeigen
- // auf die neue Box umsetzen !!
- SvxRTFItemStack& rAttrStk = GetAttrStack();
- const SvxRTFItemStackType* pStk;
- for( size_t n = 0; n < rAttrStk.size(); ++n )
- if( ( pStk = rAttrStk[ n ])->GetSttNodeIdx() == nOldPos &&
- !pStk->GetSttCnt() )
- ((SvxRTFItemStackType*)pStk)->SetStartPos( SwxPosition( pPam ) );
- }
- }
- }
- break;
-
- case RTF_PAGEBB:
- {
- pSet->Put( SvxFmtBreakItem( SVX_BREAK_PAGE_BEFORE, RES_BREAK ));
- }
- break;
-
- case RTF_PGBRK:
- {
- pSet->Put( SvxFmtBreakItem( 1 == nTokenValue ?
- SVX_BREAK_PAGE_BOTH : SVX_BREAK_PAGE_AFTER, RES_BREAK ));
- }
- break;
-
- case RTF_PGDSCNO:
- if( IsNewDoc() && bSwPageDesc &&
- sal_uInt16(nTokenValue) < pDoc->GetPageDescCnt() )
- {
- const SwPageDesc* pPgDsc = &pDoc->GetPageDesc( (sal_uInt16)nTokenValue );
- pDoc->InsertPoolItem( *pPam, SwFmtPageDesc( pPgDsc ), 0);
- }
- break;
- case RTF_CS:
- {
- std::map<sal_Int32,SwCharFmt*>::iterator iter = aCharFmtTbl.find( nTokenValue );
-
- if(iter != aCharFmtTbl.end())
- pSet->Put( SwFmtCharFmt(iter->second));
- }
- break;
-
- case RTF_LS:
- if( -1 != nTokenValue )
- {
- if( bStyleTabValid )
- {
- // dann ist auch die ListTabelle gueltig, also suche die
- // enstprechende NumRule
- SwNumRule* pRule = GetNumRuleOfListNo( nTokenValue );
- if( pRule )
- pSet->Put( SwNumRuleItem( pRule->GetName() ));
-
- if( SFX_ITEM_SET != pSet->GetItemState( FN_PARAM_NUM_LEVEL, sal_False ))
- pSet->Put( SfxUInt16Item( FN_PARAM_NUM_LEVEL, 0 ));
- }
- else
- {
- // wir sind in der Style-Definitions - Phase. Der Name
- // wird dann spaeter umgesetzt
- // pSet->Put( SwNumRuleItem( String::CreateFromInt32( nTokenValue )));
- }
-
- }
- break;
-
- case RTF_ILVL:
- case RTF_SOUTLVL:
- {
- sal_uInt8 nLevel = MAXLEVEL <= nTokenValue ? MAXLEVEL - 1
- : sal_uInt8( nTokenValue );
- pSet->Put( SfxUInt16Item( FN_PARAM_NUM_LEVEL, nLevel ));
- }
- break;
-
- }
-}
-
-void SwRTFParser::ReadInfo( const sal_Char* pChkForVerNo )
-{
-sal_Char const aChkForVerNo[] = "StarWriter";
-
- // falls nicht schon was vorgegeben wurde, setzen wir unseren Namen
- // rein. Wenn das im Kommentar match, wird im Parser die VersionNummer
- // gelesen und gesetzt
- if( !pChkForVerNo )
- pChkForVerNo = aChkForVerNo;
-
- SvxRTFParser::ReadInfo( pChkForVerNo );
-}
-
-void SwRTFParser::ReadUserProperties()
-{
- // For now we don't support user properties but at least the parser is here.
- // At the moment it just swallows the tokens to prevent them being displayed
- int nNumOpenBrakets = 1, nToken;
-
- while( nNumOpenBrakets && IsParserWorking() )
- {
- switch( nToken = GetNextToken() )
- {
- case '}':
- --nNumOpenBrakets;
- break;
- case '{':
- {
- if( RTF_IGNOREFLAG != GetNextToken() )
- nToken = SkipToken( -1 );
- else if( RTF_UNKNOWNCONTROL != GetNextToken() )
- nToken = SkipToken( -2 );
- else
- {
- // gleich herausfiltern
- ReadUnknownData();
- nToken = GetNextToken();
- if( '}' != nToken )
- eState = SVPAR_ERROR;
- break;
- }
- ++nNumOpenBrakets;
- }
- break;
-
- case RTF_PROPNAME:
- SkipGroup();
- break;
-
- case RTF_PROPTYPE:
- break;
-
- case RTF_STATICVAL:
- SkipGroup();
- break;
-
-// default:
- }
- }
-
- SkipToken( -1 );
-}
-
-
-#ifdef USED
-void SwRTFParser::SaveState( int nToken )
-{
- SvxRTFParser::SaveState( nToken );
-}
-
-void SwRTFParser::RestoreState()
-{
- SvxRTFParser::RestoreState();
-}
-#endif
-
-/**/
-
BookmarkPosition::BookmarkPosition(const SwPaM &rPaM)
: maMkNode(rPaM.GetMark()->nNode),
mnMkCntnt(rPaM.GetMark()->nContent.GetIndex())
diff --git a/sw/source/filter/rtf/swparrtf.hxx b/sw/source/filter/rtf/swparrtf.hxx
index 1ff1cbfb958b..86a0815f980c 100644
--- a/sw/source/filter/rtf/swparrtf.hxx
+++ b/sw/source/filter/rtf/swparrtf.hxx
@@ -50,7 +50,6 @@ class SwTxtFmtColl;
class SwTableNode;
class SwCharFmt;
class SwNumRule;
-class SwRTFParser;
class SvxFontItem;
class SwRelNumRuleSpaces;
class SwNodeNum;
@@ -221,243 +220,6 @@ public:
bool IsLandScape() const { return maPageInfo.mbLndscpsxn; }
};
-class rtfSections
-{
-private:
- SwRTFParser &mrReader;
- std::deque<rtfSection> maSegments;
- typedef std::deque<rtfSection>::iterator mySegIter;
- typedef std::deque<rtfSection>::reverse_iterator mySegrIter;
-
- struct wwULSpaceData
- {
- bool bHasHeader, bHasFooter;
- short nSwHLo, nHdUL, nSwFUp, nFtUL, nSwUp, nSwLo;
- wwULSpaceData() : bHasHeader(false), bHasFooter(false), nSwHLo(0), nHdUL(0), nSwFUp(0), nFtUL(0), nSwUp(0), nSwLo(0) {}
- };
-
- void SetSegmentToPageDesc(const rtfSection &rSection, bool bTitlePage,
- bool bIgnoreCols);
- SwSectionFmt *InsertSection(SwPaM& rMyPaM, rtfSection &rSection);
- void SetPage(SwPageDesc &rInPageDesc, SwFrmFmt &rFmt,
- const rtfSection &rSection, bool bIgnoreCols);
- void GetPageULData(const rtfSection &rSection, bool bFirst,
- wwULSpaceData& rData);
- void SetPageULSpaceItems(SwFrmFmt &rFmt, wwULSpaceData& rData);
- bool SetCols(SwFrmFmt &rFmt, const rtfSection &rSection,
- sal_uInt16 nNettoWidth);
- void SetHdFt(rtfSection &rSection);
- void CopyFrom(const SwPageDesc &rFrom, SwPageDesc &rDest);
- void MoveFrom(SwPageDesc &rFrom, SwPageDesc &rDest);
-public:
- bool empty() const { return maSegments.empty(); }
- int size() const { return maSegments.size(); }
- void push_back(const rtfSection &rSect);
- void pop_back() { maSegments.pop_back(); }
- rtfSection& back() { return maSegments.back(); }
- const rtfSection& back() const { return maSegments.back(); }
- void InsertSegments(bool bIsNewDoc);
- rtfSections(SwRTFParser &rReader) : mrReader(rReader) {}
- std::vector<sal_uInt16> maDummyPageNos;
- typedef std::vector<sal_uInt16>::reverse_iterator myrDummyIter;
- void PrependedInlineNode(const SwPosition &rPos,
- const SwNode &rNode);
-};
-
-
-
-
-class SwRTFParser : public SvxRTFParser
-{
- /*
- Knows which writer style a given word style should be imported as.
- */
- sw::util::ParaStyleMapper maParaStyleMapper;
- sw::util::CharStyleMapper maCharStyleMapper;
-
- std::vector<String> aRevTbl;
-
- friend class rtfSections;
- DocPageInformation maPageDefaults;
- rtfSections maSegments;
-
- sw::util::InsertedTablesManager maInsertedTables;
- std::map<sal_Int32,SwTxtFmtColl*> aTxtCollTbl;
- std::map<sal_Int32,SwCharFmt*> aCharFmtTbl;
- SwFlySaveArr aFlyArr; // Flys als Letzes im Doc setzen
- std::vector<bool> aMergeBoxes; // Flags fuer gemergte Zellen
- SwListArr aListArr;
- std::vector<SwCharFmt*> aRubyCharFmts;
- BookmarkPosition* mpBookmarkStart;
- sw::util::RedlineStack *mpRedlineStack;
- sw::util::AuthorInfos m_aAuthorInfos;
-
- SfxItemSet* pGrfAttrSet;
- SwTableNode* pTableNode, *pOldTblNd; // fuers Lesen von Tabellen: akt. Tab
- SwNodeIndex* pSttNdIdx;
- SwNodeIndex* pRegionEndIdx;
- SwDoc* pDoc;
- SwPaM* pPam; // SwPosition duerfte doch reichen, oder ??
- SwRelNumRuleSpaces* pRelNumRule; // Liste aller benannten NumRules
-
- String sNestedFieldStr;
- SwFltRedline *pRedlineInsert;
- SwFltRedline *pRedlineDelete;
-
- String sBaseURL;
-
- sal_uInt16 nAktPageDesc, nAktFirstPageDesc;
- sal_uInt16 m_nCurrentBox;
- sal_uInt16 nInsTblRow; // beim nach \row kein \pard -> neue Line anlegen
- sal_uInt16 nNewNumSectDef; // jeder SectionWechsel kann neue Rules definieren
- sal_uInt16 nRowsToRepeat;
-
- bool bSwPageDesc;
- bool bReadSwFly; // lese Swg-Fly (wichtig fuer Bitmaps!)
- bool mbReadCellWhileReadSwFly; // #i83368#
- bool mbReadNoTbl; // verhinder Tabelle in Tabelle/FootNote
- bool mbIsFootnote;
- bool bFootnoteAutoNum; // automatische Numerierung ?
- bool bStyleTabValid; // Styles schon erzeugt ?
- bool bInPgDscTbl; // beim PageDescTbl lesen
- bool bNewNumList; // Word 7.0 NumList gelesen, 6.0 ueberspringen
- bool bFirstContinue; // 1.Call ins Continue
- bool bContainsPara; // If there is no paragraph in the section
- bool bContainsTablePara; // If there is an table in this section
- bool bForceNewTable; // Forces a beginning of a new table
- bool bNestedField;
- bool bTrowdRead; // True, iff an \trowd definition was read after the last \row
-
- int nReadFlyDepth;
-
- int nZOrder;
- /*
- #i9243#
- In a footnote tables are not possible (for some obscure reason!)
- */
- bool CantUseTables() const { return mbReadNoTbl || mbIsFootnote; }
-
- virtual void InsertPara();
- virtual void InsertText();
- virtual void MovePos( int bForward = sal_True );
- virtual void SetEndPrevPara( SvxNodeIdx*& rpNodePos, xub_StrLen& rCntPos );
- void EnterEnvironment();
- void LeaveEnvironment();
-
- SwFmtPageDesc* GetCurrentPageDesc(SwPaM *pPam);
- void CheckInsNewTblLine();
-
- // setze RTF-Werte auf Swg-Werte
- void SetSwgValues( SfxItemSet& rSet );
-
- virtual void ReadInfo( const sal_Char* pChkForVerNo = 0 );
-
- void ReadUserProperties();
-
- void ReadListLevel( SwNumRule& rRule, sal_uInt8 nLvl );
- void SetBorderLine(SvxBoxItem& rBox, sal_uInt16 nLine);
- void ReadListTable();
- sal_uInt16 ReadRevTbl();
- void ReadShpRslt();
- void ReadShpTxt(String &shpTxt);
- void ReadDrawingObject();
- void InsertShpObject(SdrObject* pStroke, int nZOrder);
- void ReadShapeObject();
- void ReadListOverrideTable();
- SwNumRule *ReadNumSecLevel( int nToken );
- SwNumRule* GetNumRuleOfListNo( long nListNo,
- sal_Bool bRemoveFromList = sal_False );
- void RemoveUnusedNumRule( SwNumRule* );
- void RemoveUnusedNumRules();
- const Font* FindFontOfItem( const SvxFontItem& rItem ) const;
-
- // 3 Methoden zum Aufbauen der Styles
- SwTxtFmtColl* MakeColl( const String&, sal_uInt16 nPos, sal_uInt8 nOutlineLevel,
- bool& rbCollExist );
- SwCharFmt* MakeCharFmt( const String& rName, sal_uInt16 nPos,
- int& rbCollExist );
- void SetStyleAttr( SfxItemSet& rCollSet,
- const SfxItemSet& rStyleSet,
- const SfxItemSet& rDerivedSet );
- SwTxtFmtColl* MakeStyle( sal_uInt16 nNo, const SvxRTFStyleType& rStyle );
- SwCharFmt* MakeCharStyle( sal_uInt16 nNo, const SvxRTFStyleType& rStyle );
- void MakeStyleTab();
-
- int MakeFieldInst( String& rFieldStr );
-
- // einlesen/einfuegen von Bitmaps
- void InsPicture( const String& rNm,
- const Graphic* = 0, const SvxRTFPictureType* = 0 );
- void _SetPictureSize( const SwNoTxtNode& rNd, const SwNodeIndex& rAnchor,
- SfxItemSet& rSet, const SvxRTFPictureType* = 0 );
-
- void SetFlysInDoc();
- void GetPageSize( Size& rSize ); // Groesse der PagePrintArea
-
- // fuers Einlesen von Tabellen
- void GotoNextBox();
- void NewTblLine();
-
- void DelLastNode(); // loesche den letzten Node (Tabelle/Fly/Ftn/..)
-
- void AddNumRule( SwNumRule* pRule );
- void SetNumRelSpaces();
- void SetOultineRelSpaces( const SwNodeIndex& rStt,
- const SwNodeIndex& rEnd );
- void SetNumLSpace( SwTxtNode& rNd, const SwNodeNum& rNum,
- const SwNumRule& rRule );
- long GetSafePos(long nPos);
-
-protected:
- // wird fuer jedes Token gerufen, das in CallParser erkannt wird
- virtual void NextToken( int nToken );
-
-// virtual void ReadUnknownData();
- virtual void ReadBitmapData();
-#ifdef READ_OLE_OBJECT
- virtual void ReadOLEData();
-#endif
- virtual void SetAttrInDoc( SvxRTFItemStackType &rSet );
- virtual bool UncompressableStackEntry(const SvxRTFItemStackType &rSet) const;
- // fuer Tokens, die im ReadAttr nicht ausgewertet werden
- virtual void UnknownAttrToken( int nToken, SfxItemSet* pSet );
-
- void ReadPrtData();
- void ReadField();
- void ReadXEField();
- void ReadHeaderFooter( int nToken, SwPageDesc* pPageDesc = 0 );
- void ReadDocControls( int nToken );
- void SetPageInformationAsDefault(const DocPageInformation &rInfo);
- void ReadSectControls( int nToken );
- void DoHairyWriterPageDesc(int nToken);
- void ReadFly( int nToken, SfxItemSet* pFillSet = 0 );
- void ReadTable( int nToken );
- void ReadPageDescTbl();
- void SkipPageDescTbl();
- bool IsBorderToken(int nToken);
-
- const String& GetBaseURL() const { return sBaseURL;}
-
- virtual ~SwRTFParser();
-
-public:
- SwRTFParser( SwDoc* pD,
- ::com::sun::star::uno::Reference<
- ::com::sun::star::document::XDocumentProperties> i_xDocProps,
- const SwPaM& rCrsr, SvStream& rIn,
- const String& rBaseURL,
- int bReadNewDoc = sal_True );
-
- virtual SvParserState CallParser(); // Aufruf des Parsers
- virtual int IsEndPara( SvxNodeIdx* pNd, xub_StrLen nCnt ) const;
-
- // fuers asynchrone lesen aus dem SvStream
-// virtual void SaveState( int nToken );
-// virtual void RestoreState();
- virtual void Continue( int nToken );
-};
-
-
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */