12#include <com/sun/star/beans/PropertyValue.hpp>
13#include <com/sun/star/beans/XPropertySet.hpp>
14#include <com/sun/star/sheet/DataImportMode.hpp>
15#include <com/sun/star/util/XImportable.hpp>
16#include <com/sun/star/uno/Any.hxx>
17#include <com/sun/star/uno/Reference.hxx>
18#include <com/sun/star/uno/Sequence.hxx>
20#include <cppunit/TestAssert.h>
29 uno::Reference<beans::XPropertySet> xDatabaseImportDescriptor(
init(), UNO_QUERY_THROW);
30 uno::Reference<util::XImportable> xImportable(
getXImportable(), UNO_QUERY_THROW);
31 uno::Sequence<beans::PropertyValue> aPropValues = xImportable->createImportDescriptor(
true);
33 for (
auto& rPropValue : asNonConstRange(aPropValues))
37 if (rPropValue.Name ==
"DatabaseName" || rPropValue.Name ==
"SourceObject"
38 || rPropValue.Name ==
"ConnectionResource")
41 aOldValue = rPropValue.
Value;
43 OString aMsgGet =
"Unable to get PropertyValue "
45 CPPUNIT_ASSERT_EQUAL_MESSAGE(aMsgGet.getStr(), OUString(
""), aValue);
47 aNewValue <<= OUString(
"New");
48 rPropValue.Value = aNewValue;
50 aOldValue = rPropValue.
Value;
52 OString aMsgSet =
"Unable to set PropertyValue "
54 CPPUNIT_ASSERT_EQUAL_MESSAGE(aMsgSet.getStr(), OUString(
"New"), aValue);
56 else if (rPropValue.Name ==
"IsNative")
59 aOldValue = rPropValue.
Value;
61 OString aMsgGet =
"Unable to get PropertyValue "
63 CPPUNIT_ASSERT_MESSAGE(aMsgGet.getStr(), !aValue);
66 rPropValue.
Value = aNewValue;
68 aOldValue = rPropValue.
Value;
70 OString aMsgSet =
"Unable to set PropertyValue "
72 CPPUNIT_ASSERT_MESSAGE(aMsgSet.getStr(), aValue);
74 else if (rPropValue.Name ==
"SourceType")
76 sheet::DataImportMode aValue;
77 aOldValue = rPropValue.
Value;
79 OString aMsgGet =
"Unable to get PropertyValue "
81 CPPUNIT_ASSERT_EQUAL_MESSAGE(aMsgGet.getStr(), sheet::DataImportMode_NONE, aValue);
83 aNewValue <<= sheet::DataImportMode_SQL;
84 rPropValue.
Value = aNewValue;
86 aOldValue = rPropValue.
Value;
88 OString aMsgSet =
"Unable to set PropertyValue "
90 CPPUNIT_ASSERT_EQUAL_MESSAGE(aMsgSet.getStr(), sheet::DataImportMode_SQL, aValue);
94 OString aMsg =
"Unsupported PropertyValue "
96 CPPUNIT_FAIL(aMsg.getStr());
void testDatabaseImportDescriptorProperties()
virtual css::uno::Reference< css::uno::XInterface > init()=0
virtual css::uno::Reference< css::uno::XInterface > getXImportable()=0
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)