1*63bba73cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*63bba73cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*63bba73cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*63bba73cSAndrew Rist  * distributed with this work for additional information
6*63bba73cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*63bba73cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*63bba73cSAndrew Rist  * "License"); you may not use this file except in compliance
9*63bba73cSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*63bba73cSAndrew Rist  *
11*63bba73cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*63bba73cSAndrew Rist  *
13*63bba73cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*63bba73cSAndrew Rist  * software distributed under the License is distributed on an
15*63bba73cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*63bba73cSAndrew Rist  * KIND, either express or implied.  See the License for the
17*63bba73cSAndrew Rist  * specific language governing permissions and limitations
18*63bba73cSAndrew Rist  * under the License.
19*63bba73cSAndrew Rist  *
20*63bba73cSAndrew Rist  *************************************************************/
21*63bba73cSAndrew Rist 
22*63bba73cSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_xmloff.hxx"
26cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
27cdf0e10cSrcweir #include <tools/debug.hxx>
28cdf0e10cSrcweir #include <xmloff/xmlimp.hxx>
29cdf0e10cSrcweir #include <xmloff/nmspmap.hxx>
30cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx"
31cdf0e10cSrcweir #include <xmloff/xmltoken.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #ifndef _XMLOFF_FAMILIES_HXX
34cdf0e10cSrcweir #include <xmloff/families.hxx>
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir #include "XMLShapePropertySetContext.hxx"
37cdf0e10cSrcweir #include <xmloff/XMLGraphicsDefaultStyle.hxx>
38cdf0e10cSrcweir 
39cdf0e10cSrcweir using ::rtl::OUString;
40cdf0e10cSrcweir using ::rtl::OUStringBuffer;
41cdf0e10cSrcweir 
42cdf0e10cSrcweir using namespace ::com::sun::star;
43cdf0e10cSrcweir using namespace ::com::sun::star::uno;
44cdf0e10cSrcweir using namespace ::com::sun::star::lang;
45cdf0e10cSrcweir using namespace ::com::sun::star::beans;
46cdf0e10cSrcweir using namespace ::com::sun::star::xml::sax;
47cdf0e10cSrcweir 
48cdf0e10cSrcweir using ::xmloff::token::IsXMLToken;
49cdf0e10cSrcweir using ::xmloff::token::XML_TEXT_PROPERTIES;
50cdf0e10cSrcweir using ::xmloff::token::XML_GRAPHIC_PROPERTIES;
51cdf0e10cSrcweir using ::xmloff::token::XML_PARAGRAPH_PROPERTIES;
52cdf0e10cSrcweir 
53cdf0e10cSrcweir // ---------------------------------------------------------------------
54cdf0e10cSrcweir 
55cdf0e10cSrcweir TYPEINIT1( XMLGraphicsDefaultStyle, XMLPropStyleContext );
56cdf0e10cSrcweir 
XMLGraphicsDefaultStyle(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLName,const Reference<XAttributeList> & xAttrList,SvXMLStylesContext & rStyles)57cdf0e10cSrcweir XMLGraphicsDefaultStyle::XMLGraphicsDefaultStyle( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName, const Reference< XAttributeList >& xAttrList, SvXMLStylesContext& rStyles )
58cdf0e10cSrcweir : XMLPropStyleContext( rImport, nPrfx, rLName, xAttrList, rStyles, XML_STYLE_FAMILY_SD_GRAPHICS_ID, sal_True )
59cdf0e10cSrcweir {
60cdf0e10cSrcweir }
61cdf0e10cSrcweir 
~XMLGraphicsDefaultStyle()62cdf0e10cSrcweir XMLGraphicsDefaultStyle::~XMLGraphicsDefaultStyle()
63cdf0e10cSrcweir {
64cdf0e10cSrcweir }
65cdf0e10cSrcweir 
CreateChildContext(sal_uInt16 nPrefix,const OUString & rLocalName,const Reference<XAttributeList> & xAttrList)66cdf0e10cSrcweir SvXMLImportContext *XMLGraphicsDefaultStyle::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const Reference< XAttributeList > & xAttrList )
67cdf0e10cSrcweir {
68cdf0e10cSrcweir 	SvXMLImportContext *pContext = 0;
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 	if( XML_NAMESPACE_STYLE == nPrefix )
71cdf0e10cSrcweir 	{
72cdf0e10cSrcweir 		sal_uInt32 nFamily = 0;
73cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_TEXT_PROPERTIES ) )
74cdf0e10cSrcweir 			nFamily = XML_TYPE_PROP_TEXT;
75cdf0e10cSrcweir 		else if( IsXMLToken( rLocalName, XML_PARAGRAPH_PROPERTIES ) )
76cdf0e10cSrcweir 			nFamily = XML_TYPE_PROP_PARAGRAPH;
77cdf0e10cSrcweir 		else if( IsXMLToken( rLocalName, XML_GRAPHIC_PROPERTIES ) )
78cdf0e10cSrcweir 			nFamily = XML_TYPE_PROP_GRAPHIC;
79cdf0e10cSrcweir 		if( nFamily )
80cdf0e10cSrcweir 		{
81cdf0e10cSrcweir 			UniReference < SvXMLImportPropertyMapper > xImpPrMap = GetStyles()->GetImportPropertyMapper( GetFamily() );
82cdf0e10cSrcweir 			if( xImpPrMap.is() )
83cdf0e10cSrcweir 				pContext = new XMLShapePropertySetContext( GetImport(), nPrefix, rLocalName, xAttrList,	nFamily, GetProperties(), xImpPrMap );
84cdf0e10cSrcweir 		}
85cdf0e10cSrcweir 	}
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 	if( !pContext )
88cdf0e10cSrcweir 		pContext = XMLPropStyleContext::CreateChildContext( nPrefix, rLocalName, xAttrList );
89cdf0e10cSrcweir 
90cdf0e10cSrcweir 	return pContext;
91cdf0e10cSrcweir }
92cdf0e10cSrcweir 
93cdf0e10cSrcweir // This method is called for every default style
SetDefaults()94cdf0e10cSrcweir void XMLGraphicsDefaultStyle::SetDefaults()
95cdf0e10cSrcweir {
96cdf0e10cSrcweir 	Reference< XMultiServiceFactory > xFact( GetImport().GetModel(), UNO_QUERY );
97cdf0e10cSrcweir 	if( !xFact.is() )
98cdf0e10cSrcweir 		return;
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 	Reference< XPropertySet > xDefaults( xFact->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.Defaults") ) ), UNO_QUERY );
101cdf0e10cSrcweir 	if( !xDefaults.is() )
102cdf0e10cSrcweir 		return;
103cdf0e10cSrcweir 											// SJ: #i114750#
104cdf0e10cSrcweir 	sal_Bool bWordWrapDefault = sal_True;	// initializing with correct odf fo:wrap-option default
105cdf0e10cSrcweir 	sal_Int32 nUPD( 0 );
106cdf0e10cSrcweir 	sal_Int32 nBuild( 0 );
107cdf0e10cSrcweir 	const bool bBuildIdFound = GetImport().getBuildIds( nUPD, nBuild );
108cdf0e10cSrcweir 	if ( bBuildIdFound && (
109cdf0e10cSrcweir 		((nUPD >= 600) &&  (nUPD < 700))
110cdf0e10cSrcweir 		||
111cdf0e10cSrcweir 		((nUPD == 300) && (nBuild <= 9535))
112cdf0e10cSrcweir 		||
113cdf0e10cSrcweir 		((nUPD > 300) && (nUPD <= 330))
114cdf0e10cSrcweir 	) )
115cdf0e10cSrcweir 		bWordWrapDefault = sal_False;
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 	const OUString sTextWordWrap( RTL_CONSTASCII_USTRINGPARAM( "TextWordWrap" ) );
118cdf0e10cSrcweir 	Reference< XPropertySetInfo > xInfo( xDefaults->getPropertySetInfo() );
119cdf0e10cSrcweir 	if ( xInfo->hasPropertyByName( sTextWordWrap ) )
120cdf0e10cSrcweir 		xDefaults->setPropertyValue( sTextWordWrap, Any( bWordWrapDefault ) );
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 	FillPropertySet( xDefaults );
123cdf0e10cSrcweir }
124cdf0e10cSrcweir 
125cdf0e10cSrcweir 
126