Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
0175d3d6
Kaydet (Commit)
0175d3d6
authored
Kas 27, 2007
tarafından
Rüdiger Timm
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#i10000# Get changes from CWS dba24c.
üst
e8147a08
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
128 deletions
+59
-128
cachedrowset.cxx
forms/source/component/cachedrowset.cxx
+40
-104
cachedrowset.hxx
forms/source/component/cachedrowset.hxx
+19
-24
No files found.
forms/source/component/cachedrowset.cxx
Dosyayı görüntüle @
0175d3d6
...
@@ -4,9 +4,9 @@
...
@@ -4,9 +4,9 @@
*
*
* $RCSfile: cachedrowset.cxx,v $
* $RCSfile: cachedrowset.cxx,v $
*
*
* $Revision: 1.
2
$
* $Revision: 1.
3
$
*
*
* last change: $Author:
hr $ $Date: 2007-11-01 14:56:14
$
* last change: $Author:
rt $ $Date: 2007-11-27 16:12:56
$
*
*
* The Contents of this file are made available subject to
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
* the terms of GNU Lesser General Public License Version 2.1.
...
@@ -41,9 +41,10 @@
...
@@ -41,9 +41,10 @@
#include "frm_strings.hxx"
#include "frm_strings.hxx"
/** === begin UNO includes === **/
/** === begin UNO includes === **/
#include <com/sun/star/sdb/CommandType.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/sdb/XQueriesSupplier.hpp>
#include <com/sun/star/sdbc/ResultSetType.hpp>
/** === end UNO includes === **/
/** === end UNO includes === **/
#include <tools/diagnose_ex.h>
#include <tools/diagnose_ex.h>
...
@@ -57,17 +58,21 @@ namespace frm
...
@@ -57,17 +58,21 @@ namespace frm
using
::
com
::
sun
::
star
::
uno
::
Reference
;
using
::
com
::
sun
::
star
::
uno
::
Reference
;
using
::
com
::
sun
::
star
::
uno
::
UNO_QUERY
;
using
::
com
::
sun
::
star
::
uno
::
UNO_QUERY
;
using
::
com
::
sun
::
star
::
uno
::
UNO_QUERY_THROW
;
using
::
com
::
sun
::
star
::
uno
::
UNO_QUERY_THROW
;
using
::
com
::
sun
::
star
::
uno
::
UNO_SET_THROW
;
using
::
com
::
sun
::
star
::
uno
::
Exception
;
using
::
com
::
sun
::
star
::
uno
::
Exception
;
using
::
com
::
sun
::
star
::
uno
::
RuntimeException
;
using
::
com
::
sun
::
star
::
uno
::
RuntimeException
;
using
::
com
::
sun
::
star
::
sdbc
::
XRowSet
;
using
::
com
::
sun
::
star
::
sdbc
::
XConnection
;
using
::
com
::
sun
::
star
::
sdbc
::
XConnection
;
using
::
com
::
sun
::
star
::
lang
::
XComponent
;
using
::
com
::
sun
::
star
::
lang
::
XComponent
;
using
::
com
::
sun
::
star
::
beans
::
XPropertySet
;
using
::
com
::
sun
::
star
::
beans
::
XPropertySet
;
using
::
com
::
sun
::
star
::
uno
::
makeAny
;
using
::
com
::
sun
::
star
::
uno
::
makeAny
;
using
::
com
::
sun
::
star
::
sdbc
::
SQLException
;
using
::
com
::
sun
::
star
::
sdbc
::
SQLException
;
using
::
com
::
sun
::
star
::
uno
::
Any
;
using
::
com
::
sun
::
star
::
uno
::
Any
;
using
::
com
::
sun
::
star
::
sdb
::
XQueriesSupplier
;
using
::
com
::
sun
::
star
::
container
::
XNameAccess
;
using
::
com
::
sun
::
star
::
sdbc
::
XResultSet
;
using
::
com
::
sun
::
star
::
sdbc
::
XStatement
;
/** === end UNO using === **/
/** === end UNO using === **/
namespace
CommandType
=
::
com
::
sun
::
star
::
sdb
::
Command
Type
;
namespace
ResultSetType
=
::
com
::
sun
::
star
::
sdbc
::
ResultSet
Type
;
//====================================================================
//====================================================================
//= CachedRowSet_Data
//= CachedRowSet_Data
...
@@ -75,46 +80,22 @@ namespace frm
...
@@ -75,46 +80,22 @@ namespace frm
struct
CachedRowSet_Data
struct
CachedRowSet_Data
{
{
::
comphelper
::
ComponentContext
aContext
;
::
comphelper
::
ComponentContext
aContext
;
::
rtl
::
OUString
sDataSource
;
::
rtl
::
OUString
sCommand
;
::
rtl
::
OUString
sCommand
;
sal_Int32
nCommandType
;
sal_Bool
bEscapeProcessing
;
sal_Bool
bEscapeProcessing
;
Reference
<
XConnection
>
xConnection
;
Reference
<
XConnection
>
xConnection
;
Reference
<
XRowSet
>
xRowSet
;
bool
bStatementDirty
;
bool
bRowSetDirty
;
CachedRowSet_Data
(
const
::
comphelper
::
ComponentContext
&
_rContext
)
CachedRowSet_Data
(
const
::
comphelper
::
ComponentContext
&
_rContext
)
:
aContext
(
_rContext
)
:
aContext
(
_rContext
)
,
sDataSource
()
,
sCommand
()
,
sCommand
()
,
nCommandType
(
CommandType
::
COMMAND
)
,
bEscapeProcessing
(
sal_False
)
,
bEscapeProcessing
(
sal_True
)
,
xConnection
()
,
xConnection
()
,
xRowSet
()
,
bStatementDirty
(
true
)
,
bRowSetDirty
(
true
)
{
{
}
}
};
};
//====================================================================
//= helper
//====================================================================
namespace
{
void
lcl_clearRowSet_throw
(
CachedRowSet_Data
&
_rData
)
{
if
(
!
_rData
.
xRowSet
.
is
()
)
return
;
Reference
<
XComponent
>
xRowSetComp
(
_rData
.
xRowSet
,
UNO_QUERY_THROW
);
xRowSetComp
->
dispose
();
_rData
.
xRowSet
.
clear
();
_rData
.
bRowSetDirty
=
true
;
}
}
//====================================================================
//====================================================================
//= CachedRowSet
//= CachedRowSet
//====================================================================
//====================================================================
...
@@ -130,16 +111,6 @@ namespace frm
...
@@ -130,16 +111,6 @@ namespace frm
dispose
();
dispose
();
}
}
//--------------------------------------------------------------------
void
CachedRowSet
::
setDataSource
(
const
::
rtl
::
OUString
&
_rDataSource
)
{
if
(
m_pData
->
sDataSource
==
_rDataSource
)
return
;
m_pData
->
sDataSource
=
_rDataSource
;
m_pData
->
bRowSetDirty
=
true
;
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
void
CachedRowSet
::
setCommand
(
const
::
rtl
::
OUString
&
_rCommand
)
void
CachedRowSet
::
setCommand
(
const
::
rtl
::
OUString
&
_rCommand
)
{
{
...
@@ -147,17 +118,23 @@ namespace frm
...
@@ -147,17 +118,23 @@ namespace frm
return
;
return
;
m_pData
->
sCommand
=
_rCommand
;
m_pData
->
sCommand
=
_rCommand
;
m_pData
->
b
RowSe
tDirty
=
true
;
m_pData
->
b
Statemen
tDirty
=
true
;
}
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
void
CachedRowSet
::
setCommand
Type
(
const
sal_Int32
_nCommandTyp
e
)
void
CachedRowSet
::
setCommand
FromQuery
(
const
::
rtl
::
OUString
&
_rQueryNam
e
)
{
{
if
(
m_pData
->
nCommandType
==
_nCommandType
)
Reference
<
XQueriesSupplier
>
xSupplyQueries
(
m_pData
->
xConnection
,
UNO_QUERY_THROW
);
return
;
Reference
<
XNameAccess
>
xQueries
(
xSupplyQueries
->
getQueries
(),
UNO_QUERY_THROW
);
Reference
<
XPropertySet
>
xQuery
(
xQueries
->
getByName
(
_rQueryName
),
UNO_QUERY_THROW
);
m_pData
->
nCommandType
=
_nCommandType
;
sal_Bool
bEscapeProcessing
(
sal_False
);
m_pData
->
bRowSetDirty
=
true
;
OSL_VERIFY
(
xQuery
->
getPropertyValue
(
PROPERTY_ESCAPE_PROCESSING
)
>>=
bEscapeProcessing
);
setEscapeProcessing
(
bEscapeProcessing
);
::
rtl
::
OUString
sCommand
;
OSL_VERIFY
(
xQuery
->
getPropertyValue
(
PROPERTY_COMMAND
)
>>=
sCommand
);
setCommand
(
sCommand
);
}
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
...
@@ -167,7 +144,7 @@ namespace frm
...
@@ -167,7 +144,7 @@ namespace frm
return
;
return
;
m_pData
->
bEscapeProcessing
=
_bEscapeProcessing
;
m_pData
->
bEscapeProcessing
=
_bEscapeProcessing
;
m_pData
->
b
RowSe
tDirty
=
true
;
m_pData
->
b
Statemen
tDirty
=
true
;
}
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
...
@@ -177,61 +154,26 @@ namespace frm
...
@@ -177,61 +154,26 @@ namespace frm
return
;
return
;
m_pData
->
xConnection
=
_rxConnection
;
m_pData
->
xConnection
=
_rxConnection
;
m_pData
->
bRowSetDirty
=
true
;
m_pData
->
bStatementDirty
=
true
;
}
//--------------------------------------------------------------------
void
CachedRowSet
::
setDataSource
(
const
Any
&
_rDataSourceValue
)
{
::
rtl
::
OUString
sDataSource
;
OSL_VERIFY
(
_rDataSourceValue
>>=
sDataSource
);
setDataSource
(
sDataSource
);
}
//--------------------------------------------------------------------
void
CachedRowSet
::
setCommand
(
const
Any
&
_rCommandValue
)
{
::
rtl
::
OUString
sCommand
;
OSL_VERIFY
(
_rCommandValue
>>=
sCommand
);
setCommand
(
sCommand
);
}
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
void
CachedRowSet
::
setEscapeProcessing
(
const
Any
&
_rEscapeProcessingValue
)
Reference
<
XResultSet
>
CachedRowSet
::
execute
()
{
sal_Bool
bEscapeProcessing
(
sal_False
);
OSL_VERIFY
(
_rEscapeProcessingValue
>>=
bEscapeProcessing
);
setEscapeProcessing
(
bEscapeProcessing
);
}
//--------------------------------------------------------------------
void
CachedRowSet
::
setConnection
(
const
Any
&
_rConnectionValue
)
{
Reference
<
XConnection
>
xConnection
;
OSL_VERIFY
(
_rConnectionValue
>>=
xConnection
);
setConnection
(
xConnection
);
}
//--------------------------------------------------------------------
void
CachedRowSet
::
execute
()
{
{
Reference
<
XResultSet
>
xResult
;
try
try
{
{
if
(
m_pData
->
bRowSetDirty
)
OSL_PRECOND
(
m_pData
->
xConnection
.
is
(),
"CachedRowSet::execute: how am I expected to do this without a connection?"
);
lcl_clearRowSet_throw
(
*
m_pData
);
if
(
!
m_pData
->
xConnection
.
is
()
)
return
xResult
;
if
(
!
m_pData
->
xRowSet
.
is
()
)
Reference
<
XStatement
>
xStatement
(
m_pData
->
xConnection
->
createStatement
(),
UNO_SET_THROW
);
m_pData
->
aContext
.
createComponent
(
"com.sun.star.sdb.RowSet"
,
m_pData
->
xRowSet
);
Reference
<
XPropertySet
>
xStatementProps
(
xStatement
,
UNO_QUERY_THROW
);
xStatementProps
->
setPropertyValue
(
PROPERTY_ESCAPE_PROCESSING
,
makeAny
(
m_pData
->
bEscapeProcessing
)
);
xStatementProps
->
setPropertyValue
(
PROPERTY_RESULTSET_TYPE
,
makeAny
(
ResultSetType
::
FORWARD_ONLY
)
);
Reference
<
XPropertySet
>
xRowSetProps
(
m_pData
->
xRowSet
,
UNO_QUERY_THROW
);
xResult
.
set
(
xStatement
->
executeQuery
(
m_pData
->
sCommand
),
UNO_SET_THROW
);
xRowSetProps
->
setPropertyValue
(
PROPERTY_DATASOURCE
,
makeAny
(
m_pData
->
sDataSource
)
);
m_pData
->
bStatementDirty
=
false
;
xRowSetProps
->
setPropertyValue
(
PROPERTY_COMMAND
,
makeAny
(
m_pData
->
sCommand
)
);
xRowSetProps
->
setPropertyValue
(
PROPERTY_COMMANDTYPE
,
makeAny
(
m_pData
->
nCommandType
)
);
xRowSetProps
->
setPropertyValue
(
PROPERTY_ESCAPE_PROCESSING
,
makeAny
(
m_pData
->
bEscapeProcessing
)
);
xRowSetProps
->
setPropertyValue
(
PROPERTY_ACTIVE_CONNECTION
,
makeAny
(
m_pData
->
xConnection
)
);
m_pData
->
xRowSet
->
execute
();
m_pData
->
bRowSetDirty
=
false
;
}
}
catch
(
const
SQLException
&
)
catch
(
const
SQLException
&
)
{
{
...
@@ -241,18 +183,13 @@ namespace frm
...
@@ -241,18 +183,13 @@ namespace frm
{
{
DBG_UNHANDLED_EXCEPTION
();
DBG_UNHANDLED_EXCEPTION
();
}
}
return
xResult
;
}
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
bool
CachedRowSet
::
isDirty
()
const
bool
CachedRowSet
::
isDirty
()
const
{
{
return
m_pData
->
bRowSetDirty
;
return
m_pData
->
bStatementDirty
;
}
//--------------------------------------------------------------------
const
Reference
<
XRowSet
>&
CachedRowSet
::
getRowSet
()
const
{
return
m_pData
->
xRowSet
;
}
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
...
@@ -260,7 +197,6 @@ namespace frm
...
@@ -260,7 +197,6 @@ namespace frm
{
{
try
try
{
{
lcl_clearRowSet_throw
(
*
m_pData
);
m_pData
.
reset
(
new
CachedRowSet_Data
(
m_pData
->
aContext
)
);
m_pData
.
reset
(
new
CachedRowSet_Data
(
m_pData
->
aContext
)
);
}
}
catch
(
const
Exception
&
)
catch
(
const
Exception
&
)
...
...
forms/source/component/cachedrowset.hxx
Dosyayı görüntüle @
0175d3d6
...
@@ -4,9 +4,9 @@
...
@@ -4,9 +4,9 @@
*
*
* $RCSfile: cachedrowset.hxx,v $
* $RCSfile: cachedrowset.hxx,v $
*
*
* $Revision: 1.
2
$
* $Revision: 1.
3
$
*
*
* last change: $Author:
hr $ $Date: 2007-11-01 14:56:27
$
* last change: $Author:
rt $ $Date: 2007-11-27 16:13:34
$
*
*
* The Contents of this file are made available subject to
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
* the terms of GNU Lesser General Public License Version 2.1.
...
@@ -37,11 +37,12 @@
...
@@ -37,11 +37,12 @@
#define CACHEDROWSET_HXX
#define CACHEDROWSET_HXX
/** === begin UNO includes === **/
/** === begin UNO includes === **/
#include <com/sun/star/sdbc/XR
ow
Set.hpp>
#include <com/sun/star/sdbc/XR
esult
Set.hpp>
#include <com/sun/star/sdbc/XConnection.hpp>
#include <com/sun/star/sdbc/XConnection.hpp>
/** === end UNO includes === **/
/** === end UNO includes === **/
#include <comphelper/componentcontext.hxx>
#include <comphelper/componentcontext.hxx>
#include <unotools/sharedunocomponent.hxx>
#include <memory>
#include <memory>
...
@@ -54,6 +55,8 @@ namespace frm
...
@@ -54,6 +55,8 @@ namespace frm
//====================================================================
//====================================================================
//= CachedRowSet
//= CachedRowSet
//====================================================================
//====================================================================
/** caches a result set obtained from a SQL statement
*/
class
CachedRowSet
class
CachedRowSet
{
{
public
:
public
:
...
@@ -61,44 +64,36 @@ namespace frm
...
@@ -61,44 +64,36 @@ namespace frm
~
CachedRowSet
();
~
CachedRowSet
();
public
:
public
:
/** executes the
row se
t
/** executes the
statemen
t
Since the class is called <code>CachedRowSet</code>, it will cache the
@return
row set between the calls. If none of the parameters for the row set
the result set produced by the statement. The caller takes ownership of the
changes inbetween, then the row set instance from the previous call will be returned,
given object.
without re-execution.
@throws ::com::sun::star::sdbc::SQLException
@throws ::com::sun::star::sdbc::SQLException
if such an exception is thrown when executing the
<code>XRowSet</code>
if such an exception is thrown when executing the
statement
*/
*/
void
execute
();
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
sdbc
::
XResultSet
>
execute
();
/// determines whether the row set properties are dirty, i.e. have changed since the last call to execute
/// determines whether the row set properties are dirty, i.e. have changed since the last call to execute
bool
isDirty
()
const
;
bool
isDirty
()
const
;
/// disposes the
row set instance,
and frees all associated resources
/// disposes the
instance
and frees all associated resources
void
dispose
();
void
dispose
();
/**
returns the row set represented by this instance
/**
sets the command of a query as command to be executed
If the row set has not been executed before, <NULL/> is returned. If the row set
A connection must have been set before.
properties are dirty, an old (dirty) instance of the <code>XRowSet</code> is returned.
The caller of the method is responsible for preventing those cases.
@throws Exception
*/
*/
const
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
sdbc
::
XRowSet
>&
void
setCommandFromQuery
(
const
::
rtl
::
OUString
&
_rQueryName
);
getRowSet
()
const
;
void
setDataSource
(
const
::
rtl
::
OUString
&
_rDataSource
);
void
setCommand
(
const
::
rtl
::
OUString
&
_rCommand
);
void
setCommand
(
const
::
rtl
::
OUString
&
_rCommand
);
void
setCommandType
(
const
sal_Int32
_nCommandType
);
void
setEscapeProcessing
(
const
sal_Bool
_bEscapeProcessing
);
void
setEscapeProcessing
(
const
sal_Bool
_bEscapeProcessing
);
void
setConnection
(
const
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
sdbc
::
XConnection
>&
_rxConnection
);
void
setConnection
(
const
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
sdbc
::
XConnection
>&
_rxConnection
);
void
setDataSource
(
const
::
com
::
sun
::
star
::
uno
::
Any
&
_rDataSourceValue
);
void
setCommand
(
const
::
com
::
sun
::
star
::
uno
::
Any
&
_rCommandValue
);
void
setEscapeProcessing
(
const
::
com
::
sun
::
star
::
uno
::
Any
&
_rEscapeProcessingValue
);
void
setConnection
(
const
::
com
::
sun
::
star
::
uno
::
Any
&
_rConnectionValue
);
private
:
private
:
::
std
::
auto_ptr
<
CachedRowSet_Data
>
m_pData
;
::
std
::
auto_ptr
<
CachedRowSet_Data
>
m_pData
;
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment