merge the formfield patch from ooo-build
[ooovba.git] / configmgr / source / backend / basicimporthandler.cxx
blob2cbf3cc41b33ab8af6ac592fbd9df394473c35c9
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: basicimporthandler.cxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_configmgr.hxx"
34 #include "basicimporthandler.hxx"
35 #include <com/sun/star/configuration/backend/ComponentChangeEvent.hpp>
36 #include <com/sun/star/configuration/backend/XBackendChangesNotifier.hpp>
37 // -----------------------------------------------------------------------------
39 namespace configmgr
41 // -----------------------------------------------------------------------------
42 namespace backend
44 // -----------------------------------------------------------------------------
46 BasicImportHandler::BasicImportHandler(
47 uno::Reference< backenduno::XBackend > const & xBackend,rtl::OUString const & aEntity, const sal_Bool& bNotify)
48 : m_bSendNotification(bNotify)
49 , m_xBackend(xBackend)
50 , m_aComponentName()
51 , m_aEntity(aEntity)
53 OSL_ENSURE( m_xBackend.is(), "Creating an import handler without a target backend" );
55 // -----------------------------------------------------------------------------
57 BasicImportHandler::~BasicImportHandler()
60 // -----------------------------------------------------------------------------
62 void SAL_CALL
63 BasicImportHandler::startLayer( )
64 throw (backenduno::MalformedDataException, lang::WrappedTargetException, uno::RuntimeException)
66 m_aComponentName = rtl::OUString();
68 // -----------------------------------------------------------------------------
70 void SAL_CALL
71 BasicImportHandler::endLayer( )
72 throw (backenduno::MalformedDataException, lang::WrappedTargetException, uno::RuntimeException)
74 if ( m_bSendNotification)
76 backenduno::ComponentChangeEvent aEvent;
77 aEvent.Source=*this;
78 aEvent.Component = m_aComponentName;
80 uno::Reference<backenduno::XBackendChangesListener> xListener(m_xBackend, uno::UNO_QUERY);
81 if( xListener.is())
83 xListener->componentDataChanged(aEvent);
85 else
87 OSL_ENSURE(false, "ImportMergeHandler: target backend does not support notifications");
90 m_aComponentName = rtl::OUString();
92 // -----------------------------------------------------------------------------
94 bool BasicImportHandler::startComponent( const rtl::OUString& aName )
96 if (hasComponent()) return false;
98 m_aComponentName = aName;
99 return true;
101 // -----------------------------------------------------------------------------
103 void BasicImportHandler::raiseMalformedDataException(sal_Char const * pMsg)
105 rtl::OUString sMsg = rtl::OUString::createFromAscii(pMsg);
107 throw backenduno::MalformedDataException(sMsg, *this, uno::Any());
109 // -----------------------------------------------------------------------------
111 // -----------------------------------------------------------------------------
112 // -----------------------------------------------------------------------------
113 } // namespace
115 // -----------------------------------------------------------------------------
116 } // namespace