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 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 27 #include <tools/debug.hxx> 28 #include <xmloff/xmlimp.hxx> 29 #include <xmloff/nmspmap.hxx> 30 #include "xmloff/xmlnmspe.hxx" 31 #include <xmloff/xmltoken.hxx> 32 33 #ifndef _XMLOFF_FAMILIES_HXX 34 #include <xmloff/families.hxx> 35 #endif 36 #include "XMLShapePropertySetContext.hxx" 37 #include <xmloff/XMLGraphicsDefaultStyle.hxx> 38 39 using ::rtl::OUString; 40 using ::rtl::OUStringBuffer; 41 42 using namespace ::com::sun::star; 43 using namespace ::com::sun::star::uno; 44 using namespace ::com::sun::star::lang; 45 using namespace ::com::sun::star::beans; 46 using namespace ::com::sun::star::xml::sax; 47 48 using ::xmloff::token::IsXMLToken; 49 using ::xmloff::token::XML_TEXT_PROPERTIES; 50 using ::xmloff::token::XML_GRAPHIC_PROPERTIES; 51 using ::xmloff::token::XML_PARAGRAPH_PROPERTIES; 52 53 // --------------------------------------------------------------------- 54 55 TYPEINIT1( XMLGraphicsDefaultStyle, XMLPropStyleContext ); 56 57 XMLGraphicsDefaultStyle::XMLGraphicsDefaultStyle( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName, const Reference< XAttributeList >& xAttrList, SvXMLStylesContext& rStyles ) 58 : XMLPropStyleContext( rImport, nPrfx, rLName, xAttrList, rStyles, XML_STYLE_FAMILY_SD_GRAPHICS_ID, sal_True ) 59 { 60 } 61 62 XMLGraphicsDefaultStyle::~XMLGraphicsDefaultStyle() 63 { 64 } 65 66 SvXMLImportContext *XMLGraphicsDefaultStyle::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const Reference< XAttributeList > & xAttrList ) 67 { 68 SvXMLImportContext *pContext = 0; 69 70 if( XML_NAMESPACE_STYLE == nPrefix ) 71 { 72 sal_uInt32 nFamily = 0; 73 if( IsXMLToken( rLocalName, XML_TEXT_PROPERTIES ) ) 74 nFamily = XML_TYPE_PROP_TEXT; 75 else if( IsXMLToken( rLocalName, XML_PARAGRAPH_PROPERTIES ) ) 76 nFamily = XML_TYPE_PROP_PARAGRAPH; 77 else if( IsXMLToken( rLocalName, XML_GRAPHIC_PROPERTIES ) ) 78 nFamily = XML_TYPE_PROP_GRAPHIC; 79 if( nFamily ) 80 { 81 UniReference < SvXMLImportPropertyMapper > xImpPrMap = GetStyles()->GetImportPropertyMapper( GetFamily() ); 82 if( xImpPrMap.is() ) 83 pContext = new XMLShapePropertySetContext( GetImport(), nPrefix, rLocalName, xAttrList, nFamily, GetProperties(), xImpPrMap ); 84 } 85 } 86 87 if( !pContext ) 88 pContext = XMLPropStyleContext::CreateChildContext( nPrefix, rLocalName, xAttrList ); 89 90 return pContext; 91 } 92 93 // This method is called for every default style 94 void XMLGraphicsDefaultStyle::SetDefaults() 95 { 96 Reference< XMultiServiceFactory > xFact( GetImport().GetModel(), UNO_QUERY ); 97 if( !xFact.is() ) 98 return; 99 100 Reference< XPropertySet > xDefaults( xFact->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.Defaults") ) ), UNO_QUERY ); 101 if( !xDefaults.is() ) 102 return; 103 // SJ: #i114750# 104 sal_Bool bWordWrapDefault = sal_True; // initializing with correct odf fo:wrap-option default 105 sal_Int32 nUPD( 0 ); 106 sal_Int32 nBuild( 0 ); 107 const bool bBuildIdFound = GetImport().getBuildIds( nUPD, nBuild ); 108 if ( bBuildIdFound && ( 109 ((nUPD >= 600) && (nUPD < 700)) 110 || 111 ((nUPD == 300) && (nBuild <= 9535)) 112 || 113 ((nUPD > 300) && (nUPD <= 330)) 114 ) ) 115 bWordWrapDefault = sal_False; 116 117 const OUString sTextWordWrap( RTL_CONSTASCII_USTRINGPARAM( "TextWordWrap" ) ); 118 Reference< XPropertySetInfo > xInfo( xDefaults->getPropertySetInfo() ); 119 if ( xInfo->hasPropertyByName( sTextWordWrap ) ) 120 xDefaults->setPropertyValue( sTextWordWrap, Any( bWordWrapDefault ) ); 121 122 FillPropertySet( xDefaults ); 123 } 124 125 126