1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_xmloff.hxx"
26 #include <tools/debug.hxx>
27 #include "PagePropertySetContext.hxx"
28 #include "XMLBackgroundImageContext.hxx"
29 #include "XMLTextColumnsContext.hxx"
30 #ifndef _XMLOFF_PAGEMASTERSTYLEMAP_HXX
31 #include <xmloff/PageMasterStyleMap.hxx>
32 #endif
33 #include "XMLFootnoteSeparatorImport.hxx"
34 
35 using ::rtl::OUString;
36 
37 using namespace ::com::sun::star::uno;
38 using namespace ::com::sun::star;
39 
PagePropertySetContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLName,const Reference<xml::sax::XAttributeList> & xAttrList,sal_uInt32 nFam,::std::vector<XMLPropertyState> & rProps,const UniReference<SvXMLImportPropertyMapper> & rMap,sal_Int32 nStartIndex,sal_Int32 nEndIndex,const PageContextType aTempType)40 PagePropertySetContext::PagePropertySetContext(
41 				 SvXMLImport& rImport, sal_uInt16 nPrfx,
42 				 const OUString& rLName,
43 				 const Reference< xml::sax::XAttributeList > & xAttrList,
44 				 sal_uInt32 nFam,
45 				 ::std::vector< XMLPropertyState > &rProps,
46 				 const UniReference < SvXMLImportPropertyMapper > &rMap,
47 				 sal_Int32 nStartIndex, sal_Int32 nEndIndex,
48 				 const PageContextType aTempType ) :
49 	SvXMLPropertySetContext( rImport, nPrfx, rLName, xAttrList, nFam,
50 							 rProps, rMap, nStartIndex, nEndIndex )
51 {
52 	aType = aTempType;
53 }
54 
~PagePropertySetContext()55 PagePropertySetContext::~PagePropertySetContext()
56 {
57 }
58 
CreateChildContext(sal_uInt16 nPrefix,const OUString & rLocalName,const Reference<xml::sax::XAttributeList> & xAttrList,::std::vector<XMLPropertyState> & rProperties,const XMLPropertyState & rProp)59 SvXMLImportContext *PagePropertySetContext::CreateChildContext(
60 				   sal_uInt16 nPrefix,
61 				   const OUString& rLocalName,
62 				   const Reference< xml::sax::XAttributeList > & xAttrList,
63 				   ::std::vector< XMLPropertyState > &rProperties,
64 				   const XMLPropertyState& rProp )
65 {
66 	sal_Int32 nPos = CTF_PM_GRAPHICPOSITION;
67 	sal_Int32 nFil = CTF_PM_GRAPHICFILTER;
68 	switch ( aType )
69 	{
70 		case Header:
71 		{
72 			nPos = CTF_PM_HEADERGRAPHICPOSITION;
73 			nFil = CTF_PM_HEADERGRAPHICFILTER;
74 		}
75 		break;
76 		case Footer:
77 		{
78 			nPos = CTF_PM_FOOTERGRAPHICPOSITION;
79 			nFil = CTF_PM_FOOTERGRAPHICFILTER;
80 		}
81 		break;
82 		default:
83 			break;
84 	}
85 	SvXMLImportContext *pContext = 0;
86 
87 	switch( mxMapper->getPropertySetMapper()
88 					->GetEntryContextId( rProp.mnIndex ) )
89 	{
90 	case CTF_PM_GRAPHICURL:
91 	case CTF_PM_HEADERGRAPHICURL:
92 	case CTF_PM_FOOTERGRAPHICURL:
93 		DBG_ASSERT( rProp.mnIndex >= 2 &&
94 					nPos  == mxMapper->getPropertySetMapper()
95 						->GetEntryContextId( rProp.mnIndex-2 ) &&
96 					nFil  == mxMapper->getPropertySetMapper()
97 						->GetEntryContextId( rProp.mnIndex-1 ),
98 					"invalid property map!");
99 		pContext =
100 			new XMLBackgroundImageContext( GetImport(), nPrefix,
101 										   rLocalName, xAttrList,
102 										   rProp,
103 										   rProp.mnIndex-2,
104 										   rProp.mnIndex-1,
105                                            -1,
106 										   rProperties );
107 		break;
108 
109 	case CTF_PM_TEXTCOLUMNS:
110 #ifndef SVX_LIGHT
111 		pContext = new XMLTextColumnsContext( GetImport(), nPrefix,
112 											  rLocalName, xAttrList, rProp,
113 											  rProperties );
114 #else
115 		// create default context to skip content
116 		pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
117 #endif // #ifndef SVX_LIGHT
118 		break;
119 
120 	case CTF_PM_FTN_LINE_WEIGTH:
121 #ifndef SVX_LIGHT
122 		pContext = new XMLFootnoteSeparatorImport(
123 			GetImport(), nPrefix, rLocalName, rProperties,
124 			mxMapper->getPropertySetMapper(), rProp.mnIndex);
125 #else
126 		// create default context to skip content
127 		pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName);
128 #endif // #ifndef SVX_LIGHT
129 		break;
130 	}
131 
132 	if( !pContext )
133 		pContext = SvXMLPropertySetContext::CreateChildContext( nPrefix, rLocalName,
134 															xAttrList,
135 															rProperties, rProp );
136 
137 	return pContext;
138 }
139 
140 
141