1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
30 #include <xmloff/xmlimp.hxx>
31 #include <xmloff/nmspmap.hxx>
32 #include "xmloff/xmlnmspe.hxx"
33 #include <xmloff/xmltoken.hxx>
35 #include <xmloff/families.hxx>
36 #include "XMLShapePropertySetContext.hxx"
37 #include <xmloff/XMLGraphicsDefaultStyle.hxx>
39 using ::rtl::OUString
;
40 using ::rtl::OUStringBuffer
;
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
;
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
;
53 // ---------------------------------------------------------------------
55 TYPEINIT1( XMLGraphicsDefaultStyle
, XMLPropStyleContext
);
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
)
62 XMLGraphicsDefaultStyle::~XMLGraphicsDefaultStyle()
66 SvXMLImportContext
*XMLGraphicsDefaultStyle::CreateChildContext( sal_uInt16 nPrefix
, const OUString
& rLocalName
, const Reference
< XAttributeList
> & xAttrList
)
68 SvXMLImportContext
*pContext
= 0;
70 if( XML_NAMESPACE_STYLE
== nPrefix
)
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
;
81 UniReference
< SvXMLImportPropertyMapper
> xImpPrMap
= GetStyles()->GetImportPropertyMapper( GetFamily() );
83 pContext
= new XMLShapePropertySetContext( GetImport(), nPrefix
, rLocalName
, xAttrList
, nFamily
, GetProperties(), xImpPrMap
);
88 pContext
= XMLPropStyleContext::CreateChildContext( nPrefix
, rLocalName
, xAttrList
);
93 // This method is called for every default style
94 void XMLGraphicsDefaultStyle::SetDefaults()
96 Reference
< XMultiServiceFactory
> xFact( GetImport().GetModel(), UNO_QUERY
);
100 Reference
< XPropertySet
> xDefaults( xFact
->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.Defaults") ) ), UNO_QUERY
);
101 if( !xDefaults
.is() )
104 sal_Bool bWordWrapDefault
= sal_True
; // initializing with correct odf fo:wrap-option default
106 sal_Int32
nBuild( 0 );
107 const bool bBuildIdFound
= GetImport().getBuildIds( nUPD
, nBuild
);
108 if ( bBuildIdFound
&& (
109 ((nUPD
>= 600) && (nUPD
< 700))
111 ((nUPD
== 300) && (nBuild
<= 9535))
113 ((nUPD
> 300) && (nUPD
<= 330))
115 bWordWrapDefault
= sal_False
;
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
) );
122 FillPropertySet( xDefaults
);
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */