1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_xmloff.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include "XMLTextPropertySetContext.hxx" 32*cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx" 33*cdf0e10cSrcweir #include "xmloff/XMLEventsImportContext.hxx" 34*cdf0e10cSrcweir #include "xmloff/attrlist.hxx" 35*cdf0e10cSrcweir #include "xmloff/families.hxx" 36*cdf0e10cSrcweir #include "xmloff/txtprmap.hxx" 37*cdf0e10cSrcweir #include "xmloff/txtstyli.hxx" 38*cdf0e10cSrcweir #include "xmloff/xmlimp.hxx" 39*cdf0e10cSrcweir #include "xmloff/xmltkmap.hxx" 40*cdf0e10cSrcweir #include "xmloff/xmltoken.hxx" 41*cdf0e10cSrcweir #include "xmloff/xmluconv.hxx" 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir #include <com/sun/star/beans/XMultiPropertySet.hpp> 44*cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp> 45*cdf0e10cSrcweir #include <com/sun/star/document/XEventsSupplier.hpp> 46*cdf0e10cSrcweir #include <com/sun/star/frame/XModel.hpp> 47*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 48*cdf0e10cSrcweir #include <com/sun/star/style/ParagraphStyleCategory.hpp> 49*cdf0e10cSrcweir #include <com/sun/star/style/XStyle.hpp> 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir #include <tools/debug.hxx> 52*cdf0e10cSrcweir #include <tools/diagnose_ex.h> 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir // STL includes 55*cdf0e10cSrcweir #include <algorithm> 56*cdf0e10cSrcweir #include <functional> 57*cdf0e10cSrcweir #include <utility> 58*cdf0e10cSrcweir #include <vector> 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir using ::rtl::OUString; 61*cdf0e10cSrcweir using ::rtl::OUStringBuffer; 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir using namespace ::std; 64*cdf0e10cSrcweir using namespace ::com::sun::star; 65*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 66*cdf0e10cSrcweir using namespace ::com::sun::star::xml::sax; 67*cdf0e10cSrcweir using namespace ::com::sun::star::style; 68*cdf0e10cSrcweir using namespace ::com::sun::star::frame; 69*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 70*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 71*cdf0e10cSrcweir using namespace ::com::sun::star::container; 72*cdf0e10cSrcweir //using namespace ::com::sun::star::text; 73*cdf0e10cSrcweir using namespace ::xmloff::token; 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir static __FAR_DATA SvXMLEnumMapEntry aCategoryMap[] = 76*cdf0e10cSrcweir { 77*cdf0e10cSrcweir { XML_TEXT, ParagraphStyleCategory::TEXT }, 78*cdf0e10cSrcweir { XML_CHAPTER, ParagraphStyleCategory::CHAPTER }, 79*cdf0e10cSrcweir { XML_LIST, ParagraphStyleCategory::LIST }, 80*cdf0e10cSrcweir { XML_INDEX, ParagraphStyleCategory::INDEX }, 81*cdf0e10cSrcweir { XML_EXTRA, ParagraphStyleCategory::EXTRA }, 82*cdf0e10cSrcweir { XML_HTML, ParagraphStyleCategory::HTML }, 83*cdf0e10cSrcweir { XML_TOKEN_INVALID, 0 } 84*cdf0e10cSrcweir }; 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir void XMLTextStyleContext::SetAttribute( sal_uInt16 nPrefixKey, 87*cdf0e10cSrcweir const OUString& rLocalName, 88*cdf0e10cSrcweir const OUString& rValue ) 89*cdf0e10cSrcweir { 90*cdf0e10cSrcweir if( XML_NAMESPACE_STYLE == nPrefixKey ) 91*cdf0e10cSrcweir { 92*cdf0e10cSrcweir // TODO: use a map here 93*cdf0e10cSrcweir if( IsXMLToken( rLocalName, XML_AUTO_UPDATE ) ) 94*cdf0e10cSrcweir { 95*cdf0e10cSrcweir if( IsXMLToken( rValue, XML_TRUE ) ) 96*cdf0e10cSrcweir bAutoUpdate = sal_True; 97*cdf0e10cSrcweir } 98*cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_LIST_STYLE_NAME ) ) 99*cdf0e10cSrcweir { 100*cdf0e10cSrcweir sListStyleName = rValue; 101*cdf0e10cSrcweir // --> OD 2006-09-21 #i69523# 102*cdf0e10cSrcweir mbListStyleSet = sal_True; 103*cdf0e10cSrcweir // <-- 104*cdf0e10cSrcweir } 105*cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_MASTER_PAGE_NAME ) ) 106*cdf0e10cSrcweir { 107*cdf0e10cSrcweir sMasterPageName = rValue; 108*cdf0e10cSrcweir bHasMasterPageName = sal_True; 109*cdf0e10cSrcweir } 110*cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_DATA_STYLE_NAME ) ) 111*cdf0e10cSrcweir { 112*cdf0e10cSrcweir sDataStyleName = rValue; 113*cdf0e10cSrcweir } 114*cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_CLASS ) ) 115*cdf0e10cSrcweir { 116*cdf0e10cSrcweir sCategoryVal = rValue; 117*cdf0e10cSrcweir } 118*cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_DEFAULT_OUTLINE_LEVEL ) ) 119*cdf0e10cSrcweir { 120*cdf0e10cSrcweir sal_Int32 nTmp; 121*cdf0e10cSrcweir if( SvXMLUnitConverter::convertNumber( nTmp, rValue ) && 122*cdf0e10cSrcweir // nTmp > 0 && nTmp < 256 ) //#outline level, removed by zhaojianwei 123*cdf0e10cSrcweir 0 <= nTmp && nTmp <= 10 ) //<-end,add by zhaojianwei 124*cdf0e10cSrcweir nOutlineLevel = static_cast< sal_Int8 >( nTmp ); 125*cdf0e10cSrcweir } 126*cdf0e10cSrcweir else 127*cdf0e10cSrcweir { 128*cdf0e10cSrcweir XMLPropStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue ); 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir } 131*cdf0e10cSrcweir else 132*cdf0e10cSrcweir { 133*cdf0e10cSrcweir XMLPropStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue ); 134*cdf0e10cSrcweir } 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir TYPEINIT1( XMLTextStyleContext, XMLPropStyleContext ); 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir XMLTextStyleContext::XMLTextStyleContext( SvXMLImport& rImport, 140*cdf0e10cSrcweir sal_uInt16 nPrfx, const OUString& rLName, 141*cdf0e10cSrcweir const Reference< XAttributeList > & xAttrList, 142*cdf0e10cSrcweir SvXMLStylesContext& rStyles, sal_uInt16 nFamily, 143*cdf0e10cSrcweir sal_Bool bDefaultStyle ) 144*cdf0e10cSrcweir : XMLPropStyleContext( rImport, nPrfx, rLName, xAttrList, rStyles, nFamily, bDefaultStyle ) 145*cdf0e10cSrcweir , sIsAutoUpdate( RTL_CONSTASCII_USTRINGPARAM( "IsAutoUpdate" ) ) 146*cdf0e10cSrcweir , sCategory( RTL_CONSTASCII_USTRINGPARAM( "Category" ) ) 147*cdf0e10cSrcweir , sNumberingStyleName( RTL_CONSTASCII_USTRINGPARAM( "NumberingStyleName" ) ) 148*cdf0e10cSrcweir , sOutlineLevel(RTL_CONSTASCII_USTRINGPARAM( "OutlineLevel" ) )//#outline level,add by zhaojianwei 149*cdf0e10cSrcweir , sDropCapCharStyleName( RTL_CONSTASCII_USTRINGPARAM( "DropCapCharStyleName" ) ) 150*cdf0e10cSrcweir , sPageDescName( RTL_CONSTASCII_USTRINGPARAM( "PageDescName" ) ) 151*cdf0e10cSrcweir //, nOutlineLevel( 0 ) // removed by zhaojianwei 152*cdf0e10cSrcweir , nOutlineLevel( -1 ) //<-end, add by zhaojianwei 153*cdf0e10cSrcweir , bAutoUpdate( sal_False ) 154*cdf0e10cSrcweir , bHasMasterPageName( sal_False ) 155*cdf0e10cSrcweir , bHasCombinedCharactersLetter( sal_False ) 156*cdf0e10cSrcweir // --> OD 2006-09-21 #i69523# 157*cdf0e10cSrcweir , mbListStyleSet( sal_False ) 158*cdf0e10cSrcweir // <-- 159*cdf0e10cSrcweir , pEventContext( NULL ) 160*cdf0e10cSrcweir { 161*cdf0e10cSrcweir } 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir XMLTextStyleContext::~XMLTextStyleContext() 164*cdf0e10cSrcweir { 165*cdf0e10cSrcweir } 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir SvXMLImportContext *XMLTextStyleContext::CreateChildContext( 168*cdf0e10cSrcweir sal_uInt16 nPrefix, 169*cdf0e10cSrcweir const OUString& rLocalName, 170*cdf0e10cSrcweir const Reference< XAttributeList > & xAttrList ) 171*cdf0e10cSrcweir { 172*cdf0e10cSrcweir SvXMLImportContext *pContext = 0; 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir if( XML_NAMESPACE_STYLE == nPrefix ) 175*cdf0e10cSrcweir { 176*cdf0e10cSrcweir sal_uInt32 nFamily = 0; 177*cdf0e10cSrcweir if( IsXMLToken( rLocalName, XML_TEXT_PROPERTIES ) ) 178*cdf0e10cSrcweir nFamily = XML_TYPE_PROP_TEXT; 179*cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_PARAGRAPH_PROPERTIES ) ) 180*cdf0e10cSrcweir nFamily = XML_TYPE_PROP_PARAGRAPH; 181*cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_SECTION_PROPERTIES ) ) 182*cdf0e10cSrcweir nFamily = XML_TYPE_PROP_SECTION; 183*cdf0e10cSrcweir else if( IsDefaultStyle() && IsXMLToken( rLocalName, XML_TABLE_PROPERTIES ) ) 184*cdf0e10cSrcweir nFamily = XML_TYPE_PROP_TABLE; 185*cdf0e10cSrcweir else if( IsDefaultStyle() && IsXMLToken( rLocalName, XML_TABLE_ROW_PROPERTIES ) ) 186*cdf0e10cSrcweir nFamily = XML_TYPE_PROP_TABLE_ROW; 187*cdf0e10cSrcweir if( nFamily ) 188*cdf0e10cSrcweir { 189*cdf0e10cSrcweir UniReference < SvXMLImportPropertyMapper > xImpPrMap = 190*cdf0e10cSrcweir GetStyles()->GetImportPropertyMapper( GetFamily() ); 191*cdf0e10cSrcweir if( xImpPrMap.is() ) 192*cdf0e10cSrcweir pContext = new XMLTextPropertySetContext( GetImport(), nPrefix, 193*cdf0e10cSrcweir rLocalName, xAttrList, 194*cdf0e10cSrcweir nFamily, 195*cdf0e10cSrcweir GetProperties(), 196*cdf0e10cSrcweir xImpPrMap, 197*cdf0e10cSrcweir sDropCapTextStyleName ); 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir else if ( (XML_NAMESPACE_OFFICE == nPrefix) && 201*cdf0e10cSrcweir IsXMLToken( rLocalName, XML_EVENT_LISTENERS ) ) 202*cdf0e10cSrcweir { 203*cdf0e10cSrcweir // create and remember events import context 204*cdf0e10cSrcweir // (for delayed processing of events) 205*cdf0e10cSrcweir pEventContext = new XMLEventsImportContext( GetImport(), nPrefix, 206*cdf0e10cSrcweir rLocalName); 207*cdf0e10cSrcweir pEventContext->AddRef(); 208*cdf0e10cSrcweir pContext = pEventContext; 209*cdf0e10cSrcweir } 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir if( !pContext ) 212*cdf0e10cSrcweir pContext = XMLPropStyleContext::CreateChildContext( nPrefix, rLocalName, 213*cdf0e10cSrcweir xAttrList ); 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir return pContext; 216*cdf0e10cSrcweir } 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir void XMLTextStyleContext::CreateAndInsert( sal_Bool bOverwrite ) 219*cdf0e10cSrcweir { 220*cdf0e10cSrcweir XMLPropStyleContext::CreateAndInsert( bOverwrite ); 221*cdf0e10cSrcweir Reference < XStyle > xStyle = GetStyle(); 222*cdf0e10cSrcweir if( !xStyle.is() || !(bOverwrite || IsNew()) ) 223*cdf0e10cSrcweir return; 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir Reference < XPropertySet > xPropSet( xStyle, UNO_QUERY ); 226*cdf0e10cSrcweir Reference< XPropertySetInfo > xPropSetInfo = 227*cdf0e10cSrcweir xPropSet->getPropertySetInfo(); 228*cdf0e10cSrcweir if( xPropSetInfo->hasPropertyByName( sIsAutoUpdate ) ) 229*cdf0e10cSrcweir { 230*cdf0e10cSrcweir Any aAny; 231*cdf0e10cSrcweir sal_Bool bTmp = bAutoUpdate; 232*cdf0e10cSrcweir aAny.setValue( &bTmp, ::getBooleanCppuType() ); 233*cdf0e10cSrcweir xPropSet->setPropertyValue( sIsAutoUpdate, aAny ); 234*cdf0e10cSrcweir } 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir sal_uInt16 nCategory = ParagraphStyleCategory::TEXT; 237*cdf0e10cSrcweir if( XML_STYLE_FAMILY_TEXT_PARAGRAPH == GetFamily() && 238*cdf0e10cSrcweir sCategoryVal.getLength() && xStyle->isUserDefined() && 239*cdf0e10cSrcweir xPropSetInfo->hasPropertyByName( sCategory ) && 240*cdf0e10cSrcweir SvXMLUnitConverter::convertEnum( nCategory, sCategoryVal, aCategoryMap ) ) 241*cdf0e10cSrcweir { 242*cdf0e10cSrcweir Any aAny; 243*cdf0e10cSrcweir aAny <<= (sal_Int16)nCategory; 244*cdf0e10cSrcweir xPropSet->setPropertyValue( sCategory, aAny ); 245*cdf0e10cSrcweir } 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir // tell the style about it's events (if applicable) 248*cdf0e10cSrcweir if (NULL != pEventContext) 249*cdf0e10cSrcweir { 250*cdf0e10cSrcweir // set event suppplier and release reference to context 251*cdf0e10cSrcweir Reference<document::XEventsSupplier> xEventsSupplier(xStyle,UNO_QUERY); 252*cdf0e10cSrcweir pEventContext->SetEvents(xEventsSupplier); 253*cdf0e10cSrcweir pEventContext->ReleaseRef(); 254*cdf0e10cSrcweir } 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir // --> OD 2006-10-12 #i69629# 257*cdf0e10cSrcweir if ( nOutlineLevel > 0 ) 258*cdf0e10cSrcweir { 259*cdf0e10cSrcweir GetImport().GetTextImport()->AddOutlineStyleCandidate( nOutlineLevel, 260*cdf0e10cSrcweir GetDisplayName() ); 261*cdf0e10cSrcweir } 262*cdf0e10cSrcweir // <-- 263*cdf0e10cSrcweir } 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir void XMLTextStyleContext::SetDefaults( ) 266*cdf0e10cSrcweir { 267*cdf0e10cSrcweir if( ( GetFamily() == XML_STYLE_FAMILY_TEXT_PARAGRAPH ) || 268*cdf0e10cSrcweir ( GetFamily() == XML_STYLE_FAMILY_TABLE_TABLE ) || 269*cdf0e10cSrcweir ( GetFamily() == XML_STYLE_FAMILY_TABLE_ROW ) ) 270*cdf0e10cSrcweir { 271*cdf0e10cSrcweir Reference < XMultiServiceFactory > xFactory ( GetImport().GetModel(), UNO_QUERY); 272*cdf0e10cSrcweir if (xFactory.is()) 273*cdf0e10cSrcweir { 274*cdf0e10cSrcweir Reference < XInterface > xInt = xFactory->createInstance ( 275*cdf0e10cSrcweir OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.text.Defaults" ) ) ); 276*cdf0e10cSrcweir Reference < XPropertySet > xProperties ( xInt, UNO_QUERY ); 277*cdf0e10cSrcweir if ( xProperties.is() ) 278*cdf0e10cSrcweir FillPropertySet ( xProperties ); 279*cdf0e10cSrcweir } 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir } 282*cdf0e10cSrcweir 283*cdf0e10cSrcweir void XMLTextStyleContext::Finish( sal_Bool bOverwrite ) 284*cdf0e10cSrcweir { 285*cdf0e10cSrcweir XMLPropStyleContext::Finish( bOverwrite ); 286*cdf0e10cSrcweir 287*cdf0e10cSrcweir Reference < XStyle > xStyle = GetStyle(); 288*cdf0e10cSrcweir // --> OD 2006-09-21 #i69523# 289*cdf0e10cSrcweir // consider set empty list style 290*cdf0e10cSrcweir // if ( !( sListStyleName.getLength() || 291*cdf0e10cSrcweir if ( !( mbListStyleSet || 292*cdf0e10cSrcweir nOutlineLevel >= 0 || //#outline level,add by zhaojianwei 293*cdf0e10cSrcweir sDropCapTextStyleName.getLength() || 294*cdf0e10cSrcweir bHasMasterPageName ) || 295*cdf0e10cSrcweir !xStyle.is() || 296*cdf0e10cSrcweir !( bOverwrite || IsNew() ) ) 297*cdf0e10cSrcweir return; 298*cdf0e10cSrcweir // <-- 299*cdf0e10cSrcweir 300*cdf0e10cSrcweir Reference < XPropertySet > xPropSet( xStyle, UNO_QUERY ); 301*cdf0e10cSrcweir Reference< XPropertySetInfo > xPropSetInfo = 302*cdf0e10cSrcweir xPropSet->getPropertySetInfo(); 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir //#outline level,add by zhaojianwei 305*cdf0e10cSrcweir if( xPropSetInfo->hasPropertyByName( sOutlineLevel )) 306*cdf0e10cSrcweir { 307*cdf0e10cSrcweir Any aAny; 308*cdf0e10cSrcweir if( nOutlineLevel >= 0 ) 309*cdf0e10cSrcweir { 310*cdf0e10cSrcweir aAny <<= nOutlineLevel; 311*cdf0e10cSrcweir xPropSet->setPropertyValue( sOutlineLevel, aAny ); 312*cdf0e10cSrcweir } 313*cdf0e10cSrcweir } 314*cdf0e10cSrcweir //<-end,zhaojianwei 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir 317*cdf0e10cSrcweir // --> OD 2006-09-21 #i69523# 318*cdf0e10cSrcweir // consider set empty list style 319*cdf0e10cSrcweir // if( sListStyleName.getLength() ) 320*cdf0e10cSrcweir if ( mbListStyleSet && 321*cdf0e10cSrcweir xPropSetInfo->hasPropertyByName( sNumberingStyleName ) ) 322*cdf0e10cSrcweir { 323*cdf0e10cSrcweir // --> OD 2006-10-12 #i70223# 324*cdf0e10cSrcweir // Only for text document from version prior OOo 2.1 resp. SO 8 PU5: 325*cdf0e10cSrcweir // - Do not apply list style, if paragraph style has a default outline 326*cdf0e10cSrcweir // level > 0 and thus, will be assigned to the corresponding list 327*cdf0e10cSrcweir // level of the outline style. 328*cdf0e10cSrcweir bool bApplyListStyle( true ); 329*cdf0e10cSrcweir if ( nOutlineLevel > 0 ) 330*cdf0e10cSrcweir { 331*cdf0e10cSrcweir // --> OD 2007-12-19 #152540# 332*cdf0e10cSrcweir if ( GetImport().IsTextDocInOOoFileFormat() ) 333*cdf0e10cSrcweir { 334*cdf0e10cSrcweir bApplyListStyle = false; 335*cdf0e10cSrcweir } 336*cdf0e10cSrcweir else 337*cdf0e10cSrcweir { 338*cdf0e10cSrcweir sal_Int32 nUPD( 0 ); 339*cdf0e10cSrcweir sal_Int32 nBuild( 0 ); 340*cdf0e10cSrcweir // --> OD 2008-03-19 #i86058# 341*cdf0e10cSrcweir // check explicitly on certain versions 342*cdf0e10cSrcweir if ( GetImport().getBuildIds( nUPD, nBuild ) && 343*cdf0e10cSrcweir ( ( nUPD == 641 ) || ( nUPD == 645 ) || // prior OOo 2.0 344*cdf0e10cSrcweir ( nUPD == 680 && nBuild <= 9073 ) ) ) // OOo 2.0 - OOo 2.0.4 345*cdf0e10cSrcweir { 346*cdf0e10cSrcweir bApplyListStyle = false; 347*cdf0e10cSrcweir } 348*cdf0e10cSrcweir // <-- 349*cdf0e10cSrcweir } 350*cdf0e10cSrcweir // <-- 351*cdf0e10cSrcweir } 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir if ( bApplyListStyle ) 354*cdf0e10cSrcweir { 355*cdf0e10cSrcweir if ( !sListStyleName.getLength() ) 356*cdf0e10cSrcweir { 357*cdf0e10cSrcweir Any aAny; 358*cdf0e10cSrcweir aAny <<= sListStyleName /* empty string */; 359*cdf0e10cSrcweir xPropSet->setPropertyValue( sNumberingStyleName, aAny ); 360*cdf0e10cSrcweir } 361*cdf0e10cSrcweir else 362*cdf0e10cSrcweir { 363*cdf0e10cSrcweir // change list style name to display name 364*cdf0e10cSrcweir OUString sDisplayListStyleName( 365*cdf0e10cSrcweir GetImport().GetStyleDisplayName( XML_STYLE_FAMILY_TEXT_LIST, 366*cdf0e10cSrcweir sListStyleName ) ); 367*cdf0e10cSrcweir // The families container must exist 368*cdf0e10cSrcweir const Reference < XNameContainer >& rNumStyles = 369*cdf0e10cSrcweir GetImport().GetTextImport()->GetNumberingStyles(); 370*cdf0e10cSrcweir // if( rNumStyles.is() && rNumStyles->hasByName( sDisplayListStyleName ) && 371*cdf0e10cSrcweir // xPropSetInfo->hasPropertyByName( sNumberingStyleName ) ) 372*cdf0e10cSrcweir if ( rNumStyles.is() && 373*cdf0e10cSrcweir rNumStyles->hasByName( sDisplayListStyleName ) ) 374*cdf0e10cSrcweir { 375*cdf0e10cSrcweir Any aAny; 376*cdf0e10cSrcweir aAny <<= sDisplayListStyleName; 377*cdf0e10cSrcweir xPropSet->setPropertyValue( sNumberingStyleName, aAny ); 378*cdf0e10cSrcweir } 379*cdf0e10cSrcweir } 380*cdf0e10cSrcweir } 381*cdf0e10cSrcweir // <-- 382*cdf0e10cSrcweir } 383*cdf0e10cSrcweir // <-- 384*cdf0e10cSrcweir 385*cdf0e10cSrcweir if( sDropCapTextStyleName.getLength() ) 386*cdf0e10cSrcweir { 387*cdf0e10cSrcweir // change list style name to display name 388*cdf0e10cSrcweir OUString sDisplayDropCapTextStyleName( 389*cdf0e10cSrcweir GetImport().GetStyleDisplayName( XML_STYLE_FAMILY_TEXT_TEXT, 390*cdf0e10cSrcweir sDropCapTextStyleName ) ); 391*cdf0e10cSrcweir // The families cointaner must exist 392*cdf0e10cSrcweir const Reference < XNameContainer >& rTextStyles = 393*cdf0e10cSrcweir GetImport().GetTextImport()->GetTextStyles(); 394*cdf0e10cSrcweir if( rTextStyles.is() && 395*cdf0e10cSrcweir rTextStyles->hasByName( sDisplayDropCapTextStyleName ) && 396*cdf0e10cSrcweir xPropSetInfo->hasPropertyByName( sDropCapCharStyleName ) ) 397*cdf0e10cSrcweir { 398*cdf0e10cSrcweir Any aAny; 399*cdf0e10cSrcweir aAny <<= sDisplayDropCapTextStyleName; 400*cdf0e10cSrcweir xPropSet->setPropertyValue( sDropCapCharStyleName, aAny ); 401*cdf0e10cSrcweir } 402*cdf0e10cSrcweir } 403*cdf0e10cSrcweir 404*cdf0e10cSrcweir if( bHasMasterPageName ) 405*cdf0e10cSrcweir { 406*cdf0e10cSrcweir OUString sDisplayName( 407*cdf0e10cSrcweir GetImport().GetStyleDisplayName( 408*cdf0e10cSrcweir XML_STYLE_FAMILY_MASTER_PAGE, sMasterPageName ) ); 409*cdf0e10cSrcweir // The families cointaner must exist 410*cdf0e10cSrcweir const Reference < XNameContainer >& rPageStyles = 411*cdf0e10cSrcweir GetImport().GetTextImport()->GetPageStyles(); 412*cdf0e10cSrcweir if( ( !sDisplayName.getLength() || 413*cdf0e10cSrcweir (rPageStyles.is() && 414*cdf0e10cSrcweir rPageStyles->hasByName( sDisplayName )) ) && 415*cdf0e10cSrcweir xPropSetInfo->hasPropertyByName( sPageDescName ) ) 416*cdf0e10cSrcweir { 417*cdf0e10cSrcweir Any aAny; 418*cdf0e10cSrcweir aAny <<= sDisplayName; 419*cdf0e10cSrcweir xPropSet->setPropertyValue( sPageDescName, aAny ); 420*cdf0e10cSrcweir } 421*cdf0e10cSrcweir } 422*cdf0e10cSrcweir } 423*cdf0e10cSrcweir 424*cdf0e10cSrcweir void XMLTextStyleContext::FillPropertySet( 425*cdf0e10cSrcweir const Reference<XPropertySet > & rPropSet ) 426*cdf0e10cSrcweir { 427*cdf0e10cSrcweir // imitate the FillPropertySet of the super class, so we get a chance to 428*cdf0e10cSrcweir // catch the combined characters attribute 429*cdf0e10cSrcweir 430*cdf0e10cSrcweir // imitate XMLPropStyleContext::FillPropertySet(...) 431*cdf0e10cSrcweir UniReference < SvXMLImportPropertyMapper > xImpPrMap = 432*cdf0e10cSrcweir ((SvXMLStylesContext *)GetStyles())->GetImportPropertyMapper(GetFamily()); 433*cdf0e10cSrcweir DBG_ASSERT( xImpPrMap.is(), "Where is the import prop mapper?" ); 434*cdf0e10cSrcweir if( xImpPrMap.is() ) 435*cdf0e10cSrcweir { 436*cdf0e10cSrcweir 437*cdf0e10cSrcweir // imitate SvXMLImportPropertyMapper::FillPropertySet(...) 438*cdf0e10cSrcweir 439*cdf0e10cSrcweir // The reason for this is that we have no other way to 440*cdf0e10cSrcweir // efficiently intercept the value of combined characters. To 441*cdf0e10cSrcweir // get that value, we could iterate through the map once more, 442*cdf0e10cSrcweir // but instead we chose to insert the code into this 443*cdf0e10cSrcweir // iteration. I haven't been able to come up with a much more 444*cdf0e10cSrcweir // intelligent solution. 445*cdf0e10cSrcweir 446*cdf0e10cSrcweir 447*cdf0e10cSrcweir struct _ContextID_Index_Pair aContextIDs[] = 448*cdf0e10cSrcweir { 449*cdf0e10cSrcweir { CTF_COMBINED_CHARACTERS_FIELD, -1 }, 450*cdf0e10cSrcweir { CTF_KEEP_TOGETHER, -1 }, 451*cdf0e10cSrcweir { CTF_BORDER_MODEL, -1 }, 452*cdf0e10cSrcweir { CTF_TEXT_DISPLAY, -1 }, 453*cdf0e10cSrcweir { CTF_FONTFAMILYNAME, -1 }, 454*cdf0e10cSrcweir { CTF_FONTFAMILYNAME_CJK, -1 }, 455*cdf0e10cSrcweir { CTF_FONTFAMILYNAME_CTL, -1 }, 456*cdf0e10cSrcweir { -1, -1 } 457*cdf0e10cSrcweir }; 458*cdf0e10cSrcweir 459*cdf0e10cSrcweir // get property set info 460*cdf0e10cSrcweir Reference< XPropertySetInfo > xInfo( rPropSet->getPropertySetInfo(), UNO_SET_THROW ); 461*cdf0e10cSrcweir 462*cdf0e10cSrcweir bool bAutomatic = false; 463*cdf0e10cSrcweir if( ((SvXMLStylesContext *)GetStyles())->IsAutomaticStyle() && 464*cdf0e10cSrcweir ( GetFamily() == XML_STYLE_FAMILY_TEXT_TEXT || GetFamily() == XML_STYLE_FAMILY_TEXT_PARAGRAPH ) ) 465*cdf0e10cSrcweir { 466*cdf0e10cSrcweir bAutomatic = true; 467*cdf0e10cSrcweir if( GetAutoName().getLength() ) 468*cdf0e10cSrcweir { 469*cdf0e10cSrcweir OUString sAutoProp = ( GetFamily() == XML_STYLE_FAMILY_TEXT_TEXT ) ? 470*cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM("CharAutoStyleName") ): 471*cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM("ParaAutoStyleName") ); 472*cdf0e10cSrcweir try 473*cdf0e10cSrcweir { 474*cdf0e10cSrcweir if ( xInfo->hasPropertyByName( sAutoProp ) ) 475*cdf0e10cSrcweir rPropSet->setPropertyValue( sAutoProp, makeAny(GetAutoName()) ); 476*cdf0e10cSrcweir else 477*cdf0e10cSrcweir bAutomatic = false; 478*cdf0e10cSrcweir } 479*cdf0e10cSrcweir catch( const RuntimeException& ) { throw; } 480*cdf0e10cSrcweir catch( const Exception& ) 481*cdf0e10cSrcweir { 482*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 483*cdf0e10cSrcweir bAutomatic = false; 484*cdf0e10cSrcweir } 485*cdf0e10cSrcweir } 486*cdf0e10cSrcweir } 487*cdf0e10cSrcweir if( bAutomatic ) 488*cdf0e10cSrcweir xImpPrMap->CheckSpecialContext( GetProperties(), rPropSet, aContextIDs ); 489*cdf0e10cSrcweir else 490*cdf0e10cSrcweir xImpPrMap->FillPropertySet( GetProperties(), rPropSet, aContextIDs ); 491*cdf0e10cSrcweir 492*cdf0e10cSrcweir // have we found a combined characters 493*cdf0e10cSrcweir sal_Int32 nIndex = aContextIDs[0].nIndex; 494*cdf0e10cSrcweir if ( nIndex != -1 ) 495*cdf0e10cSrcweir { 496*cdf0e10cSrcweir Any& rAny = GetProperties()[nIndex].maValue; 497*cdf0e10cSrcweir sal_Bool bVal = *(sal_Bool*)rAny.getValue(); 498*cdf0e10cSrcweir bHasCombinedCharactersLetter = bVal; 499*cdf0e10cSrcweir } 500*cdf0e10cSrcweir 501*cdf0e10cSrcweir // keep-together: the application default is different from 502*cdf0e10cSrcweir // the file format default. Hence, if we always set this 503*cdf0e10cSrcweir // value; if we didn't find one, we'll set to false, the file 504*cdf0e10cSrcweir // format default. 505*cdf0e10cSrcweir // border-model: same 506*cdf0e10cSrcweir if( IsDefaultStyle() && GetFamily() == XML_STYLE_FAMILY_TABLE_ROW ) 507*cdf0e10cSrcweir { 508*cdf0e10cSrcweir OUString sIsSplitAllowed = 509*cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM( "IsSplitAllowed" ) ); 510*cdf0e10cSrcweir DBG_ASSERT( rPropSet->getPropertySetInfo()->hasPropertyByName( sIsSplitAllowed ), 511*cdf0e10cSrcweir "property missing?" ); 512*cdf0e10cSrcweir rPropSet->setPropertyValue( sIsSplitAllowed, 513*cdf0e10cSrcweir (aContextIDs[1].nIndex == -1) 514*cdf0e10cSrcweir ? makeAny( false ) 515*cdf0e10cSrcweir : GetProperties()[aContextIDs[1].nIndex].maValue ); 516*cdf0e10cSrcweir } 517*cdf0e10cSrcweir 518*cdf0e10cSrcweir if( IsDefaultStyle() && GetFamily() == XML_STYLE_FAMILY_TABLE_TABLE ) 519*cdf0e10cSrcweir { 520*cdf0e10cSrcweir OUString sCollapsingBorders( 521*cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM( "CollapsingBorders" ) ) ); 522*cdf0e10cSrcweir DBG_ASSERT( rPropSet->getPropertySetInfo()->hasPropertyByName( sCollapsingBorders ), 523*cdf0e10cSrcweir "property missing?" ); 524*cdf0e10cSrcweir rPropSet->setPropertyValue( sCollapsingBorders, 525*cdf0e10cSrcweir (aContextIDs[2].nIndex == -1) 526*cdf0e10cSrcweir ? makeAny( false ) 527*cdf0e10cSrcweir : GetProperties()[aContextIDs[2].nIndex].maValue ); 528*cdf0e10cSrcweir } 529*cdf0e10cSrcweir 530*cdf0e10cSrcweir 531*cdf0e10cSrcweir // check for StarBats and StarMath fonts 532*cdf0e10cSrcweir 533*cdf0e10cSrcweir // iterate over aContextIDs entries 3..6 534*cdf0e10cSrcweir for ( sal_Int32 i = 3; i < 7; i++ ) 535*cdf0e10cSrcweir { 536*cdf0e10cSrcweir nIndex = aContextIDs[i].nIndex; 537*cdf0e10cSrcweir if ( nIndex != -1 ) 538*cdf0e10cSrcweir { 539*cdf0e10cSrcweir // Found! 540*cdf0e10cSrcweir struct XMLPropertyState& rState = GetProperties()[nIndex]; 541*cdf0e10cSrcweir Any rAny = rState.maValue; 542*cdf0e10cSrcweir sal_Int32 nMapperIndex = rState.mnIndex; 543*cdf0e10cSrcweir 544*cdf0e10cSrcweir // Now check for font name in rState and set corrected value, 545*cdf0e10cSrcweir // if necessary. 546*cdf0e10cSrcweir OUString sFontName; 547*cdf0e10cSrcweir rAny >>= sFontName; 548*cdf0e10cSrcweir if ( sFontName.getLength() > 0 ) 549*cdf0e10cSrcweir { 550*cdf0e10cSrcweir OUString sStarBats( RTL_CONSTASCII_USTRINGPARAM("StarBats" ) ); 551*cdf0e10cSrcweir OUString sStarMath( RTL_CONSTASCII_USTRINGPARAM("StarMath" ) ); 552*cdf0e10cSrcweir if ( sFontName.equalsIgnoreAsciiCase( sStarBats ) || 553*cdf0e10cSrcweir sFontName.equalsIgnoreAsciiCase( sStarMath ) ) 554*cdf0e10cSrcweir { 555*cdf0e10cSrcweir // construct new value 556*cdf0e10cSrcweir sFontName = OUString( 557*cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("StarSymbol") ); 558*cdf0e10cSrcweir Any aAny( rAny ); 559*cdf0e10cSrcweir aAny <<= sFontName; 560*cdf0e10cSrcweir 561*cdf0e10cSrcweir // get property set mapper 562*cdf0e10cSrcweir UniReference<XMLPropertySetMapper> rPropMapper = 563*cdf0e10cSrcweir xImpPrMap->getPropertySetMapper(); 564*cdf0e10cSrcweir 565*cdf0e10cSrcweir // set property 566*cdf0e10cSrcweir OUString rPropertyName( 567*cdf0e10cSrcweir rPropMapper->GetEntryAPIName(nMapperIndex) ); 568*cdf0e10cSrcweir if ( xInfo->hasPropertyByName( rPropertyName ) ) 569*cdf0e10cSrcweir { 570*cdf0e10cSrcweir rPropSet->setPropertyValue( rPropertyName, aAny ); 571*cdf0e10cSrcweir } 572*cdf0e10cSrcweir } 573*cdf0e10cSrcweir // else: "normal" style name -> no correction is necessary 574*cdf0e10cSrcweir } 575*cdf0e10cSrcweir // else: no style name found -> illegal value -> ignore 576*cdf0e10cSrcweir } 577*cdf0e10cSrcweir } 578*cdf0e10cSrcweir } 579*cdf0e10cSrcweir } 580