summaryrefslogtreecommitdiff
path: root/dbaccess
diff options
context:
space:
mode:
authorFrank Schönheit <fs@openoffice.org>2001-08-02 14:25:55 +0000
committerFrank Schönheit <fs@openoffice.org>2001-08-02 14:25:55 +0000
commita714952651fe7aa4bd8bd0e23b4be48f573ab2e4 (patch)
tree71eae081b8bb78a7561fad871b86ed5bf919e2a1 /dbaccess
parent1b79af16250570c4f29d985a2bd6773f6eed9e73 (diff)
#90525# oursourced the non-HTML and non-RTF stuff in a base classs in SVX
Diffstat (limited to 'dbaccess')
-rw-r--r--dbaccess/source/ui/browser/dbexchange.cxx219
-rw-r--r--dbaccess/source/ui/inc/dbexchange.hxx35
2 files changed, 34 insertions, 220 deletions
diff --git a/dbaccess/source/ui/browser/dbexchange.cxx b/dbaccess/source/ui/browser/dbexchange.cxx
index 234b9142c524..d1ea6b97e04a 100644
--- a/dbaccess/source/ui/browser/dbexchange.cxx
+++ b/dbaccess/source/ui/browser/dbexchange.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: dbexchange.cxx,v $
*
- * $Revision: 1.15 $
+ * $Revision: 1.16 $
*
- * last change: $Author: oj $ $Date: 2001-07-05 12:46:52 $
+ * last change: $Author: fs $ $Date: 2001-08-02 15:25:55 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -106,162 +106,27 @@ namespace dbaui
const ::rtl::OUString& _rCommand,
const Reference< XConnection >& _rxConnection,
const Reference< XNumberFormatter >& _rxFormatter,
- const Reference< XMultiServiceFactory >& _rxORB,
- const sal_Int32 _nFormats)
- :m_pHtml(NULL)
+ const Reference< XMultiServiceFactory >& _rxORB)
+ :ODataAccessObjectTransferable( _rDatasource, _nCommandType, _rCommand, _rxConnection )
+ ,m_pHtml(NULL)
,m_pRtf(NULL)
- ,m_nObjectType(CommandType::TABLE)
- ,m_nFormats(_nFormats)
{
- // build the descriptor (the property sequence)
- ODataAccessDescriptor aDescriptor;
- aDescriptor[daDataSource] <<= _rDatasource;
- aDescriptor[daConnection] <<= _rxConnection;
- aDescriptor[daCommand] <<= _rCommand;
- aDescriptor[daCommandType] <<= _nCommandType;
- m_aSeq = aDescriptor.createPropertyValueSequence();
+ Sequence< PropertyValue > aProps = getDescriptor().createPropertyValueSequence();
+ m_pHtml = new OHTMLImportExport(aProps, _rxORB, _rxFormatter);
+ m_xHtml = m_pHtml;
- // calculate some stuff which helps us providing the different formats
- if (DCF_OBJECT_DESCRIPTOR == (m_nFormats & DCF_OBJECT_DESCRIPTOR))
- {
- // extract the single values from the sequence
- ::rtl::OUString sDatasourceName;
- ::rtl::OUString sObjectName;
- sal_Bool bEscapeProcessing = sal_True;
- sDatasourceName = _rDatasource;
- m_nObjectType = _nCommandType;
- sObjectName = _rCommand;
-
- // for compatibility: create a string which can be used for the SOT_FORMATSTR_ID_SBA_DATAEXCHANGE format
-
- sal_Bool bTreatAsStatement = (CommandType::COMMAND == m_nObjectType);
- // statements are - in this old and ugly format - described as queries
-
- const sal_Unicode cSeparator = sal_Unicode(11);
- const ::rtl::OUString sSeparator(&cSeparator, 1);
-
- const sal_Unicode cTableMark = '1';
- const sal_Unicode cQueryMark = '0';
-
- // build the descriptor string
- m_sCompatibleObjectDescription += sDatasourceName;
- m_sCompatibleObjectDescription += sSeparator;
- m_sCompatibleObjectDescription += bTreatAsStatement ? ::rtl::OUString() : sObjectName;
- m_sCompatibleObjectDescription += sSeparator;
- switch (m_nObjectType)
- {
- case CommandType::TABLE:
- m_sCompatibleObjectDescription += ::rtl::OUString(&cTableMark, 1);
- break;
- case CommandType::QUERY:
- m_sCompatibleObjectDescription += ::rtl::OUString(&cQueryMark, 1);
- break;
- case CommandType::COMMAND:
- m_sCompatibleObjectDescription += ::rtl::OUString(&cQueryMark, 1);
- // think of it as a query
- break;
- }
- m_sCompatibleObjectDescription += sSeparator;
- m_sCompatibleObjectDescription += bTreatAsStatement ? sObjectName : ::rtl::OUString();
- m_sCompatibleObjectDescription += sSeparator;
- }
-
- if (DCF_HTML_TABLE == (m_nFormats & DCF_HTML_TABLE))
- {
- m_pHtml = new OHTMLImportExport(m_aSeq, _rxORB, _rxFormatter);
- m_xHtml = m_pHtml;
- }
-
- if (DCF_RTF_TABLE == (m_nFormats & DCF_RTF_TABLE))
- {
- m_pRtf = new ORTFImportExport(m_aSeq, _rxORB, _rxFormatter);
- m_xRtf = m_pRtf;
- }
+ m_pRtf = new ORTFImportExport(aProps, _rxORB, _rxFormatter);
+ m_xRtf = m_pRtf;
}
// -----------------------------------------------------------------------------
- ODataClipboard::ODataClipboard(const Reference< XPropertySet >& _rxLivingForm, const Reference< XSQLQueryComposer >& _rxComposer)
- :m_pHtml(NULL)
+ ODataClipboard::ODataClipboard(const Reference< XPropertySet >& _rxLivingForm, const Sequence< Any >& _rSelectedRows)
+ :ODataAccessObjectTransferable( _rxLivingForm )
+ ,m_pHtml(NULL)
,m_pRtf(NULL)
- ,m_nObjectType(CommandType::TABLE)
- ,m_nFormats(DCF_OBJECT_DESCRIPTOR)
- {
- // collect some properties of the form
- ::rtl::OUString sDatasourceName;
- sal_Int32 nObjectType = CommandType::COMMAND;
- ::rtl::OUString sObjectName;
- try
- {
- _rxLivingForm->getPropertyValue(PROPERTY_COMMANDTYPE) >>= nObjectType;
- _rxLivingForm->getPropertyValue(PROPERTY_COMMAND) >>= sObjectName;
- _rxLivingForm->getPropertyValue(PROPERTY_DATASOURCENAME) >>= sDatasourceName;
- }
- catch(Exception&)
- {
- OSL_ENSURE(sal_False, "ODataClipboard::ODataClipboard: could not collect essential form attributes !");
- m_nFormats = 0;
- return;
- }
-
- sal_Bool bIsStatement = CommandType::COMMAND == nObjectType;
- String sObjectKind = (CommandType::TABLE == nObjectType) ? String('1') : String('0');
-
- // check if the SQL-statement is modified
- sal_Bool bHasFilterOrSort(sal_False);
- ::rtl::OUString sCompleteStatement;
- try
- {
- ::rtl::OUString sFilter;
- if (::cppu::any2bool(_rxLivingForm->getPropertyValue(PROPERTY_APPLYFILTER)))
- _rxLivingForm->getPropertyValue(PROPERTY_FILTER) >>= sFilter;
- ::rtl::OUString sSort;
- _rxLivingForm->getPropertyValue(PROPERTY_ORDER) >>= sSort;
- bHasFilterOrSort = (sFilter.getLength()>0) || (sSort.getLength()>0);
-
- _rxLivingForm->getPropertyValue(PROPERTY_ACTIVECOMMAND) >>= sCompleteStatement;
- if (_rxComposer.is())
- {
- _rxComposer->setQuery(sCompleteStatement);
- _rxComposer->setFilter(sFilter);
- _rxComposer->setOrder(sSort);
- sCompleteStatement = _rxComposer->getComposedQuery();
- }
- }
- catch(Exception&)
- {
- OSL_ENSURE(sal_False, "ODataClipboard::ODataClipboard: could not collect essential form attributes (part two) !");
- m_nFormats = 0;
- return;
- }
-
- // build the object description (as string)
- const sal_Unicode cSeparator(11);
- const ::rtl::OUString sSeparator(&cSeparator, 1);
-
- m_sCompatibleObjectDescription = sDatasourceName;
- m_sCompatibleObjectDescription += sSeparator;
- m_sCompatibleObjectDescription += bIsStatement ? ::rtl::OUString() : sObjectName;
- m_sCompatibleObjectDescription += sSeparator;
- m_sCompatibleObjectDescription += sObjectKind;
- m_sCompatibleObjectDescription += sSeparator;
- m_sCompatibleObjectDescription +=
- (CommandType::QUERY == nObjectType) && !bHasFilterOrSort
- ? ::rtl::OUString()
- : sCompleteStatement;
- // compatibility says : always add the statement, but don't if it is a "pure" query
- m_sCompatibleObjectDescription += sSeparator;
- }
-
- // -----------------------------------------------------------------------------
- void ODataClipboard::addRow(sal_Int32 _nRow)
{
- OSL_ENSURE(m_nFormats & DCF_OBJECT_DESCRIPTOR, "ODataClipboard::addRow: don't have this (object descriptor) format!");
-
- const sal_Unicode cSeparator(11);
- const ::rtl::OUString sSeparator(&cSeparator, 1);
-
- m_sCompatibleObjectDescription += ::rtl::OUString::valueOf((sal_Int32)_nRow);
- m_sCompatibleObjectDescription += sSeparator;
+ getDescriptor()[daSelection] <<= _rSelectedRows;
+ addCompatibleSelectionDescription( _rSelectedRows );
}
// -----------------------------------------------------------------------------
@@ -283,42 +148,17 @@ namespace dbaui
void ODataClipboard::AddSupportedFormats()
{
// RTF?
- if (DCF_RTF_TABLE == (m_nFormats & DCF_RTF_TABLE))
+ if (m_pRtf)
AddFormat(SOT_FORMAT_RTF);
// HTML?
- if (DCF_HTML_TABLE == (m_nFormats & DCF_HTML_TABLE))
+ if (m_pHtml)
{
AddFormat(SOT_FORMATSTR_ID_HTML);
AddFormat(SOT_FORMATSTR_ID_HTML_SIMPLE);
}
- // object descriptor?
- if (DCF_OBJECT_DESCRIPTOR == (m_nFormats & DCF_OBJECT_DESCRIPTOR))
- {
- switch (m_nObjectType)
- {
- case CommandType::TABLE:
- AddFormat(SOT_FORMATSTR_ID_DBACCESS_TABLE);
- break;
- case CommandType::QUERY:
- AddFormat(SOT_FORMATSTR_ID_DBACCESS_QUERY);
- break;
- case CommandType::COMMAND:
- AddFormat(SOT_FORMATSTR_ID_DBACCESS_COMMAND);
- break;
- }
-
- sal_Int32 nDescriptorLen = m_sCompatibleObjectDescription.getLength();
- if (nDescriptorLen)
- {
- if (m_sCompatibleObjectDescription.getStr()[nDescriptorLen] == 11)
- m_sCompatibleObjectDescription = m_sCompatibleObjectDescription.copy(0, nDescriptorLen - 1);
-
- if (nDescriptorLen)
- AddFormat(SOT_FORMATSTR_ID_SBA_DATAEXCHANGE);
- }
- }
+ ODataAccessObjectTransferable::AddSupportedFormats();
}
// -----------------------------------------------------------------------------
@@ -329,33 +169,28 @@ namespace dbaui
{
case SOT_FORMAT_RTF:
m_pRtf->initialize();
- return SetObject(m_pRtf,SOT_FORMAT_RTF,rFlavor);
+ return SetObject(m_pRtf, SOT_FORMAT_RTF, rFlavor);
case SOT_FORMATSTR_ID_HTML:
m_pHtml->initialize();
- return SetObject(m_pHtml,SOT_FORMATSTR_ID_HTML,rFlavor);
+ return SetObject(m_pHtml, SOT_FORMATSTR_ID_HTML, rFlavor);
+
case SOT_FORMATSTR_ID_HTML_SIMPLE:
m_pHtml->initialize();
- return SetObject(m_pHtml,SOT_FORMATSTR_ID_HTML_SIMPLE,rFlavor);
-
- case SOT_FORMATSTR_ID_DBACCESS_TABLE:
- case SOT_FORMATSTR_ID_DBACCESS_QUERY:
- case SOT_FORMATSTR_ID_DBACCESS_COMMAND:
- return SetAny(makeAny(m_aSeq), rFlavor);
-
- case SOT_FORMATSTR_ID_SBA_DATAEXCHANGE:
- return SetString(m_sCompatibleObjectDescription, rFlavor);
+ return SetObject(m_pHtml, SOT_FORMATSTR_ID_HTML_SIMPLE, rFlavor);
}
- return sal_False;
+
+ return ODataAccessObjectTransferable::GetData( rFlavor );
}
// -----------------------------------------------------------------------------
void ODataClipboard::ObjectReleased()
{
- m_xHtml = m_xRtf = NULL;
m_pHtml = NULL;
m_pRtf = NULL;
- m_aSeq.realloc(0);
+ m_xHtml = m_xRtf = NULL;
+
+ ODataAccessObjectTransferable::ObjectReleased( );
}
// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/ui/inc/dbexchange.hxx b/dbaccess/source/ui/inc/dbexchange.hxx
index 61147e541149..7f43d0c4983d 100644
--- a/dbaccess/source/ui/inc/dbexchange.hxx
+++ b/dbaccess/source/ui/inc/dbexchange.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: dbexchange.hxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: fs $ $Date: 2001-03-28 15:41:04 $
+ * last change: $Author: fs $ $Date: 2001-08-02 15:25:28 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -79,36 +79,22 @@
#ifndef _CPPUHELPER_IMPLBASE2_HXX_
#include <cppuhelper/implbase2.hxx>
#endif
-#ifndef _TRANSFER_HXX
-#include <svtools/transfer.hxx>
+#ifndef _SVX_DBAEXCHANGE_HXX_
+#include <svx/dbaexchange.hxx>
#endif
namespace dbaui
{
-#define DCF_OBJECT_DESCRIPTOR 0x0001
-#define DCF_HTML_TABLE 0x0002
-#define DCF_RTF_TABLE 0x0004
-#define DCF_ALL DCF_OBJECT_DESCRIPTOR | DCF_HTML_TABLE | DCF_RTF_TABLE
-
class ORTFImportExport;
class OHTMLImportExport;
- class ODataClipboard : public TransferableHelper
+ class ODataClipboard : public ::svx::ODataAccessObjectTransferable
{
- ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > m_aSeq;
::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener> m_xHtml;
::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener> m_xRtf;
OHTMLImportExport* m_pHtml;
ORTFImportExport* m_pRtf;
- sal_Int32 m_nFormats;
-
- sal_Int32 m_nObjectType;
- // the object type as extracted from the property sequence given in the ctor.
- // We need different clipboard formats for queries and tables, so we need this information
- ::rtl::OUString m_sCompatibleObjectDescription;
- // needed to provide a SOT_FORMATSTR_ID_SBA_DATAEXCHANGE format
-
public:
ODataClipboard(
const ::rtl::OUString& _rDatasource,
@@ -116,22 +102,15 @@ namespace dbaui
const ::rtl::OUString& _rCommand,
const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter,
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
- const sal_Int32 _nFormats = DCF_ALL
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
);
/** with this ctor, only the object descriptor format will be provided
*/
ODataClipboard(
const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxLivingForm,
- const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSQLQueryComposer >& _rxComposer
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& _rSelectedRows
);
- // (the query composer could be obtained from the connection which is a property of the form,
- // but for simplity we pass it here .... if somebody needs this class, having a form, but no composer,
- // we can adjust this
-
- /// add a row to the object descriptor
- void addRow(sal_Int32 _nRow);
protected:
virtual void AddSupportedFormats();