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 #include <tools/debug.hxx>
31 #include "XMLTextPropertySetContext.hxx"
32 #include "XMLTextColumnsContext.hxx"
33 #include "XMLBackgroundImageContext.hxx"
34 #include "XMLSectionFootnoteConfigImport.hxx"
35 
36 #ifndef _XMLOFF_TXTPRMAP_HXX
37 #include <xmloff/txtprmap.hxx>
38 #endif
39 #include "xmltabi.hxx"
40 #ifndef _XMLOFF_TXTDROPI_HXX
41 #include "txtdropi.hxx"
42 #endif
43 
44 using ::rtl::OUString;
45 
46 using namespace ::com::sun::star::uno;
47 using namespace ::com::sun::star;
48 
49 XMLTextPropertySetContext::XMLTextPropertySetContext(
50 				 SvXMLImport& rImport, sal_uInt16 nPrfx,
51 				 const OUString& rLName,
52 				 const Reference< xml::sax::XAttributeList > & xAttrList,
53 				 sal_uInt32 nFamily,
54 				 ::std::vector< XMLPropertyState > &rProps,
55 				 const UniReference < SvXMLImportPropertyMapper > &rMap,
56 				 OUString& rDCTextStyleName ) :
57 	SvXMLPropertySetContext( rImport, nPrfx, rLName, xAttrList, nFamily,
58 							 rProps, rMap ),
59 	rDropCapTextStyleName( rDCTextStyleName )
60 {
61 }
62 
63 XMLTextPropertySetContext::~XMLTextPropertySetContext()
64 {
65 }
66 
67 SvXMLImportContext *XMLTextPropertySetContext::CreateChildContext(
68 				   sal_uInt16 nPrefix,
69 				   const OUString& rLocalName,
70 				   const Reference< xml::sax::XAttributeList > & xAttrList,
71 				   ::std::vector< XMLPropertyState > &rProperties,
72 				   const XMLPropertyState& rProp )
73 {
74 	SvXMLImportContext *pContext = 0;
75 
76 	switch( mxMapper->getPropertySetMapper()
77 					->GetEntryContextId( rProp.mnIndex ) )
78 	{
79 	case CTF_TABSTOP:
80 		pContext = new SvxXMLTabStopImportContext( GetImport(), nPrefix,
81 												   rLocalName, rProp,
82 												   rProperties );
83 		break;
84 	case CTF_TEXTCOLUMNS:
85 #ifndef SVX_LIGHT
86 		pContext = new XMLTextColumnsContext( GetImport(), nPrefix,
87 												   rLocalName, xAttrList, rProp,
88 												   rProperties );
89 #else
90 		// create default context to skip content
91 		pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
92 #endif // #ifndef SVX_LIGHT
93 		break;
94 
95 	case CTF_DROPCAPFORMAT:
96 		{
97 			DBG_ASSERT( rProp.mnIndex >= 2 &&
98 						CTF_DROPCAPWHOLEWORD  == mxMapper->getPropertySetMapper()
99 							->GetEntryContextId( rProp.mnIndex-2 ),
100 						"invalid property map!");
101 			XMLTextDropCapImportContext *pDCContext =
102 				new XMLTextDropCapImportContext( GetImport(), nPrefix,
103 														rLocalName, xAttrList,
104 														rProp,
105 														rProp.mnIndex-2,
106 														rProperties );
107 			rDropCapTextStyleName = pDCContext->GetStyleName();
108 		pContext = pDCContext;
109 		}
110 		break;
111 
112 	case CTF_BACKGROUND_URL:
113     {
114 		DBG_ASSERT( rProp.mnIndex >= 2 &&
115 					CTF_BACKGROUND_POS  == mxMapper->getPropertySetMapper()
116 						->GetEntryContextId( rProp.mnIndex-2 ) &&
117 					CTF_BACKGROUND_FILTER  == mxMapper->getPropertySetMapper()
118 						->GetEntryContextId( rProp.mnIndex-1 ),
119 					"invalid property map!");
120 
121         // #99657# Transparency might be there as well... but doesn't have
122         // to. Thus, this is checked with an if, rather than with an assertion.
123         sal_Int32 nTranspIndex = -1;
124         if( (rProp.mnIndex >= 3) &&
125             ( CTF_BACKGROUND_TRANSPARENCY ==
126               mxMapper->getPropertySetMapper()->GetEntryContextId(
127                   rProp.mnIndex-3 ) ) )
128             nTranspIndex = rProp.mnIndex-3;
129 
130 		pContext =
131 			new XMLBackgroundImageContext( GetImport(), nPrefix,
132 										   rLocalName, xAttrList,
133 										   rProp,
134 										   rProp.mnIndex-2,
135 										   rProp.mnIndex-1,
136 										   nTranspIndex,
137 										   rProperties );
138     }
139     break;
140 #ifndef SVX_LIGHT
141 	case CTF_SECTION_FOOTNOTE_END:
142 	case CTF_SECTION_ENDNOTE_END:
143 		pContext = new XMLSectionFootnoteConfigImport(
144 			GetImport(), nPrefix, rLocalName, rProperties,
145 			mxMapper->getPropertySetMapper());
146 		break;
147 #endif // #ifndef SVX_LIGHT
148 	}
149 
150 	if( !pContext )
151 		pContext = SvXMLPropertySetContext::CreateChildContext( nPrefix, rLocalName,
152 															xAttrList,
153 															rProperties, rProp );
154 
155 	return pContext;
156 }
157 
158 
159