summaryrefslogtreecommitdiffstats
path: root/ucbhelper
diff options
context:
space:
mode:
authorMikhail Voitenko <mav@openoffice.org>2002-01-11 17:12:03 +0000
committerMikhail Voitenko <mav@openoffice.org>2002-01-11 17:12:03 +0000
commit0669841c641f8c4e9608af8374de03a69f8af13d (patch)
treea98b6d167c9533e6394078d3cb7eb490d3e04aed /ucbhelper
parent#95512# new AnyCompareFactory service implementation (diff)
downloadcore-0669841c641f8c4e9608af8374de03a69f8af13d.tar.gz
core-0669841c641f8c4e9608af8374de03a69f8af13d.zip
#95512# creation of sorted cursors
Diffstat (limited to 'ucbhelper')
-rw-r--r--ucbhelper/inc/ucbhelper/content.hxx51
-rw-r--r--ucbhelper/source/client/content.cxx325
2 files changed, 285 insertions, 91 deletions
diff --git a/ucbhelper/inc/ucbhelper/content.hxx b/ucbhelper/inc/ucbhelper/content.hxx
index e6b2a84c2334..65401f9b497b 100644
--- a/ucbhelper/inc/ucbhelper/content.hxx
+++ b/ucbhelper/inc/ucbhelper/content.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: content.hxx,v $
*
- * $Revision: 1.9 $
+ * $Revision: 1.10 $
*
- * last change: $Author: hr $ $Date: 2001-09-27 10:51:34 $
+ * last change: $Author: mav $ $Date: 2002-01-11 18:07:16 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -99,6 +99,8 @@ namespace com { namespace sun { namespace star { namespace ucb {
class XContent;
class XContentIdentifier;
class XDynamicResultSet;
+ class XAnyCompareFactory;
+ struct NumberedSortingInfo;
} } } }
namespace ucb
@@ -141,6 +143,14 @@ class Content
{
vos::ORef< Content_Impl > m_xImpl;
+protected:
+ ::com::sun::star::uno::Any createCursorAny( const ::com::sun::star::uno::Sequence<
+ rtl::OUString >& rPropertyNames,
+ ResultSetInclude eMode );
+
+ ::com::sun::star::uno::Any createCursorAny( const ::com::sun::star::uno::Sequence<
+ sal_Int32 >& rPropertyHandles,
+ ResultSetInclude eMode );
public:
/**
* Constructor.
@@ -633,6 +643,43 @@ public:
throw( ::com::sun::star::ucb::CommandAbortedException,
::com::sun::star::uno::RuntimeException,
::com::sun::star::uno::Exception );
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XDynamicResultSet >
+ createSortedDynamicCursor( const ::com::sun::star::uno::Sequence< rtl::OUString >& rPropertyNames,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::ucb::NumberedSortingInfo >& rSortInfo,
+ ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XAnyCompareFactory > rAnyCompareFactory,
+ ResultSetInclude eMode = INCLUDE_FOLDERS_AND_DOCUMENTS )
+ throw( ::com::sun::star::ucb::CommandAbortedException,
+ ::com::sun::star::uno::RuntimeException,
+ ::com::sun::star::uno::Exception );
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XDynamicResultSet >
+ createSortedDynamicCursor( const ::com::sun::star::uno::Sequence< sal_Int32 >& rPropertyHandles,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::ucb::NumberedSortingInfo >& rSortInfo,
+ ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XAnyCompareFactory > rAnyCompareFactory,
+ ResultSetInclude eMode = INCLUDE_FOLDERS_AND_DOCUMENTS )
+ throw( ::com::sun::star::ucb::CommandAbortedException,
+ ::com::sun::star::uno::RuntimeException,
+ ::com::sun::star::uno::Exception );
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >
+ createSortedCursor( const ::com::sun::star::uno::Sequence< rtl::OUString >& rPropertyNames,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::ucb::NumberedSortingInfo >& rSortInfo,
+ ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XAnyCompareFactory > rAnyCompareFactory,
+ ResultSetInclude eMode = INCLUDE_FOLDERS_AND_DOCUMENTS )
+ throw( ::com::sun::star::ucb::CommandAbortedException,
+ ::com::sun::star::uno::RuntimeException,
+ ::com::sun::star::uno::Exception );
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >
+ createSortedCursor( const ::com::sun::star::uno::Sequence< sal_Int32 >& rPropertyHandles,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::ucb::NumberedSortingInfo >& rSortInfo,
+ ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XAnyCompareFactory > rAnyCompareFactory,
+ ResultSetInclude eMode = INCLUDE_FOLDERS_AND_DOCUMENTS )
+ throw( ::com::sun::star::ucb::CommandAbortedException,
+ ::com::sun::star::uno::RuntimeException,
+ ::com::sun::star::uno::Exception );
+
/**
* This methods gives read access to the content stream of a content (i.e
* the content of a file located at the local file system).
diff --git a/ucbhelper/source/client/content.cxx b/ucbhelper/source/client/content.cxx
index 6519e550401f..5727915ebd8d 100644
--- a/ucbhelper/source/client/content.cxx
+++ b/ucbhelper/source/client/content.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: content.cxx,v $
*
- * $Revision: 1.19 $
+ * $Revision: 1.20 $
*
- * last change: $Author: mba $ $Date: 2001-11-27 11:07:18 $
+ * last change: $Author: mav $ $Date: 2002-01-11 18:06:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -133,6 +133,9 @@
#ifndef _COM_SUN_STAR_UCB_XDYNAMICRESULTSET_HPP_
#include <com/sun/star/ucb/XDynamicResultSet.hpp>
#endif
+#ifndef _COM_SUN_STAR_UCB_XSORTEDDYNAMICRESULTSETFACTORY_HPP_
+#include <com/sun/star/ucb/XSortedDynamicResultSetFactory.hpp>
+#endif
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSETINFO_HPP_
#include <com/sun/star/beans/XPropertySetInfo.hpp>
#endif
@@ -251,6 +254,7 @@ public:
Reference< XContent > getContent() const { return m_xContent; }
Reference< XCommandProcessor > getCommandProcessor();
sal_Int32 getCommandId();
+ Reference< XMultiServiceFactory > getServiceManager() { return m_xSMgr; }
Any executeCommand( const Command& rCommand );
void abortCommand();
@@ -859,9 +863,8 @@ void Content::abortCommand()
}
//=========================================================================
-Reference< XResultSet > Content::createCursor(
- const Sequence< rtl::OUString >& rPropertyNames,
- ResultSetInclude eMode )
+Any Content::createCursorAny( const Sequence< rtl::OUString >& rPropertyNames,
+ ResultSetInclude eMode )
throw( CommandAbortedException, RuntimeException, Exception )
{
sal_Int32 nCount = rPropertyNames.getLength();
@@ -889,34 +892,12 @@ Reference< XResultSet > Content::createCursor(
aCommand.Handle = -1; // n/a
aCommand.Argument <<= aArg;
- Any aResult = m_xImpl->executeCommand( aCommand );
-
- Reference< XDynamicResultSet > xDynSet;
- Reference< XResultSet > xStaticSet;
-
- aResult >>= xDynSet;
- if ( xDynSet.is() )
- xStaticSet = xDynSet->getStaticResultSet();
-
- OSL_ENSURE( xStaticSet.is(), "Content::createCursor - no cursor!" );
-
- if ( !xStaticSet.is() )
- {
- // Former, the open command directly returned a XResultSet.
- aResult >>= xStaticSet;
-
- OSL_ENSURE( !xStaticSet.is(),
- "Content::createCursor - open-Command must "
- "return a Reference< XDynnamicResultSet >!" );
- }
-
- return xStaticSet;
+ return m_xImpl->executeCommand( aCommand );
}
//=========================================================================
-Reference< XResultSet > Content::createCursor(
- const Sequence< sal_Int32 >& rPropertyHandles,
- ResultSetInclude eMode )
+Any Content::createCursorAny( const Sequence< sal_Int32 >& rPropertyHandles,
+ ResultSetInclude eMode )
throw( CommandAbortedException, RuntimeException, Exception )
{
sal_Int32 nCount = rPropertyHandles.getLength();
@@ -944,28 +925,67 @@ Reference< XResultSet > Content::createCursor(
aCommand.Handle = -1; // n/a
aCommand.Argument <<= aArg;
- Any aResult = m_xImpl->executeCommand( aCommand );
+ return m_xImpl->executeCommand( aCommand );
+}
+
+//=========================================================================
+Reference< XResultSet > Content::createCursor(
+ const Sequence< rtl::OUString >& rPropertyNames,
+ ResultSetInclude eMode )
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ Any aCursorAny = createCursorAny( rPropertyNames, eMode );
Reference< XDynamicResultSet > xDynSet;
- Reference< XResultSet > xStaticSet;
+ Reference< XResultSet > aResult;
- aResult >>= xDynSet;
+ aCursorAny >>= xDynSet;
if ( xDynSet.is() )
- xStaticSet = xDynSet->getStaticResultSet();
+ aResult = xDynSet->getStaticResultSet();
- OSL_ENSURE( xStaticSet.is(), "Content::createCursor - no cursor!" );
+ OSL_ENSURE( aResult.is(), "Content::createCursor - no cursor!" );
- if ( !xStaticSet.is() )
+ if ( !aResult.is() )
{
// Former, the open command directly returned a XResultSet.
- aResult >>= xStaticSet;
+ aCursorAny >>= aResult;
- OSL_ENSURE( !xStaticSet.is(),
+ OSL_ENSURE( !aResult.is(),
"Content::createCursor - open-Command must "
"return a Reference< XDynnamicResultSet >!" );
}
- return xStaticSet;
+ return aResult;
+}
+
+//=========================================================================
+Reference< XResultSet > Content::createCursor(
+ const Sequence< sal_Int32 >& rPropertyHandles,
+ ResultSetInclude eMode )
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ Any aCursorAny = createCursorAny( rPropertyHandles, eMode );
+
+ Reference< XDynamicResultSet > xDynSet;
+ Reference< XResultSet > aResult;
+
+ aCursorAny >>= xDynSet;
+ if ( xDynSet.is() )
+ aResult = xDynSet->getStaticResultSet();
+
+ OSL_ENSURE( aResult.is(), "Content::createCursor - no cursor!" );
+
+ if ( !aResult.is() )
+ {
+ // Former, the open command directly returned a XResultSet.
+ aCursorAny >>= aResult;
+
+ OSL_ENSURE( !aResult.is(),
+ "Content::createCursor - open-Command must "
+ "return a Reference< XDynnamicResultSet >!" );
+ }
+
+ return aResult;
}
//=========================================================================
@@ -974,79 +994,206 @@ Reference< XDynamicResultSet > Content::createDynamicCursor(
ResultSetInclude eMode )
throw( CommandAbortedException, RuntimeException, Exception )
{
- sal_Int32 nCount = rPropertyNames.getLength();
- Sequence< Property > aProps( nCount );
- Property* pProps = aProps.getArray();
- const rtl::OUString* pNames = rPropertyNames.getConstArray();
- for ( sal_Int32 n = 0; n < nCount; ++n )
+ Reference< XDynamicResultSet > aResult;
+ createCursorAny( rPropertyNames, eMode ) >>= aResult;
+
+ OSL_ENSURE( aResult.is(), "Content::createDynamicCursor - no cursor!" );
+
+ return aResult;
+}
+
+//=========================================================================
+Reference< XDynamicResultSet > Content::createDynamicCursor(
+ const Sequence< sal_Int32 >& rPropertyHandles,
+ ResultSetInclude eMode )
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ Reference< XDynamicResultSet > aResult;
+ createCursorAny( rPropertyHandles, eMode ) >>= aResult;
+
+ OSL_ENSURE( aResult.is(), "Content::createDynamicCursor - no cursor!" );
+
+ return aResult;
+}
+
+//=========================================================================
+Reference< XDynamicResultSet > Content::createSortedDynamicCursor(
+ const Sequence< rtl::OUString >& rPropertyNames,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::ucb::NumberedSortingInfo >& rSortInfo,
+ Reference< XAnyCompareFactory > rAnyCompareFactory,
+ ResultSetInclude eMode )
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ Reference< XDynamicResultSet > aResult;
+ Reference< XDynamicResultSet > aOrigCursor = createDynamicCursor( rPropertyNames, eMode );
+
+ if( aOrigCursor.is() )
{
- Property& rProp = pProps[ n ];
- rProp.Name = pNames[ n ];
- rProp.Handle = -1; // n/a
- }
+ Reference< XMultiServiceFactory > aServiceManager = m_xImpl->getServiceManager();
- OpenCommandArgument2 aArg;
- aArg.Mode = ( eMode == INCLUDE_FOLDERS_ONLY )
- ? OpenMode::FOLDERS
- : ( eMode == INCLUDE_DOCUMENTS_ONLY )
- ? OpenMode::DOCUMENTS : OpenMode::ALL;
- aArg.Priority = 0; // unused
- aArg.Sink = Reference< XInterface >(); // unused
- aArg.Properties = aProps;
+ if( aServiceManager.is() )
+ {
+ Reference< XSortedDynamicResultSetFactory > aSortFactory( aServiceManager->createInstance(
+ rtl::OUString::createFromAscii( "com.sun.star.ucb.SortedDynamicResultSetFactory" )),
+ UNO_QUERY );
- Command aCommand;
- aCommand.Name = rtl::OUString::createFromAscii( "open" );
- aCommand.Handle = -1; // n/a
- aCommand.Argument <<= aArg;
+ aResult = aSortFactory->createSortedDynamicResultSet( aOrigCursor,
+ rSortInfo,
+ rAnyCompareFactory );
+ }
- Reference< XDynamicResultSet > xSet;
- m_xImpl->executeCommand( aCommand ) >>= xSet;
+ OSL_ENSURE( aResult.is(), "Content::createSortedDynamicCursor - no sorted cursor!\n" );
- OSL_ENSURE( xSet.is(), "Content::createDynamicCursor - no cursor!" );
+ if( !aResult.is() )
+ aResult = aOrigCursor;
+ }
- return xSet;
+ return aResult;
}
//=========================================================================
-Reference< XDynamicResultSet > Content::createDynamicCursor(
+Reference< XDynamicResultSet > Content::createSortedDynamicCursor(
const Sequence< sal_Int32 >& rPropertyHandles,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::ucb::NumberedSortingInfo >& rSortInfo,
+ Reference< XAnyCompareFactory > rAnyCompareFactory,
ResultSetInclude eMode )
throw( CommandAbortedException, RuntimeException, Exception )
{
- sal_Int32 nCount = rPropertyHandles.getLength();
- Sequence< Property > aProps( nCount );
- Property* pProps = aProps.getArray();
- const sal_Int32* pHandles = rPropertyHandles.getConstArray();
- for ( sal_Int32 n = 0; n < nCount; ++n )
+ Reference< XDynamicResultSet > aResult;
+ Reference< XDynamicResultSet > aOrigCursor = createDynamicCursor( rPropertyHandles, eMode );
+
+ if( aOrigCursor.is() )
{
- Property& rProp = pProps[ n ];
- rProp.Name = rtl::OUString(); // n/a
- rProp.Handle = pHandles[ n ];
+ Reference< XMultiServiceFactory > aServiceManager = m_xImpl->getServiceManager();
+
+ if( aServiceManager.is() )
+ {
+ Reference< XSortedDynamicResultSetFactory > aSortFactory( aServiceManager->createInstance(
+ rtl::OUString::createFromAscii( "com.sun.star.ucb.SortedDynamicResultSetFactory" )),
+ UNO_QUERY );
+
+ aResult = aSortFactory->createSortedDynamicResultSet( aOrigCursor,
+ rSortInfo,
+ rAnyCompareFactory );
+ }
+
+ OSL_ENSURE( aResult.is(), "Content::createSortedDynamicCursor - no sorted cursor!\n" );
+
+ if( !aResult.is() )
+ aResult = aOrigCursor;
}
- OpenCommandArgument2 aArg;
- aArg.Mode = ( eMode == INCLUDE_FOLDERS_ONLY )
- ? OpenMode::FOLDERS
- : ( eMode == INCLUDE_DOCUMENTS_ONLY )
- ? OpenMode::DOCUMENTS : OpenMode::ALL;
- aArg.Priority = 0; // unused
- aArg.Sink = Reference< XInterface >(); // unused
- aArg.Properties = aProps;
+ return aResult;
+}
- Command aCommand;
- aCommand.Name = rtl::OUString::createFromAscii( "open" );
- aCommand.Handle = -1; // n/a
- aCommand.Argument <<= aArg;
+//=========================================================================
+Reference< XResultSet > Content::createSortedCursor(
+ const Sequence< rtl::OUString >& rPropertyNames,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::ucb::NumberedSortingInfo >& rSortInfo,
+ Reference< XAnyCompareFactory > rAnyCompareFactory,
+ ResultSetInclude eMode )
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ Reference< XResultSet > aResult;
+ Reference< XDynamicResultSet > aDynSet;
- Reference< XDynamicResultSet > xSet;
- m_xImpl->executeCommand( aCommand ) >>= xSet;
+ Any aCursorAny = createCursorAny( rPropertyNames, eMode );
- OSL_ENSURE( xSet.is(), "Content::createDynamicCursor - no cursor!" );
+ aCursorAny >>= aDynSet;
- return xSet;
+ if( aDynSet.is() )
+ {
+ Reference< XDynamicResultSet > aDynResult;
+ Reference< XMultiServiceFactory > aServiceManager = m_xImpl->getServiceManager();
+
+ if( aServiceManager.is() )
+ {
+ Reference< XSortedDynamicResultSetFactory > aSortFactory( aServiceManager->createInstance(
+ rtl::OUString::createFromAscii( "com.sun.star.ucb.SortedDynamicResultSetFactory" )),
+ UNO_QUERY );
+
+ aDynResult = aSortFactory->createSortedDynamicResultSet( aDynSet,
+ rSortInfo,
+ rAnyCompareFactory );
+ }
+
+ OSL_ENSURE( aDynResult.is(), "Content::createSortedCursor - no sorted cursor!\n" );
+
+ if( aDynResult.is() )
+ aResult = aDynResult->getStaticResultSet();
+ else
+ aResult = aDynSet->getStaticResultSet();
+ }
+
+ OSL_ENSURE( aResult.is(), "Content::createSortedCursor - no cursor!" );
+
+ if ( !aResult.is() )
+ {
+ // Former, the open command directly returned a XResultSet.
+ aCursorAny >>= aResult;
+
+ OSL_ENSURE( !aResult.is(),
+ "Content::createCursor - open-Command must "
+ "return a Reference< XDynnamicResultSet >!" );
+ }
+
+ return aResult;
}
//=========================================================================
+Reference< XResultSet > Content::createSortedCursor(
+ const Sequence< sal_Int32 >& rPropertyHandles,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::ucb::NumberedSortingInfo >& rSortInfo,
+ Reference< XAnyCompareFactory > rAnyCompareFactory,
+ ResultSetInclude eMode )
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ Reference< XResultSet > aResult;
+ Reference< XDynamicResultSet > aDynSet;
+
+ Any aCursorAny = createCursorAny( rPropertyHandles, eMode );
+
+ aCursorAny >>= aDynSet;
+
+ if( aDynSet.is() )
+ {
+ Reference< XDynamicResultSet > aDynResult;
+ Reference< XMultiServiceFactory > aServiceManager = m_xImpl->getServiceManager();
+
+ if( aServiceManager.is() )
+ {
+ Reference< XSortedDynamicResultSetFactory > aSortFactory( aServiceManager->createInstance(
+ rtl::OUString::createFromAscii( "com.sun.star.ucb.SortedDynamicResultSetFactory" )),
+ UNO_QUERY );
+
+ aDynResult = aSortFactory->createSortedDynamicResultSet( aDynSet,
+ rSortInfo,
+ rAnyCompareFactory );
+ }
+
+ OSL_ENSURE( aDynResult.is(), "Content::createSortedCursor - no sorted cursor!\n" );
+
+ if( aDynResult.is() )
+ aResult = aDynResult->getStaticResultSet();
+ else
+ aResult = aDynSet->getStaticResultSet();
+ }
+
+ OSL_ENSURE( aResult.is(), "Content::createSortedCursor - no cursor!" );
+
+ if ( !aResult.is() )
+ {
+ // Former, the open command directly returned a XResultSet.
+ aCursorAny >>= aResult;
+
+ OSL_ENSURE( !aResult.is(),
+ "Content::createCursor - open-Command must "
+ "return a Reference< XDynnamicResultSet >!" );
+ }
+
+ return aResult;
+}
+//=========================================================================
Reference< XInputStream > Content::openStream()
throw( CommandAbortedException, RuntimeException, Exception )
{