/************************************************************** * * 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 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * *************************************************************/ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" #include #include #include #include #include #ifdef DBG_UTIL #include #endif #include #define _SVSTDARR_STRINGS #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // ...Percent() #include #include #include #include // for SwBookmark ... #include #include // for Start/EndAction #include #include #include #include #include #include #include #include #include #include #include #include // ResId for Statusbar #include #define FONTSIZE_MASK 7 #define FONTCOLOR_MASK (1<<15) #define FONT_MASK (1<<14) #define HTML_ESC_PROP 80 #define HTML_ESC_SUPER DFLT_ESC_SUPER #define HTML_ESC_SUB DFLT_ESC_SUB #define HTML_SPTYPE_NONE 0 #define HTML_SPTYPE_BLOCK 1 #define HTML_SPTYPE_HORI 2 #define HTML_SPTYPE_VERT 3 #ifndef TOOLS_CONSTASCII_STRINGPARAM #define TOOLS_CONSTASCII_STRINGPARAM( constAsciiStr ) constAsciiStr, sizeof( constAsciiStr )-1 #endif using namespace ::com::sun::star; //

, , usw. HTMLOptionEnum __FAR_DATA aHTMLPAlignTable[] = { { OOO_STRING_SVTOOLS_HTML_AL_left, SVX_ADJUST_LEFT }, { OOO_STRING_SVTOOLS_HTML_AL_center, SVX_ADJUST_CENTER }, { OOO_STRING_SVTOOLS_HTML_AL_middle, SVX_ADJUST_CENTER }, // Netscape { OOO_STRING_SVTOOLS_HTML_AL_right, SVX_ADJUST_RIGHT }, { OOO_STRING_SVTOOLS_HTML_AL_justify, SVX_ADJUST_BLOCK }, { OOO_STRING_SVTOOLS_HTML_AL_char, SVX_ADJUST_LEFT }, { 0, 0 } }; // static HTMLOptionEnum __FAR_DATA aHTMLSpacerTypeTable[] = { { OOO_STRING_SVTOOLS_HTML_SPTYPE_block, HTML_SPTYPE_BLOCK }, { OOO_STRING_SVTOOLS_HTML_SPTYPE_horizontal, HTML_SPTYPE_HORI }, { OOO_STRING_SVTOOLS_HTML_SPTYPE_vertical, HTML_SPTYPE_VERT }, { 0, 0 } }; SV_IMPL_PTRARR( _HTMLAttrs, _HTMLAttrPtr ) HTMLReader::HTMLReader() { bTmplBrowseMode = sal_True; } String HTMLReader::GetTemplateName() const { String sTemplate( String::CreateFromAscii(TOOLS_CONSTASCII_STRINGPARAM("internal")) ); sTemplate += INET_PATH_TOKEN; sTemplate.AppendAscii( TOOLS_CONSTASCII_STRINGPARAM("html") ); String sTemplateWithoutExt( sTemplate ); #ifndef MAC_WITHOUT_EXT // --> OD 2005-01-26 - first search for OpenDocument Writer/Web template sTemplate.AppendAscii( TOOLS_CONSTASCII_STRINGPARAM(".oth") ); // <-- #endif SvtPathOptions aPathOpt; // OpenDocument Writer/Web template (extension .oth) sal_Bool bSet = aPathOpt.SearchFile( sTemplate, SvtPathOptions::PATH_TEMPLATE ); #ifndef MAC_WITHOUT_EXT if( !bSet ) { // 6.0 (extension .stw) sTemplate = sTemplateWithoutExt; // --> OD 2005-01-26 - no OpenDocument Writer/Web template found. // search for OpenOffice.org Writer/Web template sTemplate.AppendAscii( TOOLS_CONSTASCII_STRINGPARAM(".stw") ); // <-- bSet = aPathOpt.SearchFile( sTemplate, SvtPathOptions::PATH_TEMPLATE ); } #endif if( !bSet ) { sTemplate.Erase(); ASSERT( sal_False, "The html.vor is no longer in the defined directory!"); } return sTemplate; } int HTMLReader::SetStrmStgPtr() { ASSERT( pMedium, "Where is the medium??" ); if( pMedium->IsRemote() || !pMedium->IsStorage() ) { pStrm = pMedium->GetInStream(); return sal_True; } return sal_False; } // Call of generic Read Interface sal_uLong HTMLReader::Read( SwDoc &rDoc, const String& rBaseURL, SwPaM &rPam, const String & rName ) { if( !pStrm ) { ASSERT( pStrm, "HTML-Read without Stream" ); return ERR_SWG_READ_ERROR; } if( !bInsertMode ) { Reader::SetNoOutlineNum( rDoc ); Reader::ResetFrmFmts( rDoc ); // set HTML-template, if the document is not html, // else it is set. if( !rDoc.get(IDocumentSettingAccess::HTML_MODE) ) { rDoc.InsertPoolItem( rPam, SwFmtPageDesc( rDoc.GetPageDescFromPool( RES_POOLPAGE_HTML, false )), 0 ); } } // lock to prevent stealing of the Doc! rDoc.acquire(); sal_uLong nRet = 0; SvParserRef xParser = new SwHTMLParser( &rDoc, rPam, *pStrm, rName, rBaseURL, !bInsertMode, pMedium, IsReadUTF8(), bIgnoreHTMLComments ); SvParserState eState = xParser->CallParser(); if( SVPAR_PENDING == eState ) pStrm->ResetError(); else if( SVPAR_ACCEPTED != eState ) { String sErr( String::CreateFromInt32((sal_Int32)xParser->GetLineNr())); sErr += ','; sErr += String::CreateFromInt32((sal_Int32)xParser->GetLinePos()); // use Stream to carry the error number nRet = *new StringErrorInfo( ERR_FORMAT_ROWCOL, sErr, ERRCODE_BUTTON_OK | ERRCODE_MSG_ERROR ); } return nRet; } /* */ SwHTMLParser::SwHTMLParser( SwDoc* pD, const SwPaM& rCrsr, SvStream& rIn, const String& rPath, const String& rBaseURL, int bReadNewDoc, SfxMedium* pMed, sal_Bool bReadUTF8, sal_Bool bNoHTMLComments ) : SfxHTMLParser( rIn, static_cast< sal_Bool >(bReadNewDoc), pMed ), SwClient( 0 ), aPathToFile( rPath ), sBaseURL( rBaseURL ), pAppletImpl( 0 ), pCSS1Parser( 0 ), pNumRuleInfo( new SwHTMLNumRuleInfo ), pPendStack( 0 ), pDoc( pD ), pActionViewShell( 0 ), pSttNdIdx( 0 ), pTable(0), pFormImpl( 0 ), pMarquee( 0 ), pField( 0 ), pImageMap( 0 ), pImageMaps( 0 ), pFootEndNoteImpl( 0 ), nScriptStartLineNr( 0 ), nBaseFontStMin( 0 ), nFontStMin( 0 ), nDefListDeep( 0 ), nFontStHeadStart( 0 ), nSBModuleCnt( 0 ), nMissingImgMaps( 0 ), nParaCnt( 5 ), // --> OD 2007-10-26 #i83625# nContextStMin( 0 ), nContextStAttrMin( 0 ), // <-- nOpenParaToken( 0 ), eJumpTo( JUMPTO_NONE ), #ifdef DBG_UTIL nContinue( 0 ), #endif eParaAdjust( SVX_ADJUST_END ), bDocInitialized( sal_False ), bSetModEnabled( sal_False ), bInFloatingFrame( sal_False ), bInField( sal_False ), bCallNextToken( sal_False ), bIgnoreRawData( sal_False ), bNoParSpace( sal_False ), bInNoEmbed( sal_False ), bInTitle( sal_False ), bUpdateDocStat( sal_False ), bFixSelectWidth( sal_False ), bFixSelectHeight( sal_False ), bTextArea( sal_False ), bSelect( sal_False ), bInFootEndNoteAnchor( sal_False ), bInFootEndNoteSymbol( sal_False ), // bIgnoreHTMLComments( bNoHTMLComments ) bIgnoreHTMLComments( bNoHTMLComments ), bRemoveHidden( sal_False ), pTempViewFrame(0) { nEventId = 0; bUpperSpace = bViewCreated = bChkJumpMark = bSetCrsr = sal_False; eScriptLang = HTML_SL_UNKNOWN; bAnyStarBasic = sal_True; pPam = new SwPaM( *rCrsr.GetPoint() ); memset( &aAttrTab, 0, sizeof( _HTMLAttrTable )); // read Font-size 1-7 from INI-file SvxHtmlOptions* pHtmlOptions = SvxHtmlOptions::Get(); aFontHeights[0] = pHtmlOptions->GetFontSize( 0 ) * 20; aFontHeights[1] = pHtmlOptions->GetFontSize( 1 ) * 20; aFontHeights[2] = pHtmlOptions->GetFontSize( 2 ) * 20; aFontHeights[3] = pHtmlOptions->GetFontSize( 3 ) * 20; aFontHeights[4] = pHtmlOptions->GetFontSize( 4 ) * 20; aFontHeights[5] = pHtmlOptions->GetFontSize( 5 ) * 20; aFontHeights[6] = pHtmlOptions->GetFontSize( 6 ) * 20; bKeepUnknown = pHtmlOptions->IsImportUnknown(); if(bReadNewDoc) { SvxFontHeightItem aFontHeight(aFontHeights[2], 100, RES_CHRATR_FONTSIZE); pDoc->SetDefault( aFontHeight ); aFontHeight.SetWhich( RES_CHRATR_CJK_FONTSIZE ); pDoc->SetDefault( aFontHeight ); aFontHeight.SetWhich( RES_CHRATR_CTL_FONTSIZE ); pDoc->SetDefault( aFontHeight ); } // during import switch to HTML-Mode, in order // to set correct templates bOldIsHTMLMode = pDoc->get(IDocumentSettingAccess::HTML_MODE); pDoc->set(IDocumentSettingAccess::HTML_MODE, true); pCSS1Parser = new SwCSS1Parser( pDoc, aFontHeights, sBaseURL, IsNewDoc() ); pCSS1Parser->SetIgnoreFontFamily( pHtmlOptions->IsIgnoreFontFamily() ); if( bReadUTF8 ) { SetSrcEncoding( RTL_TEXTENCODING_UTF8 ); } else { SwDocShell *pDocSh = pDoc->GetDocShell(); SvKeyValueIterator *pHeaderAttrs = pDocSh->GetHeaderAttributes(); if( pHeaderAttrs ) SetEncodingByHTTPHeader( pHeaderAttrs ); } pCSS1Parser->SetDfltEncoding( gsl_getSystemTextEncoding() ); // use Timer only with normal Documents! SwDocShell* pDocSh = pDoc->GetDocShell(); if( pDocSh ) { bViewCreated = sal_True; // do not load synchron // a jumppoint is set. if( pMed ) { sJmpMark = pMed->GetURLObject().GetMark(); if( sJmpMark.Len() ) { eJumpTo = JUMPTO_MARK; String sCmp; xub_StrLen nLastPos, nPos = 0; while( STRING_NOTFOUND != ( nLastPos = sJmpMark.Search( cMarkSeperator, nPos + 1 )) ) nPos = nLastPos; if( nPos && ( sCmp = sJmpMark.Copy( nPos + 1 ) ). EraseAllChars().Len() ) { sCmp.ToLowerAscii(); if( sCmp.EqualsAscii( pMarkToRegion ) ) eJumpTo = JUMPTO_REGION; else if( sCmp.EqualsAscii( pMarkToTable ) ) eJumpTo = JUMPTO_TABLE; else if( sCmp.EqualsAscii( pMarkToGraphic ) ) eJumpTo = JUMPTO_GRAPHIC; else if( sCmp.EqualsAscii( pMarkToOutline ) || sCmp.EqualsAscii( pMarkToText ) || sCmp.EqualsAscii( pMarkToFrame ) ) eJumpTo = JUMPTO_NONE; // this is not valid! else // else it is a normal (Book)Mark nPos = STRING_LEN; } else nPos = STRING_LEN; sJmpMark.Erase( nPos ); if( !sJmpMark.Len() ) eJumpTo = JUMPTO_NONE; } } } } __EXPORT SwHTMLParser::~SwHTMLParser() { #ifdef DBG_UTIL ASSERT( !nContinue, "DTOR in Continue - This will not work!!!" ); #endif sal_Bool bAsync = pDoc->IsInLoadAsynchron(); pDoc->SetInLoadAsynchron( sal_False ); pDoc->set(IDocumentSettingAccess::HTML_MODE, bOldIsHTMLMode); if( pDoc->GetDocShell() && nEventId ) Application::RemoveUserEvent( nEventId ); // DocumentDetected may delete DocShells, // so requst it again if( pDoc->GetDocShell() ) { // update linked areas sal_uInt16 nLinkMode = pDoc->getLinkUpdateMode( true ); if( nLinkMode != NEVER && bAsync && SFX_CREATE_MODE_INTERNAL!=pDoc->GetDocShell()->GetCreateMode() ) pDoc->GetLinkManager().UpdateAllLinks( nLinkMode == MANUAL, sal_True, sal_False ); if ( pDoc->GetDocShell()->IsLoading() ) { // --> OD 2006-11-07 #i59688# pDoc->GetDocShell()->LoadingFinished(); } } delete pSttNdIdx; if( aSetAttrTab.Count() ) { ASSERT( !aSetAttrTab.Count(),"There are still attributes on the stack" ); aSetAttrTab.DeleteAndDestroy( 0, aSetAttrTab.Count() ); } delete pPam; delete pCSS1Parser; delete pNumRuleInfo; DeleteFormImpl(); DeleteFootEndNoteImpl(); ASSERT( !pTable, "There is still one open table" ); delete pImageMaps; //delete pTable; ASSERT( !pPendStack, "SwHTMLParser::~SwHTMLParser: There should be no more pending stack here" ); while( pPendStack ) { SwPendingStack* pTmp = pPendStack; pPendStack = pPendStack->pNext; delete pTmp->pData; delete pTmp; } if( !pDoc->release() ) { // no more use for Doc, delete it delete pDoc; pDoc = NULL; } if ( pTempViewFrame ) { pTempViewFrame->DoClose(); // the temporary view frame is hidden, so the hidden flag might need to be removed if ( bRemoveHidden && pDoc && pDoc->GetDocShell() && pDoc->GetDocShell()->GetMedium() ) pDoc->GetDocShell()->GetMedium()->GetItemSet()->ClearItem( SID_HIDDEN ); } } IMPL_LINK( SwHTMLParser, AsyncCallback, void*, /*pVoid*/ ) { nEventId=0; // --> FME 2005-08-18 #i47907# If the document has already been destructed, // the parser should be aware of this: if( ( pDoc->GetDocShell() && pDoc->GetDocShell()->IsAbortingImport() ) || 1 == pDoc->getReferenceCount() ) { // Import of SFX aborted? eState = SVPAR_ERROR; } // <-- GetAsynchCallLink().Call(0); return 0; } SvParserState __EXPORT SwHTMLParser::CallParser() { // set tempory Index, on Pos 0 in order avoid moving! pSttNdIdx = new SwNodeIndex( pDoc->GetNodes() ); if( !IsNewDoc() ) // insert to a new document ? { const SwPosition* pPos = pPam->GetPoint(); pDoc->SplitNode( *pPos, false ); *pSttNdIdx = pPos->nNode.GetIndex()-1; pDoc->SplitNode( *pPos, false ); SwPaM aInsertionRangePam( *pPos ); pPam->Move( fnMoveBackward ); // #106634# split any redline over the insertion point aInsertionRangePam.SetMark(); *aInsertionRangePam.GetPoint() = *pPam->GetPoint(); aInsertionRangePam.Move( fnMoveBackward ); pDoc->SplitRedline( aInsertionRangePam ); pDoc->SetTxtFmtColl( *pPam, pCSS1Parser->GetTxtCollFromPool( RES_POOLCOLL_STANDARD )); } if( GetMedium() ) { if( !bViewCreated ) { nEventId = Application::PostUserEvent( LINK( this, SwHTMLParser, AsyncCallback ), 0 ); } else { bViewCreated = sal_True; nEventId = 0; } } // show progress bar else if( !GetMedium() || !GetMedium()->IsRemote() ) { rInput.Seek(STREAM_SEEK_TO_END); rInput.ResetError(); ::StartProgress( STR_STATSTR_W4WREAD, 0, rInput.Tell(), pDoc->GetDocShell() ); rInput.Seek(STREAM_SEEK_TO_BEGIN); rInput.ResetError(); } SwPageDesc& rDesc = pDoc->_GetPageDesc( 0 ); rDesc.Add( this ); SvParserState eRet = HTMLParser::CallParser(); return eRet; } void __EXPORT SwHTMLParser::Continue( int nToken ) { #ifdef DBG_UTIL ASSERT( !nContinue, "Continue im Continue - That should not be, shouldn't it?" ); nContinue++; #endif // if Import (vom SFX) has been aborted, an error is set // in order to clean up, the process continues ASSERT( SVPAR_ERROR!=eState, "SwHTMLParser::Continue: already set an error" ); if( pDoc->GetDocShell() && pDoc->GetDocShell()->IsAbortingImport() ) eState = SVPAR_ERROR; // get ViewShell from Document, memorize and set as current. ViewShell *pInitVSh = CallStartAction(); if( SVPAR_ERROR != eState && GetMedium() && !bViewCreated ) { // Return at first call, show Doc and wait for timer callback. // At this point, CallParser read only one character and called // SaveState(0) eState = SVPAR_PENDING; bViewCreated = sal_True; pDoc->SetInLoadAsynchron( sal_True ); #ifdef DBG_UTIL nContinue--; #endif return; } bSetModEnabled = sal_False; if( pDoc->GetDocShell() && 0 != (bSetModEnabled = pDoc->GetDocShell()->IsEnableSetModified()) ) { pDoc->GetDocShell()->EnableSetModified( sal_False ); } // during read. do not call OLE-Modify Link aOLELink( pDoc->GetOle2Link() ); pDoc->SetOle2Link( Link() ); sal_Bool bModified = pDoc->IsModified(); bool const bWasUndo = pDoc->GetIDocumentUndoRedo().DoesUndo(); pDoc->GetIDocumentUndoRedo().DoUndo(false); // If Import aborts, do not call Continue. // if a Pending-Stack exists, call NextToken. // NextToken will take care of clean up. if( SVPAR_ERROR == eState ) { ASSERT( !pPendStack || pPendStack->nToken, "SwHTMLParser::Continue: Pending-Stack without Token" ); if( pPendStack && pPendStack->nToken ) NextToken( pPendStack->nToken ); ASSERT( !pPendStack, "SwHTMLParser::Continue: there is still a Pend-Stack" ); } else { HTMLParser::Continue( pPendStack ? pPendStack->nToken : nToken ); } // switch progress bar off EndProgress( pDoc->GetDocShell() ); sal_Bool bLFStripped = sal_False; if( SVPAR_PENDING != GetStatus() ) { // set last Attributes { if( aScriptSource.Len() ) { SwScriptFieldType *pType = (SwScriptFieldType*)pDoc->GetSysFldType( RES_SCRIPTFLD ); SwScriptField aFld( pType, aScriptType, aScriptSource, sal_False ); InsertAttr( SwFmtFld( aFld ) ); } if( pAppletImpl ) { if( pAppletImpl->GetApplet().is() ) EndApplet(); else EndObject(); } // remove LF behind last paragaf if exists if( IsNewDoc() ) bLFStripped = StripTrailingLF() > 0; // end open nummerations. while( GetNumInfo().GetNumRule() ) EndNumBulList(); ASSERT( !nContextStMin, "There are protected contexts" ); nContextStMin = 0; while( aContexts.Count() ) { _HTMLAttrContext *pCntxt = PopContext(); if( pCntxt ) { EndContext( pCntxt ); delete pCntxt; } } if( aParaAttrs.Count() ) aParaAttrs.Remove( 0, aParaAttrs.Count() ); SetAttr( sal_False ); // set deferred Styles pCSS1Parser->SetDelayedStyles(); } // fix again Start if( !IsNewDoc() && pSttNdIdx->GetIndex() ) { SwTxtNode* pTxtNode = pSttNdIdx->GetNode().GetTxtNode(); SwNodeIndex aNxtIdx( *pSttNdIdx ); if( pTxtNode && pTxtNode->CanJoinNext( &aNxtIdx )) { xub_StrLen nStt = pTxtNode->GetTxt().Len(); // if Cursor is in Node, set it to the end if( pPam->GetPoint()->nNode == aNxtIdx ) { pPam->GetPoint()->nNode = *pSttNdIdx; pPam->GetPoint()->nContent.Assign( pTxtNode, nStt ); } #ifdef DBG_UTIL // !!! should not be possible, should it ?? ASSERT( pSttNdIdx->GetIndex()+1 != pPam->GetBound( sal_True ).nNode.GetIndex(), "Pam.Bound1 is in Node" ); ASSERT( pSttNdIdx->GetIndex()+1 != pPam->GetBound( sal_False ).nNode.GetIndex(), "Pam.Bound2 is in 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 // keep character Attribute! SwTxtNode* pDelNd = aNxtIdx.GetNode().GetTxtNode(); if( pTxtNode->GetTxt().Len() ) pDelNd->FmtToTxtAttr( pTxtNode ); else pTxtNode->ChgFmtColl( pDelNd->GetTxtColl() ); pTxtNode->JoinNext(); } } } if( SVPAR_ACCEPTED == eState ) { if( nMissingImgMaps ) { // some image maps were not assigned. // Maybe their Image-Maps are already there? ConnectImageMaps(); } // now delete the last needless paragraph SwPosition* pPos = pPam->GetPoint(); if( !pPos->nContent.GetIndex() && !bLFStripped ) { SwTxtNode* pAktNd; sal_uLong nNodeIdx = pPos->nNode.GetIndex(); sal_Bool bHasFlysOrMarks = HasCurrentParaFlys() || HasCurrentParaBookmarks( sal_True ); if( IsNewDoc() ) { const SwNode *pPrev = pDoc->GetNodes()[nNodeIdx -1]; if( !pPam->GetPoint()->nContent.GetIndex() && ( pPrev->IsCntntNode() || (pPrev->IsEndNode() && pPrev->StartOfSectionNode()->IsSectionNode()) ) ) { SwCntntNode* pCNd = pPam->GetCntntNode(); if( pCNd && pCNd->StartOfSectionIndex()+2 < pCNd->EndOfSectionIndex() && !bHasFlysOrMarks ) { ViewShell *pVSh = CheckActionViewShell(); SwCrsrShell *pCrsrSh = pVSh && pVSh->ISA(SwCrsrShell) ? static_cast < SwCrsrShell * >( pVSh ) : 0; if( pCrsrSh && pCrsrSh->GetCrsr()->GetPoint() ->nNode.GetIndex() == nNodeIdx ) { pCrsrSh->MovePara(fnParaPrev, fnParaEnd ); pCrsrSh->SetMark(); pCrsrSh->ClearMark(); } pPam->GetBound(sal_True).nContent.Assign( 0, 0 ); pPam->GetBound(sal_False).nContent.Assign( 0, 0 ); pDoc->GetNodes().Delete( pPam->GetPoint()->nNode ); } } } else if( 0 != ( pAktNd = pDoc->GetNodes()[ nNodeIdx ]->GetTxtNode()) && !bHasFlysOrMarks ) { 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() ) { pPos->nContent.Assign( 0, 0 ); pPam->SetMark(); pPam->DeleteMark(); pDoc->GetNodes().Delete( pPos->nNode, 1 ); pPam->Move( fnMoveBackward ); } } } // now cancel the SplitNode from the start else if( !IsNewDoc() ) { if( pPos->nContent.GetIndex() ) // then there was no

at the end pPam->Move( fnMoveForward, fnGoNode ); // to the next node SwTxtNode* pTxtNode = pPos->nNode.GetNode().GetTxtNode(); SwNodeIndex aPrvIdx( pPos->nNode ); if( pTxtNode && pTxtNode->CanJoinPrev( &aPrvIdx ) && *pSttNdIdx <= aPrvIdx ) { // actually a JoinNext must be done here, but all cursors // etc. are registered in the pTxtNode, // which MUST remain // Convert paragraph to character attributes, // take over the paragraph attributes and the template from the Prev! 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(); } } // and prepare DocumentInfo if( IsNewDoc() ) { SwDocShell *pDocShell(pDoc->GetDocShell()); DBG_ASSERT(pDocShell, "no SwDocShell"); if (pDocShell) { uno::Reference xDPS( pDocShell->GetModel(), uno::UNO_QUERY_THROW); uno::Reference xDocProps( xDPS->getDocumentProperties()); DBG_ASSERT(xDocProps.is(), "DocumentProperties is null"); if ( xDocProps.is() && (xDocProps->getAutoloadSecs() > 0) && xDocProps->getAutoloadURL().equalsAscii("") ) { xDocProps->setAutoloadURL(aPathToFile); } } } if( bUpdateDocStat ) { SwDocStat aStat( pDoc->GetDocStat() ); pDoc->UpdateDocStat( aStat ); } } if( SVPAR_PENDING != GetStatus() ) delete pSttNdIdx, pSttNdIdx = 0; // should the parser be the last one to hold the doc, // no need to do anything here either, doc is about to be destroyed! if( 1 < pDoc->getReferenceCount() ) { if( bWasUndo ) { pDoc->GetIDocumentUndoRedo().DelAllUndoObj(); pDoc->GetIDocumentUndoRedo().DoUndo(true); } else if( !pInitVSh ) { // If there was no shell at the beginning of the Continue, // nevertheless one may have been created in the meantime. // In this case the bWasUndo flag is not correct and // a switch on the undo is necessary. ViewShell *pTmpVSh = CheckActionViewShell(); if( pTmpVSh ) { pDoc->GetIDocumentUndoRedo().DoUndo(true); } } pDoc->SetOle2Link( aOLELink ); if( !bModified ) pDoc->ResetModified(); if( bSetModEnabled && pDoc->GetDocShell() ) { pDoc->GetDocShell()->EnableSetModified( sal_True ); bSetModEnabled = sal_False; // this is unnecessary here } } // If the Dokuemnt-ViewShell still exists and an Action // is open (doesn't have to be on abort), terminate the action, // log out of the shell and finally reconstruct the old shell // again. CallEndAction( sal_True ); #ifdef DBG_UTIL nContinue--; #endif } void SwHTMLParser::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew ) { switch( pOld ? pOld->Which() : pNew ? pNew->Which() : 0 ) { case RES_OBJECTDYING: if( ((SwPtrMsgPoolItem *)pOld)->pObject == GetRegisteredIn() ) { // then finish ourselves GetRegisteredInNonConst()->Remove( this ); ReleaseRef(); // otherwise we are done! } break; } } void SwHTMLParser::DocumentDetected() { ASSERT( !bDocInitialized, "DocumentDetected called multiple times" ); bDocInitialized = sal_True; if( IsNewDoc() ) { if( IsInHeader() ) FinishHeader( sal_True ); CallEndAction( sal_True, sal_True ); pDoc->GetIDocumentUndoRedo().DoUndo(false); // By DocumentDetected a ViewShell has been created. // But it can also be that it is created later, // namely when the UI is is captured. CallStartAction(); } } // is called for each token that is recognized in CallParser void __EXPORT SwHTMLParser::NextToken( int nToken ) { if( ( pDoc->GetDocShell() && pDoc->GetDocShell()->IsAbortingImport() ) || 1 == pDoc->getReferenceCount() ) { // was the import aborted by the SFX? If a pending stack // still exists to clean it up eState = SVPAR_ERROR; ASSERT( !pPendStack || pPendStack->nToken, "SwHTMLParser::NextToken: pending stack without token" ); if( 1 == pDoc->getReferenceCount() || !pPendStack ) return ; } #ifdef DBG_UTIL if( pPendStack ) { switch( nToken ) { // tables are read via recusive method calls case HTML_TABLE_ON: // For CSS declarations you may have to wait for the // end of a file download. case HTML_LINK: // For controls, the size may still have to be set. case HTML_INPUT: case HTML_TEXTAREA_ON: case HTML_SELECT_ON: case HTML_SELECT_OFF: break; default: ASSERT( !pPendStack, "Unknown token for pending stack" ); break; } } #endif // The following special cases have to be handled before the filter detection // because the content of the title, etc. is not used for filter even in Netcape. if( !pPendStack ) { if( bInTitle ) { switch( nToken ) { case HTML_TITLE_OFF: if( IsNewDoc() && sTitle.Len() ) { if( pDoc->GetDocShell() ) { uno::Reference xDPS(pDoc->GetDocShell()->GetModel(), uno::UNO_QUERY_THROW); uno::Reference xDocProps( xDPS->getDocumentProperties()); DBG_ASSERT(xDocProps.is(), "no DocumentProperties"); if (xDocProps.is()) { xDocProps->setTitle(sTitle); } pDoc->GetDocShell()->SetTitle( sTitle ); } } bInTitle = sal_False; sTitle.Erase(); break; case HTML_NONBREAKSPACE: sTitle += ' '; break; case HTML_SOFTHYPH: sTitle += '-'; break; case HTML_TEXTTOKEN: sTitle += aToken; break; default: sTitle += '<'; if( (HTML_TOKEN_ONOFF & nToken) && (1 & nToken) ) sTitle += '/'; sTitle += sSaveToken; if( aToken.Len() ) { sTitle += ' '; sTitle += aToken; } sTitle += '>'; break; } return; } } // If we don't know yet, what kind of document we have in front of us, // let's try to find out first. This must be done for controls in // case before inserting the control, because when inserting the control // a view is already needed. if( !bDocInitialized ) DocumentDetected(); sal_Bool bGetIDOption = sal_False, bInsertUnknown = sal_False; sal_Bool bUpperSpaceSave = bUpperSpace; bUpperSpace = sal_False; // The following special cases must or can be made after the // filter detection. if( !pPendStack ) { if( bInFloatingFrame ) { //