diff options
-rw-r--r-- | sw/inc/fchrfmt.hxx | 10 | ||||
-rw-r--r-- | sw/inc/fmtfsize.hxx | 9 | ||||
-rw-r--r-- | sw/inc/fmtlsplt.hxx | 9 | ||||
-rw-r--r-- | sw/inc/fmtornt.hxx | 14 | ||||
-rw-r--r-- | sw/inc/fmtpdsc.hxx | 11 | ||||
-rw-r--r-- | sw/inc/paratr.hxx | 14 | ||||
-rw-r--r-- | sw/source/filter/xml/makefile.mk | 10 | ||||
-rw-r--r-- | sw/source/filter/xml/xmlbrsh.cxx | 39 | ||||
-rw-r--r-- | sw/source/filter/xml/xmlexpit.cxx | 706 | ||||
-rw-r--r-- | sw/source/filter/xml/xmlexpit.hxx | 8 | ||||
-rw-r--r-- | sw/source/filter/xml/xmlimpit.cxx | 759 | ||||
-rw-r--r-- | sw/source/filter/xml/xmlimpit.hxx | 13 | ||||
-rw-r--r-- | sw/source/filter/xml/xmliteme.cxx | 11 | ||||
-rw-r--r-- | sw/source/filter/xml/xmlitemi.cxx | 7 | ||||
-rw-r--r-- | sw/source/filter/xml/xmlithlp.cxx | 489 | ||||
-rw-r--r-- | sw/source/filter/xml/xmlithlp.hxx | 138 | ||||
-rw-r--r-- | sw/source/filter/xml/xmltble.cxx | 10 |
17 files changed, 2161 insertions, 96 deletions
diff --git a/sw/inc/fchrfmt.hxx b/sw/inc/fchrfmt.hxx index 45b4af767965..b9f116a71682 100644 --- a/sw/inc/fchrfmt.hxx +++ b/sw/inc/fchrfmt.hxx @@ -2,9 +2,9 @@ * * $RCSfile: fchrfmt.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: er $ $Date: 2001-05-13 03:32:47 $ + * last change: $Author: dvo $ $Date: 2001-07-09 20:10:42 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -101,12 +101,6 @@ public: virtual BOOL QueryValue( com::sun::star::uno::Any& rVal, BYTE nMemberId = 0 ) const; virtual BOOL PutValue( const com::sun::star::uno::Any& rVal, BYTE nMemberId = 0 ); - // - // XML import cannot be done using importXML, because the SwCharFmt's - // name must be adjusted according to the pool id and access to the SwDoc - // is required. - virtual BOOL exportXML( rtl::OUString& rValue, USHORT, - const SvXMLUnitConverter& ) const; // an das SwTxtCharFmt weiterleiten (vom SwClient) virtual void Modify( SfxPoolItem*, SfxPoolItem* ); diff --git a/sw/inc/fmtfsize.hxx b/sw/inc/fmtfsize.hxx index 5c96e750747d..4eb5a5e06d4b 100644 --- a/sw/inc/fmtfsize.hxx +++ b/sw/inc/fmtfsize.hxx @@ -2,9 +2,9 @@ * * $RCSfile: fmtfsize.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: er $ $Date: 2001-05-13 03:32:47 $ + * last change: $Author: dvo $ $Date: 2001-07-09 20:10:42 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -149,11 +149,6 @@ public: const SvxULSpaceItem *pULSpace ) const; Size GetSizeConvertedFromSw31( const SvxLRSpaceItem *pLRSpace, const SvxULSpaceItem *pULSpace ) const; - - virtual BOOL importXML( const ::rtl::OUString& rValue,USHORT, - const SvXMLUnitConverter& rUnitConv ); - virtual BOOL exportXML( ::rtl::OUString& rValue, USHORT, - const SvXMLUnitConverter& rUnitConv ) const; }; inline const SwFmtFrmSize &SwAttrSet::GetFrmSize(BOOL bInP) const diff --git a/sw/inc/fmtlsplt.hxx b/sw/inc/fmtlsplt.hxx index f4f79145067f..298ddb587a5d 100644 --- a/sw/inc/fmtlsplt.hxx +++ b/sw/inc/fmtlsplt.hxx @@ -2,9 +2,9 @@ * * $RCSfile: fmtlsplt.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: er $ $Date: 2001-05-13 03:32:47 $ + * last change: $Author: dvo $ $Date: 2001-07-09 20:10:42 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -87,11 +87,6 @@ public: String &rText, const IntlWrapper* pIntl = 0 ) const; virtual USHORT GetVersion( USHORT nFFVer ) const; - - virtual BOOL importXML( const ::rtl::OUString& rValue,USHORT, - const SvXMLUnitConverter& rUnitConv ); - virtual BOOL exportXML( ::rtl::OUString& rValue, USHORT, - const SvXMLUnitConverter& rUnitConv ) const; }; inline const SwFmtLayoutSplit &SwAttrSet::GetLayoutSplit(BOOL bInP) const diff --git a/sw/inc/fmtornt.hxx b/sw/inc/fmtornt.hxx index f383c0567dcd..92f45c95c2f9 100644 --- a/sw/inc/fmtornt.hxx +++ b/sw/inc/fmtornt.hxx @@ -2,9 +2,9 @@ * * $RCSfile: fmtornt.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: er $ $Date: 2001-05-13 03:32:47 $ + * last change: $Author: dvo $ $Date: 2001-07-09 20:10:42 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -116,11 +116,6 @@ public: SwTwips GetPosConvertedToSw31( const SvxULSpaceItem *pULSpace ) const; SwTwips GetPosConvertedFromSw31( const SvxULSpaceItem *pULSpace ) const; - - virtual BOOL importXML( const ::rtl::OUString& rValue,USHORT, - const SvXMLUnitConverter& rUnitConv ); - virtual BOOL exportXML( ::rtl::OUString& rValue, USHORT, - const SvXMLUnitConverter& rUnitConv ) const; }; //SwFmtHoriOrient, wie und woran orientiert -- @@ -168,11 +163,6 @@ public: BOOL IsPosToggle() const { return bPosToggle; } void SetPosToggle( BOOL bNew ) { bPosToggle = bNew; } - - virtual BOOL importXML( const ::rtl::OUString& rValue,USHORT, - const SvXMLUnitConverter& rUnitConv ); - virtual BOOL exportXML( ::rtl::OUString& rValue, USHORT, - const SvXMLUnitConverter& rUnitConv ) const; }; inline SwFmtVertOrient &SwFmtVertOrient::operator=( const SwFmtVertOrient &rCpy ) diff --git a/sw/inc/fmtpdsc.hxx b/sw/inc/fmtpdsc.hxx index b0f90cf33ad0..a1f63772042b 100644 --- a/sw/inc/fmtpdsc.hxx +++ b/sw/inc/fmtpdsc.hxx @@ -2,9 +2,9 @@ * * $RCSfile: fmtpdsc.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: er $ $Date: 2001-05-13 03:32:47 $ + * last change: $Author: dvo $ $Date: 2001-07-09 20:10:42 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -134,13 +134,6 @@ public: // fuer den SW3-Reader: USHORT GetDescNameIdx() const { return nDescNameIdx; } void SetDescNameIdx( USHORT n ) { nDescNameIdx = n; } - // - // this item must be ignored while comparing item sets during XML export - virtual BOOL equalsXML( const SfxPoolItem& ) const; - virtual BOOL importXML( const ::rtl::OUString& rValue,USHORT, - const SvXMLUnitConverter& rUnitConv ); - virtual BOOL exportXML( ::rtl::OUString& rValue, USHORT, - const SvXMLUnitConverter& rUnitConv ) const; }; inline const SwFmtPageDesc &SwAttrSet::GetPageDesc(BOOL bInP) const diff --git a/sw/inc/paratr.hxx b/sw/inc/paratr.hxx index b9cf67b50503..51b32bddd140 100644 --- a/sw/inc/paratr.hxx +++ b/sw/inc/paratr.hxx @@ -2,9 +2,9 @@ * * $RCSfile: paratr.hxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: er $ $Date: 2001-05-13 03:32:47 $ + * last change: $Author: dvo $ $Date: 2001-07-09 20:10:42 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -154,9 +154,6 @@ public: inline const SwModify* GetDefinedIn() const { return pDefinedIn; } inline void ChgDefinedIn( const SwModify* pNew ) { pDefinedIn = (SwModify*)pNew; } - - // this item must be ignored while comparing item sets during XML export - virtual BOOL equalsXML( const SfxPoolItem& ) const; }; class SwRegisterItem : public SfxBoolItem @@ -178,10 +175,6 @@ public: const IntlWrapper* pIntl = 0 ) const; virtual USHORT GetVersion( USHORT nFFVer ) const; - virtual BOOL importXML( const ::rtl::OUString& rValue,USHORT, - const SvXMLUnitConverter& rUnitConv ); - virtual BOOL exportXML( ::rtl::OUString& rValue, USHORT, - const SvXMLUnitConverter& rUnitConv ) const; }; inline SwRegisterItem::SwRegisterItem( const BOOL bRegister ) : @@ -230,9 +223,6 @@ public: virtual BOOL QueryValue( com::sun::star::uno::Any& rVal, BYTE nMemberId ) const; virtual BOOL PutValue( const com::sun::star::uno::Any& rVal, BYTE nMemberId ); - // this item must be ignored while comparing item sets during XML export - virtual BOOL equalsXML( const SfxPoolItem& ) const; - // erfrage und setze den Modify-Pointer inline const SwModify* GetDefinedIn() const { return pDefinedIn; } inline void ChgDefinedIn( const SwModify* pNew ) diff --git a/sw/source/filter/xml/makefile.mk b/sw/source/filter/xml/makefile.mk index 4cbc91fb218b..9eef74e90f9a 100644 --- a/sw/source/filter/xml/makefile.mk +++ b/sw/source/filter/xml/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.9 $ +# $Revision: 1.10 $ # -# last change: $Author: mib $ $Date: 2001-07-05 09:50:51 $ +# last change: $Author: dvo $ $Date: 2001-07-09 20:10:42 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -96,11 +96,11 @@ CXXFILES = \ xmlitemm.cxx \ xmlitemi.cxx \ xmliteme.cxx \ - swxmlat.cxx \ xmlbrsh.cxx \ xmlfonte.cxx \ XMLRedlineImportHelper.cxx \ xmlitem.cxx \ + xmlithlp.cxx \ xmlitmpr.cxx \ xmlimpit.cxx \ xmlexpit.cxx @@ -122,7 +122,7 @@ SLOFILES = \ $(SLO)$/xmlitemm.obj \ $(SLO)$/xmlitemi.obj \ $(SLO)$/xmliteme.obj \ - $(SLO)$/swxmlat.obj \ + $(SLO)$/xmlithlp.obj \ $(SLO)$/xmlbrsh.obj \ $(SLO)$/xmlfonte.obj \ $(SLO)$/XMLRedlineImportHelper.obj \ @@ -146,7 +146,7 @@ EXCEPTIONSFILES= \ $(SLO)$/xmlscript.obj \ $(SLO)$/xmlitemi.obj \ $(SLO)$/xmliteme.obj \ - $(SLO)$/swxmlat.obj \ + $(SLO)$/xmlithlp.obj \ $(SLO)$/xmlbrsh.obj \ $(SLO)$/xmlfonte.obj \ $(SLO)$/XMLRedlineImportHelper.obj diff --git a/sw/source/filter/xml/xmlbrsh.cxx b/sw/source/filter/xml/xmlbrsh.cxx index 80b20a67fe9a..a89ccc6dc718 100644 --- a/sw/source/filter/xml/xmlbrsh.cxx +++ b/sw/source/filter/xml/xmlbrsh.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmlbrsh.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: mib $ $Date: 2001-06-25 11:02:24 $ + * last change: $Author: dvo $ $Date: 2001-07-09 20:10:42 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -93,6 +93,8 @@ #include "xmlbrshi.hxx" #include "xmlbrshe.hxx" #include "xmlexp.hxx" +#include "xmlimpit.hxx" +#include "xmlexpit.hxx" using namespace ::rtl; using namespace ::com::sun::star; @@ -144,21 +146,25 @@ void SwXMLBrushItemImportContext::ProcessAttrs( switch( aTokenMap.Get( nPrefix, aLocalName ) ) { case XML_TOK_BGIMG_HREF: - pItem->importXML( GetImport().ResolveGraphicObjectURL( rValue,sal_False), - MID_GRAPHIC_LINK, rUnitConv ); + SvXMLImportItemMapper::PutXMLValue( + *pItem, GetImport().ResolveGraphicObjectURL( rValue,sal_False), + MID_GRAPHIC_LINK, rUnitConv ); break; case XML_TOK_BGIMG_TYPE: case XML_TOK_BGIMG_ACTUATE: case XML_TOK_BGIMG_SHOW: break; case XML_TOK_BGIMG_POSITION: - pItem->importXML( rValue, MID_GRAPHIC_POSITION, rUnitConv ); + SvXMLImportItemMapper::PutXMLValue( + *pItem, rValue, MID_GRAPHIC_POSITION, rUnitConv ); break; case XML_TOK_BGIMG_REPEAT: - pItem->importXML( rValue, MID_GRAPHIC_REPEAT, rUnitConv ); + SvXMLImportItemMapper::PutXMLValue( + *pItem, rValue, MID_GRAPHIC_REPEAT, rUnitConv ); break; case XML_TOK_BGIMG_FILTER: - pItem->importXML( rValue, MID_GRAPHIC_FILTER, rUnitConv ); + SvXMLImportItemMapper::PutXMLValue( + *pItem, rValue, MID_GRAPHIC_FILTER, rUnitConv ); break; } } @@ -196,7 +202,7 @@ void SwXMLBrushItemImportContext::EndElement() { OUString sURL( GetImport().ResolveGraphicObjectURLFromBase64( xBase64Stream ) ); xBase64Stream = 0; - pItem->importXML( sURL, MID_GRAPHIC_LINK, GetImport().GetMM100UnitConverter() ); + SvXMLImportItemMapper::PutXMLValue( *pItem, sURL, MID_GRAPHIC_LINK, GetImport().GetMM100UnitConverter() ); } if( !(pItem->GetGraphicLink() || pItem->GetGraphic() ) ) @@ -253,7 +259,8 @@ void SwXMLBrushItemExport::exportXML( const SvxBrushItem& rItem ) OUString sValue, sURL; const SvXMLUnitConverter& rUnitConv = GetExport().GetTwipUnitConverter(); - if( rItem.exportXML( sURL, MID_GRAPHIC_LINK, rUnitConv ) ) + if( SvXMLExportItemMapper::QueryXMLValue( + rItem, sURL, MID_GRAPHIC_LINK, rUnitConv ) ) { sValue = GetExport().AddEmbeddedGraphicObject( sURL ); if( sValue.getLength() ) @@ -264,13 +271,16 @@ void SwXMLBrushItemExport::exportXML( const SvxBrushItem& rItem ) GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD ); } - if( rItem.exportXML( sValue, MID_GRAPHIC_POSITION, rUnitConv ) ) + if( SvXMLExportItemMapper::QueryXMLValue( + rItem, sValue, MID_GRAPHIC_POSITION, rUnitConv ) ) GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_POSITION, sValue ); - if( rItem.exportXML( sValue, MID_GRAPHIC_REPEAT, rUnitConv ) ) + if( SvXMLExportItemMapper::QueryXMLValue( + rItem, sValue, MID_GRAPHIC_REPEAT, rUnitConv ) ) GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_REPEAT, sValue ); - if( rItem.exportXML( sValue, MID_GRAPHIC_FILTER, rUnitConv ) ) + if( SvXMLExportItemMapper::QueryXMLValue( + rItem, sValue, MID_GRAPHIC_FILTER, rUnitConv ) ) GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_FILTER_NAME, sValue ); } @@ -289,11 +299,14 @@ void SwXMLBrushItemExport::exportXML( const SvxBrushItem& rItem ) Source Code Control ::com::sun::star::chaos::System - Header - $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/xmlbrsh.cxx,v 1.5 2001-06-25 11:02:24 mib Exp $ + $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/xmlbrsh.cxx,v 1.6 2001-07-09 20:10:42 dvo Exp $ Source Code Control ::com::sun::star::chaos::System - Update $Log: not supported by cvs2svn $ + Revision 1.5 2001/06/25 11:02:24 mib + #87313#: embedded images as BASE64 + Revision 1.4 2001/06/18 17:27:51 dvo #86004# - changed SvXMLItemMaps to use XMLTokenEnum diff --git a/sw/source/filter/xml/xmlexpit.cxx b/sw/source/filter/xml/xmlexpit.cxx index 77460ba87c31..c28cd6787e9b 100644 --- a/sw/source/filter/xml/xmlexpit.cxx +++ b/sw/source/filter/xml/xmlexpit.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmlexpit.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: mib $ $Date: 2001-07-04 14:14:26 $ + * last change: $Author: dvo $ $Date: 2001-07-09 20:10:42 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -104,6 +104,73 @@ #include <svtools/svstdarr.hxx> #endif + + +#ifndef _HINTIDS_HXX +#include "hintids.hxx" +#endif + +#ifndef SW_UNOMID_HXX +#include "unomid.h" +#endif + +#ifndef _SVX_UNOMID_HXX +#include <svx/unomid.hxx> +#endif + +#ifndef _SVX_LRSPITEM_HXX +#include <svx/lrspitem.hxx> +#endif + +#ifndef _SVX_ULSPITEM_HXX +#include <svx/ulspitem.hxx> +#endif + +#ifndef _SVX_SHADITEM_HXX +#include <svx/shaditem.hxx> +#endif + +#ifndef _SVX_BOXITEM_HXX +#include <svx/boxitem.hxx> +#endif + +#ifndef _SVX_BRKITEM_HXX +#include <svx/brkitem.hxx> +#endif + +#ifndef _SVX_KEEPITEM_HXX +#include <svx/keepitem.hxx> +#endif + +#ifndef _SVX_BRSHITEM_HXX +#include <svx/brshitem.hxx> +#endif + +#ifndef _FMTPDSC_HXX +#include "fmtpdsc.hxx" +#endif + +#ifndef _FMTORNT_HXX +#include "fmtornt.hxx" +#endif + +#ifndef _FMTFSIZE_HXX +#include "fmtfsize.hxx" +#endif + +#ifndef _FMTLSPLT_HXX +#include "fmtlsplt.hxx" +#endif + +#ifndef _XMLOFF_XMLTOKEN_HXX +#include <xmloff/xmltoken.hxx> +#endif + +#ifndef _SW_XMLITHLP_HXX +#include "xmlithlp.hxx" +#endif + + using namespace ::rtl; using namespace ::com::sun::star; using namespace ::xmloff::token; @@ -225,7 +292,7 @@ void SvXMLExportItemMapper::exportXML( SvXMLAttributeList& rAttrList, else if( 0 == (rEntry.nMemberId & MID_FLAG_ELEMENT_ITEM_EXPORT) ) { OUString aValue; - if( rItem.exportXML( aValue, rEntry.nMemberId & MID_FLAG_MASK, + if( QueryXMLValue(rItem, aValue, rEntry.nMemberId & MID_FLAG_MASK, rUnitConverter ) ) { OUString sName( @@ -419,3 +486,636 @@ void SvXMLExportItemMapper::handleElementItem( DBG_ERROR( "element item not handled in xml export" ); } + +sal_Bool SvXMLExportItemMapper::QueryXMLValue( + const SfxPoolItem& rItem, + OUString& rValue, + sal_uInt16 nMemberId, + const SvXMLUnitConverter& rUnitConverter ) +{ + sal_Bool bOk = sal_False; + OUStringBuffer aOut; + + switch ( rItem.Which() ) + { + + case ITEMID_LRSPACE: + { + const SvxLRSpaceItem* pLRSpace = PTR_CAST(SvxLRSpaceItem, &rItem); + DBG_ASSERT( pLRSpace != NULL, "Wrong Which-ID!" ); + + sal_Bool bOk = sal_True; + switch( nMemberId ) + { + case MID_L_MARGIN: + if(pLRSpace->GetPropLeft() != 100) + rUnitConverter.convertPercent( aOut, pLRSpace->GetPropLeft() ); + else + rUnitConverter.convertMeasure( aOut, pLRSpace->GetTxtLeft() ); + break; + + case MID_R_MARGIN: + if(pLRSpace->GetPropRight() != 100) + rUnitConverter.convertPercent( aOut, pLRSpace->GetPropRight() ); + else + rUnitConverter.convertMeasure( aOut, pLRSpace->GetRight() ); + break; + + case MID_FIRST_AUTO: + if( pLRSpace->IsAutoFirst() ) + rUnitConverter.convertBool( aOut, pLRSpace->IsAutoFirst() ); + else + bOk = sal_False; + break; + + case MID_FIRST_LINE_INDENT: + if( !pLRSpace->IsAutoFirst() ) + { + if(pLRSpace->GetPropTxtFirstLineOfst() != 100) + rUnitConverter.convertPercent( + aOut, pLRSpace->GetPropTxtFirstLineOfst() ); + else + rUnitConverter.convertMeasure( aOut, pLRSpace->GetTxtFirstLineOfst() ); + } + else + bOk = sal_False; + break; + + default: + DBG_ERROR( "unknown member id!"); + bOk = sal_False; + break; + } + } + break; + + case ITEMID_ULSPACE: + { + const SvxULSpaceItem* pULSpace = PTR_CAST(SvxULSpaceItem, &rItem); + DBG_ASSERT( pULSpace != NULL, "Wrong Which-ID!" ); + + switch( nMemberId ) + { + case MID_UP_MARGIN: + if( pULSpace->GetPropUpper() != 100 ) + rUnitConverter.convertPercent( aOut, pULSpace->GetPropUpper() ); + else + rUnitConverter.convertMeasure( aOut, pULSpace->GetUpper() ); + break; + + case MID_LO_MARGIN: + if( pULSpace->GetPropLower() != 100 ) + rUnitConverter.convertPercent( aOut, pULSpace->GetPropLower() ); + else + rUnitConverter.convertMeasure( aOut, pULSpace->GetLower() ); + break; + + default: + DBG_ERROR("unknown MemberId"); + }; + + bOk = sal_True; + } + break; + + case ITEMID_SHADOW: + { + const SvxShadowItem* pShadow = PTR_CAST(SvxShadowItem, &rItem); + DBG_ASSERT( pShadow != NULL, "Wrong Which-ID" ); + + sal_Int32 nX = 1, nY = 1; + switch( pShadow->GetLocation() ) + { + case SVX_SHADOW_TOPLEFT: + nX = -1; + nY = -1; + break; + case SVX_SHADOW_TOPRIGHT: + nY = -1; + break; + case SVX_SHADOW_BOTTOMLEFT: + nX = -1; + break; + case SVX_SHADOW_BOTTOMRIGHT: + break; + case SVX_SHADOW_NONE: + default: + rValue = GetXMLToken(XML_NONE); + return sal_True; + } + + nX *= pShadow->GetWidth(); + nY *= pShadow->GetWidth(); + + rUnitConverter.convertColor( aOut, pShadow->GetColor() ); + aOut.append( sal_Unicode(' ') ); + rUnitConverter.convertMeasure( aOut, nX ); + aOut.append( sal_Unicode(' ') ); + rUnitConverter.convertMeasure( aOut, nY ); + + bOk = sal_True; + } + break; + + case ITEMID_BOX: + { + SvxBoxItem* pBox = PTR_CAST(SvxBoxItem, &rItem); + DBG_ASSERT( pBox != NULL, "Wrong WHich-ID" ); + + /** + xml -> MemberId + + border-padding ALL_BORDER_PADDING + border-padding-before LEFT_BORDER_PADDING + border-padding-after RIGHT_BORDER_PADDING + border-padding-start TOP_BORDER_PADDING + border-padding-end BOTTOM_BORDER_PADDING + + border ALL_BORDER + border-before LEFT_BORDER + border-after RIGHT_BORDER + border-start TOP_BORDER + border-end BOTTOM_BORDER + + border-line-width ALL_BORDER_LINE_WIDTH + border-line-width-before LEFT_BORDER_LINE_WIDTH + border-line-width-after RIGHT_BORDER_LINE_WIDTH + border-line-width-start TOP_BORDER_LINE_WIDTH + border-line-width-end BOTTOM_BORDER_LINE_WIDTH + */ + + const SvxBorderLine* pLeft = pBox->GetLeft(); + const SvxBorderLine* pRight = pBox->GetRight(); + const SvxBorderLine* pTop = pBox->GetTop(); + const SvxBorderLine* pBottom = pBox->GetBottom(); + sal_uInt16 nTopDist = pBox->GetDistance( BOX_LINE_TOP ); + sal_uInt16 nBottomDist = pBox->GetDistance( BOX_LINE_BOTTOM ); + sal_uInt16 nLeftDist = pBox->GetDistance( BOX_LINE_LEFT ); + sal_uInt16 nRightDist = pBox->GetDistance( BOX_LINE_RIGHT ); + + + // check if we need to export it + switch( nMemberId ) + { + case ALL_BORDER_PADDING: + case LEFT_BORDER_PADDING: + case RIGHT_BORDER_PADDING: + case TOP_BORDER_PADDING: + case BOTTOM_BORDER_PADDING: + { + sal_Bool bEqual = nLeftDist == nRightDist && + nLeftDist == nTopDist && + nLeftDist == nBottomDist; + // don't export individual paddings if all paddings are equal and + // don't export all padding if some paddings are not equal + if( (bEqual && ALL_BORDER_PADDING != nMemberId) || + (!bEqual && ALL_BORDER_PADDING == nMemberId) ) + return sal_False; + } + break; + case ALL_BORDER: + case LEFT_BORDER: + case RIGHT_BORDER: + case TOP_BORDER: + case BOTTOM_BORDER: + { + sal_Bool bEqual = ( NULL == pTop && NULL == pBottom && + NULL == pLeft && NULL == pRight ) || + ( pTop && pBottom && pLeft && pRight && + *pTop == *pBottom && *pTop == *pLeft && + *pTop == *pRight ); + + // don't export individual borders if all are the same and + // don't export all borders if some are not equal + if( (bEqual && ALL_BORDER != nMemberId) || + (!bEqual && ALL_BORDER == nMemberId) ) + return sal_False; + } + break; + case ALL_BORDER_LINE_WIDTH: + case LEFT_BORDER_LINE_WIDTH: + case RIGHT_BORDER_LINE_WIDTH: + case TOP_BORDER_LINE_WIDTH: + case BOTTOM_BORDER_LINE_WIDTH: + { + // if no line is set, there is nothing to export + if( !pTop && !pBottom && !pLeft && !pRight ) + return sal_False; + + sal_Bool bEqual = NULL != pTop && + NULL != pBottom && + NULL != pLeft && + NULL != pRight; + + if( bEqual ) + { + const sal_uInt16 nDistance = pTop->GetDistance(); + const sal_uInt16 nInWidth = pTop->GetInWidth(); + const sal_uInt16 nOutWidth = pTop->GetOutWidth(); + + bEqual = nDistance == pLeft->GetDistance() && + nInWidth == pLeft->GetInWidth() && + nOutWidth == pLeft->GetOutWidth() && + nDistance == pRight->GetDistance() && + nInWidth == pRight->GetInWidth() && + nOutWidth == pRight->GetOutWidth() && + nDistance == pBottom->GetDistance() && + nInWidth == pBottom->GetInWidth() && + nOutWidth == pBottom->GetOutWidth(); + } + + switch( nMemberId ) + { + case ALL_BORDER_LINE_WIDTH: + if( !bEqual || pTop->GetDistance() == 0 ) + return sal_False; + break; + case LEFT_BORDER_LINE_WIDTH: + if( bEqual || NULL == pLeft || + 0 == pLeft->GetDistance() ) + return sal_False; + break; + case RIGHT_BORDER_LINE_WIDTH: + if( bEqual || NULL == pRight || + 0 == pRight->GetDistance() ) + return sal_False; + break; + case TOP_BORDER_LINE_WIDTH: + if( bEqual || NULL == pTop || + 0 == pTop->GetDistance() ) + return sal_False; + break; + case BOTTOM_BORDER_LINE_WIDTH: + if( bEqual || NULL == pBottom || + 0 == pBottom->GetDistance() ) + return sal_False; + break; + } + } + break; + } + + // now export it export + switch( nMemberId ) + { + // padding + case ALL_BORDER_PADDING: + case LEFT_BORDER_PADDING: + rUnitConverter.convertMeasure( aOut, nLeftDist ); + break; + case RIGHT_BORDER_PADDING: + rUnitConverter.convertMeasure( aOut, nRightDist ); + break; + case TOP_BORDER_PADDING: + rUnitConverter.convertMeasure( aOut, nTopDist ); + break; + case BOTTOM_BORDER_PADDING: + rUnitConverter.convertMeasure( aOut, nBottomDist ); + break; + + // border + case ALL_BORDER: + case LEFT_BORDER: + case RIGHT_BORDER: + case TOP_BORDER: + case BOTTOM_BORDER: + { + const SvxBorderLine* pLine; + switch( nMemberId ) + { + case ALL_BORDER: + case LEFT_BORDER: + pLine = pLeft; + break; + case RIGHT_BORDER: + pLine = pRight; + break; + case TOP_BORDER: + pLine = pTop; + break; + case BOTTOM_BORDER: + pLine = pBottom; + break; + default: + pLine = NULL; + break; + } + + if( NULL != pLine ) + { + sal_Int32 nWidth = pLine->GetOutWidth(); + const sal_uInt16 nDistance = pLine->GetDistance(); + if( 0 != nDistance ) + { + nWidth += nDistance; + nWidth += pLine->GetInWidth(); + } + + enum XMLTokenEnum eStyle = + (0 == nDistance) ? XML_SOLID : XML_DOUBLE; + + rUnitConverter.convertMeasure( aOut, nWidth ); + aOut.append( sal_Unicode( ' ' ) ); + aOut.append( GetXMLToken( eStyle ) ); + aOut.append( sal_Unicode( ' ' ) ); + rUnitConverter.convertColor( aOut, pLine->GetColor() ); + + } + else + { + aOut.append( GetXMLToken(XML_NONE) ); + } + } + break; + + // width + case ALL_BORDER_LINE_WIDTH: + case LEFT_BORDER_LINE_WIDTH: + case RIGHT_BORDER_LINE_WIDTH: + case TOP_BORDER_LINE_WIDTH: + case BOTTOM_BORDER_LINE_WIDTH: + const SvxBorderLine* pLine; + switch( nMemberId ) + { + case ALL_BORDER_LINE_WIDTH: + case LEFT_BORDER_LINE_WIDTH: + pLine = pLeft; + break; + case RIGHT_BORDER_LINE_WIDTH: + pLine = pRight; + break; + case TOP_BORDER_LINE_WIDTH: + pLine = pTop; + break; + case BOTTOM_BORDER_LINE_WIDTH: + pLine = pBottom; + break; + default: + return sal_False; + } + rUnitConverter.convertMeasure( aOut, pLine->GetInWidth() ); + aOut.append( sal_Unicode( ' ' ) ); + rUnitConverter.convertMeasure( aOut, pLine->GetDistance() ); + aOut.append( sal_Unicode( ' ' ) ); + rUnitConverter.convertMeasure( aOut, pLine->GetOutWidth() ); + break; + } + + bOk = sal_True; + } + break; + + case ITEMID_FMTBREAK: + { + const SvxFmtBreakItem* pFmtBreak = PTR_CAST(SvxFmtBreakItem, &rItem); + DBG_ASSERT( pFmtBreak != NULL, "Wrong Which-ID" ); + + sal_uInt16 eEnum = 0; + + switch( nMemberId ) + { + case MID_BREAK_BEFORE: + switch( pFmtBreak->GetValue() ) + { + case SVX_BREAK_COLUMN_BEFORE: + eEnum = 1; + break; + case SVX_BREAK_PAGE_BEFORE: + eEnum = 2; + break; + case SVX_BREAK_NONE: + eEnum = 0; + break; + default: + return sal_False; + } + break; + case MID_BREAK_AFTER: + switch( pFmtBreak->GetValue() ) + { + case SVX_BREAK_COLUMN_AFTER: + eEnum = 1; + break; + case SVX_BREAK_PAGE_AFTER: + eEnum = 2; + break; + case SVX_BREAK_NONE: + eEnum = 0; + break; + default: + return sal_False; + } + break; + } + + bOk = rUnitConverter.convertEnum( aOut, eEnum, psXML_BreakType ); + } + break; + + case ITEMID_FMTKEEP: + { + SvxFmtKeepItem* pFmtKeep = PTR_CAST(SvxFmtKeepItem, &rItem); + DBG_ASSERT( pFmtKeep != NULL, "Wrong Which-ID" ); + + rUnitConverter.convertBool( aOut, pFmtKeep->GetValue() ); + bOk = sal_True; + } + break; + + case ITEMID_BRUSH: + { + SvxBrushItem* pBrush = PTR_CAST(SvxBrushItem, &rItem); + DBG_ASSERT( pBrush != NULL, "Wrong Which-ID" ); + + // note: the graphic is only exported if nMemberId equals + // MID_GRAPHIC.. + // If not, only the color or transparency is exported + + switch( nMemberId ) + { + case MID_BACK_COLOR: + if ( pBrush->GetColor().GetTransparency() ) + aOut.append( GetXMLToken(XML_TRANSPARENT) ); + else + rUnitConverter.convertColor( aOut, pBrush->GetColor()); + bOk = sal_True; + break; + + case MID_GRAPHIC_LINK: + if( pBrush->GetGraphicPos() != GPOS_NONE ) + { + uno::Any aAny; + pBrush->QueryValue( aAny, MID_GRAPHIC_URL ); + OUString sTmp; + aAny >>= sTmp; + aOut.append( sTmp ); + bOk = sal_True; + } + break; + + case MID_GRAPHIC_POSITION: + switch( pBrush->GetGraphicPos() ) + { + case GPOS_LT: + case GPOS_MT: + case GPOS_RT: + aOut.append( GetXMLToken(XML_TOP) ); + bOk = sal_True; + break; + case GPOS_LM: + case GPOS_MM: + case GPOS_RM: + aOut.append( GetXMLToken(XML_CENTER) ); + bOk = sal_True; + break; + case GPOS_LB: + case GPOS_MB: + case GPOS_RB: + aOut.append( GetXMLToken(XML_BOTTOM) ); + bOk = sal_True; + break; + } + + if( bOk ) + { + aOut.append( sal_Unicode( ' ' ) ); + + switch( pBrush->GetGraphicPos() ) + { + case GPOS_LT: + case GPOS_LB: + case GPOS_LM: + aOut.append( GetXMLToken(XML_LEFT) ); + break; + case GPOS_MT: + case GPOS_MM: + case GPOS_MB: + aOut.append( GetXMLToken(XML_CENTER) ); + break; + case GPOS_RM: + case GPOS_RT: + case GPOS_RB: + aOut.append( GetXMLToken(XML_RIGHT) ); + break; + } + } + break; + + case MID_GRAPHIC_REPEAT: + { + SvxGraphicPosition eGraphicPos = pBrush->GetGraphicPos(); + if( GPOS_AREA == eGraphicPos ) + { + aOut.append( GetXMLToken(XML_BACKGROUND_STRETCH) ); + bOk = sal_True; + } + else if( GPOS_NONE != eGraphicPos && GPOS_TILED != eGraphicPos ) + { + aOut.append( GetXMLToken(XML_BACKGROUND_NO_REPEAT) ); + bOk = sal_True; + } + } + break; + + case MID_GRAPHIC_FILTER: + if( pBrush->GetGraphicPos() != GPOS_NONE && + pBrush->GetGraphicFilter() ) + { + aOut.append( pBrush->GetGraphicFilter()->GetBuffer() ); + bOk = sal_True; + } + break; + } + } + break; + + case RES_PAGEDESC: + { + const SwFmtPageDesc* pPageDesc = PTR_CAST(SwFmtPageDesc, &rItem); + DBG_ASSERT( pPageDesc != NULL, "Wrong Which-ID" ); + + if( MID_PAGEDESC_PAGENUMOFFSET==nMemberId ) + { + + rUnitConverter.convertNumber( + aOut, (sal_Int32)pPageDesc->GetNumOffset() ); + bOk = sal_True; + } + } + break; + + case RES_LAYOUT_SPLIT: + { + const SwFmtLayoutSplit* pLayoutSplit = PTR_CAST(SwFmtLayoutSplit, &rItem); + DBG_ASSERT( pLayoutSplit != NULL, "Wrong Which-ID" ); + + rUnitConverter.convertBool( aOut, pLayoutSplit->GetValue() ); + bOk = sal_True; + } + break; + + case RES_HORI_ORIENT: + { + SwFmtHoriOrient* pHoriOrient = PTR_CAST(SwFmtHoriOrient, &rItem); + DBG_ASSERT( pHoriOrient != NULL, "Wrong Which-ID" ); + + rUnitConverter.convertEnum( aOut, pHoriOrient->GetHoriOrient(), + aXMLTableAlignMap ); + bOk = sal_True; + } + break; + + case RES_VERT_ORIENT: + { + SwFmtVertOrient* pVertOrient = PTR_CAST(SwFmtVertOrient, &rItem); + DBG_ASSERT( pVertOrient != NULL, "Wrong Which-ID" ); + + rUnitConverter.convertEnum( aOut, pVertOrient->GetVertOrient(), + aXMLTableVAlignMap ); + bOk = sal_True; + } + break; + + case RES_FRM_SIZE: + { + SwFmtFrmSize* pFrmSize = PTR_CAST(SwFmtFrmSize, &rItem); + DBG_ASSERT( pFrmSize != NULL, "Wrong Which-ID" ); + + sal_Bool bOutHeight = sal_False; + switch( nMemberId ) + { + case MID_FRMSIZE_REL_WIDTH: + if( pFrmSize->GetWidthPercent() ) + { + rUnitConverter.convertPercent( aOut, pFrmSize->GetWidthPercent() ); + bOk = sal_True; + } + break; + case MID_FRMSIZE_MIN_HEIGHT: + if( ATT_MIN_SIZE == pFrmSize->GetSizeType() ) + bOutHeight = sal_True; + break; + case MID_FRMSIZE_FIX_HEIGHT: + if( ATT_FIX_SIZE == pFrmSize->GetSizeType() ) + bOutHeight = sal_True; + break; + } + + if( bOutHeight ) + { + rUnitConverter.convertMeasure( aOut, pFrmSize->GetHeight() ); + bOk = sal_True; + } + } + break; + + default: + DBG_ERROR("GetXMLValue not implemented for this item."); + break; + } + + if ( bOk ) + rValue = aOut.makeStringAndClear(); + + return bOk; +} diff --git a/sw/source/filter/xml/xmlexpit.hxx b/sw/source/filter/xml/xmlexpit.hxx index 4877ef0dc623..e99276bee9b1 100644 --- a/sw/source/filter/xml/xmlexpit.hxx +++ b/sw/source/filter/xml/xmlexpit.hxx @@ -2,9 +2,9 @@ * * $RCSfile: xmlexpit.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: mib $ $Date: 2001-07-04 14:14:34 $ + * last change: $Author: dvo $ $Date: 2001-07-09 20:10:42 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -196,6 +196,10 @@ public: sal_uInt16 nFlags ) const; inline void setMapEntries( SvXMLItemMapEntriesRef rMapEntries ); + + static sal_Bool QueryXMLValue( const SfxPoolItem& rItem, + ::rtl::OUString& rValue, sal_uInt16 nMemberId, + const SvXMLUnitConverter& rUnitConverter ); }; inline void diff --git a/sw/source/filter/xml/xmlimpit.cxx b/sw/source/filter/xml/xmlimpit.cxx index 58718c53a303..f398196bfc92 100644 --- a/sw/source/filter/xml/xmlimpit.cxx +++ b/sw/source/filter/xml/xmlimpit.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmlimpit.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: mib $ $Date: 2001-07-04 14:14:42 $ + * last change: $Author: dvo $ $Date: 2001-07-09 20:10:42 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -90,8 +90,75 @@ #include <svx/xmlcnitm.hxx> #endif + +#ifndef _HINTIDS_HXX +#include "hintids.hxx" +#endif + +#ifndef SW_UNOMID_HXX +#include "unomid.h" +#endif + +#ifndef _SVX_UNOMID_HXX +#include <svx/unomid.hxx> +#endif + +#ifndef _SVX_LRSPITEM_HXX +#include <svx/lrspitem.hxx> +#endif + +#ifndef _SVX_ULSPITEM_HXX +#include <svx/ulspitem.hxx> +#endif + +#ifndef _SVX_SHADITEM_HXX +#include <svx/shaditem.hxx> +#endif + +#ifndef _SVX_BOXITEM_HXX +#include <svx/boxitem.hxx> +#endif + +#ifndef _SVX_BRKITEM_HXX +#include <svx/brkitem.hxx> +#endif + +#ifndef _SVX_KEEPITEM_HXX +#include <svx/keepitem.hxx> +#endif + +#ifndef _SVX_BRSHITEM_HXX +#include <svx/brshitem.hxx> +#endif + +#ifndef _FMTPDSC_HXX +#include "fmtpdsc.hxx" +#endif + +#ifndef _FMTORNT_HXX +#include "fmtornt.hxx" +#endif + +#ifndef _FMTFSIZE_HXX +#include "fmtfsize.hxx" +#endif + +#ifndef _FMTLSPLT_HXX +#include "fmtlsplt.hxx" +#endif + +#ifndef _XMLOFF_XMLTOKEN_HXX +#include <xmloff/xmltoken.hxx> +#endif + +#ifndef _SW_XMLITHLP_HXX +#include "xmlithlp.hxx" +#endif + + using namespace ::rtl; using namespace ::com::sun::star; +using namespace ::xmloff::token; SvXMLImportItemMapper::SvXMLImportItemMapper( SvXMLItemMapEntriesRef rMapEntries, @@ -152,7 +219,10 @@ void SvXMLImportItemMapper::importXML( SfxItemSet& rSet, if( 0 == (pEntry->nMemberId&MID_FLAG_SPECIAL_ITEM_IMPORT) ) { - bPut = pNewItem->importXML( rValue, +// bPut = pNewItem->importXML( rValue, +// pEntry->nMemberId & MID_FLAG_MASK, +// rUnitConverter ); + bPut = PutXMLValue( *pNewItem, rValue, pEntry->nMemberId & MID_FLAG_MASK, rUnitConverter ); @@ -254,3 +324,686 @@ void SvXMLImportItemMapper::finished( SfxItemSet& ) const // nothing to do here } + + +// put an XML-string value into an item +sal_Bool SvXMLImportItemMapper::PutXMLValue( + SfxPoolItem& rItem, + const ::rtl::OUString& rValue, + sal_uInt16 nMemberId, + const SvXMLUnitConverter& rUnitConverter ) +{ + sal_Bool bOk = sal_False; + + switch (rItem.Which()) + { + case ITEMID_LRSPACE: + { + SvxLRSpaceItem* pLRSpace = PTR_CAST(SvxLRSpaceItem, &rItem); + DBG_ASSERT( pLRSpace != NULL, "Wrong Which-ID!" ); + + switch( nMemberId ) + { + case MID_L_MARGIN: + case MID_R_MARGIN: + { + sal_Int32 nProp = 100; + sal_Int32 nAbs = 0; + + if( rValue.indexOf( sal_Unicode('%') ) != -1 ) + bOk = rUnitConverter.convertPercent( nProp, rValue ); + else + bOk = rUnitConverter.convertMeasure( nAbs, rValue ); + + if( bOk ) + { + switch( nMemberId ) + { + case MID_L_MARGIN: + pLRSpace->SetTxtLeft( (sal_Int32)nAbs, (sal_uInt16)nProp ); + break; + case MID_R_MARGIN: + pLRSpace->SetRight( (sal_Int32)nAbs, (sal_uInt16)nProp ); + break; + } + } + } + break; + case MID_FIRST_LINE_INDENT: + { + sal_Int32 nProp = 100; + sal_Int32 nAbs = 0; + + if( rValue.indexOf( sal_Unicode('%') ) != -1 ) + bOk = rUnitConverter.convertPercent( nProp, rValue ); + else + bOk = rUnitConverter.convertMeasure( nAbs, rValue, + -0x7fff, 0x7fff ); + + pLRSpace->SetTxtFirstLineOfst( (short)nAbs, (sal_uInt16)nProp ); + } + + case MID_FIRST_AUTO: + { + sal_Bool bAutoFirst; + bOk = rUnitConverter.convertBool( bAutoFirst, rValue ); + if( bOk ) + pLRSpace->SetAutoFirst( bAutoFirst ); + } + break; + + default: + DBG_ERROR( "unknown member id!"); + } + } + break; + + case ITEMID_ULSPACE: + { + SvxULSpaceItem* pULSpace = PTR_CAST(SvxULSpaceItem, &rItem); + DBG_ASSERT( pULSpace != NULL, "Wrong Which-ID!" ); + + sal_Int32 nProp = 100; + sal_Int32 nAbs = 0; + + if( rValue.indexOf( sal_Unicode('%') ) != -1 ) + bOk = rUnitConverter.convertPercent( nProp, rValue ); + else + bOk = rUnitConverter.convertMeasure( nAbs, rValue ); + + switch( nMemberId ) + { + case MID_UP_MARGIN: + pULSpace->SetUpper( (sal_uInt16)nAbs, (sal_uInt16)nProp ); + break; + case MID_LO_MARGIN: + pULSpace->SetLower( (sal_uInt16)nAbs, (sal_uInt16)nProp ); + break; + default: + DBG_ERROR("unknown MemberId"); + } + } + break; + + case ITEMID_SHADOW: + { + SvxShadowItem* pShadow = PTR_CAST(SvxShadowItem, &rItem); + DBG_ASSERT( pShadow != NULL, "Wrong Which-ID" ); + + sal_Bool bColorFound = sal_False; + sal_Bool bOffsetFound = sal_False; + + SvXMLTokenEnumerator aTokenEnum( rValue ); + + Color aColor( 128,128, 128 ); + pShadow->SetLocation( SVX_SHADOW_BOTTOMRIGHT ); + + OUString aToken; + while( aTokenEnum.getNextToken( aToken ) ) + { + if( IsXMLToken( aToken, XML_NONE ) ) + { + pShadow->SetLocation( SVX_SHADOW_NONE ); + bOk = sal_True; + } + else if( !bColorFound && aToken.compareToAscii( "#", 1 ) == 0 ) + { + bOk = rUnitConverter.convertColor( aColor, aToken ); + if( !bOk ) + return sal_False; + + bColorFound = sal_True; + } + else if( !bOffsetFound ) + { + sal_Int32 nX = 0, nY = 0; + + bOk = rUnitConverter.convertMeasure( nX, aToken ); + if( bOk && aTokenEnum.getNextToken( aToken ) ) + bOk = rUnitConverter.convertMeasure( nY, aToken ); + + if( bOk ) + { + if( nX < 0 ) + { + if( nY < 0 ) + { + pShadow->SetLocation( SVX_SHADOW_TOPLEFT ); + } + else + { + pShadow->SetLocation( SVX_SHADOW_TOPRIGHT ); + } + } + else + { + if( nY < 0 ) + { + pShadow->SetLocation( SVX_SHADOW_BOTTOMLEFT ); + } + else + { + pShadow->SetLocation( SVX_SHADOW_BOTTOMRIGHT ); + } + } + + if( nX < 0 ) nX *= -1; + if( nY < 0 ) nY *= -1; + + pShadow->SetWidth( (nX + nY) >> 1 ); + } + } + } + + if( bOk && ( bColorFound || bOffsetFound ) ) + { + pShadow->SetColor( aColor ); + } + else + bOk = sal_False; + } + break; + + case ITEMID_BOX: + { + SvxBoxItem* pBox = PTR_CAST(SvxBoxItem, &rItem); + DBG_ASSERT( pBox != NULL, "Wrong WHich-ID" ); + + /** copy SvxBorderLines */ + SvxBorderLine* pTop = pBox->GetTop() == NULL ? + NULL : new SvxBorderLine( *pBox->GetTop() ); + SvxBorderLine* pBottom = pBox->GetBottom() == NULL ? + NULL : new SvxBorderLine( *pBox->GetBottom() ); + SvxBorderLine* pLeft = pBox->GetLeft() == NULL ? + NULL : new SvxBorderLine( *pBox->GetLeft() ); + SvxBorderLine* pRight = pBox->GetRight() == NULL ? + NULL : new SvxBorderLine( *pBox->GetRight() ); + + sal_Int32 nTemp; + + switch( nMemberId ) + { + case ALL_BORDER_PADDING: + case LEFT_BORDER_PADDING: + case RIGHT_BORDER_PADDING: + case TOP_BORDER_PADDING: + case BOTTOM_BORDER_PADDING: + if(!rUnitConverter.convertMeasure( nTemp, rValue, 0, 0xffff )) + return sal_False; + + if( nMemberId == LEFT_BORDER_PADDING || + nMemberId == ALL_BORDER_PADDING ) + pBox->SetDistance( (sal_uInt16)nTemp, BOX_LINE_LEFT ); + if( nMemberId == RIGHT_BORDER_PADDING || + nMemberId == ALL_BORDER_PADDING ) + pBox->SetDistance( (sal_uInt16)nTemp, BOX_LINE_RIGHT ); + if( nMemberId == TOP_BORDER_PADDING || + nMemberId == ALL_BORDER_PADDING ) + pBox->SetDistance( (sal_uInt16)nTemp, BOX_LINE_TOP ); + if( nMemberId == BOTTOM_BORDER_PADDING || + nMemberId == ALL_BORDER_PADDING ) + pBox->SetDistance( (sal_uInt16)nTemp, BOX_LINE_BOTTOM); + break; + + case ALL_BORDER: + case LEFT_BORDER: + case RIGHT_BORDER: + case TOP_BORDER: + case BOTTOM_BORDER: + { + sal_Bool bHasStyle = sal_False; + sal_Bool bHasWidth = sal_False; + sal_Bool bHasColor = sal_False; + + sal_uInt16 nStyle = USHRT_MAX; + sal_uInt16 nWidth = 0; + sal_uInt16 nNamedWidth = USHRT_MAX; + + Color aColor( COL_BLACK ); + + if( !lcl_frmitems_parseXMLBorder( rValue, rUnitConverter, + bHasStyle, nStyle, + bHasWidth, nWidth, nNamedWidth, + bHasColor, aColor ) ) + return sal_False; + + if( TOP_BORDER == nMemberId || ALL_BORDER == nMemberId ) + lcl_frmitems_setXMLBorder( pTop, + bHasStyle, nStyle, + bHasWidth, nWidth, nNamedWidth, + bHasColor, aColor ); + + if( BOTTOM_BORDER == nMemberId || ALL_BORDER == nMemberId ) + lcl_frmitems_setXMLBorder( pBottom, + bHasStyle, nStyle, + bHasWidth, nWidth, nNamedWidth, + bHasColor, aColor ); + + if( LEFT_BORDER == nMemberId || ALL_BORDER == nMemberId ) + lcl_frmitems_setXMLBorder( pLeft, + bHasStyle, nStyle, + bHasWidth, nWidth, nNamedWidth, + bHasColor, aColor ); + + if( RIGHT_BORDER == nMemberId || ALL_BORDER == nMemberId ) + lcl_frmitems_setXMLBorder( pRight, + bHasStyle, nStyle, + bHasWidth, nWidth, nNamedWidth, + bHasColor, aColor ); + } + break; + case ALL_BORDER_LINE_WIDTH: + case LEFT_BORDER_LINE_WIDTH: + case RIGHT_BORDER_LINE_WIDTH: + case TOP_BORDER_LINE_WIDTH: + case BOTTOM_BORDER_LINE_WIDTH: + { + SvXMLTokenEnumerator aTokenEnum( rValue ); + + sal_Int32 nInWidth, nDistance, nOutWidth; + + OUString aToken; + if( !aTokenEnum.getNextToken( aToken ) ) + return sal_False; + + if( !rUnitConverter.convertMeasure( nInWidth, aToken, + DEF_LINE_WIDTH_0, + DEF_LINE_WIDTH_4 ) ) + return sal_False; + + if( !aTokenEnum.getNextToken( aToken ) ) + return sal_False; + + if( !rUnitConverter.convertMeasure( nDistance, aToken, + DEF_LINE_WIDTH_0, + DEF_LINE_WIDTH_4 ) ) + return sal_False; + + if( !aTokenEnum.getNextToken( aToken ) ) + return sal_False; + + if( !rUnitConverter.convertMeasure( nOutWidth, aToken, + DEF_LINE_WIDTH_0, + DEF_LINE_WIDTH_4 ) ) + return sal_False; + + sal_uInt16 nSize = sizeof( aDBorderWidths ); + for( sal_uInt16 i=0; i < nSize; i += 4 ) + { + if( aDBorderWidths[i+1] == nOutWidth && + aDBorderWidths[i+2] == nInWidth && + aDBorderWidths[i+3] == nDistance ) + break; + } + + sal_uInt16 nWidth = i < nSize ? 0 : nOutWidth + nInWidth + nDistance; + + if( TOP_BORDER_LINE_WIDTH == nMemberId || + ALL_BORDER_LINE_WIDTH == nMemberId ) + lcl_frmitems_setXMLBorder( pTop, nWidth, nOutWidth, + nInWidth, nDistance ); + + if( BOTTOM_BORDER_LINE_WIDTH == nMemberId || + ALL_BORDER_LINE_WIDTH == nMemberId ) + lcl_frmitems_setXMLBorder( pBottom, nWidth, nOutWidth, + nInWidth, nDistance ); + + if( LEFT_BORDER_LINE_WIDTH == nMemberId || + ALL_BORDER_LINE_WIDTH == nMemberId ) + lcl_frmitems_setXMLBorder( pLeft, nWidth, nOutWidth, + nInWidth, nDistance ); + + if( RIGHT_BORDER_LINE_WIDTH == nMemberId || + ALL_BORDER_LINE_WIDTH == nMemberId ) + lcl_frmitems_setXMLBorder( pRight, nWidth, nOutWidth, + nInWidth, nDistance ); + } + break; + } + + pBox->SetLine( pTop, BOX_LINE_TOP ); + pBox->SetLine( pBottom, BOX_LINE_BOTTOM ); + pBox->SetLine( pLeft, BOX_LINE_LEFT ); + pBox->SetLine( pRight, BOX_LINE_RIGHT ); + + bOk = sal_True; + } + break; + + case ITEMID_FMTBREAK: + { + SvxFmtBreakItem* pFmtBreak = PTR_CAST(SvxFmtBreakItem, &rItem); + DBG_ASSERT( pFmtBreak != NULL, "Wrong Which-ID" ); + + sal_uInt16 eEnum; + + if( !rUnitConverter.convertEnum( eEnum, rValue, psXML_BreakType ) ) + return sal_False; + + if( eEnum == 0 ) + { + pFmtBreak->SetValue( SVX_BREAK_NONE ); + bOk = sal_True; + } + else + { + switch( nMemberId ) + { + case MID_BREAK_BEFORE: + pFmtBreak->SetValue( (eEnum == 1) ? + SVX_BREAK_COLUMN_BEFORE : + SVX_BREAK_PAGE_BEFORE ); + break; + case MID_BREAK_AFTER: + pFmtBreak->SetValue( (eEnum == 1) ? + SVX_BREAK_COLUMN_AFTER : + SVX_BREAK_PAGE_AFTER ); + break; + } + bOk = sal_True; + } + } + break; + + case ITEMID_FMTKEEP: + { + SvxFmtKeepItem* pFmtKeep = PTR_CAST(SvxFmtKeepItem, &rItem); + DBG_ASSERT( pFmtKeep != NULL, "Wrong Which-ID" ); + + sal_Bool bValue; + bOk = rUnitConverter.convertBool( bValue, rValue ); + if ( bOk ) + pFmtKeep->SetValue( bValue ); + } + break; + + case ITEMID_BRUSH: + { + SvxBrushItem* pBrush = PTR_CAST(SvxBrushItem, &rItem); + DBG_ASSERT( pBrush != NULL, "Wrong Which-ID" ); + + Color aTempColor; + switch( nMemberId ) + { + case MID_BACK_COLOR: + if( IsXMLToken( rValue, XML_TRANSPARENT ) ) + { + pBrush->GetColor().SetTransparency(0xff); + bOk = sal_True; + } + else if( rUnitConverter.convertColor( aTempColor, rValue ) ) + { + aTempColor.SetTransparency(0); + pBrush->SetColor( aTempColor ); + bOk = sal_True; + } + break; + + case MID_GRAPHIC_LINK: + { + SvxGraphicPosition eOldGraphicPos = pBrush->GetGraphicPos(); + uno::Any aAny; + aAny <<= rValue; + pBrush->PutValue( aAny, MID_GRAPHIC_URL ); + if( GPOS_NONE == eOldGraphicPos && + GPOS_NONE != pBrush->GetGraphicPos() ) + pBrush->SetGraphicPos( GPOS_TILED ); + bOk = sal_True ; + } + break; + + case MID_GRAPHIC_REPEAT: + { + SvxGraphicPosition eGraphicPos = pBrush->GetGraphicPos(); + sal_uInt16 nPos = GPOS_NONE; + if( rUnitConverter.convertEnum( nPos, rValue, + psXML_BrushRepeat ) ) + { + if( GPOS_MM != nPos || GPOS_NONE == eGraphicPos || + GPOS_AREA == eGraphicPos || GPOS_TILED == eGraphicPos ) + pBrush->SetGraphicPos( (SvxGraphicPosition)nPos ); + bOk = sal_True; + } + } + break; + + case MID_GRAPHIC_POSITION: + { + SvxGraphicPosition ePos = GPOS_NONE, eTmp; + sal_uInt16 nTmp; + SvXMLTokenEnumerator aTokenEnum( rValue ); + OUString aToken; + sal_Bool bHori = sal_False, bVert = sal_False; + bOk = sal_True; + while( bOk && aTokenEnum.getNextToken( aToken ) ) + { + if( bHori && bVert ) + { + bOk = sal_False; + } + else if( -1 != aToken.indexOf( sal_Unicode('%') ) ) + { + long nPrc = 50; + if( rUnitConverter.convertPercent( nPrc, aToken ) ) + { + if( !bHori ) + { + ePos = nPrc < 25 ? GPOS_LT : + (nPrc < 75 ? GPOS_MM : GPOS_RB); + bHori = sal_True; + } + else + { + eTmp = nPrc < 25 ? GPOS_LT: + (nPrc < 75 ? GPOS_LM : GPOS_LB); + lcl_frmitems_MergeXMLVertPos( ePos, eTmp ); + bVert = sal_True; + } + } + else + { + // wrong percentage + bOk = sal_False; + } + } + else if( IsXMLToken( aToken, XML_CENTER ) ) + { + if( bHori ) + lcl_frmitems_MergeXMLVertPos( ePos, GPOS_MM ); + else if ( bVert ) + lcl_frmitems_MergeXMLHoriPos( ePos, GPOS_MM ); + else + ePos = GPOS_MM; + } + else if( rUnitConverter.convertEnum( nTmp, aToken, + psXML_BrushHoriPos ) ) + { + if( bVert ) + lcl_frmitems_MergeXMLHoriPos( + ePos, (SvxGraphicPosition)nTmp ); + else if( !bHori ) + ePos = (SvxGraphicPosition)nTmp; + else + bOk = sal_False; + bHori = sal_True; + } + else if( rUnitConverter.convertEnum( nTmp, aToken, + psXML_BrushVertPos ) ) + { + if( bHori ) + lcl_frmitems_MergeXMLVertPos( + ePos, (SvxGraphicPosition)nTmp ); + else if( !bVert ) + ePos = (SvxGraphicPosition)nTmp; + else + bOk = sal_False; + bVert = sal_True; + } + else + { + bOk = sal_False; + } + } + + bOk &= GPOS_NONE != ePos; + if( bOk ) + pBrush->SetGraphicPos( ePos ); + } + break; + + case MID_GRAPHIC_FILTER: + pBrush->SetGraphicFilter( rValue.getStr() ); + bOk = sal_True; + break; + } + } + break; + + case RES_PAGEDESC: + { + SwFmtPageDesc* pPageDesc = PTR_CAST(SwFmtPageDesc, &rItem); + DBG_ASSERT( pPageDesc != NULL, "Wrong Which-ID" ); + + if( MID_PAGEDESC_PAGENUMOFFSET==nMemberId ) + { + sal_Int32 nVal; + bOk = rUnitConverter.convertNumber( nVal, rValue, 0, USHRT_MAX ); + if( bOk ) + pPageDesc->SetNumOffset( (USHORT)nVal ); + } + } + break; + + case RES_LAYOUT_SPLIT: + { + SwFmtLayoutSplit* pLayoutSplit = PTR_CAST(SwFmtLayoutSplit, &rItem); + DBG_ASSERT( pLayoutSplit != NULL, "Wrong Which-ID" ); + + sal_Bool bValue; + bOk = rUnitConverter.convertBool( bValue, rValue ); + if( bOk ) + pLayoutSplit->SetValue( bValue ); + } + break; + + case RES_HORI_ORIENT: + { + SwFmtHoriOrient* pHoriOrient = PTR_CAST(SwFmtHoriOrient, &rItem); + DBG_ASSERT( pHoriOrient != NULL, "Wrong Which-ID" ); + + sal_uInt16 nValue; + bOk = rUnitConverter.convertEnum( nValue, rValue, + aXMLTableAlignMap ); + if( bOk ) + pHoriOrient->SetHoriOrient( (SwHoriOrient)nValue ); + } + break; + + case RES_VERT_ORIENT: + { + SwFmtVertOrient* pVertOrient = PTR_CAST(SwFmtVertOrient, &rItem); + DBG_ASSERT( pVertOrient != NULL, "Wrong Which-ID" ); + + sal_uInt16 nValue; + bOk = rUnitConverter.convertEnum( nValue, rValue, + aXMLTableVAlignMap ); + if( bOk ) + pVertOrient->SetVertOrient( (SwVertOrient)nValue ); + } + break; + + case RES_FRM_SIZE: + { + SwFmtFrmSize* pFrmSize = PTR_CAST(SwFmtFrmSize, &rItem); + DBG_ASSERT( pFrmSize != NULL, "Wrong Which-ID" ); + + sal_Bool bSetHeight = sal_False; + sal_Bool bSetWidth = sal_False; + sal_Bool bSetSizeType = sal_False; + SwFrmSize eSizeType = ATT_VAR_SIZE; + sal_Int32 nMin = MINLAY; + + switch( nMemberId ) + { + case MID_FRMSIZE_REL_WIDTH: + { + sal_Int32 nValue; + bOk = rUnitConverter.convertPercent( nValue, rValue ); + if( bOk ) + { + if( nValue < 1 ) + nValue = 1; + else if( nValue > 100 ) + nValue = 100; + + pFrmSize->SetWidthPercent( (sal_Int8)nValue ); + } + } + break; + case MID_FRMSIZE_WIDTH: + bSetWidth = sal_True; + break; + case MID_FRMSIZE_MIN_HEIGHT: + eSizeType = ATT_MIN_SIZE; + bSetHeight = sal_True; + nMin = 1; + bSetSizeType = sal_True; + break; + case MID_FRMSIZE_FIX_HEIGHT: + eSizeType = ATT_FIX_SIZE; + bSetHeight = sal_True; + nMin = 1; + bSetSizeType = sal_True; + break; + case MID_FRMSIZE_COL_WIDTH: + eSizeType = ATT_FIX_SIZE; + bSetWidth = sal_True; + bSetSizeType = sal_True; + break; + case MID_FRMSIZE_REL_COL_WIDTH: + { + sal_Int32 nPos = rValue.indexOf( (sal_Unicode)'*' ); + if( -1L != nPos ) + { + OUString sNum( rValue.copy( 0L, nPos ) ); + sal_Int32 nValue = rValue.toInt32(); + if( nValue < MINLAY ) + nValue = MINLAY; + else if( nValue > USHRT_MAX ) + nValue = USHRT_MAX; + + pFrmSize->SetWidth( (sal_uInt16)nValue ); + pFrmSize->SetSizeType( ATT_VAR_SIZE ); + bOk = sal_True; + } + } + break; + } + + sal_Int32 nValue; + if( bSetHeight || bSetWidth ) + { + bOk = rUnitConverter.convertMeasure( nValue, rValue, nMin, + USHRT_MAX ); + if( bOk ) + { + if( bSetWidth ) + pFrmSize->SetWidth( (sal_uInt16)nValue ); + if( bSetHeight ) + pFrmSize->SetHeight( (sal_uInt16)nValue ); + if( bSetSizeType ) + pFrmSize->SetSizeType( eSizeType ); + } + } + } + break; + + default: + DBG_ERROR("Item not implemented!"); + break; + } + + return bOk; +} + + diff --git a/sw/source/filter/xml/xmlimpit.hxx b/sw/source/filter/xml/xmlimpit.hxx index d2790c8bd675..a7179d2ffd3a 100644 --- a/sw/source/filter/xml/xmlimpit.hxx +++ b/sw/source/filter/xml/xmlimpit.hxx @@ -2,9 +2,9 @@ * * $RCSfile: xmlimpit.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: mib $ $Date: 2001-07-04 14:14:49 $ + * last change: $Author: dvo $ $Date: 2001-07-09 20:10:42 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -144,6 +144,15 @@ public: inline void setMapEntries( SvXMLItemMapEntriesRef rMapEntries ); inline SvXMLItemMapEntriesRef getMapEntries() const; + + + /** This method is called for every item that should be set based + upon an XML attribute value. */ + static sal_Bool PutXMLValue( + SfxPoolItem& rItem, + const ::rtl::OUString& rValue, + sal_uInt16 nMemberId, + const SvXMLUnitConverter& rUnitConverter ); }; inline void diff --git a/sw/source/filter/xml/xmliteme.cxx b/sw/source/filter/xml/xmliteme.cxx index 319d4bad7b8e..27cf33a617fe 100644 --- a/sw/source/filter/xml/xmliteme.cxx +++ b/sw/source/filter/xml/xmliteme.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmliteme.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: mib $ $Date: 2001-07-04 14:16:19 $ + * last change: $Author: dvo $ $Date: 2001-07-09 20:10:42 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -242,8 +242,8 @@ void SwXMLTableItemMapper_Impl::handleSpecialItem( break; } OUString sValue; - if( bExport && rItem.exportXML( sValue, nMemberId, - rUnitConverter ) ) + if( bExport && SvXMLExportItemMapper::QueryXMLValue( + rItem, sValue, nMemberId, rUnitConverter ) ) { AddAttribute( rEntry.nNameSpace, rEntry.eLocalName, sValue, rNamespaceMap, rAttrList ); @@ -270,7 +270,8 @@ void SwXMLTableItemMapper_Impl::handleSpecialItem( case MID_FRMSIZE_REL_WIDTH: { OUString sValue; - if( rItem.exportXML( sValue, nMemberId, rUnitConverter ) ) + if( SvXMLExportItemMapper::QueryXMLValue( + rItem, sValue, nMemberId, rUnitConverter ) ) { AddAttribute( rEntry.nNameSpace, rEntry.eLocalName, sValue, rNamespaceMap, rAttrList ); diff --git a/sw/source/filter/xml/xmlitemi.cxx b/sw/source/filter/xml/xmlitemi.cxx index 750e21a89701..e7bf3f644cdc 100644 --- a/sw/source/filter/xml/xmlitemi.cxx +++ b/sw/source/filter/xml/xmlitemi.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmlitemi.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: mib $ $Date: 2001-07-04 14:16:19 $ + * last change: $Author: dvo $ $Date: 2001-07-09 20:10:42 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -193,7 +193,8 @@ sal_Bool SwXMLImportTableItemMapper_Impl::handleSpecialItem( // already that must be preserved. if( SFX_ITEM_SET != rItemSet.GetItemState( RES_FRM_SIZE, sal_False ) ) - bRet = rItem.importXML( rValue, nMemberId, rUnitConv ); + bRet = SvXMLImportItemMapper::PutXMLValue( + rItem, rValue, nMemberId, rUnitConv ); break; } } diff --git a/sw/source/filter/xml/xmlithlp.cxx b/sw/source/filter/xml/xmlithlp.cxx new file mode 100644 index 000000000000..a2248eb15f51 --- /dev/null +++ b/sw/source/filter/xml/xmlithlp.cxx @@ -0,0 +1,489 @@ +/************************************************************************* + * + * $RCSfile: xmlithlp.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dvo $ $Date: 2001-07-09 20:10:43 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SW_XMLITHLP_HXX +#include "xmlithlp.hxx" +#endif + +#ifndef _HINTIDS_HXX +#include "hintids.hxx" +#endif + +#ifndef SW_UNOMID_HXX +#include "unomid.h" +#endif + +#ifndef _SVX_UNOMID_HXX +#include <svx/unomid.hxx> +#endif + +#ifndef _SVX_LRSPITEM_HXX +#include <svx/lrspitem.hxx> +#endif + +#ifndef _SVX_ULSPITEM_HXX +#include <svx/ulspitem.hxx> +#endif + +#ifndef _SVX_SHADITEM_HXX +#include <svx/shaditem.hxx> +#endif + +#ifndef _SVX_BOXITEM_HXX +#include <svx/boxitem.hxx> +#endif + +#ifndef _SVX_BRKITEM_HXX +#include <svx/brkitem.hxx> +#endif + +#ifndef _SVX_KEEPITEM_HXX +#include <svx/keepitem.hxx> +#endif + +#ifndef _SVX_BRSHITEM_HXX +#include <svx/brshitem.hxx> +#endif + +#ifndef _FMTPDSC_HXX +#include "fmtpdsc.hxx" +#endif + +#ifndef _FMTORNT_HXX +#include "fmtornt.hxx" +#endif + +#ifndef _FMTFSIZE_HXX +#include "fmtfsize.hxx" +#endif + +#ifndef _FMTLSPLT_HXX +#include "fmtlsplt.hxx" +#endif + +#ifndef _XMLOFF_XMLUCONV_HXX +#include <xmloff/xmluconv.hxx> +#endif + +#ifndef _XMLOFF_XMLTOKEN_HXX +#include <xmloff/xmltoken.hxx> +#endif + + +using namespace ::rtl; +using namespace ::xmloff::token; + + +#define SVX_XML_BORDER_STYLE_NONE 0 +#define SVX_XML_BORDER_STYLE_SOLID 1 +#define SVX_XML_BORDER_STYLE_DOUBLE 2 + +#define SVX_XML_BORDER_WIDTH_THIN 0 +#define SVX_XML_BORDER_WIDTH_MIDDLE 1 +#define SVX_XML_BORDER_WIDTH_THICK 2 + + +const struct SvXMLEnumMapEntry psXML_BorderStyles[] = +{ + { XML_NONE, SVX_XML_BORDER_STYLE_NONE }, + { XML_HIDDEN, SVX_XML_BORDER_STYLE_NONE }, + { XML_SOLID, SVX_XML_BORDER_STYLE_SOLID }, + { XML_DOUBLE, SVX_XML_BORDER_STYLE_DOUBLE }, + { XML_DOTTED, SVX_XML_BORDER_STYLE_SOLID }, + { XML_DASHED, SVX_XML_BORDER_STYLE_SOLID }, + { XML_GROOVE, SVX_XML_BORDER_STYLE_SOLID }, + { XML_RIDGE, SVX_XML_BORDER_STYLE_SOLID }, + { XML_INSET, SVX_XML_BORDER_STYLE_SOLID }, + { XML_OUTSET, SVX_XML_BORDER_STYLE_SOLID }, + { XML_TOKEN_INVALID, 0 } +}; + +const struct SvXMLEnumMapEntry psXML_NamedBorderWidths[] = +{ + { XML_THIN, SVX_XML_BORDER_WIDTH_THIN }, + { XML_MIDDLE, SVX_XML_BORDER_WIDTH_MIDDLE }, + { XML_THICK, SVX_XML_BORDER_WIDTH_THICK }, + { XML_TOKEN_INVALID, 0 } +}; +// mapping tables to map external xml input to intarnal box line widths + +// Ein Eintrag besteht aus vier USHORTs. Der erste ist die Gesamtbreite, +// die anderen sind die 3 Einzelbreiten + +#define SBORDER_ENTRY( n ) \ + DEF_LINE_WIDTH_##n, DEF_LINE_WIDTH_##n, 0, 0 + +#define DBORDER_ENTRY( n ) \ + DEF_DOUBLE_LINE##n##_OUT + DEF_DOUBLE_LINE##n##_IN + \ + DEF_DOUBLE_LINE##n##_DIST, \ + DEF_DOUBLE_LINE##n##_OUT, \ + DEF_DOUBLE_LINE##n##_IN, \ + DEF_DOUBLE_LINE##n##_DIST + +#define TDBORDER_ENTRY( n ) \ + DEF_DOUBLE_LINE##n##_OUT, \ + DEF_DOUBLE_LINE##n##_OUT, \ + DEF_DOUBLE_LINE##n##_IN, \ + DEF_DOUBLE_LINE##n##_DIST + + +const sal_uInt16 aSBorderWidths[] = +{ + SBORDER_ENTRY( 0 ), SBORDER_ENTRY( 1 ), SBORDER_ENTRY( 2 ), + SBORDER_ENTRY( 3 ), SBORDER_ENTRY( 4 ) +}; + +const sal_uInt16 aDBorderWidths[5*11] = +{ + DBORDER_ENTRY( 0 ), + DBORDER_ENTRY( 7 ), + DBORDER_ENTRY( 1 ), + DBORDER_ENTRY( 8 ), + DBORDER_ENTRY( 4 ), + DBORDER_ENTRY( 9 ), + DBORDER_ENTRY( 3 ), + DBORDER_ENTRY( 10 ), + DBORDER_ENTRY( 2 ), + DBORDER_ENTRY( 6 ), + DBORDER_ENTRY( 5 ) +}; + +sal_Bool lcl_frmitems_parseXMLBorder( const OUString& rValue, + const SvXMLUnitConverter& rUnitConverter, + sal_Bool& rHasStyle, sal_uInt16& rStyle, + sal_Bool& rHasWidth, sal_uInt16& rWidth, + sal_uInt16& rNamedWidth, + sal_Bool& rHasColor, Color& rColor ) +{ + OUString aToken; + SvXMLTokenEnumerator aTokens( rValue ); + + rHasStyle = sal_False; + rHasWidth = sal_False; + rHasColor = sal_False; + + rStyle = USHRT_MAX; + rWidth = 0; + rNamedWidth = USHRT_MAX; + + long nTemp; + while( aTokens.getNextToken( aToken ) && aToken.getLength() != 0 ) + { + if( !rHasWidth && + rUnitConverter.convertEnum( rNamedWidth, aToken, + psXML_NamedBorderWidths ) ) + { + rHasWidth = sal_True; + } + else if( !rHasStyle && + rUnitConverter.convertEnum( rStyle, aToken, + psXML_BorderStyles ) ) + { + rHasStyle = sal_True; + } + else if( !rHasColor && rUnitConverter.convertColor( rColor, aToken ) ) + { + rHasColor = sal_True; + } + else if( !rHasWidth && + rUnitConverter.convertMeasure( nTemp, aToken, 0, USHRT_MAX ) ) + { + rWidth = (sal_uInt16)nTemp; + rHasWidth = sal_True; + } + else + { + // missformed + return sal_False; + } + } + + return rHasStyle || rHasWidth || rHasColor; +} + +void lcl_frmitems_setXMLBorderWidth( SvxBorderLine& rLine, + sal_uInt16 nOutWidth, sal_uInt16 nInWidth, + sal_uInt16 nDistance ) +{ + rLine.SetOutWidth( nOutWidth ); + rLine.SetInWidth( nInWidth ); + rLine.SetDistance( nDistance ); +} + +void lcl_frmitems_setXMLBorderWidth( SvxBorderLine& rLine, + sal_uInt16 nWidth, sal_Bool bDouble ) +{ + const sal_uInt16 *aWidths; + sal_uInt16 nSize; + if( !bDouble ) + { + aWidths = aSBorderWidths; + nSize = sizeof( aSBorderWidths ); + } + else + { + aWidths = aDBorderWidths; + nSize = sizeof( aDBorderWidths ); + } + + sal_uInt16 i = (nSize / sizeof(sal_uInt16)) - 4; + while( i>0 && + nWidth <= ((aWidths[i] + aWidths[i-4]) / 2) ) + { + DBG_ASSERT( aWidths[i] >= aWidths[i-4], "line widths are unordered!" ); + i -= 4; + } + + rLine.SetOutWidth( aWidths[i+1] ); + rLine.SetInWidth( aWidths[i+2] ); + rLine.SetDistance( aWidths[i+3] ); +} + +sal_Bool lcl_frmitems_setXMLBorder( SvxBorderLine*& rpLine, + sal_Bool bHasStyle, sal_uInt16 nStyle, + sal_Bool bHasWidth, sal_uInt16 nWidth, + sal_uInt16 nNamedWidth, + sal_Bool bHasColor, const Color& rColor ) +{ + // first of all, delete an empty line + if( (bHasStyle && SVX_XML_BORDER_STYLE_NONE == nStyle) || + (bHasWidth && USHRT_MAX == nNamedWidth && 0 == nWidth) ) + { + sal_Bool bRet = 0 != rpLine; + if( rpLine ) + { + delete rpLine; + rpLine = 0; + } + + return bRet; + } + + // if there is no line and no style and no with, there will never be a line + if( !rpLine && !(bHasStyle && bHasWidth) ) + return sal_False; + + // We now do know that there will be a line + if( !rpLine ) + rpLine = new SvxBorderLine; + + + if( ( bHasWidth && + (USHRT_MAX != nNamedWidth || (nWidth != rpLine->GetOutWidth() + + rpLine->GetInWidth() + + rpLine->GetDistance()) ) ) || + ( bHasStyle && + ((SVX_XML_BORDER_STYLE_SOLID == nStyle && rpLine->GetDistance()) || + (SVX_XML_BORDER_STYLE_DOUBLE == nStyle && !rpLine->GetDistance())) )) + { + sal_Bool bDouble = (bHasWidth && SVX_XML_BORDER_STYLE_DOUBLE == nStyle ) || + rpLine->GetDistance(); + + // The width has to be changed + if( bHasWidth && USHRT_MAX != nNamedWidth ) + { + const sal_uInt16 *aWidths = bDouble ? aDBorderWidths :aSBorderWidths; + + sal_uInt16 nNWidth = nNamedWidth * 4; + rpLine->SetOutWidth( aWidths[nNWidth+1] ); + rpLine->SetInWidth( aWidths[nNWidth+2] ); + rpLine->SetDistance( aWidths[nNWidth+3] ); + + } + else + { + if( !bHasWidth ) + nWidth = rpLine->GetInWidth() + rpLine->GetDistance() + + rpLine->GetOutWidth(); + + lcl_frmitems_setXMLBorderWidth( *rpLine, nWidth, bDouble ); + } + } + + // set color + if( bHasColor ) + rpLine->SetColor( rColor ); + + return sal_True; +} + +void lcl_frmitems_setXMLBorder( SvxBorderLine*& rpLine, + sal_uInt16 nWidth, sal_uInt16 nOutWidth, + sal_uInt16 nInWidth, sal_uInt16 nDistance ) +{ + if( !rpLine ) + rpLine = new SvxBorderLine; + + if( nWidth > 0 ) + lcl_frmitems_setXMLBorderWidth( *rpLine, nWidth, sal_True ); + else + lcl_frmitems_setXMLBorderWidth( *rpLine, nOutWidth, nInWidth, + nDistance ); +} + +const struct SvXMLEnumMapEntry psXML_BrushRepeat[] = +{ + { XML_BACKGROUND_REPEAT, GPOS_TILED }, + { XML_BACKGROUND_NO_REPEAT, GPOS_MM }, + { XML_BACKGROUND_STRETCH, GPOS_AREA }, + { XML_TOKEN_INVALID, 0 } +}; + +const struct SvXMLEnumMapEntry psXML_BrushHoriPos[] = +{ + { XML_LEFT, GPOS_LM }, + { XML_RIGHT, GPOS_RM }, + { XML_TOKEN_INVALID, 0 } +}; + +const struct SvXMLEnumMapEntry psXML_BrushVertPos[] = +{ + { XML_TOP, GPOS_MT }, + { XML_BOTTOM, GPOS_MB }, + { XML_TOKEN_INVALID, 0 } +}; + +void lcl_frmitems_MergeXMLHoriPos( SvxGraphicPosition& ePos, + SvxGraphicPosition eHori ) +{ + DBG_ASSERT( GPOS_LM==eHori || GPOS_MM==eHori || GPOS_RM==eHori, + "lcl_frmitems_MergeXMLHoriPos: vertical pos must be middle" ); + + switch( ePos ) + { + case GPOS_LT: + case GPOS_MT: + case GPOS_RT: + ePos = GPOS_LM==eHori ? GPOS_LT : (GPOS_MM==eHori ? GPOS_MT : GPOS_RT); + break; + + case GPOS_LM: + case GPOS_MM: + case GPOS_RM: + ePos = eHori; + break; + + case GPOS_LB: + case GPOS_MB: + case GPOS_RB: + ePos = GPOS_LM==eHori ? GPOS_LB : (GPOS_MM==eHori ? GPOS_MB : GPOS_RB); + break; + } +} + +void lcl_frmitems_MergeXMLVertPos( SvxGraphicPosition& ePos, + SvxGraphicPosition eVert ) +{ + DBG_ASSERT( GPOS_MT==eVert || GPOS_MM==eVert || GPOS_MB==eVert, + "lcl_frmitems_MergeXMLVertPos: horizontal pos must be middle" ); + + switch( ePos ) + { + case GPOS_LT: + case GPOS_LM: + case GPOS_LB: + ePos = GPOS_MT==eVert ? GPOS_LT : (GPOS_MM==eVert ? GPOS_LM : GPOS_LB); + ePos = eVert; + break; + + case GPOS_MT: + case GPOS_MM: + case GPOS_MB: + ePos = eVert; + break; + + case GPOS_RT: + case GPOS_RM: + case GPOS_RB: + ePos = GPOS_MT==eVert ? GPOS_RT : (GPOS_MM==eVert ? GPOS_RM : GPOS_RB); + break; + } +} + + +const struct SvXMLEnumMapEntry psXML_BreakType[] = +{ + { XML_AUTO, 0 }, + { XML_COLUMN, 1 }, + { XML_PAGE, 2 }, + { XML_EVEN_PAGE, 2 }, + { XML_ODD_PAGE, 2 }, + { XML_TOKEN_INVALID, 0} +}; + +const struct SvXMLEnumMapEntry aXMLTableAlignMap[] = +{ + { XML_LEFT, HORI_LEFT }, + { XML_LEFT, HORI_LEFT_AND_WIDTH }, + { XML_CENTER, HORI_CENTER }, + { XML_RIGHT, HORI_RIGHT }, + { XML_MARGINS, HORI_FULL }, + { XML_MARGINS, HORI_NONE }, + { XML_TOKEN_INVALID, 0 } +}; + +const struct SvXMLEnumMapEntry aXMLTableVAlignMap[] = +{ + { XML_TOP, VERT_TOP }, + { XML_MIDDLE, VERT_CENTER }, + { XML_BOTTOM, VERT_BOTTOM }, + { XML_TOKEN_INVALID, 0 } +}; diff --git a/sw/source/filter/xml/xmlithlp.hxx b/sw/source/filter/xml/xmlithlp.hxx new file mode 100644 index 000000000000..4639b11e95c1 --- /dev/null +++ b/sw/source/filter/xml/xmlithlp.hxx @@ -0,0 +1,138 @@ +/************************************************************************* + * + * $RCSfile: xmlithlp.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dvo $ $Date: 2001-07-09 20:10:43 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SW_XMLITHLP_HXX +#define _SW_XMLITHLP_HXX + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + +#ifndef _XMLOFF_XMLEMENT_HXX +#include <xmloff/xmlement.hxx> +#endif + +class SvxBorderLine; +struct SvXMLEnumMapEntry; +class SvXMLUnitConverter; +class Color; +enum SvxGraphicPosition; +namespace rtl { class OUString; } + + + +/** Define various helper variables and functions for xmlimpit.cxx and + * xmlexpit.cxx. */ + + +#define SVX_XML_BORDER_STYLE_NONE 0 +#define SVX_XML_BORDER_STYLE_SOLID 1 +#define SVX_XML_BORDER_STYLE_DOUBLE 2 + +#define SVX_XML_BORDER_WIDTH_THIN 0 +#define SVX_XML_BORDER_WIDTH_MIDDLE 1 +#define SVX_XML_BORDER_WIDTH_THICK 2 + + +sal_Bool lcl_frmitems_parseXMLBorder( const ::rtl::OUString& rValue, + const SvXMLUnitConverter& rUnitConverter, + sal_Bool& rHasStyle, sal_uInt16& rStyle, + sal_Bool& rHasWidth, sal_uInt16& rWidth, + sal_uInt16& rNamedWidth, + sal_Bool& rHasColor, Color& rColor ); + +void lcl_frmitems_setXMLBorderWidth( SvxBorderLine& rLine, + sal_uInt16 nOutWidth, sal_uInt16 nInWidth, + sal_uInt16 nDistance ); + +void lcl_frmitems_setXMLBorderWidth( SvxBorderLine& rLine, + sal_uInt16 nWidth, sal_Bool bDouble ); + +sal_Bool lcl_frmitems_setXMLBorder( SvxBorderLine*& rpLine, + sal_Bool bHasStyle, sal_uInt16 nStyle, + sal_Bool bHasWidth, sal_uInt16 nWidth, + sal_uInt16 nNamedWidth, + sal_Bool bHasColor, const Color& rColor ); + +void lcl_frmitems_setXMLBorder( SvxBorderLine*& rpLine, + sal_uInt16 nWidth, sal_uInt16 nOutWidth, + sal_uInt16 nInWidth, sal_uInt16 nDistance ); + +void lcl_frmitems_MergeXMLHoriPos( SvxGraphicPosition& ePos, + SvxGraphicPosition eHori ); + +void lcl_frmitems_MergeXMLVertPos( SvxGraphicPosition& ePos, + SvxGraphicPosition eVert ); + +extern const sal_uInt16 aSBorderWidths[]; +extern const sal_uInt16 aDBorderWidths[5*11]; + +extern const struct SvXMLEnumMapEntry psXML_BorderStyles[]; +extern const struct SvXMLEnumMapEntry psXML_NamedBorderWidths[]; +extern const struct SvXMLEnumMapEntry psXML_BrushRepeat[]; +extern const struct SvXMLEnumMapEntry psXML_BrushHoriPos[]; +extern const struct SvXMLEnumMapEntry psXML_BrushVertPos[]; +extern const struct SvXMLEnumMapEntry psXML_BreakType[]; +extern const struct SvXMLEnumMapEntry aXMLTableAlignMap[]; +extern const struct SvXMLEnumMapEntry aXMLTableVAlignMap[]; + + +#endif diff --git a/sw/source/filter/xml/xmltble.cxx b/sw/source/filter/xml/xmltble.cxx index 993a807468fa..041c53f87924 100644 --- a/sw/source/filter/xml/xmltble.cxx +++ b/sw/source/filter/xml/xmltble.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmltble.cxx,v $ * - * $Revision: 1.18 $ + * $Revision: 1.19 $ * - * last change: $Author: jp $ $Date: 2001-07-05 17:28:23 $ + * last change: $Author: dvo $ $Date: 2001-07-09 20:10:43 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -401,7 +401,7 @@ sal_Bool SwXMLTableFrmFmtsSort_Impl::AddRow( SwFrmFmt& rFrmFmt, pFrmSize->GetHeight() != pTestFrmSize->GetHeight() ) ) continue; - if( pBrush && !pBrush->equalsXML( *pTestBrush ) ) + if( pBrush && (*pBrush != *pTestBrush) ) continue; // found! @@ -537,10 +537,10 @@ sal_Bool SwXMLTableFrmFmtsSort_Impl::AddCell( SwFrmFmt& rFrmFmt, pVertOrient->GetVertOrient() != pTestVertOrient->GetVertOrient() ) continue; - if( pBrush && !pBrush->equalsXML( *pTestBrush ) ) + if( pBrush && ( *pBrush != *pTestBrush ) ) continue; - if( pBox && !pBox->equalsXML( *pTestBox ) ) + if( pBox && ( *pBox != *pTestBox ) ) continue; // compare formats based on value (rather than presentation) |