xref: /aoo41x/main/xmloff/source/draw/ximpgrp.cxx (revision 63bba73c)
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"xmloff/xmlnmspe.hxx"
27 #include "ximpgrp.hxx"
28 #include <xmloff/xmltoken.hxx>
29 #include "ximpshap.hxx"
30 #include "eventimp.hxx"
31 #include "descriptionimp.hxx"
32 
33 using ::rtl::OUString;
34 using ::rtl::OUStringBuffer;
35 
36 using namespace ::com::sun::star;
37 using namespace ::xmloff::token;
38 
39 //////////////////////////////////////////////////////////////////////////////
40 
41 TYPEINIT1( SdXMLGroupShapeContext, SvXMLImportContext );
42 
SdXMLGroupShapeContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLocalName,const uno::Reference<xml::sax::XAttributeList> & xAttrList,uno::Reference<drawing::XShapes> & rShapes,sal_Bool bTemporaryShape)43 SdXMLGroupShapeContext::SdXMLGroupShapeContext(
44 	SvXMLImport& rImport,
45 	sal_uInt16 nPrfx, const OUString& rLocalName,
46 	const uno::Reference< xml::sax::XAttributeList>& xAttrList,
47 	uno::Reference< drawing::XShapes >& rShapes,
48     sal_Bool bTemporaryShape)
49 :	SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape )
50 {
51 }
52 
53 //////////////////////////////////////////////////////////////////////////////
54 
~SdXMLGroupShapeContext()55 SdXMLGroupShapeContext::~SdXMLGroupShapeContext()
56 {
57 }
58 
59 //////////////////////////////////////////////////////////////////////////////
60 
CreateChildContext(sal_uInt16 nPrefix,const OUString & rLocalName,const uno::Reference<xml::sax::XAttributeList> & xAttrList)61 SvXMLImportContext* SdXMLGroupShapeContext::CreateChildContext( sal_uInt16 nPrefix,
62 	const OUString& rLocalName,
63 	const uno::Reference< xml::sax::XAttributeList>& xAttrList )
64 {
65 	SvXMLImportContext* pContext = 0L;
66 
67 	// #i68101#
68 	if( nPrefix == XML_NAMESPACE_SVG &&
69 		(IsXMLToken( rLocalName, XML_TITLE ) || IsXMLToken( rLocalName, XML_DESC ) ) )
70 	{
71 		pContext = new SdXMLDescriptionContext( GetImport(), nPrefix, rLocalName, xAttrList, mxShape );
72 	}
73 	else if( nPrefix == XML_NAMESPACE_OFFICE && IsXMLToken( rLocalName, XML_EVENT_LISTENERS ) )
74 	{
75 		pContext = new SdXMLEventsContext( GetImport(), nPrefix, rLocalName, xAttrList, mxShape );
76 	}
77 	else if( nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( rLocalName, XML_GLUE_POINT ) )
78 	{
79 		addGluePoint( xAttrList );
80 	}
81 	else
82 	{
83 		// call GroupChildContext function at common ShapeImport
84 		pContext = GetImport().GetShapeImport()->CreateGroupChildContext(
85 			GetImport(), nPrefix, rLocalName, xAttrList, mxChilds);
86 	}
87 
88 	// call parent when no own context was created
89 	if(!pContext)
90 		pContext = SvXMLImportContext::CreateChildContext(
91 		nPrefix, rLocalName, xAttrList);
92 
93 	return pContext;
94 }
95 
96 //////////////////////////////////////////////////////////////////////////////
97 
StartElement(const uno::Reference<xml::sax::XAttributeList> &)98 void SdXMLGroupShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>&)
99 {
100 	// create new group shape and add it to rShapes, use it
101 	// as base for the new group import
102 	AddShape( "com.sun.star.drawing.GroupShape" );
103 
104 	if(mxShape.is())
105 	{
106 		SetStyle( false );
107 
108 		mxChilds = uno::Reference< drawing::XShapes >::query( mxShape );
109 		if( mxChilds.is() )
110 			GetImport().GetShapeImport()->pushGroupForSorting( mxChilds );
111 	}
112 
113 	GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
114 }
115 
116 //////////////////////////////////////////////////////////////////////////////
117 
EndElement()118 void SdXMLGroupShapeContext::EndElement()
119 {
120 	if( mxChilds.is() )
121 		GetImport().GetShapeImport()->popGroupAndSort();
122 
123 	SdXMLShapeContext::EndElement();
124 }
125 
126 
127