1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: emptylayer.cxx,v $
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 "emptylayerimpl.hxx"
35 #include "emptylayer.hxx"
37 // -----------------------------------------------------------------------------
41 // -----------------------------------------------------------------------------
44 // -----------------------------------------------------------------------------
45 namespace uno
= ::com::sun::star::uno
;
46 // -----------------------------------------------------------------------------
47 // -----------------------------------------------------------------------------
49 uno::Reference
< backenduno::XLayer
> createEmptyLayer()
51 return new EmptyLayer();
53 // -----------------------------------------------------------------------------
55 bool checkEmptyLayer(uno::Reference
< backenduno::XLayer
> const & xLayer
)
57 OSL_ENSURE(xLayer
.is(),"Unexpected NULL Layer");
58 if (!xLayer
.is()) return false;
60 RequireEmptyLayer
* const pChecker
= new RequireEmptyLayer
;
61 uno::Reference
< backenduno::XLayerHandler
> xChecker(pChecker
);
65 xLayer
->readData(xChecker
);
67 catch (uno::Exception
&)
69 OSL_ENSURE(!pChecker
->wasEmpty(), "Checking for empty layer: exception occurred after empty layer was ended");
72 return pChecker
->wasEmpty();
75 // -----------------------------------------------------------------------------
76 // -----------------------------------------------------------------------------
78 EmptyLayer::~EmptyLayer( )
81 // -----------------------------------------------------------------------------
84 EmptyLayer::readData( const uno::Reference
< backenduno::XLayerHandler
>& aHandler
)
85 throw (backenduno::MalformedDataException
, lang::NullPointerException
, lang::WrappedTargetException
, uno::RuntimeException
)
89 aHandler
->startLayer();
93 throw lang::NullPointerException(rtl::OUString::createFromAscii("EmptyLayer: Null Handler"),*this);
95 // -----------------------------------------------------------------------------
96 // -----------------------------------------------------------------------------
98 RequireEmptyLayer::RequireEmptyLayer()
104 // -----------------------------------------------------------------------------
106 RequireEmptyLayer::~RequireEmptyLayer( )
109 // -----------------------------------------------------------------------------
111 void SAL_CALL
RequireEmptyLayer::startLayer( )
112 throw (backenduno::MalformedDataException
, uno::RuntimeException
)
117 if (m_bStarted
) fail("Layer started twice");
120 // -----------------------------------------------------------------------------
122 void SAL_CALL
RequireEmptyLayer::endLayer( )
123 throw (backenduno::MalformedDataException
, uno::RuntimeException
)
125 if (!m_bStarted
) fail("Layer was not started");
126 m_bEmpty
= !m_bInvalid
;
129 // -----------------------------------------------------------------------------
131 void SAL_CALL
RequireEmptyLayer::overrideNode( const rtl::OUString
& /*aName*/, sal_Int16
/*aAttributes*/, sal_Bool
/*bClear*/ )
132 throw (backenduno::MalformedDataException
, uno::RuntimeException
)
136 // -----------------------------------------------------------------------------
138 void SAL_CALL
RequireEmptyLayer::addOrReplaceNode( const rtl::OUString
& /*aName*/, sal_Int16
/*aAttributes*/ )
139 throw (backenduno::MalformedDataException
, uno::RuntimeException
)
143 // -----------------------------------------------------------------------------
145 void SAL_CALL
RequireEmptyLayer::addOrReplaceNodeFromTemplate( const rtl::OUString
& /*aName*/, const backenduno::TemplateIdentifier
& /*aTemplate*/, sal_Int16
/*aAttributes*/)
146 throw (backenduno::MalformedDataException
, uno::RuntimeException
)
150 // -----------------------------------------------------------------------------
152 void SAL_CALL
RequireEmptyLayer::endNode( )
153 throw (backenduno::MalformedDataException
, uno::RuntimeException
)
157 // -----------------------------------------------------------------------------
159 void SAL_CALL
RequireEmptyLayer::dropNode( const rtl::OUString
& /*aName*/ )
160 throw (backenduno::MalformedDataException
, uno::RuntimeException
)
164 // -----------------------------------------------------------------------------
166 void SAL_CALL
RequireEmptyLayer::addProperty( const rtl::OUString
& /*aName*/, sal_Int16
/*aAttributes*/, const uno::Type
& /*aType*/ )
167 throw (backenduno::MalformedDataException
, uno::RuntimeException
)
171 // -----------------------------------------------------------------------------
173 void SAL_CALL
RequireEmptyLayer::addPropertyWithValue( const rtl::OUString
& /*aName*/, sal_Int16
/*aAttributes*/, const uno::Any
& /*aValue*/ )
174 throw (backenduno::MalformedDataException
, uno::RuntimeException
)
178 // -----------------------------------------------------------------------------
180 void SAL_CALL
RequireEmptyLayer::overrideProperty( const rtl::OUString
& /*aName*/, sal_Int16
/*aAttributes*/, const uno::Type
& /*aType*/, sal_Bool
/*bClear*/ )
181 throw (backenduno::MalformedDataException
, uno::RuntimeException
)
185 // -----------------------------------------------------------------------------
187 void SAL_CALL
RequireEmptyLayer::endProperty( )
188 throw (backenduno::MalformedDataException
, uno::RuntimeException
)
192 // -----------------------------------------------------------------------------
194 void SAL_CALL
RequireEmptyLayer::setPropertyValue( const uno::Any
& /*aValue*/ )
195 throw (backenduno::MalformedDataException
, uno::RuntimeException
)
199 // -----------------------------------------------------------------------------
201 void SAL_CALL
RequireEmptyLayer::setPropertyValueForLocale( const uno::Any
& /*aValue*/, const rtl::OUString
& /*aLocale*/ )
202 throw (backenduno::MalformedDataException
, uno::RuntimeException
)
206 // -----------------------------------------------------------------------------
208 void RequireEmptyLayer::fail(sal_Char
const * pMsg
)
210 if (!m_bStarted
& !m_bInvalid
) pMsg
= "Layer was not started";
215 rtl::OUString sMsg
= rtl::OUString::createFromAscii(pMsg
);
217 throw backenduno::MalformedDataException( sMsg
, *this, uno::Any() );
220 // -----------------------------------------------------------------------------
221 // -----------------------------------------------------------------------------
223 // -----------------------------------------------------------------------------
226 // -----------------------------------------------------------------------------