1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_xmloff.hxx" 30 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 31 #include <tools/debug.hxx> 32 #include <xmloff/xmlimp.hxx> 33 #include <xmloff/nmspmap.hxx> 34 #include "xmloff/xmlnmspe.hxx" 35 #include <xmloff/xmltoken.hxx> 36 37 #ifndef _XMLOFF_FAMILIES_HXX 38 #include <xmloff/families.hxx> 39 #endif 40 #include "XMLShapePropertySetContext.hxx" 41 #include <xmloff/XMLGraphicsDefaultStyle.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::lang; 49 using namespace ::com::sun::star::beans; 50 using namespace ::com::sun::star::xml::sax; 51 52 using ::xmloff::token::IsXMLToken; 53 using ::xmloff::token::XML_TEXT_PROPERTIES; 54 using ::xmloff::token::XML_GRAPHIC_PROPERTIES; 55 using ::xmloff::token::XML_PARAGRAPH_PROPERTIES; 56 57 // --------------------------------------------------------------------- 58 59 TYPEINIT1( XMLGraphicsDefaultStyle, XMLPropStyleContext ); 60 61 XMLGraphicsDefaultStyle::XMLGraphicsDefaultStyle( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName, const Reference< XAttributeList >& xAttrList, SvXMLStylesContext& rStyles ) 62 : XMLPropStyleContext( rImport, nPrfx, rLName, xAttrList, rStyles, XML_STYLE_FAMILY_SD_GRAPHICS_ID, sal_True ) 63 { 64 } 65 66 XMLGraphicsDefaultStyle::~XMLGraphicsDefaultStyle() 67 { 68 } 69 70 SvXMLImportContext *XMLGraphicsDefaultStyle::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const Reference< XAttributeList > & xAttrList ) 71 { 72 SvXMLImportContext *pContext = 0; 73 74 if( XML_NAMESPACE_STYLE == nPrefix ) 75 { 76 sal_uInt32 nFamily = 0; 77 if( IsXMLToken( rLocalName, XML_TEXT_PROPERTIES ) ) 78 nFamily = XML_TYPE_PROP_TEXT; 79 else if( IsXMLToken( rLocalName, XML_PARAGRAPH_PROPERTIES ) ) 80 nFamily = XML_TYPE_PROP_PARAGRAPH; 81 else if( IsXMLToken( rLocalName, XML_GRAPHIC_PROPERTIES ) ) 82 nFamily = XML_TYPE_PROP_GRAPHIC; 83 if( nFamily ) 84 { 85 UniReference < SvXMLImportPropertyMapper > xImpPrMap = GetStyles()->GetImportPropertyMapper( GetFamily() ); 86 if( xImpPrMap.is() ) 87 pContext = new XMLShapePropertySetContext( GetImport(), nPrefix, rLocalName, xAttrList, nFamily, GetProperties(), xImpPrMap ); 88 } 89 } 90 91 if( !pContext ) 92 pContext = XMLPropStyleContext::CreateChildContext( nPrefix, rLocalName, xAttrList ); 93 94 return pContext; 95 } 96 97 // This method is called for every default style 98 void XMLGraphicsDefaultStyle::SetDefaults() 99 { 100 Reference< XMultiServiceFactory > xFact( GetImport().GetModel(), UNO_QUERY ); 101 if( !xFact.is() ) 102 return; 103 104 Reference< XPropertySet > xDefaults( xFact->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.Defaults") ) ), UNO_QUERY ); 105 if( !xDefaults.is() ) 106 return; 107 // SJ: #i114750# 108 sal_Bool bWordWrapDefault = sal_True; // initializing with correct odf fo:wrap-option default 109 sal_Int32 nUPD( 0 ); 110 sal_Int32 nBuild( 0 ); 111 const bool bBuildIdFound = GetImport().getBuildIds( nUPD, nBuild ); 112 if ( bBuildIdFound && ( 113 ((nUPD >= 600) && (nUPD < 700)) 114 || 115 ((nUPD == 300) && (nBuild <= 9535)) 116 || 117 ((nUPD > 300) && (nUPD <= 330)) 118 ) ) 119 bWordWrapDefault = sal_False; 120 121 const OUString sTextWordWrap( RTL_CONSTASCII_USTRINGPARAM( "TextWordWrap" ) ); 122 Reference< XPropertySetInfo > xInfo( xDefaults->getPropertySetInfo() ); 123 if ( xInfo->hasPropertyByName( sTextWordWrap ) ) 124 xDefaults->setPropertyValue( sTextWordWrap, Any( bWordWrapDefault ) ); 125 126 FillPropertySet( xDefaults ); 127 } 128 129 130