summaryrefslogtreecommitdiff
path: root/ucb/source/ucp/gio/gio_content.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'ucb/source/ucp/gio/gio_content.cxx')
-rw-r--r--ucb/source/ucp/gio/gio_content.cxx52
1 files changed, 34 insertions, 18 deletions
diff --git a/ucb/source/ucp/gio/gio_content.cxx b/ucb/source/ucp/gio/gio_content.cxx
index d3a910c02c4a..e3f2c0cb0222 100644
--- a/ucb/source/ucp/gio/gio_content.cxx
+++ b/ucb/source/ucp/gio/gio_content.cxx
@@ -432,12 +432,11 @@ static util::DateTime getDateFromUnix (time_t t)
return util::DateTime();
}
-uno::Reference< sdbc::XRow > Content::getPropertyValuesFromGFileInfo(GFileInfo *pInfo,
- const uno::Reference< uno::XComponentContext >& rxContext,
- const uno::Reference< ucb::XCommandEnvironment > & xEnv,
- const uno::Sequence< beans::Property >& rProperties)
+uno::Reference< sdbc::XRow > Content::getPropertyValues(
+ const uno::Sequence< beans::Property >& rProperties,
+ const uno::Reference< ucb::XCommandEnvironment >& xEnv )
{
- rtl::Reference< ::ucbhelper::PropertyValueSet > xRow = new ::ucbhelper::PropertyValueSet( rxContext );
+ rtl::Reference< ::ucbhelper::PropertyValueSet > xRow = new ::ucbhelper::PropertyValueSet( m_xContext );
sal_Int32 nProps;
const beans::Property* pProps;
@@ -445,12 +444,14 @@ uno::Reference< sdbc::XRow > Content::getPropertyValuesFromGFileInfo(GFileInfo *
nProps = rProperties.getLength();
pProps = rProperties.getConstArray();
+ GFileInfo *pInfo = nullptr;
for( sal_Int32 n = 0; n < nProps; ++n )
{
const beans::Property& rProp = pProps[ n ];
if ( rProp.Name == "IsDocument" )
{
+ getFileInfo(xEnv, &pInfo, true);
if (pInfo != nullptr && g_file_info_has_attribute(pInfo, G_FILE_ATTRIBUTE_STANDARD_TYPE))
xRow->appendBoolean( rProp, ( g_file_info_get_file_type( pInfo ) == G_FILE_TYPE_REGULAR ||
g_file_info_get_file_type( pInfo ) == G_FILE_TYPE_UNKNOWN ) );
@@ -459,6 +460,7 @@ uno::Reference< sdbc::XRow > Content::getPropertyValuesFromGFileInfo(GFileInfo *
}
else if ( rProp.Name == "IsFolder" )
{
+ getFileInfo(xEnv, &pInfo, true);
if (pInfo != nullptr && g_file_info_has_attribute( pInfo, G_FILE_ATTRIBUTE_STANDARD_TYPE) )
xRow->appendBoolean( rProp, ( g_file_info_get_file_type( pInfo ) == G_FILE_TYPE_DIRECTORY ));
else
@@ -466,6 +468,7 @@ uno::Reference< sdbc::XRow > Content::getPropertyValuesFromGFileInfo(GFileInfo *
}
else if ( rProp.Name == "Title" )
{
+ getFileInfo(xEnv, &pInfo, false);
if (pInfo != nullptr && g_file_info_has_attribute(pInfo, G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME))
{
const char *pName = g_file_info_get_display_name(pInfo);
@@ -476,6 +479,7 @@ uno::Reference< sdbc::XRow > Content::getPropertyValuesFromGFileInfo(GFileInfo *
}
else if ( rProp.Name == "IsReadOnly" )
{
+ getFileInfo(xEnv, &pInfo, true);
if (pInfo != nullptr && g_file_info_has_attribute( pInfo, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE ) )
xRow->appendBoolean( rProp, !g_file_info_get_attribute_boolean( pInfo, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE) );
else
@@ -483,6 +487,7 @@ uno::Reference< sdbc::XRow > Content::getPropertyValuesFromGFileInfo(GFileInfo *
}
else if ( rProp.Name == "DateCreated" )
{
+ getFileInfo(xEnv, &pInfo, true);
if (pInfo != nullptr && g_file_info_has_attribute( pInfo, G_FILE_ATTRIBUTE_TIME_CREATED ) )
xRow->appendTimestamp( rProp, getDateFromUnix(g_file_info_get_attribute_uint64(pInfo, G_FILE_ATTRIBUTE_TIME_CREATED)) );
else
@@ -490,6 +495,7 @@ uno::Reference< sdbc::XRow > Content::getPropertyValuesFromGFileInfo(GFileInfo *
}
else if ( rProp.Name == "DateModified" )
{
+ getFileInfo(xEnv, &pInfo, true);
if (pInfo != nullptr && g_file_info_has_attribute( pInfo, G_FILE_ATTRIBUTE_TIME_CHANGED ) )
xRow->appendTimestamp( rProp, getDateFromUnix(g_file_info_get_attribute_uint64(pInfo, G_FILE_ATTRIBUTE_TIME_CHANGED)) );
else
@@ -497,6 +503,7 @@ uno::Reference< sdbc::XRow > Content::getPropertyValuesFromGFileInfo(GFileInfo *
}
else if ( rProp.Name == "Size" )
{
+ getFileInfo(xEnv, &pInfo, true);
if (pInfo != nullptr && g_file_info_has_attribute( pInfo, G_FILE_ATTRIBUTE_STANDARD_SIZE) )
xRow->appendLong( rProp, ( g_file_info_get_size( pInfo ) ));
else
@@ -509,6 +516,7 @@ uno::Reference< sdbc::XRow > Content::getPropertyValuesFromGFileInfo(GFileInfo *
}
else if ( rProp.Name == "IsCompactDisc" )
{
+ getFileInfo(xEnv, &pInfo, true);
if (pInfo != nullptr && g_file_info_has_attribute( pInfo, G_FILE_ATTRIBUTE_MOUNTABLE_CAN_EJECT ) )
xRow->appendBoolean( rProp, g_file_info_get_attribute_boolean(pInfo, G_FILE_ATTRIBUTE_MOUNTABLE_CAN_EJECT) );
else
@@ -516,6 +524,7 @@ uno::Reference< sdbc::XRow > Content::getPropertyValuesFromGFileInfo(GFileInfo *
}
else if ( rProp.Name == "IsRemoveable" )
{
+ getFileInfo(xEnv, &pInfo, true);
if (pInfo != nullptr && g_file_info_has_attribute( pInfo, G_FILE_ATTRIBUTE_MOUNTABLE_CAN_UNMOUNT ) )
xRow->appendBoolean( rProp, g_file_info_get_attribute_boolean(pInfo, G_FILE_ATTRIBUTE_MOUNTABLE_CAN_UNMOUNT ) );
else
@@ -527,6 +536,7 @@ uno::Reference< sdbc::XRow > Content::getPropertyValuesFromGFileInfo(GFileInfo *
}
else if ( rProp.Name == "IsHidden" )
{
+ getFileInfo(xEnv, &pInfo, true);
if (pInfo != nullptr && g_file_info_has_attribute( pInfo, G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN) )
xRow->appendBoolean( rProp, ( g_file_info_get_is_hidden ( pInfo ) ) );
else
@@ -547,19 +557,6 @@ uno::Reference< sdbc::XRow > Content::getPropertyValuesFromGFileInfo(GFileInfo *
return uno::Reference< sdbc::XRow >( xRow.get() );
}
-uno::Reference< sdbc::XRow > Content::getPropertyValues(
- const uno::Sequence< beans::Property >& rProperties,
- const uno::Reference< ucb::XCommandEnvironment >& xEnv )
-{
- GError * err = nullptr;
- GFileInfo *pInfo = getGFileInfo(xEnv, &err);
- if (pInfo == nullptr && !mbTransient) {
- ucbhelper::cancelCommandExecution(mapGIOError(err), xEnv);
- }
- assert(err == nullptr);
- return getPropertyValuesFromGFileInfo(pInfo, m_xContext, xEnv, rProperties);
-}
-
static lang::IllegalAccessException
getReadOnlyException( const uno::Reference< uno::XInterface >& rContext )
{
@@ -646,6 +643,25 @@ bool Content::exchangeIdentity( const uno::Reference< ucb::XContentIdentifier >&
return false;
}
+void Content::getFileInfo(
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & env, GFileInfo ** info, bool fail)
+{
+ assert(info != nullptr);
+ if (*info == nullptr)
+ {
+ GError * err = nullptr;
+ *info = getGFileInfo(env, &err);
+ if (*info == nullptr && !mbTransient && fail)
+ {
+ ucbhelper::cancelCommandExecution(mapGIOError(err), env);
+ }
+ else if (err != nullptr)
+ {
+ g_error_free(err);
+ }
+ }
+}
+
uno::Sequence< uno::Any > Content::setPropertyValues(
const uno::Sequence< beans::PropertyValue >& rValues,
const uno::Reference< ucb::XCommandEnvironment >& xEnv )