summaryrefslogtreecommitdiff
path: root/ucb/source/ucp/odma/odma_content.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'ucb/source/ucp/odma/odma_content.cxx')
-rwxr-xr-x[-rw-r--r--]ucb/source/ucp/odma/odma_content.cxx225
1 files changed, 48 insertions, 177 deletions
diff --git a/ucb/source/ucp/odma/odma_content.cxx b/ucb/source/ucp/odma/odma_content.cxx
index ae3c3ede60e7..4ef70bec95c9 100644..100755
--- a/ucb/source/ucp/odma/odma_content.cxx
+++ b/ucb/source/ucp/odma/odma_content.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -123,10 +124,6 @@ uno::Any SAL_CALL Content::queryInterface( const uno::Type & rType )
uno::Any aRet;
// @@@ Add support for additional interfaces.
-#if 0
- aRet = cppu::queryInterface( rType,
- static_cast< yyy::Xxxxxxxxx * >( this ) );
-#endif
return aRet.hasValue() ? aRet : ContentImplHelper::queryInterface( rType );
}
@@ -182,7 +179,7 @@ rtl::OUString SAL_CALL Content::getImplementationName()
throw( uno::RuntimeException )
{
// @@@ Adjust implementation name. Keep the prefix "com.sun.star.comp."!
- return rtl::OUString::createFromAscii( "com.sun.star.comp.odma.Content" );
+ return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.odma.Content"));
}
//=========================================================================
@@ -193,7 +190,7 @@ uno::Sequence< rtl::OUString > SAL_CALL Content::getSupportedServiceNames()
// @@@ Adjust macro name.
uno::Sequence< rtl::OUString > aSNS( 1 );
aSNS.getArray()[ 0 ]
- = rtl::OUString::createFromAscii( ODMA_CONTENT_SERVICE_NAME );
+ = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( ODMA_CONTENT_SERVICE_NAME ));
return aSNS;
}
@@ -208,7 +205,7 @@ rtl::OUString SAL_CALL Content::getContentType()
throw( uno::RuntimeException )
{
// @@@ Adjust macro name ( def in odma_provider.hxx ).
- return rtl::OUString::createFromAscii( ODMA_CONTENT_TYPE );
+ return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( ODMA_CONTENT_TYPE ));
}
//=========================================================================
@@ -397,7 +394,7 @@ uno::Any SAL_CALL Content::execute(
}
catch(uno::Exception&)
{
- OSL_ENSURE(0,"Exception occured while creating the file content!");
+ OSL_ENSURE(0,"Exception occurred while creating the file content!");
}
xDataSink->setInputStream( xIn );
}
@@ -471,6 +468,12 @@ uno::Any SAL_CALL Content::execute(
}
else if( ! aCommand.Name.compareToAscii( "transfer" ) )
{
+ // So far I have determined that this command is called when
+ // doing "Save As" to copy an already written backup copy of
+ // the document in the file system into the DMS.
+
+ // Maybe also in other situations.
+
ucb::TransferInfo aTransferInfo;
if( ! ( aCommand.Argument >>= aTransferInfo ) )
{
@@ -486,84 +489,21 @@ uno::Any SAL_CALL Content::execute(
::rtl::Reference<ContentProperties> aProp = m_aProps;
if(aProp->m_bIsFolder)
{
- aProp = getContentProvider()->getContentPropertyWithTitle(aTransferInfo.NewTitle);
+ aProp = getContentProvider()->getContentPropertyWithDocumentId(aTransferInfo.NewTitle);
if(!aProp.is())
aProp = getContentProvider()->getContentPropertyWithSavedAsName(aTransferInfo.NewTitle);
sal_Bool bError = !aProp.is();
- if(bError)
- {
- sal_Char* pExtension = NULL;
- ::rtl::OString sExt;
- sal_Int32 nPos = aTransferInfo.NewTitle.lastIndexOf('.');
- if(nPos != -1)
- {
- sExt = ::rtl::OUStringToOString(aTransferInfo.NewTitle.copy(nPos+1),RTL_TEXTENCODING_ASCII_US);
- if(sExt.equalsIgnoreAsciiCase("txt"))
- pExtension = ODM_FORMAT_TEXT;
- else if(sExt.equalsIgnoreAsciiCase("rtf"))
- pExtension = ODM_FORMAT_RTF;
- else if(sExt.equalsIgnoreAsciiCase("ps"))
- pExtension = ODM_FORMAT_PS;
- else
- pExtension = const_cast<sal_Char*>(sExt.getStr());
- }
- else
- pExtension = ODM_FORMAT_TEXT;
-
- sal_Char* lpszNewDocId = new sal_Char[ODM_DOCID_MAX];
- void *pData = NULL;
- DWORD dwFlags = ODM_SILENT;
- ODMSTATUS odm = NODMSaveAsEx(ContentProvider::getHandle(),
- NULL, // means it is saved the first time
- lpszNewDocId,
- pExtension,
- NULL, // no callback function here
- pData,
- &dwFlags);
-
- // check if we have to call the DMS dialog
- if(odm == ODM_E_USERINT)
- {
- dwFlags = 0;
- odm = NODMSaveAsEx(ContentProvider::getHandle(),
- NULL, // means it is saved the first time
- lpszNewDocId,
- pExtension,
- NULL, // no callback function here
- pData,
- &dwFlags);
- }
- bError = odm != ODM_SUCCESS;
- if(!bError)
- {
- aProp = new ContentProperties();
- aProp->m_sDocumentId = ::rtl::OString(lpszNewDocId);
- aProp->m_sContentType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ODMA_CONTENT_TYPE));
- aProp->m_sSavedAsName = aTransferInfo.NewTitle;
- getContentProvider()->append(aProp);
-
- // now set the title
- WORD nDocInfo = ODM_NAME;
- ::rtl::OUString sFileName = aTransferInfo.NewTitle;
- sal_Int32 nIndex = aTransferInfo.NewTitle.lastIndexOf( sal_Unicode('.') );
- if(nIndex != -1)
- sFileName = aTransferInfo.NewTitle.copy(0,nIndex);
-
- ::rtl::OString sDocInfoValue = ::rtl::OUStringToOString(sFileName,RTL_TEXTENCODING_ASCII_US);
- odm = NODMSetDocInfo( ContentProvider::getHandle(),
- lpszNewDocId,
- nDocInfo,
- const_cast<sal_Char*>(sDocInfoValue.getStr())
- );
- }
- else if ( odm == ODM_E_CANCEL)
- NODMActivate(ContentProvider::getHandle(),
- ODM_DELETE,
- lpszNewDocId);
+ // There used to be code below that called ODMSaveAsEx,
+ // but that was very broken. We have already called
+ // ODMSaveAsEx in the ODMA file picker when selecting the
+ // name for a new document, or the document already exists
+ // in the DMS and we don't need any ODMSaveAsEx. The ODMA
+ // file picker tells odma::ContentProvider about the new
+ // document's DOCID, so the
+ // getContentPropertyWithDocumentId() call above should
+ // succeed.
- delete [] lpszNewDocId;
- }
if(bError)
ucbhelper::cancelCommandExecution(
uno::makeAny( lang::IllegalArgumentException(
@@ -575,12 +515,23 @@ uno::Any SAL_CALL Content::execute(
rtl::OUString sFileURL = ContentProvider::openDoc(aProp);
sal_Int32 nLastIndex = sFileURL.lastIndexOf( sal_Unicode('/') );
+ // Create a new Content object for the "shadow" file
+ // corresponding to the opened document from the DMS.
::ucbhelper::Content aContent(sFileURL.copy(0,nLastIndex),NULL);
// aTransferInfo.NameClash = ucb::NameClash::OVERWRITE;
aTransferInfo.NewTitle = sFileURL.copy( 1 + nLastIndex );
+ // Copy our saved backup copy to the "shadow" file.
aContent.executeCommand(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("transfer")),uno::makeAny(aTransferInfo));
+ // Tell the DMS that the "shadow" file is done and can be
+ // imported.
getContentProvider()->saveDocument(aProp->m_sDocumentId);
}
+ else if ( aCommand.Name.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( "getCasePreservingURL" ) ) )
+ {
+ rtl::OUString CasePreservingURL = openDoc();
+ aRet <<= CasePreservingURL;
+ }
else
{
//////////////////////////////////////////////////////////////////
@@ -751,27 +702,27 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
{
// Append all Core Properties.
xRow->appendString (
- beans::Property( rtl::OUString::createFromAscii( "ContentType" ),
+ beans::Property( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ContentType")),
-1,
getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::READONLY ),
rData->m_sContentType );
xRow->appendString (
- beans::Property( rtl::OUString::createFromAscii( "Title" ),
+ beans::Property( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Title")),
-1,
getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
beans::PropertyAttribute::BOUND ),
rData->m_sTitle );
xRow->appendBoolean(
- beans::Property( rtl::OUString::createFromAscii( "IsDocument" ),
+ beans::Property( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsDocument")),
-1,
getCppuBooleanType(),
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::READONLY ),
rData->m_bIsDocument );
xRow->appendBoolean(
- beans::Property( rtl::OUString::createFromAscii( "IsFolder" ),
+ beans::Property( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsFolder")),
-1,
getCppuBooleanType(),
beans::PropertyAttribute::BOUND
@@ -780,40 +731,40 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
// @@@ Append other properties supported directly.
xRow->appendTimestamp(
- beans::Property( rtl::OUString::createFromAscii( "DateCreated" ),
+ beans::Property( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DateCreated")),
-1,
getCppuType(static_cast< const util::DateTime * >( 0 ) ),
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::READONLY ),
rData->m_aDateCreated );
xRow->appendTimestamp(
- beans::Property( rtl::OUString::createFromAscii( "DateModified" ),
+ beans::Property( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DateModified")),
-1,
getCppuType(static_cast< const util::DateTime * >( 0 ) ),
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::READONLY ),
rData->m_aDateModified );
xRow->appendBoolean(
- beans::Property( rtl::OUString::createFromAscii( "IsReadOnly" ),
+ beans::Property( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsReadOnly")),
-1,
getCppuBooleanType(),
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::READONLY ),
rData->m_bIsReadOnly );
xRow->appendString (
- beans::Property( rtl::OUString::createFromAscii( "Author" ),
+ beans::Property( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Author")),
-1,
getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
beans::PropertyAttribute::BOUND ),
rData->m_sAuthor );
xRow->appendString (
- beans::Property( rtl::OUString::createFromAscii( "Subject" ),
+ beans::Property( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Subject")),
-1,
getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
beans::PropertyAttribute::BOUND ),
rData->m_sSubject );
xRow->appendString (
- beans::Property( rtl::OUString::createFromAscii( "Keywords" ),
+ beans::Property( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Keywords")),
-1,
getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
beans::PropertyAttribute::BOUND ),
@@ -970,8 +921,8 @@ uno::Sequence< uno::Any > Content::setPropertyValues(
else
{
aRet[ n ] <<= uno::Exception(
- rtl::OUString::createFromAscii(
- "No property set for storing the value!" ),
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "No property set for storing the value!" )),
static_cast< cppu::OWeakObject * >( this ) );
}
}
@@ -989,59 +940,6 @@ uno::Sequence< uno::Any > Content::setPropertyValues(
return aRet;
}
-
-#if 0
-//=========================================================================
-void Content::queryChildren( ContentRefList& rChildren )
-{
- // @@@ Adapt method to your URL scheme...
-
- // Obtain a list with a snapshot of all currently instanciated contents
- // from provider and extract the contents which are direct children
- // of this content.
-
- ::ucbhelper::ContentRefList aAllContents;
- m_xProvider->queryExistingContents( aAllContents );
-
- OUString aURL = m_xIdentifier->getContentIdentifier();
- sal_Int32 nPos = aURL.lastIndexOf( '/' );
-
- if ( nPos != ( aURL.getLength() - 1 ) )
- {
- // No trailing slash found. Append.
- aURL += OUString::createFromAscii( "/" );
- }
-
- sal_Int32 nLen = aURL.getLength();
-
- ::ucbhelper::ContentRefList::const_iterator it = aAllContents.begin();
- ::ucbhelper::ContentRefList::const_iterator end = aAllContents.end();
-
- while ( it != end )
- {
- ::ucbhelper::ContentImplHelperRef xChild = (*it);
- OUString aChildURL = xChild->getIdentifier()->getContentIdentifier();
-
- // Is aURL a prefix of aChildURL?
- if ( ( aChildURL.getLength() > nLen ) &&
- ( aChildURL.compareTo( aURL, nLen ) == 0 ) )
- {
- sal_Int32 nPos = nLen;
- nPos = aChildURL.indexOf( '/', nPos );
-
- if ( ( nPos == -1 ) ||
- ( nPos == ( aChildURL.getLength() - 1 ) ) )
- {
- // No further slashes / only a final slash. It's a child!
- rChildren.push_back(
- ContentRef(
- static_cast< Content * >( xChild.get() ) ) );
- }
- }
- ++it;
- }
-}
-#endif
//=========================================================================
void Content::insert(
const uno::Reference< io::XInputStream > & xInputStream,
@@ -1057,7 +955,7 @@ void Content::insert(
OSL_ENSURE( sal_False, "Content::insert - property value missing!" );
uno::Sequence< rtl::OUString > aProps( 1 );
- aProps[ 0 ] = rtl::OUString::createFromAscii( "zzzz" );
+ aProps[ 0 ] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("zzzz"));
ucbhelper::cancelCommandExecution(
uno::makeAny( ucb::MissingPropertiesException(
rtl::OUString(),
@@ -1107,34 +1005,6 @@ void Content::insert(
aGuard.clear();
inserted();
}
-#if 0
-//=========================================================================
-void Content::destroy( sal_Bool bDeletePhysical )
- throw( uno::Exception )
-{
- // @@@ take care about bDeletePhysical -> trashcan support
-
- uno::Reference< ucb::XContent > xThis = this;
-
- deleted();
-
- osl::Guard< osl::Mutex > aGuard( m_aMutex );
-
- // Process instanciated children...
-
- ContentRefList aChildren;
- queryChildren( aChildren );
-
- ContentRefList::const_iterator it = aChildren.begin();
- ContentRefList::const_iterator end = aChildren.end();
-
- while ( it != end )
- {
- (*it)->destroy( bDeletePhysical );
- ++it;
- }
-}
-#endif
// -----------------------------------------------------------------------------
::rtl::OUString Content::openDoc()
@@ -1206,10 +1076,11 @@ void Content::changePropertyValue(const beans::PropertyValue& _rValue,
if(bError)
{
_rRet[ _rnCurrentPos ] <<= beans::IllegalTypeException(
- rtl::OUString::createFromAscii(
- "Property value has wrong type!" ),
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "Property value has wrong type!" )),
static_cast< cppu::OWeakObject * >( this ) );
}
}
// -----------------------------------------------------------------------------
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */