summaryrefslogtreecommitdiff
path: root/sw/source/filter/ww8
diff options
context:
space:
mode:
authorCaolán McNamara <cmc@openoffice.org>2002-02-04 08:50:19 +0000
committerCaolán McNamara <cmc@openoffice.org>2002-02-04 08:50:19 +0000
commit3e13e053749e1bf19179bf83bdf0a18a9488b5e8 (patch)
tree0234f9f29a5134de7b3a5ceaff994ffc3066baac /sw/source/filter/ww8
parent856ef59f81446a0fb762fd0f2af5852c3a026cb2 (diff)
#i2408# Import and export set/ask references fields as set/input, change references to bookmarks to show variable as appropiate
Diffstat (limited to 'sw/source/filter/ww8')
-rw-r--r--sw/source/filter/ww8/wrtw8nds.cxx11
-rw-r--r--sw/source/filter/ww8/wrtww8.cxx72
-rw-r--r--sw/source/filter/ww8/wrtww8.hxx10
-rw-r--r--sw/source/filter/ww8/ww8atr.cxx95
-rw-r--r--sw/source/filter/ww8/ww8par.cxx210
-rw-r--r--sw/source/filter/ww8/ww8par.hxx63
-rw-r--r--sw/source/filter/ww8/ww8par5.cxx332
-rw-r--r--sw/source/filter/ww8/ww8par6.cxx269
-rw-r--r--sw/source/filter/ww8/ww8scan.cxx112
-rw-r--r--sw/source/filter/ww8/ww8scan.hxx9
10 files changed, 713 insertions, 470 deletions
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
index 4639c3f7e6c2..f5fae8ee652a 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: wrtw8nds.cxx,v $
*
- * $Revision: 1.15 $
+ * $Revision: 1.16 $
*
- * last change: $Author: cmc $ $Date: 2002-01-23 12:32:13 $
+ * last change: $Author: cmc $ $Date: 2002-02-04 09:50:19 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -1114,6 +1114,8 @@ Writer& OutWW8_SwTxtNode( Writer& rWrt, SwCntntNode& rNode )
if( nNextAttr > nEnd )
nNextAttr = nEnd;
+ //Append bookmarks in this range, exclusive of final position
+ //of this range
rWW8Wrt.AppendBookmarks( *pNd, nAktPos, nNextAttr - nAktPos );
BOOL bTxtAtr = aAttrIter.IsTxtAttr( nAktPos );
BOOL bAttrWithRange = aAttrIter.OutAttrWithRange( nAktPos );
@@ -1132,6 +1134,8 @@ Writer& OutWW8_SwTxtNode( Writer& rWrt, SwCntntNode& rNode )
bRedlineAtEnd = TRUE;
else
{
+ //insert final bookmarks if any before CR
+ rWW8Wrt.AppendBookmarks( *pNd, nEnd, 1 );
if( pTOXSect )
rWW8Wrt.EndTOX( *pTOXSect );
rWW8Wrt.WriteCR(); // CR danach
@@ -1157,6 +1161,9 @@ Writer& OutWW8_SwTxtNode( Writer& rWrt, SwCntntNode& rNode )
if( bTxtAtr || bAttrWithRange || bRedlineAtEnd )
{
+ //insert final bookmarks if any before CR
+ rWW8Wrt.AppendBookmarks( *pNd, nEnd, 1 );
+
if( pTOXSect )
rWW8Wrt.EndTOX( *pTOXSect );
diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx
index 2d28761c36e8..84560190c023 100644
--- a/sw/source/filter/ww8/wrtww8.cxx
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: wrtww8.cxx,v $
*
- * $Revision: 1.24 $
+ * $Revision: 1.25 $
*
- * last change: $Author: cmc $ $Date: 2002-01-23 12:32:13 $
+ * last change: $Author: cmc $ $Date: 2002-02-04 09:50:19 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -266,8 +266,9 @@ public:
class WW8_WrtBookmarks
{
private:
- SvULongs aSttCps, aEndCps; // Array of Start- and End CPs
- SvStringsDtor aSwBkmkNms; // Array of Sw - Bookmarknames
+ SvULongs aSttCps, aEndCps; // Array of Start- and End CPs
+ SvBools aFieldBookmarks; // If the bookmark is in a field result
+ SvStringsDtor aSwBkmkNms; // Array of Sw - Bookmarknames
USHORT GetPos( const String& rNm );
@@ -280,6 +281,7 @@ public:
void Append( WW8_CP nStartCp, const String& rNm );
void Write( SwWW8Writer& rWrt );
+ void MoveFieldBookmarks(ULONG nFrom,ULONG nTo);
// String GetWWBkmkName( const String& rName ) const;
};
@@ -1242,6 +1244,7 @@ void WW8_WrtBookmarks::Append( WW8_CP nStartCp, const String& rNm )
aSttCps.Insert( nStartCp, nPos );
aEndCps.Insert( nStartCp, nPos );
+ aFieldBookmarks.Insert( BOOL(FALSE), nPos );
String* p = new String( rNm );
aSwBkmkNms.Insert( p, nPos );
// JP 24.06.99: not used at time
@@ -1252,6 +1255,13 @@ void WW8_WrtBookmarks::Append( WW8_CP nStartCp, const String& rNm )
{
// 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 (aFieldBookmarks[nPos])
+ --nStartCp;
+
aEndCps.Replace( nStartCp, nPos );
}
}
@@ -1331,6 +1341,55 @@ USHORT WW8_WrtBookmarks::GetPos( const String& rNm )
return nRet;
}
+void WW8_WrtBookmarks::MoveFieldBookmarks(ULONG nFrom, ULONG nTo)
+{
+ for (USHORT nI=0;nI<aSttCps.Count();++nI)
+ {
+ if (aSttCps[nI] == nFrom)
+ {
+ aSttCps[nI] = nTo;
+ if (aEndCps[nI] == nFrom)
+ {
+ aFieldBookmarks[nI] = TRUE;
+ aEndCps[nI] = nTo;
+ }
+ }
+ }
+}
+
+/*
+Writer::GetBookmarks is inconsistent, when its changed this might go away, and
+the usage of GetBookmarks refined. GetBookmarks is inconsistent in use between
+asking for a range in the txtnode that has bookmarks vs the full node. The
+first is exclusive of the end point, the second is inclusive. This makes is
+consistently exclusive.
+*/
+USHORT SwWW8Writer::GetBookmarks(const SwCntntNode& rNd, xub_StrLen nStt,
+ xub_StrLen nEnd, SvPtrarr& rArr)
+{
+ if (Writer::GetBookmarks( rNd, nStt, nEnd, rArr))
+ {
+ if (!nStt && nEnd == rNd.Len())
+ {
+ for( USHORT n = 0; n < rArr.Count(); ++n )
+ {
+ void* p = rArr[n];
+ const SwBookmark& rBkmk = *(SwBookmark*)p;
+ xub_StrLen nCntnt = rBkmk.GetPos().nContent.GetIndex();
+ xub_StrLen nCntnt2;
+ if (rBkmk.GetOtherPos())
+ nCntnt2 = rBkmk.GetOtherPos()->nContent.GetIndex();
+ else
+ nCntnt2 = nCntnt;
+
+ if ((nCntnt >= nEnd) && (nCntnt2 >= nEnd))
+ rArr.Remove(n--);
+ }
+ }
+ }
+ return rArr.Count();
+}
+
void SwWW8Writer::AppendBookmarks( const SwTxtNode& rNd,
xub_StrLen nAktPos, xub_StrLen nLen )
{
@@ -1370,6 +1429,11 @@ void SwWW8Writer::AppendBookmarks( const SwTxtNode& rNd,
}
}
+void SwWW8Writer::MoveFieldBookmarks(ULONG nFrom, ULONG nTo)
+{
+ pBkmks->MoveFieldBookmarks(nFrom, nTo);
+}
+
void SwWW8Writer::AppendBookmark( const String& rName, USHORT nOffset )
{
ULONG nSttCP = Fc2Cp( Strm().Tell() ) + nOffset;
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index 58ae52fcb498..57aa71d2be91 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: wrtww8.hxx,v $
*
- * $Revision: 1.15 $
+ * $Revision: 1.16 $
*
- * last change: $Author: cmc $ $Date: 2002-01-15 11:21:11 $
+ * last change: $Author: cmc $ $Date: 2002-02-04 09:50:19 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -68,6 +68,7 @@
#include <tools/gen.hxx>
#endif
#ifndef _SVSTDARR_HXX
+#define _SVSTDARR_BOOLS
#define _SVSTDARR_USHORTS
#define _SVSTDARR_ULONGS
#define _SVSTDARR_STRINGS
@@ -461,8 +462,13 @@ public:
SvStorageRef xObjStg, String &rStorageName, SwOLENode *pOLENd);
void AppendBookmarks( const SwTxtNode& rNd, xub_StrLen nAktPos,
xub_StrLen nLen );
+ //Hides Writer::GetBookmarks, hopefully temporarily until that is
+ //made consistent.
+ USHORT GetBookmarks(const SwCntntNode& rNd, xub_StrLen nStt,
+ xub_StrLen nEnd, SvPtrarr& rArr);
void AppendBookmark( const String& rName, USHORT nOffset = 0 );
String GetBookmarkName( USHORT nTyp, const String* pNm, USHORT nSeqNo );
+ void MoveFieldBookmarks(ULONG nFrom, ULONG nTo);
BOOL HasRefToObject( USHORT nTyp, const String* pNm, USHORT nSeqNo );
void WriteAsStringTable( const SvStrings&, INT32& rfcSttbf,
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 8f5499a2b7ee..a4fd2cbaa968 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ww8atr.cxx,v $
*
- * $Revision: 1.29 $
+ * $Revision: 1.30 $
*
- * last change: $Author: cmc $ $Date: 2002-01-23 12:32:13 $
+ * last change: $Author: cmc $ $Date: 2002-02-04 09:50:19 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -255,6 +255,9 @@
#ifndef _DOCUFLD_HXX
#include <docufld.hxx> // fuer SwField ...
#endif
+#ifndef _EXPFLD_HXX
+#include <expfld.hxx>
+#endif
#ifndef _FORMAT_HXX
#include <format.hxx>
#endif
@@ -571,7 +574,9 @@ void SwWW8Writer::Out_SwFmt( const SwFmt& rFmt, BOOL bPapFmt, BOOL bChpFmt,
if( bWrtWW8 )
{
- // write sprmPIlvl and sprmPIlfo
+ // write sprmPOutLvl sprmPIlvl and sprmPIlfo
+ SwWW8Writer::InsUInt16( *pO, 0x2640 );
+ pO->Insert( nLvl, pO->Count() );
SwWW8Writer::InsUInt16( *pO, 0x260a );
pO->Insert( nLvl, pO->Count() );
SwWW8Writer::InsUInt16( *pO, 0x460b );
@@ -1784,7 +1789,31 @@ static Writer& OutWW8_SwField( Writer& rWrt, const SfxPoolItem& rHt )
{
// case RES_CHAPTERFLD:
// break;
-
+ case RES_GETEXPFLD:
+ if (nSubType == GSE_STRING)
+ {
+ const SwGetExpField *pGet=(const SwGetExpField*)(pFld);
+ sStr.ASSIGN_CONST_ASC( " REF \"" );
+ sStr += pGet->GetFormula();
+ sStr.APPEND_CONST_ASC( "\" " );
+ rWW8Wrt.OutField( pFld, 3, sStr,WRITEFIELD_START |
+ WRITEFIELD_CMD_START | WRITEFIELD_CMD_END);
+ String sVar = pFld->Expand();
+ if (sVar.Len())
+ {
+ if (rWW8Wrt.IsUnicode())
+ SwWW8Writer::WriteString16( rWrt.Strm(), sVar, FALSE );
+ else
+ {
+ SwWW8Writer::WriteString8( rWrt.Strm(), sVar, FALSE,
+ RTL_TEXTENCODING_MS_1252 );
+ }
+ }
+ rWW8Wrt.OutField( pFld, 3, sStr, WRITEFIELD_CLOSE );
+ }
+ else
+ bWriteExpand = TRUE;
+ break;
case RES_SETEXPFLD:
if( GSE_SEQ == nSubType )
{
@@ -1795,10 +1824,60 @@ static Writer& OutWW8_SwField( Writer& rWrt, const SfxPoolItem& rHt )
::WW8_GetNumberPara( sStr, *pFld );
rWW8Wrt.OutField( pFld, 12, sStr );
}
+ else if (nSubType & GSE_STRING)
+ {
+ BYTE nFieldNo;
+ const SwSetExpField *pSet=(const SwSetExpField*)(pFld);
+ const String &rVar = pSet->GetPar2();
+ if (pSet->GetInputFlag())
+ {
+ sStr.ASSIGN_CONST_ASC( " ASK \"" );
+ sStr += pSet->GetPar1();
+ sStr.APPEND_CONST_ASC( "\" " );
+ sStr += pSet->GetPromptText();
+ sStr.APPEND_CONST_ASC( " \\d " );
+ sStr += rVar;
+ nFieldNo = 38;
+ }
+ else
+ {
+ sStr.ASSIGN_CONST_ASC( " SET \"" );
+ sStr += pSet->GetPar1();
+ sStr.APPEND_CONST_ASC( "\" " );
+ sStr += rVar;
+ nFieldNo = 6;
+ }
+
+ ULONG nFrom = rWW8Wrt.Fc2Cp(rWrt.Strm().Tell());
+
+ rWW8Wrt.OutField( pFld, nFieldNo, sStr,WRITEFIELD_START |
+ WRITEFIELD_CMD_START | WRITEFIELD_CMD_END);
+
+ /*
+ Is there a bookmark at the start position of this field, if so
+ move it to the 0x14 of the result of the field. This is what word
+ does. MoveFieldBookmarks moves any bookmarks at this position to
+ the beginning of the field result, and marks the bookmark as a
+ fieldbookmark which is to be ended before the field end mark
+ instead of after it like a normal bookmark.
+ */
+ rWW8Wrt.MoveFieldBookmarks(nFrom,rWW8Wrt.Fc2Cp(rWrt.Strm().Tell()));
+
+ if (rVar.Len())
+ {
+ if (rWW8Wrt.IsUnicode())
+ SwWW8Writer::WriteString16( rWrt.Strm(), rVar, FALSE );
+ else
+ {
+ SwWW8Writer::WriteString8( rWrt.Strm(), rVar, FALSE,
+ RTL_TEXTENCODING_MS_1252 );
+ }
+ }
+ rWW8Wrt.OutField( pFld, nFieldNo, sStr, WRITEFIELD_CLOSE );
+ }
else
bWriteExpand = TRUE;
break;
-
case RES_PAGENUMBERFLD:
sStr.ASSIGN_CONST_ASC( " SEITE " );
::WW8_GetNumberPara( sStr, *pFld );
@@ -2028,13 +2107,13 @@ static Writer& OutWW8_SwField( Writer& rWrt, const SfxPoolItem& rHt )
sStr.InsertAscii( "SEITEN", 1 );
nFldTyp = 37;
break;
-
case REF_UPDOWN:
sStr.APPEND_CONST_ASC( " \\p" );
nFldTyp = 3;
break;
-
case REF_CHAPTER:
+ sStr.APPEND_CONST_ASC( " \\n" );
+ break;
case REF_ONLYNUMBER:
case REF_ONLYCAPTION:
case REF_ONLYSEQNO:
@@ -2042,10 +2121,8 @@ static Writer& OutWW8_SwField( Writer& rWrt, const SfxPoolItem& rHt )
// default:
// case REF_CONTENT:
}
-
sStr.APPEND_CONST_ASC( " \\h " ); // insert hyperlink
rWW8Wrt.OutField( pFld, nFldTyp, sStr );
-
}
else
bWriteExpand = TRUE;
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 6cfe8fe43d31..437b1b2acac0 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ww8par.cxx,v $
*
- * $Revision: 1.42 $
+ * $Revision: 1.43 $
*
- * last change: $Author: cmc $ $Date: 2002-01-23 12:32:13 $
+ * last change: $Author: cmc $ $Date: 2002-02-04 09:50:19 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -390,31 +390,12 @@ void SwWW8ImplReader::Read_Majority( USHORT, const BYTE* , short )
//-----------------------------------------
// Stack
//-----------------------------------------
-BOOL SwWW8FltControlStack::IsFtnEdnBkmField(SwFmtFld& rFmtFld, USHORT& nBkmNo)
+void SwWW8FltControlStack::NewAttr(const SwPosition& rPos,
+ const SfxPoolItem& rAttr)
{
- const SwField* pFld = rFmtFld.GetFld();
- USHORT nSubType;
- return( pFld
- && (RES_GETREFFLD == pFld->Which())
- && ( (REF_FOOTNOTE == (nSubType = pFld->GetSubType()))
- || (REF_ENDNOTE == nSubType))
- && ((SwGetRefField*)pFld)->GetSetRefName().Len()
- // find Sequence No of corresponding Foot-/Endnote
- && (USHRT_MAX != (nBkmNo = pDoc->FindBookmark(
- ((SwGetRefField*)pFld)->GetSetRefName() ))));
-}
-
-void SwWW8FltControlStack::NewAttr(const SwPosition& rPos, const SfxPoolItem& rAttr)
-{
- USHORT nBkmNo;
- if( (RES_TXTATR_FIELD == rAttr.Which())
- && IsFtnEdnBkmField((SwFmtFld&)rAttr, nBkmNo) )
- {
- SwFltStackEntry *pTmp = new SwFltStackEntry(rPos, rAttr.Clone());
- Insert(pTmp, Count());
- }
- else
- SwFltControlStack::NewAttr(rPos, rAttr);
+ ASSERT(RES_TXTATR_FIELD != rAttr.Which(), "probably don't want to put"
+ "fields into the control stack");
+ SwFltControlStack::NewAttr(rPos, rAttr);
}
void SwWW8FltControlStack::SetAttr(const SwPosition& rPos, USHORT nAttrId, BOOL bTstEnde, long nHand)
@@ -435,7 +416,8 @@ void SwWW8FltControlStack::SetAttr(const SwPosition& rPos, USHORT nAttrId, BOOL
SwFltControlStack::SetAttr(rPos, nAttrId, bTstEnde, nHand);
}
-void SwWW8FltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry* pEntry)
+void SwWW8FltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
+ SwFltStackEntry* pEntry)
{
switch( pEntry->pAttr->Which() )
{
@@ -457,116 +439,110 @@ void SwWW8FltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEnt
{
if( bChange1stLine )
{
- if( 0 != (pNum = ((SwTxtNode*)pNode)->GetNum() )
- && (MAXLEVEL > pNum->GetLevel())
- && 0 != (pRule = ((SwTxtNode*)pNode)->GetNumRule() ) )
+ if ( (pNum = ((SwTxtNode*)pNode)->GetNum()) &&
+ (MAXLEVEL > pNum->GetLevel()) &&
+ (pRule = ((SwTxtNode*)pNode)->GetNumRule()) )
{
- const SwNumFmt rNumFmt = pRule->Get( pNum->GetLevel() );
- aLR.SetTxtFirstLineOfst( rNumFmt.GetFirstLineOffset() );
+ const SwNumFmt rNumFmt =
+ pRule->Get(pNum->GetLevel());
+ aLR.SetTxtFirstLineOfst(
+ rNumFmt.GetFirstLineOffset());
}
else
aLR.SetTxtFirstLineOfst( 0 );
}
((SwCntntNode*)pNode)->SetAttr( aLR );
- // wenn wir dies nicht tun, ueberschreibt die NumRule uns alle
- // harten L-Randeinstellungen
+ // wenn wir dies nicht tun, ueberschreibt die NumRule
+ // uns alle harten L-Randeinstellungen
pNode->SetNumLSpace( FALSE );
}
}
}
}
- break;
+ break;
case RES_TXTATR_FIELD:
- {
- SwFmtFld& rFmtFld = *(SwFmtFld*)pEntry->pAttr;
- const SwField* pFld = rFmtFld.GetFld();
- USHORT nBkmNo;
- if( IsFtnEdnBkmField(rFmtFld, nBkmNo) )
- {
- SwBookmark& rBkMrk = pDoc->GetBookmark( nBkmNo );
-
- const SwPosition& rBkMrkPos = rBkMrk.GetPos();
-
- SwTxtNode* pTxt = rBkMrkPos.nNode.GetNode().GetTxtNode();
- if( pTxt && rBkMrkPos.nContent.GetIndex() )
- {
- SwTxtAttr* pFtn = pTxt->GetTxtAttr( rBkMrkPos.nContent.GetIndex()-1,
- RES_TXTATR_FTN );
- if( pFtn )
- {
- USHORT nRefNo = ((SwTxtFtn*)pFtn)->GetSeqRefNo();
+ ASSERT(0,"What is a field doing in the control stack,"
+ "probably should have been in the endstack");
+ break;
+ default:
+ SwFltControlStack::SetAttrInDoc(rTmpPos, pEntry);
+ break;
+ }
+}
- ((SwGetRefField*)pFld)->SetSeqNo( nRefNo );
+BOOL SwWW8FltRefStack::IsFtnEdnBkmField(const SwFmtFld& rFmtFld, USHORT& rBkmNo)
+{
+ const SwField* pFld = rFmtFld.GetFld();
+ USHORT nSubType;
+ return (pFld && (RES_GETREFFLD == pFld->Which())
+ && ((REF_FOOTNOTE == (nSubType = pFld->GetSubType())) ||
+ (REF_ENDNOTE == nSubType))
+ && ((SwGetRefField*)pFld)->GetSetRefName().Len()
+ // find Sequence No of corresponding Foot-/Endnote
+ && (USHRT_MAX != (rBkmNo = pDoc->FindBookmark(
+ ((SwGetRefField*)pFld)->GetSetRefName() ))));
+}
- if( pFtn->GetFtn().IsEndNote() )
- ((SwGetRefField*)pFld)->SetSubType( REF_ENDNOTE );
- }
- }
- /*
- const SwStartNode* pSearchNode =
- rBkMrkPos.nNode.GetNode().FindFootnoteStartNode();
+void SwWW8FltRefStack::SetAttrInDoc(const SwPosition& rTmpPos,
+ SwFltStackEntry* pEntry)
+{
+ switch( pEntry->pAttr->Which() )
+ {
+ /*
+ Look up these in our lists of bookmarks that were changed to
+ variables, and replace the ref field with a var field, otherwise
+ do normal (?) strange stuff
+ */
+ case RES_TXTATR_FIELD:
+ {
+ const SwFmtFld& rFmtFld = *(const SwFmtFld*)pEntry->pAttr;
+ const SwField* pFld = rFmtFld.GetFld();
- if( pSearchNode )
+ if (!RefToVar(pFld,pEntry))
+ {
+ USHORT nBkmNo;
+ if( IsFtnEdnBkmField(rFmtFld, nBkmNo) )
{
- const SwFtnIdxs& rFtnIdxs = pDoc->GetFtnIdxs();
+ SwBookmark& rBkMrk = pDoc->GetBookmark( nBkmNo );
- const USHORT nFtnCnt = rFtnIdxs.Count();
+ const SwPosition& rBkMrkPos = rBkMrk.GetPos();
- for(USHORT n = 0; n < nFtnCnt; ++n )
+ SwTxtNode* pTxt = rBkMrkPos.nNode.GetNode().GetTxtNode();
+ if( pTxt && rBkMrkPos.nContent.GetIndex() )
{
- SwTxtFtn* pFtn = rFtnIdxs[ n ];
- const SwNodeIndex* pSttIdx =
- ((SwTxtFtn*)pFtn)->GetStartNode();
- if( pSttIdx &&
- (pSearchNode ==
- pSttIdx->GetNode().GetStartNode()) )
+ SwTxtAttr* pFtn = pTxt->GetTxtAttr(
+ rBkMrkPos.nContent.GetIndex()-1, RES_TXTATR_FTN );
+ if( pFtn )
{
- USHORT nRefNo = pFtn->SetSeqRefNo();
+ USHORT nRefNo = ((SwTxtFtn*)pFtn)->GetSeqRefNo();
((SwGetRefField*)pFld)->SetSeqNo( nRefNo );
+ if( pFtn->GetFtn().IsEndNote() )
+ ((SwGetRefField*)pFld)->SetSubType(REF_ENDNOTE);
}
}
}
- */
}
+
SwNodeIndex aIdx( pEntry->nMkNode, +1 );
SwPaM aPaM( aIdx, pEntry->nMkCntnt );
pDoc->Insert(aPaM, *pEntry->pAttr);
+ MoveAttrs(*aPaM.GetPoint());
}
break;
-/*
- case RES_TXTATR_INETFMT:
- {
- if( rReader.pSBase )
- {
- if( rReader.pSBase->pFldPLCF )
- {
- WW8PLCFx_FLD& rPLCF = *rReader.pSBase->pFldPLCF;
- if( rPLCF.SeekPos( pEntry->nCPStart ) )
- {
- const ULONG nIdxPoint = rPLCF.GetIdx();
- if( rPLCF.SeekPos( pEntry->nCPEnd ) )
- {
- const ULONG nIdxMark = rPLCF.GetIdx();
- if( nIdxPoint == nIdxMark )
- {
- ;
- }
- }
- }
- }
- }
- }
- break;
-*/
- default: SwFltControlStack::SetAttrInDoc(rTmpPos, pEntry);
+ case RES_FLTR_TOX:
+ case RES_FLTR_BOOKMARK:
+ SwFltEndStack::SetAttrInDoc(rTmpPos, pEntry);
+ break;
+ default:
+ ASSERT(0,"EndStck used with non field, not what we want");
+ SwFltEndStack::SetAttrInDoc(rTmpPos, pEntry);
+ break;
}
}
-
-
//-----------------------------------------
// Tabs
//-----------------------------------------
@@ -826,6 +802,7 @@ WW8ReaderSave::WW8ReaderSave( SwWW8ImplReader* pRdr ,WW8_CP nStartCp)
bTableInApo = pRdr->bTableInApo;
bAnl = pRdr->bAnl;
bInHyperlink = pRdr->bInHyperlink;
+ bPgSecBreak = pRdr->bPgSecBreak;
nAktColl = pRdr->nAktColl;
nNoAttrScan = pRdr->pSBase->GetNoAttrScan();
@@ -837,17 +814,10 @@ WW8ReaderSave::WW8ReaderSave( SwWW8ImplReader* pRdr ,WW8_CP nStartCp)
pRdr->pSFlyPara = 0;
pRdr->pTableDesc = 0;
- pOldEndStck = pRdr->pEndStck;
- pRdr->pEndStck = new SwFltEndStack(&pRdr->rDoc, pRdr->nFieldFlags );
-
pOldStck = pRdr->pCtrlStck;
pRdr->pCtrlStck = new SwWW8FltControlStack(&pRdr->rDoc, pRdr->nFieldFlags,
*pRdr);
- pOldFldStck = pRdr->pRefFldStck;
- pRdr->pRefFldStck = new SwWW8FltControlStack(&pRdr->rDoc, pRdr->nFieldFlags,
- *pRdr);
-
// rette die Attributverwaltung: dies ist noetig, da der neu anzulegende
// PLCFx Manager natuerlich auf die gleichen FKPs zugreift, wie der alte
// und deren Start-End-Positionen veraendert...
@@ -879,6 +849,7 @@ void WW8ReaderSave::Restore( SwWW8ImplReader* pRdr )
pRdr->bTableInApo = bTableInApo;
pRdr->bAnl = bAnl;
pRdr->bInHyperlink = bInHyperlink;
+ pRdr->bPgSecBreak = bPgSecBreak;
pRdr->nAktColl = nAktColl;
pRdr->pSBase->SetNoAttrScan( nNoAttrScan );
@@ -887,12 +858,6 @@ void WW8ReaderSave::Restore( SwWW8ImplReader* pRdr )
pRdr->DeleteCtrlStk();
pRdr->pCtrlStck = pOldStck;
- pRdr->DeleteRefFldStk();
- pRdr->pRefFldStck = pOldFldStck;
-
- pRdr->DeleteEndStk();
- pRdr->pEndStck = pOldEndStck;
-
*pRdr->pPaM->GetPoint() = aTmpPos;
delete pRdr->pPlcxMan;
@@ -2009,6 +1974,7 @@ void SwWW8ImplReader::ReadText( long nStartCp, long nTextLen, short nType )
pAktItemSet = 0;
nCharFmt = -1;
bSpec = FALSE;
+ bPgSecBreak = FALSE;
nHdTextHeight = nFtTextHeight = 0;
pPlcxMan = new WW8PLCFMan( pSBase, nType, nStartCp );
@@ -2126,8 +2092,7 @@ SwWW8ImplReader::SwWW8ImplReader( BYTE nVersionPara, SvStorage* pStorage,
pStrm->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
nWantedVersion = nVersionPara;
pCtrlStck = 0;
- pEndStck = 0;
- pRefFldStck = 0;
+ pRefStck = 0;
pFonts = 0;
pSBase = 0;
pPlcxMan = 0;
@@ -2221,14 +2186,10 @@ ULONG SwWW8ImplReader::LoadDoc1( SwPaM& rPaM ,WW8Glossary *pGloss)
pCtrlStck = new SwWW8FltControlStack( &rDoc, nFieldFlags, *this );
/*
- Endestack: haelt z.B. Bookmarks und Variablen solange vor,
- bis er den Befehl zum inserten bekommt.
- */
- pEndStck = new SwFltEndStack( &rDoc, nFieldFlags );
- /*
- fieldstack holds Reference Fields until the very end of file import
+ RefFldStck: Keeps track of bookmarks which may be inserted as
+ variables intstead.
*/
- pRefFldStck = new SwWW8FltControlStack( &rDoc, nFieldFlags, *this );
+ pRefStck = new SwWW8FltRefStack(&rDoc, nFieldFlags);
nPageDescOffset = rDoc.GetPageDescCnt();
@@ -2718,8 +2679,7 @@ ULONG SwWW8ImplReader::LoadDoc1( SwPaM& rPaM ,WW8Glossary *pGloss)
DELETEZ( pWwFib );
DeleteCtrlStk();
DELETEZ(pFontSrcCharSets);
- DeleteEndStk();
- DeleteRefFldStk();
+ DeleteRefStk();
// set NoBallanced flag on last inserted section
if( pNewSection )
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index c3666e8b9180..5a98a791faca 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ww8par.hxx,v $
*
- * $Revision: 1.47 $
+ * $Revision: 1.48 $
*
- * last change: $Author: cmc $ $Date: 2002-01-23 12:32:13 $
+ * last change: $Author: cmc $ $Date: 2002-02-04 09:50:19 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -65,6 +65,9 @@
#ifndef __SGI_STL_VECTOR
#include <vector>
#endif
+#ifndef __SGI_STL_MAP
+#include <map>
+#endif
#ifndef _STRING_HXX //autogen
#include <tools/string.hxx>
#endif
@@ -116,8 +119,6 @@ class SwAttrSet;
class SwNumRule;
class SwFrmFmt;
-class SwFltControlStack;
-class SwFltEndStack;
class SwWW8StyInf;
class WW8Fib;
class WW8PLCFMan;
@@ -316,7 +317,6 @@ public:
nToggleAttrFlags( 0 )
{}
- BOOL IsFtnEdnBkmField(SwFmtFld& rFmtFld, USHORT& nBkmNo);
void NewAttr(const SwPosition& rPos, const SfxPoolItem& rAttr);
void SetAttr(const SwPosition& rPos, USHORT nAttrId=0, BOOL bTstEnde=TRUE,
long nHand=LONG_MAX);
@@ -330,6 +330,36 @@ public:
USHORT GetToggleAttrFlags() const { return nToggleAttrFlags; }
};
+class SwWW8FltRefStack : public SwFltEndStack
+{
+public:
+ SwWW8FltRefStack(SwDoc* pDo, ULONG nFieldFl)
+ : SwFltEndStack( pDo, nFieldFl )
+ {}
+ BOOL IsFtnEdnBkmField(const SwFmtFld& rFmtFld, USHORT& rBkmNo);
+
+ struct ltstr
+ {
+ bool operator()(const String &r1, const String &r2) const
+ {
+ return r1.CompareIgnoreCaseToAscii(r2) == COMPARE_LESS;
+ }
+ };
+
+ //Keep track of variable names created with fields, and the bookmark
+ //mapped to their position, hopefully the same, but very possibly
+ //an additional pseudo bookmark
+ ::std::map<String, String, ltstr> aFieldVarNames;
+protected:
+ SwFltStackEntry *RefToVar(const SwField* pFld,SwFltStackEntry *pEntry);
+ virtual void SetAttrInDoc(const SwPosition& rTmpPos,
+ SwFltStackEntry* pEntry);
+private:
+ //No copying
+ SwWW8FltRefStack(const SwWW8FltRefStack&);
+ SwWW8FltRefStack& operator=(const SwWW8FltRefStack&);
+};
+
//-----------------------------------------
// Redlining Authors
//-----------------------------------------
@@ -361,8 +391,6 @@ class WW8ReaderSave
{
SwPosition aTmpPos;
SwWW8FltControlStack* pOldStck;
- SwWW8FltControlStack* pOldFldStck;
- SwFltEndStack* pOldEndStck;
WW8PLCFxSaveAll aPLCFxSave;
WW8PLCFMan* pOldPlcxMan;
@@ -382,6 +410,7 @@ class WW8ReaderSave
BOOL bTableInApo : 1;
BOOL bAnl : 1;
BOOL bInHyperlink : 1;
+ BOOL bPgSecBreak : 1;
public:
WW8ReaderSave( SwWW8ImplReader* pRdr, WW8_CP nStart=-1 );
void Restore( SwWW8ImplReader* pRdr );
@@ -542,10 +571,14 @@ friend class WW8FormulaControl;
SwPaM* pPaM;
SwWW8FltControlStack* pCtrlStck; // Stack fuer die Attribute
- SwFltEndStack* pEndStck; // End-Stack fuer die Attribute
- SwWW8FltControlStack* pRefFldStck; // for Reference Fields
-// BYTE* pCharBuf; // Puffer fuer nackten Text
+ /*
+ This stack is for fields whose true conversion cannot be determined until
+ the end of the document, it is the same stack for headers/footers/main
+ text/textboxes/tables etc...
+ */
+ SwWW8FltRefStack *pRefStck;
+
SwMSConvertControls *pFormImpl; // Control-Implementierung
SwFlyFrmFmt* pFlyFmtOfJustInsertedGraphic;
@@ -768,8 +801,7 @@ friend class WW8FormulaControl;
void DeleteStk(SwFltControlStack* prStck);
void DeleteCtrlStk() { DeleteStk( pCtrlStck ); pCtrlStck = 0; }
- void DeleteEndStk() { DeleteStk( pEndStck ); pEndStck = 0; }
- void DeleteRefFldStk() { DeleteStk( pRefFldStck); pRefFldStck = 0; }
+ void DeleteRefStk() { DeleteStk( pRefStck ); pRefStck = 0; }
BOOL ReadChar( long nPosCp, long nCpOfs );
BOOL ReadPlainChars( long& rPos, long nEnd, long nCpOfs );
@@ -1097,14 +1129,15 @@ public: // eigentlich private, geht aber leider nur public
void Read_LFOPosition( USHORT nId, const sal_uInt8* pData, short nLen);
BOOL SetTxtFmtCollAndListLevel(const SwPaM& rRg, SwWW8StyInf& rStyleInfo);
- // FastSave-Attribute
-
void Read_StyleCode(USHORT, const BYTE* pData, short nLen);
void Read_Majority(USHORT, const BYTE* , short );
void Read_DoubleLine_Rotate( USHORT, const BYTE* pDATA, short nLen);
- // Felder
+ long MapBookmarkVariables(const WW8FieldDesc* pF,String &rOrigName,
+ const String &rData);
+ const String &GetMappedBookmark(String &rOrigName);
+ // Felder
eF_ResT Read_F_Nul(WW8FieldDesc*, String& );
eF_ResT Read_F_Input(WW8FieldDesc*, String& rStr);
eF_ResT Read_F_InputVar(WW8FieldDesc*, String& rStr);
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
index 732703951bbc..9ba915ccd1aa 100644
--- a/sw/source/filter/ww8/ww8par5.cxx
+++ b/sw/source/filter/ww8/ww8par5.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ww8par5.cxx,v $
*
- * $Revision: 1.36 $
+ * $Revision: 1.37 $
*
- * last change: $Author: cmc $ $Date: 2002-01-23 12:32:14 $
+ * last change: $Author: cmc $ $Date: 2002-02-04 09:50:19 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -407,7 +407,7 @@ long SwWW8ImplReader::Read_Book(WW8PLCFManResult*, BOOL bStartAttr)
if( !bStartAttr )
{
ASSERT( bStartAttr, "Read_Book::Nanu ?" );
- pEndStck->SetAttr( *pPaM->GetPoint(), RES_FLTR_BOOKMARK );
+ pRefStck->SetAttr( *pPaM->GetPoint(), RES_FLTR_BOOKMARK );
return 0;
}
// muesste auch ueber pRes.nCo2OrIdx gehen
@@ -418,17 +418,17 @@ long SwWW8ImplReader::Read_Book(WW8PLCFManResult*, BOOL bStartAttr)
return 0;
}
+ eBookStatus eB = pB->GetStatus();
+ if (eB & BOOK_IGNORE)
+ return 0; // Bookmark zu ignorieren
+
if (pB->GetIsEnd())
{
- pEndStck->SetAttr( *pPaM->GetPoint(), RES_FLTR_BOOKMARK, TRUE,
+ pRefStck->SetAttr( *pPaM->GetPoint(), RES_FLTR_BOOKMARK, TRUE,
pB->GetHandle() );
return 0;
}
- eBookStatus eB = pB->GetStatus();
- if ( (eB & BOOK_IGNORE) != 0 )
- return 0; // Bookmark zu ignorieren
-
//"_Toc*" and "_Hlt*" are unnecessary
const String* pName = pB->GetName();
if( !pName || pName->EqualsIgnoreCaseAscii( "_Toc", 0, 4 )
@@ -503,8 +503,8 @@ long SwWW8ImplReader::Read_Book(WW8PLCFManResult*, BOOL bStartAttr)
if( aVal.Len() > (MAX_FIELDLEN - 4))
aVal.Erase( MAX_FIELDLEN - 4 );
}
- pEndStck->NewAttr( *pPaM->GetPoint(), SwFltBookmark( *pName, aVal,
- pB->GetHandle(), ( eB & BOOK_ONLY_REF ) != 0 ) );
+ pRefStck->NewAttr( *pPaM->GetPoint(), SwFltBookmark( *pName, aVal,
+ pB->GetHandle(), 0 ) );
return 0;
}
@@ -972,7 +972,7 @@ void SwWW8ImplReader::InsertTagField( const USHORT nId, const String& rTagText )
SwSetExpFieldType( &rDoc, aName, GSE_STRING ) );
SwSetExpField aFld( (SwSetExpFieldType*)pFT, rTagText ); // SUB_INVISIBLE
USHORT nSubType = ( SwFltGetFlag( nFieldFlags, SwFltControlStack::TAGS_VISIBLE ) ) ? 0 : SUB_INVISIBLE;
- aFld.SetSubType(nSubType);
+ aFld.SetSubType(nSubType|GSE_STRING);
rDoc.Insert( *pPaM, SwFmtFld( aFld ) );
}
@@ -1070,10 +1070,129 @@ String SwWW8ImplReader::GetFieldResult( WW8FieldDesc* pF )
return sRes;
}
-// "FRAGE"
+/*
+Bookmarks can be set with fields SET and ASK, and they can be referenced with
+REF. When set, they behave like variables in writer, otherwise they behave
+like normal bookmarks. We can check whether we should use a show variable
+instead of a normal bookmark ref by converting to "show variable" at the end
+of the document those refs which look for the content of a bookmark but whose
+bookmarks were set with SET or ASK. (See SwWW8FltRefStack)
+
+The other piece of the puzzle is that refs that point to the "location" of the
+bookmark will in word actually point to the last location where the bookmark
+was set with SET or ASK, not the actual bookmark. This is only noticable when
+a document sets the bookmark more than once. This is because word places the
+true bookmark at the location of the last set, but the refs will display the
+position of the first set before the ref.
+
+So what we will do is
+
+1) keep a list of all bookmarks that were set, any bookmark names mentioned
+here that are refed by content will be converted to show variables.
+
+2) create pseudo bookmarks for every position that a bookmark is set with SET
+or ASK but has no existing bookmark. We can then keep a map from the original
+bookmark name to the new one. As we parse the document new pseudo names will
+replace the older ones, so the map always contains the bookmark of the
+location that msword itself would use.
+
+3) word's bookmarks are case insensitive, writers are not. So we need to
+map case different versions together, regardless of whether they are
+variables or not.
+
+4) when a reference is (first) SET or ASK, the bookmark associated with it
+is placed around the 0x14 0x15 result part of the field. We will fiddle
+the placement to be the writer equivalent of directly before and after
+the field, which gives the same effect and meaning, to do so we must
+get any bookmarks in the field range, and begin them immediately before
+the set/ask field, and end them directly afterwards. MapBookmarkVariables
+returns an identifier of the bookmark attribute to close after inserting
+the appropiate set/ask field.
+*/
+long SwWW8ImplReader::MapBookmarkVariables(const WW8FieldDesc* pF,
+ String &rOrigName, const String &rData)
+{
+ ASSERT(pPlcxMan,"No pPlcxMan");
+ long nNo;
+ /*
+ If there was no bookmark associated with this set field, then we create a
+ pseudo one and insert it in the document.
+ */
+ USHORT nIndex;
+ pPlcxMan->GetBook()->MapName(rOrigName);
+ String sName = pPlcxMan->GetBook()->GetBookmark(
+ pF->nSCode, pF->nSCode + pF->nLen, nIndex);
+ if (sName.Len())
+ {
+ pPlcxMan->GetBook()->SetStatus(nIndex,BOOK_IGNORE);
+ nNo = nIndex;
+ }
+ else
+ {
+ sName = String::CreateFromAscii("WWSetBkmk");
+ nNo = pRefStck->aFieldVarNames.size()+1;
+ sName += String::CreateFromInt32(nNo);
+ nNo += pPlcxMan->GetBook()->GetIMax();
+ }
+ pRefStck->NewAttr(*pPaM->GetPoint(),SwFltBookmark(sName,rData,nNo,0));
+ pRefStck->aFieldVarNames[rOrigName] = sName;
+ return nNo;
+}
+
+/*
+Word can set a bookmark with set or with ask, such a bookmark is equivalent to
+our variables, but until the end of a document we cannot be sure if a bookmark
+is a variable or not, at the end we will have a list of reference names which
+were set or asked, all bookmarks using the content of those bookmarks are
+converted to show variables, those that reference the position of the field
+can be left as references, because a bookmark is also inserted at the position
+of a set or ask field, either by word, or in some special cases by the import
+filter itself.
+*/
+SwFltStackEntry *SwWW8FltRefStack::RefToVar(const SwField* pFld,
+ SwFltStackEntry *pEntry)
+{
+ SwFltStackEntry *pRet=0;
+ if (RES_GETREFFLD == pFld->Which())
+ {
+ //Get the name of the ref field, and see if actually a variable
+ const String &rName = pFld->GetPar1();
+ ::std::map<String,String,SwWW8FltRefStack::ltstr>::const_iterator
+ aResult = aFieldVarNames.find(rName);
+
+ if (aResult != aFieldVarNames.end())
+ {
+ SwGetExpField aFld( (SwGetExpFieldType*)
+ pDoc->GetSysFldType(RES_GETEXPFLD), rName, GSE_STRING, 0);
+ delete pEntry->pAttr;
+ SwFmtFld aTmp(aFld);
+ pEntry->pAttr = aTmp.Clone();
+ pRet = pEntry;
+ }
+ }
+ return pRet;
+}
+
+const String &SwWW8ImplReader::GetMappedBookmark(String &rOrigName)
+{
+ ASSERT(pPlcxMan,"no pPlcxMan");
+ pPlcxMan->GetBook()->MapName(rOrigName);
+
+ //See if there has been a variable set with this name, if so get
+ //the pseudo bookmark name that was set with it.
+ ::std::map<String,String,SwWW8FltRefStack::ltstr>::const_iterator aResult =
+ pRefStck->aFieldVarNames.find(rOrigName);
+
+ const String &rBkmName = (aResult == pRefStck->aFieldVarNames.end())
+ ? rOrigName : (*aResult).second;
+
+ return rBkmName;
+}
+
+// "ASK"
eF_ResT SwWW8ImplReader::Read_F_InputVar( WW8FieldDesc* pF, String& rStr )
{
- String aVar;
+ String sOrigName;
String aQ;
String aDef;
long nRet;
@@ -1083,39 +1202,36 @@ eF_ResT SwWW8ImplReader::Read_F_InputVar( WW8FieldDesc* pF, String& rStr )
switch( nRet )
{
case -2:
- if( !aVar.Len() )
- aVar = aReadParam.GetResult();
+ if( !sOrigName.Len() )
+ sOrigName = aReadParam.GetResult();
else if( !aQ.Len() )
aQ = aReadParam.GetResult();
break;
case 'd':
case 'D':
- {
- xub_StrLen n = aReadParam.GoToTokenParam();
- if( STRING_NOTFOUND != n )
- aDef = aReadParam.GetResult();
- }
+ if (STRING_NOTFOUND != aReadParam.GoToTokenParam())
+ aDef = aReadParam.GetResult();
break;
}
}
- if( !aVar.Len() )
+
+ if( !sOrigName.Len() )
return FLD_TAGIGN; // macht ohne Textmarke keinen Sinn
if( !aDef.Len() )
aDef = GetFieldResult( pF );
+ long nNo = MapBookmarkVariables(pF,sOrigName,aDef);
-
- SwFieldType* pFT = rDoc.InsertFldType( SwSetExpFieldType( &rDoc, aVar, GSE_STRING ) );
- SwSetExpField aFld( (SwSetExpFieldType*)pFT, aVar );
- aFld.SetSubType(SUB_INVISIBLE);
+ SwSetExpFieldType* pFT = (SwSetExpFieldType*)rDoc.InsertFldType(
+ SwSetExpFieldType(&rDoc, sOrigName, GSE_STRING));
+ SwSetExpField aFld( pFT, aDef );
+ aFld.SetSubType(SUB_INVISIBLE|GSE_STRING);
aFld.SetInputFlag( TRUE );
aFld.SetPromptText( aQ );
- aFld.SetPar2( aDef );
- pPlcxMan->GetBook()->SetStatus( pF->nSCode, pF->nSCode + pF->nLen,
- aVar, BOOK_ONLY_REF );
- rDoc.Insert( *pPaM, SwFmtFld( aFld ) );
+ rDoc.Insert( *pPaM, SwFmtFld( aFld ) );
+ pRefStck->SetAttr(*pPaM->GetPoint(), RES_FLTR_BOOKMARK, TRUE, nNo);
return FLD_OK;
}
@@ -1194,8 +1310,7 @@ eF_ResT SwWW8ImplReader::Read_F_Seq( WW8FieldDesc*, String& rStr )
break;
}
}
- if( !aSequenceName.Len()
- && !aBook.Len() )
+ if (!aSequenceName.Len() && !aBook.Len())
return FLD_TAGIGN;
SwSetExpFieldType* pFT = (SwSetExpFieldType*)rDoc.InsertFldType(
@@ -1593,7 +1708,6 @@ eF_ResT SwWW8ImplReader::Read_F_Symbol( WW8FieldDesc*, String& rStr )
return FLD_OK;
}
-
// "EINBETTEN"
eF_ResT SwWW8ImplReader::Read_F_Embedd( WW8FieldDesc*, String& rStr )
{
@@ -1622,11 +1736,11 @@ eF_ResT SwWW8ImplReader::Read_F_Embedd( WW8FieldDesc*, String& rStr )
}
-// "BESTIMMEN"
+// "SET"
eF_ResT SwWW8ImplReader::Read_F_Set( WW8FieldDesc* pF, String& rStr )
{
- String aName;
- String aVal;
+ String sOrigName;
+ String sVal;
long nRet;
_ReadFieldParams aReadParam( rStr );
while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
@@ -1634,28 +1748,32 @@ eF_ResT SwWW8ImplReader::Read_F_Set( WW8FieldDesc* pF, String& rStr )
switch( nRet )
{
case -2:
- if( !aName.Len() )
- aName = aReadParam.GetResult();
- else if( !aVal.Len() )
- aVal = aReadParam.GetResult();
+ if( !sOrigName.Len() )
+ sOrigName = aReadParam.GetResult();
+ else if( !sVal.Len() )
+ sVal = aReadParam.GetResult();
break;
}
}
- SwFieldType* pFT = rDoc.InsertFldType(
- SwSetExpFieldType( &rDoc, aName, GSE_STRING ) );
- SwSetExpField aFld( (SwSetExpFieldType*)pFT, aVal );
- aFld.SetSubType(SUB_INVISIBLE);
- pPlcxMan->GetBook()->SetStatus( pF->nSCode, pF->nSCode + pF->nLen,
- aName, BOOK_IGNORE );
+
+ long nNo = MapBookmarkVariables(pF,sOrigName,sVal);
+
+ SwFieldType* pFT = rDoc.InsertFldType( SwSetExpFieldType( &rDoc, sOrigName,
+ GSE_STRING ) );
+ SwSetExpField aFld( (SwSetExpFieldType*)pFT, sVal );
+ aFld.SetSubType(SUB_INVISIBLE|GSE_STRING);
+
rDoc.Insert( *pPaM, SwFmtFld( aFld ) );
+
+ pRefStck->SetAttr(*pPaM->GetPoint(), RES_FLTR_BOOKMARK, TRUE, nNo);
+
return FLD_OK;
}
// "REF"
eF_ResT SwWW8ImplReader::Read_F_Ref( WW8FieldDesc*, String& rStr )
{ // Reference - Field
- String aBkmName;
- REFERENCEMARK eMark = REF_CONTENT;
+ String sOrigBkmName;
BOOL bChapterNr = FALSE;
BOOL bAboveBelow = FALSE;
@@ -1666,8 +1784,8 @@ eF_ResT SwWW8ImplReader::Read_F_Ref( WW8FieldDesc*, String& rStr )
switch( nRet )
{
case -2:
- if( !aBkmName.Len() ) // get name of bookmark
- aBkmName = aReadParam.GetResult();
+ if( !sOrigBkmName.Len() ) // get name of bookmark
+ sOrigBkmName = aReadParam.GetResult();
break;
case 'n':
case 'r':
@@ -1689,23 +1807,46 @@ eF_ResT SwWW8ImplReader::Read_F_Ref( WW8FieldDesc*, String& rStr )
if ( SwFltGetFlag( nFieldFlags, SwFltControlStack::HYPO ) )
{
SwGetExpField aFld( (SwGetExpFieldType*)
- rDoc.GetSysFldType( RES_GETEXPFLD ),aBkmName, GSE_STRING, VVF_SYS );
+ rDoc.GetSysFldType( RES_GETEXPFLD ),sOrigBkmName, GSE_STRING,
+ VVF_SYS );
rDoc.Insert( *pPaM, SwFmtFld( aFld ) );
- pEndStck->SetBookRef( aBkmName, FALSE );
+ pRefStck->SetBookRef( sOrigBkmName, FALSE );
}
else
{
- if (bChapterNr || bAboveBelow)
- eMark = REF_CHAPTER;
- SwGetRefField aFld( (SwGetRefFieldType*)
- rDoc.GetSysFldType( RES_GETREFFLD ),aBkmName,REF_BOOKMARK,0,eMark);
- rDoc.Insert( *pPaM, SwFmtFld( aFld ) );
+ const String &rBkmName = GetMappedBookmark(sOrigBkmName);
+
+ if (!bAboveBelow || bChapterNr)
+ {
+ if (bChapterNr)
+ {
+ SwGetRefField aFld(
+ (SwGetRefFieldType*)rDoc.GetSysFldType( RES_GETREFFLD ),
+ rBkmName,REF_BOOKMARK,0,REF_CHAPTER);
+ rDoc.Insert( *pPaM, SwFmtFld( aFld ) );
+ }
+ else
+ {
+ /*
+ If we are just inserting the contents of the bookmark, then it
+ is possible that the bookmark is actually a variable, so we
+ must store it until the end of the document to see if it was,
+ in which case we'll turn it into a show variable
+ */
+ SwGetRefField aFld(
+ (SwGetRefFieldType*)rDoc.GetSysFldType( RES_GETREFFLD ),
+ sOrigBkmName,REF_BOOKMARK,0,REF_CONTENT);
+ pRefStck->NewAttr( *pPaM->GetPoint(), SwFmtFld(aFld) );
+ pRefStck->SetAttr( *pPaM->GetPoint(), RES_TXTATR_FIELD);
+ }
+ }
+
if( bAboveBelow )
{
- SwGetRefField aFld2( (SwGetRefFieldType*)
- rDoc.GetSysFldType( RES_GETREFFLD ), aBkmName, REF_BOOKMARK, 0,
+ SwGetRefField aFld( (SwGetRefFieldType*)
+ rDoc.GetSysFldType( RES_GETREFFLD ), rBkmName, REF_BOOKMARK, 0,
REF_UPDOWN );
- rDoc.Insert( *pPaM, SwFmtFld( aFld2 ) );
+ rDoc.Insert(*pPaM, SwFmtFld(aFld));
}
}
return FLD_OK;
@@ -1747,7 +1888,7 @@ eF_ResT SwWW8ImplReader::Read_F_NoteReference( WW8FieldDesc*, String& rStr )
SwGetExpField aFld( (SwGetExpFieldType*)
rDoc.GetSysFldType( RES_GETEXPFLD ), aBkmName, GSE_STRING, VVF_SYS);
rDoc.Insert( *pPaM, SwFmtFld( aFld ) );
- pEndStck->SetBookRef( aBkmName, FALSE );
+ pRefStck->SetBookRef( aBkmName, FALSE );
}
else
{ // set Sequence No of corresponding Foot-/Endnote to Zero
@@ -1755,13 +1896,13 @@ eF_ResT SwWW8ImplReader::Read_F_NoteReference( WW8FieldDesc*, String& rStr )
SwGetRefField aFld( (SwGetRefFieldType*)
rDoc.GetSysFldType( RES_GETREFFLD ), aBkmName, REF_FOOTNOTE, 0,
REF_ONLYNUMBER );
- pRefFldStck->NewAttr(*pPaM->GetPoint(), SwFmtFld( aFld ));
+ pRefStck->NewAttr(*pPaM->GetPoint(), SwFmtFld( aFld ));
if( bAboveBelow )
{
SwGetRefField aFld2( (SwGetRefFieldType*)
rDoc.GetSysFldType( RES_GETREFFLD ),aBkmName, REF_FOOTNOTE, 0,
REF_UPDOWN );
- pRefFldStck->NewAttr(*pPaM->GetPoint(), SwFmtFld( aFld2 ));
+ pRefStck->NewAttr(*pPaM->GetPoint(), SwFmtFld( aFld2 ));
}
}
return FLD_OK;
@@ -1770,7 +1911,7 @@ eF_ResT SwWW8ImplReader::Read_F_NoteReference( WW8FieldDesc*, String& rStr )
// "SEITENREF"
eF_ResT SwWW8ImplReader::Read_F_PgRef( WW8FieldDesc*, String& rStr )
{
- String aName;
+ String sOrigName;
long nRet;
_ReadFieldParams aReadParam( rStr );
while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
@@ -1778,27 +1919,27 @@ eF_ResT SwWW8ImplReader::Read_F_PgRef( WW8FieldDesc*, String& rStr )
switch( nRet )
{
case -2:
- if( !aName.Len() )
- aName = aReadParam.GetResult();
+ if( !sOrigName.Len() )
+ sOrigName = aReadParam.GetResult();
break;
}
}
if ( SwFltGetFlag( nFieldFlags, SwFltControlStack::HYPO ) )
{
SwGetRefField aFld( (SwGetRefFieldType*)
- rDoc.GetSysFldType( RES_GETREFFLD ), aName, 0, 0,
+ rDoc.GetSysFldType( RES_GETREFFLD ), sOrigName, 0, 0,
REF_PAGE );
rDoc.Insert( *pPaM, SwFmtFld( aFld ) );
- pEndStck->SetBookRef( aName, TRUE );
+ pRefStck->SetBookRef( sOrigName, TRUE );
}
else
{
- SwGetRefField aFld( (SwGetRefFieldType*)
- rDoc.GetSysFldType( RES_GETREFFLD ),
- aName,
- REF_BOOKMARK,
- 0,
- REF_PAGE );
+ const String &rName = GetMappedBookmark(sOrigName);
+
+ SwGetRefField aFld(
+ (SwGetRefFieldType*)rDoc.GetSysFldType( RES_GETREFFLD ), rName,
+ REF_BOOKMARK, 0, REF_PAGE );
+
rDoc.Insert( *pPaM, SwFmtFld( aFld ) );
}
return FLD_OK;
@@ -1942,14 +2083,7 @@ eF_ResT SwWW8ImplReader::Read_F_IncludeText( WW8FieldDesc* pF, String& rStr )
aPara += aBook;
}
String aStr(CREATE_CONST_ASC( "WW" ));
-#if 0
- SwSection* pSection = new SwSection( FILE_LINK_SECTION,
- rDoc.GetUniqueSectionName( &aStr ) );
- pSection->SetLinkFileName( aPara );
- pSection->SetProtect( TRUE );
- NewAttr( SwFltSection( pSection ) );
- pEndStck->SetAttr( *pPaM->GetPoint(), RES_FLTR_SECTION );
-#else
+
/*
##509##
What we will do is insert a section to be linked to a file, but just in
@@ -1974,7 +2108,7 @@ eF_ResT SwWW8ImplReader::Read_F_IncludeText( WW8FieldDesc* pF, String& rStr )
ReadText(pF->nSRes, pF->nLRes, pPlcxMan->GetManType());
aSave.Restore( this );
-#endif
+
return FLD_OK;
}
@@ -2772,12 +2906,12 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, String& rStr )
}
// Setze Anfang in Stack
- pEndStck->NewAttr( *pPos, aFltTOX );
+ pRefStck->NewAttr( *pPos, aFltTOX );
if( 1 < nIndexCols )
bDontCreateSep = TRUE;
// Setze Ende in Stack
- pEndStck->SetAttr( *pPos, RES_FLTR_TOX );
+ pRefStck->SetAttr( *pPos, RES_FLTR_TOX );
return FLD_OK;
}
@@ -2788,31 +2922,8 @@ eF_ResT SwWW8ImplReader::Read_F_Hyperlink( WW8FieldDesc* pF, String& rStr )
String sURL, sTarget, sMark;
BOOL bDataImport=FALSE;
- // JP 02.12.98: es gibt Hyperlink-Felder, die am Ende eine '\x01' stehen
- // haben. Die wollen wir aber nicht beachten
- /*
- if( pStr[ pF->nLCode - 1 ] < ' ' )
- pStr[ pF->nLCode - 1 ] = 0;
- */
-
-
-
-/*
- //caolan
- if( rStr.GetChar( pF->nLCode - 1 ) < ' ' )
- {
-#if DEBUG
- if( 0x01 == rStr.GetChar( pF->nLCode-1 ) )
- bDataImport=ImportURL( sURL, sMark, pF->nSCode + pF->nLCode-1 );
-#endif
- rStr.SetChar( pF->nLCode - 1, 0 );
- }
-*/
-
rStr.EraseTrailingChars( 1 );
-
-
if (!bDataImport)
{
long nRet;
@@ -2896,16 +3007,16 @@ eF_ResT SwWW8ImplReader::Read_F_Hyperlink( WW8FieldDesc* pF, String& rStr )
pFmtOfJustInsertedGraphicOrOLE->SetAttr( aURL );
pFmtOfJustInsertedGraphicOrOLE = 0;
}
- eRet = FLD_OK;
}
else
{
SwFmtINetFmt aURL( sURL, sTarget );
- pRefFldStck->NewAttr( *pPaM->GetPoint(), aURL );
+ pCtrlStck->NewAttr( *pPaM->GetPoint(), aURL );
// das Ende als "relative" Pos auf den Stack setzen
pPaM->SetMark();
pPaM->GetMark()->nContent += sDef.Len();
+
/*#83156#
We need to know the length of this content field here, but we
do not truly know the length of the final result as we may
@@ -2923,7 +3034,8 @@ eF_ResT SwWW8ImplReader::Read_F_Hyperlink( WW8FieldDesc* pF, String& rStr )
for(xub_StrLen i=sDef.Len();i>0;i--)
if (sDef.GetChar(i-1) < 0x20)
pPaM->GetMark()->nContent--;
- pRefFldStck->SetAttr( *pPaM->GetMark(), RES_TXTATR_INETFMT, FALSE );
+
+ pCtrlStck->SetAttr( *pPaM->GetMark(), RES_TXTATR_INETFMT, FALSE );
pPaM->DeleteMark();
eRet = FLD_TEXT;
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index e536312e3da3..bef58db802a0 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ww8par6.cxx,v $
*
- * $Revision: 1.58 $
+ * $Revision: 1.59 $
*
- * last change: $Author: cmc $ $Date: 2002-01-18 10:47:31 $
+ * last change: $Author: cmc $ $Date: 2002-02-04 09:50:19 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -280,11 +280,6 @@
#include <ww8par2.hxx> // class WW8RStyle, class WwAnchorPara
#endif
-
-#define NEW_MINHDSIZ // Definieren zum Ausnutzen der minimalen
- // Header- und Footerhoehe
-
-
static ColorData __FAR_DATA eSwWW8ColA[] = {
COL_AUTO, COL_BLACK, COL_LIGHTBLUE,
COL_LIGHTCYAN, COL_LIGHTGREEN, COL_LIGHTMAGENTA, COL_LIGHTRED,
@@ -565,10 +560,42 @@ void SwWW8ImplReader::SetPage1( SwPageDesc* pInPageDesc, SwFrmFmt &rFmt,
short nWWRi = ReadULSprm( pSep, pIds[4], nRig[nLIdx] );
short nWWGu = ReadULSprm( pSep, pIds[5], 0 );
- nWWLe += nWWGu;
+ /*
+ 0x322A is set if the gutter is on the right, the gutter is otherwise
+ placed on the left unless the global dop options are to put it on top,
+ that case is handled in GetPageULData, unfortunately when we are "2 pages
+ in 1" then the gutter is alternated between the top of odd pages and bottom
+ of even pages, which we can't do, so ignore it in that case
+ */
+ if (!pWDop->doptypography.f2on1)
+ {
+ if ((!bVer67) && ReadULSprm( pSep, 0x322A, 0 ))
+ nWWRi += nWWGu;
+ else if (!pWDop->iGutterPos)
+ nWWLe += nWWGu;
+ }
- // Left / Right
- rFmt.SetAttr( SvxLRSpaceItem( nWWLe, nWWRi ) );
+ // Left / Right
+ if ((aSz.GetWidth() - nWWLe - nWWRi) < MINLAY)
+ {
+ /*
+ There are some label templates which are "broken", they specify
+ margins which make no sense e.g. Left 16.10cm, Right 16.10cm. So the
+ space left between the margins is less than 0 In word the left margin
+ is honoured and if the right margin would be past the left margin is
+ left at the left margin position.
+
+ Now this will work fine for importing, layout and exporting, *but* the
+ page layout dialog has a hardcoded minimum page width of 0.5cm so it
+ will report a different value than what is actually being used. i.e.
+ it will add up the values to give a wider page than is actually being
+ used.
+ */
+ nWWRi = aSz.GetWidth()-nWWLe-MINLAY;
+ }
+
+ SvxLRSpaceItem aTemp( nWWLe, nWWRi );
+ rFmt.SetAttr( aTemp );
nPgLeft = nWWLe;
nPgRight = nWWRi;
@@ -580,22 +607,17 @@ void SwWW8ImplReader::SetPage1( SwPageDesc* pInPageDesc, SwFrmFmt &rFmt,
}
}
-
-
-
struct WW8ULSpaceData
{
BOOL bHasHeader, bHasFooter;
short nSwHLo, nHdUL,
nSwFUp, nFtUL,
nSwUp, nSwLo;
- WW8ULSpaceData(): bHasHeader( FALSE ), bHasFooter( FALSE ){}
+ WW8ULSpaceData() : bHasHeader( FALSE ), bHasFooter( FALSE ) {}
};
-void SwWW8ImplReader::GetPageULData( const WW8PLCFx_SEPX* pSep,
- USHORT nLIdx,
- BOOL bFirst,
- WW8ULSpaceData& rData )
+void SwWW8ImplReader::GetPageULData( const WW8PLCFx_SEPX* pSep, USHORT nLIdx,
+ BOOL bFirst, WW8ULSpaceData& rData )
{
if( nIniFlags & WW8FL_NO_LRUL ) // abgeschaltet
return;
@@ -626,6 +648,19 @@ void SwWW8ImplReader::GetPageULData( const WW8PLCFx_SEPX* pSep,
short nWWHTop = ReadULSprm( pSep, pIds[2], MM_125 );
short nWWFBot = ReadULSprm( pSep, pIds[3], MM_125 );
+ /*
+ If there is gutter in 97+ and the dop says put it on top then get the
+ gutter distance and set it to the top margin. When we are "two pages
+ in one" the gutter is put at the top of odd pages, and bottom of
+ even pages, something we cannot do. So we will put it on top of all
+ pages, that way the pages are at least the right size.
+ */
+ if ( pWDop->doptypography.f2on1 ||
+ (!bVer67 && pWDop->iGutterPos && !ReadULSprm( pSep, 0x322A, 0 )))
+ {
+ nWWUp += ReadULSprm( pSep, 0xB025, 0 );
+ }
+
if( bFirst )
rData.bHasHeader = (nCorrIhdt & WW8_HEADER_FIRST )!=0;
else
@@ -635,20 +670,8 @@ void SwWW8ImplReader::GetPageULData( const WW8PLCFx_SEPX* pSep,
{
rData.nSwUp = nWWHTop; // Header -> umrechnen
rData.nSwHLo = nWWUp - nWWHTop;
-#ifdef NEW_MINHDSIZ
if( rData.nSwHLo < MINLAY )
rData.nSwHLo = MINLAY;
-#else // NEW_MINHDSIZ
- if( nIniHdSiz )
- rData.nSwHLo -= (short)nIniHdSiz;
- else if( nHdTextHeight )
- rData.nSwHLo -= (short)nHdTextHeight;
- else
- rData.nSwHLo -= 240;
-
- if( rData.nSwHLo < 0 )
- rData.nSwHLo = 0;
-#endif // NEW_MINHDSIZ
}
else // kein Header -> Up einfach uebernehmen
rData.nSwUp = nWWUp;
@@ -663,10 +686,6 @@ void SwWW8ImplReader::GetPageULData( const WW8PLCFx_SEPX* pSep,
rData.nSwLo = nWWFBot; // Footer -> Umrechnen
rData.nSwFUp = nWWLo - nWWFBot;
-#if 0
- if( rData.nSwFUp < MINLAY )
- rData.nSwFUp = MINLAY;
-#else // 0
if( nIniFtSiz )
rData.nSwFUp -= (short)nIniFtSiz;
else if( nFtTextHeight )
@@ -676,7 +695,6 @@ void SwWW8ImplReader::GetPageULData( const WW8PLCFx_SEPX* pSep,
if( rData.nSwFUp < 0 )
rData.nSwFUp = 0;
-#endif // !0
}
else // kein Footer -> Lo einfach uebernehmen
rData.nSwLo = nWWLo;
@@ -692,35 +710,21 @@ void SwWW8ImplReader::SetPageULSpaceItems( SwFrmFmt &rFmt, WW8ULSpaceData& rData
if( rData.bHasHeader ) // ... und Header-Lower setzen
{
- SwFrmFmt* pHdFmt = (SwFrmFmt*)rFmt.GetHeader().GetHeaderFmt();
- if( pHdFmt )
- {
-#ifdef NEW_MINHDSIZ
-// Kopfzeilenhoehe minimal sezten
+ //Kopfzeilenhoehe minimal sezten
+ if (SwFrmFmt* pHdFmt = (SwFrmFmt*)rFmt.GetHeader().GetHeaderFmt())
pHdFmt->SetAttr( SwFmtFrmSize( ATT_MIN_SIZE, 0, rData.nSwHLo ) );
-#else // NEW_MINHDSIZ
- SvxULSpaceItem aHdUL( pHdFmt->GetULSpace() );
- aHdUL.SetLower( rData.nSwHLo );
- pHdFmt->SetAttr( aHdUL );
-#endif // NEW_MINHDSIZ
- }
}
if( rData.bHasFooter ) // ... und Footer-Upper setzen
{
- SwFrmFmt* pFtFmt = (SwFrmFmt*)rFmt.GetFooter().GetFooterFmt();
- if( pFtFmt )
+ if (SwFrmFmt* pFtFmt = (SwFrmFmt*)rFmt.GetFooter().GetFooterFmt())
{
-#if 0
-// Fusszeilenhoehe minimal sezten
- pFtFmt->SetAttr( SwFmtFrmSize( ATT_MIN_SIZE, 0, rData.nSwFUp ) );
-#else // 0
SvxULSpaceItem aFtUL( pFtFmt->GetULSpace() );
aFtUL.SetUpper( rData.nSwFUp );
pFtFmt->SetAttr( aFtUL );
-#endif // !0
}
}
+
SvxULSpaceItem aUL( rData.nSwUp, rData.nSwLo ); // Page-UL setzen
rFmt.SetAttr( aUL );
}
@@ -1196,8 +1200,8 @@ void SwWW8ImplReader::CreateSep(const long nTxtPos,BOOL bMustHaveBreak)
// sprmSNfcPgn
BYTE nLastNfcPgn = nNfcPgn;
nNfcPgn = ReadBSprm( pSep, (bVer67 ? 147 : 0x300E), 0 );
- if( nNfcPgn > 4 ) nNfcPgn = 0;
-
+ if (nNfcPgn > 4)
+ nNfcPgn = 0;
/*
Pruefen, ob wir uns den neuen Abschnitt schenken koennen, da kein
@@ -2724,7 +2728,6 @@ BOOL SwWW8ImplReader::StartApo( const BYTE* pSprm29, BOOL bNowStyleApo,
WW8DupProperties aDup(rDoc,pCtrlStck);
pCtrlStck->SetAttr( *pPaM->GetPoint(), 0, FALSE );
- pEndStck->SetAttr( *pPaM->GetPoint(), 0, FALSE );
// Setze Pam in den FlyFrame
const SwFmtCntnt& rCntnt = pSFlyPara->pFlyFmt->GetCntnt();
@@ -2792,7 +2795,6 @@ void SwWW8ImplReader::StopApo()
// die aus Flys rausragen
WW8DupProperties aDup(rDoc,pCtrlStck);
pCtrlStck->SetAttr( *pPaM->GetPoint(), 0, FALSE );
- pEndStck->SetAttr( *pPaM->GetPoint(), 0, FALSE );
/*
##582##
@@ -3356,12 +3358,6 @@ void SwWW8ImplReader::Read_TxtColor( USHORT, const BYTE* pData, short nLen )
{
pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_COLOR );
bTxtCol = FALSE;
-#if 0
- //No longer need this with auto color
- if( bCharShdTxtCol || bShdTxtCol )
- // dann muss die wieder eingeschaltet werden!!
- NewAttr( SvxColorItem( Color( COL_WHITE ) ) ); // -> weisse Schrift
-#endif
}
else
{
@@ -3371,7 +3367,7 @@ void SwWW8ImplReader::Read_TxtColor( USHORT, const BYTE* pData, short nLen )
b = 0;
NewAttr( SvxColorItem( Color( eSwWW8ColA[b] ) ) );
- bTxtCol = TRUE; // SHD darf nicht Farbe einschalten
+ bTxtCol = TRUE; // SHD darf nicht Farbe einschalten
if( pAktColl && pStyles )
pStyles->bTxtColChanged = TRUE;
}
@@ -3584,9 +3580,6 @@ void SwWW8ImplReader::Read_FontCode( USHORT nId, const BYTE* pData, short nLen )
}
}
-
-
-
void SwWW8ImplReader::Read_FontSize( USHORT nId, const BYTE* pData, short nLen )
{
switch( nId )
@@ -3663,8 +3656,6 @@ void SwWW8ImplReader::Read_Language( USHORT nId, const BYTE* pData, short nLen )
}
}
-
-
/*
Einschalten des Zeichen-Styles:
*/
@@ -3714,7 +3705,8 @@ void SwWW8ImplReader::Read_CharShadow( USHORT, const BYTE* pData, short nLen )
pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_BACKGROUND );
if( bCharShdTxtCol )
{
- pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_COLOR ); // Zeichenfarbe auch
+ // Zeichenfarbe auch
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_COLOR );
bCharShdTxtCol = FALSE;
}
}
@@ -3725,16 +3717,6 @@ void SwWW8ImplReader::Read_CharShadow( USHORT, const BYTE* pData, short nLen )
SwWW8Shade aSh( bVer67, aSHD );
NewAttr( SvxBrushItem( aSh.aColor, RES_CHRATR_BACKGROUND ));
-
-#if 0
- //Now we have auto color, no longer need this
- // weisse Schrift und nicht ueberattributiert
- if( aSh.bWhiteText && !bTxtCol && !bShdTxtCol )
- {
- NewAttr( SvxColorItem( Color( COL_WHITE ) ) ); // -> weisse Schrift
- bCharShdTxtCol = TRUE;
- }
-#endif
}
}
@@ -3758,16 +3740,6 @@ void SwWW8ImplReader::Read_CharHighlight(USHORT, const BYTE* pData, short nLen)
Color aCol( eSwWW8ColA[b] );
NewAttr( SvxBrushItem( aCol , RES_CHRATR_BACKGROUND ));
-
-#if 0
- //No longer need this with auto color
- // weisse Schrift und nicht ueberattributiert
- if( COL_BLACK == aCol.GetColor() && !bTxtCol && !bShdTxtCol )
- {
- NewAttr( SvxColorItem( Color( COL_WHITE ) ) ); // -> weisse Schrift
- bCharShdTxtCol = TRUE;
- }
-#endif
}
}
@@ -4093,7 +4065,8 @@ void SwWW8ImplReader::Read_LineSpace( USHORT, const BYTE* pData, short nLen )
}
}
-void SwWW8ImplReader::Read_UL( USHORT nId, const BYTE* pData, short nLen ) // Sprm 21, 22
+// Sprm 21, 22
+void SwWW8ImplReader::Read_UL( USHORT nId, const BYTE* pData, short nLen )
{
if( nIniFlags & WW8FL_NO_LRUL )
return;
@@ -4116,7 +4089,9 @@ void SwWW8ImplReader::Read_UL( USHORT nId, const BYTE* pData, short nLen ) // Sp
if( bStyNormal && ( nIniFlags & WW8FL_NO_STD_STY_DYA ) )
return;
- if( nLen < 0 ){ // Ende des Attributes
+ if( nLen < 0 )
+ {
+ // Ende des Attributes
pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_UL_SPACE );
return;
}
@@ -4126,40 +4101,22 @@ void SwWW8ImplReader::Read_UL( USHORT nId, const BYTE* pData, short nLen ) // Sp
SvxULSpaceItem aUL( *(const SvxULSpaceItem*)GetFmtAttr( RES_UL_SPACE ));
- switch( nId ){ // keine Versuche
+ switch( nId )
+ {
//sprmPDyaBefore
case 21:
- case 0xA413: aUL.SetUpper( nPara ); break;
+ case 0xA413:
+ aUL.SetUpper( nPara );
+ break;
//sprmPDyaAfter
case 22:
- case 0xA414: aUL.SetLower( nPara ); break;
- default: return;
+ case 0xA414:
+ aUL.SetLower( nPara );
+ break;
+ default:
+ return;
};
-#if 0
- // nIniFlags stehen in c:\winnt40\soffice.ini[user]
- // siehe wwpar.hxx
- // und SwWW8ImplReader::LoadDoc( SwPaM& rPaM )
- //
- if( nIniFlags & WW8FL_NO_IMPLPASP ){
- switch( nId ){ // keine Versuche
- case 21:
- case 0xA413: aUL.SetUpper( nPara ); break;
- case 22:
- case 0xA414: aUL.SetLower( nPara ); break;
- default: return;
- };
- }else{
- // auf alte Werte addieren wg. implizitem Absatzabstand
- // ( siehe Read_LineSpace() )
- switch( nId ){
- case 21:
- case 0xA413: aUL.SetUpper( aUL.GetUpper() + nPara ); break;
- case 22:
- case 0xA414: aUL.SetLower( aUL.GetLower() + nPara ); break;
- default: return;
- };
- }
-#endif
+
NewAttr( aUL );
}
@@ -4168,7 +4125,8 @@ void SwWW8ImplReader::Read_Justify( USHORT, const BYTE* pData, short nLen )
static SvxAdjust aAdjArr[] = { SVX_ADJUST_LEFT, SVX_ADJUST_CENTER,
SVX_ADJUST_RIGHT, SVX_ADJUST_BLOCK };
- if( nLen < 0 ){
+ if( nLen < 0 )
+ {
pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_PARATR_ADJUST );
return;
}
@@ -4182,12 +4140,18 @@ void SwWW8ImplReader::Read_BoolItem( USHORT nId, const BYTE* pData, short nLen )
{
switch( nId )
{
- case 0x2433: nId = RES_PARATR_FORBIDDEN_RULES; break;
- case 0x2435: nId = RES_PARATR_HANGINGPUNCTUATION; break;
- case 0x2437: nId = RES_PARATR_SCRIPTSPACE; break;
- default:
- ASSERT( !this, "wrong Id" );
- return ;
+ case 0x2433:
+ nId = RES_PARATR_FORBIDDEN_RULES;
+ break;
+ case 0x2435:
+ nId = RES_PARATR_HANGINGPUNCTUATION;
+ break;
+ case 0x2437:
+ nId = RES_PARATR_SCRIPTSPACE;
+ break;
+ default:
+ ASSERT( !this, "wrong Id" );
+ return ;
}
if( nLen < 0 )
@@ -4212,7 +4176,9 @@ void SwWW8ImplReader::Read_Emphasis( USHORT, const BYTE* pData, short nLen )
//there is use it, if there is not fall back to the currently set one.
//Only the cjk language setting seems to matter to word, the western
//one is ignored
- const BYTE *pLang = pPlcxMan ? pPlcxMan->GetChpPLCF()->HasSprm(0x486E) : 0;
+ const BYTE *pLang =
+ pPlcxMan ? pPlcxMan->GetChpPLCF()->HasSprm(0x486E) : 0;
+
if (pLang)
nLang = SVBT16ToShort( pLang );
else
@@ -4298,7 +4264,6 @@ void SwWW8ImplReader::Read_Relief( USHORT nId, const BYTE* pData, short nLen )
}
}
-
SwWW8Shade::SwWW8Shade( BOOL bVer67, const WW8_SHD& rSHD )
{
static ULONG __READONLY_DATA eMSGrayScale[] = {
@@ -4413,34 +4378,31 @@ static ULONG __READONLY_DATA eMSGrayScale[] = {
{
Color aForeColor = Color( nFore );
Color aBackColor = Color( nBack );
- ULONG nRed = aForeColor.GetRed() * nWW8BrushStyle;
- ULONG nGreen = aForeColor.GetGreen() * nWW8BrushStyle;
- ULONG nBlue = aForeColor.GetBlue() * nWW8BrushStyle;
- nRed += (ULONG)(aBackColor.GetRed() *(1000-nWW8BrushStyle));
+ ULONG nRed = aForeColor.GetRed() * nWW8BrushStyle;
+ ULONG nGreen = aForeColor.GetGreen() * nWW8BrushStyle;
+ ULONG nBlue = aForeColor.GetBlue() * nWW8BrushStyle;
+ nRed += (ULONG)(aBackColor.GetRed() *(1000-nWW8BrushStyle));
nGreen += (ULONG)(aBackColor.GetGreen()*(1000-nWW8BrushStyle));
- nBlue += (ULONG)(aBackColor.GetBlue() *(1000-nWW8BrushStyle));
+ nBlue += (ULONG)(aBackColor.GetBlue() *(1000-nWW8BrushStyle));
- aColor.SetColor( RGB_COLORDATA( nRed/1000, nGreen/1000, nBlue/1000 ) );
+ aColor.SetColor( RGB_COLORDATA( nRed/1000, nGreen/1000,
+ nBlue/1000 ) );
}
break;
}
-#if 0
- //Now we have Auto color, no longer need this
- // schwarzer Hintergrund -> weisse Schrift
- bWhiteText = (nFore == COL_BLACK) && ( 800 <= nWW8BrushStyle )
- || (nBack == COL_BLACK) && ( 200 >= nWW8BrushStyle );
-#endif
}
void SwWW8ImplReader::Read_Shade( USHORT, const BYTE* pData, short nLen )
{
if( nLen <= 0 )
- { // Ende des Attributes
+ {
+ // Ende des Attributes
pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_BACKGROUND );
if( bShdTxtCol )
{
- pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_COLOR ); // Zeichenfarbe auch
+ // Zeichenfarbe auch
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_COLOR );
bShdTxtCol = FALSE;
}
}
@@ -4451,15 +4413,6 @@ void SwWW8ImplReader::Read_Shade( USHORT, const BYTE* pData, short nLen )
SwWW8Shade aSh( bVer67, aSHD );
NewAttr( SvxBrushItem( aSh.aColor ) );
-#if 0
- //Now we have Auto Color, no longer need this
- // weisse Schrift und nicht ueberattributiert
- if( aSh.bWhiteText && !bTxtCol )
- {
- NewAttr( SvxColorItem( Color( COL_WHITE ) ) ); // -> weisse Schrift
- bShdTxtCol = TRUE;
- }
-#endif
}
}
@@ -4571,7 +4524,6 @@ void SwWW8ImplReader::Read_WidowControl( USHORT, const BYTE* pData, short nLen )
}
}
-
void SwWW8ImplReader::Read_AlignFont( USHORT, const BYTE* pData, short nLen )
{
if( nLen <= 0 )
@@ -4607,7 +4559,6 @@ void SwWW8ImplReader::Read_AlignFont( USHORT, const BYTE* pData, short nLen )
}
}
-
void SwWW8ImplReader::Read_KeepLines( USHORT, const BYTE* pData, short nLen )
{
if( nLen <= 0 )
@@ -4688,9 +4639,9 @@ typedef long (SwWW8ImplReader:: *FNReadRecordExt)( WW8PLCFManResult*, BOOL );
static FNReadRecordExt aWwSprmTab2[] = {
/* 0 (256) */ &SwWW8ImplReader::Read_Ftn, // FootNote
/* 1 (257) */ &SwWW8ImplReader::Read_Ftn, // EndNote
-/* 2 (258) */ &SwWW8ImplReader::Read_Field, // Feld
-/* 3 (259) */ &SwWW8ImplReader::Read_Book, // Bookmark
-/* 4 (260) */ &SwWW8ImplReader::Read_And // Annotation
+/* 2 (258) */ &SwWW8ImplReader::Read_Field, // Feld
+/* 3 (259) */ &SwWW8ImplReader::Read_Book, // Bookmark
+/* 4 (260) */ &SwWW8ImplReader::Read_And // Annotation
};
long SwWW8ImplReader::ImportExtSprm( WW8PLCFManResult* pRes, BOOL bStart )
@@ -5166,7 +5117,7 @@ SprmReadInfo aSprmReadTab[] = {
0xD227, (FNReadRecord)0, //"sprmSPropRMark" // sep.fPropRMark, sep.ibstPropRMark, sep.dttmPropRMark ;complex (see below);variable length always recorded as 7 bytes;
//0x3228, ? ? ? , "sprmSFBiDi", // ;;;
//0x3229, ? ? ? , "sprmSFFacingCol", // ;;;
-//0x322A, ? ? ? , "sprmSFRTLGutter", // ;;;
+ 0x322A, (FNReadRecord)0, // "sprmSFRTLGutter", //set to 1 if gutter is on the right.
0x702B, (FNReadRecord)0, //"sprmSBrcTop" // sep.brcTop;BRC;long;
0x702C, (FNReadRecord)0, //"sprmSBrcLeft" // sep.brcLeft;BRC;long;
0x702D, (FNReadRecord)0, //"sprmSBrcBottom" // sep.brcBottom;BRC;long;
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index 4d76d56f12d8..14ca8e2c80f6 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ww8scan.cxx,v $
*
- * $Revision: 1.36 $
+ * $Revision: 1.37 $
*
- * last change: $Author: cmc $ $Date: 2002-01-23 12:32:14 $
+ * last change: $Author: cmc $ $Date: 2002-02-04 09:50:19 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -1102,7 +1102,7 @@ private:
public:
UShortStk() : SvShorts( 10, 10 ) {}
~UShortStk() {}
- void Push( USHORT s ) { Insert( (USHORT)s, SvShorts::Count() ); }
+ void Push( USHORT s ) { Insert( s, SvShorts::Count() ); }
inline USHORT Top();
inline USHORT Pop();
USHORT Count() { return SvShorts::Count(); }
@@ -3115,44 +3115,10 @@ long WW8PLCFx_Book::GetLen() const
return nNum;
}
-// IgnoreBook ist dafuer da, bei Feldern mit implizitem WW-Bookmark
-// die Bookmarks zwischen Anfang und Ende des Feldes zu ignorieren,
-// die den angegebenen Namen tragen.
-BOOL WW8PLCFx_Book::SetStatus( WW8_CP nStartRegion, WW8_CP nEndRegion,
- const String& rName, eBookStatus eStat )
+void WW8PLCFx_Book::SetStatus(USHORT nIndex, eBookStatus eStat )
{
- ASSERT( nStartRegion < LONG_MAX && nEndRegion < LONG_MAX,
- "IgnoreBook mit falschen Parametern" );
-
- if( !pBook[0] || !pBook[1] )
- return FALSE;
-
- BOOL bFound = FALSE;
- USHORT i = 0;
- WW8_CP nStartAkt, nEndAkt;
- do
- {
- void* p;
- USHORT nEndIdx;
-
- if( pBook[0]->GetData( i, nStartAkt, p ) && p )
- nEndIdx = SVBT16ToShort( *((SVBT16*)p) );
- else
- {
- ASSERT( !this, "Bookmark-EndIdx nicht lesbar" );
- nEndIdx = (USHORT)i;
- }
- nEndAkt = pBook[1]->GetPos( nEndIdx );
- if ( (nStartAkt >= nStartRegion) && (nEndAkt <= nEndRegion)
- && (rName.Equals( *aBookNames[ i ] )) )
- {
- pStatus[nEndIdx] = (eBookStatus)( pStatus[nEndIdx] | eStat );
- bFound = TRUE;
- }
- i++;
- }
- while( nStartAkt <= nEndRegion && i < pBook[0]->GetIMax() );
- return bFound;
+ ASSERT(nIndex < nIMax, "set status of non existing bookmark!");
+ pStatus[nIndex] = (eBookStatus)( pStatus[nIndex] | eStat );
}
eBookStatus WW8PLCFx_Book::GetStatus() const
@@ -3180,6 +3146,72 @@ long WW8PLCFx_Book::GetHandle() const
}
}
+String WW8PLCFx_Book::GetBookmark(long nStart,long nEnd, USHORT &nIndex)
+{
+ BOOL bFound = FALSE;
+ USHORT i = 0;
+ if( pBook[0] && pBook[1] )
+ {
+ WW8_CP nStartAkt, nEndAkt;
+ do
+ {
+ void* p;
+ USHORT nEndIdx;
+
+ if( pBook[0]->GetData( i, nStartAkt, p ) && p )
+ nEndIdx = SVBT16ToShort( *((SVBT16*)p) );
+ else
+ {
+ ASSERT( !this, "Bookmark-EndIdx nicht lesbar" );
+ nEndIdx = i;
+ }
+
+ nEndAkt = pBook[1]->GetPos( nEndIdx );
+
+ if ((nStartAkt >= nStart) && (nEndAkt <= nEnd))
+ {
+ nIndex = i;
+ bFound=TRUE;
+ break;
+ }
+ ++i;
+ }
+ while (i < pBook[0]->GetIMax());
+ }
+ return bFound ? *aBookNames[i] : aEmptyStr;
+}
+
+BOOL WW8PLCFx_Book::MapName(String& rName)
+{
+ if( !pBook[0] || !pBook[1] )
+ return FALSE;
+
+ BOOL bFound = FALSE;
+ USHORT i = 0;
+ WW8_CP nStartAkt, nEndAkt;
+ do
+ {
+ void* p;
+ USHORT nEndIdx;
+
+ if( pBook[0]->GetData( i, nStartAkt, p ) && p )
+ nEndIdx = SVBT16ToShort( *((SVBT16*)p) );
+ else
+ {
+ ASSERT( !this, "Bookmark-EndIdx nicht lesbar" );
+ nEndIdx = i;
+ }
+ nEndAkt = pBook[1]->GetPos( nEndIdx );
+ if (COMPARE_EQUAL == rName.CompareIgnoreCaseToAscii(*aBookNames[i]))
+ {
+ rName = *aBookNames[i];
+ bFound = TRUE;
+ }
+ ++i;
+ }
+ while (!bFound && i < pBook[0]->GetIMax());
+ return bFound;
+}
//-----------------------------------------
// WW8PLCFMan
//-----------------------------------------
diff --git a/sw/source/filter/ww8/ww8scan.hxx b/sw/source/filter/ww8/ww8scan.hxx
index c9eb97811bdb..a2abfc3baf33 100644
--- a/sw/source/filter/ww8/ww8scan.hxx
+++ b/sw/source/filter/ww8/ww8scan.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ww8scan.hxx,v $
*
- * $Revision: 1.22 $
+ * $Revision: 1.23 $
*
- * last change: $Author: cmc $ $Date: 2002-01-23 12:32:14 $
+ * last change: $Author: cmc $ $Date: 2002-02-04 09:50:19 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -660,8 +660,9 @@ public:
long GetLen() const;
BOOL GetIsEnd() const { return nIsEnd ? TRUE : FALSE; }
long GetHandle() const;
- BOOL SetStatus( WW8_CP nStartRegion, WW8_CP nEndRegion, const String& rName,
- eBookStatus eStat );
+ void SetStatus( USHORT nIndex, eBookStatus eStat );
+ BOOL MapName(String& rName);
+ String GetBookmark(long nStart,long nEnd, USHORT &nIndex);
eBookStatus GetStatus() const;
};