android: Update app icon to new startcenter icon
[LibreOffice.git] / dbaccess / source / filter / xml / xmlHierarchyCollection.cxx
blob74a5b5e3f15027bf5a92d79f04e4f80fb08700c1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "xmlHierarchyCollection.hxx"
21 #include "xmlComponent.hxx"
22 #include "xmlColumn.hxx"
23 #include "xmlfilter.hxx"
24 #include <utility>
25 #include <xmloff/xmltoken.hxx>
26 #include <xmloff/ProgressBarHelper.hxx>
27 #include "xmlEnums.hxx"
28 #include <com/sun/star/container/XNameContainer.hpp>
29 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
30 #include <comphelper/propertysequence.hxx>
31 #include <comphelper/diagnose_ex.hxx>
33 namespace dbaxml
35 using namespace ::com::sun::star::uno;
36 using namespace ::com::sun::star::beans;
37 using namespace ::com::sun::star::container;
38 using namespace ::com::sun::star::xml::sax;
40 OXMLHierarchyCollection::OXMLHierarchyCollection( ODBFilter& rImport
41 ,const Reference< XFastAttributeList > & _xAttrList
42 ,const Reference< XNameAccess >& _xParentContainer
43 ,const OUString& _sCollectionServiceName
44 ,OUString _sComponentServiceName) :
45 SvXMLImportContext( rImport )
46 ,m_sCollectionServiceName(_sCollectionServiceName)
47 ,m_sComponentServiceName(std::move(_sComponentServiceName))
49 OUString sName;
50 for (auto &aIter : sax_fastparser::castToFastAttributeList( _xAttrList ))
52 switch( aIter.getToken() & TOKEN_MASK )
54 case XML_NAME:
55 sName = aIter.toString();
56 break;
57 default:
58 XMLOFF_WARN_UNKNOWN("dbaccess", aIter);
61 if ( sName.isEmpty() || !_xParentContainer.is() )
62 return;
64 try
66 Reference<XMultiServiceFactory> xORB(_xParentContainer,UNO_QUERY);
67 if ( xORB.is() )
69 Sequence<Any> aArguments(comphelper::InitAnyPropertySequence(
71 {"Name", Any(sName)}, // set as folder
72 {"Parent", Any(_xParentContainer)},
73 }));
74 m_xContainer.set(xORB->createInstanceWithArguments(_sCollectionServiceName,aArguments),UNO_QUERY);
75 Reference<XNameContainer> xNameContainer(_xParentContainer,UNO_QUERY);
76 if ( xNameContainer.is() && !xNameContainer->hasByName(sName) )
77 xNameContainer->insertByName(sName,Any(m_xContainer));
80 catch(Exception&)
82 TOOLS_WARN_EXCEPTION( "dbaccess", "OXMLHierarchyCollection::OXMLHierarchyCollection");
86 OXMLHierarchyCollection::OXMLHierarchyCollection( ODBFilter& rImport
87 ,const Reference< XNameAccess >& _xContainer
88 ,const Reference< XPropertySet >& _xTable
89 ) :
90 SvXMLImportContext( rImport )
91 ,m_xContainer(_xContainer)
92 ,m_xTable(_xTable)
96 OXMLHierarchyCollection::~OXMLHierarchyCollection()
101 css::uno::Reference< css::xml::sax::XFastContextHandler > OXMLHierarchyCollection::createFastChildContext(
102 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
104 SvXMLImportContext *pContext = nullptr;
106 switch( nElement & TOKEN_MASK )
108 case XML_COMPONENT:
109 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
110 pContext = new OXMLComponent( GetOwnImport(), xAttrList,m_xContainer,m_sComponentServiceName );
111 break;
112 case XML_COLUMN:
113 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
114 pContext = new OXMLColumn( GetOwnImport(), xAttrList,m_xContainer,m_xTable);
115 break;
116 case XML_COMPONENT_COLLECTION:
117 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
118 pContext = new OXMLHierarchyCollection( GetOwnImport(), xAttrList,m_xContainer,m_sCollectionServiceName,m_sComponentServiceName);
119 break;
122 return pContext;
125 ODBFilter& OXMLHierarchyCollection::GetOwnImport()
127 return static_cast<ODBFilter&>(GetImport());
130 } // namespace dbaxml
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */