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 
31 #ifndef _XMLOFF_XMLSHAPEPROPERTYSETCONTEXT_HXX_
32 #include "XMLShapePropertySetContext.hxx"
33 #endif
34 #include <xmloff/xmlimp.hxx>
35 #include <xmloff/xmlnumi.hxx>
36 #include "xmltabi.hxx"
37 #include <xmloff/txtprmap.hxx>
38 
39 #include "sdpropls.hxx"
40 
41 using ::rtl::OUString;
42 using ::rtl::OUStringBuffer;
43 
44 using namespace ::com::sun::star;
45 using namespace ::com::sun::star::uno;
46 
47 //////////////////////////////////////////////////////////////////////////////
48 
49 TYPEINIT1( XMLShapePropertySetContext, SvXMLPropertySetContext );
50 
51 XMLShapePropertySetContext::XMLShapePropertySetContext(
52 				 SvXMLImport& rImport, sal_uInt16 nPrfx,
53 				 const OUString& rLName,
54 				 const Reference< xml::sax::XAttributeList > & xAttrList,
55 				 sal_uInt32 nFam,
56 				 ::std::vector< XMLPropertyState > &rProps,
57 				 const UniReference < SvXMLImportPropertyMapper > &rMap ) :
58 	SvXMLPropertySetContext( rImport, nPrfx, rLName, xAttrList, nFam,
59 							 rProps, rMap ),
60 	mnBulletIndex(-1)
61 {
62 }
63 
64 XMLShapePropertySetContext::~XMLShapePropertySetContext()
65 {
66 }
67 
68 void XMLShapePropertySetContext::EndElement()
69 {
70 	Reference< container::XIndexReplace > xNumRule;
71 	if( mxBulletStyle.Is() )
72 	{
73 		SvxXMLListStyleContext* pBulletStyle = (SvxXMLListStyleContext*)&mxBulletStyle;
74 		xNumRule = pBulletStyle->CreateNumRule( GetImport().GetModel() );
75 		if( xNumRule.is() )
76 			pBulletStyle->FillUnoNumRule(xNumRule, NULL /* const SvI18NMap * ??? */ );
77 	}
78 
79 	Any aAny;
80 	aAny <<= xNumRule;
81 
82 	XMLPropertyState aPropState( mnBulletIndex, aAny );
83 	mrProperties.push_back( aPropState );
84 
85 	SvXMLPropertySetContext::EndElement();
86 }
87 
88 SvXMLImportContext *XMLShapePropertySetContext::CreateChildContext(
89 				   sal_uInt16 nPrefix,
90 				   const OUString& rLocalName,
91 				   const Reference< xml::sax::XAttributeList > & xAttrList,
92 				   ::std::vector< XMLPropertyState > &rProperties,
93 				   const XMLPropertyState& rProp )
94 {
95 	SvXMLImportContext *pContext = 0;
96 
97 	switch( mxMapper->getPropertySetMapper()->GetEntryContextId( rProp.mnIndex ) )
98 	{
99 	case CTF_NUMBERINGRULES:
100 		mnBulletIndex = rProp.mnIndex;
101 		mxBulletStyle = pContext = new SvxXMLListStyleContext( GetImport(), nPrefix, rLocalName, xAttrList );
102 		break;
103 	case CTF_TABSTOP:
104 		pContext = new SvxXMLTabStopImportContext( GetImport(), nPrefix,
105 												   rLocalName, rProp,
106 												   rProperties );
107 		break;
108 	}
109 
110 	if( !pContext )
111 		pContext = SvXMLPropertySetContext::CreateChildContext( nPrefix, rLocalName,
112 															xAttrList,
113 															rProperties, rProp );
114 
115 	return pContext;
116 }
117