From cd1a12dc552e9d34c7481c83b07a6f6af0e8762b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?= Date: Sun, 16 Oct 2011 16:54:23 +0200 Subject: [PATCH] CMIS: use another name to show than the one extracted from the base URL In CMIS, the URL is only providing an easy access to the CMIS interface and doesn't reflect the public path on the server. A new property has been added in the SfxMedium items to hold the document name on the server and set it as the window title. --- sfx2/source/doc/sfxbasemodel.cxx | 22 +++++++++++++++++++--- ucb/source/ucp/cmis/cmis_content.cxx | 8 ++++++-- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index 777929dfc806..c335aea69ad4 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -65,6 +66,7 @@ #include #include #include +#include #include // can be removed when this is a "real" service #include @@ -3769,9 +3771,23 @@ css::uno::Reference< css::frame::XUntitledNumbers > SfxBaseModel::impl_getUntitl SfxMedium* pMedium = m_pData->m_pObjectShell->GetMedium(); if ( pMedium ) { - SFX_ITEMSET_ARG( pMedium->GetItemSet(), pRepairedDocItem, SfxBoolItem, SID_REPAIRPACKAGE, sal_False ); - if ( pRepairedDocItem && pRepairedDocItem->GetValue() ) - aResult += String( SfxResId(STR_REPAIREDDOCUMENT) ); + ::ucbhelper::Content aContent( pMedium->GetName(), com::sun::star::uno::Reference < ucb::XCommandEnvironment >() ); + com::sun::star::uno::Reference < beans::XPropertySetInfo > xProps = aContent.getProperties(); + if ( xProps.is() ) + { + ::rtl::OUString aServerTitle( RTL_CONSTASCII_USTRINGPARAM("TitleOnServer") ); + if ( xProps->hasPropertyByName( aServerTitle ) ) + { + uno::Any aAny = aContent.getPropertyValue( aServerTitle ); + aAny >>= aResult; + } + } + else + { + SFX_ITEMSET_ARG( pMedium->GetItemSet(), pRepairedDocItem, SfxBoolItem, SID_REPAIRPACKAGE, sal_False ); + if ( pRepairedDocItem && pRepairedDocItem->GetValue() ) + aResult += String( SfxResId(STR_REPAIREDDOCUMENT) ); + } } if ( m_pData->m_pObjectShell->IsReadOnlyUI() || (pMedium && pMedium->IsReadOnly()) ) diff --git a/ucb/source/ucp/cmis/cmis_content.cxx b/ucb/source/ucp/cmis/cmis_content.cxx index d72041e5e9b6..f765f1947069 100644 --- a/ucb/source/ucp/cmis/cmis_content.cxx +++ b/ucb/source/ucp/cmis/cmis_content.cxx @@ -126,6 +126,9 @@ namespace cmis for( sal_Int32 n = 0; n < nProps; ++n ) { const beans::Property& rProp = pProps[ n ]; +#if OSL_DEBUG_LEVEL > 1 + fprintf( stderr, "Property: %s\n", rtl::OUStringToOString( rProp.Name, RTL_TEXTENCODING_UTF8 ).getStr() ); +#endif if (rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsDocument" ) ) ) { @@ -141,8 +144,9 @@ namespace cmis else xRow->appendVoid( rProp ); } - else if (rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Title" ) ) ) + else if (rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "TitleOnServer" ) ) ) { + // TODO Set the path instead of the name xRow->appendString( rProp, rtl::OUString::createFromAscii( m_pObject->getName().c_str() ) ); } else if (rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsReadOnly" ) ) ) @@ -354,7 +358,7 @@ namespace cmis beans::Property( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ), -1, getCppuBooleanType(), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY ), - beans::Property( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ), + beans::Property( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TitleOnServer" ) ), -1, getCppuType( static_cast< const rtl::OUString * >( 0 ) ), beans::PropertyAttribute::BOUND ), beans::Property( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsReadOnly" ) ),