void testJsonAwtSize()
{ // Given a list of beans::PropertyValues in JSON:
OString aJson = R"json(
{ "mykey": { "type": "any", "value": { "type": "com.sun.star.awt.Size", "value": { "Width": { "type": "long", "value": 42
}, "Height": { "type": "long", "value": 43
}
}
}
}
}
)json"_ostr;
// When parsing that:
std::vector<beans::PropertyValue> aRet = comphelper::JsonToPropertyValues(aJson);
// Then make sure we can construct an awt::Size:
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aRet.size());
beans::PropertyValue aFirst = aRet[0];
CPPUNIT_ASSERT_EQUAL(OUString("mykey"), aFirst.Name); // Without the accompanying fix in place, this test would have failed with: // - Cannot extract an Any(void) to com.sun.star.awt.Size auto aSize = aFirst.Value.get<awt::Size>();
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(42), aSize.Width);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(43), aSize.Height);
}
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.