1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: XMLGraphicsDefaultStyle.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
33 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
34 #include <tools/debug.hxx>
35 #include <xmloff/xmlimp.hxx>
36 #include <xmloff/nmspmap.hxx>
37 #include "xmlnmspe.hxx"
38 #include <xmloff/xmltoken.hxx>
40 #ifndef _XMLOFF_FAMILIES_HXX
41 #include <xmloff/families.hxx>
43 #include "XMLShapePropertySetContext.hxx"
44 #include <xmloff/XMLGraphicsDefaultStyle.hxx>
46 using ::rtl::OUString
;
47 using ::rtl::OUStringBuffer
;
49 using namespace ::com::sun::star
;
50 using namespace ::com::sun::star::uno
;
51 using namespace ::com::sun::star::lang
;
52 using namespace ::com::sun::star::beans
;
53 using namespace ::com::sun::star::xml::sax
;
55 using ::xmloff::token::IsXMLToken
;
56 using ::xmloff::token::XML_TEXT_PROPERTIES
;
57 using ::xmloff::token::XML_GRAPHIC_PROPERTIES
;
58 using ::xmloff::token::XML_PARAGRAPH_PROPERTIES
;
60 // ---------------------------------------------------------------------
62 TYPEINIT1( XMLGraphicsDefaultStyle
, XMLPropStyleContext
);
64 XMLGraphicsDefaultStyle::XMLGraphicsDefaultStyle( SvXMLImport
& rImport
, sal_uInt16 nPrfx
, const OUString
& rLName
, const Reference
< XAttributeList
>& xAttrList
, SvXMLStylesContext
& rStyles
)
65 : XMLPropStyleContext( rImport
, nPrfx
, rLName
, xAttrList
, rStyles
, XML_STYLE_FAMILY_SD_GRAPHICS_ID
, sal_True
)
69 XMLGraphicsDefaultStyle::~XMLGraphicsDefaultStyle()
73 SvXMLImportContext
*XMLGraphicsDefaultStyle::CreateChildContext( sal_uInt16 nPrefix
, const OUString
& rLocalName
, const Reference
< XAttributeList
> & xAttrList
)
75 SvXMLImportContext
*pContext
= 0;
77 if( XML_NAMESPACE_STYLE
== nPrefix
)
79 sal_uInt32 nFamily
= 0;
80 if( IsXMLToken( rLocalName
, XML_TEXT_PROPERTIES
) )
81 nFamily
= XML_TYPE_PROP_TEXT
;
82 else if( IsXMLToken( rLocalName
, XML_PARAGRAPH_PROPERTIES
) )
83 nFamily
= XML_TYPE_PROP_PARAGRAPH
;
84 else if( IsXMLToken( rLocalName
, XML_GRAPHIC_PROPERTIES
) )
85 nFamily
= XML_TYPE_PROP_GRAPHIC
;
88 UniReference
< SvXMLImportPropertyMapper
> xImpPrMap
= GetStyles()->GetImportPropertyMapper( GetFamily() );
90 pContext
= new XMLShapePropertySetContext( GetImport(), nPrefix
, rLocalName
, xAttrList
, nFamily
, GetProperties(), xImpPrMap
);
95 pContext
= XMLPropStyleContext::CreateChildContext( nPrefix
, rLocalName
, xAttrList
);
100 // This method is called for every default style
101 void XMLGraphicsDefaultStyle::SetDefaults()
103 Reference
< XMultiServiceFactory
> xFact( GetImport().GetModel(), UNO_QUERY
);
107 Reference
< XPropertySet
> xDefaults( xFact
->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.Defaults") ) ), UNO_QUERY
);
108 if( !xDefaults
.is() )
111 FillPropertySet( xDefaults
);