1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_xmloff.hxx" 26 27 #include <com/sun/star/style/ParagraphStyleCategory.hpp> 28 #include <com/sun/star/beans/XPropertySet.hpp> 29 #include <com/sun/star/beans/XPropertySetInfo.hpp> 30 #include <com/sun/star/beans/XPropertyState.hpp> 31 #include <com/sun/star/style/XStyle.hpp> 32 #include <xmloff/xmltoken.hxx> 33 #include "xmloff/xmlnmspe.hxx" 34 #include <xmloff/families.hxx> 35 #include <xmloff/txtparae.hxx> 36 #include <xmloff/xmlnume.hxx> 37 #include <xmloff/xmlexp.hxx> 38 #include "XMLSectionExport.hxx" 39 #include "XMLLineNumberingExport.hxx" 40 #include "txtexppr.hxx" 41 #include <xmloff/txtprmap.hxx> 42 43 using ::rtl::OUString; 44 using ::rtl::OUStringBuffer; 45 46 using namespace ::com::sun::star; 47 using namespace ::com::sun::star::uno; 48 using namespace ::com::sun::star::style; 49 using namespace ::com::sun::star::container; 50 using namespace ::com::sun::star::beans; 51 using namespace ::xmloff::token; 52 53 void XMLTextParagraphExport::exportStyleAttributes( 54 const ::com::sun::star::uno::Reference< 55 ::com::sun::star::style::XStyle > & rStyle ) 56 { 57 OUString sName; 58 Any aAny; 59 Reference< XPropertySet > xPropSet( rStyle, UNO_QUERY ); 60 Reference< XPropertySetInfo > xPropSetInfo( 61 xPropSet->getPropertySetInfo()); 62 if( xPropSetInfo->hasPropertyByName( sCategory ) ) 63 { 64 sal_Int16 nCategory = 0; 65 xPropSet->getPropertyValue( sCategory ) >>= nCategory; 66 enum XMLTokenEnum eValue = XML_TOKEN_INVALID; 67 if( -1 != nCategory ) 68 { 69 switch( nCategory ) 70 { 71 case ParagraphStyleCategory::TEXT: 72 eValue = XML_TEXT; 73 break; 74 case ParagraphStyleCategory::CHAPTER: 75 eValue = XML_CHAPTER; 76 break; 77 case ParagraphStyleCategory::LIST: 78 eValue = XML_LIST; 79 break; 80 case ParagraphStyleCategory::INDEX: 81 eValue = XML_INDEX; 82 break; 83 case ParagraphStyleCategory::EXTRA: 84 eValue = XML_EXTRA; 85 break; 86 case ParagraphStyleCategory::HTML: 87 eValue = XML_HTML; 88 break; 89 } 90 } 91 if( eValue != XML_TOKEN_INVALID ) 92 GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_CLASS, eValue); 93 } 94 if( xPropSetInfo->hasPropertyByName( sPageDescName ) ) 95 { 96 Reference< XPropertyState > xPropState( xPropSet, uno::UNO_QUERY ); 97 if( PropertyState_DIRECT_VALUE == 98 xPropState->getPropertyState( sPageDescName ) ) 99 { 100 xPropSet->getPropertyValue( sPageDescName ) >>= sName; 101 // fix for #i5551# if( sName.getLength() > 0 ) 102 GetExport().AddAttribute( XML_NAMESPACE_STYLE, 103 XML_MASTER_PAGE_NAME, 104 GetExport().EncodeStyleName( sName ) ); 105 } 106 } 107 //sal_Int32 nOutlineLevel = //#outline level, zhaojianwei, moved to styleexp.cxx - XMLStyleExport::exportStyle(����) 108 // GetExport().GetTextParagraphExport()->GetHeadingLevel( rStyle->getName() ); 109 //if( nOutlineLevel != -1 ) 110 //{ 111 // OUStringBuffer sTmp; 112 // sTmp.append( static_cast<sal_Int32>(nOutlineLevel+1L) ); 113 // GetExport().AddAttribute( XML_NAMESPACE_STYLE, 114 // XML_DEFAULT_OUTLINE_LEVEL, 115 // sTmp.makeStringAndClear() ); 116 //} 117 118 if( bProgress ) 119 { 120 ProgressBarHelper *pProgress = GetExport().GetProgressBarHelper(); 121 pProgress->SetValue( pProgress->GetValue()+2 ); 122 } 123 } 124 125 void XMLTextParagraphExport::exportNumStyles( sal_Bool bUsed ) 126 { 127 SvxXMLNumRuleExport aNumRuleExport( GetExport() ); 128 aNumRuleExport.exportStyles( bUsed, pListAutoPool, !IsBlockMode() ); 129 } 130 131 void XMLTextParagraphExport::exportTextStyles( sal_Bool bUsed, sal_Bool bProg ) 132 { 133 sal_Bool bOldProg = bProgress; 134 bProgress = bProg; 135 136 Reference < lang::XMultiServiceFactory > xFactory (GetExport().GetModel(), UNO_QUERY); 137 if (xFactory.is()) 138 { 139 OUString sTextDefaults ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.text.Defaults" ) ); 140 Reference < XPropertySet > xPropSet (xFactory->createInstance ( sTextDefaults ), UNO_QUERY); 141 if (xPropSet.is()) 142 { 143 exportDefaultStyle( xPropSet, GetXMLToken(XML_PARAGRAPH), GetParaPropMapper()); 144 145 exportDefaultStyle( 146 xPropSet, 147 GetXMLToken(XML_TABLE), 148 new XMLTextExportPropertySetMapper( 149 new XMLTextPropertySetMapper( 150 TEXT_PROP_MAP_TABLE_DEFAULTS ), 151 GetExport() ) ); 152 153 exportDefaultStyle( 154 xPropSet, 155 GetXMLToken(XML_TABLE_ROW), 156 new XMLTextExportPropertySetMapper( 157 new XMLTextPropertySetMapper( 158 TEXT_PROP_MAP_TABLE_ROW_DEFAULTS ), 159 GetExport() ) ); 160 } 161 } 162 exportStyleFamily( "ParagraphStyles", GetXMLToken(XML_PARAGRAPH), GetParaPropMapper(), 163 bUsed, XML_STYLE_FAMILY_TEXT_PARAGRAPH, 0); 164 exportStyleFamily( "CharacterStyles", GetXMLToken(XML_TEXT), GetTextPropMapper(), 165 bUsed, XML_STYLE_FAMILY_TEXT_TEXT ); 166 // get shape export to make sure the the frame family is added correctly. 167 GetExport().GetShapeExport(); 168 exportStyleFamily( "FrameStyles", OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_GRAPHICS_NAME)), GetFramePropMapper(), 169 bUsed, XML_STYLE_FAMILY_TEXT_FRAME, 0); 170 exportNumStyles( bUsed ); 171 if( !IsBlockMode() ) 172 { 173 exportTextFootnoteConfiguration(); 174 XMLSectionExport::ExportBibliographyConfiguration(GetExport()); 175 XMLLineNumberingExport aLineNumberingExport(GetExport()); 176 aLineNumberingExport.Export(); 177 } 178 179 bProgress = bOldProg; 180 } 181