From a0dcf961879ab644a52f801f65466756cb144b72 Mon Sep 17 00:00:00 2001 From: Cédric Bosdonnat Date: Fri, 30 Nov 2012 18:51:55 +0100 Subject: Hidden styles: ODF import/export Change-Id: I1138314eba33dc8cf8d1f60e77ac419b4550bbcc --- sw/source/ui/app/docstyle.cxx | 55 ++++++++++++------------- xmloff/inc/xmloff/xmlnume.hxx | 2 +- xmloff/inc/xmloff/xmlstyle.hxx | 3 ++ xmloff/source/draw/sdpropls.cxx | 2 +- xmloff/source/style/XMLPageExport.cxx | 3 ++ xmloff/source/style/prstylei.cxx | 2 + xmloff/source/style/styleexp.cxx | 3 ++ xmloff/source/style/xmlnume.cxx | 10 +++-- xmloff/source/style/xmlstyle.cxx | 5 +++ xmloff/source/text/XMLTextListAutoStylePool.cxx | 2 +- xmloff/source/text/txtstyli.cxx | 2 + 11 files changed, 54 insertions(+), 35 deletions(-) diff --git a/sw/source/ui/app/docstyle.cxx b/sw/source/ui/app/docstyle.cxx index cae4c506b10f..c2228dcfd01e 100644 --- a/sw/source/ui/app/docstyle.cxx +++ b/sw/source/ui/app/docstyle.cxx @@ -523,39 +523,36 @@ sal_Bool SwDocStyleSheet::IsHidden( ) const { sal_Bool bRet = sal_False; - if(!bPhysical) + SwFmt* pFmt = 0; + switch(nFamily) { - SwFmt* pFmt = 0; - switch(nFamily) - { - case SFX_STYLE_FAMILY_CHAR: - pFmt = rDoc.FindCharFmtByName( aName ); - bRet = pFmt && pFmt->IsHidden( ); - break; + case SFX_STYLE_FAMILY_CHAR: + pFmt = rDoc.FindCharFmtByName( aName ); + bRet = pFmt && pFmt->IsHidden( ); + break; - case SFX_STYLE_FAMILY_PARA: - pFmt = rDoc.FindTxtFmtCollByName( aName ); - bRet = pFmt && pFmt->IsHidden( ); - break; + case SFX_STYLE_FAMILY_PARA: + pFmt = rDoc.FindTxtFmtCollByName( aName ); + bRet = pFmt && pFmt->IsHidden( ); + break; - case SFX_STYLE_FAMILY_FRAME: - pFmt = rDoc.FindFrmFmtByName( aName ); - bRet = pFmt && pFmt->IsHidden( ); - break; + case SFX_STYLE_FAMILY_FRAME: + pFmt = rDoc.FindFrmFmtByName( aName ); + bRet = pFmt && pFmt->IsHidden( ); + break; - case SFX_STYLE_FAMILY_PAGE: - { - SwPageDesc* pPgDesc = rDoc.FindPageDescByName( aName ); - bRet = pPgDesc && pPgDesc->IsHidden( ); - } - break; - case SFX_STYLE_FAMILY_PSEUDO: - { - SwNumRule* pRule = rDoc.FindNumRulePtr( aName ); - bRet = pRule && pRule->IsHidden( ); - } - default:; - } + case SFX_STYLE_FAMILY_PAGE: + { + SwPageDesc* pPgDesc = rDoc.FindPageDescByName( aName ); + bRet = pPgDesc && pPgDesc->IsHidden( ); + } + break; + case SFX_STYLE_FAMILY_PSEUDO: + { + SwNumRule* pRule = rDoc.FindNumRulePtr( aName ); + bRet = pRule && pRule->IsHidden( ); + } + default:; } return bRet; diff --git a/xmloff/inc/xmloff/xmlnume.hxx b/xmloff/inc/xmloff/xmlnume.hxx index e6406bd02ad5..dca651db2bcc 100644 --- a/xmloff/inc/xmloff/xmlnume.hxx +++ b/xmloff/inc/xmloff/xmlnume.hxx @@ -86,7 +86,7 @@ public: XMLTextListAutoStylePool *pPool, sal_Bool bExportChapterNumbering = sal_True ); void exportNumberingRule( - const ::rtl::OUString& rName, + const ::rtl::OUString& rName, sal_Bool bIsHidden, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexReplace > & xNumRule ); }; diff --git a/xmloff/inc/xmloff/xmlstyle.hxx b/xmloff/inc/xmloff/xmlstyle.hxx index 222ba2643689..8296b24799a0 100644 --- a/xmloff/inc/xmloff/xmlstyle.hxx +++ b/xmloff/inc/xmloff/xmlstyle.hxx @@ -65,6 +65,7 @@ class XMLOFF_DLLPUBLIC SvXMLStyleContext : public SvXMLImportContext ::rtl::OUString maAutoName; ::rtl::OUString maParentName;// Will be moved to XMLPropStyle soon!!!! ::rtl::OUString maFollow; // Will be moved to XMLPropStyle soon!!!! + sal_Bool mbHidden; ::rtl::OUString maHelpFile; // Will be removed very soon!!!! @@ -125,6 +126,8 @@ public: sal_Bool IsNew() const { return mbNew; } void SetNew( sal_Bool b ) { mbNew = b; } + sal_Bool IsHidden() const { return mbHidden; } + // This method is called for every default style virtual void SetDefaults(); diff --git a/xmloff/source/draw/sdpropls.cxx b/xmloff/source/draw/sdpropls.cxx index 6f9f89701f81..1ca236b20f3a 100644 --- a/xmloff/source/draw/sdpropls.cxx +++ b/xmloff/source/draw/sdpropls.cxx @@ -1567,7 +1567,7 @@ void XMLShapeExportPropertyMapper::handleElementItem( { uno::Reference< container::XIndexReplace > xNumRule( rProperty.maValue, uno::UNO_QUERY ); if( xNumRule.is() ) - const_cast(this)->maNumRuleExp.exportNumberingRule( maStyleName, xNumRule ); + const_cast(this)->maNumRuleExp.exportNumberingRule( maStyleName, sal_False, xNumRule ); } } break; diff --git a/xmloff/source/style/XMLPageExport.cxx b/xmloff/source/style/XMLPageExport.cxx index b187c404554a..2710bee2acf6 100644 --- a/xmloff/source/style/XMLPageExport.cxx +++ b/xmloff/source/style/XMLPageExport.cxx @@ -117,6 +117,9 @@ sal_Bool XMLPageExport::exportStyle( GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_NAME, GetExport().EncodeStyleName( sName, &bEncoded ) ); + if ( rStyle->isHidden( ) && GetExport( ).getDefaultVersion( ) == SvtSaveOptions::ODFVER_LATEST ) + GetExport( ).AddAttribute( XML_NAMESPACE_STYLE, XML_HIDDEN, "true" ); + if( bEncoded ) GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_DISPLAY_NAME, sName); diff --git a/xmloff/source/style/prstylei.cxx b/xmloff/source/style/prstylei.cxx index 278ff5799e49..9dac4827a4ab 100644 --- a/xmloff/source/style/prstylei.cxx +++ b/xmloff/source/style/prstylei.cxx @@ -341,6 +341,8 @@ void XMLPropStyleContext::Finish( sal_Bool bOverwrite ) if( !xFamilies.is() ) return; + mxStyle->setHidden( IsHidden( ) ); + // connect parent OUString sParent( GetParentName() ); if( !sParent.isEmpty() ) diff --git a/xmloff/source/style/styleexp.cxx b/xmloff/source/style/styleexp.cxx index 2970392078fa..0a9669eb1fdf 100644 --- a/xmloff/source/style/styleexp.cxx +++ b/xmloff/source/style/styleexp.cxx @@ -121,6 +121,9 @@ sal_Bool XMLStyleExport::exportStyle( if( !rXMLFamily.isEmpty() ) GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_FAMILY, rXMLFamily); + if ( rStyle->isHidden( ) && GetExport( ).getDefaultVersion( ) == SvtSaveOptions::ODFVER_LATEST ) + GetExport( ).AddAttribute( XML_NAMESPACE_STYLE, XML_HIDDEN, "true" ); + // style:parent-style-name="..." OUString sParentString(rStyle->getParentStyle()); OUString sParent; diff --git a/xmloff/source/style/xmlnume.cxx b/xmloff/source/style/xmlnume.cxx index 2efffc75d5fa..cd697eccdd5b 100644 --- a/xmloff/source/style/xmlnume.cxx +++ b/xmloff/source/style/xmlnume.cxx @@ -682,7 +682,7 @@ SvxXMLNumRuleExport::~SvxXMLNumRuleExport() } void SvxXMLNumRuleExport::exportNumberingRule( - const OUString& rName, + const OUString& rName, sal_Bool bIsHidden, const Reference< XIndexReplace >& rNumRule ) { Reference< XPropertySet > xPropSet( rNumRule, UNO_QUERY ); @@ -703,6 +703,10 @@ void SvxXMLNumRuleExport::exportNumberingRule( rName); } + // style:hidden="..." + if ( bIsHidden && GetExport( ).getDefaultVersion( ) == SvtSaveOptions::ODFVER_LATEST ) + GetExport( ).AddAttribute( XML_NAMESPACE_STYLE, XML_HIDDEN, "true" ); + // text:consecutive-numbering="..." sal_Bool bContNumbering = sal_False; if( xPropSetInfo.is() && @@ -747,7 +751,7 @@ sal_Bool SvxXMLNumRuleExport::exportStyle( const Reference< XStyle >& rStyle ) OUString sName = rStyle->getName(); - exportNumberingRule( sName, xNumRule ); + exportNumberingRule( sName, rStyle->isHidden(), xNumRule ); return sal_True; } @@ -784,7 +788,7 @@ void SvxXMLNumRuleExport::exportOutline() nODFVersion == SvtSaveOptions::ODFVER_011 ) && GetExport().writeOutlineStyleAsNormalListStyle() ) { - exportNumberingRule( sOutlineStyleName, xNumRule ); + exportNumberingRule( sOutlineStyleName, sal_False, xNumRule ); } else { diff --git a/xmloff/source/style/xmlstyle.cxx b/xmloff/source/style/xmlstyle.cxx index fe28e57d7bfe..433b1407e10c 100644 --- a/xmloff/source/style/xmlstyle.cxx +++ b/xmloff/source/style/xmlstyle.cxx @@ -138,6 +138,10 @@ void SvXMLStyleContext::SetAttribute( sal_uInt16 nPrefixKey, (nTmp < 0L) ? 0U : ( (nTmp > USHRT_MAX) ? USHRT_MAX : (sal_uInt16)nTmp ); } + else if( IsXMLToken( rLocalName, XML_HIDDEN ) ) + { + mbHidden = rValue.toBoolean(); + } } } @@ -149,6 +153,7 @@ SvXMLStyleContext::SvXMLStyleContext( const uno::Reference< xml::sax::XAttributeList >&, sal_uInt16 nFam, sal_Bool bDefault ) : SvXMLImportContext( rImp, nPrfx, rLName ), + mbHidden( sal_False ), mnHelpId( UCHAR_MAX ), mnFamily( nFam ), mbValid( sal_True ), diff --git a/xmloff/source/text/XMLTextListAutoStylePool.cxx b/xmloff/source/text/XMLTextListAutoStylePool.cxx index 2bc446d41913..9e875a9a4b96 100644 --- a/xmloff/source/text/XMLTextListAutoStylePool.cxx +++ b/xmloff/source/text/XMLTextListAutoStylePool.cxx @@ -268,7 +268,7 @@ void XMLTextListAutoStylePool::exportXML() const for( i=0; i < nCount; i++ ) { XMLTextListAutoStylePoolEntry_Impl *pEntry = aExpEntries[i]; - aNumRuleExp.exportNumberingRule( pEntry->GetName(), + aNumRuleExp.exportNumberingRule( pEntry->GetName(), sal_False, pEntry->GetNumRules() ); } delete [] aExpEntries; diff --git a/xmloff/source/text/txtstyli.cxx b/xmloff/source/text/txtstyli.cxx index 349712523e87..81ce15cc042f 100644 --- a/xmloff/source/text/txtstyli.cxx +++ b/xmloff/source/text/txtstyli.cxx @@ -280,6 +280,8 @@ void XMLTextStyleContext::Finish( sal_Bool bOverwrite ) !( bOverwrite || IsNew() ) ) return; + xStyle->setHidden( IsHidden( ) ); + Reference < XPropertySet > xPropSet( xStyle, UNO_QUERY ); Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo(); -- cgit v1.2.3