diff options
author | Michael Brauer <mib@openoffice.org> | 2000-10-18 10:23:55 +0000 |
---|---|---|
committer | Michael Brauer <mib@openoffice.org> | 2000-10-18 10:23:55 +0000 |
commit | 0adb26902e341b44d02e92e2095c38beff76673b (patch) | |
tree | 018cef0186b99852f7928ea771e4c239dc0d5301 | |
parent | 3e6f28a2290080e8e8d2c292edf52fe33318dece (diff) |
master page import and export continued
-rw-r--r-- | sw/inc/fmtpdsc.hxx | 8 | ||||
-rw-r--r-- | sw/source/filter/xml/xmlfmt.cxx | 1045 | ||||
-rw-r--r-- | sw/source/filter/xml/xmlfmte.cxx | 267 | ||||
-rw-r--r-- | sw/source/filter/xml/xmlimp.cxx | 7 | ||||
-rw-r--r-- | sw/source/filter/xml/xmlimp.hxx | 7 | ||||
-rw-r--r-- | sw/source/filter/xml/xmlitemm.cxx | 13 | ||||
-rw-r--r-- | sw/source/filter/xml/xmltext.cxx | 12 |
7 files changed, 218 insertions, 1141 deletions
diff --git a/sw/inc/fmtpdsc.hxx b/sw/inc/fmtpdsc.hxx index d8353ea33e87..4702576d55fc 100644 --- a/sw/inc/fmtpdsc.hxx +++ b/sw/inc/fmtpdsc.hxx @@ -2,9 +2,9 @@ * * $RCSfile: fmtpdsc.hxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: hr $ $Date: 2000-09-18 17:14:26 $ + * last change: $Author: mib $ $Date: 2000-10-18 11:23:55 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -137,6 +137,10 @@ public: // // this item must be ignored while comparing item sets during XML export virtual BOOL equalsXML( const SfxPoolItem& ) const; + virtual BOOL importXML( const NAMESPACE_RTL(OUString)& rValue,USHORT, + const SvXMLUnitConverter& rUnitConv ); + virtual BOOL exportXML( NAMESPACE_RTL(OUString)& rValue, USHORT, + const SvXMLUnitConverter& rUnitConv ) const; }; inline const SwFmtPageDesc &SwAttrSet::GetPageDesc(BOOL bInP) const diff --git a/sw/source/filter/xml/xmlfmt.cxx b/sw/source/filter/xml/xmlfmt.cxx index 4a15c44aa044..c9b896a998df 100644 --- a/sw/source/filter/xml/xmlfmt.cxx +++ b/sw/source/filter/xml/xmlfmt.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmlfmt.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: mib $ $Date: 2000-10-12 17:32:03 $ + * last change: $Author: mib $ $Date: 2000-10-18 11:20:44 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -115,6 +115,12 @@ #ifndef _UNOSTYLE_HXX #include "unostyle.hxx" #endif +#ifndef _FMTPDSC_HXX +#include "fmtpdsc.hxx" +#endif +#ifndef _PAGEDESC_HXX +#include "pagedesc.hxx" +#endif #ifndef _XMLOFF_XMLNMSPE_HXX #include <xmloff/xmlnmspe.hxx> @@ -398,8 +404,6 @@ SwXMLConditionContext_Impl::~SwXMLConditionContext_Impl() typedef SwXMLConditionContext_Impl *SwXMLConditionContextPtr; SV_DECL_PTRARR( SwXMLConditions_Impl, SwXMLConditionContextPtr, 5, 2 ); -#ifndef XML_CORE_API - class SwXMLTextStyleContext_Impl : public XMLTextStyleContext { SwXMLConditions_Impl *pConditions; @@ -558,24 +562,16 @@ void SwXMLTextStyleContext_Impl::Finish( sal_Bool bOverwrite ) } } } -#endif // --------------------------------------------------------------------- class SwXMLItemSetStyleContext_Impl : public SvXMLStyleContext { -#ifdef XML_CORE_API - OUString sListStyleName; - SwFmt *pFmt; -#endif + OUString sMasterPageName; SfxItemSet *pItemSet; -#ifdef XML_CORE_API - SwXMLConditions_Impl *pConditions; - - sal_uInt16 nPoolId; // PoolId - sal_Bool bAutoUpdate; -#endif + sal_Bool bHasMasterPageName : 1; + sal_Bool bPageDescConnected : 1; SvXMLImportContext *CreateItemSetContext( sal_uInt16 nPrefix, @@ -584,11 +580,9 @@ class SwXMLItemSetStyleContext_Impl : public SvXMLStyleContext protected: -#ifdef XML_CORE_API virtual void SetAttribute( sal_uInt16 nPrefixKey, const OUString& rLocalName, const OUString& rValue ); -#endif const SwXMLImport& GetSwImport() const { return (const SwXMLImport&)GetImport(); } @@ -601,11 +595,8 @@ public: SwXMLItemSetStyleContext_Impl( SwXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName, - const Reference< xml::sax::XAttributeList > & xAttrList -#ifndef XML_CORE_API - ,sal_uInt16 nFamily -#endif - ); + const Reference< xml::sax::XAttributeList > & xAttrList, + sal_uInt16 nFamily); virtual ~SwXMLItemSetStyleContext_Impl(); virtual SvXMLImportContext *CreateChildContext( @@ -613,101 +604,32 @@ public: const OUString& rLocalName, const Reference< xml::sax::XAttributeList > & xAttrList ); -#ifdef XML_CORE_API - sal_uInt16 GetPoolId() const { return nPoolId; } - sal_Bool IsAutoUpdate() const { return bAutoUpdate; } -#endif - // The item set may be empty! SfxItemSet *GetItemSet() { return pItemSet; } const SfxItemSet *GetItemSet() const { return pItemSet; } -#ifdef XML_CORE_API - SwFmt *GetFmt() { return pFmt; } - void SetFmt( SwFmt *p ) { pFmt = p; } - - SwTxtFmtColl* GetColl(); - - sal_Bool HasConditions() const { return 0 != pConditions && - pConditions->Count() > 0; } - const OUString& GetListStyle() const { return sListStyleName; } + const OUString& GetMasterPageName() const { return sMasterPageName; } + sal_Bool HasMasterPageName() const { bHasMasterPageName; } - void ConnectParent(); - void ConnectFollow(); - void ConnectConditions(); - void ConnectListStyle(); - void ConnectAutoListStyle(); -#endif + sal_Bool IsPageDescConnected() const { return bPageDescConnected; } + void ConnectPageDesc(); }; -#ifdef XML_CORE_API void SwXMLItemSetStyleContext_Impl::SetAttribute( sal_uInt16 nPrefixKey, const OUString& rLocalName, const OUString& rValue ) { - // TODO: use a map here - if( XML_NAMESPACE_STYLE == nPrefixKey ) + if( XML_NAMESPACE_STYLE == nPrefixKey && + rLocalName.compareToAscii( sXML_master_page_name ) == 0 ) { - if( rLocalName.compareToAscii( sXML_family ) == 0 ) - { - SfxStyleFamily eFamily = SFX_STYLE_FAMILY_ALL; - sal_uInt16 nSubFamily = 0U; - if( rValue.compareToAscii( sXML_paragraph ) == 0 ) - { - eFamily = SFX_STYLE_FAMILY_PARA; - } - else if( rValue.compareToAscii( sXML_text ) == 0 ) - { - eFamily = SFX_STYLE_FAMILY_CHAR; - } - else if( 0 == rValue.compareToAscii( sXML_table, 5L ) ) - { - eFamily = SFX_STYLE_FAMILY_FRAME; - if( 5L == rValue.getLength() ) - nSubFamily = SW_STYLE_SUBFAMILY_TABLE; - else if( rValue.compareToAscii( sXML_table_column ) == 0 ) - nSubFamily = SW_STYLE_SUBFAMILY_TABLE_COL; - else if( rValue.compareToAscii( sXML_table_row ) == 0 ) - nSubFamily = SW_STYLE_SUBFAMILY_TABLE_LINE; - else if( rValue.compareToAscii( sXML_table_cell ) == 0 ) - nSubFamily = SW_STYLE_SUBFAMILY_TABLE_BOX; - else - eFamily = SFX_STYLE_FAMILY_ALL; - } - - if( SFX_STYLE_FAMILY_ALL != eFamily ) - { - SetFamily( eFamily ); - SetSubFamily( nSubFamily ); - } - } - else if( rLocalName.compareToAscii( sXML_pool_id ) == 0 ) - { - sal_Int32 nTmp = rValue.toInt32(); - nPoolId = - (nTmp < 0L) ? 0U : ( (nTmp > USHRT_MAX) ? USHRT_MAX - : (sal_uInt16)nTmp ); - } - else if( rLocalName.compareToAscii( sXML_auto_update ) == 0 ) - { - if( rValue.compareToAscii( sXML_true ) == 0 ) - bAutoUpdate = sal_True; - } - else if( rLocalName.compareToAscii( sXML_list_style_name ) == 0 ) - { - sListStyleName = rValue; - } - else - { - SvXMLStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue ); - } + sMasterPageName = rValue; + bHasMasterPageName = sal_True; } else { SvXMLStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue ); } } -#endif SvXMLImportContext *SwXMLItemSetStyleContext_Impl::CreateItemSetContext( sal_uInt16 nPrefix, const OUString& rLName, @@ -718,55 +640,6 @@ SvXMLImportContext *SwXMLItemSetStyleContext_Impl::CreateItemSetContext( SvXMLImportContext *pContext = 0; -#ifdef XML_CORE_API - SfxItemPool& rItemPool = GetSwImport().GetDoc().GetAttrPool(); - switch( GetFamily() ) - { - case SFX_STYLE_FAMILY_PARA: - pItemSet = new SfxItemSet( rItemPool, aTxtFmtCollSetRange ); - pContext = GetSwImport().CreateParaItemImportContext( - nPrefix, rLName, xAttrList, *pItemSet ); - break; - - case SFX_STYLE_FAMILY_CHAR: - pItemSet = new SfxItemSet( rItemPool, aCharFmtSetRange ); - pContext = GetSwImport().CreateParaItemImportContext( - nPrefix, rLName, xAttrList, *pItemSet ); - break; - - case SFX_STYLE_FAMILY_FRAME: - { - switch( GetSubFamily() ) - { - case SW_STYLE_SUBFAMILY_TABLE: - pItemSet = new SfxItemSet( rItemPool, aTableSetRange ); - break; - case SW_STYLE_SUBFAMILY_TABLE_COL: - pItemSet = new SfxItemSet( rItemPool, RES_FRM_SIZE, - RES_FRM_SIZE, 0 ); - break; - case SW_STYLE_SUBFAMILY_TABLE_LINE: - pItemSet = new SfxItemSet( rItemPool, aTableLineSetRange ); - break; - case SW_STYLE_SUBFAMILY_TABLE_BOX: - pItemSet = new SfxItemSet( rItemPool, aTableBoxSetRange ); - break; - } - if( pItemSet ) - pContext = GetSwImport().CreateTableItemImportContext( - nPrefix, rLName, xAttrList, GetSubFamily(), - *pItemSet ); - ASSERT( pItemSet, - "SwXMLItemSetStyleContext_Impl::CreateItemSetContext: frames are unsopprted"); - } - break; - - default: - ASSERT( !this, - "SwXMLItemSetStyleContext_Impl::CreateItemSetContext: unknown family" ); - break; - } -#else Reference<XUnoTunnel> xCrsrTunnel( GetImport().GetTextImport()->GetCursor(), UNO_QUERY); ASSERT( xCrsrTunnel.is(), "missing XUnoTunnel for Cursor" ); @@ -797,8 +670,6 @@ SvXMLImportContext *SwXMLItemSetStyleContext_Impl::CreateItemSetContext( pContext = GetSwImport().CreateTableItemImportContext( nPrefix, rLName, xAttrList, GetFamily(), *pItemSet ); -#endif - if( !pContext ) { delete pItemSet; @@ -812,40 +683,19 @@ TYPEINIT1( SwXMLItemSetStyleContext_Impl, SvXMLStyleContext ); SwXMLItemSetStyleContext_Impl::SwXMLItemSetStyleContext_Impl( SwXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName, - const Reference< xml::sax::XAttributeList > & xAttrList -#ifndef XML_CORE_API - ,sal_uInt16 nFamily -#endif - ) : + const Reference< xml::sax::XAttributeList > & xAttrList, + sal_uInt16 nFamily ) : SvXMLStyleContext( rImport, nPrfx, rLName, xAttrList ), -#ifdef XML_CORE_API - nPoolId( USHRT_MAX ), - bAutoUpdate( sal_False ), - pFmt( 0 ), - pConditions( 0 ), -#endif - pItemSet( 0 ) + pItemSet( 0 ), + bHasMasterPageName( sal_False ), + bPageDescConnected( sal_False ) { -#ifndef XML_CORE_API SetFamily( nFamily ); -#endif } SwXMLItemSetStyleContext_Impl::~SwXMLItemSetStyleContext_Impl() { delete pItemSet; -#ifdef XML_CORE_API - if( pConditions ) - { - while( pConditions->Count() ) - { - SwXMLConditionContext_Impl *pCond = pConditions->GetObject(0); - pConditions->Remove( 0UL ); - pCond->ReleaseRef(); - } - delete pConditions; - } -#endif } SvXMLImportContext *SwXMLItemSetStyleContext_Impl::CreateChildContext( @@ -861,22 +711,6 @@ SvXMLImportContext *SwXMLItemSetStyleContext_Impl::CreateChildContext( { pContext = CreateItemSetContext( nPrefix, rLocalName, xAttrList ); } -#ifdef XML_CORE_API - else if( rLocalName.compareToAscii( sXML_map ) == 0 ) - { - SwXMLConditionContext_Impl *pCond = - new SwXMLConditionContext_Impl( GetSwImport(), nPrefix, - rLocalName, xAttrList ); - if( pCond->IsValid() ) - { - if( !pConditions ) - pConditions = new SwXMLConditions_Impl; - pConditions->Insert( pCond, pConditions->Count() ); - pCond->AddRef(); - } - pContext = pCond; - } -#endif } if( !pContext ) @@ -886,180 +720,67 @@ SvXMLImportContext *SwXMLItemSetStyleContext_Impl::CreateChildContext( return pContext; } -#ifdef XML_CORE_API -SwTxtFmtColl* SwXMLItemSetStyleContext_Impl::GetColl() -{ - return (GetFamily() & SFX_STYLE_FAMILY_PARA) != 0 - ? (SwTxtFmtColl*) pFmt - : NULL; -} - -void SwXMLItemSetStyleContext_Impl::ConnectParent() +void SwXMLItemSetStyleContext_Impl::ConnectPageDesc() { - if( !pFmt ) + if( bPageDescConnected || !HasMasterPageName() ) return; + bPageDescConnected = sal_True; - SwDoc *pDoc = pFmt->GetDoc(); - String aName( GetSwImport().GetI18NMap().Get( GetFamily(), GetParent() ) ); + Reference<XUnoTunnel> xCrsrTunnel( GetImport().GetTextImport()->GetCursor(), + UNO_QUERY); + ASSERT( xCrsrTunnel.is(), "missing XUnoTunnel for Cursor" ); + SwXTextCursor *pTxtCrsr = (SwXTextCursor*)xCrsrTunnel->getSomething( + SwXTextCursor::getUnoTunnelId() ); + ASSERT( pTxtCrsr, "SwXTextCursor missing" ); + SwDoc *pDoc = pTxtCrsr->GetDoc(); -// String aName( SwXStyleFamilies::GetUIName( GetParent(), -// (SfxStyleFamily)GetFamily() ) ); - SwFmt* pParent; - switch( GetFamily() ) + String sName( SwXStyleFamilies::GetUIName( GetMasterPageName(), + SFX_STYLE_FAMILY_PAGE ) ); + SwPageDesc *pPageDesc = pDoc->FindPageDescByName( sName ); + if( !pPageDesc ) { - case SFX_STYLE_FAMILY_PARA: - if( aName.Len() ) - pParent = pDoc->FindTxtFmtCollByName( aName ); - else - pParent = (*pDoc->GetTxtFmtColls())[ 0 ]; - break; - - case SFX_STYLE_FAMILY_FRAME: - if( aName.Len() ) - pParent = pDoc->FindFrmFmtByName( aName ); - else - pParent = (*pDoc->GetFrmFmts())[ 0 ]; - break; - - case SFX_STYLE_FAMILY_CHAR: - if( aName.Len() ) - pParent = pDoc->FindCharFmtByName( aName ); - else - pParent = (*pDoc->GetCharFmts())[ 0 ]; - break; + // If the page style is a pool style, then we maybe have to create it + // first if it hasn't been used by now. + sal_uInt16 nPoolId = pDoc->GetPoolId( sName, GET_POOLID_PAGEDESC ); + if( USHRT_MAX != nPoolId ) + pPageDesc = pDoc->GetPageDescFromPool( nPoolId ); } - if( pParent ) - pFmt->SetDerivedFrom( pParent ); -} - -void SwXMLItemSetStyleContext_Impl::ConnectFollow() -{ - if( !pFmt || GetFamily() != SFX_STYLE_FAMILY_PARA ) + if( !pPageDesc ) return; - SwDoc *pDoc = pFmt->GetDoc(); - String aName( GetSwImport().GetI18NMap().Get( GetFamily(), GetFollow() ) ); -// String aName( SwXStyleFamilies::GetUIName( GetFollow(), (SfxStyleFamily)GetFamily() ) ); - - SwTxtFmtColl* pFollow; - if( aName.Len() ) - pFollow = pDoc->FindTxtFmtCollByName( aName ); - else - pFollow = GetColl(); - if( pFollow ) - GetColl()->SetNextTxtFmtColl( *pFollow ); -} - -void SwXMLItemSetStyleContext_Impl::ConnectConditions() -{ - if( !pFmt || GetFamily() != SFX_STYLE_FAMILY_PARA || !pConditions || - RES_CONDTXTFMTCOLL != pFmt->Which() ) - return; - - SwDoc *pDoc = pFmt->GetDoc(); - SvI18NMap& rI18NMap = ((SwXMLImport&)GetImport()).GetI18NMap(); - - sal_uInt16 nCount = pConditions->Count(); - for( sal_uInt16 i = 0; i < nCount; i++ ) + if( !pItemSet ) { - const SwXMLConditionContext_Impl *pCond = (*pConditions)[i]; - OUString sName( rI18NMap.Get( SFX_STYLE_FAMILY_PARA, - pCond->GetApplyStyle() ) ); -// OUString sName( SwXStyleFamilies::GetUIName( -// pCond->GetApplyStyle(), SFX_STYLE_FAMILY_PARA ) ); - SwTxtFmtColl* pCondColl = pDoc->FindTxtFmtCollByName( sName ); - ASSERT( pCondColl, - "SwXMLItemSetStyleContext_Impl::ConnectConditions: cond coll missing" ); - if( pCondColl ) - { - SwCollCondition aCond( pCondColl, pCond->GetCondition(), - pCond->GetSubCondition() ); - ((SwConditionTxtFmtColl*)pFmt)->InsertCondition( aCond ); - } + SfxItemPool& rItemPool = pDoc->GetAttrPool(); + pItemSet = new SfxItemSet( rItemPool, aTableSetRange ); } -} - -void SwXMLItemSetStyleContext_Impl::ConnectListStyle() -{ - if( !pFmt || GetFamily() != SFX_STYLE_FAMILY_PARA || - !GetListStyle().getLength() ) - return; - - SwDoc *pDoc = pFmt->GetDoc(); - String aName( GetSwImport().GetI18NMap().Get( SFX_STYLE_FAMILY_PSEUDO, - GetListStyle() ) ); -// String aName( SwXStyleFamilies::GetUIName( -// GetListStyle(), SFX_STYLE_FAMILY_PSEUDO ) ); - // Styles must not reference automatic num rules - SwNumRule *pNumRule = pDoc->FindNumRulePtr( aName ); - if( pNumRule && !pNumRule->IsAutoRule() ) - GetColl()->SetAttr( SwNumRuleItem(aName) ); -} - -void SwXMLItemSetStyleContext_Impl::ConnectAutoListStyle() -{ - if( GetFamily() != SFX_STYLE_FAMILY_PARA || !GetListStyle().getLength() ) - return; - SwDoc& rDoc = GetSwImport().GetDoc(); - String aName( GetSwImport().GetI18NMap().Get( SFX_STYLE_FAMILY_PSEUDO, - GetListStyle() ) ); -// String aName( SwXStyleFamilies::GetUIName( -// GetListStyle(), SFX_STYLE_FAMILY_PSEUDO ) ); - if( rDoc.FindNumRulePtr( aName ) ) + const SfxPoolItem *pItem; + SwFmtPageDesc *pFmtPageDesc = 0; + if( SFX_ITEM_SET == pItemSet->GetItemState( RES_PAGEDESC, sal_False, + &pItem ) ) { - if( !pItemSet ) - { - SfxItemPool& rItemPool = rDoc.GetAttrPool(); - pItemSet = new SfxItemSet( rItemPool, aTxtFmtCollSetRange ); - } - pItemSet->Put( SwNumRuleItem(aName) ); + if( ((SwFmtPageDesc *)pItem)->GetPageDesc() != pPageDesc ) + pFmtPageDesc = new SwFmtPageDesc( *(SwFmtPageDesc *)pItem ); } -} -#endif - -// --------------------------------------------------------------------- - -#ifdef XML_CORE_API -enum SwXMLStyleStylesElemTokens -{ - SW_XML_TOK_STYLE_STYLE, - SW_XML_TOK_TEXT_LIST_STYLE, - SW_XML_TOK_TEXT_OUTLINE, - SW_XML_TOK_STYLE_STYLES_ELEM_END=XML_TOK_UNKNOWN -}; - -static __FAR_DATA SvXMLTokenMapEntry aStyleStylesElemTokenMap[] = -{ - { XML_NAMESPACE_STYLE, sXML_style, SW_XML_TOK_STYLE_STYLE }, - { XML_NAMESPACE_TEXT, sXML_list_style, SW_XML_TOK_TEXT_LIST_STYLE}, - { XML_NAMESPACE_TEXT, sXML_outline_style, SW_XML_TOK_TEXT_OUTLINE }, - XML_TOKEN_MAP_END -}; - -const SvXMLTokenMap& SwXMLImport::GetStyleStylesElemTokenMap() -{ - if( !pStyleStylesElemTokenMap ) - pStyleStylesElemTokenMap = - new SvXMLTokenMap( aStyleStylesElemTokenMap ); + else + pFmtPageDesc = new SwFmtPageDesc(); - return *pStyleStylesElemTokenMap; + if( pFmtPageDesc ) + { + pPageDesc->Add( pFmtPageDesc ); + pItemSet->Put( *pFmtPageDesc ); + delete pFmtPageDesc; + } } -#endif // --------------------------------------------------------------------- // class SwXMLStylesContext_Impl : public SvXMLStylesContext { - SwXMLItemSetStyleContext_Impl *GetSwStyle( sal_uInt16 i ) const; -#ifdef XML_CORE_API - SwXMLListStyleContext *GetSwListStyle( sal_uInt16 i ) const; + sal_Bool bAutoStyles; - SwFmt *FindFmtByName( const String& rName, - sal_uInt16 eFamily ) const; - SwXMLItemSetStyleContext_Impl *FindByPoolId( sal_uInt16 nPoolId ) const; -#endif + SwXMLItemSetStyleContext_Impl *GetSwStyle( sal_uInt16 i ) const; SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); } const SwXMLImport& GetSwImport() const @@ -1067,13 +788,6 @@ class SwXMLStylesContext_Impl : public SvXMLStylesContext protected: -#ifdef XML_CORE_API - // Create a style context. - virtual SvXMLStyleContext *CreateStyleChildContext( - sal_uInt16 nPrefix, - const OUString& rLocalName, - const Reference< xml::sax::XAttributeList > & xAttrList ); -#else virtual SvXMLStyleContext *CreateStyleStyleChildContext( sal_uInt16 nFamily, sal_uInt16 nPrefix, const OUString& rLocalName, const Reference< xml::sax::XAttributeList > & xAttrList ); @@ -1086,7 +800,6 @@ protected: GetStylesContainer( sal_uInt16 nFamily ) const; virtual ::rtl::OUString GetServiceName( sal_uInt16 nFamily ) const; // HACK -#endif public: @@ -1095,14 +808,13 @@ public: SwXMLStylesContext_Impl( SwXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName , - const Reference< xml::sax::XAttributeList > & xAttrList ); + const Reference< xml::sax::XAttributeList > & xAttrList, + sal_Bool bAuto ); virtual ~SwXMLStylesContext_Impl(); virtual sal_Bool InsertStyleFamily( sal_uInt16 nFamily ) const; -#ifdef XML_CORE_API - void CopyStylesToDoc(); - void CopyAutoStylesToDoc(); -#endif + + virtual void EndElement(); }; TYPEINIT1( SwXMLStylesContext_Impl, SvXMLStylesContext ); @@ -1113,115 +825,6 @@ inline SwXMLItemSetStyleContext_Impl *SwXMLStylesContext_Impl::GetSwStyle( return PTR_CAST( SwXMLItemSetStyleContext_Impl, GetStyle( i ) ); } -#ifdef XML_CORE_API -inline SwXMLListStyleContext *SwXMLStylesContext_Impl::GetSwListStyle( - sal_uInt16 i ) const -{ - return PTR_CAST( SwXMLListStyleContext, GetStyle( i ) ); -} - -sal_Bool lcl_xmlfmt_isValidPoolId( sal_uInt16 nPoolId, sal_uInt16 eFamily ) -{ - sal_Bool bValid = sal_False; - - // check if pool id is valid - if( eFamily & SFX_STYLE_FAMILY_CHAR ) - { - bValid = (RES_POOLCHR_NORMAL_BEGIN <= nPoolId && - nPoolId < RES_POOLCHR_NORMAL_END) || - (RES_POOLCHR_HTML_BEGIN <= nPoolId && - nPoolId < RES_POOLCHR_HTML_END); - } - else if( eFamily & SFX_STYLE_FAMILY_FRAME ) - { - bValid = RES_POOLFRM_BEGIN <= nPoolId && nPoolId < RES_POOLFRM_END; - } - else if( eFamily & SFX_STYLE_FAMILY_PARA ) - { - bValid = (RES_POOLCOLL_TEXT_BEGIN <= nPoolId && - nPoolId < RES_POOLCOLL_TEXT_END) || - (RES_POOLCOLL_LISTS_BEGIN <= nPoolId && - nPoolId < RES_POOLCOLL_LISTS_END) || - (RES_POOLCOLL_EXTRA_BEGIN <= nPoolId && - nPoolId < RES_POOLCOLL_EXTRA_END) || - (RES_POOLCOLL_REGISTER_BEGIN <= nPoolId && - nPoolId < RES_POOLCOLL_REGISTER_END) || - (RES_POOLCOLL_DOC_BEGIN <= nPoolId && - nPoolId < RES_POOLCOLL_DOC_END) || - (RES_POOLCOLL_HTML_BEGIN <= nPoolId && - nPoolId < RES_POOLCOLL_HTML_END); - } - - return bValid; -} - -SwFmt *SwXMLStylesContext_Impl::FindFmtByName( const String& rName, - sal_uInt16 eFamily ) const -{ - const SwDoc& rDoc = GetSwImport().GetDoc(); - SwFmt *pFmt = 0; - switch( eFamily ) - { - case SFX_STYLE_FAMILY_PARA: - pFmt = rDoc.FindTxtFmtCollByName( rName ); - break; - case SFX_STYLE_FAMILY_FRAME: - pFmt = rDoc.FindFrmFmtByName( rName ); - break; - case SFX_STYLE_FAMILY_CHAR: - pFmt = rDoc.FindCharFmtByName( rName ); - break; - } - - return pFmt; -} - -SwXMLItemSetStyleContext_Impl *SwXMLStylesContext_Impl::FindByPoolId( - sal_uInt16 nPoolId ) const -{ - SwXMLItemSetStyleContext_Impl *pStyle = 0; - sal_uInt16 nCount = GetStyleCount(); - for( sal_uInt16 i=0; i < nCount && !pStyle; i++ ) - { - SwXMLItemSetStyleContext_Impl *pTmp = GetSwStyle( i ); - if( pTmp && pTmp->GetPoolId() == nPoolId ) - pStyle = pTmp; - } - - return pStyle; -} - -SvXMLStyleContext *SwXMLStylesContext_Impl::CreateStyleChildContext( - sal_uInt16 nPrefix, const OUString& rLocalName, - const Reference< xml::sax::XAttributeList > & xAttrList ) -{ - SvXMLStyleContext *pStyle = 0; - - const SvXMLTokenMap& rTokenMap = GetSwImport().GetStyleStylesElemTokenMap(); - switch( rTokenMap.Get( nPrefix, rLocalName ) ) - { - case SW_XML_TOK_STYLE_STYLE: - pStyle = new SwXMLItemSetStyleContext_Impl( GetSwImport(), nPrefix, rLocalName, - xAttrList); - break; - case SW_XML_TOK_TEXT_LIST_STYLE: - pStyle = new SwXMLListStyleContext( GetSwImport(), nPrefix, - rLocalName, xAttrList ); - break; - case SW_XML_TOK_TEXT_OUTLINE: - pStyle = new SwXMLListStyleContext( GetSwImport(), nPrefix, - rLocalName, xAttrList, sal_True ); - break; - default: - pStyle = SvXMLStylesContext::CreateStyleChildContext( nPrefix, - rLocalName, - xAttrList ); - break; - } - - return pStyle; -} -#else SvXMLStyleContext *SwXMLStylesContext_Impl::CreateStyleStyleChildContext( sal_uInt16 nFamily, sal_uInt16 nPrefix, const OUString& rLocalName, const Reference< xml::sax::XAttributeList > & xAttrList ) @@ -1256,12 +859,13 @@ SvXMLStyleContext *SwXMLStylesContext_Impl::CreateStyleStyleChildContext( return pStyle; } -#endif SwXMLStylesContext_Impl::SwXMLStylesContext_Impl( SwXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName, - const Reference< xml::sax::XAttributeList > & xAttrList ) : - SvXMLStylesContext( rImport, nPrfx, rLName, xAttrList ) + const Reference< xml::sax::XAttributeList > & xAttrList, + sal_Bool bAuto ) : + SvXMLStylesContext( rImport, nPrfx, rLName, xAttrList ), + bAutoStyles( bAuto ) { } @@ -1269,7 +873,6 @@ SwXMLStylesContext_Impl::~SwXMLStylesContext_Impl() { } -#ifndef XML_CORE_API sal_Bool SwXMLStylesContext_Impl::InsertStyleFamily( sal_uInt16 nFamily ) const { const SwXMLImport& rSwImport = GetSwImport(); @@ -1336,277 +939,68 @@ OUString SwXMLStylesContext_Impl::GetServiceName( sal_uInt16 nFamily ) const return sServiceName; } -#endif -#ifdef XML_CORE_API -void SwXMLStylesContext_Impl::CopyStylesToDoc() +void SwXMLStylesContext_Impl::EndElement() { - SwXMLImport& rSwImport = GetSwImport(); - SwDoc& rDoc = rSwImport.GetDoc(); - SvI18NMap& rI18NMap = rSwImport.GetI18NMap(); - sal_Bool bInsertMode = rSwImport.IsInsertMode(); - sal_uInt16 nStyleFamilyMask = rSwImport.GetStyleFamilyMask(); - - // The following families are of interest for pass 1 - sal_uInt16 nFamilies = nStyleFamilyMask & - ( SFX_STYLE_FAMILY_FRAME|SFX_STYLE_FAMILY_PARA| - SFX_STYLE_FAMILY_CHAR ); - - // pass 1: create text, paragraph and frame styles - sal_uInt16 nCount = GetStyleCount(); - for( sal_uInt16 i=0; i<nCount; i++ ) - { - SwXMLItemSetStyleContext_Impl *pStyle = GetSwStyle( i ); - if( !pStyle ) - { - continue; - } - - sal_uInt16 eFamily = pStyle->GetFamily(); - if( !(nFamilies & eFamily) ) - { - pStyle->SetValid( sal_False ); - continue; - } - - const OUString& rName = pStyle->GetName(); - if( 0 == rName.getLength() ) - { - pStyle->SetValid( sal_False ); - continue; - } - OUString sName = - SwXStyleFamilies::GetUIName( rName, (SfxStyleFamily)eFamily ); - -// sal_uInt16 nPoolId = pStyle->GetPoolId(); + GetSwImport().InsertStyles( bAutoStyles ); +} - sal_Bool bNewFmt = sal_False; - SwFmt *pFmt = FindFmtByName( sName, eFamily ); - if( !pFmt ) - { - // it is a new format - SwGetPoolIdFromName eNameType; - if( eFamily & SFX_STYLE_FAMILY_CHAR ) - eNameType = GET_POOLID_CHRFMT; - else if( eFamily & SFX_STYLE_FAMILY_FRAME ) - eNameType = GET_POOLID_FRMFMT; - else - eNameType = GET_POOLID_TXTCOLL; - - sal_uInt16 nPoolId = rDoc.GetPoolId( sName, eNameType ); - bNewFmt = sal_True; -// sal_Bool bIsUserDefined = (nPoolId & USER_FMT) != 0; - sal_Bool bIsUserDefined = nPoolId == USHRT_MAX; -#if 0 - if( !bIsUserDefined ) - { - bIsUserDefined = !lcl_xmlfmt_isValidPoolId( nPoolId, eFamily ); - if( bIsUserDefined ) - { - // If the pool id is invalid create a user style - nPoolId |= (USHRT_MAX & - ~(COLL_GET_RANGE_BITS + POOLGRP_NOCOLLID)); - } - } - else - { - // The style is not a pool style, but maybe there is - // a pool style with this name now? - SwGetPoolIdFromName eNameType; - if( eFamily & SFX_STYLE_FAMILY_CHAR ) - eNameType = GET_POOLID_CHRFMT; - else if( eFamily & SFX_STYLE_FAMILY_FRAME ) - eNameType = GET_POOLID_FRMFMT; - else - eNameType = GET_POOLID_TXTCOLL; - sal_uInt16 nId = rDoc.GetPoolId( rName, eNameType ); - if( nId != USHRT_MAX ) - { - if( FindByPoolId( nId ) ) - { - // There is a style with the new pool id, too. - // This means, that the user style will be ignored. - continue; - } - else - { - bIsUserDefined = sal_False; - nPoolId = nId; - } - } - } -#endif +// --------------------------------------------------------------------- +// +class SwXMLMasterStylesContext_Impl : public XMLTextMasterStylesContext +{ +protected: + virtual sal_Bool InsertStyleFamily( sal_uInt16 nFamily ) const; - if( bIsUserDefined ) - { - if( eFamily & SFX_STYLE_FAMILY_CHAR ) - { - pFmt = rDoc.MakeCharFmt( rName, NULL ); - pFmt->SetAuto( sal_False ); - } - else if( eFamily & SFX_STYLE_FAMILY_FRAME ) - { - pFmt = rDoc.MakeFrmFmt( rName, NULL ); - pFmt->SetAuto( sal_False ); - } - else if( pStyle->HasConditions() ) - { - SwTxtFmtColl* pDer = (*rDoc.GetTxtFmtColls())[ 0 ]; - pFmt = rDoc.MakeCondTxtFmtColl( rName, pDer ); - } - else - { - SwTxtFmtColl* pDer = (*rDoc.GetTxtFmtColls())[ 0 ]; - pFmt = rDoc.MakeTxtFmtColl( rName, pDer ); - } + SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); } + const SwXMLImport& GetSwImport() const + { return (const SwXMLImport&)GetImport(); } -// pFmt->SetPoolFmtId( nPoolId ); -// if( pStyle->GetHelpFile().getLength() ) -// pFmt->SetPoolHlpFileId -// ( (sal_Int8) rDoc.SetDocPattern( -// pStyle->GetHelpFile() ) ); -// pFmt->SetPoolHelpId( (sal_uInt16)pStyle->GetHelpId() ); - } - else - { - if( eFamily & SFX_STYLE_FAMILY_CHAR ) - { - sal_uInt16 nStyleCnt = rDoc.GetCharFmts()->Count(); - pFmt = rDoc.GetCharFmtFromPool( nPoolId ); - bNewFmt = nStyleCnt != rDoc.GetCharFmts()->Count(); - } - else if( eFamily & SFX_STYLE_FAMILY_FRAME ) - { - sal_uInt16 nStyleCnt = rDoc.GetFrmFmts()->Count(); - pFmt = rDoc.GetFrmFmtFromPool( nPoolId ); - bNewFmt = nStyleCnt != rDoc.GetFrmFmts()->Count(); - } - else - { - sal_uInt16 nStyleCnt = rDoc.GetTxtFmtColls()->Count(); - pFmt = rDoc.GetTxtCollFromPool( nPoolId ); - bNewFmt = nStyleCnt != rDoc.GetTxtFmtColls()->Count(); - } +public: - // If the name of the pool style has been changed, add - // a i18n map entry. - if( String(rName) != pFmt->GetName() ) - rI18NMap.Add( eFamily, pStyle->GetName(), pFmt->GetName() ); - } - } -#if 0 - else if( (nPoolId & USER_FMT) != 0 ) - { - // If a pool style has been renamed it may have the same - // name a a user style. If this is the case, the user style - // will be ignored. - sal_uInt16 nId = pFmt->GetPoolFmtId(); - SwXMLItemSetStyleContext_Impl *pTmp; - if( nId != nPoolId && (nId & USER_FMT) == 0 && - (pTmp = FindByPoolId( nPoolId )) != 0 && - pTmp->GetFmt() == pFmt ) - { - pStyle->SetValid( sal_False ); - continue; - } - } -#endif + TYPEINFO(); - pStyle->SetFmt( pFmt ); + SwXMLMasterStylesContext_Impl( + SwXMLImport& rImport, sal_uInt16 nPrfx, + const OUString& rLName , + const Reference< xml::sax::XAttributeList > & xAttrList ); + virtual ~SwXMLMasterStylesContext_Impl(); + virtual void EndElement(); +}; - if( !bInsertMode || bNewFmt ) - { - if( pStyle->GetItemSet() ) - { - pFmt->ResetAllAttr(); // delete default attributes +TYPEINIT1( SwXMLMasterStylesContext_Impl, XMLTextMasterStylesContext ); - ((SwAttrSet&) pFmt->GetAttrSet()).Put( *pStyle->GetItemSet() ); - } - SwTxtFmtColl* pColl = pStyle->GetColl(); - if( pColl ) - { - ((SwAttrSet&) pColl->GetAttrSet()).SetModifyAtAttr( pColl ); - } - pFmt->SetAutoUpdateFmt( pStyle->IsAutoUpdate() ); - } - else - { - pStyle->SetValid( sal_False ); - } - } +SwXMLMasterStylesContext_Impl::SwXMLMasterStylesContext_Impl( + SwXMLImport& rImport, sal_uInt16 nPrfx, + const OUString& rLName , + const Reference< xml::sax::XAttributeList > & xAttrList ) : + XMLTextMasterStylesContext( rImport, nPrfx, rLName, xAttrList ) +{ +} - // pass 2: connect parent/next styles and create list styles - for( i=0; i<nCount; i++ ) - { - SwXMLItemSetStyleContext_Impl *pStyle = GetSwStyle( i ); - if( !pStyle ) - { - if( (nStyleFamilyMask & SFX_STYLE_FAMILY_PSEUDO) != 0 ) - { - SwXMLListStyleContext *pListStyle = GetSwListStyle( i ); - if( pListStyle ) - pListStyle->InsertNumRule( sal_False ); - } - continue; - } - else if( !pStyle->IsValid() ) - continue; +SwXMLMasterStylesContext_Impl::~SwXMLMasterStylesContext_Impl() +{ +} - sal_uInt16 eFamily = pStyle->GetFamily(); - if( (nFamilies & eFamily) != 0 ) - { - pStyle->ConnectParent(); - pStyle->ConnectFollow(); +sal_Bool SwXMLMasterStylesContext_Impl::InsertStyleFamily( sal_uInt16 nFamily ) const +{ + sal_Bool bIns; - // The format has been changed - SwFmtChg aHint( pStyle->GetFmt() ); - pStyle->GetFmt()->Modify( &aHint, &aHint ); - } - } + const SwXMLImport& rSwImport = GetSwImport(); + sal_uInt16 nStyleFamilyMask = rSwImport.GetStyleFamilyMask(); + if( XML_STYLE_FAMILY_MASTER_PAGE == nFamily ) + bIns = (nStyleFamilyMask & SFX_STYLE_FAMILY_PAGE) != 0; + else + bIns = XMLTextMasterStylesContext::InsertStyleFamily( nFamily ); - // pass 3: connect conditions and list styles - for( i=0; i<nCount; i++ ) - { - SwXMLItemSetStyleContext_Impl *pStyle = GetSwStyle( i ); - if( pStyle && pStyle->IsValid() && - (nFamilies & pStyle->GetFamily()) != 0 ) - { - pStyle->ConnectListStyle(); - if( pStyle->HasConditions() ) - pStyle->ConnectConditions(); - } - } + return bIns; } -void SwXMLStylesContext_Impl::CopyAutoStylesToDoc() +void SwXMLMasterStylesContext_Impl::EndElement() { - // pass 1: create list styles - sal_uInt16 nCount = GetStyleCount(); - if( (GetSwImport().GetStyleFamilyMask() & SFX_STYLE_FAMILY_PSEUDO) != 0 ) - { - for( sal_uInt16 i=0; i<nCount; i++ ) - { - SwXMLListStyleContext *pListStyle = GetSwListStyle( i ); - if( pListStyle && !pListStyle->IsOutline() ) - pListStyle->InsertNumRule( sal_True ); - } - } - - // pass 3: connect list styles - if( (GetSwImport().GetStyleFamilyMask() & SFX_STYLE_FAMILY_PARA) != 0 ) - { - for( sal_uInt16 i=0; i<nCount; i++ ) - { - SwXMLItemSetStyleContext_Impl *pStyle = GetSwStyle( i ); - if( pStyle && SFX_STYLE_FAMILY_PARA == pStyle->GetFamily() ) - { - pStyle->ConnectAutoListStyle(); - } - } - } + FinishStyles( !GetSwImport().IsInsertMode() ); + GetSwImport().FinishStyles(); } -#endif - // --------------------------------------------------------------------- SvXMLImportContext *SwXMLImport::CreateStylesContext( @@ -1616,7 +1010,7 @@ SvXMLImportContext *SwXMLImport::CreateStylesContext( { SvXMLImportContext *pContext = new SwXMLStylesContext_Impl( *this, XML_NAMESPACE_OFFICE, rLocalName, - xAttrList ); + xAttrList, bAuto ); if( bAuto ) xAutoStyles = pContext; else @@ -1630,64 +1024,53 @@ SvXMLImportContext *SwXMLImport::CreateMasterStylesContext( const Reference< xml::sax::XAttributeList > & xAttrList ) { SvXMLImportContext *pContext = - new XMLTextMasterStylesContext( *this, XML_NAMESPACE_OFFICE, rLocalName, + new SwXMLMasterStylesContext_Impl( *this, XML_NAMESPACE_OFFICE, rLocalName, xAttrList ); return pContext; } -void SwXMLImport::InsertStyles() +void SwXMLImport::InsertStyles( sal_Bool bAuto ) { - sal_Bool bStylesValid = xStyles.Is(); - bAutoStylesValid = xAutoStyles.Is(); - - if( bStylesValid ) -#ifdef XML_CORE_API - ((SwXMLStylesContext_Impl *)&xStyles)->CopyStylesToDoc(); -#else + if( !bAuto && xStyles.Is() ) ((SwXMLStylesContext_Impl *)&xStyles)->CopyStylesToDoc( - !IsInsertMode() ); -#endif - xStyles = 0; + !IsInsertMode(), + sal_False ); - if( bAutoStylesValid ) -#ifdef XML_CORE_API - ((SwXMLStylesContext_Impl *)&xAutoStyles)->CopyAutoStylesToDoc(); -#else + if( bAuto && xAutoStyles.Is() ) GetTextImport()->SetAutoStyles( (SwXMLStylesContext_Impl *)&xAutoStyles ); -#endif - else - xAutoStyles = 0; +} + +void SwXMLImport::FinishStyles() +{ + if( xStyles.Is() ) + ((SwXMLStylesContext_Impl *)&xStyles)->FinishStyles( + !IsInsertMode() ); } sal_Bool SwXMLImport::FindAutomaticStyle( -#ifdef XML_CORE_API - SfxStyleFamily eFamily, - sal_uInt16 nSubFamily, -#else sal_uInt16 nFamily, -#endif const OUString& rName, const SfxItemSet **ppItemSet, OUString *pParent ) const { - const SwXMLItemSetStyleContext_Impl *pStyle = 0; - if( bAutoStylesValid && xAutoStyles.Is() ) + SwXMLItemSetStyleContext_Impl *pStyle = 0; + if( xAutoStyles.Is() ) { -#ifdef XML_CORE_API - pStyle = PTR_CAST( SwXMLItemSetStyleContext_Impl, - ((SwXMLStylesContext_Impl *)&xAutoStyles)-> - FindStyleChildContext( eFamily, nSubFamily, rName, - sal_True ) ); -#else pStyle = PTR_CAST( SwXMLItemSetStyleContext_Impl, ((SwXMLStylesContext_Impl *)&xAutoStyles)-> FindStyleChildContext( nFamily, rName, sal_True ) ); -#endif if( pStyle ) { if( ppItemSet ) + { + if( XML_STYLE_FAMILY_TABLE_TABLE == pStyle->GetFamily() && + pStyle->HasMasterPageName() && + !pStyle->IsPageDescConnected() ) + pStyle->ConnectPageDesc(); (*ppItemSet) = pStyle->GetItemSet(); + } + if( pParent ) *pParent = pStyle->GetParent(); } @@ -1695,149 +1078,3 @@ sal_Bool SwXMLImport::FindAutomaticStyle( return pStyle != 0; } - -/************************************************************************* - - Source Code Control System - Header - - $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/xmlfmt.cxx,v 1.3 2000-10-12 17:32:03 mib Exp $ - - Source Code Control System - Update - - $Log: not supported by cvs2svn $ - Revision 1.2 2000/09/28 12:45:50 mib - Splitting and joining nodes in insert mode fixed - - Revision 1.1.1.1 2000/09/18 17:15:00 hr - initial import - - Revision 1.42 2000/09/18 16:05:05 willem.vandorp - OpenOffice header added. - - Revision 1.41 2000/09/18 11:58:02 mib - text frames/graphics import and export continued - - Revision 1.40 2000/08/31 14:26:32 mib - conditional styles - - Revision 1.39 2000/08/24 11:16:41 mib - text import continued - - Revision 1.38 2000/08/10 10:22:15 mib - #74404#: Adeptions to new XSL/XLink working draft - - Revision 1.37 2000/07/27 08:06:34 mib - text import continued - - Revision 1.36 2000/07/21 12:55:15 mib - text import/export using StarOffice API - - Revision 1.35 2000/07/07 13:58:36 mib - text styles using StarOffice API - - Revision 1.34 2000/06/26 08:31:15 mib - removed SfxStyleFamily - - Revision 1.33 2000/06/08 09:45:54 aw - changed to use functionality from xmloff project now - - Revision 1.32 2000/05/03 12:08:05 mib - unicode - - Revision 1.31 2000/03/13 14:33:44 mib - UNO3 - - Revision 1.30 2000/03/06 10:46:10 mib - #72585#: toInt32 - - Revision 1.29 2000/02/18 09:20:12 mib - #70271#: initialization of pContext was missing - - Revision 1.28 2000/02/17 14:40:30 mib - #70271#: XML table import - - Revision 1.26 2000/01/27 08:59:02 mib - #70271#: outline numbering - - Revision 1.25 2000/01/20 10:03:15 mib - #70271#: Lists reworked - - Revision 1.24 2000/01/06 15:08:27 mib - #70271#:separation of text/layout, cond. styles, adaptions to wd-xlink-19991229 - - Revision 1.23 1999/12/13 08:28:25 mib - #70271#: Support for element items added - - Revision 1.22 1999/12/06 11:41:33 mib - #70258#: Container item for unkown attributes - - Revision 1.21 1999/11/26 11:13:57 mib - loading of styles only and insert mode - - Revision 1.20 1999/11/22 15:52:34 os - headers added - - Revision 1.19 1999/11/17 20:08:49 nn - document language - - Revision 1.18 1999/11/12 14:50:28 mib - meta import and export reactivated - - Revision 1.17 1999/11/12 11:43:03 mib - using item mapper, part iii - - Revision 1.16 1999/11/10 15:08:09 mib - Import now uses XMLItemMapper - - Revision 1.15 1999/11/09 15:40:08 mib - Using XMLItemMapper for export - - Revision 1.14 1999/11/05 19:44:11 nn - handle office:meta - - Revision 1.13 1999/11/01 11:38:50 mib - List style import - - Revision 1.12 1999/10/25 10:41:48 mib - Using new OUString ASCII methods - - Revision 1.11 1999/10/22 09:49:16 mib - List style export - - Revision 1.10 1999/10/15 12:37:05 mib - integrated SvXMLStyle into SvXMLStyleContext - - Revision 1.9 1999/10/08 11:47:45 mib - moved some file to SVTOOLS/SVX - - Revision 1.8 1999/10/01 13:02:51 mib - no comparisons between OUString and char* any longer - - Revision 1.7 1999/09/28 10:47:58 mib - char fmts again - - Revision 1.6 1999/09/28 08:31:15 mib - char fmts, hints - - Revision 1.5 1999/09/23 11:53:58 mib - i18n, token maps and hard paragraph attributes - - Revision 1.4 1999/09/22 11:56:57 mib - string -> wstring - - Revision 1.3 1999/08/19 12:57:42 MIB - attribute import added - - - Rev 1.2 19 Aug 1999 14:57:42 MIB - attribute import added - - Rev 1.1 18 Aug 1999 17:03:36 MIB - Style import - - Rev 1.0 13 Aug 1999 16:18:10 MIB - Initial revision. - - -*************************************************************************/ - diff --git a/sw/source/filter/xml/xmlfmte.cxx b/sw/source/filter/xml/xmlfmte.cxx index d566683e94bd..8373071264d6 100644 --- a/sw/source/filter/xml/xmlfmte.cxx +++ b/sw/source/filter/xml/xmlfmte.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmlfmte.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: mib $ $Date: 2000-10-12 17:30:28 $ + * last change: $Author: mib $ $Date: 2000-10-18 11:20:44 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -150,6 +150,12 @@ #ifndef _PARATR_HXX #include <paratr.hxx> #endif +#ifndef _FMTPDSC_HXX +#include <fmtpdsc.hxx> +#endif +#ifndef _PAGEDESC_HXX +#include <pagedesc.hxx> +#endif #ifndef _DOC_HXX //autogen wg. SwDoc #include <doc.hxx> @@ -235,252 +241,65 @@ void SwXMLExport::ExportFmt( const SwFmt& rFmt, const char *pFamily ) // style:family="..." const sal_Char *pStr = pFamily; -#ifdef XML_CORE_API - SfxStyleFamily eFamily = SFX_STYLE_FAMILY_ALL; - switch( rFmt.Which() ) - { - case RES_CHRFMT: - if( !pStr ) - pStr = sXML_text; - eFamily = SFX_STYLE_FAMILY_CHAR; - break; - case RES_FRMFMT: - if( !pStr ) - pStr = sXML_frame; - eFamily = SFX_STYLE_FAMILY_FRAME; - break; - case RES_TXTFMTCOLL: - case RES_CONDTXTFMTCOLL: - if( !pStr ) - pStr = sXML_paragraph; - eFamily = SFX_STYLE_FAMILY_PARA; - break; - case RES_FLYFRMFMT: - case RES_GRFFMTCOLL: - DBG_ASSERT( pStr, "SwXMLExport::ExportFmt: which id unexpected" ); - break; - default: - DBG_ASSERT( pStr, "SwXMLExport::ExportFmt: which id unknown" ); - break; - } - // style:name="..." - AddAttribute( XML_NAMESPACE_STYLE, sXML_name, - SwXStyleFamilies::GetProgrammaticName( rFmt.GetName(), eFamily ) ); -#else DBG_ASSERT( RES_FRMFMT==rFmt.Which(), "frame format expected" ); if( RES_FRMFMT != rFmt.Which() ) return; DBG_ASSERT( pStr, "family must be specified" ); // style:name="..." AddAttribute( XML_NAMESPACE_STYLE, sXML_name, rFmt.GetName() ); -#endif if( pStr ) AddAttributeASCII( XML_NAMESPACE_STYLE, sXML_family, pStr ); -#ifdef XML_CORE_API - // register name to prevent it from beeing reused as an automtic - // style name - if( SFX_STYLE_FAMILY_ALL != eFamily ) - pItemSetAutoStylePool->RegisterName( eFamily, rFmt.GetName() ); -#endif - // style:parent-style-name="..." (if its not the default only) const SwFmt* pParent = rFmt.DerivedFrom(); // Parent-Namen nur uebernehmen, wenn kein Default - if( pParent && !pParent->IsDefault() ) - { -#ifdef XML_CORE_API - AddAttribute( XML_NAMESPACE_STYLE, sXML_parent_style_name, - SwXStyleFamilies::GetProgrammaticName( pParent->GetName(), - eFamily ) ); -#else - AddAttribute( XML_NAMESPACE_STYLE, sXML_parent_style_name, - pParent->GetName() ); -#endif - } + ASSERT( !pParent || pParent->IsDefault(), "unexpected parent" ); -#ifdef XML_CORE_API - // style:next-style-name="..." - // (if its not the default and not the same style only) - if( RES_TXTFMTCOLL == rFmt.Which() || RES_CONDTXTFMTCOLL == rFmt.Which() ) - { - const SwTxtFmtColl& rFollow = - ((const SwTxtFmtColl&)rFmt).GetNextTxtFmtColl(); - if( !rFollow.IsDefault() && &rFollow != &rFmt ) - { - AddAttribute( XML_NAMESPACE_STYLE, sXML_next_style_name, - SwXStyleFamilies::GetProgrammaticName( rFollow.GetName(), - eFamily ) ); - } - } - -#if 0 - // style:pool-id="..." - if( USHRT_MAX != rFmt.GetPoolFmtId() ) - { - OUStringBuffer sTmp( 5L ); - sTmp.append( (sal_Int32)rFmt.GetPoolFmtId() ); - AddAttribute( XML_NAMESPACE_STYLE, sXML_pool_id, - sTmp.makeStringAndClear() ); - } - - // style:help-file-name="..." and style:help-id="..." - if( UCHAR_MAX != rFmt.GetPoolHlpFileId() ) - { - AddAttribute( XML_NAMESPACE_STYLE, sXML_help_file_name, - *pDoc->GetDocPattern( rFmt.GetPoolHlpFileId() ) ); - OUStringBuffer sTmp( 5L ); - sTmp.append( (sal_Int32)rFmt.GetPoolHelpId() ); - AddAttribute( XML_NAMESPACE_STYLE, sXML_help_id, - sTmp.makeStringAndClear() ); - } -#endif - - // style:auto-update="..." - if( rFmt.IsAutoUpdateFmt() ) - { - AddAttributeASCII( XML_NAMESPACE_STYLE, sXML_auto_update, sXML_true ); - } + ASSERT( USHRT_MAX == rFmt.GetPoolFmtId(), "pool ids arent'supported" ); + ASSERT( UCHAR_MAX == rFmt.GetPoolHlpFileId(), "help ids aren't supported" ); - // text:list-style-name - if( RES_TXTFMTCOLL == rFmt.Which() || RES_CONDTXTFMTCOLL == rFmt.Which() ) + // style:master-page-name + if( RES_FRMFMT == rFmt.Which() && sXML_table == pStr ) { const SfxPoolItem *pItem; - if( SFX_ITEM_SET == rFmt.GetAttrSet().GetItemState( RES_PARATR_NUMRULE, + if( SFX_ITEM_SET == rFmt.GetAttrSet().GetItemState( RES_PAGEDESC, sal_False, &pItem ) ) { - AddAttribute( XML_NAMESPACE_STYLE, sXML_list_style_name, - SwXStyleFamilies::GetProgrammaticName( - ((const SwNumRuleItem *)pItem)->GetValue(), - SFX_STYLE_FAMILY_PSEUDO ) ); + String sName; + const SwPageDesc *pPageDesc = + ((const SwFmtPageDesc *)pItem)->GetPageDesc(); + if( pPageDesc ) + sName = SwXStyleFamilies::GetProgrammaticName( + pPageDesc->GetName(), + SFX_STYLE_FAMILY_PAGE ); + AddAttribute( XML_NAMESPACE_STYLE, sXML_master_page_name, sName ); } } -#else - ASSERT( USHRT_MAX == rFmt.GetPoolFmtId(), "pool ids arent'supported" ); - ASSERT( UCHAR_MAX == rFmt.GetPoolHlpFileId(), "help ids aren't supported" ); -#endif { SvXMLElementExport aElem( *this, XML_NAMESPACE_STYLE, sXML_style, sal_True, sal_True ); -#ifdef XML_CORE_API - switch( rFmt.Which() ) + SvXMLItemMapEntriesRef xItemMap; + if( sXML_table == pStr ) + xItemMap = xTableItemMap; + else if( sXML_table_row == pStr ) + xItemMap = xTableRowItemMap; + else if( sXML_table_cell == pStr ) + xItemMap = xTableCellItemMap; + + if( xItemMap.Is() ) { - case RES_TXTFMTCOLL: - case RES_CONDTXTFMTCOLL: - case RES_CHRFMT: - GetParaItemMapper().exportXML( GetDocHandler(), + SvXMLExportItemMapper& rItemMapper = GetTableItemMapper(); + rItemMapper.setMapEntries( xItemMap ); + + GetTableItemMapper().exportXML( GetDocHandler(), rFmt.GetAttrSet(), GetTwipUnitConverter(), GetNamespaceMap(), XML_EXPORT_FLAG_IGN_WS ); - break; - case RES_FRMFMT: - { -#endif - SvXMLItemMapEntriesRef xItemMap; - if( sXML_table == pStr ) - xItemMap = xTableItemMap; - else if( sXML_table_row == pStr ) - xItemMap = xTableRowItemMap; - else if( sXML_table_cell == pStr ) - xItemMap = xTableCellItemMap; - - if( xItemMap.Is() ) - { - SvXMLExportItemMapper& rItemMapper = GetTableItemMapper(); - rItemMapper.setMapEntries( xItemMap ); - - GetTableItemMapper().exportXML( GetDocHandler(), - rFmt.GetAttrSet(), - GetTwipUnitConverter(), - GetNamespaceMap(), - XML_EXPORT_FLAG_IGN_WS ); - } -#ifdef XML_CORE_API - } - break; - default: - DBG_ASSERT( !this, - "SwXMLExport::ExportFmt: attribute export missing" ); - break; - } - - if( RES_CONDTXTFMTCOLL == rFmt.Which() ) - { - const SwFmtCollConditions& rConditions = - ((SwConditionTxtFmtColl&)rFmt). GetCondColls(); - for( sal_uInt16 i=0; i < rConditions.Count(); i++ ) - { - const SwCollCondition& rCond = *rConditions[i]; - - const sal_Char *pFunc = 0; - OUStringBuffer sBuffer( 20 ); - switch( rCond.GetCondition() ) - { - case PARA_IN_LIST: - pFunc = sXML_list_level; - sBuffer.append( (sal_Int32)(rCond.GetSubCondition()+1) ); - break; - case PARA_IN_OUTLINE: - pFunc = sXML_outline_level; - sBuffer.append( (sal_Int32)(rCond.GetSubCondition()+1) ); - break; - case PARA_IN_FRAME: - pFunc = sXML_text_box; - break; - case PARA_IN_TABLEHEAD: - pFunc = sXML_table_header; - break; - case PARA_IN_TABLEBODY: - pFunc = sXML_table; - break; - case PARA_IN_SECTION: - pFunc = sXML_section; - break; - case PARA_IN_FOOTENOTE: - pFunc = sXML_footnote; - break; - case PARA_IN_FOOTER: - pFunc = sXML_footer; - break; - case PARA_IN_HEADER: - pFunc = sXML_header; - break; - case PARA_IN_ENDNOTE: - pFunc = sXML_endnote; - break; - } - OUString sVal( sBuffer.makeStringAndClear() ); - - DBG_ASSERT( pFunc, "SwXMLExport::ExportFmt: unknon condition" ); - if( pFunc ) - { - sBuffer.appendAscii( pFunc ); - sBuffer.append( (sal_Unicode)'(' ); - sBuffer.append( (sal_Unicode)')' ); - if( sVal.getLength() ) - { - sBuffer.append( (sal_Unicode)'=' ); - sBuffer.append( sVal ); - } - - AddAttribute( XML_NAMESPACE_STYLE, sXML_condition, - sBuffer.makeStringAndClear() ); - const String& rName = - SwXStyleFamilies::GetProgrammaticName( - rCond.GetTxtFmtColl()->GetName(), - SFX_STYLE_FAMILY_PARA ); - AddAttribute( XML_NAMESPACE_STYLE, sXML_apply_style_name, - rName ); - SvXMLElementExport aElem( *this, XML_NAMESPACE_STYLE, - sXML_map, sal_True, sal_True ); - } - } } -#endif } } @@ -928,6 +747,7 @@ class SwXMLAutoStylePoolP : public SvXMLAutoStylePoolP { SvXMLExport& rExport; const OUString sListStyleName; + const OUString sMasterPageName; const OUString sCDATA; protected: @@ -978,6 +798,15 @@ void SwXMLAutoStylePoolP::exportStyleAttributes( } } break; + case CTF_PAGEDESCNAME: + { + OUString sStyleName; + aProperty->maValue >>= sStyleName; + OUString sName( rNamespaceMap.GetQNameByKey( + XML_NAMESPACE_STYLE, sMasterPageName ) ); + rAttrList.AddAttribute( sName, sCDATA, sStyleName ); + } + break; } } } @@ -987,6 +816,7 @@ SwXMLAutoStylePoolP::SwXMLAutoStylePoolP(SvXMLExport& rExp ) : SvXMLAutoStylePoolP(), rExport( rExp ), sListStyleName( RTL_CONSTASCII_USTRINGPARAM( sXML_list_style_name) ), + sMasterPageName( RTL_CONSTASCII_USTRINGPARAM( sXML_master_page_name) ), sCDATA( RTL_CONSTASCII_USTRINGPARAM( sXML_CDATA) ) { } @@ -1006,11 +836,14 @@ SvXMLAutoStylePoolP* SwXMLExport::CreateAutoStylePool() Source Code Control System - Header - $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/xmlfmte.cxx,v 1.3 2000-10-12 17:30:28 mib Exp $ + $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/xmlfmte.cxx,v 1.4 2000-10-18 11:20:44 mib Exp $ Source Code Control System - Update $Log: not supported by cvs2svn $ + Revision 1.3 2000/10/12 17:30:28 mib + export of master pages + Revision 1.2 2000/09/29 10:54:05 mib export graphics styles again diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx index 221f9238d172..fffbdde73b42 100644 --- a/sw/source/filter/xml/xmlimp.cxx +++ b/sw/source/filter/xml/xmlimp.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmlimp.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: mib $ $Date: 2000-10-12 17:32:03 $ + * last change: $Author: mib $ $Date: 2000-10-18 11:20:44 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -263,8 +263,7 @@ SwXMLImport::SwXMLImport( pDocElemTokenMap( 0 ), pTableElemTokenMap( 0 ), pTableItemMapper( 0 ), - pSttNdIdx( 0 ), - bAutoStylesValid( sal_False ) + pSttNdIdx( 0 ) { _InitItemImport(); diff --git a/sw/source/filter/xml/xmlimp.hxx b/sw/source/filter/xml/xmlimp.hxx index 057a0365569c..7531507ae854 100644 --- a/sw/source/filter/xml/xmlimp.hxx +++ b/sw/source/filter/xml/xmlimp.hxx @@ -2,9 +2,9 @@ * * $RCSfile: xmlimp.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: mib $ $Date: 2000-10-12 17:32:03 $ + * last change: $Author: mib $ $Date: 2000-10-18 11:20:44 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -111,7 +111,6 @@ class SwXMLImport: public SvXMLImport void _InitItemImport(); void _FinitItemImport(); - void InsertStyles(); protected: @@ -133,6 +132,8 @@ public: ~SwXMLImport(); + void InsertStyles( sal_Bool bAuto ); + void FinishStyles(); // namespace office SvXMLImportContext *CreateMetaContext( const ::rtl::OUString& rLocalName ); SvXMLImportContext *CreateStylesContext( diff --git a/sw/source/filter/xml/xmlitemm.cxx b/sw/source/filter/xml/xmlitemm.cxx index c0a03aec8d3f..e43cdaf63ae1 100644 --- a/sw/source/filter/xml/xmlitemm.cxx +++ b/sw/source/filter/xml/xmlitemm.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmlitemm.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: mib $ $Date: 2000-10-12 10:42:49 $ + * last change: $Author: mib $ $Date: 2000-10-18 11:20:44 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -207,7 +207,7 @@ SvXMLItemMapEntry aXMLParaItemMap[] = M_E( FO, margin_top, RES_UL_SPACE, MID_UP_MARGIN ), M_E( FO, margin_bottom, RES_UL_SPACE, MID_LO_MARGIN ), // RES_PAGEDESC - // TODO + M_E( STYLE, page_number, RES_PAGEDESC, MID_PAGEDESC_PAGENUMOFFSET), // RES_BREAK M_E( FO, break_before, RES_BREAK, MID_BREAK_BEFORE ), M_E( FO, break_after, RES_BREAK, MID_BREAK_AFTER ), @@ -294,7 +294,7 @@ SvXMLItemMapEntry aXMLTableItemMap[] = M_E( FO, margin_top, RES_UL_SPACE, MID_UP_MARGIN ), M_E( FO, margin_bottom, RES_UL_SPACE, MID_LO_MARGIN ), // RES_PAGEDESC - // TODO + M_E( STYLE, page_number, RES_PAGEDESC, MID_PAGEDESC_PAGENUMOFFSET), // RES_BREAK M_E( FO, break_before, RES_BREAK, MID_BREAK_BEFORE ), M_E( FO, break_after, RES_BREAK, MID_BREAK_AFTER ), @@ -514,11 +514,14 @@ SvXMLItemMapEntry aXMLTableCellItemMap[] = Source Code Control System - Header - $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/xmlitemm.cxx,v 1.2 2000-10-12 10:42:49 mib Exp $ + $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/xmlitemm.cxx,v 1.3 2000-10-18 11:20:44 mib Exp $ Source Code Control System - Update $Log: not supported by cvs2svn $ + Revision 1.2 2000/10/12 10:42:49 mib + #79090#: table:vertical-align -> fo:vertical-align + Revision 1.1.1.1 2000/09/18 17:15:00 hr initial import diff --git a/sw/source/filter/xml/xmltext.cxx b/sw/source/filter/xml/xmltext.cxx index bbc3171c062b..5dce75c62c77 100644 --- a/sw/source/filter/xml/xmltext.cxx +++ b/sw/source/filter/xml/xmltext.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmltext.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: mib $ $Date: 2000-09-27 06:15:11 $ + * last change: $Author: mib $ $Date: 2000-10-18 11:20:44 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -930,9 +930,6 @@ const SvXMLTokenMap& SwXMLImport::GetBodyElemTokenMap() SvXMLImportContext *SwXMLImport::CreateBodyContext( const OUString& rLocalName ) { - // styles nun einfuegen! - InsertStyles(); - SvXMLImportContext *pContext = 0; if( !IsStylesOnlyMode() ) @@ -1500,11 +1497,14 @@ void SwXMLExport::ExportSection( const SwSectionNode& rSectNd ) Source Code Control System - Header - $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/xmltext.cxx,v 1.2 2000-09-27 06:15:11 mib Exp $ + $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/xmltext.cxx,v 1.3 2000-10-18 11:20:44 mib Exp $ Source Code Control System - Update $Log: not supported by cvs2svn $ + Revision 1.2 2000/09/27 06:15:11 mib + Setting outline styles at end of body + Revision 1.1.1.1 2000/09/18 17:15:00 hr initial import |