You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by or...@apache.org on 2012/09/04 14:53:10 UTC
svn commit: r1380613 - in /incubator/ooo/branches/writer001/main/sw: inc/
source/core/doc/ source/core/tox/ source/filter/ww8/
source/filter/ww8/dump/ source/ui/index/
Author: orw
Date: Tue Sep 4 12:53:09 2012
New Revision: 1380613
URL: http://svn.apache.org/viewvc?rev=1380613&view=rev
Log:
#119963# - WW8 export: export of actual TOC content - second part of TOC enhancement
Patch by: zhengfan
Review by: Oliver
Modified:
incubator/ooo/branches/writer001/main/sw/inc/tox.hxx
incubator/ooo/branches/writer001/main/sw/source/core/doc/doctxm.cxx
incubator/ooo/branches/writer001/main/sw/source/core/tox/tox.cxx
incubator/ooo/branches/writer001/main/sw/source/filter/ww8/attributeoutputbase.hxx
incubator/ooo/branches/writer001/main/sw/source/filter/ww8/dump/ww8scan.cxx
incubator/ooo/branches/writer001/main/sw/source/filter/ww8/writerwordglue.cxx
incubator/ooo/branches/writer001/main/sw/source/filter/ww8/wrtw8nds.cxx
incubator/ooo/branches/writer001/main/sw/source/filter/ww8/wrtww8.cxx
incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8atr.cxx
incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8attributeoutput.hxx
incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8par.cxx
incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8par.hxx
incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8par5.cxx
incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8scan.cxx
incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8scan.hxx
incubator/ooo/branches/writer001/main/sw/source/ui/index/toxmgr.cxx
Modified: incubator/ooo/branches/writer001/main/sw/inc/tox.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/sw/inc/tox.hxx?rev=1380613&r1=1380612&r2=1380613&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/sw/inc/tox.hxx (original)
+++ incubator/ooo/branches/writer001/main/sw/inc/tox.hxx Tue Sep 4 12:53:09 2012
@@ -501,6 +501,13 @@ class SW_DLLPUBLIC SwTOXBase : public Sw
sal_Bool bFromObjectNames : 1; // create a table or object index
// from the names rather than the caption
sal_Bool bLevelFromChapter : 1; // User index: get the level from the source chapter
+
+protected:
+ // Add a data member, for record the TOC field expression of MS Word binary format
+ // For keeping fedality and may giving a better exporting performance
+ String maMSTOCExpression;
+ sal_Bool mbKeepExpression;
+
public:
SwTOXBase( const SwTOXType* pTyp, const SwForm& rForm,
sal_uInt16 nCreaType, const String& rTitle );
@@ -520,6 +527,12 @@ public:
const String& GetTOXName() const {return aName;}
void SetTOXName(const String& rSet) {aName = rSet;}
+ // for record the TOC field expression of MS Word binary format
+ const String& GetMSTOCExpression() const{return maMSTOCExpression;}
+ void SetMSTOCExpression(const String& rExp) {maMSTOCExpression = rExp;}
+ void EnableKeepExpression() {mbKeepExpression = sal_True;}
+ void DisableKeepExpression() {mbKeepExpression = sal_False;}
+
const String& GetTitle() const; // Title
const String& GetTypeName() const; // Name
const SwForm& GetTOXForm() const; // description of the lines
Modified: incubator/ooo/branches/writer001/main/sw/source/core/doc/doctxm.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/sw/source/core/doc/doctxm.cxx?rev=1380613&r1=1380612&r2=1380613&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/sw/source/core/doc/doctxm.cxx (original)
+++ incubator/ooo/branches/writer001/main/sw/source/core/doc/doctxm.cxx Tue Sep 4 12:53:09 2012
@@ -792,19 +792,26 @@ sal_Bool SwTOXBaseSection::SetPosAtStart
void SwTOXBaseSection::Update(const SfxItemSet* pAttr,
const bool _bNewTOX )//swmodtest 080307
{
- const SwSectionNode* pSectNd;
- if( !SwTOXBase::GetRegisteredIn()->GetDepends() ||
- !GetFmt() || 0 == (pSectNd = GetFmt()->GetSectionNode() ) ||
- !pSectNd->GetNodes().IsDocNodes() ||
- IsHiddenFlag() )
- return;
+ const SwSectionNode* pSectNd;
+ if( !SwTOXBase::GetRegisteredIn()->GetDepends() ||
+ !GetFmt() || 0 == (pSectNd = GetFmt()->GetSectionNode() ) ||
+ !pSectNd->GetNodes().IsDocNodes() ||
+ IsHiddenFlag() )
+ {
+ return;
+ }
+
+ if ( !mbKeepExpression )
+ {
+ maMSTOCExpression = String();
+ }
- SwDoc* pDoc = (SwDoc*)pSectNd->GetDoc();
+ SwDoc* pDoc = (SwDoc*)pSectNd->GetDoc();
DBG_ASSERT(pDoc != NULL, "Where is the document?");
- if(pAttr && pDoc && GetFmt())
- pDoc->ChgFmt(*GetFmt(), *pAttr);
+ if(pAttr && pDoc && GetFmt())
+ pDoc->ChgFmt(*GetFmt(), *pAttr);
// OD 18.03.2003 #106329# - determine default page description, which
// will be used by the content nodes, if no approriate one is found.
Modified: incubator/ooo/branches/writer001/main/sw/source/core/tox/tox.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/sw/source/core/tox/tox.cxx?rev=1380613&r1=1380612&r2=1380613&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/sw/source/core/tox/tox.cxx (original)
+++ incubator/ooo/branches/writer001/main/sw/source/core/tox/tox.cxx Tue Sep 4 12:53:09 2012
@@ -510,17 +510,19 @@ void SwForm::AdjustTabStops(SwDoc& rDoc,
SwTOXBase::SwTOXBase(const SwTOXType* pTyp, const SwForm& rForm,
sal_uInt16 nCreaType, const String& rTitle )
- : SwClient((SwModify*)pTyp),
- aForm(rForm),
- aTitle(rTitle),
- eLanguage((LanguageType)::GetAppLanguage()),
- nCreateType(nCreaType),
- nOLEOptions(0),
- eCaptionDisplay(CAPTION_COMPLETE),
- bProtected( sal_True ),
- bFromChapter(sal_False),
- bFromObjectNames(sal_False),
- bLevelFromChapter(sal_False)
+ : SwClient((SwModify*)pTyp)
+ , aForm(rForm)
+ , aTitle(rTitle)
+ , eLanguage((LanguageType)::GetAppLanguage())
+ , nCreateType(nCreaType)
+ , nOLEOptions(0)
+ , eCaptionDisplay(CAPTION_COMPLETE)
+ , bProtected( sal_True )
+ , bFromChapter(sal_False)
+ , bFromObjectNames(sal_False)
+ , bLevelFromChapter(sal_False)
+ , maMSTOCExpression()
+ , mbKeepExpression(sal_True)
{
aData.nOptions = 0;
}
@@ -528,6 +530,7 @@ SwTOXBase::SwTOXBase(const SwTOXType* pT
SwTOXBase::SwTOXBase( const SwTOXBase& rSource, SwDoc* pDoc )
: SwClient( rSource.GetRegisteredInNonConst() )
+ , mbKeepExpression(sal_True)
{
CopyTOXBase( pDoc, rSource );
}
@@ -539,6 +542,7 @@ void SwTOXBase::RegisterToTOXType( SwTOX
SwTOXBase& SwTOXBase::CopyTOXBase( SwDoc* pDoc, const SwTOXBase& rSource )
{
+ maMSTOCExpression = rSource.maMSTOCExpression;
SwTOXType* pType = (SwTOXType*)rSource.GetTOXType();
if( pDoc && USHRT_MAX == pDoc->GetTOXTypes().GetPos( pType ))
{
Modified: incubator/ooo/branches/writer001/main/sw/source/filter/ww8/attributeoutputbase.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/sw/source/filter/ww8/attributeoutputbase.hxx?rev=1380613&r1=1380612&r2=1380613&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/sw/source/filter/ww8/attributeoutputbase.hxx (original)
+++ incubator/ooo/branches/writer001/main/sw/source/filter/ww8/attributeoutputbase.hxx Tue Sep 4 12:53:09 2012
@@ -187,7 +187,9 @@ public:
void StartTOX( const SwSection& rSect );
- void EndTOX( const SwSection& rSect );
+ void EndTOX( const SwSection& rSect,bool bCareEnd=true );
+
+ virtual void OnTOXEnding() {}
virtual void TOXMark( const SwTxtNode& rNode, const SwTOXMark& rAttr );
Modified: incubator/ooo/branches/writer001/main/sw/source/filter/ww8/dump/ww8scan.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/sw/source/filter/ww8/dump/ww8scan.cxx?rev=1380613&r1=1380612&r2=1380613&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/sw/source/filter/ww8/dump/ww8scan.cxx (original)
+++ incubator/ooo/branches/writer001/main/sw/source/filter/ww8/dump/ww8scan.cxx Tue Sep 4 12:53:09 2012
@@ -3541,7 +3541,7 @@ bool WW8PLCFx_FLD::StartPosIsFieldStart(
return true;
}
-bool WW8PLCFx_FLD::EndPosIsFieldEnd()
+bool WW8PLCFx_FLD::EndPosIsFieldEnd(WW8_CP& nCP)
{
bool bRet = false;
@@ -3554,7 +3554,10 @@ bool WW8PLCFx_FLD::EndPosIsFieldEnd()
void* pData;
long nTest;
if ( pPLCF->Get(nTest, pData) && ((((sal_uInt8*)pData)[0] & 0x1f) == 0x15) )
+ {
+ nCP = nTest;
bRet = true;
+ }
pPLCF->SetIdx(n);
}
Modified: incubator/ooo/branches/writer001/main/sw/source/filter/ww8/writerwordglue.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/sw/source/filter/ww8/writerwordglue.cxx?rev=1380613&r1=1380612&r2=1380613&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/sw/source/filter/ww8/writerwordglue.cxx (original)
+++ incubator/ooo/branches/writer001/main/sw/source/filter/ww8/writerwordglue.cxx Tue Sep 4 12:53:09 2012
@@ -522,6 +522,10 @@ namespace sw
return true;
if (nB == RES_TXTATR_CHARFMT)
return false;
+ if (nA == RES_TXTATR_INETFMT)
+ return true;
+ if (nB == RES_TXTATR_INETFMT)
+ return false;
return nA < nB;
}
Modified: incubator/ooo/branches/writer001/main/sw/source/filter/ww8/wrtw8nds.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/sw/source/filter/ww8/wrtw8nds.cxx?rev=1380613&r1=1380612&r2=1380613&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/sw/source/filter/ww8/wrtw8nds.cxx (original)
+++ incubator/ooo/branches/writer001/main/sw/source/filter/ww8/wrtw8nds.cxx Tue Sep 4 12:53:09 2012
@@ -1955,7 +1955,7 @@ void MSWordExportBase::OutputTextNode( c
if ( pTOXSect )
{
m_aCurrentCharPropStarts.pop();
- AttrOutput().EndTOX( *pTOXSect );
+ AttrOutput().EndTOX( *pTOXSect ,false);
}
WriteCR( pTextNodeInfoInner );
}
@@ -1993,6 +1993,7 @@ void MSWordExportBase::OutputTextNode( c
aAttrIter.OutFlys( nEnd );
// insert final bookmarks if any before CR and after flys
AppendBookmarks( rNode, nEnd, 1 );
+ WriteCR( pTextNodeInfoInner );
if ( pTOXSect )
{
@@ -2000,8 +2001,6 @@ void MSWordExportBase::OutputTextNode( c
AttrOutput().EndTOX( *pTOXSect );
}
- WriteCR( pTextNodeInfoInner );
-
if ( bRedlineAtEnd )
{
AttrOutput().Redline( aAttrIter.GetRedline( nEnd ) );
@@ -2523,7 +2522,8 @@ void MSWordExportBase::OutputSectionNode
SwNodeIndex aIdx( rSectionNode, 1 );
const SwNode& rNd = aIdx.GetNode();
- if ( !rNd.IsSectionNode() && !IsInTable() ) //No sections in table
+ if ( !rNd.IsSectionNode() && !IsInTable()
+ && rSection.GetType() != TOX_CONTENT_SECTION && rSection.GetType() != TOX_HEADER_SECTION) //No sections in table
{
// Bug 74245 - if the first Node inside the section has an own
// PageDesc or PageBreak attribut, then dont write
Modified: incubator/ooo/branches/writer001/main/sw/source/filter/ww8/wrtww8.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/sw/source/filter/ww8/wrtww8.cxx?rev=1380613&r1=1380612&r2=1380613&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/sw/source/filter/ww8/wrtww8.cxx (original)
+++ incubator/ooo/branches/writer001/main/sw/source/filter/ww8/wrtww8.cxx Tue Sep 4 12:53:09 2012
@@ -33,6 +33,9 @@
#include <algorithm>
+#include <map>
+#include <set>
+
#include <hintids.hxx>
#include <string.h> // memcpy()
#include <osl/endian.h>
@@ -187,30 +190,143 @@ public:
WW8_FC GetStartFc() const { return nStartFc; }
};
+typedef std::map<String,long> BKMKNames;
+typedef BKMKNames::iterator BKMKNmItr;
+typedef std::pair<bool,String> BKMK;
+typedef std::pair<long,BKMK> BKMKCP;
+typedef std::multimap<long,BKMKCP*> BKMKCPs;
+typedef BKMKCPs::iterator CPItr;
+
class WW8_WrtBookmarks
{
private:
- SvULongs aSttCps, aEndCps; // Array of Start- and End CPs
- SvBools aFieldMarks; // If the bookmark is in a field result
- std::vector<String> maSwBkmkNms; // Array of Sw - Bookmarknames
- typedef std::vector<String>::iterator myIter;
-
- sal_uInt16 GetPos( const String& rNm );
-
- //No copying
+ BKMKCPs aSttCps,aEndCps;
+ BKMKNames maSwBkmkNms;
WW8_WrtBookmarks(const WW8_WrtBookmarks&);
WW8_WrtBookmarks& operator=(const WW8_WrtBookmarks&);
+
public:
WW8_WrtBookmarks();
~WW8_WrtBookmarks();
-
void Append( WW8_CP nStartCp, const String& rNm, const ::sw::mark::IMark* pBkmk=NULL );
void Write( WW8Export& rWrt );
void MoveFieldMarks(sal_uLong nFrom,sal_uLong nTo);
-
-// String GetWWBkmkName( const String& rName ) const;
};
+WW8_WrtBookmarks::WW8_WrtBookmarks()
+{}
+
+WW8_WrtBookmarks::~WW8_WrtBookmarks()
+{
+ CPItr aEnd = aSttCps.end();
+ for (CPItr aItr = aSttCps.begin();aItr!=aEnd;aItr++)
+ {
+ if (aItr->second)
+ {
+ delete aItr->second;
+ aItr->second = NULL;
+ }
+ }
+}
+
+void WW8_WrtBookmarks::Append( WW8_CP nStartCp, const String& rNm, const ::sw::mark::IMark*)
+{
+ std::pair<BKMKNmItr,bool> aResult = maSwBkmkNms.insert(std::pair<String,long>(rNm,0L));
+ if (aResult.second)
+ {
+ BKMK aBK(false,rNm);
+ BKMKCP* pBKCP = new BKMKCP((long)nStartCp,aBK);
+ aSttCps.insert(std::pair<long,BKMKCP*>(nStartCp,pBKCP));
+ aResult.first->second = (long)nStartCp;
+ }
+ else
+ {
+ std::pair<CPItr,CPItr> aRange = aSttCps.equal_range(aResult.first->second);
+ for (CPItr aItr = aRange.first;aItr != aRange.second;aItr++)
+ {
+ if (aItr->second && aItr->second->second.second == rNm)
+ {
+ if (aItr->second->second.first)
+ nStartCp--;
+ aItr->second->first = (long)nStartCp;
+ break;
+ }
+ }
+ }
+}
+
+void WW8_WrtBookmarks::Write( WW8Export& rWrt)
+{
+ if (!aSttCps.size())
+ return;
+ CPItr aItr;
+ long n;
+ std::vector<String> aNames;
+ SvMemoryStream aTempStrm1(65535,65535);
+ SvMemoryStream aTempStrm2(65535,65535);
+ for (aItr = aSttCps.begin();aItr!=aSttCps.end();aItr++)
+ {
+ if (aItr->second)
+ {
+ aEndCps.insert(std::pair<long,BKMKCP*>(aItr->second->first,aItr->second));
+ aNames.push_back(aItr->second->second.second);
+ SwWW8Writer::WriteLong( aTempStrm1, aItr->first);
+ }
+ }
+
+ aTempStrm1.Seek(0L);
+ for (aItr = aEndCps.begin(), n = 0;aItr != aEndCps.end();aItr++,n++)
+ {
+ if (aItr->second)
+ {
+ aItr->second->first = n;
+ SwWW8Writer::WriteLong( aTempStrm2, aItr->first);
+ }
+ }
+
+ aTempStrm2.Seek(0L);
+ rWrt.WriteAsStringTable(aNames, rWrt.pFib->fcSttbfbkmk,rWrt.pFib->lcbSttbfbkmk);
+ SvStream& rStrm = rWrt.bWrtWW8 ? *rWrt.pTableStrm : rWrt.Strm();
+ rWrt.pFib->fcPlcfbkf = rStrm.Tell();
+ rStrm<<aTempStrm1;
+ SwWW8Writer::WriteLong(rStrm, rWrt.pFib->ccpText + rWrt.pFib->ccpTxbx);
+ for (aItr = aSttCps.begin();aItr!=aSttCps.end();aItr++)
+ {
+ if (aItr->second)
+ {
+ SwWW8Writer::WriteLong(rStrm, aItr->second->first);
+ }
+ }
+ rWrt.pFib->lcbPlcfbkf = rStrm.Tell() - rWrt.pFib->fcPlcfbkf;
+ rWrt.pFib->fcPlcfbkl = rStrm.Tell();
+ rStrm<<aTempStrm2;
+ SwWW8Writer::WriteLong(rStrm, rWrt.pFib->ccpText + rWrt.pFib->ccpTxbx);
+ rWrt.pFib->lcbPlcfbkl = rStrm.Tell() - rWrt.pFib->fcPlcfbkl;
+}
+
+void WW8_WrtBookmarks::MoveFieldMarks(sal_uLong nFrom,sal_uLong nTo)
+{
+ std::pair<CPItr,CPItr> aRange = aSttCps.equal_range(nFrom);
+ CPItr aItr = aRange.first;
+ while (aItr != aRange.second)
+ {
+ if (aItr->second)
+ {
+ if (aItr->second->first == nFrom)
+ {
+ aItr->second->second.first = true;
+ aItr->second->first = nTo;
+ }
+ aSttCps.insert(std::pair<long,BKMKCP*>(nTo,aItr->second));
+ aItr->second = NULL;
+ aRange = aSttCps.equal_range(nFrom);
+ aItr = aRange.first;
+ continue;
+ }
+ aItr++;
+ }
+}
+
#define ANZ_DEFAULT_STYLES 16
// die Namen der StorageStreams
@@ -1253,136 +1369,6 @@ WW8_CP WW8_WrPct::Fc2Cp( sal_uLong nFc )
return nFc + pPcts->GetObject( pPcts->Count() - 1 )->GetStartCp();
}
-//--------------------------------------------------------------------------
-/* */
-
-WW8_WrtBookmarks::WW8_WrtBookmarks()
- : aSttCps( 0, 16 ), aEndCps( 0, 16 )
-{
-}
-
-WW8_WrtBookmarks::~WW8_WrtBookmarks()
-{
-}
-
-void WW8_WrtBookmarks::Append( WW8_CP nStartCp, const String& rNm, const ::sw::mark::IMark* )
-{
- sal_uInt16 nPos = GetPos( rNm );
- if( USHRT_MAX == nPos )
- {
- // new -> insert as start position
- nPos = aSttCps.Count();
- myIter aIter = maSwBkmkNms.end();
- // sort by startposition
- // theory: write continuous -> then the new position is at end
- while( nPos && aSttCps[ nPos - 1 ] > sal_uLong( nStartCp ))
- {
- --nPos;
- --aIter;
- }
-
- aSttCps.Insert(nStartCp, nPos);
- aEndCps.Insert(nStartCp, nPos);
- aFieldMarks.insert(aFieldMarks.begin() + nPos, sal_Bool(false));
- maSwBkmkNms.insert(aIter, rNm);
- }
- else
- {
- // old -> its the end position
- ASSERT( aEndCps[ nPos ] == aSttCps[ nPos ], "end position is valid" );
-
- //If this bookmark was around a field in writer, then we want to move
- //it to the field result in word. The end is therefore one cp
- //backwards from the 0x15 end mark that was inserted.
- if (aFieldMarks[nPos])
- --nStartCp;
-
- aEndCps.Replace( nStartCp, nPos );
- }
-}
-
-
-void WW8_WrtBookmarks::Write( WW8Export& rWrt )
-{
- sal_uInt16 nCount = aSttCps.Count(), i;
- if( nCount )
- {
- SvULongs aEndSortTab( 255 < nCount ? 255 : nCount, 4 );
- // sort then endpositions
- for( i = 0; i < nCount; ++i )
- {
- sal_uLong nCP = aEndCps[ i ];
- sal_uInt16 nPos = i;
- while( nPos && aEndSortTab[ nPos - 1 ] > nCP )
- --nPos;
- aEndSortTab.Insert( nCP, nPos );
- }
-
- // we have some bookmarks found in the document -> write them
- // first the Bookmark Name Stringtable
- rWrt.WriteAsStringTable(maSwBkmkNms, rWrt.pFib->fcSttbfbkmk,
- rWrt.pFib->lcbSttbfbkmk);
-
- // second the Bookmark start positions as pcf of longs
- SvStream& rStrm = rWrt.bWrtWW8 ? *rWrt.pTableStrm : rWrt.Strm();
- rWrt.pFib->fcPlcfbkf = rStrm.Tell();
- for( i = 0; i < nCount; ++i )
- SwWW8Writer::WriteLong( rStrm, aSttCps[ i ] );
- SwWW8Writer::WriteLong(rStrm, rWrt.pFib->ccpText + rWrt.pFib->ccpTxbx);
- for( i = 0; i < nCount; ++i )
- {
- sal_uLong nEndCP = aEndCps[ i ];
- sal_uInt16 nPos = i;
- if( aEndSortTab[ nPos ] > nEndCP )
- {
- while( aEndSortTab[ --nPos ] != nEndCP )
- ;
- }
- else if( aEndSortTab[ nPos ] < nEndCP )
- while( aEndSortTab[ ++nPos ] != nEndCP )
- ;
-
- SwWW8Writer::WriteLong( rStrm, nPos );
- }
- rWrt.pFib->lcbPlcfbkf = rStrm.Tell() - rWrt.pFib->fcPlcfbkf;
-
- // third the Bookmark end positions
- rWrt.pFib->fcPlcfbkl = rStrm.Tell();
- for( i = 0; i < nCount; ++i )
- SwWW8Writer::WriteLong( rStrm, aEndSortTab[ i ] );
- SwWW8Writer::WriteLong(rStrm, rWrt.pFib->ccpText + rWrt.pFib->ccpTxbx);
- rWrt.pFib->lcbPlcfbkl = rStrm.Tell() - rWrt.pFib->fcPlcfbkl;
- }
-}
-
-sal_uInt16 WW8_WrtBookmarks::GetPos( const String& rNm )
-{
- sal_uInt16 nRet = USHRT_MAX, n;
- for (n = 0; n < aSttCps.Count(); ++n)
- if (rNm == maSwBkmkNms[n])
- {
- nRet = n;
- break;
- }
- return nRet;
-}
-
-void WW8_WrtBookmarks::MoveFieldMarks(sal_uLong nFrom, sal_uLong nTo)
-{
- for (sal_uInt16 nI=0;nI<aSttCps.Count();++nI)
- {
- if (aSttCps[nI] == nFrom)
- {
- aSttCps[nI] = nTo;
- if (aEndCps[nI] == nFrom)
- {
- aFieldMarks[nI] = true;
- aEndCps[nI] = nTo;
- }
- }
- }
-}
-
void WW8Export::AppendBookmarks( const SwTxtNode& rNd,
xub_StrLen nAktPos, xub_StrLen nLen )
{
@@ -2561,7 +2547,8 @@ void MSWordExportBase::WriteText()
;
else if ( aIdx.GetNode().IsSectionNode() )
;
- else if ( !IsInTable() ) //No sections in table
+ else if ( !IsInTable()
+ && (rSect.GetType() != TOX_CONTENT_SECTION && rSect.GetType() != TOX_HEADER_SECTION )) //No sections in table
{
//#120140# Do not need to insert a page/section break after a section end. Check this case first
sal_Bool bNeedExportBreakHere = sal_True;
Modified: incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8atr.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8atr.cxx?rev=1380613&r1=1380612&r2=1380613&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8atr.cxx (original)
+++ incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8atr.cxx Tue Sep 4 12:53:09 2012
@@ -957,7 +957,8 @@ void WW8AttributeOutput::RTLAndCJKState(
void WW8AttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner )
{
- m_rWW8Export.pPapPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), m_rWW8Export.pO->Count(), m_rWW8Export.pO->GetData() );
+ m_rWW8Export.pPapPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell() - (mbOnTOXEnding?2:0), m_rWW8Export.pO->Count(), m_rWW8Export.pO->GetData() );
+ mbOnTOXEnding = false;
m_rWW8Export.pO->Remove( 0, m_rWW8Export.pO->Count() ); // delete
if ( pTextNodeInfoInner.get() != NULL )
@@ -1001,6 +1002,11 @@ void WW8AttributeOutput::StartRun( const
}
}
+void WW8AttributeOutput::OnTOXEnding()
+{
+ mbOnTOXEnding = true;
+}
+
void WW8AttributeOutput::EndRunProperties( const SwRedlineData* pRedlineData )
{
Redline( pRedlineData );
@@ -2076,347 +2082,289 @@ void AttributeOutputBase::StartTOX( cons
static const sal_Char sEntryEnd[] = "\" ";
ww::eField eCode = ww::eTOC;
- String sStr;
- switch (pTOX->GetType())
+ String sStr = pTOX->GetMSTOCExpression();
+ if ( !sStr.Len() )
{
- case TOX_INDEX:
- eCode = ww::eINDEX;
- sStr = FieldString(eCode);
-
- if (pTOX->GetTOXForm().IsCommaSeparated())
- sStr.APPEND_CONST_ASC("\\r ");
-
- if (nsSwTOIOptions::TOI_ALPHA_DELIMITTER & pTOX->GetOptions())
- sStr.APPEND_CONST_ASC("\\h \"A\" ");
-
+ switch (pTOX->GetType())
{
- String aFillTxt;
- for (sal_uInt8 n = 1; n <= 3; ++n)
- {
- String aTxt;
- int nRet = ::lcl_CheckForm(pTOX->GetTOXForm(), n, aTxt);
+ case TOX_INDEX:
+ eCode = ww::eINDEX;
+ sStr = FieldString(eCode);
- if( 3 == nRet )
- aFillTxt = aTxt;
- else if ((4 == nRet) || (2 == nRet)) //#109414#
- aFillTxt = '\t';
- else
- aFillTxt.Erase();
- }
- sStr.APPEND_CONST_ASC("\\e \"");
- sStr += aFillTxt;
- sStr.AppendAscii(sEntryEnd);
- }
- break;
+ if (pTOX->GetTOXForm().IsCommaSeparated())
+ sStr.APPEND_CONST_ASC("\\r ");
-// case TOX_AUTHORITIES: eCode = eTOA; sStr = ???; break;
+ if (nsSwTOIOptions::TOI_ALPHA_DELIMITTER & pTOX->GetOptions())
+ sStr.APPEND_CONST_ASC("\\h \"A\" ");
- case TOX_ILLUSTRATIONS:
- case TOX_OBJECTS:
- case TOX_TABLES:
- if (!pTOX->IsFromObjectNames())
- {
- sStr = FieldString(eCode);
-
- sStr.APPEND_CONST_ASC("\\c \"");
- sStr += pTOX->GetSequenceName();
- sStr.AppendAscii(sEntryEnd);
-
- String aTxt;
- int nRet = ::lcl_CheckForm( pTOX->GetTOXForm(), 1, aTxt );
- if (1 == nRet)
- sStr.APPEND_CONST_ASC("\\n ");
- else if( 3 == nRet || 4 == nRet )
{
- sStr.APPEND_CONST_ASC("\\p \"");
- sStr += aTxt;
+ String aFillTxt;
+ for (sal_uInt8 n = 1; n <= 3; ++n)
+ {
+ String aTxt;
+ int nRet = ::lcl_CheckForm(pTOX->GetTOXForm(), n, aTxt);
+
+ if( 3 == nRet )
+ aFillTxt = aTxt;
+ else if ((4 == nRet) || (2 == nRet)) //#109414#
+ aFillTxt = '\t';
+ else
+ aFillTxt.Erase();
+ }
+ sStr.APPEND_CONST_ASC("\\e \"");
+ sStr += aFillTxt;
sStr.AppendAscii(sEntryEnd);
}
- }
- break;
-
-// case TOX_USER:
-// case TOX_CONTENT:
- default:
- {
- sStr = FieldString(eCode);
+ break;
- String sTOption;
- sal_uInt16 n, nTOXLvl = pTOX->GetLevel();
- if( !nTOXLvl )
- ++nTOXLvl;
+ // case TOX_AUTHORITIES: eCode = eTOA; sStr = ???; break;
- if( nsSwTOXElement::TOX_MARK & pTOX->GetCreateType() )
+ case TOX_ILLUSTRATIONS:
+ case TOX_OBJECTS:
+ case TOX_TABLES:
+ if (!pTOX->IsFromObjectNames())
{
- sStr.APPEND_CONST_ASC( "\\f " );
+ sStr = FieldString(eCode);
+
+ sStr.APPEND_CONST_ASC("\\c \"");
+ sStr += pTOX->GetSequenceName();
+ sStr.AppendAscii(sEntryEnd);
- if( TOX_USER == pTOX->GetType() )
+ String aTxt;
+ int nRet = ::lcl_CheckForm( pTOX->GetTOXForm(), 1, aTxt );
+ if (1 == nRet)
+ sStr.APPEND_CONST_ASC("\\n ");
+ else if( 3 == nRet || 4 == nRet )
{
- sStr += '\"';
- sStr += (sal_Char)( 'A' + GetExport( ).GetId( *pTOX->GetTOXType() ) );
- sStr.AppendAscii( sEntryEnd );
+ sStr.APPEND_CONST_ASC("\\p \"");
+ sStr += aTxt;
+ sStr.AppendAscii(sEntryEnd);
}
+ }
+ break;
- if( nsSwTOXElement::TOX_OUTLINELEVEL & pTOX->GetCreateType() )
+ // case TOX_USER:
+ // case TOX_CONTENT:
+ default:
{
- // --> OD 2009-02-27 #i99641#
- // The following code does not determine the minimum outline
- // level for the TOC
-// // Search over all the outline styles used and figure out
-// // what is the minimum outline level we need to display
-// // (ignoring headline styles 1-9)
-// //sal_uInt8 nLvl = 0, nMinLvl = 0; //#outline level, removed by zhaojianwei
-// int nLvl = 0, nMinLvl = 0; //<-end,add by zhaojianwei
-// const SwTxtFmtColls& rColls = *GetExport().pDoc->GetTxtFmtColls();
-// const SwTxtFmtColl* pColl;
-// for( n = rColls.Count(); n; )
-// {
-// pColl = rColls[ --n ];
-// //nLvl = pColl->GetOutlineLevel(); //#outline level,zhaojianwei
-// //sal_uInt16 nPoolId = pColl->GetPoolFmtId();
-// //if( MAXLEVEL > nLvl && nMinLvl < nLvl && //<-end, ->add by zhaojianwei
-// sal_uInt16 nPoolId = pColl->GetPoolFmtId();
-// if( pColl->IsAssignedToListLevelOfOutlineStyle() &&
-// nMinLvl < (nLvl = pColl->GetAssignedOutlineStyleLevel()) && //<-end,zhaojianwei
-// ( RES_POOLCOLL_HEADLINE1 > nPoolId ||
-// RES_POOLCOLL_HEADLINE9 < nPoolId ))
-// {
-// // If we are using the default heading styles then use nTOXLvl
-// if(!nMinLvl)
-// nLvl = nTOXLvl;
-// else
-// nLvl = nMinLvl < nTOXLvl ? nMinLvl : (sal_uInt8)nTOXLvl;
-// nMinLvl = nLvl;
-// }
-// }
- const int nMinLvl = nTOXLvl;
+ sStr = FieldString(eCode);
+
+ String sTOption;
+ sal_uInt16 n, nTOXLvl = pTOX->GetLevel();
+ if( !nTOXLvl )
+ ++nTOXLvl;
-// if( nLvl )
- if ( nMinLvl > 0 )
+ if( nsSwTOXElement::TOX_MARK & pTOX->GetCreateType() )
{
- int nTmpLvl = nMinLvl;
- if (nTmpLvl > WW8ListManager::nMaxLevel)
- nTmpLvl = WW8ListManager::nMaxLevel;
+ sStr.APPEND_CONST_ASC( "\\f " );
- sStr.APPEND_CONST_ASC( "\\o \"1-" );
- sStr += String::CreateFromInt32( nTmpLvl );
- sStr.AppendAscii(sEntryEnd);
+ if( TOX_USER == pTOX->GetType() )
+ {
+ sStr += '\"';
+ sStr += (sal_Char)( 'A' + GetExport( ).GetId( *pTOX->GetTOXType() ) );
+ sStr.AppendAscii( sEntryEnd );
+ }
- }
- // <--
+ if( nsSwTOXElement::TOX_OUTLINELEVEL & pTOX->GetCreateType() )
+ {
+ const int nMinLvl = nTOXLvl;
+ if ( nMinLvl > 0 )
+ {
+ int nTmpLvl = nMinLvl;
+ if (nTmpLvl > WW8ListManager::nMaxLevel)
+ nTmpLvl = WW8ListManager::nMaxLevel;
+
+ sStr.APPEND_CONST_ASC( "\\o \"1-" );
+ sStr += String::CreateFromInt32( nTmpLvl );
+ sStr.AppendAscii(sEntryEnd);
- // --> OD 2009-02-27 #i99641#
- // not needed to additional export paragraph style with
- // an outline level to the /t option
-// if( nMinLvl > 0 )
-// // <--
-// {
-// // collect this templates into the \t otion
-// const SwTxtFmtColls& rColls = *pDoc->GetTxtFmtColls();
-// const SwTxtFmtColl* pColl;
-// int nLvl = 0;
-// for( n = rColls.Count(); n;)
-// {
-// pColl = rColls[--n];
-// //nLvl = pColl->GetOutlineLevel(); //#outline level, removed by zhaojianwei
-// //if (MAXLEVEL > nLvl && nMinLvl <= nLvl)
-// //{ //<-end, ->add by zhaojianwei
-// if( pColl->IsAssignedToListLevelOfOutlineStyle() &&
-// nMinLvl <= ( nLvl = pColl->GetAssignedOutlineStyleLevel()))
-// { //<-end,zhaojianwei
-// if( sTOption.Len() )
-// sTOption += ';';
-// (( sTOption += pColl->GetName() ) += ';' )
-// += String::CreateFromInt32( nLvl + 1 );
-// }
-// }
-// }
+ }
+ }
- }
-
- if( nsSwTOXElement::TOX_OUTLINELEVEL & pTOX->GetCreateType() )
- {
- // Take the TOC value of the max level to evaluate to as
- // the starting point for the \o flag, but reduce it to the
- // value of the highest outline level filled by a *standard*
- // Heading 1 - 9 style because \o "Builds a table of
- // contents from paragraphs formatted with built-in heading
- // styles". And afterward fill in any outline styles left
- // uncovered by that range to the \t flag
- //
- // i.e. for
- // Heading 1
- // Heading 2
- // custom-style
- // Heading 4
- // output
- // \o 1-2 \tcustom-style,3,Heading 3,4
-
- // Search over all the outline styles used and figure out
- // what is the minimum outline level (if any) filled by a
- // non-standard style for that level, i.e. ignore headline
- // styles 1-9 and find the lowest valid outline level
- sal_uInt8 nPosOfLowestNonStandardLvl = MAXLEVEL;
- const SwTxtFmtColls& rColls = *GetExport().pDoc->GetTxtFmtColls();
- for( n = rColls.Count(); n; )
- {
- const SwTxtFmtColl* pColl = rColls[ --n ];
- sal_uInt16 nPoolId = pColl->GetPoolFmtId();
- if (
- //Is a Non-Standard Outline Style
- (RES_POOLCOLL_HEADLINE1 > nPoolId || RES_POOLCOLL_HEADLINE9 < nPoolId) &&
- //Has a valid outline level
- (pColl->IsAssignedToListLevelOfOutlineStyle()) &&
- // Is less than the lowest known non-standard level
- (pColl->GetAssignedOutlineStyleLevel() < nPosOfLowestNonStandardLvl)
- )
- {
- nPosOfLowestNonStandardLvl = ::sal::static_int_cast<sal_uInt8>(pColl->GetAssignedOutlineStyleLevel());
- }
- }
-
- sal_uInt8 nMaxMSAutoEvaluate = nPosOfLowestNonStandardLvl < nTOXLvl ? nPosOfLowestNonStandardLvl : (sal_uInt8)nTOXLvl;
-
- //output \o 1-X where X is the highest normal outline style to be included in the toc
- if ( nMaxMSAutoEvaluate )
- {
- if (nMaxMSAutoEvaluate > WW8ListManager::nMaxLevel)
- nMaxMSAutoEvaluate = WW8ListManager::nMaxLevel;
-
- sStr.APPEND_CONST_ASC( "\\o \"1-" );
- sStr += String::CreateFromInt32( nMaxMSAutoEvaluate );
- sStr.AppendAscii(sEntryEnd);
- }
-
- //collect up any other styles in the writer TOC which will
- //not already appear in the MS TOC and place then into the
- //\t option
- if( nMaxMSAutoEvaluate < nTOXLvl )
- {
- // collect this templates into the \t otion
- for( n = rColls.Count(); n;)
- {
- const SwTxtFmtColl* pColl = rColls[ --n ];
- if (!pColl->IsAssignedToListLevelOfOutlineStyle())
- continue;
- sal_uInt8 nTestLvl = ::sal::static_int_cast<sal_uInt8>(pColl->GetAssignedOutlineStyleLevel());
- if (nTestLvl < nTOXLvl && nTestLvl >= nMaxMSAutoEvaluate)
- {
- if( sTOption.Len() )
- sTOption += ',';
- (( sTOption += pColl->GetName() ) += ',' )
- += String::CreateFromInt32( nTestLvl + 1 );
- }
- }
- }
- }
-
- if( nsSwTOXElement::TOX_TEMPLATE & pTOX->GetCreateType() )
- // --> OD 2009-02-27 #i99641#
- // Consider additional styles regardless of TOX-outlinelevel
- for( n = 0; n < MAXLEVEL; ++n )
- // <--
- {
- const String& rStyles = pTOX->GetStyleNames( n );
- if( rStyles.Len() )
+ if( nsSwTOXElement::TOX_OUTLINELEVEL & pTOX->GetCreateType() )
{
- xub_StrLen nPos = 0;
- String sLvl( ',' );
- sLvl += String::CreateFromInt32( n + 1 );
- do {
- String sStyle( rStyles.GetToken( 0,
- TOX_STYLE_DELIMITER, nPos ));
- if( sStyle.Len() )
+ // Take the TOC value of the max level to evaluate to as
+ // the starting point for the \o flag, but reduce it to the
+ // value of the highest outline level filled by a *standard*
+ // Heading 1 - 9 style because \o "Builds a table of
+ // contents from paragraphs formatted with built-in heading
+ // styles". And afterward fill in any outline styles left
+ // uncovered by that range to the \t flag
+ //
+ // i.e. for
+ // Heading 1
+ // Heading 2
+ // custom-style
+ // Heading 4
+ // output
+ // \o 1-2 \tcustom-style,3,Heading 3,4
+
+ // Search over all the outline styles used and figure out
+ // what is the minimum outline level (if any) filled by a
+ // non-standard style for that level, i.e. ignore headline
+ // styles 1-9 and find the lowest valid outline level
+ sal_uInt8 nPosOfLowestNonStandardLvl = MAXLEVEL;
+ const SwTxtFmtColls& rColls = *GetExport().pDoc->GetTxtFmtColls();
+ for( n = rColls.Count(); n; )
+ {
+ const SwTxtFmtColl* pColl = rColls[ --n ];
+ sal_uInt16 nPoolId = pColl->GetPoolFmtId();
+ if (
+ //Is a Non-Standard Outline Style
+ (RES_POOLCOLL_HEADLINE1 > nPoolId || RES_POOLCOLL_HEADLINE9 < nPoolId) &&
+ //Has a valid outline level
+ (pColl->IsAssignedToListLevelOfOutlineStyle()) &&
+ // Is less than the lowest known non-standard level
+ (pColl->GetAssignedOutlineStyleLevel() < nPosOfLowestNonStandardLvl)
+ )
{
- SwTxtFmtColl* pColl = GetExport().pDoc->FindTxtFmtCollByName(sStyle);
- if (!pColl->IsAssignedToListLevelOfOutlineStyle() || pColl->GetAssignedOutlineStyleLevel() < nTOXLvl)
+ nPosOfLowestNonStandardLvl = ::sal::static_int_cast<sal_uInt8>(pColl->GetAssignedOutlineStyleLevel());
+ }
+ }
+
+ sal_uInt8 nMaxMSAutoEvaluate = nPosOfLowestNonStandardLvl < nTOXLvl ? nPosOfLowestNonStandardLvl : (sal_uInt8)nTOXLvl;
+
+ //output \o 1-X where X is the highest normal outline style to be included in the toc
+ if ( nMaxMSAutoEvaluate )
+ {
+ if (nMaxMSAutoEvaluate > WW8ListManager::nMaxLevel)
+ nMaxMSAutoEvaluate = WW8ListManager::nMaxLevel;
+
+ sStr.APPEND_CONST_ASC( "\\o \"1-" );
+ sStr += String::CreateFromInt32( nMaxMSAutoEvaluate );
+ sStr.AppendAscii(sEntryEnd);
+ }
+
+ //collect up any other styles in the writer TOC which will
+ //not already appear in the MS TOC and place then into the
+ //\t option
+ if( nMaxMSAutoEvaluate < nTOXLvl )
+ {
+ // collect this templates into the \t otion
+ for( n = rColls.Count(); n;)
+ {
+ const SwTxtFmtColl* pColl = rColls[ --n ];
+ if (!pColl->IsAssignedToListLevelOfOutlineStyle())
+ continue;
+ sal_uInt8 nTestLvl = ::sal::static_int_cast<sal_uInt8>(pColl->GetAssignedOutlineStyleLevel());
+ if (nTestLvl < nTOXLvl && nTestLvl >= nMaxMSAutoEvaluate)
{
if( sTOption.Len() )
sTOption += ',';
- ( sTOption += sStyle ) += sLvl;
+ (( sTOption += pColl->GetName() ) += ',' )
+ += String::CreateFromInt32( nTestLvl + 1 );
}
}
- } while( STRING_NOTFOUND != nPos );
+ }
}
- }
- {
- String aFillTxt;
- sal_uInt8 nNoPgStt = MAXLEVEL, nNoPgEnd = MAXLEVEL;
- bool bFirstFillTxt = true, bOnlyText = true;
- for( n = 0; n < nTOXLvl; ++n )
- {
- String aTxt;
- int nRet = ::lcl_CheckForm( pTOX->GetTOXForm(),
- static_cast< sal_uInt8 >(n+1), aTxt );
- if( 1 == nRet )
- {
- bOnlyText = false;
- if( MAXLEVEL == nNoPgStt )
- nNoPgStt = static_cast< sal_uInt8 >(n+1);
- }
- else
- {
- if( MAXLEVEL != nNoPgStt &&
- MAXLEVEL == nNoPgEnd )
- nNoPgEnd = sal_uInt8(n);
+ if( nsSwTOXElement::TOX_TEMPLATE & pTOX->GetCreateType() )
+ // --> OD 2009-02-27 #i99641#
+ // Consider additional styles regardless of TOX-outlinelevel
+ for( n = 0; n < MAXLEVEL; ++n )
+ // <--
+ {
+ const String& rStyles = pTOX->GetStyleNames( n );
+ if( rStyles.Len() )
+ {
+ xub_StrLen nPos = 0;
+ String sLvl( ',' );
+ sLvl += String::CreateFromInt32( n + 1 );
+ do {
+ String sStyle( rStyles.GetToken( 0,
+ TOX_STYLE_DELIMITER, nPos ));
+ if( sStyle.Len() )
+ {
+ SwTxtFmtColl* pColl = GetExport().pDoc->FindTxtFmtCollByName(sStyle);
+ if (!pColl->IsAssignedToListLevelOfOutlineStyle() || pColl->GetAssignedOutlineStyleLevel() < nTOXLvl)
+ {
+ if( sTOption.Len() )
+ sTOption += ',';
+ ( sTOption += sStyle ) += sLvl;
+ }
+ }
+ } while( STRING_NOTFOUND != nPos );
+ }
+ }
+
+ {
+ String aFillTxt;
+ sal_uInt8 nNoPgStt = MAXLEVEL, nNoPgEnd = MAXLEVEL;
+ bool bFirstFillTxt = true, bOnlyText = true;
+ for( n = 0; n < nTOXLvl; ++n )
+ {
+ String aTxt;
+ int nRet = ::lcl_CheckForm( pTOX->GetTOXForm(),
+ static_cast< sal_uInt8 >(n+1), aTxt );
+ if( 1 == nRet )
+ {
+ bOnlyText = false;
+ if( MAXLEVEL == nNoPgStt )
+ nNoPgStt = static_cast< sal_uInt8 >(n+1);
+ }
+ else
+ {
+ if( MAXLEVEL != nNoPgStt &&
+ MAXLEVEL == nNoPgEnd )
+ nNoPgEnd = sal_uInt8(n);
+
+ bOnlyText = bOnlyText && 3 == nRet;
+ if( 3 == nRet || 4 == nRet )
+ {
+ if( bFirstFillTxt )
+ aFillTxt = aTxt;
+ else if( aFillTxt != aTxt )
+ aFillTxt.Erase();
+ bFirstFillTxt = false;
+ }
+ }
+ }
+ if( MAXLEVEL != nNoPgStt )
+ {
+ if (WW8ListManager::nMaxLevel < nNoPgEnd)
+ nNoPgEnd = WW8ListManager::nMaxLevel;
+ sStr.APPEND_CONST_ASC( "\\n " );
+ sStr += String::CreateFromInt32( nNoPgStt );
+ sStr += '-';
+ sStr += String::CreateFromInt32( nNoPgEnd );
+ sStr += ' ';
+ }
+ if( bOnlyText )
+ {
+ sStr.APPEND_CONST_ASC( "\\p \"" );
+ sStr += aFillTxt;
+ sStr.AppendAscii(sEntryEnd);
+ }
+ }
- bOnlyText = bOnlyText && 3 == nRet;
- if( 3 == nRet || 4 == nRet )
+ if( sTOption.Len() )
{
- if( bFirstFillTxt )
- aFillTxt = aTxt;
- else if( aFillTxt != aTxt )
- aFillTxt.Erase();
- bFirstFillTxt = false;
+ sStr.APPEND_CONST_ASC( "\\t \"" );
+ sStr += sTOption;
+ sStr.AppendAscii(sEntryEnd);
}
- }
- }
- if( MAXLEVEL != nNoPgStt )
- {
- if (WW8ListManager::nMaxLevel < nNoPgEnd)
- nNoPgEnd = WW8ListManager::nMaxLevel;
- sStr.APPEND_CONST_ASC( "\\n " );
- sStr += String::CreateFromInt32( nNoPgStt );
- sStr += '-';
- sStr += String::CreateFromInt32( nNoPgEnd );
- sStr += ' ';
- }
- if( bOnlyText )
- {
- sStr.APPEND_CONST_ASC( "\\p \"" );
- sStr += aFillTxt;
- sStr.AppendAscii(sEntryEnd);
- }
- }
- if( sTOption.Len() )
- {
- sStr.APPEND_CONST_ASC( "\\t \"" );
- sStr += sTOption;
- sStr.AppendAscii(sEntryEnd);
+ if (lcl_IsHyperlinked(pTOX->GetTOXForm(), nTOXLvl))
+ sStr.APPEND_CONST_ASC("\\h");
+ }
+ break;
}
-
- if (lcl_IsHyperlinked(pTOX->GetTOXForm(), nTOXLvl))
- sStr.APPEND_CONST_ASC("\\h");
}
- break;
- }
- }
+ }
- if( sStr.Len() )
+ if ( sStr.Len() )
{
GetExport( ).bInWriteTOX = true;
- GetExport( ).OutputField( 0, eCode, sStr, WRITEFIELD_START | WRITEFIELD_CMD_START |
- WRITEFIELD_CMD_END );
+ GetExport( ).OutputField( 0, eCode, sStr,
+ WRITEFIELD_START | WRITEFIELD_CMD_START | WRITEFIELD_CMD_END );
}
}
-
+
GetExport( ).bStartTOX = false;
}
-void AttributeOutputBase::EndTOX( const SwSection& rSect )
+void AttributeOutputBase::EndTOX( const SwSection& rSect,bool bCareEnd )
{
const SwTOXBase* pTOX = rSect.GetTOXBase();
if ( pTOX )
@@ -2425,6 +2373,8 @@ void AttributeOutputBase::EndTOX( const
GetExport( ).OutputField( 0, eCode, aEmptyStr, WRITEFIELD_CLOSE );
}
GetExport( ).bInWriteTOX = false;
+ if (bCareEnd)
+ OnTOXEnding();
}
bool MSWordExportBase::GetNumberFmt(const SwField& rFld, String& rStr)
Modified: incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8attributeoutput.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8attributeoutput.hxx?rev=1380613&r1=1380612&r2=1380613&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8attributeoutput.hxx (original)
+++ incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8attributeoutput.hxx Tue Sep 4 12:53:09 2012
@@ -52,6 +52,8 @@ public:
///
virtual void StartRun( const SwRedlineData* pRedlineData );
+ virtual void OnTOXEnding();
+
/// End of the text run.
///
/// No-op for binary filters.
@@ -429,8 +431,10 @@ protected:
/// of the field results if we were forced to split text.
sal_uInt16 m_nFieldResults;
+ bool mbOnTOXEnding;
+
public:
- WW8AttributeOutput( WW8Export &rWW8Export ) : AttributeOutputBase(), m_rWW8Export( rWW8Export ) {}
+ WW8AttributeOutput( WW8Export &rWW8Export ) : AttributeOutputBase(), m_rWW8Export( rWW8Export ),mbOnTOXEnding(false) {}
virtual ~WW8AttributeOutput() {}
/// Return the right export class.
Modified: incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8par.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8par.cxx?rev=1380613&r1=1380612&r2=1380613&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8par.cxx (original)
+++ incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8par.cxx Tue Sep 4 12:53:09 2012
@@ -2723,7 +2723,13 @@ bool SwWW8ImplReader::ReadChar(long nPos
break;
case 0x15:
if( !bSpec ) // Juristenparagraph
- cInsert = '\xa7';
+ {
+ cp_set::iterator aItr = maTOXEndCps.find((WW8_CP)nPosCp);
+ if (aItr == maTOXEndCps.end())
+ cInsert = '\xa7';
+ else
+ maTOXEndCps.erase(aItr);
+ }
break;
case 0x9:
cInsert = '\x9'; // Tab
@@ -3108,7 +3114,23 @@ bool SwWW8ImplReader::ReadText(long nSta
// create a new txtnode and join the two paragraphs together
if (bStartLine && !pPreviousNode) // Zeilenende
- AppendTxtNode(*pPaM->GetPoint());
+ {
+ bool bSplit = true;
+ if (mbCareFirstParaEndInToc)
+ {
+ mbCareFirstParaEndInToc = false;
+ if (pPaM->End() && pPaM->End()->nNode.GetNode().GetTxtNode() && pPaM->End()->nNode.GetNode().GetTxtNode()->Len() == 0)
+ bSplit = false;
+ }
+ if (mbCareLastParaEndInToc)
+ {
+ mbCareLastParaEndInToc = false;
+ if (pPaM->End() && pPaM->End()->nNode.GetNode().GetTxtNode() && pPaM->End()->nNode.GetNode().GetTxtNode()->Len() == 0)
+ bSplit = false;
+ }
+ if (bSplit)
+ AppendTxtNode(*pPaM->GetPoint());
+ }
if (pPreviousNode && bStartLine)
{
@@ -3273,6 +3295,9 @@ SwWW8ImplReader::SwWW8ImplReader(sal_uIn
, mbLoadingTOCCache(false)
, mbLoadingTOCHyperlink(false)
, mpPosAfterTOC(0)
+ , mbCareFirstParaEndInToc(false)
+ , mbCareLastParaEndInToc(false)
+ , maTOXEndCps()
{
pStrm->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
nWantedVersion = nVersionPara;
@@ -3594,11 +3619,11 @@ void wwSectionManager::InsertSegments()
bool bInsertSection = (aIter != aStart) ? (aIter->IsContinous() && bThisAndPreviousAreCompatible): false;
bool bInsertPageDesc = !bInsertSection;
bool bProtected = SectionIsProtected(*aIter); // do we really need this ?? I guess I have a different logic in editshell which disales this...
- if (bUseEnhFields && mrReader.pWDop->fProtEnabled && aIter->IsNotProtected()) {
- // here we have the special case that the whole document is protected, with the execption of this section.
- // I want to address this when I do the section rework, so for the moment we disable the overall protection then...
- mrReader.rDoc.set(IDocumentSettingAccess::PROTECT_FORM, false );
- }
+ if (bUseEnhFields && mrReader.pWDop->fProtEnabled && aIter->IsNotProtected()) {
+ // here we have the special case that the whole document is protected, with the execption of this section.
+ // I want to address this when I do the section rework, so for the moment we disable the overall protection then...
+ mrReader.rDoc.set(IDocumentSettingAccess::PROTECT_FORM, false );
+ }
if (bInsertPageDesc)
Modified: incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8par.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8par.hxx?rev=1380613&r1=1380612&r2=1380613&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8par.hxx (original)
+++ incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8par.hxx Tue Sep 4 12:53:09 2012
@@ -789,6 +789,9 @@ struct WW8PostProcessAttrsInfo
//-----------------------------------------
// Storage-Reader
//-----------------------------------------
+typedef std::set<WW8_CP> cp_set;
+
+
class SwWW8ImplReader
{
private:
@@ -1097,6 +1100,9 @@ private:
// a document position recorded the after-position of TOC section, managed by Read_F_TOX() and End_Field()
SwPaM* mpPosAfterTOC;
+ bool mbCareFirstParaEndInToc;
+ bool mbCareLastParaEndInToc;
+ cp_set maTOXEndCps;
//---------------------------------------------
const SprmReadInfo& GetSprmReadInfo(sal_uInt16 nId) const;
Modified: incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8par5.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8par5.cxx?rev=1380613&r1=1380612&r2=1380613&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8par5.cxx (original)
+++ incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8par5.cxx Tue Sep 4 12:53:09 2012
@@ -666,7 +666,8 @@ sal_uInt16 SwWW8ImplReader::End_Field()
sal_uInt16 nRet = 0;
WW8PLCFx_FLD* pF = pPlcxMan->GetFld();
ASSERT(pF, "WW8PLCFx_FLD - Pointer nicht da");
- if (!pF || !pF->EndPosIsFieldEnd())
+ WW8_CP nCP = 0;
+ if (!pF || !pF->EndPosIsFieldEnd(nCP))
return nRet;
const SvtFilterOptions* pOpt = SvtFilterOptions::Get();
@@ -720,9 +721,18 @@ sal_uInt16 SwWW8ImplReader::End_Field()
case 8://index
if (mbLoadingTOCCache)
{
+ maTOXEndCps.insert(nCP);
mbLoadingTOCCache = false;
- if (pPaM->End() && pPaM->End()->nNode.GetNode().GetTxtNode() && pPaM->End()->nNode.GetNode().GetTxtNode()->Len() == 0)
+ if ( pPaM->End() &&
+ pPaM->End()->nNode.GetNode().GetTxtNode() &&
+ pPaM->End()->nNode.GetNode().GetTxtNode()->Len() == 0 )
+ {
JoinNode(*pPaM);
+ }
+ else
+ {
+ mbCareLastParaEndInToc = true;
+ }
if (mpPosAfterTOC)
{
@@ -761,19 +771,15 @@ bool AcceptableNestedField(sal_uInt16 nF
{
switch (nFieldCode)
{
-//#if defined(WW_NATIVE_TOC)
- case 8: // allow recursive field in TOC...
- case 13: // allow recursive field in TOC...
-//#endif
+ case 8: // allow recursive field in TOC...
+ case 13: // allow recursive field in TOC...
case 36:
case 68:
case 79:
case 88:
- // --> OD 2007-01-02 #b6504125#
// Accept AutoTextList field as nested field.
// Thus, the field result is imported as plain text.
case 89:
- // <--
return true;
default:
return false;
@@ -2153,13 +2159,10 @@ eF_ResT SwWW8ImplReader::Read_F_PgRef( W
_ReadFieldParams aReadParam( rStr );
while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
{
- switch( nRet )
+ if ( nRet == -2 &&
+ !sOrigName.Len() )
{
- case -2:
- if( !sOrigName.Len() )
- sOrigName = aReadParam.GetResult();
-
- break;
+ sOrigName = aReadParam.GetResult();
}
}
@@ -3144,6 +3147,7 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8
case TOX_CONTENT:
{
bool bIsHyperlink = false;
+ bool bShowPage = true;
// TOX_OUTLINELEVEL setzen wir genau dann, wenn
// die Parameter \o in 1 bis 9 liegen
// oder der Parameter \f existiert
@@ -3253,6 +3257,7 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8
case 'n': // don't print page numbers
{
// read START and END param
+ bShowPage = false;
sal_uInt16 nStart, nEnd;
if( !aReadParam.GetTokenSttFromTo( &nStart, &nEnd,
WW8ListManager::nMaxLevel ) )
@@ -3327,9 +3332,11 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8
for(sal_uInt16 nLevel = 1; nLevel <= nEnd; ++nLevel)
{
SwFormTokens aPattern = aForm.GetPattern(nLevel);
- if (bIsHyperlink)
+ if ( bIsHyperlink )
+ {
aPattern.insert(aPattern.begin(), aLinkStart);
- else
+ }
+ else if ( bShowPage )
{
for (SwFormTokens::iterator aItr = aPattern.begin();aItr!= aPattern.end();aItr++)
{
@@ -3470,6 +3477,14 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8
//#i10028# inserting a toc implicltly acts like a parabreak
//in word and writer
+
+ if ( pPaM->End() &&
+ pPaM->End()->nNode.GetNode().GetTxtNode() &&
+ pPaM->End()->nNode.GetNode().GetTxtNode()->Len() != 0 )
+ {
+ mbCareFirstParaEndInToc = true;
+ }
+
if (pPaM->GetPoint()->nContent.GetIndex())
AppendTxtNode(*pPaM->GetPoint());
@@ -3516,6 +3531,7 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8
ASSERT(rDoc.GetCurTOX(*aRegion.GetPoint()), "Misunderstood how toc works");
if (SwTOXBase* pBase2 = (SwTOXBase*)rDoc.GetCurTOX(*aRegion.GetPoint()))
{
+ pBase2->SetMSTOCExpression(rStr);
if(nIndexCols>1)
{
// Set the column number for index
@@ -3536,7 +3552,7 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8
if (!maApos.back()) //a para end in apo doesn't count
bWasParaEnd = true;
- //Reture FLD_TEXT, instead of FLD_OK
+ //Return FLD_TEXT, instead of FLD_OK
//FLD_TEXT means the following content, commonly indicate the field representation content should be parsed
//FLD_OK means the current field loading is finished. The rest part should be ignored.
return FLD_TEXT;
@@ -3559,7 +3575,6 @@ eF_ResT SwWW8ImplReader::Read_F_Hyperlin
::rtl::OUString aBookmarkName=::rtl::OUString::createFromAscii("_HYPERLINK");
maFieldStack.back().SetBookmarkName(aBookmarkName);
maFieldStack.back().SetBookmarkType(::rtl::OUString::createFromAscii(ODF_HYPERLINK));
-// maFieldStack.back().AddParam(::rtl::OUString::createFromAscii("Description"), aFormula.sToolTip);
return FLD_TEXT;
}
#endif
@@ -3627,7 +3642,6 @@ eF_ResT SwWW8ImplReader::Read_F_Hyperlin
( sURL += INET_MARK_TOKEN ) += sMark;
SwFmtINetFmt aURL( sURL, sTarget );
-
// If on loading TOC field, change the default style into the "index link"
if (mbLoadingTOCCache)
{
Modified: incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8scan.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8scan.cxx?rev=1380613&r1=1380612&r2=1380613&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8scan.cxx (original)
+++ incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8scan.cxx Tue Sep 4 12:53:09 2012
@@ -3786,7 +3786,7 @@ bool WW8PLCFx_FLD::StartPosIsFieldStart(
return true;
}
-bool WW8PLCFx_FLD::EndPosIsFieldEnd()
+bool WW8PLCFx_FLD::EndPosIsFieldEnd(WW8_CP& nCP)
{
bool bRet = false;
@@ -3799,7 +3799,10 @@ bool WW8PLCFx_FLD::EndPosIsFieldEnd()
void* pData;
sal_Int32 nTest;
if ( pPLCF->Get(nTest, pData) && ((((sal_uInt8*)pData)[0] & 0x1f) == 0x15) )
+ {
+ nCP = nTest;
bRet = true;
+ }
pPLCF->SetIdx(n);
}
@@ -4116,7 +4119,14 @@ WW8PLCFx& WW8PLCFx_Book::operator ++( in
else if( l1 < l0 )
nIsEnd = 1;
else
- nIsEnd = ( nIsEnd ) ? 0 : 1;
+ {
+ const void * p = pBook[0]->GetData(pBook[0]->GetIdx());
+ long nPairFor = (p == NULL)? 0L : SVBT16ToShort(*((SVBT16*) p));
+ if (nPairFor == pBook[1]->GetIdx())
+ nIsEnd = 0;
+ else
+ nIsEnd = ( nIsEnd ) ? 0 : 1;
+ }
}
return *this;
}
Modified: incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8scan.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8scan.hxx?rev=1380613&r1=1380612&r2=1380613&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8scan.hxx (original)
+++ incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8scan.hxx Tue Sep 4 12:53:09 2012
@@ -701,7 +701,7 @@ public:
virtual void GetSprms(WW8PLCFxDesc* p);
virtual WW8PLCFx& operator ++( int );
bool StartPosIsFieldStart();
- bool EndPosIsFieldEnd();
+ bool EndPosIsFieldEnd(WW8_CP&);
bool GetPara(long nIdx, WW8FieldDesc& rF);
};
Modified: incubator/ooo/branches/writer001/main/sw/source/ui/index/toxmgr.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/sw/source/ui/index/toxmgr.cxx?rev=1380613&r1=1380612&r2=1380613&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/sw/source/ui/index/toxmgr.cxx (original)
+++ incubator/ooo/branches/writer001/main/sw/source/ui/index/toxmgr.cxx Tue Sep 4 12:53:09 2012
@@ -459,7 +459,9 @@ sal_Bool SwTOXMgr::UpdateOrInsertTOX(con
if (pNewTOX != NULL) // => pTOX != NULL
pDoc->ChgTOX(*pTOX, *pNewTOX);
- bRet = pSh->UpdateTableOf(*pTOX, pSet);
+ pTOX->DisableKeepExpression();
+ bRet = pSh->UpdateTableOf(*pTOX, pSet);
+ pTOX->EnableKeepExpression();
if (pDoc->GetIDocumentUndoRedo().DoesUndo())
{