Kaydet (Commit) 274b0636 authored tarafından jp's avatar jp

handle RTF default attributes correct, import of…

handle RTF default attributes correct, import of fontalignment/scriptspace/forbiddenrule/hangingpuctuation items
üst d2cd4d90
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: rtfitem.cxx,v $ * $RCSfile: rtfitem.cxx,v $
* *
* $Revision: 1.7 $ * $Revision: 1.8 $
* *
* last change: $Author: jp $ $Date: 2001-03-27 21:33:42 $ * last change: $Author: jp $ $Date: 2001-05-03 11:49:05 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -111,6 +111,10 @@ ...@@ -111,6 +111,10 @@
#define ITEMID_CHARSCALE_W 0 #define ITEMID_CHARSCALE_W 0
#define ITEMID_CHARROTATE 0 #define ITEMID_CHARROTATE 0
#define ITEMID_CHARRELIEF 0 #define ITEMID_CHARRELIEF 0
#define ITEMID_PARAVERTALIGN 0
#define ITEMID_FORBIDDENRULE 0
#define ITEMID_SCRIPTSPACE 0
#define ITEMID_HANGINGPUNCTUATION 0
#include "flstitem.hxx" #include "flstitem.hxx"
#include "fontitem.hxx" #include "fontitem.hxx"
...@@ -151,7 +155,6 @@ ...@@ -151,7 +155,6 @@
#include "keepitem.hxx" #include "keepitem.hxx"
#include "bolnitem.hxx" #include "bolnitem.hxx"
#include "brshitem.hxx" #include "brshitem.hxx"
#include "lspcitem.hxx" #include "lspcitem.hxx"
#include "adjitem.hxx" #include "adjitem.hxx"
#include "orphitem.hxx" #include "orphitem.hxx"
...@@ -163,6 +166,11 @@ ...@@ -163,6 +166,11 @@
#include "charscaleitem.hxx" #include "charscaleitem.hxx"
#include "charrotateitem.hxx" #include "charrotateitem.hxx"
#include "charreliefitem.hxx" #include "charreliefitem.hxx"
#include "paravertalignitem.hxx"
#include "forbiddenruleitem.hxx"
#include "hngpnctitem.hxx"
#include "scriptspaceitem.hxx"
#ifndef _RTFTOKEN_H #ifndef _RTFTOKEN_H
#include <svtools/rtftoken.h> #include <svtools/rtftoken.h>
...@@ -315,6 +323,7 @@ void SvxRTFParser::ReadAttr( int nToken, SfxItemSet* pSet ) ...@@ -315,6 +323,7 @@ void SvxRTFParser::ReadAttr( int nToken, SfxItemSet* pSet )
FontEmphasisMark eEmphasis; FontEmphasisMark eEmphasis;
bPardTokenRead = FALSE; bPardTokenRead = FALSE;
RTF_CharTypeDef eCharType = NOTDEF_CHARTYPE; RTF_CharTypeDef eCharType = NOTDEF_CHARTYPE;
USHORT nFontAlign;
int bChkStkPos = !bNewGroup && aAttrStack.Top(); int bChkStkPos = !bNewGroup && aAttrStack.Top();
...@@ -353,6 +362,8 @@ void SvxRTFParser::ReadAttr( int nToken, SfxItemSet* pSet ) ...@@ -353,6 +362,8 @@ void SvxRTFParser::ReadAttr( int nToken, SfxItemSet* pSet )
SvxRTFItemStackType* pNew = new SvxRTFItemStackType( SvxRTFItemStackType* pNew = new SvxRTFItemStackType(
*pAkt, *pInsPos, TRUE ); *pAkt, *pInsPos, TRUE );
pNew->aAttrSet.SetParent( pAkt->aAttrSet.GetParent() ); pNew->aAttrSet.SetParent( pAkt->aAttrSet.GetParent() );
pNew->SetRTFDefaults( GetRTFDefaults() );
// alle bis hierher gueltigen Attribute "setzen" // alle bis hierher gueltigen Attribute "setzen"
AttrGroupEnd(); AttrGroupEnd();
aAttrStack.Push( pNew ); aAttrStack.Push( pNew );
...@@ -378,6 +389,13 @@ void SvxRTFParser::ReadAttr( int nToken, SfxItemSet* pSet ) ...@@ -378,6 +389,13 @@ void SvxRTFParser::ReadAttr( int nToken, SfxItemSet* pSet )
break; break;
case RTF_S: case RTF_S:
if( bIsInReadStyleTab )
{
if( !bFirstToken )
SkipToken( -1 );
bWeiter = FALSE;
}
else
{ {
nStyleNo = -1 == nTokenValue ? 0 : USHORT(nTokenValue); nStyleNo = -1 == nTokenValue ? 0 : USHORT(nTokenValue);
// setze am akt. auf dem AttrStack stehenden Style die // setze am akt. auf dem AttrStack stehenden Style die
...@@ -604,6 +622,47 @@ void SvxRTFParser::ReadAttr( int nToken, SfxItemSet* pSet ) ...@@ -604,6 +622,47 @@ void SvxRTFParser::ReadAttr( int nToken, SfxItemSet* pSet )
} }
break; break;
case RTF_NOCWRAP:
if( PARDID->nForbRule )
{
pSet->Put( SvxForbiddenRuleItem( FALSE,
PARDID->nForbRule ));
}
break;
case RTF_NOOVERFLOW:
if( PARDID->nHangPunct )
{
pSet->Put( SvxHangingPunctuationItem( FALSE,
PARDID->nHangPunct ));
}
break;
case RTF_ASPALPHA:
if( PARDID->nScriptSpace )
{
pSet->Put( SvxScriptSpaceItem( TRUE,
PARDID->nScriptSpace ));
}
break;
case RTF_FAFIXED:
case RTF_FAAUTO: nFontAlign = SvxParaVertAlignItem::AUTOMATIC;
goto SET_FONTALIGNMENT;
case RTF_FAHANG: nFontAlign = SvxParaVertAlignItem::TOP;
goto SET_FONTALIGNMENT;
case RTF_FAVAR: nFontAlign = SvxParaVertAlignItem::BOTTOM;
goto SET_FONTALIGNMENT;
case RTF_FACENTER: nFontAlign = SvxParaVertAlignItem::CENTER;
goto SET_FONTALIGNMENT;
case RTF_FAROMAN: nFontAlign = SvxParaVertAlignItem::BASELINE;
goto SET_FONTALIGNMENT;
SET_FONTALIGNMENT:
if( PARDID->nFontAlign )
{
pSet->Put( SvxParaVertAlignItem( nFontAlign,
PARDID->nFontAlign ));
}
break;
/* */ /* */
case RTF_B: case RTF_B:
...@@ -1742,6 +1801,8 @@ void SvxRTFParser::RTFPardPlain( int bPard, SfxItemSet** ppSet ) ...@@ -1742,6 +1801,8 @@ void SvxRTFParser::RTFPardPlain( int bPard, SfxItemSet** ppSet )
// eine neue Gruppe aufmachen // eine neue Gruppe aufmachen
SvxRTFItemStackType* pNew = new SvxRTFItemStackType( *pAkt, *pInsPos, TRUE ); SvxRTFItemStackType* pNew = new SvxRTFItemStackType( *pAkt, *pInsPos, TRUE );
pNew->aAttrSet.SetParent( pAkt->aAttrSet.GetParent() ); pNew->aAttrSet.SetParent( pAkt->aAttrSet.GetParent() );
pNew->SetRTFDefaults( GetRTFDefaults() );
// alle bis hierher gueltigen Attribute "setzen" // alle bis hierher gueltigen Attribute "setzen"
AttrGroupEnd(); AttrGroupEnd();
aAttrStack.Push( pNew ); aAttrStack.Push( pNew );
...@@ -1762,6 +1823,7 @@ void SvxRTFParser::RTFPardPlain( int bPard, SfxItemSet** ppSet ) ...@@ -1762,6 +1823,7 @@ void SvxRTFParser::RTFPardPlain( int bPard, SfxItemSet** ppSet )
const SfxPoolItem *pItem, *pDef; const SfxPoolItem *pItem, *pDef;
const USHORT* pPtr; const USHORT* pPtr;
USHORT nCnt; USHORT nCnt;
const SfxItemSet* pDfltSet = &GetRTFDefaults();
if( bPard ) if( bPard )
{ {
pAkt->nStyleNo = 0; pAkt->nStyleNo = 0;
...@@ -1785,16 +1847,27 @@ void SvxRTFParser::RTFPardPlain( int bPard, SfxItemSet** ppSet ) ...@@ -1785,16 +1847,27 @@ void SvxRTFParser::RTFPardPlain( int bPard, SfxItemSet** ppSet )
else if( SFX_WHICH_MAX < *pPtr ) else if( SFX_WHICH_MAX < *pPtr )
pAkt->aAttrSet.ClearItem( *pPtr ); pAkt->aAttrSet.ClearItem( *pPtr );
else if( IsChkStyleAttr() ) else if( IsChkStyleAttr() )
pAkt->aAttrSet.Put( pAttrPool->GetDefaultItem( *pPtr ) ); pAkt->aAttrSet.Put( pDfltSet->Get( *pPtr ) );
else if( !pAkt->aAttrSet.GetParent() ) else if( !pAkt->aAttrSet.GetParent() )
pAkt->aAttrSet.ClearItem( *pPtr ); {
if( SFX_ITEM_SET ==
pDfltSet->GetItemState( *pPtr, FALSE, &pDef ))
pAkt->aAttrSet.Put( *pDef );
else
pAkt->aAttrSet.ClearItem( *pPtr );
}
else if( SFX_ITEM_SET == pAkt->aAttrSet.GetParent()-> else if( SFX_ITEM_SET == pAkt->aAttrSet.GetParent()->
GetItemState( *pPtr, TRUE, &pItem ) && GetItemState( *pPtr, TRUE, &pItem ) &&
*( pDef = &pAttrPool->GetDefaultItem( *pPtr )) *( pDef = &pDfltSet->Get( *pPtr )) != *pItem )
!= *pItem )
pAkt->aAttrSet.Put( *pDef ); pAkt->aAttrSet.Put( *pDef );
else else
pAkt->aAttrSet.ClearItem( *pPtr ); {
if( SFX_ITEM_SET ==
pDfltSet->GetItemState( *pPtr, FALSE, &pDef ))
pAkt->aAttrSet.Put( *pDef );
else
pAkt->aAttrSet.ClearItem( *pPtr );
}
} }
} }
else if( bPard ) else if( bPard )
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: svxrtf.cxx,v $ * $RCSfile: svxrtf.cxx,v $
* *
* $Revision: 1.7 $ * $Revision: 1.8 $
* *
* last change: $Author: jp $ $Date: 2001-03-27 21:34:02 $ * last change: $Author: jp $ $Date: 2001-05-03 11:49:05 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -63,6 +63,7 @@ ...@@ -63,6 +63,7 @@
#define ITEMID_FONT 0 #define ITEMID_FONT 0
#define ITEMID_COLOR 0 #define ITEMID_COLOR 0
#define ITEMID_SCRIPTSPACE 0
#include <ctype.h> #include <ctype.h>
...@@ -100,6 +101,8 @@ ...@@ -100,6 +101,8 @@
#include <svtools/itempool.hxx> #include <svtools/itempool.hxx>
#endif #endif
#include "scriptspaceitem.hxx"
#include "fontitem.hxx" #include "fontitem.hxx"
#include "colritem.hxx" #include "colritem.hxx"
#include "svxrtf.hxx" #include "svxrtf.hxx"
...@@ -120,11 +123,12 @@ SvxRTFParser::SvxRTFParser( SfxItemPool& rPool, SvStream& rIn, ...@@ -120,11 +123,12 @@ SvxRTFParser::SvxRTFParser( SfxItemPool& rPool, SvStream& rIn,
aColorTbl( 16, 4 ), aColorTbl( 16, 4 ),
aFontTbl( 16, 4 ), aFontTbl( 16, 4 ),
nVersionNo( 0 ), nVersionNo( 0 ),
pSfxInfo( 0 ) pSfxInfo( 0 ),
pRTFDefaults( 0 )
{ {
bNewDoc = bReadNewDoc; bNewDoc = bReadNewDoc;
bChkStyleAttr = bCalcValue = bReadDocInfo = FALSE; bChkStyleAttr = bCalcValue = bReadDocInfo = bIsInReadStyleTab = FALSE;
bIsLeftToRightDef = TRUE; bIsLeftToRightDef = TRUE;
{ {
...@@ -152,6 +156,8 @@ SvxRTFParser::~SvxRTFParser() ...@@ -152,6 +156,8 @@ SvxRTFParser::~SvxRTFParser()
if( aAttrStack.Count() ) if( aAttrStack.Count() )
ClearAttrStack(); ClearAttrStack();
delete pRTFDefaults;
delete pInsPos; delete pInsPos;
#ifndef SVX_LIGHT #ifndef SVX_LIGHT
delete pSfxInfo; delete pSfxInfo;
...@@ -371,7 +377,9 @@ void SvxRTFParser::ReadStyleTable() ...@@ -371,7 +377,9 @@ void SvxRTFParser::ReadStyleTable()
short nStyleNo = 0; short nStyleNo = 0;
int nOpenBrakets = 1; // die erste wurde schon vorher erkannt !! int nOpenBrakets = 1; // die erste wurde schon vorher erkannt !!
SvxRTFStyleType* pStyle = new SvxRTFStyleType( *pAttrPool, aWhichMap.GetData() ); SvxRTFStyleType* pStyle = new SvxRTFStyleType( *pAttrPool, aWhichMap.GetData() );
pStyle->aAttrSet.Put( GetRTFDefaults() );
bIsInReadStyleTab = TRUE;
bChkStyleAttr = FALSE; // Attribute nicht gegen die Styles checken bChkStyleAttr = FALSE; // Attribute nicht gegen die Styles checken
while( nOpenBrakets && IsParserWorking() ) while( nOpenBrakets && IsParserWorking() )
...@@ -431,6 +439,7 @@ void SvxRTFParser::ReadStyleTable() ...@@ -431,6 +439,7 @@ void SvxRTFParser::ReadStyleTable()
// alle Daten vom Style vorhanden, also ab in die Tabelle // alle Daten vom Style vorhanden, also ab in die Tabelle
aStyleTbl.Insert( nStyleNo, pStyle ); aStyleTbl.Insert( nStyleNo, pStyle );
pStyle = new SvxRTFStyleType( *pAttrPool, aWhichMap.GetData() ); pStyle = new SvxRTFStyleType( *pAttrPool, aWhichMap.GetData() );
pStyle->aAttrSet.Put( GetRTFDefaults() );
nStyleNo = 0; nStyleNo = 0;
} }
break; break;
...@@ -467,6 +476,7 @@ void SvxRTFParser::ReadStyleTable() ...@@ -467,6 +476,7 @@ void SvxRTFParser::ReadStyleTable()
// Flag wieder auf alten Zustand // Flag wieder auf alten Zustand
bChkStyleAttr = bSaveChkStyleAttr; bChkStyleAttr = bSaveChkStyleAttr;
bIsInReadStyleTab = FALSE;
} }
void SvxRTFParser::ReadColorTable() void SvxRTFParser::ReadColorTable()
...@@ -864,7 +874,9 @@ SvxRTFItemStackType* SvxRTFParser::_GetAttrSet( int bCopyAttr ) ...@@ -864,7 +874,9 @@ SvxRTFItemStackType* SvxRTFParser::_GetAttrSet( int bCopyAttr )
if( pAkt ) if( pAkt )
pNew = new SvxRTFItemStackType( *pAkt, *pInsPos, bCopyAttr ); pNew = new SvxRTFItemStackType( *pAkt, *pInsPos, bCopyAttr );
else else
pNew = new SvxRTFItemStackType( *pAttrPool, aWhichMap.GetData(), *pInsPos ); pNew = new SvxRTFItemStackType( *pAttrPool, aWhichMap.GetData(),
*pInsPos );
pNew->SetRTFDefaults( GetRTFDefaults() );
aAttrStack.Push( pNew ); aAttrStack.Push( pNew );
bNewGroup = FALSE; bNewGroup = FALSE;
...@@ -1021,6 +1033,7 @@ void SvxRTFParser::AttrGroupEnd() // den akt. Bearbeiten, vom Stack loeschen ...@@ -1021,6 +1033,7 @@ void SvxRTFParser::AttrGroupEnd() // den akt. Bearbeiten, vom Stack loeschen
pNew->aAttrSet.Count(); ++n ) pNew->aAttrSet.Count(); ++n )
if( aPardMap[n] ) if( aPardMap[n] )
pNew->aAttrSet.ClearItem( aPardMap[n] ); pNew->aAttrSet.ClearItem( aPardMap[n] );
pNew->SetRTFDefaults( GetRTFDefaults() );
// gab es ueberhaupt welche ? // gab es ueberhaupt welche ?
if( pNew->aAttrSet.Count() == pOld->aAttrSet.Count() ) if( pNew->aAttrSet.Count() == pOld->aAttrSet.Count() )
...@@ -1156,6 +1169,24 @@ void SvxRTFParser::BuildWhichTbl() ...@@ -1156,6 +1169,24 @@ void SvxRTFParser::BuildWhichTbl()
SvParser::BuildWhichTbl( aWhichMap, (USHORT*)aPlainMap.GetData(), aPlainMap.Count() ); SvParser::BuildWhichTbl( aWhichMap, (USHORT*)aPlainMap.GetData(), aPlainMap.Count() );
} }
const SfxItemSet& SvxRTFParser::GetRTFDefaults()
{
if( !pRTFDefaults )
{
pRTFDefaults = new SfxItemSet( *pAttrPool, aWhichMap.GetData() );
USHORT nId;
if( 0 != ( nId = ((RTFPardAttrMapIds*)aPardMap.GetData())->nScriptSpace ))
{
SvxScriptSpaceItem aItem( FALSE, nId );
if( bNewDoc )
pAttrPool->SetPoolDefaultItem( aItem );
else
pRTFDefaults->Put( aItem );
}
}
return *pRTFDefaults;
}
/* */ /* */
SvxRTFStyleType::SvxRTFStyleType( SfxItemPool& rPool, const USHORT* pWhichRange ) SvxRTFStyleType::SvxRTFStyleType( SfxItemPool& rPool, const USHORT* pWhichRange )
...@@ -1308,6 +1339,23 @@ void SvxRTFItemStackType::Compress( const SvxRTFParser& rParser ) ...@@ -1308,6 +1339,23 @@ void SvxRTFItemStackType::Compress( const SvxRTFParser& rParser )
pChildList = 0; pChildList = 0;
} }
} }
void SvxRTFItemStackType::SetRTFDefaults( const SfxItemSet& rDefaults )
{
if( rDefaults.Count() )
{
SfxItemIter aIter( rDefaults );
const SfxPoolItem* pItem;
do {
USHORT nWhich = aIter.GetCurItem()->Which();
if( SFX_ITEM_SET != aAttrSet.GetItemState( nWhich, FALSE ))
aAttrSet.Put( *aIter.GetCurItem() );
if( aIter.IsAtEnd() )
break;
aIter.NextItem();
} while( TRUE );
}
}
/* */ /* */
...@@ -1362,6 +1410,10 @@ RTFPardAttrMapIds ::RTFPardAttrMapIds ( const SfxItemPool& rPool ) ...@@ -1362,6 +1410,10 @@ RTFPardAttrMapIds ::RTFPardAttrMapIds ( const SfxItemPool& rPool )
nOutlineLvl = rPool.GetTrueWhich( SID_ATTR_PARA_OUTLLEVEL, FALSE ); nOutlineLvl = rPool.GetTrueWhich( SID_ATTR_PARA_OUTLLEVEL, FALSE );
nSplit = rPool.GetTrueWhich( SID_ATTR_PARA_SPLIT, FALSE ); nSplit = rPool.GetTrueWhich( SID_ATTR_PARA_SPLIT, FALSE );
nKeep = rPool.GetTrueWhich( SID_ATTR_PARA_KEEP, FALSE ); nKeep = rPool.GetTrueWhich( SID_ATTR_PARA_KEEP, FALSE );
nFontAlign = rPool.GetTrueWhich( SID_PARA_VERTALIGN, FALSE );
nScriptSpace = rPool.GetTrueWhich( SID_ATTR_PARA_SCRIPTSPACE, FALSE );
nHangPunct = rPool.GetTrueWhich( SID_ATTR_PARA_HANGPUNCTUATION, FALSE );
nForbRule = rPool.GetTrueWhich( SID_ATTR_PARA_FORBIDDEN_RULES, FALSE );
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment