xref: /AOO41X/main/xmloff/source/draw/ximpbody.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_xmloff.hxx"
30*cdf0e10cSrcweir #include "ximpbody.hxx"
31*cdf0e10cSrcweir #include <xmloff/prstylei.hxx>
32*cdf0e10cSrcweir #include "ximpnote.hxx"
33*cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawPage.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawPages.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/container/XNamed.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/presentation/XPresentationPage.hpp>
37*cdf0e10cSrcweir #include "ximpstyl.hxx"
38*cdf0e10cSrcweir #include <com/sun/star/drawing/XMasterPageTarget.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
40*cdf0e10cSrcweir #include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir #include "unointerfacetouniqueidentifiermapper.hxx"
43*cdf0e10cSrcweir #include <xmloff/xmluconv.hxx>
44*cdf0e10cSrcweir #include <xmloff/xmlprmap.hxx>
45*cdf0e10cSrcweir #include <xmloff/families.hxx>
46*cdf0e10cSrcweir #include "ximpshow.hxx"
47*cdf0e10cSrcweir #include "PropertySetMerger.hxx"
48*cdf0e10cSrcweir #include "animationimport.hxx"
49*cdf0e10cSrcweir #include <tools/string.hxx>
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir using ::rtl::OUString;
52*cdf0e10cSrcweir using ::rtl::OUStringBuffer;
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir using namespace ::com::sun::star;
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir SdXMLDrawPageContext::SdXMLDrawPageContext( SdXMLImport& rImport,
59*cdf0e10cSrcweir 	sal_uInt16 nPrfx, const OUString& rLocalName,
60*cdf0e10cSrcweir 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
61*cdf0e10cSrcweir 	uno::Reference< drawing::XShapes >& rShapes)
62*cdf0e10cSrcweir :	SdXMLGenericPageContext( rImport, nPrfx, rLocalName, xAttrList, rShapes )
63*cdf0e10cSrcweir ,	mbHadSMILNodes( false )
64*cdf0e10cSrcweir {
65*cdf0e10cSrcweir     bool bHaveXmlId( false );
66*cdf0e10cSrcweir     OUString sXmlId;
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir 	sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir 	for(sal_Int16 i=0; i < nAttrCount; i++)
71*cdf0e10cSrcweir 	{
72*cdf0e10cSrcweir 		OUString sAttrName = xAttrList->getNameByIndex( i );
73*cdf0e10cSrcweir 		OUString aLocalName;
74*cdf0e10cSrcweir 		sal_uInt16 nPrefix = GetSdImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
75*cdf0e10cSrcweir 		OUString sValue = xAttrList->getValueByIndex( i );
76*cdf0e10cSrcweir 		const SvXMLTokenMap& rAttrTokenMap = GetSdImport().GetDrawPageAttrTokenMap();
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir 		switch(rAttrTokenMap.Get(nPrefix, aLocalName))
79*cdf0e10cSrcweir 		{
80*cdf0e10cSrcweir 			case XML_TOK_DRAWPAGE_NAME:
81*cdf0e10cSrcweir 			{
82*cdf0e10cSrcweir 				maName = sValue;
83*cdf0e10cSrcweir 				break;
84*cdf0e10cSrcweir 			}
85*cdf0e10cSrcweir 			case XML_TOK_DRAWPAGE_STYLE_NAME:
86*cdf0e10cSrcweir 			{
87*cdf0e10cSrcweir 				maStyleName = sValue;
88*cdf0e10cSrcweir 				break;
89*cdf0e10cSrcweir 			}
90*cdf0e10cSrcweir 			case XML_TOK_DRAWPAGE_MASTER_PAGE_NAME:
91*cdf0e10cSrcweir 			{
92*cdf0e10cSrcweir 				maMasterPageName = sValue;
93*cdf0e10cSrcweir 				break;
94*cdf0e10cSrcweir 			}
95*cdf0e10cSrcweir 			case XML_TOK_DRAWPAGE_PAGE_LAYOUT_NAME:
96*cdf0e10cSrcweir 			{
97*cdf0e10cSrcweir 				maPageLayoutName =  sValue;
98*cdf0e10cSrcweir 				break;
99*cdf0e10cSrcweir 			}
100*cdf0e10cSrcweir 			case XML_TOK_DRAWPAGE_USE_HEADER_NAME:
101*cdf0e10cSrcweir 			{
102*cdf0e10cSrcweir 				maUseHeaderDeclName =  sValue;
103*cdf0e10cSrcweir 				break;
104*cdf0e10cSrcweir 			}
105*cdf0e10cSrcweir 			case XML_TOK_DRAWPAGE_USE_FOOTER_NAME:
106*cdf0e10cSrcweir 			{
107*cdf0e10cSrcweir 				maUseFooterDeclName =  sValue;
108*cdf0e10cSrcweir 				break;
109*cdf0e10cSrcweir 			}
110*cdf0e10cSrcweir 			case XML_TOK_DRAWPAGE_USE_DATE_TIME_NAME:
111*cdf0e10cSrcweir 			{
112*cdf0e10cSrcweir 				maUseDateTimeDeclName =  sValue;
113*cdf0e10cSrcweir 				break;
114*cdf0e10cSrcweir 			}
115*cdf0e10cSrcweir             case XML_TOK_DRAWPAGE_DRAWID:
116*cdf0e10cSrcweir             {
117*cdf0e10cSrcweir                 if (!bHaveXmlId) { sXmlId = sValue; }
118*cdf0e10cSrcweir             }
119*cdf0e10cSrcweir             break;
120*cdf0e10cSrcweir             case XML_TOK_DRAWPAGE_XMLID:
121*cdf0e10cSrcweir             {
122*cdf0e10cSrcweir                 sXmlId = sValue;
123*cdf0e10cSrcweir                 bHaveXmlId = true;
124*cdf0e10cSrcweir             }
125*cdf0e10cSrcweir             break;
126*cdf0e10cSrcweir 			case XML_TOK_DRAWPAGE_HREF:
127*cdf0e10cSrcweir 			{
128*cdf0e10cSrcweir 				maHREF = sValue;
129*cdf0e10cSrcweir 				break;
130*cdf0e10cSrcweir 			}
131*cdf0e10cSrcweir 		}
132*cdf0e10cSrcweir 	}
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir     if (sXmlId.getLength())
135*cdf0e10cSrcweir     {
136*cdf0e10cSrcweir         uno::Reference< uno::XInterface > const xRef( rShapes.get() );
137*cdf0e10cSrcweir         GetImport().getInterfaceToIdentifierMapper().registerReference(
138*cdf0e10cSrcweir             sXmlId, xRef );
139*cdf0e10cSrcweir     }
140*cdf0e10cSrcweir 	GetImport().GetShapeImport()->startPage( rShapes );
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir 	uno::Reference< drawing::XDrawPage > xShapeDrawPage(rShapes, uno::UNO_QUERY);
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir 	// set PageName?
145*cdf0e10cSrcweir 	if(maName.getLength())
146*cdf0e10cSrcweir 	{
147*cdf0e10cSrcweir 		if(xShapeDrawPage.is())
148*cdf0e10cSrcweir 		{
149*cdf0e10cSrcweir 			uno::Reference < container::XNamed > xNamed(xShapeDrawPage, uno::UNO_QUERY);
150*cdf0e10cSrcweir 			if(xNamed.is())
151*cdf0e10cSrcweir 				xNamed->setName(maName);
152*cdf0e10cSrcweir 		}
153*cdf0e10cSrcweir 	}
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir 	// set MasterPage?
156*cdf0e10cSrcweir 	if(maMasterPageName.getLength())
157*cdf0e10cSrcweir 	{
158*cdf0e10cSrcweir 		// #85906# Code for setting masterpage needs complete rework
159*cdf0e10cSrcweir 		// since GetSdImport().GetMasterStylesContext() gives always ZERO
160*cdf0e10cSrcweir 		// because of content/style file split. Now the nechanism is to
161*cdf0e10cSrcweir 		// compare the wanted masterpage-name with the existing masterpages
162*cdf0e10cSrcweir 		// which were loaded and created in the styles section loading.
163*cdf0e10cSrcweir 		uno::Reference< drawing::XDrawPages > xMasterPages(GetSdImport().GetLocalMasterPages(), uno::UNO_QUERY);
164*cdf0e10cSrcweir 		uno::Reference < drawing::XMasterPageTarget > xDrawPage(rShapes, uno::UNO_QUERY);
165*cdf0e10cSrcweir 		uno::Reference< drawing::XDrawPage > xMasterPage;
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir 		if(xDrawPage.is() && xMasterPages.is())
168*cdf0e10cSrcweir 		{
169*cdf0e10cSrcweir 			sal_Bool bDone(sal_False);
170*cdf0e10cSrcweir 			OUString sDisplayName( rImport.GetStyleDisplayName(
171*cdf0e10cSrcweir 							XML_STYLE_FAMILY_MASTER_PAGE, maMasterPageName ) );
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir 			for(sal_Int32 a = 0; !bDone && a < xMasterPages->getCount(); a++)
174*cdf0e10cSrcweir 			{
175*cdf0e10cSrcweir 				uno::Any aAny(xMasterPages->getByIndex(a));
176*cdf0e10cSrcweir 				aAny >>= xMasterPage;
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir 				if(xMasterPage.is())
179*cdf0e10cSrcweir 				{
180*cdf0e10cSrcweir 					uno::Reference < container::XNamed > xMasterNamed(xMasterPage, uno::UNO_QUERY);
181*cdf0e10cSrcweir 					if(xMasterNamed.is())
182*cdf0e10cSrcweir 					{
183*cdf0e10cSrcweir 						OUString sMasterPageName = xMasterNamed->getName();
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir 						if(sMasterPageName.getLength() &&
186*cdf0e10cSrcweir 							sMasterPageName.equals(sDisplayName))
187*cdf0e10cSrcweir 						{
188*cdf0e10cSrcweir 							xDrawPage->setMasterPage(xMasterPage);
189*cdf0e10cSrcweir 							bDone = sal_True;
190*cdf0e10cSrcweir 						}
191*cdf0e10cSrcweir 					}
192*cdf0e10cSrcweir 				}
193*cdf0e10cSrcweir 			}
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir 			DBG_ASSERT( bDone, "xmloff::SdXMLDrawPageContext::SdXMLDrawPageContext(), could not find a slide master!" );
196*cdf0e10cSrcweir 		}
197*cdf0e10cSrcweir 	}
198*cdf0e10cSrcweir 
199*cdf0e10cSrcweir 	SetStyle( maStyleName );
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir 	if( maHREF.getLength() )
202*cdf0e10cSrcweir 	{
203*cdf0e10cSrcweir 		uno::Reference< beans::XPropertySet > xProps( xShapeDrawPage, uno::UNO_QUERY );
204*cdf0e10cSrcweir 		if( xProps.is() )
205*cdf0e10cSrcweir 		{
206*cdf0e10cSrcweir 			sal_Int32 nIndex = maHREF.lastIndexOf( (sal_Unicode)'#' );
207*cdf0e10cSrcweir 			if( nIndex != -1 )
208*cdf0e10cSrcweir 			{
209*cdf0e10cSrcweir 				OUString aFileName( maHREF.copy( 0, nIndex ) );
210*cdf0e10cSrcweir 				OUString aBookmarkName( maHREF.copy( nIndex+1 ) );
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir 				maHREF = GetImport().GetAbsoluteReference( aFileName );
213*cdf0e10cSrcweir 				maHREF += String( (sal_Unicode)'#' );
214*cdf0e10cSrcweir 				maHREF += aBookmarkName;
215*cdf0e10cSrcweir 			}
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir 			xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "BookmarkURL" ) ), uno::makeAny( maHREF ) );
218*cdf0e10cSrcweir 		}
219*cdf0e10cSrcweir 	}
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir 	SetLayout();
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir 	DeleteAllShapes();
224*cdf0e10cSrcweir }
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir SdXMLDrawPageContext::~SdXMLDrawPageContext()
229*cdf0e10cSrcweir {
230*cdf0e10cSrcweir }
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
233*cdf0e10cSrcweir 
234*cdf0e10cSrcweir SvXMLImportContext *SdXMLDrawPageContext::CreateChildContext( sal_uInt16 nPrefix,
235*cdf0e10cSrcweir 	const OUString& rLocalName,
236*cdf0e10cSrcweir 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList )
237*cdf0e10cSrcweir {
238*cdf0e10cSrcweir 	SvXMLImportContext *pContext = 0L;
239*cdf0e10cSrcweir 	const SvXMLTokenMap& rTokenMap = GetSdImport().GetDrawPageElemTokenMap();
240*cdf0e10cSrcweir 
241*cdf0e10cSrcweir 	// some special objects inside draw:page context
242*cdf0e10cSrcweir 	switch(rTokenMap.Get(nPrefix, rLocalName))
243*cdf0e10cSrcweir 	{
244*cdf0e10cSrcweir 		case XML_TOK_DRAWPAGE_NOTES:
245*cdf0e10cSrcweir 		{
246*cdf0e10cSrcweir 			if( GetSdImport().IsImpress() )
247*cdf0e10cSrcweir 			{
248*cdf0e10cSrcweir 				// get notes page
249*cdf0e10cSrcweir 				uno::Reference< presentation::XPresentationPage > xPresPage(GetLocalShapesContext(), uno::UNO_QUERY);
250*cdf0e10cSrcweir 				if(xPresPage.is())
251*cdf0e10cSrcweir 				{
252*cdf0e10cSrcweir 					uno::Reference< drawing::XDrawPage > xNotesDrawPage(xPresPage->getNotesPage(), uno::UNO_QUERY);
253*cdf0e10cSrcweir 					if(xNotesDrawPage.is())
254*cdf0e10cSrcweir 					{
255*cdf0e10cSrcweir 						uno::Reference< drawing::XShapes > xNewShapes(xNotesDrawPage, uno::UNO_QUERY);
256*cdf0e10cSrcweir 						if(xNewShapes.is())
257*cdf0e10cSrcweir 						{
258*cdf0e10cSrcweir 							// presentation:notes inside draw:page context
259*cdf0e10cSrcweir 							pContext = new SdXMLNotesContext( GetSdImport(), nPrefix, rLocalName, xAttrList, xNewShapes);
260*cdf0e10cSrcweir 						}
261*cdf0e10cSrcweir 					}
262*cdf0e10cSrcweir 				}
263*cdf0e10cSrcweir 			}
264*cdf0e10cSrcweir 			break;
265*cdf0e10cSrcweir 		}
266*cdf0e10cSrcweir 		case XML_TOK_DRAWPAGE_PAR:
267*cdf0e10cSrcweir 		case XML_TOK_DRAWPAGE_SEQ:
268*cdf0e10cSrcweir 		{
269*cdf0e10cSrcweir 			if( GetSdImport().IsImpress() )
270*cdf0e10cSrcweir 			{
271*cdf0e10cSrcweir 				uno::Reference< animations::XAnimationNodeSupplier > xNodeSupplier(GetLocalShapesContext(), uno::UNO_QUERY);
272*cdf0e10cSrcweir 				if(xNodeSupplier.is())
273*cdf0e10cSrcweir 				{
274*cdf0e10cSrcweir 					pContext = new xmloff::AnimationNodeContext( xNodeSupplier->getAnimationNode(), GetSdImport(), nPrefix, rLocalName, xAttrList );
275*cdf0e10cSrcweir 					mbHadSMILNodes = true;
276*cdf0e10cSrcweir 				}
277*cdf0e10cSrcweir 			}
278*cdf0e10cSrcweir 			break;
279*cdf0e10cSrcweir 		}
280*cdf0e10cSrcweir 	}
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir 	// call parent when no own context was created
283*cdf0e10cSrcweir 	if(!pContext)
284*cdf0e10cSrcweir 		pContext = SdXMLGenericPageContext::CreateChildContext(nPrefix, rLocalName, xAttrList);
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir 	return pContext;
287*cdf0e10cSrcweir }
288*cdf0e10cSrcweir 
289*cdf0e10cSrcweir void SdXMLDrawPageContext::EndElement()
290*cdf0e10cSrcweir {
291*cdf0e10cSrcweir 	SdXMLGenericPageContext::EndElement();
292*cdf0e10cSrcweir 	GetImport().GetShapeImport()->endPage(GetLocalShapesContext());
293*cdf0e10cSrcweir 
294*cdf0e10cSrcweir 	if( mbHadSMILNodes )
295*cdf0e10cSrcweir 	{
296*cdf0e10cSrcweir 		uno::Reference< animations::XAnimationNodeSupplier > xNodeSupplier(GetLocalShapesContext(), uno::UNO_QUERY);
297*cdf0e10cSrcweir 		uno::Reference< beans::XPropertySet > xPageProps( GetLocalShapesContext(), uno::UNO_QUERY );
298*cdf0e10cSrcweir 		if(xNodeSupplier.is())
299*cdf0e10cSrcweir 			xmloff::AnimationNodeContext::postProcessRootNode( GetSdImport(), xNodeSupplier->getAnimationNode(), xPageProps );
300*cdf0e10cSrcweir 	}
301*cdf0e10cSrcweir }
302*cdf0e10cSrcweir 
303*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
304*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir SdXMLBodyContext::SdXMLBodyContext( SdXMLImport& rImport,
307*cdf0e10cSrcweir 	sal_uInt16 nPrfx, const OUString& rLocalName )
308*cdf0e10cSrcweir :	SvXMLImportContext( rImport, nPrfx, rLocalName )
309*cdf0e10cSrcweir {
310*cdf0e10cSrcweir }
311*cdf0e10cSrcweir 
312*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
313*cdf0e10cSrcweir 
314*cdf0e10cSrcweir SdXMLBodyContext::~SdXMLBodyContext()
315*cdf0e10cSrcweir {
316*cdf0e10cSrcweir }
317*cdf0e10cSrcweir 
318*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir SvXMLImportContext *SdXMLBodyContext::CreateChildContext(
321*cdf0e10cSrcweir 	sal_uInt16 nPrefix,
322*cdf0e10cSrcweir 	const OUString& rLocalName,
323*cdf0e10cSrcweir 	const uno::Reference< xml::sax::XAttributeList>& xAttrList )
324*cdf0e10cSrcweir {
325*cdf0e10cSrcweir 	SvXMLImportContext *pContext = 0L;
326*cdf0e10cSrcweir 	const SvXMLTokenMap& rTokenMap = GetSdImport().GetBodyElemTokenMap();
327*cdf0e10cSrcweir 
328*cdf0e10cSrcweir 	switch(rTokenMap.Get(nPrefix, rLocalName))
329*cdf0e10cSrcweir 	{
330*cdf0e10cSrcweir 		case XML_TOK_BODY_HEADER_DECL:
331*cdf0e10cSrcweir 		case XML_TOK_BODY_FOOTER_DECL:
332*cdf0e10cSrcweir 		case XML_TOK_BODY_DATE_TIME_DECL:
333*cdf0e10cSrcweir 		{
334*cdf0e10cSrcweir 			pContext = new SdXMLHeaderFooterDeclContext( GetImport(), nPrefix, rLocalName, xAttrList );
335*cdf0e10cSrcweir 			break;
336*cdf0e10cSrcweir 		}
337*cdf0e10cSrcweir 		case XML_TOK_BODY_PAGE:
338*cdf0e10cSrcweir 		{
339*cdf0e10cSrcweir 			// only read the first page in preview mode
340*cdf0e10cSrcweir 			if( (GetSdImport().GetNewPageCount() == 0) || !GetSdImport().IsPreview() )
341*cdf0e10cSrcweir 			{
342*cdf0e10cSrcweir 				// import this page
343*cdf0e10cSrcweir 				uno::Reference< drawing::XDrawPage > xNewDrawPage;
344*cdf0e10cSrcweir 				uno::Reference< drawing::XDrawPages > xDrawPages(GetSdImport().GetLocalDrawPages(), uno::UNO_QUERY);
345*cdf0e10cSrcweir 
346*cdf0e10cSrcweir 				if( !xDrawPages.is() )
347*cdf0e10cSrcweir 					break;
348*cdf0e10cSrcweir 
349*cdf0e10cSrcweir 				if(GetSdImport().GetNewPageCount() + 1 > xDrawPages->getCount())
350*cdf0e10cSrcweir 				{
351*cdf0e10cSrcweir 					// new page, create and insert
352*cdf0e10cSrcweir 					xNewDrawPage = xDrawPages->insertNewByIndex(xDrawPages->getCount());
353*cdf0e10cSrcweir 				}
354*cdf0e10cSrcweir 				else
355*cdf0e10cSrcweir 				{
356*cdf0e10cSrcweir 					// existing page, use it
357*cdf0e10cSrcweir 					uno::Any aAny(xDrawPages->getByIndex(GetSdImport().GetNewPageCount()));
358*cdf0e10cSrcweir 					aAny >>= xNewDrawPage;
359*cdf0e10cSrcweir 				}
360*cdf0e10cSrcweir 
361*cdf0e10cSrcweir 				// increment global import page counter
362*cdf0e10cSrcweir 				GetSdImport().IncrementNewPageCount();
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir 				if(xNewDrawPage.is())
365*cdf0e10cSrcweir 				{
366*cdf0e10cSrcweir 					uno::Reference< drawing::XShapes > xNewShapes(xNewDrawPage, uno::UNO_QUERY);
367*cdf0e10cSrcweir 					if(xNewShapes.is())
368*cdf0e10cSrcweir 					{
369*cdf0e10cSrcweir 						// draw:page inside office:body context
370*cdf0e10cSrcweir 						pContext = new SdXMLDrawPageContext(GetSdImport(), nPrefix, rLocalName, xAttrList,
371*cdf0e10cSrcweir 							xNewShapes);
372*cdf0e10cSrcweir 					}
373*cdf0e10cSrcweir 				}
374*cdf0e10cSrcweir 			}
375*cdf0e10cSrcweir 			break;
376*cdf0e10cSrcweir 		}
377*cdf0e10cSrcweir 		case XML_TOK_BODY_SETTINGS:
378*cdf0e10cSrcweir 		{
379*cdf0e10cSrcweir 			pContext = new SdXMLShowsContext( GetSdImport(), nPrefix, rLocalName, xAttrList );
380*cdf0e10cSrcweir 		}
381*cdf0e10cSrcweir 	}
382*cdf0e10cSrcweir 
383*cdf0e10cSrcweir 	// call parent when no own context was created
384*cdf0e10cSrcweir 	if(!pContext)
385*cdf0e10cSrcweir 		pContext = SvXMLImportContext::CreateChildContext(nPrefix, rLocalName, xAttrList);
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir 	return pContext;
388*cdf0e10cSrcweir }
389