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: sdbcoretools.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_dbaccess.hxx"
34 #ifndef DBACORE_SDBCORETOOLS_HXX
35 #include "sdbcoretools.hxx"
37 #ifndef _TOOLS_DEBUG_HXX
38 #include <tools/debug.hxx>
40 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
41 #include <com/sun/star/beans/XPropertySet.hpp>
43 #ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
44 #include <com/sun/star/beans/PropertyValue.hpp>
46 #ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_
47 #include <com/sun/star/container/XChild.hpp>
49 #ifndef _COM_SUN_STAR_UTIL_XMODIFIABLE_HPP_
50 #include <com/sun/star/util/XModifiable.hpp>
52 #ifndef _COM_SUN_STAR_SDB_XDOCUMENTDATASOURCE_HPP_
53 #include <com/sun/star/sdb/XDocumentDataSource.hpp>
55 #ifndef DBACCESS_SHARED_DBASTRINGS_HRC
56 #include "dbastrings.hrc"
59 //.........................................................................
62 //.........................................................................
64 using namespace ::com::sun::star::uno
;
65 using namespace ::com::sun::star::lang
;
66 using namespace ::com::sun::star::util
;
67 using namespace ::com::sun::star::sdbc
;
68 using namespace ::com::sun::star::sdb
;
69 using namespace ::com::sun::star::beans
;
70 using namespace ::com::sun::star::container
;
72 // =========================================================================
73 // -------------------------------------------------------------------------
74 void notifyDataSourceModified(const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& _rxObject
,sal_Bool _bModified
)
76 Reference
< XInterface
> xDs
= getDataSource( _rxObject
);
77 Reference
<XDocumentDataSource
> xDocumentDataSource(xDs
,UNO_QUERY
);
78 if ( xDocumentDataSource
.is() )
79 xDs
= xDocumentDataSource
->getDatabaseDocument();
80 Reference
< XModifiable
> xModi( xDs
, UNO_QUERY
);
82 xModi
->setModified(_bModified
);
85 // -------------------------------------------------------------------------
86 Reference
< XInterface
> getDataSource( const Reference
< XInterface
>& _rxDependentObject
)
88 Reference
< XInterface
> xParent
= _rxDependentObject
;
89 Reference
< XInterface
> xReturn
;
93 Reference
<XChild
> xChild(xParent
,UNO_QUERY
);
94 xParent
.set(xChild
.is() ? xChild
->getParent() : Reference
< XInterface
>(),UNO_QUERY
);
99 // -------------------------------------------------------------------------
100 bool getDataSourceSetting( const Reference
< XInterface
>& _rxDataSource
, const sal_Char
* _pAsciiSettingsName
,
101 Any
& /* [out] */ _rSettingsValue
)
103 bool bIsPresent
= false;
106 Reference
< XPropertySet
> xDataSource( _rxDataSource
, UNO_QUERY
);
107 OSL_ENSURE( xDataSource
.is(), "getDataSourceSetting: invalid data source object!" );
108 if ( !xDataSource
.is() )
111 Sequence
< PropertyValue
> aSettings
;
112 OSL_VERIFY( xDataSource
->getPropertyValue( PROPERTY_INFO
) >>= aSettings
);
113 const PropertyValue
* pSetting
= aSettings
.getConstArray();
114 const PropertyValue
* pSettingEnd
= aSettings
.getConstArray() + aSettings
.getLength();
115 for ( ; pSetting
!= pSettingEnd
; ++pSetting
)
117 if ( pSetting
->Name
.equalsAscii( _pAsciiSettingsName
) )
119 _rSettingsValue
= pSetting
->Value
;
125 catch( const Exception
& )
127 OSL_ENSURE( sal_False
, "getDataSourceSetting: caught an exception!" );
132 // -----------------------------------------------------------------------------
133 //.........................................................................
134 } // namespace dbaccess
135 //.........................................................................