LibreOffice Module xmloff (master)  1
ximpgrp.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include<xmloff/xmlnmspe.hxx>
21 #include "ximpgrp.hxx"
22 #include <xmloff/xmltoken.hxx>
23 #include "ximpshap.hxx"
24 #include "eventimp.hxx"
25 #include "descriptionimp.hxx"
26 
27 using namespace ::com::sun::star;
28 using namespace ::xmloff::token;
29 
30 
32  SvXMLImport& rImport,
33  sal_uInt16 nPrfx, const OUString& rLocalName,
34  const uno::Reference< xml::sax::XAttributeList>& xAttrList,
35  uno::Reference< drawing::XShapes > const & rShapes,
36  bool bTemporaryShape)
37 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape )
38 {
39 }
40 
42 {
43 }
44 
46  const OUString& rLocalName,
47  const uno::Reference< xml::sax::XAttributeList>& xAttrList )
48 {
49  SvXMLImportContextRef xContext;
50 
51  // #i68101#
52  if( nPrefix == XML_NAMESPACE_SVG &&
53  (IsXMLToken( rLocalName, XML_TITLE ) || IsXMLToken( rLocalName, XML_DESC ) ) )
54  {
55  xContext = new SdXMLDescriptionContext( GetImport(), nPrefix, rLocalName, xAttrList, mxShape );
56  }
57  else if( nPrefix == XML_NAMESPACE_OFFICE && IsXMLToken( rLocalName, XML_EVENT_LISTENERS ) )
58  {
59  xContext = new SdXMLEventsContext( GetImport(), nPrefix, rLocalName, xAttrList, mxShape );
60  }
61  else if( nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( rLocalName, XML_GLUE_POINT ) )
62  {
63  addGluePoint( xAttrList );
64  }
65  else
66  {
67  // call GroupChildContext function at common ShapeImport
68  xContext = GetImport().GetShapeImport()->CreateGroupChildContext(
69  GetImport(), nPrefix, rLocalName, xAttrList, mxChildren);
70  }
71 
72  return xContext;
73 }
74 
75 void SdXMLGroupShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>&)
76 {
77  // create new group shape and add it to rShapes, use it
78  // as base for the new group import
79  AddShape( "com.sun.star.drawing.GroupShape" );
80 
81  if(mxShape.is())
82  {
83  SetStyle( false );
84 
85  mxChildren.set( mxShape, uno::UNO_QUERY );
86  if( mxChildren.is() )
87  GetImport().GetShapeImport()->pushGroupForPostProcessing( mxChildren );
88  }
89 
90  GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
91 }
92 
94 {
95  if( mxChildren.is() )
96  GetImport().GetShapeImport()->popGroupAndPostProcess();
97 
99 }
100 
101 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool IsXMLToken(const OUString &rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3422
virtual void EndElement() override
EndElement is called before a context will be destructed, but after an elements context has been pars...
Definition: ximpshap.cxx:346
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:62
void AddShape(css::uno::Reference< css::drawing::XShape > &xShape)
void addGluePoint(const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList)
Definition: ximpshap.cxx:258
css::uno::Reference< css::drawing::XShapes > mxChildren
Definition: ximpgrp.hxx:32
constexpr sal_uInt16 XML_NAMESPACE_DRAW
Definition: xmlnmspe.hxx:33
css::uno::Reference< css::xml::sax::XAttributeList > mxAttrList
Definition: ximpshap.hxx:51
virtual void StartElement(const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
StartElement is called after a context has been constructed and before an elements context is parsed...
Definition: ximpgrp.cxx:75
SdXMLGroupShapeContext(SvXMLImport &rImport, sal_uInt16 nPrfx, const OUString &rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes, bool bTemporaryShape)
Definition: ximpgrp.cxx:31
css::uno::Reference< css::drawing::XShape > mxShape
virtual ~SdXMLGroupShapeContext() override
Definition: ximpgrp.cxx:41
css::uno::Reference< css::drawing::XShapes > mxShapes
Definition: ximpshap.hxx:48
virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 nPrefix, const OUString &rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
Create a children element context.
Definition: ximpgrp.cxx:45
Handling of tokens in XML:
void SetStyle(bool bSupportsStyle=true)
if bSupportsStyle is false, auto styles will be set but not a style
Definition: ximpshap.cxx:611
virtual void EndElement() override
EndElement is called before a context will be destructed, but after an elements context has been pars...
Definition: ximpgrp.cxx:93
constexpr sal_uInt16 XML_NAMESPACE_SVG
Definition: xmlnmspe.hxx:40
rtl::Reference< XMLShapeImportHelper > const & GetShapeImport()
Definition: xmlimp.hxx:602
constexpr sal_uInt16 XML_NAMESPACE_OFFICE
Definition: xmlnmspe.hxx:29