include/vcl/sysdata.hxx | 2 ucb/source/cacher/cachedcontentresultset.cxx | 180 +++++++++++++-------------- ucb/source/cacher/cachedcontentresultset.hxx | 3 vcl/headless/svpdummies.cxx | 4 vcl/headless/svpframe.cxx | 4 vcl/inc/headless/svpdummies.hxx | 2 vcl/inc/unx/gtk/gtkobject.hxx | 2 vcl/inc/unx/salframe.h | 2 vcl/inc/unx/salobj.h | 2 vcl/inc/win/salobj.h | 2 vcl/unx/generic/window/salframe.cxx | 4 vcl/unx/generic/window/salobj.cxx | 6 vcl/unx/gtk/window/gtkobject.cxx | 2 vcl/unx/gtk/window/gtksalframe.cxx | 2 14 files changed, 112 insertions(+), 105 deletions(-)
New commits: commit ed87e4c4b09d0f623c350528a4f6a6d049735bd1 Author: Stephan Bergmann <sberg...@redhat.com> Date: Tue Sep 3 23:14:40 2013 +0200 Replace XROW_GETXXX macro with template Change-Id: Ibd476f9a60dcc15be3b330d738faf56781998dfc diff --git a/ucb/source/cacher/cachedcontentresultset.cxx b/ucb/source/cacher/cachedcontentresultset.cxx index 52e7d2f..0c692fd 100644 --- a/ucb/source/cacher/cachedcontentresultset.cxx +++ b/ucb/source/cacher/cachedcontentresultset.cxx @@ -42,74 +42,70 @@ using namespace cppu; #define COMSUNSTARUCBCCRS_DEFAULT_FETCH_SIZE 256 #define COMSUNSTARUCBCCRS_DEFAULT_FETCH_DIRECTION FetchDirection::FORWARD -//-------------------------------------------------------------------------- -//-------------------------------------------------------------------------- -//define for getXXX methods of interface XRow -//-------------------------------------------------------------------------- -//-------------------------------------------------------------------------- +//if you change this function template please pay attention to +//function getObject, where this is similar implemented + +template<typename T> T CachedContentResultSet::rowOriginGet( + T (SAL_CALL css::sdbc::XRow::* f)(sal_Int32), sal_Int32 columnIndex) +{ + impl_EnsureNotDisposed(); + ReacquireableGuard aGuard( m_aMutex ); + sal_Int32 nRow = m_nRow; + sal_Int32 nFetchSize = m_nFetchSize; + sal_Int32 nFetchDirection = m_nFetchDirection; + if( !m_aCache.hasRow( nRow ) ) + { + if( !m_aCache.hasCausedException( nRow ) ) + { + if( !m_xFetchProvider.is() ) + { + OSL_FAIL( "broadcaster was disposed already" ); + throw SQLException(); + } + aGuard.clear(); + if( impl_isForwardOnly() ) + applyPositionToOrigin( nRow ); -//if you change this macro please pay attention to -//function ::getObject, where this is similar implemented - -#define XROW_GETXXX( getXXX, Type ) \ -impl_EnsureNotDisposed(); \ -ReacquireableGuard aGuard( m_aMutex ); \ -sal_Int32 nRow = m_nRow; \ -sal_Int32 nFetchSize = m_nFetchSize; \ -sal_Int32 nFetchDirection = m_nFetchDirection; \ -if( !m_aCache.hasRow( nRow ) ) \ -{ \ - if( !m_aCache.hasCausedException( nRow ) ) \ -{ \ - if( !m_xFetchProvider.is() ) \ - { \ - OSL_FAIL( "broadcaster was disposed already" ); \ - throw SQLException(); \ - } \ - aGuard.clear(); \ - if( impl_isForwardOnly() ) \ - applyPositionToOrigin( nRow ); \ - \ - impl_fetchData( nRow, nFetchSize, nFetchDirection ); \ - } \ - aGuard.reacquire(); \ - if( !m_aCache.hasRow( nRow ) ) \ - { \ - m_bLastReadWasFromCache = sal_False; \ - aGuard.clear(); \ - applyPositionToOrigin( nRow ); \ - impl_init_xRowOrigin(); \ - return m_xRowOrigin->getXXX( columnIndex ); \ - } \ -} \ -const Any& rValue = m_aCache.getAny( nRow, columnIndex );\ -Type aRet = Type(); \ -m_bLastReadWasFromCache = sal_True; \ -m_bLastCachedReadWasNull = !( rValue >>= aRet ); \ -/* Last chance. Try type converter service... */ \ -if ( m_bLastCachedReadWasNull && rValue.hasValue() ) \ -{ \ - Reference< XTypeConverter > xConverter \ - = getTypeConverter(); \ - if ( xConverter.is() ) \ - { \ - try \ - { \ - Any aConvAny = xConverter->convertTo( \ - rValue, \ - getCppuType( static_cast< \ - const Type * >( 0 ) ) ); \ - m_bLastCachedReadWasNull = !( aConvAny >>= aRet ); \ - } \ - catch (const IllegalArgumentException&) \ - { \ - } \ - catch (const CannotConvertException&) \ - { \ - } \ - } \ -} \ -return aRet; + impl_fetchData( nRow, nFetchSize, nFetchDirection ); + } + aGuard.reacquire(); + if( !m_aCache.hasRow( nRow ) ) + { + m_bLastReadWasFromCache = sal_False; + aGuard.clear(); + applyPositionToOrigin( nRow ); + impl_init_xRowOrigin(); + return (m_xRowOrigin.get()->*f)( columnIndex ); + } + } + const Any& rValue = m_aCache.getAny( nRow, columnIndex ); + T aRet = T(); + m_bLastReadWasFromCache = sal_True; + m_bLastCachedReadWasNull = !( rValue >>= aRet ); + /* Last chance. Try type converter service... */ + if ( m_bLastCachedReadWasNull && rValue.hasValue() ) + { + Reference< XTypeConverter > xConverter = getTypeConverter(); + if ( xConverter.is() ) + { + try + { + Any aConvAny = xConverter->convertTo( + rValue, + getCppuType( static_cast< + const T * >( 0 ) ) ); + m_bLastCachedReadWasNull = !( aConvAny >>= aRet ); + } + catch (const IllegalArgumentException&) + { + } + catch (const CannotConvertException&) + { + } + } + } + return aRet; +} //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- @@ -1924,7 +1920,7 @@ OUString SAL_CALL CachedContentResultSet throw( SQLException, RuntimeException ) { - XROW_GETXXX( getString, OUString ); + return rowOriginGet<OUString>(&css::sdbc::XRow::getString, columnIndex); } //virtual @@ -1933,7 +1929,7 @@ sal_Bool SAL_CALL CachedContentResultSet throw( SQLException, RuntimeException ) { - XROW_GETXXX( getBoolean, sal_Bool ); + return rowOriginGet<sal_Bool>(&css::sdbc::XRow::getBoolean, columnIndex); } //virtual @@ -1942,7 +1938,7 @@ sal_Int8 SAL_CALL CachedContentResultSet throw( SQLException, RuntimeException ) { - XROW_GETXXX( getByte, sal_Int8 ); + return rowOriginGet<sal_Int8>(&css::sdbc::XRow::getByte, columnIndex); } //virtual @@ -1951,7 +1947,7 @@ sal_Int16 SAL_CALL CachedContentResultSet throw( SQLException, RuntimeException ) { - XROW_GETXXX( getShort, sal_Int16 ); + return rowOriginGet<sal_Int16>(&css::sdbc::XRow::getShort, columnIndex); } //virtual @@ -1960,7 +1956,7 @@ sal_Int32 SAL_CALL CachedContentResultSet throw( SQLException, RuntimeException ) { - XROW_GETXXX( getInt, sal_Int32 ); + return rowOriginGet<sal_Int32>(&css::sdbc::XRow::getInt, columnIndex); } //virtual @@ -1969,7 +1965,7 @@ sal_Int64 SAL_CALL CachedContentResultSet throw( SQLException, RuntimeException ) { - XROW_GETXXX( getLong, sal_Int64 ); + return rowOriginGet<sal_Int64>(&css::sdbc::XRow::getLong, columnIndex); } //virtual @@ -1978,7 +1974,7 @@ float SAL_CALL CachedContentResultSet throw( SQLException, RuntimeException ) { - XROW_GETXXX( getFloat, float ); + return rowOriginGet<float>(&css::sdbc::XRow::getFloat, columnIndex); } //virtual @@ -1987,7 +1983,7 @@ double SAL_CALL CachedContentResultSet throw( SQLException, RuntimeException ) { - XROW_GETXXX( getDouble, double ); + return rowOriginGet<double>(&css::sdbc::XRow::getDouble, columnIndex); } //virtual @@ -1996,7 +1992,8 @@ Sequence< sal_Int8 > SAL_CALL CachedContentResultSet throw( SQLException, RuntimeException ) { - XROW_GETXXX( getBytes, Sequence< sal_Int8 > ); + return rowOriginGet< css::uno::Sequence<sal_Int8> >( + &css::sdbc::XRow::getBytes, columnIndex); } //virtual @@ -2005,7 +2002,8 @@ Date SAL_CALL CachedContentResultSet throw( SQLException, RuntimeException ) { - XROW_GETXXX( getDate, Date ); + return rowOriginGet<css::util::Date>( + &css::sdbc::XRow::getDate, columnIndex); } //virtual @@ -2014,7 +2012,8 @@ Time SAL_CALL CachedContentResultSet throw( SQLException, RuntimeException ) { - XROW_GETXXX( getTime, Time ); + return rowOriginGet<css::util::Time>( + &css::sdbc::XRow::getTime, columnIndex); } //virtual @@ -2023,7 +2022,8 @@ DateTime SAL_CALL CachedContentResultSet throw( SQLException, RuntimeException ) { - XROW_GETXXX( getTimestamp, DateTime ); + return rowOriginGet<css::util::DateTime>( + &css::sdbc::XRow::getTimestamp, columnIndex); } //virtual @@ -2033,7 +2033,8 @@ Reference< com::sun::star::io::XInputStream > throw( SQLException, RuntimeException ) { - XROW_GETXXX( getBinaryStream, Reference< com::sun::star::io::XInputStream > ); + return rowOriginGet< css::uno::Reference<css::io::XInputStream> >( + &css::sdbc::XRow::getBinaryStream, columnIndex); } //virtual @@ -2043,7 +2044,8 @@ Reference< com::sun::star::io::XInputStream > throw( SQLException, RuntimeException ) { - XROW_GETXXX( getCharacterStream, Reference< com::sun::star::io::XInputStream > ); + return rowOriginGet< css::uno::Reference<css::io::XInputStream> >( + &css::sdbc::XRow::getCharacterStream, columnIndex); } //virtual @@ -2054,8 +2056,8 @@ Any SAL_CALL CachedContentResultSet throw( SQLException, RuntimeException ) { - //if you change this macro please pay attention to - //define XROW_GETXXX, where this is similar implemented + //if you change this function please pay attention to + //function template rowOriginGet, where this is similar implemented ReacquireableGuard aGuard( m_aMutex ); sal_Int32 nRow = m_nRow; @@ -2098,7 +2100,8 @@ Reference< XRef > SAL_CALL CachedContentResultSet throw( SQLException, RuntimeException ) { - XROW_GETXXX( getRef, Reference< XRef > ); + return rowOriginGet< css::uno::Reference<css::sdbc::XRef> >( + &css::sdbc::XRow::getRef, columnIndex); } //virtual @@ -2107,7 +2110,8 @@ Reference< XBlob > SAL_CALL CachedContentResultSet throw( SQLException, RuntimeException ) { - XROW_GETXXX( getBlob, Reference< XBlob > ); + return rowOriginGet< css::uno::Reference<css::sdbc::XBlob> >( + &css::sdbc::XRow::getBlob, columnIndex); } //virtual @@ -2116,7 +2120,8 @@ Reference< XClob > SAL_CALL CachedContentResultSet throw( SQLException, RuntimeException ) { - XROW_GETXXX( getClob, Reference< XClob > ); + return rowOriginGet< css::uno::Reference<css::sdbc::XClob> >( + &css::sdbc::XRow::getClob, columnIndex); } //virtual @@ -2125,7 +2130,8 @@ Reference< XArray > SAL_CALL CachedContentResultSet throw( SQLException, RuntimeException ) { - XROW_GETXXX( getArray, Reference< XArray > ); + return rowOriginGet< css::uno::Reference<css::sdbc::XArray> >( + &css::sdbc::XRow::getArray, columnIndex); } //----------------------------------------------------------------- diff --git a/ucb/source/cacher/cachedcontentresultset.hxx b/ucb/source/cacher/cachedcontentresultset.hxx index 3d3df4b..bcb52ed 100644 --- a/ucb/source/cacher/cachedcontentresultset.hxx +++ b/ucb/source/cacher/cachedcontentresultset.hxx @@ -462,6 +462,9 @@ private: const com::sun::star::uno::Reference< com::sun::star::script::XTypeConverter >& getTypeConverter(); + + template<typename T> T rowOriginGet( + T (SAL_CALL css::sdbc::XRow::* f)(sal_Int32), sal_Int32 columnIndex); }; //========================================================================= commit e561a04792f0ae6fb618132655b7d6d5dd291ee1 Author: Stephan Bergmann <sberg...@redhat.com> Date: Tue Sep 3 22:33:51 2013 +0200 Remove unnecessary SystemChildData -> SystemEnvData define Change-Id: Ifd6763617b9aef45c7301085033b6bbaf9d52e02 diff --git a/include/vcl/sysdata.hxx b/include/vcl/sysdata.hxx index 57b32e3..3cc6aad 100644 --- a/include/vcl/sysdata.hxx +++ b/include/vcl/sysdata.hxx @@ -83,8 +83,6 @@ struct SystemEnvData #endif }; -#define SystemChildData SystemEnvData - // -------------------- // - SystemParentData - // -------------------- diff --git a/vcl/headless/svpdummies.cxx b/vcl/headless/svpdummies.cxx index a8c4eb6..c45076b 100644 --- a/vcl/headless/svpdummies.cxx +++ b/vcl/headless/svpdummies.cxx @@ -26,8 +26,8 @@ SvpSalObject::SvpSalObject() { // fast and easy cross-platform wiping of the data - memset( (void *)&m_aSystemChildData, 0, sizeof( SystemChildData ) ); - m_aSystemChildData.nSize = sizeof( SystemChildData ); + memset( (void *)&m_aSystemChildData, 0, sizeof( SystemEnvData ) ); + m_aSystemChildData.nSize = sizeof( SystemEnvData ); } SvpSalObject::~SvpSalObject() diff --git a/vcl/headless/svpframe.cxx b/vcl/headless/svpframe.cxx index 79b231ff..2ce3074 100644 --- a/vcl/headless/svpframe.cxx +++ b/vcl/headless/svpframe.cxx @@ -80,8 +80,8 @@ SvpSalFrame::SvpSalFrame( SvpSalInstance* pInstance, m_nMaxHeight( 0 ) { // fast and easy cross-platform wiping of the data - memset( (void *)&m_aSystemChildData, 0, sizeof( SystemChildData ) ); - m_aSystemChildData.nSize = sizeof( SystemChildData ); + memset( (void *)&m_aSystemChildData, 0, sizeof( SystemEnvData ) ); + m_aSystemChildData.nSize = sizeof( SystemEnvData ); #ifdef IOS // Nothing #elif defined ANDROID diff --git a/vcl/inc/headless/svpdummies.hxx b/vcl/inc/headless/svpdummies.hxx index 01fc5f7..84cdf0e 100644 --- a/vcl/inc/headless/svpdummies.hxx +++ b/vcl/inc/headless/svpdummies.hxx @@ -30,7 +30,7 @@ class SalGraphics; class SvpSalObject : public SalObject { public: - SystemChildData m_aSystemChildData; + SystemEnvData m_aSystemChildData; SvpSalObject(); virtual ~SvpSalObject(); diff --git a/vcl/inc/unx/gtk/gtkobject.hxx b/vcl/inc/unx/gtk/gtkobject.hxx index df8ec1f2..1690908 100644 --- a/vcl/inc/unx/gtk/gtkobject.hxx +++ b/vcl/inc/unx/gtk/gtkobject.hxx @@ -27,7 +27,7 @@ class GtkSalObject : public SalObject { - SystemChildData m_aSystemData; + SystemEnvData m_aSystemData; GtkWidget* m_pSocket; #if GTK_CHECK_VERSION(3,0,0) cairo_region_t* m_pRegion; diff --git a/vcl/inc/unx/salframe.h b/vcl/inc/unx/salframe.h index 1a58b904..5d31839 100644 --- a/vcl/inc/unx/salframe.h +++ b/vcl/inc/unx/salframe.h @@ -120,7 +120,7 @@ class VCLPLUG_GEN_PUBLIC X11SalFrame : public SalFrame OUString m_sWMClass; - SystemChildData maSystemChildData; + SystemEnvData maSystemChildData; SalI18N_InputContext *mpInputContext; Bool mbInputFocus; diff --git a/vcl/inc/unx/salobj.h b/vcl/inc/unx/salobj.h index 464cd234..96e5570 100644 --- a/vcl/inc/unx/salobj.h +++ b/vcl/inc/unx/salobj.h @@ -60,7 +60,7 @@ private: class VCLPLUG_GEN_PUBLIC X11SalObject : public SalObject { public: - SystemChildData maSystemChildData; + SystemEnvData maSystemChildData; SalFrame* mpParent; XLIB_Window maPrimary; XLIB_Window maSecondary; diff --git a/vcl/inc/win/salobj.h b/vcl/inc/win/salobj.h index 6826872..c0c6df9 100644 --- a/vcl/inc/win/salobj.h +++ b/vcl/inc/win/salobj.h @@ -32,7 +32,7 @@ public: HWND mhWnd; // Window handle HWND mhWndChild; // Child Window handle HWND mhLastFocusWnd; // Child-Window, welches als letztes den Focus hatte - SystemChildData maSysData; // SystemEnvData + SystemEnvData maSysData; // SystemEnvData RGNDATA* mpClipRgnData; // ClipRegion-Data RGNDATA* mpStdClipRgnData; // Cache Standard-ClipRegion-Data RECT* mpNextClipRect; // Naechstes ClipRegion-Rect diff --git a/vcl/unx/generic/window/salframe.cxx b/vcl/unx/generic/window/salframe.cxx index 65bd389..6fe079c 100644 --- a/vcl/unx/generic/window/salframe.cxx +++ b/vcl/unx/generic/window/salframe.cxx @@ -857,10 +857,10 @@ void X11SalFrame::SetExtendedFrameStyle( SalExtStyle nStyle ) } } -const SystemChildData* X11SalFrame::GetSystemData() const +const SystemEnvData* X11SalFrame::GetSystemData() const { X11SalFrame *pFrame = const_cast<X11SalFrame*>(this); - pFrame->maSystemChildData.nSize = sizeof( SystemChildData ); + pFrame->maSystemChildData.nSize = sizeof( SystemEnvData ); pFrame->maSystemChildData.pDisplay = GetXDisplay(); pFrame->maSystemChildData.aWindow = pFrame->GetWindow(); pFrame->maSystemChildData.pSalFrame = pFrame; diff --git a/vcl/unx/generic/window/salobj.cxx b/vcl/unx/generic/window/salobj.cxx index 3026c5c..bc7dfbc 100644 --- a/vcl/unx/generic/window/salobj.cxx +++ b/vcl/unx/generic/window/salobj.cxx @@ -51,7 +51,7 @@ X11SalObject* X11SalObject::CreateObject( SalFrame* pParent, SystemWindowData* p { int error_base, event_base; X11SalObject* pObject = new X11SalObject(); - SystemChildData* pObjData = const_cast<SystemChildData*>(pObject->GetSystemData()); + SystemEnvData* pObjData = const_cast<SystemEnvData*>(pObject->GetSystemData()); if ( ! XShapeQueryExtension( (Display*)pObjData->pDisplay, &event_base, &error_base ) ) @@ -236,7 +236,7 @@ SalClipRegion::UnionClipRegion( long nX, long nY, long nWidth, long nHeight ) X11SalObject::X11SalObject() { - maSystemChildData.nSize = sizeof( SystemChildData ); + maSystemChildData.nSize = sizeof( SystemEnvData ); maSystemChildData.pDisplay = GetGenericData()->GetSalDisplay()->GetDisplay(); maSystemChildData.aWindow = None; maSystemChildData.pSalFrame = 0; @@ -412,7 +412,7 @@ void X11SalObject::GrabFocus() // ----------------------------------------------------------------------- -const SystemChildData* X11SalObject::GetSystemData() const +const SystemEnvData* X11SalObject::GetSystemData() const { return &maSystemChildData; } diff --git a/vcl/unx/gtk/window/gtkobject.cxx b/vcl/unx/gtk/window/gtkobject.cxx index b0fa39a..3ba5b06 100644 --- a/vcl/unx/gtk/window/gtkobject.cxx +++ b/vcl/unx/gtk/window/gtkobject.cxx @@ -52,7 +52,7 @@ GtkSalObject::GtkSalObject( GtkSalFrame* pParent, sal_Bool bShow ) // system data SalDisplay* pDisp = GetGenericData()->GetSalDisplay(); - m_aSystemData.nSize = sizeof( SystemChildData ); + m_aSystemData.nSize = sizeof( SystemEnvData ); m_aSystemData.pDisplay = pDisp->GetDisplay(); m_aSystemData.aWindow = GDK_WINDOW_XWINDOW(widget_get_window(m_pSocket)); m_aSystemData.pSalFrame = NULL; diff --git a/vcl/unx/gtk/window/gtksalframe.cxx b/vcl/unx/gtk/window/gtksalframe.cxx index 44d894d..8eda04a 100644 --- a/vcl/unx/gtk/window/gtksalframe.cxx +++ b/vcl/unx/gtk/window/gtksalframe.cxx @@ -997,7 +997,7 @@ void GtkSalFrame::InitCommon() gtk_widget_realize( m_pWindow ); //system data - m_aSystemData.nSize = sizeof( SystemChildData ); + m_aSystemData.nSize = sizeof( SystemEnvData ); #if !GTK_CHECK_VERSION(3,0,0) GtkSalDisplay* pDisp = GetGtkSalData()->GetGtkDisplay(); m_aSystemData.pDisplay = pDisp->GetDisplay(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits