Files
libreoffice/editeng/source/rtf/rtfitem.cxx

1910 lines
66 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
re-base on ALv2 code. Includes (at least) relevant parts of: linecap: Reintegrating finished LineCap feature Patch contributed by Regina Henschel http://svn.apache.org/viewvc?view=revision&revision=1232507 Patches contributed by Sven Jacobi impress212: #i81610# fixed animation export http://svn.apache.org/viewvc?view=revision&revision=1167620 impress212: drawinglayer gbuild environment changes http://svn.apache.org/viewvc?view=revision&revision=1167627 http://svn.apache.org/viewvc?view=revision&revision=1167628 impress212: DffPropSet -> minor code improvements, removing table http://svn.apache.org/viewvc?view=revision&revision=1167634 impress212: #158494# fixed excel import (text rotation) http://svn.apache.org/viewvc?view=revision&revision=1167638 Patches contributed by Armin Le Grand Svg: Reintegrated Svg replacement from /branches/alg/svgreplavement http://svn.apache.org/viewvc?view=revision&revision=1220836 #118728# changed indentifying definitions for Svg file detection http://svn.apache.org/viewvc?view=revision&revision=1229961 #118838# LineGeometry creation for complicated cases optimized to create single Polygons http://svn.apache.org/viewvc?view=revision&revision=1236232 #119176# corrected file type detection for SVG for svg files without xml header http://svn.apache.org/viewvc?view=revision&revision=1309445 #118728# Extended Svg file detection http://svn.apache.org/viewvc?view=revision&revision=1230531 #118529# solve break converters and convert commands for OLEs and images http://svn.apache.org/viewvc?view=revision&revision=1186168 svg: added WaE changes from branch svgreplacement to trunc http://svn.apache.org/viewvc?view=revision&revision=1222974 svg: corrected missing member initialization http://svn.apache.org/viewvc?view=revision&revision=1226134 fix for #118525#: Using primitives for chart sub-geometry visualisation http://svn.apache.org/viewvc?view=revision&revision=1226879 #118898# Adapted ImpGraphic::ImplGetBitmap to correctly convert metafiles to bitmapEx ... http://svn.apache.org/viewvc?view=revision&revision=1293316 fix for #118525#: removed no longer used variable maOriginalMapMode, one more exception eliminated http://svn.apache.org/viewvc?view=revision&revision=1227097 #16758# Added buffering to the VDev usages of the VclProcessor2D derivates... http://svn.apache.org/viewvc?view=revision&revision=1229521 #116758# Secured VDev buffer device to Vcl deinit http://svn.apache.org/viewvc?view=revision&revision=1230574 #116758# added remembering allocated VDevs for VDevBuffer to be able to also delete these when vcl goes down; it should never happen, but You never know http://svn.apache.org/viewvc?view=revision&revision=1230927 #118730# Changed SvgClipPathNode to use MaskPrimitive2D for primitive representation instead of TransparencePrimitive2D http://svn.apache.org/viewvc?view=revision&revision=1231198 #118822# secured 3D geometry creation (slices) by subdividing the 2D source polyPolygon early http://svn.apache.org/viewvc?view=revision&revision=1234749 #118829# enhanced Svg gradient quality, obstacles avoided http://svn.apache.org/viewvc?view=revision&revision=1235361 #118834# Unified usage of TextBreakupHelper as single tooling class for i18n text primitive breakup http://svn.apache.org/viewvc?view=revision&revision=1236110 #118853# added square pixel size limit to conversion of TransparencePrimitive2D to Metafile action http://svn.apache.org/viewvc?view=revision&revision=1237656 #118824# coreccted mirroring and boundrect when the graphicmanager is used for bitmap output http://svn.apache.org/viewvc?view=revision&revision=1240097 #115092# Corrected VclProcessor2D::RenderPolygonStrokePrimitive2D for various optimization scenarios http://svn.apache.org/viewvc?view=revision&revision=1241434 #118783# Corrected errors in ID strings, corrected Svg line/fill export, corrected polygon close state http://svn.apache.org/viewvc?view=revision&revision=1232006 #118796# corrected null-pointer usage in SVG text exporter http://svn.apache.org/viewvc?view=revision&revision=1240262 #118729# Use GraphicStreamUrl and GraphicUrl to allow multi image import with linked graphics, too http://svn.apache.org/viewvc?view=revision&revision=1229962 #118898# corrected error in GDIMetaFile::GetBoundRect in handling MetaFloatTransparentAction http://svn.apache.org/viewvc?view=revision&revision=1293349 #118855# Corrected handling of possibly created empty clipRegions after PolyPolygon clipping http://svn.apache.org/viewvc?view=revision&revision=1237725 #115962# Better (but not yet optimal, see comments in task) handling of MetaFloatTransparentAction in PDF export http://svn.apache.org/viewvc?view=revision&revision=1241078 IP clearance: #118466# This patch removes librsvg, libcroco, libgsf, ... http://svn.apache.org/viewvc?view=revision&revision=1200879 118779# Added svg content streaming in/out to ImpGraphic stream operators http://svn.apache.org/viewvc?view=revision&revision=1231908 linecap: correctons for WaE and mac drawing http://svn.apache.org/viewvc?view=revision&revision=1232793 svg: uses current system Dpi for Svg replacement image creation http://svn.apache.org/viewvc?view=revision&revision=1233948 Patches contributed by Mathias Bauer (and others) gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394326 http://svn.apache.org/viewvc?view=revision&revision=1396797 http://svn.apache.org/viewvc?view=revision&revision=1397315 http://svn.apache.org/viewvc?view=revision&revision=1394326 Remove duplicate header includes. cws mba34issues01: #i117720#: convert assertion into warning http://svn.apache.org/viewvc?view=revision&revision=1172352 118485 - Styles for OLEs are not saved. Submitted by Armin Le Grand. http://svn.apache.org/viewvc?view=revision&revision=1182166 cws mba34issues01: #i117714#: remove assertion http://svn.apache.org/viewvc?view=revision&revision=1172357 Patch contributed by Jurgen Schmidt add some additional checks to ensure proper reading operations http://svn.apache.org/viewvc?view=revision&revision=1209022 mostly prefer our stream / bounds checking work. Patches contributed by Herbert Duerr #i118816# add clarifying comment regarding Font::*Color*() methods http://svn.apache.org/viewvc?view=revision&revision=1233833 extend macro->string handling for empty strings http://svn.apache.org/viewvc?view=revision&revision=1175801 avoid magic constants for SALCOLOR_NONE http://svn.apache.org/viewvc?view=revision&revision=1177543 initialize slant properly in ImplFontMetricData constructor (author=iorsh) http://svn.apache.org/viewvc?view=revision&revision=1177551 #i118675# make check for extension updates more stable http://svn.apache.org/viewvc?view=revision&revision=1214797 #a118617# remove VBasicEventListener.dll binary There are no known users depending on its CLSID http://svn.apache.org/viewvc?view=revision&revision=1203697 Patches contributed by Ariel Constenla-Haile Fix build breaker on Linux/gcc http://svn.apache.org/viewvc?view=revision&revision=1221104 Fix crash when trying to instantiate css.graphic.GraphicRasterizer_RSVG http://svn.apache.org/viewvc?view=revision&revision=1215559 Patches contributed by Oliver-Rainer Wittmann sw34bf06: #i117962# - method <SwFlyFrm::IsPaint(..)> - consider instances of <SwFlyDrawObj> http://svn.apache.org/viewvc?view=revision&revision=1172120 sw34bf06: #i117783# - Writer's implementation of XPagePrintable - apply print settings to new printing routines http://svn.apache.org/viewvc?view=revision&revision=1172115 gnumake4 work variously from Hans-Joachim Lankenau http://svn.apache.org/viewvc?view=revision&revision=1397315 http://svn.apache.org/viewvc?view=revision&revision=1396797 http://svn.apache.org/viewvc?view=revision&revision=1396782 http://svn.apache.org/viewvc?view=revision&revision=1394707 plus some amount of re-splitting of legacy headers. Patch contributed by Pavel Janik WaE: Remove unused variables. http://svn.apache.org/viewvc?view=revision&revision=1230697 Patches contributed by Takashi Ono mingwport35: i#117795: MinGW port fix for vcl2gnumake http://svn.apache.org/viewvc?view=revision&revision=1172091 mingwport35: i#117795: MinGW port fix for vcl2gnumake http://svn.apache.org/viewvc?view=revision&revision=1172091 Patch contributed by Christian Lippka impress212: #i98044# re enable Text menu for outline and title shapes http://svn.apache.org/viewvc?view=revision&revision=1167639 Patch contributed by Andre Fischer 118674: Made category B code optional and disabled by default. http://svn.apache.org/viewvc?view=revision&revision=1215131 118881: Ignore empty paragraphs after bullets. http://svn.apache.org/viewvc?view=revision&revision=1296205 Patches contributed by Philipp Lohmann ooo340fixes: #i117780# use rtl allocator http://svn.apache.org/viewvc?view=revision&revision=1172087 ooo34gsl02: #i117807# fix an off by one error (index actually inside the pfb section header) http://svn.apache.org/viewvc?view=revision&revision=1167576 various cleanups, related compilation fixes, warning cleanups, re-working of obsolete stl template pieces to use boost instead, changed string classes, re-adapt KDE about data, about dialog, fixing warnings, and other fixes & improvements. Disable svg import / render for about/ branding code-paths for now. Restore full icon theme set. Remove OS/2 conditionals and sources. Remove conflicting gtk/full-screen monitors support. Retain existing svg rasterizer files - temporarily disabled. Standardize stringificaiton and fixup dllpostfix issues. Rename SvgGradientHelper::== to equalTo to avoid overloading issues. Use the flat GdiPlus API for LineCaps calls.
2012-10-09 12:22:23 +01:00
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
2000-09-18 16:07:07 +00:00
#include <editeng/flstitem.hxx>
#include <editeng/fontitem.hxx>
#include <editeng/postitem.hxx>
#include <editeng/wghtitem.hxx>
#include <editeng/fhgtitem.hxx>
#include <editeng/fwdtitem.hxx>
#include <editeng/udlnitem.hxx>
#include <editeng/crossedoutitem.hxx>
#include <editeng/shdditem.hxx>
#include <editeng/autokernitem.hxx>
#include <editeng/wrlmitem.hxx>
#include <editeng/contouritem.hxx>
#include <editeng/prszitem.hxx>
#include <editeng/colritem.hxx>
#include <editeng/charsetcoloritem.hxx>
#include <editeng/kernitem.hxx>
#include <editeng/cmapitem.hxx>
#include <editeng/escapementitem.hxx>
#include <editeng/langitem.hxx>
#include <editeng/nlbkitem.hxx>
#include <editeng/nhypitem.hxx>
#include <editeng/lcolitem.hxx>
#include <editeng/blinkitem.hxx>
#include <editeng/emphasismarkitem.hxx>
#include <editeng/twolinesitem.hxx>
#include <editeng/pbinitem.hxx>
#include <editeng/sizeitem.hxx>
#include <editeng/lrspitem.hxx>
#include <editeng/ulspitem.hxx>
#include <editeng/prntitem.hxx>
#include <editeng/opaqitem.hxx>
#include <editeng/protitem.hxx>
#include <editeng/shaditem.hxx>
#include <editeng/boxitem.hxx>
#include <editeng/formatbreakitem.hxx>
#include <editeng/keepitem.hxx>
#include <editeng/lineitem.hxx>
#include <editeng/brushitem.hxx>
#include <editeng/lspcitem.hxx>
#include <editeng/adjustitem.hxx>
#include <editeng/orphitem.hxx>
#include <editeng/widwitem.hxx>
#include <editeng/tstpitem.hxx>
#include <editeng/pmdlitem.hxx>
#include <editeng/spltitem.hxx>
#include <editeng/hyphenzoneitem.hxx>
#include <editeng/charscaleitem.hxx>
#include <editeng/charrotateitem.hxx>
#include <editeng/charreliefitem.hxx>
#include <editeng/paravertalignitem.hxx>
#include <editeng/forbiddenruleitem.hxx>
#include <editeng/hngpnctitem.hxx>
#include <editeng/scriptspaceitem.hxx>
#include <editeng/frmdiritem.hxx>
#include <editeng/charhiddenitem.hxx>
2000-09-18 16:07:07 +00:00
#include <svtools/rtftoken.h>
#include <svl/itempool.hxx>
#include <svl/itemiter.hxx>
2000-09-18 16:07:07 +00:00
#include <editeng/svxrtf.hxx>
#include <editeng/editids.hrc>
2000-09-18 16:07:07 +00:00
#define BRACELEFT '{'
#define BRACERIGHT '}'
using namespace ::com::sun::star;
using namespace editeng;
2000-09-18 16:07:07 +00:00
2011-02-16 16:34:02 -05:00
// Some helper functions
2000-09-18 16:07:07 +00:00
// char
inline const SvxEscapementItem& GetEscapement(const SfxItemSet& rSet,sal_uInt16 nId,bool bInP=true)
{ return static_cast<const SvxEscapementItem&>(rSet.Get( nId,bInP)); }
inline const SvxLineSpacingItem& GetLineSpacing(const SfxItemSet& rSet,sal_uInt16 nId,bool bInP=true)
{ return static_cast<const SvxLineSpacingItem&>(rSet.Get( nId,bInP)); }
2000-09-18 16:07:07 +00:00
// frm
inline const SvxLRSpaceItem& GetLRSpace(const SfxItemSet& rSet,sal_uInt16 nId,bool bInP=true)
{ return static_cast<const SvxLRSpaceItem&>(rSet.Get( nId,bInP)); }
inline const SvxULSpaceItem& GetULSpace(const SfxItemSet& rSet,sal_uInt16 nId,bool bInP=true)
{ return static_cast<const SvxULSpaceItem&>(rSet.Get( nId,bInP)); }
2000-09-18 16:07:07 +00:00
void SvxRTFParser::SetScriptAttr( RTF_CharTypeDef eType, SfxItemSet& rSet,
SfxPoolItem& rItem )
2000-11-10 10:34:57 +00:00
{
const sal_uInt16 *pNormal = 0, *pCJK = 0, *pCTL = 0;
switch( rItem.Which() )
2000-11-10 10:34:57 +00:00
{
case SID_ATTR_CHAR_FONT:
pNormal = &aPlainMap.nFont;
pCJK = &aPlainMap.nCJKFont;
pCTL = &aPlainMap.nCTLFont;
2000-11-10 10:34:57 +00:00
break;
case SID_ATTR_CHAR_FONTHEIGHT:
pNormal = &aPlainMap.nFontHeight;
pCJK = &aPlainMap.nCJKFontHeight;
pCTL = &aPlainMap.nCTLFontHeight;
2000-11-10 10:34:57 +00:00
break;
case SID_ATTR_CHAR_POSTURE:
pNormal = &aPlainMap.nPosture;
pCJK = &aPlainMap.nCJKPosture;
pCTL = &aPlainMap.nCTLPosture;
2000-11-10 10:34:57 +00:00
break;
case SID_ATTR_CHAR_WEIGHT:
pNormal = &aPlainMap.nWeight;
pCJK = &aPlainMap.nCJKWeight;
pCTL = &aPlainMap.nCTLWeight;
2000-11-10 10:34:57 +00:00
break;
case SID_ATTR_CHAR_LANGUAGE:
pNormal = &aPlainMap.nLanguage;
pCJK = &aPlainMap.nCJKLanguage;
pCTL = &aPlainMap.nCTLLanguage;
2000-11-10 10:34:57 +00:00
break;
case 0:
// it exist no WhichId - don't set this item
break;
2000-11-10 10:34:57 +00:00
default:
rSet.Put( rItem );
break;
2000-11-10 10:34:57 +00:00
}
if( DOUBLEBYTE_CHARTYPE == eType )
{
if( bIsLeftToRightDef && pCJK )
{
rItem.SetWhich( *pCJK );
rSet.Put( rItem );
}
2000-11-10 10:34:57 +00:00
}
else if( !bIsLeftToRightDef )
{
if( pCTL )
{
rItem.SetWhich( *pCTL );
rSet.Put( rItem );
}
}
2000-11-10 10:34:57 +00:00
else
{
if( LOW_CHARTYPE == eType )
{
if( pNormal )
{
rItem.SetWhich( *pNormal );
rSet.Put( rItem );
}
}
else if( HIGH_CHARTYPE == eType )
{
if( pCTL )
{
rItem.SetWhich( *pCTL );
rSet.Put( rItem );
}
}
else
{
if( pCJK )
{
rItem.SetWhich( *pCJK );
rSet.Put( rItem );
}
if( pCTL )
{
rItem.SetWhich( *pCTL );
rSet.Put( rItem );
}
if( pNormal )
{
rItem.SetWhich( *pNormal );
rSet.Put( rItem );
}
}
}
2000-11-10 10:34:57 +00:00
}
2000-09-18 16:07:07 +00:00
void SvxRTFParser::ReadAttr( int nToken, SfxItemSet* pSet )
{
2011-02-16 16:34:02 -05:00
DBG_ASSERT( pSet, "A SfxItemSet has to be provided as argument!" );
bool bFirstToken = true;
bool bContinue = true;
sal_uInt16 nStyleNo = 0; // default
2000-09-18 16:07:07 +00:00
FontUnderline eUnderline;
FontUnderline eOverline;
2000-11-10 10:34:57 +00:00
FontEmphasisMark eEmphasis;
bPardTokenRead = false;
2000-11-10 10:34:57 +00:00
RTF_CharTypeDef eCharType = NOTDEF_CHARTYPE;
sal_uInt16 nFontAlign;
2000-09-18 16:07:07 +00:00
bool bChkStkPos = !bNewGroup && !aAttrStack.empty();
2000-09-18 16:07:07 +00:00
while( bContinue && IsParserWorking() ) // as long as known Attribute are recognized
2000-09-18 16:07:07 +00:00
{
switch( nToken )
{
case RTF_PARD:
RTFPardPlain( true, &pSet );
2000-09-18 16:07:07 +00:00
nStyleNo = 0;
bPardTokenRead = true;
2000-09-18 16:07:07 +00:00
break;
case RTF_PLAIN:
RTFPardPlain( false, &pSet );
2000-09-18 16:07:07 +00:00
break;
default:
do { // middle checked loop
if( !bChkStkPos )
break;
2010-11-19 14:24:51 +01:00
SvxRTFItemStackType* pAkt = aAttrStack.empty() ? 0 : aAttrStack.back();
2000-09-18 16:07:07 +00:00
if( !pAkt || (pAkt->pSttNd->GetIdx() == pInsPos->GetNodeIdx() &&
pAkt->nSttCnt == pInsPos->GetCntIdx() ))
break;
int nLastToken = GetStackPtr(-1)->nTokenId;
if( RTF_PARD == nLastToken || RTF_PLAIN == nLastToken )
break;
if( pAkt->aAttrSet.Count() || pAkt->pChildList ||
pAkt->nStyleNo )
{
2011-02-16 16:34:02 -05:00
// Open a new Group
2000-09-18 16:07:07 +00:00
SvxRTFItemStackType* pNew = new SvxRTFItemStackType(
*pAkt, *pInsPos, true );
pNew->SetRTFDefaults( GetRTFDefaults() );
2011-02-16 16:34:02 -05:00
// "Set" all valid attributes up until this point
2000-09-18 16:07:07 +00:00
AttrGroupEnd();
2010-11-19 14:24:51 +01:00
pAkt = aAttrStack.empty() ? 0 : aAttrStack.back(); // can be changed after AttrGroupEnd!
pNew->aAttrSet.SetParent( pAkt ? &pAkt->aAttrSet : 0 );
aAttrStack.push_back( pNew );
2000-09-18 16:07:07 +00:00
pAkt = pNew;
}
else
2011-02-16 16:34:02 -05:00
// continue to use this entry as a new one
2000-09-18 16:07:07 +00:00
pAkt->SetStartPos( *pInsPos );
pSet = &pAkt->aAttrSet;
} while( false );
2000-09-18 16:07:07 +00:00
switch( nToken )
{
case RTF_INTBL:
case RTF_PAGEBB:
case RTF_SBYS:
case RTF_CS:
case RTF_LS:
case RTF_ILVL:
UnknownAttrToken( nToken, pSet );
break;
case RTF_S:
if( bIsInReadStyleTab )
{
if( !bFirstToken )
SkipToken( -1 );
bContinue = false;
}
else
2000-09-18 16:07:07 +00:00
{
nStyleNo = -1 == nTokenValue ? 0 : sal_uInt16(nTokenValue);
/* setze am akt. auf dem AttrStack stehenden Style die
I sit on akt. which is on the immediate style AttrStack */
2000-09-18 16:07:07 +00:00
// StyleNummer
2010-11-19 14:24:51 +01:00
SvxRTFItemStackType* pAkt = aAttrStack.empty() ? 0 : aAttrStack.back();
2000-09-18 16:07:07 +00:00
if( !pAkt )
break;
pAkt->nStyleNo = sal_uInt16( nStyleNo );
2000-09-18 16:07:07 +00:00
}
break;
case RTF_KEEP:
if( aPardMap.nSplit )
2000-09-18 16:07:07 +00:00
{
pSet->Put( SvxFormatSplitItem( false, aPardMap.nSplit ));
2000-09-18 16:07:07 +00:00
}
break;
case RTF_KEEPN:
if( aPardMap.nKeep )
2000-09-18 16:07:07 +00:00
{
pSet->Put( SvxFormatKeepItem( true, aPardMap.nKeep ));
2000-09-18 16:07:07 +00:00
}
break;
case RTF_LEVEL:
if( aPardMap.nOutlineLvl )
2000-09-18 16:07:07 +00:00
{
pSet->Put( SfxUInt16Item( aPardMap.nOutlineLvl,
(sal_uInt16)nTokenValue ));
2000-09-18 16:07:07 +00:00
}
break;
case RTF_QL:
if( aPardMap.nAdjust )
2000-09-18 16:07:07 +00:00
{
pSet->Put( SvxAdjustItem( SVX_ADJUST_LEFT, aPardMap.nAdjust ));
2000-09-18 16:07:07 +00:00
}
break;
case RTF_QR:
if( aPardMap.nAdjust )
2000-09-18 16:07:07 +00:00
{
pSet->Put( SvxAdjustItem( SVX_ADJUST_RIGHT, aPardMap.nAdjust ));
2000-09-18 16:07:07 +00:00
}
break;
case RTF_QJ:
if( aPardMap.nAdjust )
2000-09-18 16:07:07 +00:00
{
pSet->Put( SvxAdjustItem( SVX_ADJUST_BLOCK, aPardMap.nAdjust ));
2000-09-18 16:07:07 +00:00
}
break;
case RTF_QC:
if( aPardMap.nAdjust )
2000-09-18 16:07:07 +00:00
{
pSet->Put( SvxAdjustItem( SVX_ADJUST_CENTER, aPardMap.nAdjust ));
2000-09-18 16:07:07 +00:00
}
break;
case RTF_FI:
if( aPardMap.nLRSpace )
2000-09-18 16:07:07 +00:00
{
SvxLRSpaceItem aLR( GetLRSpace(*pSet, aPardMap.nLRSpace ));
sal_uInt16 nSz = 0;
2000-09-18 16:07:07 +00:00
if( -1 != nTokenValue )
{
if( IsCalcValue() )
CalcValue();
nSz = sal_uInt16(nTokenValue);
2000-09-18 16:07:07 +00:00
}
aLR.SetTextFirstLineOfst( nSz );
2000-09-18 16:07:07 +00:00
pSet->Put( aLR );
}
break;
case RTF_LI:
case RTF_LIN:
if( aPardMap.nLRSpace )
2000-09-18 16:07:07 +00:00
{
SvxLRSpaceItem aLR( GetLRSpace(*pSet, aPardMap.nLRSpace ));
sal_uInt16 nSz = 0;
2000-09-18 16:07:07 +00:00
if( 0 < nTokenValue )
{
if( IsCalcValue() )
CalcValue();
nSz = sal_uInt16(nTokenValue);
2000-09-18 16:07:07 +00:00
}
aLR.SetTextLeft( nSz );
2000-09-18 16:07:07 +00:00
pSet->Put( aLR );
}
break;
case RTF_RI:
case RTF_RIN:
if( aPardMap.nLRSpace )
2000-09-18 16:07:07 +00:00
{
SvxLRSpaceItem aLR( GetLRSpace(*pSet, aPardMap.nLRSpace ));
sal_uInt16 nSz = 0;
2000-09-18 16:07:07 +00:00
if( 0 < nTokenValue )
{
if( IsCalcValue() )
CalcValue();
nSz = sal_uInt16(nTokenValue);
2000-09-18 16:07:07 +00:00
}
aLR.SetRight( nSz );
pSet->Put( aLR );
}
break;
case RTF_SB:
if( aPardMap.nULSpace )
2000-09-18 16:07:07 +00:00
{
SvxULSpaceItem aUL( GetULSpace(*pSet, aPardMap.nULSpace ));
sal_uInt16 nSz = 0;
2000-09-18 16:07:07 +00:00
if( 0 < nTokenValue )
{
if( IsCalcValue() )
CalcValue();
nSz = sal_uInt16(nTokenValue);
2000-09-18 16:07:07 +00:00
}
aUL.SetUpper( nSz );
pSet->Put( aUL );
}
break;
case RTF_SA:
if( aPardMap.nULSpace )
2000-09-18 16:07:07 +00:00
{
SvxULSpaceItem aUL( GetULSpace(*pSet, aPardMap.nULSpace ));
sal_uInt16 nSz = 0;
2000-09-18 16:07:07 +00:00
if( 0 < nTokenValue )
{
if( IsCalcValue() )
CalcValue();
nSz = sal_uInt16(nTokenValue);
2000-09-18 16:07:07 +00:00
}
aUL.SetLower( nSz );
pSet->Put( aUL );
}
break;
case RTF_SLMULT:
if( aPardMap.nLinespacing && 1 == nTokenValue )
2000-09-18 16:07:07 +00:00
{
2011-02-16 16:34:02 -05:00
// then switches to multi-line!
2000-09-18 16:07:07 +00:00
SvxLineSpacingItem aLSpace( GetLineSpacing( *pSet,
aPardMap.nLinespacing, false ));
2000-09-18 16:07:07 +00:00
2011-02-16 16:34:02 -05:00
// how much do you get from the line height value?
2000-09-18 16:07:07 +00:00
2011-02-16 16:34:02 -05:00
// Proportional-Size:
// Ie, the ratio is (n / 240) twips
2000-09-18 16:07:07 +00:00
nTokenValue = 240;
if( IsCalcValue() )
CalcValue();
nTokenValue = short( 100L * aLSpace.GetLineHeight()
/ long( nTokenValue ) );
2011-02-16 16:34:02 -05:00
if( nTokenValue > 200 ) // Data value for PropLnSp
nTokenValue = 200; // is one BYTE !!!
2000-09-18 16:07:07 +00:00
aLSpace.SetPropLineSpace( (const sal_uInt8)nTokenValue );
2000-09-18 16:07:07 +00:00
aLSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
pSet->Put( aLSpace );
}
break;
case RTF_SL:
if( aPardMap.nLinespacing )
2000-09-18 16:07:07 +00:00
{
2011-02-16 16:34:02 -05:00
// Calculate the ratio between the default font and the
// specified size. The distance consists of the line height
// (100%) and the space above the line (20%).
SvxLineSpacingItem aLSpace(0, aPardMap.nLinespacing);
2000-09-18 16:07:07 +00:00
nTokenValue = !bTokenHasValue ? 0 : nTokenValue;
if (1000 == nTokenValue )
2000-09-18 16:07:07 +00:00
nTokenValue = 240;
SvxLineSpace eLnSpc;
if (nTokenValue < 0)
2000-09-18 16:07:07 +00:00
{
eLnSpc = SVX_LINE_SPACE_FIX;
nTokenValue = -nTokenValue;
}
else if (nTokenValue == 0)
{
//if \sl0 is used, the line spacing is automatically
//determined
eLnSpc = SVX_LINE_SPACE_AUTO;
}
2000-09-18 16:07:07 +00:00
else
eLnSpc = SVX_LINE_SPACE_MIN;
if (IsCalcValue())
2000-09-18 16:07:07 +00:00
CalcValue();
if (eLnSpc != SVX_LINE_SPACE_AUTO)
aLSpace.SetLineHeight( (const sal_uInt16)nTokenValue );
aLSpace.GetLineSpaceRule() = eLnSpc;
pSet->Put(aLSpace);
2000-09-18 16:07:07 +00:00
}
break;
case RTF_NOCWRAP:
if( aPardMap.nForbRule )
{
pSet->Put( SvxForbiddenRuleItem( false,
aPardMap.nForbRule ));
}
break;
case RTF_NOOVERFLOW:
if( aPardMap.nHangPunct )
{
pSet->Put( SvxHangingPunctuationItem( false,
aPardMap.nHangPunct ));
}
break;
case RTF_ASPALPHA:
if( aPardMap.nScriptSpace )
{
pSet->Put( SvxScriptSpaceItem( true,
aPardMap.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( aPardMap.nFontAlign )
{
pSet->Put( SvxParaVertAlignItem( nFontAlign,
aPardMap.nFontAlign ));
}
break;
2000-09-18 16:07:07 +00:00
case RTF_B:
case RTF_AB:
2011-02-16 16:34:02 -05:00
if( IsAttrSttPos() ) // not in the text flow?
2000-09-18 16:07:07 +00:00
{
2001-10-16 16:45:47 +00:00
SvxWeightItem aTmpItem(
nTokenValue ? WEIGHT_BOLD : WEIGHT_NORMAL,
2001-10-16 16:45:47 +00:00
SID_ATTR_CHAR_WEIGHT );
SetScriptAttr( eCharType, *pSet, aTmpItem);
2000-09-18 16:07:07 +00:00
}
break;
case RTF_CAPS:
case RTF_SCAPS:
if( aPlainMap.nCaseMap &&
2011-02-16 16:34:02 -05:00
IsAttrSttPos() ) // not in the text flow?
2000-09-18 16:07:07 +00:00
{
SvxCaseMap eCaseMap;
if( !nTokenValue )
eCaseMap = SVX_CASEMAP_NOT_MAPPED;
else if( RTF_CAPS == nToken )
eCaseMap = SVX_CASEMAP_VERSALIEN;
else
eCaseMap = SVX_CASEMAP_KAPITAELCHEN;
pSet->Put( SvxCaseMapItem( eCaseMap, aPlainMap.nCaseMap ));
2000-09-18 16:07:07 +00:00
}
break;
case RTF_DN:
case RTF_SUB:
if( aPlainMap.nEscapement )
2000-09-18 16:07:07 +00:00
{
const sal_uInt16 nEsc = aPlainMap.nEscapement;
2000-09-18 16:07:07 +00:00
if( -1 == nTokenValue || RTF_SUB == nToken )
nTokenValue = 6;
if( IsCalcValue() )
CalcValue();
const SvxEscapementItem& rOld = GetEscapement( *pSet, nEsc, false );
2000-09-18 16:07:07 +00:00
short nEs;
sal_uInt8 nProp;
2000-09-18 16:07:07 +00:00
if( DFLT_ESC_AUTO_SUPER == rOld.GetEsc() )
{
nEs = DFLT_ESC_AUTO_SUB;
nProp = rOld.GetProp();
}
else
{
nEs = (short)-nTokenValue;
nProp = (nToken == RTF_SUB) ? DFLT_ESC_PROP : 100;
2000-09-18 16:07:07 +00:00
}
pSet->Put( SvxEscapementItem( nEs, nProp, nEsc ));
}
break;
case RTF_NOSUPERSUB:
if( aPlainMap.nEscapement )
2000-09-18 16:07:07 +00:00
{
const sal_uInt16 nEsc = aPlainMap.nEscapement;
2000-09-18 16:07:07 +00:00
pSet->Put( SvxEscapementItem( nEsc ));
}
break;
case RTF_EXPND:
if( aPlainMap.nKering )
2000-09-18 16:07:07 +00:00
{
if( -1 == nTokenValue )
nTokenValue = 0;
else
nTokenValue *= 5;
if( IsCalcValue() )
CalcValue();
pSet->Put( SvxKerningItem( (short)nTokenValue, aPlainMap.nKering ));
2000-09-18 16:07:07 +00:00
}
break;
case RTF_KERNING:
if( aPlainMap.nAutoKerning )
2000-09-18 16:07:07 +00:00
{
if( -1 == nTokenValue )
nTokenValue = 0;
else
nTokenValue *= 10;
if( IsCalcValue() )
CalcValue();
pSet->Put( SvxAutoKernItem( 0 != nTokenValue,
aPlainMap.nAutoKerning ));
2000-09-18 16:07:07 +00:00
}
break;
case RTF_EXPNDTW:
if( aPlainMap.nKering )
2000-09-18 16:07:07 +00:00
{
if( -1 == nTokenValue )
nTokenValue = 0;
if( IsCalcValue() )
CalcValue();
pSet->Put( SvxKerningItem( (short)nTokenValue, aPlainMap.nKering ));
2000-09-18 16:07:07 +00:00
}
break;
case RTF_F:
2000-11-10 10:34:57 +00:00
case RTF_AF:
2000-09-18 16:07:07 +00:00
{
const vcl::Font& rSVFont = GetFont( sal_uInt16(nTokenValue) );
2001-10-16 16:45:47 +00:00
SvxFontItem aTmpItem( rSVFont.GetFamily(),
rSVFont.GetName(), rSVFont.GetStyleName(),
rSVFont.GetPitch(), rSVFont.GetCharSet(),
2001-10-16 16:45:47 +00:00
SID_ATTR_CHAR_FONT );
SetScriptAttr( eCharType, *pSet, aTmpItem );
if( RTF_F == nToken )
{
SetEncoding( rSVFont.GetCharSet() );
RereadLookahead();
}
2000-09-18 16:07:07 +00:00
}
break;
case RTF_FS:
2000-11-10 10:34:57 +00:00
case RTF_AFS:
2000-09-18 16:07:07 +00:00
{
if( -1 == nTokenValue )
nTokenValue = 240;
else
nTokenValue *= 10;
// #i66167#
// for the SwRTFParser 'IsCalcValue' will be false and for the EditRTFParser
// the converiosn takes now place in EditRTFParser since for other reasons
// the wrong MapUnit might still be use there
// if( IsCalcValue() )
// CalcValue();
2001-10-16 16:45:47 +00:00
SvxFontHeightItem aTmpItem(
(const sal_uInt16)nTokenValue, 100,
2001-10-16 16:45:47 +00:00
SID_ATTR_CHAR_FONTHEIGHT );
SetScriptAttr( eCharType, *pSet, aTmpItem );
2000-09-18 16:07:07 +00:00
}
break;
case RTF_I:
case RTF_AI:
2011-02-16 16:34:02 -05:00
if( IsAttrSttPos() ) // not in the text flow?
2000-09-18 16:07:07 +00:00
{
2001-10-16 16:45:47 +00:00
SvxPostureItem aTmpItem(
nTokenValue ? ITALIC_NORMAL : ITALIC_NONE,
2001-10-16 16:45:47 +00:00
SID_ATTR_CHAR_POSTURE );
SetScriptAttr( eCharType, *pSet, aTmpItem );
2000-09-18 16:07:07 +00:00
}
break;
case RTF_OUTL:
if( aPlainMap.nContour &&
2011-02-16 16:34:02 -05:00
IsAttrSttPos() ) // not in the text flow?
2000-09-18 16:07:07 +00:00
{
pSet->Put( SvxContourItem(nTokenValue != 0,
aPlainMap.nContour ));
2000-09-18 16:07:07 +00:00
}
break;
case RTF_SHAD:
if( aPlainMap.nShadowed &&
2011-02-16 16:34:02 -05:00
IsAttrSttPos() ) // not in the text flow?
2000-09-18 16:07:07 +00:00
{
pSet->Put( SvxShadowedItem(nTokenValue != 0,
aPlainMap.nShadowed ));
2000-09-18 16:07:07 +00:00
}
break;
case RTF_STRIKE:
if( aPlainMap.nCrossedOut &&
2011-02-16 16:34:02 -05:00
IsAttrSttPos() ) // not in the text flow?
2000-09-18 16:07:07 +00:00
{
pSet->Put( SvxCrossedOutItem(
nTokenValue ? STRIKEOUT_SINGLE : STRIKEOUT_NONE,
aPlainMap.nCrossedOut ));
2000-09-18 16:07:07 +00:00
}
break;
2000-11-10 10:34:57 +00:00
case RTF_STRIKED:
if( aPlainMap.nCrossedOut ) // not in the text flow?
2000-09-18 16:07:07 +00:00
{
pSet->Put( SvxCrossedOutItem(
2000-11-10 10:34:57 +00:00
nTokenValue ? STRIKEOUT_DOUBLE : STRIKEOUT_NONE,
aPlainMap.nCrossedOut ));
2000-09-18 16:07:07 +00:00
}
break;
case RTF_UL:
if( !IsAttrSttPos() )
break;
eUnderline = nTokenValue ? UNDERLINE_SINGLE : UNDERLINE_NONE;
goto ATTR_SETUNDERLINE;
case RTF_ULD:
eUnderline = UNDERLINE_DOTTED;
goto ATTR_SETUNDERLINE;
case RTF_ULDASH:
eUnderline = UNDERLINE_DASH;
goto ATTR_SETUNDERLINE;
case RTF_ULDASHD:
eUnderline = UNDERLINE_DASHDOT;
goto ATTR_SETUNDERLINE;
case RTF_ULDASHDD:
eUnderline = UNDERLINE_DASHDOTDOT;
goto ATTR_SETUNDERLINE;
case RTF_ULDB:
eUnderline = UNDERLINE_DOUBLE;
goto ATTR_SETUNDERLINE;
case RTF_ULNONE:
eUnderline = UNDERLINE_NONE;
goto ATTR_SETUNDERLINE;
case RTF_ULTH:
eUnderline = UNDERLINE_BOLD;
goto ATTR_SETUNDERLINE;
case RTF_ULWAVE:
eUnderline = UNDERLINE_WAVE;
goto ATTR_SETUNDERLINE;
case RTF_ULTHD:
eUnderline = UNDERLINE_BOLDDOTTED;
goto ATTR_SETUNDERLINE;
case RTF_ULTHDASH:
eUnderline = UNDERLINE_BOLDDASH;
goto ATTR_SETUNDERLINE;
case RTF_ULLDASH:
eUnderline = UNDERLINE_LONGDASH;
goto ATTR_SETUNDERLINE;
case RTF_ULTHLDASH:
eUnderline = UNDERLINE_BOLDLONGDASH;
goto ATTR_SETUNDERLINE;
case RTF_ULTHDASHD:
eUnderline = UNDERLINE_BOLDDASHDOT;
goto ATTR_SETUNDERLINE;
case RTF_ULTHDASHDD:
eUnderline = UNDERLINE_BOLDDASHDOTDOT;
goto ATTR_SETUNDERLINE;
case RTF_ULHWAVE:
eUnderline = UNDERLINE_BOLDWAVE;
goto ATTR_SETUNDERLINE;
case RTF_ULULDBWAVE:
eUnderline = UNDERLINE_DOUBLEWAVE;
goto ATTR_SETUNDERLINE;
case RTF_ULW:
eUnderline = UNDERLINE_SINGLE;
if( aPlainMap.nWordlineMode )
2000-09-18 16:07:07 +00:00
{
pSet->Put( SvxWordLineModeItem( true, aPlainMap.nWordlineMode ));
2000-09-18 16:07:07 +00:00
}
goto ATTR_SETUNDERLINE;
ATTR_SETUNDERLINE:
if( aPlainMap.nUnderline )
2000-09-18 16:07:07 +00:00
{
pSet->Put( SvxUnderlineItem( eUnderline, aPlainMap.nUnderline ));
2000-09-18 16:07:07 +00:00
}
break;
2000-11-16 16:55:17 +00:00
case RTF_ULC:
if( aPlainMap.nUnderline )
2000-11-16 16:55:17 +00:00
{
SvxUnderlineItem aUL( UNDERLINE_SINGLE, aPlainMap.nUnderline );
2000-11-16 16:55:17 +00:00
const SfxPoolItem* pItem;
if( SfxItemState::SET == pSet->GetItemState(
aPlainMap.nUnderline, false, &pItem ) )
2000-11-16 16:55:17 +00:00
{
// is switched off ?
if( UNDERLINE_NONE ==
static_cast<const SvxUnderlineItem*>(pItem)->GetLineStyle() )
2000-11-16 16:55:17 +00:00
break;
aUL = *static_cast<const SvxUnderlineItem*>(pItem);
2000-11-16 16:55:17 +00:00
}
else
aUL = static_cast<const SvxUnderlineItem&>(pSet->Get( aPlainMap.nUnderline, false ));
2000-11-16 16:55:17 +00:00
if( UNDERLINE_NONE == aUL.GetLineStyle() )
aUL.SetLineStyle( UNDERLINE_SINGLE );
aUL.SetColor( GetColor( sal_uInt16(nTokenValue) ));
2000-11-16 16:55:17 +00:00
pSet->Put( aUL );
}
break;
case RTF_OL:
if( !IsAttrSttPos() )
break;
eOverline = nTokenValue ? UNDERLINE_SINGLE : UNDERLINE_NONE;
goto ATTR_SETOVERLINE;
case RTF_OLD:
eOverline = UNDERLINE_DOTTED;
goto ATTR_SETOVERLINE;
case RTF_OLDASH:
eOverline = UNDERLINE_DASH;
goto ATTR_SETOVERLINE;
case RTF_OLDASHD:
eOverline = UNDERLINE_DASHDOT;
goto ATTR_SETOVERLINE;
case RTF_OLDASHDD:
eOverline = UNDERLINE_DASHDOTDOT;
goto ATTR_SETOVERLINE;
case RTF_OLDB:
eOverline = UNDERLINE_DOUBLE;
goto ATTR_SETOVERLINE;
case RTF_OLNONE:
eOverline = UNDERLINE_NONE;
goto ATTR_SETOVERLINE;
case RTF_OLTH:
eOverline = UNDERLINE_BOLD;
goto ATTR_SETOVERLINE;
case RTF_OLWAVE:
eOverline = UNDERLINE_WAVE;
goto ATTR_SETOVERLINE;
case RTF_OLTHD:
eOverline = UNDERLINE_BOLDDOTTED;
goto ATTR_SETOVERLINE;
case RTF_OLTHDASH:
eOverline = UNDERLINE_BOLDDASH;
goto ATTR_SETOVERLINE;
case RTF_OLLDASH:
eOverline = UNDERLINE_LONGDASH;
goto ATTR_SETOVERLINE;
case RTF_OLTHLDASH:
eOverline = UNDERLINE_BOLDLONGDASH;
goto ATTR_SETOVERLINE;
case RTF_OLTHDASHD:
eOverline = UNDERLINE_BOLDDASHDOT;
goto ATTR_SETOVERLINE;
case RTF_OLTHDASHDD:
eOverline = UNDERLINE_BOLDDASHDOTDOT;
goto ATTR_SETOVERLINE;
case RTF_OLHWAVE:
eOverline = UNDERLINE_BOLDWAVE;
goto ATTR_SETOVERLINE;
case RTF_OLOLDBWAVE:
eOverline = UNDERLINE_DOUBLEWAVE;
goto ATTR_SETOVERLINE;
case RTF_OLW:
eOverline = UNDERLINE_SINGLE;
if( aPlainMap.nWordlineMode )
{
pSet->Put( SvxWordLineModeItem( true, aPlainMap.nWordlineMode ));
}
goto ATTR_SETOVERLINE;
ATTR_SETOVERLINE:
if( aPlainMap.nUnderline )
{
pSet->Put( SvxOverlineItem( eOverline, aPlainMap.nOverline ));
}
break;
case RTF_OLC:
if( aPlainMap.nOverline )
{
SvxOverlineItem aOL( UNDERLINE_SINGLE, aPlainMap.nOverline );
const SfxPoolItem* pItem;
if( SfxItemState::SET == pSet->GetItemState(
aPlainMap.nOverline, false, &pItem ) )
{
// is switched off ?
if( UNDERLINE_NONE ==
static_cast<const SvxOverlineItem*>(pItem)->GetLineStyle() )
break;
aOL = *static_cast<const SvxOverlineItem*>(pItem);
}
else
aOL = static_cast<const SvxOverlineItem&>(pSet->Get( aPlainMap.nOverline, false ));
if( UNDERLINE_NONE == aOL.GetLineStyle() )
aOL.SetLineStyle( UNDERLINE_SINGLE );
aOL.SetColor( GetColor( sal_uInt16(nTokenValue) ));
pSet->Put( aOL );
}
break;
2000-11-16 16:55:17 +00:00
2000-09-18 16:07:07 +00:00
case RTF_UP:
case RTF_SUPER:
if( aPlainMap.nEscapement )
2000-09-18 16:07:07 +00:00
{
const sal_uInt16 nEsc = aPlainMap.nEscapement;
2000-09-18 16:07:07 +00:00
if( -1 == nTokenValue || RTF_SUPER == nToken )
nTokenValue = 6;
if( IsCalcValue() )
CalcValue();
const SvxEscapementItem& rOld = GetEscapement( *pSet, nEsc, false );
2000-09-18 16:07:07 +00:00
short nEs;
sal_uInt8 nProp;
2000-09-18 16:07:07 +00:00
if( DFLT_ESC_AUTO_SUB == rOld.GetEsc() )
{
nEs = DFLT_ESC_AUTO_SUPER;
nProp = rOld.GetProp();
}
else
{
nEs = (short)nTokenValue;
nProp = (nToken == RTF_SUPER) ? DFLT_ESC_PROP : 100;
2000-09-18 16:07:07 +00:00
}
pSet->Put( SvxEscapementItem( nEs, nProp, nEsc ));
}
break;
case RTF_CF:
if( aPlainMap.nColor )
2000-09-18 16:07:07 +00:00
{
pSet->Put( SvxColorItem( GetColor( sal_uInt16(nTokenValue) ),
aPlainMap.nColor ));
2000-09-18 16:07:07 +00:00
}
break;
//#i12501# While cb is clearly documented in the rtf spec, word
//doesn't accept it at all
2011-03-12 18:57:32 -06:00
#if 0
2000-09-18 16:07:07 +00:00
case RTF_CB:
if( aPlainMap.nBgColor )
2000-09-18 16:07:07 +00:00
{
pSet->Put( SvxBrushItem( GetColor( sal_uInt16(nTokenValue) ),
aPlainMap.nBgColor ));
2000-09-18 16:07:07 +00:00
}
break;
#endif
2011-03-12 18:57:32 -06:00
2000-09-18 16:07:07 +00:00
case RTF_LANG:
if( aPlainMap.nLanguage )
2000-09-18 16:07:07 +00:00
{
pSet->Put( SvxLanguageItem( (LanguageType)nTokenValue,
aPlainMap.nLanguage ));
2000-09-18 16:07:07 +00:00
}
break;
2000-11-10 10:34:57 +00:00
case RTF_LANGFE:
if( aPlainMap.nCJKLanguage )
2000-11-10 10:34:57 +00:00
{
pSet->Put( SvxLanguageItem( (LanguageType)nTokenValue,
aPlainMap.nCJKLanguage ));
2000-11-10 10:34:57 +00:00
}
break;
case RTF_ALANG:
{
2001-10-16 16:45:47 +00:00
SvxLanguageItem aTmpItem( (LanguageType)nTokenValue,
SID_ATTR_CHAR_LANGUAGE );
SetScriptAttr( eCharType, *pSet, aTmpItem );
2000-11-10 10:34:57 +00:00
}
break;
case RTF_RTLCH:
bIsLeftToRightDef = false;
break;
case RTF_LTRCH:
bIsLeftToRightDef = true;
break;
case RTF_RTLPAR:
if (aPardMap.nDirection)
{
pSet->Put(SvxFrameDirectionItem(FRMDIR_HORI_RIGHT_TOP,
aPardMap.nDirection));
}
break;
case RTF_LTRPAR:
if (aPardMap.nDirection)
{
pSet->Put(SvxFrameDirectionItem(FRMDIR_HORI_LEFT_TOP,
aPardMap.nDirection));
}
break;
2000-11-10 10:34:57 +00:00
case RTF_LOCH: eCharType = LOW_CHARTYPE; break;
case RTF_HICH: eCharType = HIGH_CHARTYPE; break;
case RTF_DBCH: eCharType = DOUBLEBYTE_CHARTYPE; break;
case RTF_ACCNONE:
eEmphasis = EMPHASISMARK_NONE;
goto ATTR_SETEMPHASIS;
case RTF_ACCDOT:
eEmphasis = EMPHASISMARK_DOTS_ABOVE;
goto ATTR_SETEMPHASIS;
case RTF_ACCCOMMA:
eEmphasis = EMPHASISMARK_SIDE_DOTS;
ATTR_SETEMPHASIS:
if( aPlainMap.nEmphasis )
2000-11-10 10:34:57 +00:00
{
pSet->Put( SvxEmphasisMarkItem( eEmphasis,
aPlainMap.nEmphasis ));
2000-11-10 10:34:57 +00:00
}
break;
2000-11-16 16:55:17 +00:00
case RTF_TWOINONE:
if( aPlainMap.nTwoLines )
2000-11-16 16:55:17 +00:00
{
sal_Unicode cStt, cEnd;
switch ( nTokenValue )
{
case 1: cStt = '(', cEnd = ')'; break;
case 2: cStt = '[', cEnd = ']'; break;
case 3: cStt = '<', cEnd = '>'; break;
case 4: cStt = '{', cEnd = '}'; break;
default: cStt = 0, cEnd = 0; break;
}
pSet->Put( SvxTwoLinesItem( true, cStt, cEnd,
aPlainMap.nTwoLines ));
2000-11-16 16:55:17 +00:00
}
break;
case RTF_CHARSCALEX :
if (aPlainMap.nCharScaleX)
{
//i21372
if (nTokenValue < 1 || nTokenValue > 600)
nTokenValue = 100;
pSet->Put( SvxCharScaleWidthItem( sal_uInt16(nTokenValue),
aPlainMap.nCharScaleX ));
}
break;
case RTF_HORZVERT:
if( aPlainMap.nHorzVert )
{
// RTF knows only 90deg
pSet->Put( SvxCharRotateItem( 900, 1 == nTokenValue,
aPlainMap.nHorzVert ));
}
break;
2001-03-12 15:19:49 +00:00
case RTF_EMBO:
if (aPlainMap.nRelief)
2001-03-12 15:19:49 +00:00
{
pSet->Put(SvxCharReliefItem(RELIEF_EMBOSSED,
aPlainMap.nRelief));
2001-03-12 15:19:49 +00:00
}
break;
case RTF_IMPR:
if (aPlainMap.nRelief)
2001-03-12 15:19:49 +00:00
{
pSet->Put(SvxCharReliefItem(RELIEF_ENGRAVED,
aPlainMap.nRelief));
}
break;
case RTF_V:
if (aPlainMap.nHidden)
{
pSet->Put(SvxCharHiddenItem(nTokenValue != 0,
aPlainMap.nHidden));
2001-03-12 15:19:49 +00:00
}
break;
2001-03-27 20:33:42 +00:00
case RTF_CHBGFDIAG:
case RTF_CHBGDKVERT:
case RTF_CHBGDKHORIZ:
case RTF_CHBGVERT:
case RTF_CHBGHORIZ:
case RTF_CHBGDKFDIAG:
case RTF_CHBGDCROSS:
case RTF_CHBGCROSS:
case RTF_CHBGBDIAG:
case RTF_CHBGDKDCROSS:
case RTF_CHBGDKCROSS:
case RTF_CHBGDKBDIAG:
case RTF_CHCBPAT:
case RTF_CHCFPAT:
case RTF_CHSHDNG:
if( aPlainMap.nBgColor )
2001-03-27 20:33:42 +00:00
ReadBackgroundAttr( nToken, *pSet );
break;
2000-09-18 16:07:07 +00:00
case BRACELEFT:
{
2011-02-16 16:34:02 -05:00
// tests on Swg internal tokens
bool bHandled = false;
2000-09-18 16:07:07 +00:00
short nSkip = 0;
if( RTF_IGNOREFLAG != GetNextToken())
2000-09-18 16:07:07 +00:00
nSkip = -1;
else if( (nToken = GetNextToken() ) & RTF_SWGDEFS )
{
bHandled = true;
2000-09-18 16:07:07 +00:00
switch( nToken )
{
case RTF_PGDSCNO:
case RTF_PGBRK:
case RTF_SOUTLVL:
UnknownAttrToken( nToken, pSet );
2011-02-16 16:34:02 -05:00
// overwrite the closing parenthesis
2000-09-18 16:07:07 +00:00
break;
case RTF_SWG_ESCPROP:
{
2011-02-16 16:34:02 -05:00
// Store percentage change!
sal_uInt8 nProp = sal_uInt8( nTokenValue / 100 );
2000-09-18 16:07:07 +00:00
short nEsc = 0;
if( 1 == ( nTokenValue % 100 ))
2011-02-16 16:34:02 -05:00
// Recognize own auto-flags!
2000-09-18 16:07:07 +00:00
nEsc = DFLT_ESC_AUTO_SUPER;
if( aPlainMap.nEscapement )
2000-09-18 16:07:07 +00:00
pSet->Put( SvxEscapementItem( nEsc, nProp,
aPlainMap.nEscapement ));
2000-09-18 16:07:07 +00:00
}
break;
case RTF_HYPHEN:
{
SvxHyphenZoneItem aHypenZone(
(nTokenValue & 1) != 0,
aPardMap.nHyphenzone );
aHypenZone.SetPageEnd((nTokenValue & 2) != 0);
2000-09-18 16:07:07 +00:00
if( aPardMap.nHyphenzone &&
2000-09-18 16:07:07 +00:00
RTF_HYPHLEAD == GetNextToken() &&
RTF_HYPHTRAIL == GetNextToken() &&
RTF_HYPHMAX == GetNextToken() )
{
aHypenZone.GetMinLead() =
sal_uInt8(GetStackPtr( -2 )->nTokenValue);
2000-09-18 16:07:07 +00:00
aHypenZone.GetMinTrail() =
sal_uInt8(GetStackPtr( -1 )->nTokenValue);
2000-09-18 16:07:07 +00:00
aHypenZone.GetMaxHyphens() =
sal_uInt8(nTokenValue);
2000-09-18 16:07:07 +00:00
pSet->Put( aHypenZone );
}
else
2011-02-16 16:34:02 -05:00
SkipGroup(); // at the end of the group
2000-09-18 16:07:07 +00:00
}
break;
case RTF_SHADOW:
{
bool bSkip = true;
2000-09-18 16:07:07 +00:00
do { // middle check loop
SvxShadowLocation eSL = SvxShadowLocation( nTokenValue );
if( RTF_SHDW_DIST != GetNextToken() )
break;
sal_uInt16 nDist = sal_uInt16( nTokenValue );
2000-09-18 16:07:07 +00:00
if( RTF_SHDW_STYLE != GetNextToken() )
break;
if( RTF_SHDW_COL != GetNextToken() )
break;
sal_uInt16 nCol = sal_uInt16( nTokenValue );
2000-09-18 16:07:07 +00:00
if( RTF_SHDW_FCOL != GetNextToken() )
break;
Color aColor = GetColor( nCol );
if( aPardMap.nShadow )
pSet->Put( SvxShadowItem( aPardMap.nShadow,
2000-09-18 16:07:07 +00:00
&aColor, nDist, eSL ) );
bSkip = false;
} while( false );
2000-09-18 16:07:07 +00:00
if( bSkip )
2011-02-16 16:34:02 -05:00
SkipGroup(); // at the end of the group
2000-09-18 16:07:07 +00:00
}
break;
default:
bHandled = false;
2000-09-18 16:07:07 +00:00
if( (nToken & ~(0xff | RTF_SWGDEFS)) == RTF_TABSTOPDEF )
{
nToken = SkipToken( -2 );
ReadTabAttr( nToken, *pSet );
/*
CWS-TOOLING: integrate CWS hb32bugs01 2009-08-03 22:06:54 +0200 hbrinkm r274599 : resolved warning on unxlngi6 2009-08-03 17:52:32 +0200 hbrinkm r274592 : CWS-TOOLING: rebase CWS hb32bugs01 to trunk@274203 (milestone: DEV300:m53) 2009-08-03 13:52:40 +0200 hbrinkm r274578 : #i102260# applied patches 2009-08-03 11:49:22 +0200 hbrinkm r274570 : #i96371# applied patch 2009-07-24 17:44:05 +0200 hbrinkm r274316 : #i99261# adjust to change in behaviour of DeleteAndJoin 2009-07-24 17:40:30 +0200 hbrinkm r274315 : resolved warnings on wntmsci12 2009-07-17 13:33:22 +0200 hbrinkm r274091 : #i74153# robustness check in SwRTFParser::NextToken 2009-07-06 16:34:52 +0200 hbrinkm r273753 : #97488# applied patch 2009-07-06 16:04:05 +0200 hbrinkm r273750 : #i96875# some robustness changes 2009-06-30 17:06:15 +0200 hbrinkm r273523 : #i99786# applied patch 2009-06-30 14:17:49 +0200 hbrinkm r273505 : #i100918# applied patch 2009-06-18 13:18:08 +0200 hbrinkm r273111 : #i100952# TabCellEnd: Do not remove empty text node if it has SwFrmFmts anchored 2009-06-18 13:14:23 +0200 hbrinkm r273110 : #i100952# SwFltAnchorClient to watch for changes of SwFrmFmt in SwFltAnchor 2009-06-16 13:20:50 +0200 hbrinkm r273018 : #102490# applied patch 2009-06-16 12:51:01 +0200 hbrinkm r273017 : #i102473# applied patch 2009-06-16 10:45:04 +0200 hbrinkm r273009 : #100353# applied patch 2009-06-15 17:39:47 +0200 hbrinkm r273004 : CWS-TOOLING: rebase CWS hb32bugs01 to trunk@272827 (milestone: DEV300:m50) 2009-06-10 14:32:45 +0200 hbrinkm r272812 : CWS-TOOLING: rebase CWS hb32bugs01 to trunk@272291 (milestone: DEV300:m49)
2009-08-25 14:08:24 +00:00
cmc: #i76140, he who consumed the { must consume the }
We rewound to a state of { being the current
CWS-TOOLING: integrate CWS hb32bugs01 2009-08-03 22:06:54 +0200 hbrinkm r274599 : resolved warning on unxlngi6 2009-08-03 17:52:32 +0200 hbrinkm r274592 : CWS-TOOLING: rebase CWS hb32bugs01 to trunk@274203 (milestone: DEV300:m53) 2009-08-03 13:52:40 +0200 hbrinkm r274578 : #i102260# applied patches 2009-08-03 11:49:22 +0200 hbrinkm r274570 : #i96371# applied patch 2009-07-24 17:44:05 +0200 hbrinkm r274316 : #i99261# adjust to change in behaviour of DeleteAndJoin 2009-07-24 17:40:30 +0200 hbrinkm r274315 : resolved warnings on wntmsci12 2009-07-17 13:33:22 +0200 hbrinkm r274091 : #i74153# robustness check in SwRTFParser::NextToken 2009-07-06 16:34:52 +0200 hbrinkm r273753 : #97488# applied patch 2009-07-06 16:04:05 +0200 hbrinkm r273750 : #i96875# some robustness changes 2009-06-30 17:06:15 +0200 hbrinkm r273523 : #i99786# applied patch 2009-06-30 14:17:49 +0200 hbrinkm r273505 : #i100918# applied patch 2009-06-18 13:18:08 +0200 hbrinkm r273111 : #i100952# TabCellEnd: Do not remove empty text node if it has SwFrmFmts anchored 2009-06-18 13:14:23 +0200 hbrinkm r273110 : #i100952# SwFltAnchorClient to watch for changes of SwFrmFmt in SwFltAnchor 2009-06-16 13:20:50 +0200 hbrinkm r273018 : #102490# applied patch 2009-06-16 12:51:01 +0200 hbrinkm r273017 : #i102473# applied patch 2009-06-16 10:45:04 +0200 hbrinkm r273009 : #100353# applied patch 2009-06-15 17:39:47 +0200 hbrinkm r273004 : CWS-TOOLING: rebase CWS hb32bugs01 to trunk@272827 (milestone: DEV300:m50) 2009-06-10 14:32:45 +0200 hbrinkm r272812 : CWS-TOOLING: rebase CWS hb32bugs01 to trunk@272291 (milestone: DEV300:m49)
2009-08-25 14:08:24 +00:00
token so it is our responsibility to consume the }
token if we consumed the {. We will not have consumed
the { if it belonged to our caller, i.e. if the { we
are handling is the "firsttoken" passed to us then
the *caller* must consume it, not us. Otherwise *we*
should consume it.
*/
CWS-TOOLING: integrate CWS hb32bugs01 2009-08-03 22:06:54 +0200 hbrinkm r274599 : resolved warning on unxlngi6 2009-08-03 17:52:32 +0200 hbrinkm r274592 : CWS-TOOLING: rebase CWS hb32bugs01 to trunk@274203 (milestone: DEV300:m53) 2009-08-03 13:52:40 +0200 hbrinkm r274578 : #i102260# applied patches 2009-08-03 11:49:22 +0200 hbrinkm r274570 : #i96371# applied patch 2009-07-24 17:44:05 +0200 hbrinkm r274316 : #i99261# adjust to change in behaviour of DeleteAndJoin 2009-07-24 17:40:30 +0200 hbrinkm r274315 : resolved warnings on wntmsci12 2009-07-17 13:33:22 +0200 hbrinkm r274091 : #i74153# robustness check in SwRTFParser::NextToken 2009-07-06 16:34:52 +0200 hbrinkm r273753 : #97488# applied patch 2009-07-06 16:04:05 +0200 hbrinkm r273750 : #i96875# some robustness changes 2009-06-30 17:06:15 +0200 hbrinkm r273523 : #i99786# applied patch 2009-06-30 14:17:49 +0200 hbrinkm r273505 : #i100918# applied patch 2009-06-18 13:18:08 +0200 hbrinkm r273111 : #i100952# TabCellEnd: Do not remove empty text node if it has SwFrmFmts anchored 2009-06-18 13:14:23 +0200 hbrinkm r273110 : #i100952# SwFltAnchorClient to watch for changes of SwFrmFmt in SwFltAnchor 2009-06-16 13:20:50 +0200 hbrinkm r273018 : #102490# applied patch 2009-06-16 12:51:01 +0200 hbrinkm r273017 : #i102473# applied patch 2009-06-16 10:45:04 +0200 hbrinkm r273009 : #100353# applied patch 2009-06-15 17:39:47 +0200 hbrinkm r273004 : CWS-TOOLING: rebase CWS hb32bugs01 to trunk@272827 (milestone: DEV300:m50) 2009-06-10 14:32:45 +0200 hbrinkm r272812 : CWS-TOOLING: rebase CWS hb32bugs01 to trunk@272291 (milestone: DEV300:m49)
2009-08-25 14:08:24 +00:00
if (nToken == BRACELEFT && !bFirstToken)
{
nToken = GetNextToken();
SAL_WARN_IF( nToken != BRACERIGHT,
"editeng",
"} did not follow { as expected");
}
2000-09-18 16:07:07 +00:00
}
else if( (nToken & ~(0xff| RTF_SWGDEFS)) == RTF_BRDRDEF)
{
nToken = SkipToken( -2 );
ReadBorderAttr( nToken, *pSet );
}
2011-02-16 16:34:02 -05:00
else // so no more attribute
2000-09-18 16:07:07 +00:00
nSkip = -2;
break;
}
#if 1
/*
cmc: #i4727# / #i12713# Who owns this closing bracket?
If we read the opening one, we must read this one, if
other is counting the brackets so as to push/pop off
the correct environment then we will have pushed a new
environment for the start { of this, but will not see
the } and so is out of sync for the rest of the
document.
*/
if (bHandled && !bFirstToken)
GetNextToken();
#endif
2000-09-18 16:07:07 +00:00
}
else
nSkip = -2;
2011-02-16 16:34:02 -05:00
if( nSkip ) // all completely unknown
2000-09-18 16:07:07 +00:00
{
if (!bFirstToken)
2011-02-16 16:34:02 -05:00
--nSkip; // BRACELEFT: is the next token
2000-09-18 16:07:07 +00:00
SkipToken( nSkip );
bContinue = false;
2000-09-18 16:07:07 +00:00
}
}
break;
default:
if( (nToken & ~0xff ) == RTF_TABSTOPDEF )
ReadTabAttr( nToken, *pSet );
else if( (nToken & ~0xff ) == RTF_BRDRDEF )
ReadBorderAttr( nToken, *pSet );
else if( (nToken & ~0xff ) == RTF_SHADINGDEF )
ReadBackgroundAttr( nToken, *pSet );
else
{
2011-02-16 16:34:02 -05:00
// unknown token, so token "returned in Parser"
2000-09-18 16:07:07 +00:00
if( !bFirstToken )
SkipToken( -1 );
bContinue = false;
2000-09-18 16:07:07 +00:00
}
}
}
if( bContinue )
2000-09-18 16:07:07 +00:00
{
nToken = GetNextToken();
}
bFirstToken = false;
2000-09-18 16:07:07 +00:00
}
}
void SvxRTFParser::ReadTabAttr( int nToken, SfxItemSet& rSet )
{
bool bMethodOwnsToken = false; // #i52542# patch from cmc.
2011-02-16 16:34:02 -05:00
// then read all the TabStops
2000-09-18 16:07:07 +00:00
SvxTabStop aTabStop;
SvxTabStopItem aAttr( 0, 0, SVX_TAB_ADJUST_DEFAULT, aPardMap.nTabStop );
bool bContinue = true;
2000-09-18 16:07:07 +00:00
do {
switch( nToken )
{
case RTF_TB: // BarTab ???
case RTF_TX:
{
if( IsCalcValue() )
CalcValue();
aTabStop.GetTabPos() = nTokenValue;
aAttr.Insert( aTabStop );
2011-02-16 16:34:02 -05:00
aTabStop = SvxTabStop(); // all values default
2000-09-18 16:07:07 +00:00
}
break;
case RTF_TQL:
aTabStop.GetAdjustment() = SVX_TAB_ADJUST_LEFT;
break;
case RTF_TQR:
aTabStop.GetAdjustment() = SVX_TAB_ADJUST_RIGHT;
break;
case RTF_TQC:
aTabStop.GetAdjustment() = SVX_TAB_ADJUST_CENTER;
break;
case RTF_TQDEC:
aTabStop.GetAdjustment() = SVX_TAB_ADJUST_DECIMAL;
break;
case RTF_TLDOT: aTabStop.GetFill() = '.'; break;
case RTF_TLHYPH: aTabStop.GetFill() = ' '; break;
case RTF_TLUL: aTabStop.GetFill() = '_'; break;
case RTF_TLTH: aTabStop.GetFill() = '-'; break;
case RTF_TLEQ: aTabStop.GetFill() = '='; break;
case BRACELEFT:
{
2011-02-16 16:34:02 -05:00
// Swg - control BRACELEFT RTF_IGNOREFLAG RTF_TLSWG BRACERIGHT
2000-09-18 16:07:07 +00:00
short nSkip = 0;
if( RTF_IGNOREFLAG != GetNextToken() )
nSkip = -1;
else if( RTF_TLSWG != ( nToken = GetNextToken() ))
nSkip = -2;
else
{
aTabStop.GetDecimal() = sal_uInt8(nTokenValue & 0xff);
aTabStop.GetFill() = sal_uInt8((nTokenValue >> 8) & 0xff);
2011-03-12 18:57:32 -06:00
// overwrite the closing parenthesis
if (bMethodOwnsToken)
GetNextToken();
2000-09-18 16:07:07 +00:00
}
if( nSkip )
{
2011-02-16 16:34:02 -05:00
SkipToken( nSkip ); // Ignore back again
bContinue = false;
2000-09-18 16:07:07 +00:00
}
}
break;
default:
bContinue = false;
2000-09-18 16:07:07 +00:00
}
if( bContinue )
{
2000-09-18 16:07:07 +00:00
nToken = GetNextToken();
bMethodOwnsToken = true;
}
} while( bContinue );
2000-09-18 16:07:07 +00:00
2011-02-16 16:34:02 -05:00
// Fill with defaults is still missing!
2000-09-18 16:07:07 +00:00
rSet.Put( aAttr );
SkipToken( -1 );
}
static void SetBorderLine( int nBorderTyp, SvxBoxItem& rItem,
const SvxBorderLine& rBorder )
{
switch( nBorderTyp )
{
2011-02-16 16:34:02 -05:00
case RTF_BOX: // run through all levels
2000-09-18 16:07:07 +00:00
case RTF_BRDRT:
rItem.SetLine( &rBorder, SvxBoxItemLine::TOP );
2000-09-18 16:07:07 +00:00
if( RTF_BOX != nBorderTyp )
return;
// fall-through
2000-09-18 16:07:07 +00:00
case RTF_BRDRB:
rItem.SetLine( &rBorder, SvxBoxItemLine::BOTTOM );
2000-09-18 16:07:07 +00:00
if( RTF_BOX != nBorderTyp )
return;
// fall-through
2000-09-18 16:07:07 +00:00
case RTF_BRDRL:
rItem.SetLine( &rBorder, SvxBoxItemLine::LEFT );
2000-09-18 16:07:07 +00:00
if( RTF_BOX != nBorderTyp )
return;
// fall-through
2000-09-18 16:07:07 +00:00
case RTF_BRDRR:
rItem.SetLine( &rBorder, SvxBoxItemLine::RIGHT );
2000-09-18 16:07:07 +00:00
if( RTF_BOX != nBorderTyp )
return;
}
}
void SvxRTFParser::ReadBorderAttr( int nToken, SfxItemSet& rSet,
bool bTableDef )
2000-09-18 16:07:07 +00:00
{
2011-02-16 16:34:02 -05:00
// then read the border attribute
SvxBoxItem aAttr( aPardMap.nBox );
2000-09-18 16:07:07 +00:00
const SfxPoolItem* pItem;
if( SfxItemState::SET == rSet.GetItemState( aPardMap.nBox, false, &pItem ) )
aAttr = *static_cast<const SvxBoxItem*>(pItem);
2000-09-18 16:07:07 +00:00
SvxBorderLine aBrd( 0, DEF_LINE_WIDTH_0 ); // Simple plain line
bool bContinue = true;
int nBorderTyp = 0;
2000-09-18 16:07:07 +00:00
long nWidth = 1;
bool bDoubleWidth = false;
2000-09-18 16:07:07 +00:00
do {
switch( nToken )
{
case RTF_BOX:
case RTF_BRDRT:
case RTF_BRDRB:
case RTF_BRDRL:
case RTF_BRDRR:
nBorderTyp = nToken;
break;
case RTF_CLBRDRT: // Cell top border
{
if( bTableDef )
{
if (nBorderTyp != 0)
SetBorderLine( nBorderTyp, aAttr, aBrd );
nBorderTyp = RTF_BRDRT;
}
break;
}
case RTF_CLBRDRB: // Cell bottom border
{
if( bTableDef )
{
if (nBorderTyp != 0)
SetBorderLine( nBorderTyp, aAttr, aBrd );
nBorderTyp = RTF_BRDRB;
}
break;
}
case RTF_CLBRDRL: // Cell left border
{
if( bTableDef )
{
if (nBorderTyp != 0)
SetBorderLine( nBorderTyp, aAttr, aBrd );
nBorderTyp = RTF_BRDRL;
}
break;
}
case RTF_CLBRDRR: // Cell right border
{
if( bTableDef )
{
if (nBorderTyp != 0)
SetBorderLine( nBorderTyp, aAttr, aBrd );
nBorderTyp = RTF_BRDRR;
}
break;
}
case RTF_BRDRDOT: // dotted border
aBrd.SetBorderLineStyle(table::BorderLineStyle::DOTTED);
break;
case RTF_BRDRDASH: // dashed border
aBrd.SetBorderLineStyle(table::BorderLineStyle::DASHED);
break;
case RTF_BRDRHAIR: // hairline border
{
aBrd.SetBorderLineStyle( table::BorderLineStyle::SOLID);
aBrd.SetWidth( DEF_LINE_WIDTH_0 );
}
break;
case RTF_BRDRDB: // Double border
aBrd.SetBorderLineStyle(table::BorderLineStyle::DOUBLE);
break;
case RTF_BRDRINSET: // inset border
aBrd.SetBorderLineStyle(table::BorderLineStyle::INSET);
break;
case RTF_BRDROUTSET: // outset border
aBrd.SetBorderLineStyle(table::BorderLineStyle::OUTSET);
break;
case RTF_BRDRTNTHSG: // ThinThick Small gap
aBrd.SetBorderLineStyle(table::BorderLineStyle::THINTHICK_SMALLGAP);
break;
case RTF_BRDRTNTHMG: // ThinThick Medium gap
aBrd.SetBorderLineStyle(table::BorderLineStyle::THINTHICK_MEDIUMGAP);
break;
case RTF_BRDRTNTHLG: // ThinThick Large gap
aBrd.SetBorderLineStyle(table::BorderLineStyle::THINTHICK_LARGEGAP);
break;
case RTF_BRDRTHTNSG: // ThickThin Small gap
aBrd.SetBorderLineStyle(table::BorderLineStyle::THICKTHIN_SMALLGAP);
break;
case RTF_BRDRTHTNMG: // ThickThin Medium gap
aBrd.SetBorderLineStyle(table::BorderLineStyle::THICKTHIN_MEDIUMGAP);
break;
case RTF_BRDRTHTNLG: // ThickThin Large gap
aBrd.SetBorderLineStyle(table::BorderLineStyle::THICKTHIN_LARGEGAP);
break;
case RTF_BRDREMBOSS: // Embossed border
aBrd.SetBorderLineStyle(table::BorderLineStyle::EMBOSSED);
break;
case RTF_BRDRENGRAVE: // Engraved border
aBrd.SetBorderLineStyle(table::BorderLineStyle::ENGRAVED);
break;
case RTF_BRDRS: // single thickness border
bDoubleWidth = false;
break;
case RTF_BRDRTH: // double thickness border width*2
bDoubleWidth = true;
break;
case RTF_BRDRW: // border width <255
nWidth = nTokenValue;
break;
case RTF_BRDRCF: // Border color
aBrd.SetColor( GetColor( sal_uInt16(nTokenValue) ) );
break;
case RTF_BRDRSH: // Shadowed border
rSet.Put( SvxShadowItem( aPardMap.nShadow, nullptr, 60 /*3pt*/,
SVX_SHADOW_BOTTOMRIGHT ) );
break;
case RTF_BRSP: // Spacing to content in twip
{
switch( nBorderTyp )
{
case RTF_BRDRB:
aAttr.SetDistance( (sal_uInt16)nTokenValue, SvxBoxItemLine::BOTTOM );
break;
case RTF_BRDRT:
aAttr.SetDistance( (sal_uInt16)nTokenValue, SvxBoxItemLine::TOP );
break;
case RTF_BRDRL:
aAttr.SetDistance( (sal_uInt16)nTokenValue, SvxBoxItemLine::LEFT );
break;
case RTF_BRDRR:
aAttr.SetDistance( (sal_uInt16)nTokenValue, SvxBoxItemLine::RIGHT );
break;
case RTF_BOX:
aAttr.SetDistance( (sal_uInt16)nTokenValue );
break;
}
}
break;
case RTF_BRDRBTW: // Border formatting group
case RTF_BRDRBAR: // Border outside
// TODO unhandled ATM
break;
2000-09-18 16:07:07 +00:00
default:
bContinue = (nToken & ~(0xff| RTF_SWGDEFS)) == RTF_BRDRDEF;
2000-09-18 16:07:07 +00:00
}
if( bContinue )
2000-09-18 16:07:07 +00:00
nToken = GetNextToken();
} while( bContinue );
// Finally compute the border width
if ( bDoubleWidth ) nWidth *= 2;
aBrd.SetWidth( nWidth );
SetBorderLine( nBorderTyp, aAttr, aBrd );
2000-09-18 16:07:07 +00:00
rSet.Put( aAttr );
SkipToken( -1 );
}
inline sal_uInt32 CalcShading( sal_uInt32 nColor, sal_uInt32 nFillColor, sal_uInt8 nShading )
2000-09-18 16:07:07 +00:00
{
nColor = (nColor * nShading) / 100;
nFillColor = (nFillColor * ( 100 - nShading )) / 100;
return nColor + nFillColor;
}
2001-03-27 20:33:42 +00:00
void SvxRTFParser::ReadBackgroundAttr( int nToken, SfxItemSet& rSet,
bool bTableDef )
2000-09-18 16:07:07 +00:00
{
2011-02-16 16:34:02 -05:00
// then read the border attribute
bool bContinue = true;
sal_uInt16 nColor = USHRT_MAX, nFillColor = USHRT_MAX;
sal_uInt8 nFillValue = 0;
2000-09-18 16:07:07 +00:00
sal_uInt16 nWh = ( nToken & ~0xff ) == RTF_CHRFMT
? aPlainMap.nBgColor
: aPardMap.nBrush;
2001-03-27 20:33:42 +00:00
2000-09-18 16:07:07 +00:00
do {
switch( nToken )
{
case RTF_CLCBPAT:
2001-03-27 20:33:42 +00:00
case RTF_CHCBPAT:
2000-09-18 16:07:07 +00:00
case RTF_CBPAT:
nFillColor = sal_uInt16( nTokenValue );
2000-09-18 16:07:07 +00:00
break;
case RTF_CLCFPAT:
2001-03-27 20:33:42 +00:00
case RTF_CHCFPAT:
2000-09-18 16:07:07 +00:00
case RTF_CFPAT:
nColor = sal_uInt16( nTokenValue );
2000-09-18 16:07:07 +00:00
break;
case RTF_CLSHDNG:
2001-03-27 20:33:42 +00:00
case RTF_CHSHDNG:
2000-09-18 16:07:07 +00:00
case RTF_SHADING:
nFillValue = (sal_uInt8)( nTokenValue / 100 );
2000-09-18 16:07:07 +00:00
break;
case RTF_CLBGDKHOR:
2001-03-27 20:33:42 +00:00
case RTF_CHBGDKHORIZ:
2000-09-18 16:07:07 +00:00
case RTF_BGDKHORIZ:
case RTF_CLBGDKVERT:
2001-03-27 20:33:42 +00:00
case RTF_CHBGDKVERT:
2000-09-18 16:07:07 +00:00
case RTF_BGDKVERT:
case RTF_CLBGDKBDIAG:
2001-03-27 20:33:42 +00:00
case RTF_CHBGDKBDIAG:
2000-09-18 16:07:07 +00:00
case RTF_BGDKBDIAG:
case RTF_CLBGDKFDIAG:
2001-03-27 20:33:42 +00:00
case RTF_CHBGDKFDIAG:
2000-09-18 16:07:07 +00:00
case RTF_BGDKFDIAG:
case RTF_CLBGDKCROSS:
2001-03-27 20:33:42 +00:00
case RTF_CHBGDKCROSS:
2000-09-18 16:07:07 +00:00
case RTF_BGDKCROSS:
case RTF_CLBGDKDCROSS:
2001-03-27 20:33:42 +00:00
case RTF_CHBGDKDCROSS:
2000-09-18 16:07:07 +00:00
case RTF_BGDKDCROSS:
// dark -> 60%
nFillValue = 60;
break;
case RTF_CLBGHORIZ:
2001-03-27 20:33:42 +00:00
case RTF_CHBGHORIZ:
2000-09-18 16:07:07 +00:00
case RTF_BGHORIZ:
case RTF_CLBGVERT:
2001-03-27 20:33:42 +00:00
case RTF_CHBGVERT:
2000-09-18 16:07:07 +00:00
case RTF_BGVERT:
case RTF_CLBGBDIAG:
2001-03-27 20:33:42 +00:00
case RTF_CHBGBDIAG:
2000-09-18 16:07:07 +00:00
case RTF_BGBDIAG:
case RTF_CLBGFDIAG:
2001-03-27 20:33:42 +00:00
case RTF_CHBGFDIAG:
2000-09-18 16:07:07 +00:00
case RTF_BGFDIAG:
case RTF_CLBGCROSS:
2001-03-27 20:33:42 +00:00
case RTF_CHBGCROSS:
2000-09-18 16:07:07 +00:00
case RTF_BGCROSS:
case RTF_CLBGDCROSS:
2001-03-27 20:33:42 +00:00
case RTF_CHBGDCROSS:
2000-09-18 16:07:07 +00:00
case RTF_BGDCROSS:
// light -> 20%
nFillValue = 20;
break;
default:
if( bTableDef )
bContinue = (nToken & ~(0xff | RTF_TABLEDEF) ) == RTF_SHADINGDEF;
2000-09-18 16:07:07 +00:00
else
bContinue = (nToken & ~0xff) == RTF_SHADINGDEF;
2000-09-18 16:07:07 +00:00
}
if( bContinue )
2000-09-18 16:07:07 +00:00
nToken = GetNextToken();
} while( bContinue );
2000-09-18 16:07:07 +00:00
Color aCol( COL_WHITE ), aFCol;
if( !nFillValue )
{
2011-02-16 16:34:02 -05:00
// there was only one of two colors specified or no BrushTyp
2000-09-18 16:07:07 +00:00
if( USHRT_MAX != nFillColor )
{
nFillValue = 100;
aCol = GetColor( nFillColor );
}
else if( USHRT_MAX != nColor )
aFCol = GetColor( nColor );
}
else
{
if( USHRT_MAX != nColor )
aCol = GetColor( nColor );
else
aCol = Color( COL_BLACK );
if( USHRT_MAX != nFillColor )
aFCol = GetColor( nFillColor );
else
aFCol = Color( COL_WHITE );
}
Color aColor;
if( 0 == nFillValue || 100 == nFillValue )
aColor = aCol;
else
aColor = Color(
(sal_uInt8)CalcShading( aCol.GetRed(), aFCol.GetRed(), nFillValue ),
(sal_uInt8)CalcShading( aCol.GetGreen(), aFCol.GetGreen(), nFillValue ),
(sal_uInt8)CalcShading( aCol.GetBlue(), aFCol.GetBlue(), nFillValue ) );
2000-09-18 16:07:07 +00:00
2001-03-27 20:33:42 +00:00
rSet.Put( SvxBrushItem( aColor, nWh ) );
2000-09-18 16:07:07 +00:00
SkipToken( -1 );
}
// pard / plain handling
void SvxRTFParser::RTFPardPlain( bool const bPard, SfxItemSet** ppSet )
2000-09-18 16:07:07 +00:00
{
2010-11-19 14:24:51 +01:00
if( !bNewGroup && !aAttrStack.empty() ) // not at the beginning of a new group
2000-09-18 16:07:07 +00:00
{
SvxRTFItemStackType* pAkt = aAttrStack.back();
2000-09-18 16:07:07 +00:00
int nLastToken = GetStackPtr(-1)->nTokenId;
bool bNewStkEntry = true;
2000-09-18 16:07:07 +00:00
if( RTF_PARD != nLastToken &&
RTF_PLAIN != nLastToken &&
BRACELEFT != nLastToken )
{
if( pAkt->aAttrSet.Count() || pAkt->pChildList || pAkt->nStyleNo )
{
2011-02-16 16:34:02 -05:00
// open a new group
SvxRTFItemStackType* pNew = new SvxRTFItemStackType( *pAkt, *pInsPos, true );
pNew->SetRTFDefaults( GetRTFDefaults() );
2011-02-16 16:34:02 -05:00
// Set all until here valid attributes
2000-09-18 16:07:07 +00:00
AttrGroupEnd();
2010-11-19 14:24:51 +01:00
pAkt = aAttrStack.empty() ? 0 : aAttrStack.back(); // can be changed after AttrGroupEnd!
pNew->aAttrSet.SetParent( pAkt ? &pAkt->aAttrSet : 0 );
aAttrStack.push_back( pNew );
2000-09-18 16:07:07 +00:00
pAkt = pNew;
}
else
{
2011-02-16 16:34:02 -05:00
// continue to use this entry as new
2000-09-18 16:07:07 +00:00
pAkt->SetStartPos( *pInsPos );
bNewStkEntry = false;
2000-09-18 16:07:07 +00:00
}
}
2011-02-16 16:34:02 -05:00
// now reset all to default
2000-09-18 16:07:07 +00:00
if( bNewStkEntry &&
( pAkt->aAttrSet.GetParent() || pAkt->aAttrSet.Count() ))
{
const SfxPoolItem *pItem, *pDef;
const sal_uInt16* pPtr;
sal_uInt16 nCnt;
const SfxItemSet* pDfltSet = &GetRTFDefaults();
2000-09-18 16:07:07 +00:00
if( bPard )
{
pAkt->nStyleNo = 0;
pPtr = reinterpret_cast<sal_uInt16*>(&aPardMap);
nCnt = sizeof(aPardMap) / sizeof(sal_uInt16);
2000-09-18 16:07:07 +00:00
}
else
{
pPtr = reinterpret_cast<sal_uInt16*>(&aPlainMap);
nCnt = sizeof(aPlainMap) / sizeof(sal_uInt16);
2000-09-18 16:07:07 +00:00
}
for( sal_uInt16 n = 0; n < nCnt; ++n, ++pPtr )
2000-09-18 16:07:07 +00:00
{
2011-02-16 16:34:02 -05:00
// Item set and different -> Set the Default Pool
2000-09-18 16:07:07 +00:00
if( !*pPtr )
;
else if( SFX_WHICH_MAX < *pPtr )
pAkt->aAttrSet.ClearItem( *pPtr );
else if( IsChkStyleAttr() )
pAkt->aAttrSet.Put( pDfltSet->Get( *pPtr ) );
2000-09-18 16:07:07 +00:00
else if( !pAkt->aAttrSet.GetParent() )
{
if( SfxItemState::SET ==
pDfltSet->GetItemState( *pPtr, false, &pDef ))
pAkt->aAttrSet.Put( *pDef );
else
pAkt->aAttrSet.ClearItem( *pPtr );
}
else if( SfxItemState::SET == pAkt->aAttrSet.GetParent()->
GetItemState( *pPtr, true, &pItem ) &&
*( pDef = &pDfltSet->Get( *pPtr )) != *pItem )
2000-09-18 16:07:07 +00:00
pAkt->aAttrSet.Put( *pDef );
else
{
if( SfxItemState::SET ==
pDfltSet->GetItemState( *pPtr, false, &pDef ))
pAkt->aAttrSet.Put( *pDef );
else
pAkt->aAttrSet.ClearItem( *pPtr );
}
2000-09-18 16:07:07 +00:00
}
}
else if( bPard )
2011-02-16 16:34:02 -05:00
pAkt->nStyleNo = 0; // reset Style number
2000-09-18 16:07:07 +00:00
*ppSet = &pAkt->aAttrSet;
if (!bPard)
{
//Once we have a default font, then any text without a font specifier is
//in the default font, and thus has the default font charset, otherwise
//we can fall back to the ansicpg set codeset
if (nDfltFont != -1)
{
const vcl::Font& rSVFont = GetFont(sal_uInt16(nDfltFont));
SetEncoding(rSVFont.GetCharSet());
}
else
SetEncoding(GetCodeSet());
}
2000-09-18 16:07:07 +00:00
}
}
void SvxRTFParser::SetDefault( int nToken, int nValue )
2000-09-18 16:07:07 +00:00
{
if( !bNewDoc )
return;
2011-10-29 13:24:48 +02:00
SfxItemSet aTmp( *pAttrPool, &aWhichMap[0] );
bool bOldFlag = bIsLeftToRightDef;
bIsLeftToRightDef = true;
2000-09-18 16:07:07 +00:00
switch( nToken )
{
case RTF_ADEFF: bIsLeftToRightDef = false; // no break!
2000-09-18 16:07:07 +00:00
case RTF_DEFF:
{
if( -1 == nValue )
nValue = 0;
const vcl::Font& rSVFont = GetFont( sal_uInt16(nValue) );
2001-10-16 16:45:47 +00:00
SvxFontItem aTmpItem(
rSVFont.GetFamily(), rSVFont.GetName(),
rSVFont.GetStyleName(), rSVFont.GetPitch(),
2001-10-16 16:45:47 +00:00
rSVFont.GetCharSet(), SID_ATTR_CHAR_FONT );
SetScriptAttr( NOTDEF_CHARTYPE, aTmp, aTmpItem );
2000-09-18 16:07:07 +00:00
}
break;
case RTF_ADEFLANG: bIsLeftToRightDef = false; // no break!
2000-09-18 16:07:07 +00:00
case RTF_DEFLANG:
2011-02-16 16:34:02 -05:00
// store default Language
if( -1 != nValue )
2000-09-18 16:07:07 +00:00
{
2001-10-16 16:45:47 +00:00
SvxLanguageItem aTmpItem( (const LanguageType)nValue,
SID_ATTR_CHAR_LANGUAGE );
SetScriptAttr( NOTDEF_CHARTYPE, aTmp, aTmpItem );
2000-09-18 16:07:07 +00:00
}
break;
case RTF_DEFTAB:
if( aPardMap.nTabStop )
2000-09-18 16:07:07 +00:00
{
2011-02-16 16:34:02 -05:00
// RTF defines 720 twips as default
bIsSetDfltTab = true;
2000-09-18 16:07:07 +00:00
if( -1 == nValue || !nValue )
nValue = 720;
2011-02-16 16:34:02 -05:00
// who would like to have no twips ...
2000-09-18 16:07:07 +00:00
if( IsCalcValue() )
{
nTokenValue = nValue;
CalcValue();
nValue = nTokenValue;
2000-09-18 16:07:07 +00:00
}
2011-02-16 16:34:02 -05:00
// Calculate the ratio of default TabWidth / Tabs and
// calculate the corresponding new number.
// ?? how did one come up with 13 ??
sal_uInt16 nTabCount = (SVX_TAB_DEFDIST * 13 ) / sal_uInt16(nValue);
/*
cmc, make sure we have at least one, or all hell breaks loose in
everybodies exporters, #i8247#
*/
if (nTabCount < 1)
nTabCount = 1;
2000-09-18 16:07:07 +00:00
2011-02-16 16:34:02 -05:00
// we want Defaulttabs
SvxTabStopItem aNewTab( nTabCount, sal_uInt16(nValue),
SVX_TAB_ADJUST_DEFAULT, aPardMap.nTabStop );
while( nTabCount )
((SvxTabStop&)aNewTab[ --nTabCount ]).GetAdjustment() = SVX_TAB_ADJUST_DEFAULT;
2000-09-18 16:07:07 +00:00
pAttrPool->SetPoolDefaultItem( aNewTab );
}
break;
}
bIsLeftToRightDef = bOldFlag;
if( aTmp.Count() )
{
SfxItemIter aIter( aTmp );
const SfxPoolItem* pItem = aIter.GetCurItem();
while( true )
{
pAttrPool->SetPoolDefaultItem( *pItem );
if( aIter.IsAtEnd() )
break;
pItem = aIter.NextItem();
}
}
2000-09-18 16:07:07 +00:00
}
2011-02-16 16:34:02 -05:00
// default: no conversion, leaving everything in twips.
2000-09-18 16:07:07 +00:00
void SvxRTFParser::CalcValue()
{
}
2011-02-16 16:34:02 -05:00
// for tokens that are not evaluated in ReadAttr
void SvxRTFParser::UnknownAttrToken( int, SfxItemSet* )
2000-09-18 16:07:07 +00:00
{
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */