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 "PagePropertySetContext.hxx"
32 #include "XMLBackgroundImageContext.hxx"
33 #include "XMLTextColumnsContext.hxx"
34 #ifndef _XMLOFF_PAGEMASTERSTYLEMAP_HXX
35 #include <xmloff/PageMasterStyleMap.hxx>
36 #endif
37 #include "XMLFootnoteSeparatorImport.hxx"
38 
39 using ::rtl::OUString;
40 
41 using namespace ::com::sun::star::uno;
42 using namespace ::com::sun::star;
43 
44 PagePropertySetContext::PagePropertySetContext(
45 				 SvXMLImport& rImport, sal_uInt16 nPrfx,
46 				 const OUString& rLName,
47 				 const Reference< xml::sax::XAttributeList > & xAttrList,
48 				 sal_uInt32 nFam,
49 				 ::std::vector< XMLPropertyState > &rProps,
50 				 const UniReference < SvXMLImportPropertyMapper > &rMap,
51 				 sal_Int32 nStartIndex, sal_Int32 nEndIndex,
52 				 const PageContextType aTempType ) :
53 	SvXMLPropertySetContext( rImport, nPrfx, rLName, xAttrList, nFam,
54 							 rProps, rMap, nStartIndex, nEndIndex )
55 {
56 	aType = aTempType;
57 }
58 
59 PagePropertySetContext::~PagePropertySetContext()
60 {
61 }
62 
63 SvXMLImportContext *PagePropertySetContext::CreateChildContext(
64 				   sal_uInt16 nPrefix,
65 				   const OUString& rLocalName,
66 				   const Reference< xml::sax::XAttributeList > & xAttrList,
67 				   ::std::vector< XMLPropertyState > &rProperties,
68 				   const XMLPropertyState& rProp )
69 {
70 	sal_Int32 nPos = CTF_PM_GRAPHICPOSITION;
71 	sal_Int32 nFil = CTF_PM_GRAPHICFILTER;
72 	switch ( aType )
73 	{
74 		case Header:
75 		{
76 			nPos = CTF_PM_HEADERGRAPHICPOSITION;
77 			nFil = CTF_PM_HEADERGRAPHICFILTER;
78 		}
79 		break;
80 		case Footer:
81 		{
82 			nPos = CTF_PM_FOOTERGRAPHICPOSITION;
83 			nFil = CTF_PM_FOOTERGRAPHICFILTER;
84 		}
85 		break;
86 		default:
87 			break;
88 	}
89 	SvXMLImportContext *pContext = 0;
90 
91 	switch( mxMapper->getPropertySetMapper()
92 					->GetEntryContextId( rProp.mnIndex ) )
93 	{
94 	case CTF_PM_GRAPHICURL:
95 	case CTF_PM_HEADERGRAPHICURL:
96 	case CTF_PM_FOOTERGRAPHICURL:
97 		DBG_ASSERT( rProp.mnIndex >= 2 &&
98 					nPos  == mxMapper->getPropertySetMapper()
99 						->GetEntryContextId( rProp.mnIndex-2 ) &&
100 					nFil  == mxMapper->getPropertySetMapper()
101 						->GetEntryContextId( rProp.mnIndex-1 ),
102 					"invalid property map!");
103 		pContext =
104 			new XMLBackgroundImageContext( GetImport(), nPrefix,
105 										   rLocalName, xAttrList,
106 										   rProp,
107 										   rProp.mnIndex-2,
108 										   rProp.mnIndex-1,
109                                            -1,
110 										   rProperties );
111 		break;
112 
113 	case CTF_PM_TEXTCOLUMNS:
114 #ifndef SVX_LIGHT
115 		pContext = new XMLTextColumnsContext( GetImport(), nPrefix,
116 											  rLocalName, xAttrList, rProp,
117 											  rProperties );
118 #else
119 		// create default context to skip content
120 		pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
121 #endif // #ifndef SVX_LIGHT
122 		break;
123 
124 	case CTF_PM_FTN_LINE_WEIGTH:
125 #ifndef SVX_LIGHT
126 		pContext = new XMLFootnoteSeparatorImport(
127 			GetImport(), nPrefix, rLocalName, rProperties,
128 			mxMapper->getPropertySetMapper(), rProp.mnIndex);
129 #else
130 		// create default context to skip content
131 		pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName);
132 #endif // #ifndef SVX_LIGHT
133 		break;
134 	}
135 
136 	if( !pContext )
137 		pContext = SvXMLPropertySetContext::CreateChildContext( nPrefix, rLocalName,
138 															xAttrList,
139 															rProperties, rProp );
140 
141 	return pContext;
142 }
143 
144 
145