diff options
87 files changed, 2464 insertions, 1209 deletions
diff --git a/connectivity/inc/connectivity/FValue.hxx b/connectivity/inc/connectivity/FValue.hxx index 0821b680277d..4196e8d843d9 100644 --- a/connectivity/inc/connectivity/FValue.hxx +++ b/connectivity/inc/connectivity/FValue.hxx @@ -289,6 +289,10 @@ namespace connectivity } bool operator==(const ORowSetValue& _rRH) const; + bool operator!=(const ORowSetValue& _rRH) const + { + return !( *this == _rRH ); + } sal_Bool isNull() const { diff --git a/connectivity/inc/connectivity/dbtools.hxx b/connectivity/inc/connectivity/dbtools.hxx index 186e2f81b786..493dc2a3802f 100644 --- a/connectivity/inc/connectivity/dbtools.hxx +++ b/connectivity/inc/connectivity/dbtools.hxx @@ -570,12 +570,14 @@ namespace dbtools /** ask the user for parameters if the prepared statement needs some and sets them in the prepared statement @param _xConnection the connection must be able to create <type scope="com::sun::star::sdb">SingleSelectQueryComposer</type>s @param _xPreparedStmt the prepared statement where the parameters could be set when needed + @param _aParametersSet contains which parameters have to asked for and which already have set. */ OOO_DLLPUBLIC_DBTOOLS void askForParameters( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer >& _xComposer, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XParameters>& _xParameters, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection, - const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& _rxHandler); + const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& _rxHandler, + const ::std::bit_vector& _aParametersSet = ::std::bit_vector()); /** call the appropiate set method for the specific sql type @see com::sun::star::sdbc::DataType @param _xParams the parameters where to set the value diff --git a/connectivity/inc/connectivity/sqlnode.hxx b/connectivity/inc/connectivity/sqlnode.hxx index 459ded6158d4..7e9b2df14981 100644 --- a/connectivity/inc/connectivity/sqlnode.hxx +++ b/connectivity/inc/connectivity/sqlnode.hxx @@ -69,7 +69,7 @@ namespace connectivity class OSQLParseNode; class IParseContext; - typedef ::std::vector< OSQLParseNode* > OSQLParseNodes; + typedef ::std::vector< OSQLParseNode* > OSQLParseNodes; enum SQLNodeType {SQL_NODE_RULE, SQL_NODE_LISTRULE, SQL_NODE_COMMALISTRULE, SQL_NODE_KEYWORD, SQL_NODE_COMPARISON, SQL_NODE_NAME, @@ -119,7 +119,7 @@ namespace connectivity { friend class OSQLParser; - OSQLParseNodes m_aChilds; + OSQLParseNodes m_aChildren; OSQLParseNode* m_pParent; // pParent fuer Reuckverkettung im Baum ::rtl::OUString m_aNodeValue; // Token-Name oder leer bei Regeln oder ::rtl::OUString bei // ::rtl::OUString, INT, usw. -Werten @@ -256,7 +256,7 @@ namespace connectivity void setParent(OSQLParseNode* pParseNode) {m_pParent = pParseNode;}; // ChildCount liefert die Anzahl der Kinder eines Knotens - sal_uInt32 count() const {return m_aChilds.size();}; + sal_uInt32 count() const {return m_aChildren.size();}; inline OSQLParseNode* getChild(sal_uInt32 nPos) const; void append(OSQLParseNode* pNewSubTree); @@ -371,7 +371,7 @@ namespace connectivity void setTokenValue(const ::rtl::OUString& rString) { if (isToken()) m_aNodeValue = rString;} // IsLeaf testet ob ein Node ein Blatt ist - sal_Bool isLeaf() const {return m_aChilds.empty();} + sal_Bool isLeaf() const {return m_aChildren.empty();} // negate only a searchcondition, any other rule could cause a gpf static void negateSearchCondition(OSQLParseNode*& pSearchCondition,sal_Bool bNegate=sal_False); @@ -443,10 +443,10 @@ namespace connectivity //----------------------------------------------------------------------------- inline OSQLParseNode* OSQLParseNode::getChild(sal_uInt32 nPos) const { - OSL_ENSURE(nPos < m_aChilds.size(), "Invalid Position"); + OSL_ENSURE(nPos < m_aChildren.size(), "Invalid Position"); - // return m_aChilds[nPos]; - return m_aChilds.at(nPos); + // return m_aChildren[nPos]; + return m_aChildren.at(nPos); } // Utility-Methoden zum Abfragen auf bestimmte Rules, Token oder Punctuation: diff --git a/connectivity/inc/connectivity/sqlparse.hxx b/connectivity/inc/connectivity/sqlparse.hxx index 9f27600f43a3..6ca31d695bd9 100644 --- a/connectivity/inc/connectivity/sqlparse.hxx +++ b/connectivity/inc/connectivity/sqlparse.hxx @@ -46,6 +46,8 @@ #include <com/sun/star/i18n/XLocaleData.hpp> #include "connectivity/IParseContext.hxx" #include "connectivity/dbtoolsdllapi.hxx" +#include <salhelper/singletonref.hxx> +#include <osl/mutex.hxx> #include <map> @@ -112,6 +114,27 @@ namespace connectivity }; //========================================================================== + // OSQLParseNodesContainer + // grabage collection of nodes + //========================================================================== + class OSQLParseNodesContainer + { + ::osl::Mutex m_aMutex; + ::std::vector< OSQLParseNode* > m_aNodes; + public: + OSQLParseNodesContainer(); + ~OSQLParseNodesContainer(); + + void push_back(OSQLParseNode* _pNode); + void erase(OSQLParseNode* _pNode); + bool empty() const; + void clear(); + void clearAndDelete(); + }; + + typedef salhelper::SingletonRef<OSQLParseNodesContainer> OSQLParseNodesGarbageCollector; + + //========================================================================== //= OSQLParser //========================================================================== struct OSQLParser_Data; @@ -130,11 +153,9 @@ namespace connectivity static RuleIDMap s_aReverseRuleIDLookup; static OParseContext s_aDefaultContext; - // parts controled by mutex - // static ::osl::Mutex s_aMutex; - static OSQLScanner* s_pScanner; - static OSQLParseNodes* s_pGarbageCollector; - static sal_Int32 s_nRefCount; + static OSQLScanner* s_pScanner; + static OSQLParseNodesGarbageCollector* s_pGarbageCollector; + static sal_Int32 s_nRefCount; // informations on the current parse action const IParseContext* m_pContext; diff --git a/connectivity/source/commontools/FValue.cxx b/connectivity/source/commontools/FValue.cxx index a6da2b165612..433b5ffc69ec 100644 --- a/connectivity/source/commontools/FValue.cxx +++ b/connectivity/source/commontools/FValue.cxx @@ -35,6 +35,7 @@ #include "connectivity/FValue.hxx" #include "connectivity/CommonTools.hxx" #include <connectivity/dbconversion.hxx> +#include <cppuhelper/extract.hxx> #include <com/sun/star/io/XInputStream.hpp> #include <rtl/logfile.hxx> @@ -1811,15 +1812,17 @@ void ORowSetValue::fill(sal_Int32 _nPos, sal_Int32 _nType, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow>& _xRow) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::fill" ); + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::fill (1)" ); fill(_nPos,_nType,sal_True,_xRow); } + +// ----------------------------------------------------------------------------- void ORowSetValue::fill(sal_Int32 _nPos, sal_Int32 _nType, sal_Bool _bNullable, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow>& _xRow) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::fill" ); + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::fill (2)" ); sal_Bool bReadData = sal_True; switch(_nType) { @@ -1888,7 +1891,8 @@ void ORowSetValue::fill(sal_Int32 _nPos, setTypeKind(DataType::BLOB); break; default: - bReadData = sal_False; + OSL_ENSURE( false, "ORowSetValue::fill: unsupported type!" ); + bReadData = false; break; } if ( bReadData && _bNullable && _xRow->wasNull() ) @@ -1898,7 +1902,7 @@ void ORowSetValue::fill(sal_Int32 _nPos, // ----------------------------------------------------------------------------- void ORowSetValue::fill(const Any& _rValue) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::fill" ); + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::fill (3)" ); switch (_rValue.getValueType().getTypeClass()) { case TypeClass_VOID: @@ -1991,11 +1995,44 @@ void ORowSetValue::fill(const Any& _rValue) setSigned(sal_False); break; } + case TypeClass_ENUM: + { + sal_Int32 enumValue( 0 ); + ::cppu::enum2int( enumValue, _rValue ); + (*this) = enumValue; + } + break; + case TypeClass_SEQUENCE: { Sequence<sal_Int8> aDummy; if ( _rValue >>= aDummy ) (*this) = aDummy; + else + OSL_ENSURE( false, "ORowSetValue::fill: unsupported sequence type!" ); + break; + } + + case TypeClass_STRUCT: + { + ::com::sun::star::util::Date aDate; + ::com::sun::star::util::Time aTime; + ::com::sun::star::util::DateTime aDateTime; + if ( _rValue >>= aDate ) + { + (*this) = aDate; + } + else if ( _rValue >>= aTime ) + { + (*this) = aTime; + } + else if ( _rValue >>= aDateTime ) + { + (*this) = aDateTime; + } + else + OSL_ENSURE( false, "ORowSetValue::fill: unsupported structure!" ); + break; } diff --git a/connectivity/source/commontools/dbmetadata.cxx b/connectivity/source/commontools/dbmetadata.cxx index c68fed6905ce..66d2791c3fce 100644 --- a/connectivity/source/commontools/dbmetadata.cxx +++ b/connectivity/source/commontools/dbmetadata.cxx @@ -297,6 +297,7 @@ namespace dbtools } catch( const Exception& ) { + DBG_UNHANDLED_EXCEPTION(); } try { diff --git a/connectivity/source/commontools/dbtools.cxx b/connectivity/source/commontools/dbtools.cxx index a1847c98d2ab..6730d7beb9ce 100644 --- a/connectivity/source/commontools/dbtools.cxx +++ b/connectivity/source/commontools/dbtools.cxx @@ -1711,13 +1711,63 @@ sal_Bool implSetObject( const Reference< XParameters >& _rxParameters, } //.................................................................. - +namespace +{ + class OParameterWrapper : public ::cppu::WeakImplHelper1< XIndexAccess > + { + ::std::bit_vector m_aSet; + Reference<XIndexAccess> m_xSource; + public: + OParameterWrapper(const ::std::bit_vector& _aSet,const Reference<XIndexAccess>& _xSource) : m_aSet(_aSet),m_xSource(_xSource){} + private: + // ::com::sun::star::container::XElementAccess + virtual Type SAL_CALL getElementType() throw(RuntimeException) + { + return m_xSource->getElementType(); + } + virtual sal_Bool SAL_CALL hasElements( ) throw(RuntimeException) + { + if ( m_aSet.empty() ) + return m_xSource->hasElements(); + return ::std::count(m_aSet.begin(),m_aSet.end(),false) != 0; + } + // ::com::sun::star::container::XIndexAccess + virtual sal_Int32 SAL_CALL getCount( ) throw(RuntimeException) + { + if ( m_aSet.empty() ) + return m_xSource->getCount(); + return ::std::count(m_aSet.begin(),m_aSet.end(),false); + } + virtual Any SAL_CALL getByIndex( sal_Int32 Index ) throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException) + { + if ( m_aSet.empty() ) + return m_xSource->getByIndex(Index); + if ( m_aSet.size() < (size_t)Index ) + throw IndexOutOfBoundsException(); + + ::std::bit_vector::iterator aIter = m_aSet.begin(); + ::std::bit_vector::iterator aEnd = m_aSet.end(); + sal_Int32 i = 0; + sal_Int32 nParamPos = -1; + for(; aIter != aEnd && i <= Index; ++aIter) + { + ++nParamPos; + if ( !*aIter ) + { + ++i; + } + } + return m_xSource->getByIndex(nParamPos); + } + }; +} // ----------------------------------------------------------------------------- void askForParameters(const Reference< XSingleSelectQueryComposer >& _xComposer, const Reference<XParameters>& _xParameters, const Reference< XConnection>& _xConnection, - const Reference< XInteractionHandler >& _rxHandler) + const Reference< XInteractionHandler >& _rxHandler, + const ::std::bit_vector& _aParametersSet) { OSL_ENSURE(_xComposer.is(),"dbtools::askForParameters XSQLQueryComposer is null!"); OSL_ENSURE(_xParameters.is(),"dbtools::askForParameters XParameters is null!"); @@ -1730,7 +1780,7 @@ void askForParameters(const Reference< XSingleSelectQueryComposer >& _xComposer, Reference<XIndexAccess> xParamsAsIndicies = xParameters.is() ? xParameters->getParameters() : Reference<XIndexAccess>(); Reference<XNameAccess> xParamsAsNames(xParamsAsIndicies, UNO_QUERY); sal_Int32 nParamCount = xParamsAsIndicies.is() ? xParamsAsIndicies->getCount() : 0; - if (nParamCount) + if ( (nParamCount && _aParametersSet.empty()) || ::std::count(_aParametersSet.begin(),_aParametersSet.end(),true) != nParamCount ) { // build an interaction request // two continuations (Ok and Cancel) @@ -1738,7 +1788,8 @@ void askForParameters(const Reference< XSingleSelectQueryComposer >& _xComposer, OParameterContinuation* pParams = new OParameterContinuation; // the request ParametersRequest aRequest; - aRequest.Parameters = xParamsAsIndicies; + Reference<XIndexAccess> xWrappedParameters = new OParameterWrapper(_aParametersSet,xParamsAsIndicies); + aRequest.Parameters = xWrappedParameters; aRequest.Connection = _xConnection; OInteractionRequest* pRequest = new OInteractionRequest(makeAny(aRequest)); Reference< XInteractionRequest > xRequest(pRequest); @@ -1762,8 +1813,7 @@ void askForParameters(const Reference< XSingleSelectQueryComposer >& _xComposer, const PropertyValue* pFinalValues = aFinalValues.getConstArray(); for (sal_Int32 i=0; i<aFinalValues.getLength(); ++i, ++pFinalValues) { - Reference< XPropertySet > xParamColumn; - ::cppu::extractInterface(xParamColumn, xParamsAsIndicies->getByIndex(i)); + Reference< XPropertySet > xParamColumn(xWrappedParameters->getByIndex(i),UNO_QUERY); if (xParamColumn.is()) { #ifdef DBG_UTIL @@ -1779,7 +1829,19 @@ void askForParameters(const Reference< XSingleSelectQueryComposer >& _xComposer, if (hasProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE), xParamColumn)) xParamColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)) >>= nScale; // and set the value - _xParameters->setObjectWithInfo(i + 1, pFinalValues->Value, nParamType, nScale); + ::std::bit_vector::const_iterator aIter = _aParametersSet.begin(); + ::std::bit_vector::const_iterator aEnd = _aParametersSet.end(); + sal_Int32 j = 0; + sal_Int32 nParamPos = -1; + for(; aIter != aEnd && j <= i; ++aIter) + { + ++nParamPos; + if ( !*aIter ) + { + ++j; + } + } + _xParameters->setObjectWithInfo(nParamPos + 1, pFinalValues->Value, nParamType, nScale); // (the index of the parameters is one-based) } } diff --git a/connectivity/source/drivers/calc/CDriver.cxx b/connectivity/source/drivers/calc/CDriver.cxx index df3937803190..525ef9596317 100644 --- a/connectivity/source/drivers/calc/CDriver.cxx +++ b/connectivity/source/drivers/calc/CDriver.cxx @@ -91,11 +91,7 @@ Reference< XConnection > SAL_CALL ODriver::connect( const ::rtl::OUString& url, sal_Bool SAL_CALL ODriver::acceptsURL( const ::rtl::OUString& url ) throw(SQLException, RuntimeException) { - if(!url.compareTo(::rtl::OUString::createFromAscii("sdbc:calc:"),10)) - { - return sal_True; - } - return sal_False; + return url.compareTo(::rtl::OUString::createFromAscii("sdbc:calc:"),10) == 0; } Sequence< DriverPropertyInfo > SAL_CALL ODriver::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& /*info*/ ) throw(SQLException, RuntimeException) diff --git a/connectivity/source/drivers/calc/CTable.cxx b/connectivity/source/drivers/calc/CTable.cxx index 2d35c16c11dd..91f917224496 100644 --- a/connectivity/source/drivers/calc/CTable.cxx +++ b/connectivity/source/drivers/calc/CTable.cxx @@ -164,11 +164,11 @@ CellContentType lcl_GetContentOrResultType( const Reference<XCell>& xCell ) CellContentType eCellType = xCell->getType(); if ( eCellType == CellContentType_FORMULA ) { + static const ::rtl::OUString s_sFormulaResultType(RTL_CONSTASCII_USTRINGPARAM("FormulaResultType")); Reference<XPropertySet> xProp( xCell, UNO_QUERY ); try { - static ::rtl::OUString s_FormulaResultType(RTL_CONSTASCII_USTRINGPARAM("FormulaResultType")); - xProp->getPropertyValue( s_FormulaResultType ) >>= eCellType; // type of formula result + xProp->getPropertyValue( s_sFormulaResultType ) >>= eCellType; // type of formula result } catch (UnknownPropertyException&) { @@ -346,101 +346,101 @@ void lcl_SetValue( ORowSetValue& rValue, const Reference<XSpreadsheet>& xSheet, const Reference<XCell> xCell = xSheet->getCellByPosition( nDocColumn, nDocRow ); if ( xCell.is() ) { - if ( DataType::VARCHAR == nType ) + CellContentType eCellType = lcl_GetContentOrResultType( xCell ); + switch (nType) { - // no difference between empty cell and empty string in spreadsheet - const Reference<XText> xText( xCell, UNO_QUERY ); - if ( xText.is() ) - rValue = xText->getString(); - } - else - { - CellContentType eCellType = lcl_GetContentOrResultType( xCell ); - switch (nType) - { - case DataType::DECIMAL: - if ( eCellType == CellContentType_VALUE ) - rValue = xCell->getValue(); // double - else - rValue.setNull(); - break; - case DataType::BIT: - if ( eCellType == CellContentType_VALUE ) - rValue = (sal_Bool)( xCell->getValue() != 0.0 ); - else - rValue.setNull(); - break; - case DataType::DATE: - if ( eCellType == CellContentType_VALUE ) - { - ::Date aDate( rNullDate ); - aDate += (long)::rtl::math::approxFloor( xCell->getValue() ); - ::com::sun::star::util::Date aDateStruct( aDate.GetDay(), aDate.GetMonth(), aDate.GetYear() ); - rValue = aDateStruct; - } - else - rValue.setNull(); - break; - case DataType::TIME: - if ( eCellType == CellContentType_VALUE ) + case DataType::VARCHAR: + if ( eCellType == CellContentType_TEXT ) + { + const Reference<XText> xText( xCell, UNO_QUERY ); + if ( xText.is() ) + rValue = xText->getString(); + } // if ( eCellType == CellContentType_TEXT ) + else + rValue.setNull(); + break; + case DataType::DECIMAL: + if ( eCellType == CellContentType_VALUE ) + rValue = xCell->getValue(); // double + else + rValue.setNull(); + break; + case DataType::BIT: + if ( eCellType == CellContentType_VALUE ) + rValue = (sal_Bool)( xCell->getValue() != 0.0 ); + else + rValue.setNull(); + break; + case DataType::DATE: + if ( eCellType == CellContentType_VALUE ) + { + ::Date aDate( rNullDate ); + aDate += (long)::rtl::math::approxFloor( xCell->getValue() ); + ::com::sun::star::util::Date aDateStruct( aDate.GetDay(), aDate.GetMonth(), aDate.GetYear() ); + rValue = aDateStruct; + } + else + rValue.setNull(); + break; + case DataType::TIME: + if ( eCellType == CellContentType_VALUE ) + { + double fCellVal = xCell->getValue(); + double fTime = fCellVal - rtl::math::approxFloor( fCellVal ); + long nIntTime = (long)rtl::math::round( fTime * 8640000.0 ); + if ( nIntTime == 8640000 ) + nIntTime = 0; // 23:59:59.995 and above is 00:00:00.00 + ::com::sun::star::util::Time aTime; + aTime.HundredthSeconds = (sal_uInt16)( nIntTime % 100 ); + nIntTime /= 100; + aTime.Seconds = (sal_uInt16)( nIntTime % 60 ); + nIntTime /= 60; + aTime.Minutes = (sal_uInt16)( nIntTime % 60 ); + nIntTime /= 60; + OSL_ENSURE( nIntTime < 24, "error in time calculation" ); + aTime.Hours = (sal_uInt16) nIntTime; + rValue = aTime; + } + else + rValue.setNull(); + break; + case DataType::TIMESTAMP: + if ( eCellType == CellContentType_VALUE ) + { + double fCellVal = xCell->getValue(); + double fDays = ::rtl::math::approxFloor( fCellVal ); + double fTime = fCellVal - fDays; + long nIntDays = (long)fDays; + long nIntTime = (long)::rtl::math::round( fTime * 8640000.0 ); + if ( nIntTime == 8640000 ) { - double fCellVal = xCell->getValue(); - double fTime = fCellVal - rtl::math::approxFloor( fCellVal ); - long nIntTime = (long)rtl::math::round( fTime * 8640000.0 ); - if ( nIntTime == 8640000 ) - nIntTime = 0; // 23:59:59.995 and above is 00:00:00.00 - ::com::sun::star::util::Time aTime; - aTime.HundredthSeconds = (sal_uInt16)( nIntTime % 100 ); - nIntTime /= 100; - aTime.Seconds = (sal_uInt16)( nIntTime % 60 ); - nIntTime /= 60; - aTime.Minutes = (sal_uInt16)( nIntTime % 60 ); - nIntTime /= 60; - OSL_ENSURE( nIntTime < 24, "error in time calculation" ); - aTime.Hours = (sal_uInt16) nIntTime; - rValue = aTime; + nIntTime = 0; // 23:59:59.995 and above is 00:00:00.00 + ++nIntDays; // (next day) } - else - rValue.setNull(); - break; - case DataType::TIMESTAMP: - if ( eCellType == CellContentType_VALUE ) - { - double fCellVal = xCell->getValue(); - double fDays = ::rtl::math::approxFloor( fCellVal ); - double fTime = fCellVal - fDays; - long nIntDays = (long)fDays; - long nIntTime = (long)::rtl::math::round( fTime * 8640000.0 ); - if ( nIntTime == 8640000 ) - { - nIntTime = 0; // 23:59:59.995 and above is 00:00:00.00 - ++nIntDays; // (next day) - } - ::com::sun::star::util::DateTime aDateTime; + ::com::sun::star::util::DateTime aDateTime; - aDateTime.HundredthSeconds = (sal_uInt16)( nIntTime % 100 ); - nIntTime /= 100; - aDateTime.Seconds = (sal_uInt16)( nIntTime % 60 ); - nIntTime /= 60; - aDateTime.Minutes = (sal_uInt16)( nIntTime % 60 ); - nIntTime /= 60; - OSL_ENSURE( nIntTime < 24, "error in time calculation" ); - aDateTime.Hours = (sal_uInt16) nIntTime; + aDateTime.HundredthSeconds = (sal_uInt16)( nIntTime % 100 ); + nIntTime /= 100; + aDateTime.Seconds = (sal_uInt16)( nIntTime % 60 ); + nIntTime /= 60; + aDateTime.Minutes = (sal_uInt16)( nIntTime % 60 ); + nIntTime /= 60; + OSL_ENSURE( nIntTime < 24, "error in time calculation" ); + aDateTime.Hours = (sal_uInt16) nIntTime; - ::Date aDate( rNullDate ); - aDate += nIntDays; - aDateTime.Day = aDate.GetDay(); - aDateTime.Month = aDate.GetMonth(); - aDateTime.Year = aDate.GetYear(); + ::Date aDate( rNullDate ); + aDate += nIntDays; + aDateTime.Day = aDate.GetDay(); + aDateTime.Month = aDate.GetMonth(); + aDateTime.Year = aDate.GetYear(); - rValue = aDateTime; - } - else - rValue.setNull(); - break; - } // switch (nType) - } + rValue = aDateTime; + } + else + rValue.setNull(); + break; + } // switch (nType) } // rValue.setTypeKind(nType); diff --git a/connectivity/source/drivers/dbase/DDatabaseMetaData.cxx b/connectivity/source/drivers/dbase/DDatabaseMetaData.cxx index 469656bcbf11..bcc734c0e07a 100644 --- a/connectivity/source/drivers/dbase/DDatabaseMetaData.cxx +++ b/connectivity/source/drivers/dbase/DDatabaseMetaData.cxx @@ -87,8 +87,8 @@ Reference< XResultSet > ODbaseDatabaseMetaData::impl_getTypeInfo_throw( ) aRow.reserve(18); aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); - aRow.push_back(new ORowSetValueDecorator(::rtl::OUString::createFromAscii("CHAR"))); - aRow.push_back(new ORowSetValueDecorator(DataType::CHAR)); + aRow.push_back(new ORowSetValueDecorator(::rtl::OUString::createFromAscii("VARCHAR"))); + aRow.push_back(new ORowSetValueDecorator(DataType::VARCHAR)); aRow.push_back(new ORowSetValueDecorator((sal_Int32)254)); aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue()); aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue()); @@ -99,7 +99,7 @@ Reference< XResultSet > ODbaseDatabaseMetaData::impl_getTypeInfo_throw( ) aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); - aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); + aRow.push_back(new ORowSetValueDecorator(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("C")))); aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); @@ -108,23 +108,17 @@ Reference< XResultSet > ODbaseDatabaseMetaData::impl_getTypeInfo_throw( ) aRows.push_back(aRow); - aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("VARCHAR")); - aRow[2] = new ORowSetValueDecorator(DataType::VARCHAR); - aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue(); - aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue(); - aRow[6] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("length")); - aRows.push_back(aRow); - - aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("LONGVARCHAR")); aRow[2] = new ORowSetValueDecorator(DataType::LONGVARCHAR); - aRow[3] = new ORowSetValueDecorator((sal_Int32)65535); + aRow[3] = new ORowSetValueDecorator((sal_Int32)2147483647); aRow[6] = new ORowSetValueDecorator(); + aRow[13] = new ORowSetValueDecorator(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("M"))); aRows.push_back(aRow); aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("DATE")); aRow[2] = new ORowSetValueDecorator(DataType::DATE); aRow[3] = new ORowSetValueDecorator((sal_Int32)10); + aRow[13] = new ORowSetValueDecorator(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("D"))); aRows.push_back(aRow); aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("BOOLEAN")); @@ -134,13 +128,43 @@ Reference< XResultSet > ODbaseDatabaseMetaData::impl_getTypeInfo_throw( ) aRow[5] = ODatabaseMetaDataResultSet::getEmptyValue(); aRow[6] = new ORowSetValueDecorator(::rtl::OUString()); aRow[9] = ODatabaseMetaDataResultSet::getBasicValue(); + aRow[13] = new ORowSetValueDecorator(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("L"))); + aRows.push_back(aRow); + + aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("DOUBLE")); + aRow[2] = new ORowSetValueDecorator(DataType::DOUBLE); + aRow[3] = new ORowSetValueDecorator((sal_Int32)8); + aRow[13] = new ORowSetValueDecorator(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("B"))); + aRows.push_back(aRow); + + aRow[11] = new ORowSetValueDecorator(sal_True); + aRow[13] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("Y")); + aRows.push_back(aRow); + + aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("TIMESTAMP")); + aRow[2] = new ORowSetValueDecorator(DataType::TIMESTAMP); + aRow[11] = new ORowSetValueDecorator(sal_False); + aRow[13] = new ORowSetValueDecorator(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("T"))); + aRows.push_back(aRow); + + aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("INTEGER")); + aRow[2] = new ORowSetValueDecorator(DataType::INTEGER); + aRow[3] = new ORowSetValueDecorator((sal_Int32)10); + aRow[13] = new ORowSetValueDecorator(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("I"))); aRows.push_back(aRow); aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("DECIMAL")); aRow[2] = new ORowSetValueDecorator(DataType::DECIMAL); aRow[3] = new ORowSetValueDecorator((sal_Int32)20); aRow[6] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("length,scale")); - aRow[15] = new ORowSetValueDecorator((sal_Int32)20); + aRow[13] = new ORowSetValueDecorator(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("F"))); + aRows.push_back(aRow); + + aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("NUMERIC")); + aRow[2] = new ORowSetValueDecorator(DataType::DECIMAL); + aRow[3] = new ORowSetValueDecorator((sal_Int32)16); + aRow[13] = new ORowSetValueDecorator(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("N"))); + aRow[15] = new ORowSetValueDecorator((sal_Int32)16); aRows.push_back(aRow); } diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx index 5449235eb739..1c5210bfcdc6 100644 --- a/connectivity/source/drivers/dbase/DTable.cxx +++ b/connectivity/source/drivers/dbase/DTable.cxx @@ -42,8 +42,10 @@ #include <tools/config.hxx> #include "dbase/DIndex.hxx" #include "dbase/DIndexes.hxx" +//#include "file/FDriver.hxx" #include <comphelper/sequence.hxx> #include <svtools/zforlist.hxx> +#include <svtools/syslocale.hxx> #include <rtl/math.hxx> #include <stdio.h> //sprintf #include <ucbhelper/content.hxx> @@ -52,6 +54,7 @@ #include <connectivity/dbconversion.hxx> #include <com/sun/star/lang/DisposedException.hpp> #include <comphelper/property.hxx> +//#include <unotools/calendarwrapper.hxx> #include <unotools/tempfile.hxx> #include <unotools/ucbhelper.hxx> #include <comphelper/types.hxx> @@ -81,15 +84,14 @@ using namespace ::com::sun::star::sdbcx; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::container; using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::i18n; // stored as the Field Descriptor terminator #define FIELD_DESCRIPTOR_TERMINATOR 0x0D #define DBF_EOL 0x1A -//================================================================== namespace { -//================================================================== sal_Int32 lcl_getFileSize(SvStream& _rStream) { sal_Int32 nFileSize = 0; @@ -102,9 +104,123 @@ sal_Int32 lcl_getFileSize(SvStream& _rStream) nFileSize -= 1; return nFileSize; } -//================================================================== +/** + calculates the Julian date +*/ +void lcl_CalcJulDate(sal_Int32& _nJulianDate,sal_Int32& _nJulianTime,const com::sun::star::util::DateTime _aDateTime) +{ + com::sun::star::util::DateTime aDateTime = _aDateTime; + // weird: months fix + if (aDateTime.Month > 12) + { + aDateTime.Month--; + sal_uInt16 delta = _aDateTime.Month / 12; + aDateTime.Year += delta; + aDateTime.Month -= delta * 12; + aDateTime.Month++; + } + + _nJulianTime = ((aDateTime.Hours*3600000)+(aDateTime.Minutes*60000)+(aDateTime.Seconds*1000)+(aDateTime.HundredthSeconds*10)); + /* conversion factors */ + sal_uInt16 iy0; + sal_uInt16 im0; + if ( aDateTime.Month <= 2 ) + { + iy0 = aDateTime.Year - 1; + im0 = aDateTime.Month + 12; + } + else + { + iy0 = aDateTime.Year; + im0 = aDateTime.Month; + } + sal_Int32 ia = iy0 / 100; + sal_Int32 ib = 2 - ia + (ia >> 2); + /* calculate julian date */ + if ( aDateTime.Year <= 0 ) + { + _nJulianDate = (sal_Int32) ((365.25 * iy0) - 0.75) + + (sal_Int32) (30.6001 * (im0 + 1) ) + + aDateTime.Day + 1720994; + } // if ( _aDateTime.Year <= 0 ) + else + { + _nJulianDate = static_cast<sal_Int32>( ((365.25 * iy0) + + (sal_Int32) (30.6001 * (im0 + 1)) + + aDateTime.Day + 1720994)); + } + double JD = _nJulianDate + 0.5; + _nJulianDate = (sal_Int32)( JD + 0.5); + const double gyr = aDateTime.Year + (0.01 * aDateTime.Month) + (0.0001 * aDateTime.Day); + if ( gyr >= 1582.1015 ) /* on or after 15 October 1582 */ + _nJulianDate += ib; +} + +/** + calculates date time from the Julian Date +*/ +void lcl_CalDate(sal_Int32 _nJulianDate,sal_Int32 _nJulianTime,com::sun::star::util::DateTime& _rDateTime) +{ + if ( _nJulianDate ) + { + sal_Int32 ialp; + sal_Int32 ka = _nJulianDate; + if ( _nJulianDate >= 2299161 ) + { + ialp = (sal_Int32)( ((double) _nJulianDate - 1867216.25 ) / ( 36524.25 )); + ka = _nJulianDate + 1 + ialp - ( ialp >> 2 ); + } + sal_Int32 kb = ka + 1524; + sal_Int32 kc = (sal_Int32) ( ((double) kb - 122.1 ) / 365.25 ); + sal_Int32 kd = (sal_Int32) ((double) kc * 365.25); + sal_Int32 ke = (sal_Int32) ((double) ( kb - kd ) / 30.6001 ); + _rDateTime.Day = static_cast<sal_uInt16>(kb - kd - ((sal_Int32) ( (double) ke * 30.6001 ))); + if ( ke > 13 ) + _rDateTime.Month = static_cast<sal_uInt16>(ke - 13); + else + _rDateTime.Month = static_cast<sal_uInt16>(ke - 1); + if ( (_rDateTime.Month == 2) && (_rDateTime.Day > 28) ) + _rDateTime.Day = 29; + if ( (_rDateTime.Month == 2) && (_rDateTime.Day == 29) && (ke == 3) ) + _rDateTime.Year = static_cast<sal_uInt16>(kc - 4716); + else if ( _rDateTime.Month > 2 ) + _rDateTime.Year = static_cast<sal_uInt16>(kc - 4716); + else + _rDateTime.Year = static_cast<sal_uInt16>(kc - 4715); + } // if ( _nJulianDate ) + + if ( _nJulianTime ) + { + double d_s = _nJulianTime / 1000; + double d_m = d_s / 60; + double d_h = d_m / 60; + _rDateTime.Hours = (sal_uInt16) (d_h); + _rDateTime.Minutes = (sal_uInt16) d_m; // integer _aDateTime.Minutes + //// weird: time fix + // int test = (_rDateTime.Hours % 3) * 100 + _rDateTime.Minutes; + //int test_tbl[] = {0, 1, 2, 11, 12, 13, 22, 23, 24, 25, 34, 35, 36, + // 45, 46, 47, 56, 57, 58, 107, 108, 109, 110, 119, 120, 121, + // 130, 131, 132, 141, 142, 143, 152, 153, 154, 155, 204, 205, + // 206, 215, 216, 217, 226, 227, 228, 237, 238, 239, 240, 249, + // 250, 251}; + // for (int i = 0; i < sizeof(test_tbl)/sizeof(test_tbl[0]); i++) + //{ + // if (test == test_tbl[i]) + // { + // // frac += 0.000012; + // //d_hour = frac * 24.0; + // _rDateTime.Hours = (sal_uInt16)d_hour; + // d_minute = (d_hour - (double)_rDateTime.Hours) * 60.0; + // _rDateTime.Minutes = (sal_uInt16)d_minute; + // break; + // } + // } + + _rDateTime.Seconds = static_cast<sal_uInt16>(( d_m - (double) _rDateTime.Minutes ) * 60.0); + } +} + } -//================================================================== // ------------------------------------------------------------------------- void ODbaseTable::readHeader() @@ -152,6 +268,7 @@ void ODbaseTable::readHeader() case dBaseIV: case dBaseV: case VisualFoxPro: + case VisualFoxProAuto: case dBaseFS: case dBaseFSMemo: case dBaseIVMemoSQL: @@ -227,6 +344,7 @@ void ODbaseTable::fillColumns() ::rtl::OUString aTypeName; static const ::rtl::OUString sVARCHAR(RTL_CONSTASCII_USTRINGPARAM("VARCHAR")); const sal_Bool bCase = getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers(); + const bool bFoxPro = m_aHeader.db_typ == VisualFoxPro || m_aHeader.db_typ == VisualFoxProAuto || m_aHeader.db_typ == FoxProMemo; sal_Int32 i = 0; for (; i < nFieldCount; i++) @@ -236,61 +354,96 @@ void ODbaseTable::fillColumns() if ( FIELD_DESCRIPTOR_TERMINATOR == aDBFColumn.db_fnm[0] ) // 0x0D stored as the Field Descriptor terminator. break; + sal_Bool bIsRowVersion = bFoxPro && ( aDBFColumn.db_frei2[0] & 0x01 ) == 0x01; + //if ( bFoxPro && ( aDBFColumn.db_frei2[0] & 0x01 ) == 0x01 ) // system column not visible to user + // continue; const String aColumnName((const char *)aDBFColumn.db_fnm,m_eEncoding); + m_aRealFieldLengths.push_back(aDBFColumn.db_flng); sal_Int32 nPrecision = aDBFColumn.db_flng; sal_Int32 eType; + sal_Bool bIsCurrency = sal_False; + + char cType[2]; + cType[0] = aDBFColumn.db_typ; + cType[1] = 0; + aTypeName = ::rtl::OUString::createFromAscii(cType); switch (aDBFColumn.db_typ) { case 'C': - eType = DataType::VARCHAR; - aTypeName = sVARCHAR; + eType = DataType::CHAR; + aTypeName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VARCHAR")); break; case 'F': + aTypeName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DECIMAL")); case 'N': + if ( aDBFColumn.db_typ == 'N' ) + aTypeName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NUMERIC")); eType = DataType::DECIMAL; - aTypeName = ::rtl::OUString::createFromAscii("DECIMAL"); // Bei numerischen Feldern werden zwei Zeichen mehr geschrieben, als die Precision der Spaltenbeschreibung eigentlich // angibt, um Platz fuer das eventuelle Vorzeichen und das Komma zu haben. Das muss ich jetzt aber wieder rausrechnen. nPrecision = SvDbaseConverter::ConvertPrecisionToOdbc(nPrecision,aDBFColumn.db_dez); // leider gilt das eben Gesagte nicht fuer aeltere Versionen .... - ; break; case 'L': eType = DataType::BIT; - aTypeName = ::rtl::OUString::createFromAscii("BIT"); + aTypeName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BOOLEAN")); + break; + case 'Y': + bIsCurrency = sal_True; + eType = DataType::DOUBLE; + aTypeName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DOUBLE")); break; case 'D': eType = DataType::DATE; - aTypeName = ::rtl::OUString::createFromAscii("DATE"); + aTypeName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DATE")); + break; + case 'T': + eType = DataType::TIMESTAMP; + aTypeName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TIMESTAMP")); + break; + case 'I': + eType = DataType::INTEGER; + aTypeName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("INTEGER")); break; case 'M': - eType = DataType::LONGVARCHAR; - aTypeName = ::rtl::OUString::createFromAscii("LONGVARCHAR"); - nPrecision = 65535; + if ( bFoxPro && ( aDBFColumn.db_frei2[0] & 0x04 ) == 0x04 ) + { + eType = DataType::LONGVARBINARY; + aTypeName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LONGVARBINARY")); + } + else + { + aTypeName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LONGVARCHAR")); + eType = DataType::LONGVARCHAR; + } + nPrecision = 2147483647; + break; + case 'P': + aTypeName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LONGVARBINARY")); + eType = DataType::LONGVARBINARY; + nPrecision = 2147483647; + break; + case '0': + case 'B': + if ( m_aHeader.db_typ == VisualFoxPro || m_aHeader.db_typ == VisualFoxProAuto ) + { + aTypeName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DOUBLE")); + eType = DataType::DOUBLE; + } + else + { + aTypeName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LONGVARBINARY")); + eType = DataType::LONGVARBINARY; + nPrecision = 2147483647; + } break; default: - aTypeName = ::rtl::OUString::createFromAscii("OTHER"); eType = DataType::OTHER; - } -// sal_Int32 nFlags = 0; -// switch (aDBFColumn.db_typ) -// { -// case 'C': -// case 'D': -// case 'L': nFlags = ColumnSearch::FULL; break; -// case 'F': -// case 'N': nFlags = ColumnSearch::BASIC; break; -// case 'M': nFlags = ColumnSearch::CHAR; break; -// default: -// nFlags = ColumnSearch::NONE; -// -// } - m_aTypes.push_back(eType); m_aPrecisions.push_back(nPrecision); m_aScales.push_back(aDBFColumn.db_dez); @@ -303,8 +456,8 @@ void ODbaseTable::fillColumns() aDBFColumn.db_dez, eType, sal_False, - sal_False, - sal_False, + bIsRowVersion, + bIsCurrency, bCase); m_aColumns->get().push_back(xCol); } // for (; i < nFieldCount; i++) @@ -380,7 +533,7 @@ void ODbaseTable::construct() // Memo-Dateinamen bilden (.DBT): // nyi: Unschoen fuer Unix und Mac! - if ( m_aHeader.db_typ == FoxProMemo || VisualFoxPro == m_aHeader.db_typ ) // foxpro uses another extension + if ( m_aHeader.db_typ == FoxProMemo || VisualFoxPro == m_aHeader.db_typ || VisualFoxProAuto == m_aHeader.db_typ ) // foxpro uses another extension aURL.SetExtension(String::CreateFromAscii("fpt")); else aURL.SetExtension(String::CreateFromAscii("dbt")); @@ -465,6 +618,7 @@ BOOL ODbaseTable::ReadMemoHeader() } break; case VisualFoxPro: + case VisualFoxProAuto: case FoxProMemo: m_aMemoHeader.db_typ = MemoFoxPro; m_pMemoStream->Seek(6L); @@ -693,15 +847,23 @@ sal_Bool ODbaseTable::fetchRow(OValueRefRow& _rRow,const OSQLColumns & _rCols, s } switch(nType) { - case DataType::DATE: nLen = 8; break; + case DataType::INTEGER: + case DataType::DOUBLE: + case DataType::TIMESTAMP: + case DataType::DATE: + case DataType::BIT: + case DataType::LONGVARCHAR: + case DataType::LONGVARBINARY: + nLen = m_aRealFieldLengths[i-1]; + break; case DataType::DECIMAL: if(_bUseTableDefs) nLen = SvDbaseConverter::ConvertPrecisionToDbase(nLen,m_aScales[i-1]); else nLen = SvDbaseConverter::ConvertPrecisionToDbase(nLen,getINT32((*aIter)->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)))); break; // das Vorzeichen und das Komma - case DataType::BIT: nLen = 1; break; - case DataType::LONGVARCHAR: nLen = 10; break; + + case DataType::BINARY: case DataType::OTHER: nByteOffset += nLen; continue; @@ -714,7 +876,9 @@ sal_Bool ODbaseTable::fetchRow(OValueRefRow& _rRow,const OSQLColumns & _rCols, s nByteOffset += nLen; OSL_ENSURE( nByteOffset <= m_nBufferSize ,"ByteOffset > m_nBufferSize!"); continue; - } + } // if ( !(_rRow->get())[i]->isBound() ) + if ( ( nByteOffset + nLen) > m_nBufferSize ) + break; // length doesn't match buffer size. char *pData = (char *) (m_pBuffer + nByteOffset); @@ -733,6 +897,48 @@ sal_Bool ODbaseTable::fetchRow(OValueRefRow& _rRow,const OSQLColumns & _rCols, s (_rRow->get())[i]->setNull(); pData[nLen] = cLast; + } // if (nType == DataType::CHAR || nType == DataType::VARCHAR) + else if ( DataType::TIMESTAMP == nType ) + { + sal_Int32 nDate = 0,nTime = 0; + memcpy(&nDate, pData, 4); + memcpy(&nTime, pData+ 4, 4); + if ( !nDate && !nTime ) + { + (_rRow->get())[i]->setNull(); + } + else + { + ::com::sun::star::util::DateTime aDateTime; + lcl_CalDate(nDate,nTime,aDateTime); + *(_rRow->get())[i] = aDateTime; + } + } + else if ( DataType::INTEGER == nType ) + { + sal_Int32 nValue = 0; + memcpy(&nValue, pData, nLen); + *(_rRow->get())[i] = nValue; + } + else if ( DataType::DOUBLE == nType ) + { + double d = 0.0; + if (getBOOL((*aIter)->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)))) // Currency wird gesondert behandelt + { + sal_Int64 nValue = 0; + memcpy(&nValue, pData, nLen); + + if ( m_aScales[i-1] ) + d = (double)(nValue / pow(10.0,(int)m_aScales[i-1])); + else + d = (double)(nValue); + } + else + { + memcpy(&d, pData, nLen); + } + + *(_rRow->get())[i] = d; } else { @@ -789,6 +995,8 @@ sal_Bool ODbaseTable::fetchRow(OValueRefRow& _rRow,const OSQLColumns & _rCols, s // pVal->setDouble(b); } break; + case DataType::LONGVARBINARY: + case DataType::BINARY: case DataType::LONGVARCHAR: { const long nBlockNo = aStr.ToInt32(); // Blocknummer lesen @@ -806,9 +1014,6 @@ sal_Bool ODbaseTable::fetchRow(OValueRefRow& _rRow,const OSQLColumns & _rCols, s (_rRow->get())[i]->setTypeKind(nType); } -// if (aStatus.IsError()) -// break; - // Und weiter ... nByteOffset += nLen; OSL_ENSURE( nByteOffset <= m_nBufferSize ,"ByteOffset > m_nBufferSize!"); } @@ -978,38 +1183,78 @@ BOOL ODbaseTable::CreateFile(const INetURLObject& aFile, BOOL& bCreateMemo) if (!m_pFileStream) return sal_False; + BYTE nDbaseType = dBaseIII; + Reference<XIndexAccess> xColumns(getColumns(),UNO_QUERY); + Reference<XPropertySet> xCol; + const ::rtl::OUString sPropType = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE); + + try + { + const sal_Int32 nCount = xColumns->getCount(); + for(sal_Int32 i=0;i<nCount;++i) + { + xColumns->getByIndex(i) >>= xCol; + OSL_ENSURE(xCol.is(),"This should be a column!"); + + switch (getINT32(xCol->getPropertyValue(sPropType))) + { + case DataType::DOUBLE: + case DataType::INTEGER: + case DataType::TIMESTAMP: + case DataType::LONGVARBINARY: + nDbaseType = VisualFoxPro; + i = nCount; // no more columns need to be checked + break; + } // switch (getINT32(xCol->getPropertyValue(sPropType))) + } + } + catch ( const Exception& e ) + { + (void)e; + + try + { + // we have to drop the file because it is corrupted now + DropImpl(); + } + catch(const Exception&) { } + throw; + } + char aBuffer[21]; // write buffer memset(aBuffer,0,sizeof(aBuffer)); m_pFileStream->Seek(0L); - (*m_pFileStream) << (BYTE) dBaseIII; // dBase format + (*m_pFileStream) << (BYTE) nDbaseType; // dBase format (*m_pFileStream) << (BYTE) (aDate.GetYear() % 100); // aktuelles Datum (*m_pFileStream) << (BYTE) aDate.GetMonth(); (*m_pFileStream) << (BYTE) aDate.GetDay(); - (*m_pFileStream) << 0L; // Anzahl der Datensaetze - (*m_pFileStream) << (USHORT)((m_pColumns->getCount()+1) * 32 + 1); // Kopfinformationen, + (*m_pFileStream) << 0L; // Anzahl der Datensaetze + (*m_pFileStream) << (USHORT)((m_pColumns->getCount()+1) * 32 + 1); // Kopfinformationen, // pColumns erhaelt immer eine Spalte mehr - (*m_pFileStream) << (USHORT) 0; // Satzlaenge wird spaeter bestimmt + (*m_pFileStream) << (USHORT) 0; // Satzlaenge wird spaeter bestimmt m_pFileStream->Write(aBuffer, 20); - USHORT nRecLength = 1; // Laenge 1 fuer deleted flag + USHORT nRecLength = 1; // Laenge 1 fuer deleted flag sal_Int32 nMaxFieldLength = m_pConnection->getMetaData()->getMaxColumnNameLength(); - Reference<XIndexAccess> xColumns(getColumns(),UNO_QUERY); - ::rtl::OUString aName; - Reference<XPropertySet> xCol; + const ::rtl::OUString sPropName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME); + const ::rtl::OUString sPropPrec = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION); + const ::rtl::OUString sPropScale = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE); + try { - for(sal_Int32 i=0;i<xColumns->getCount();++i) + const sal_Int32 nCount = xColumns->getCount(); + for(sal_Int32 i=0;i<nCount;++i) { - ::cppu::extractInterface(xCol,xColumns->getByIndex(i)); + xColumns->getByIndex(i) >>= xCol; OSL_ENSURE(xCol.is(),"This should be a column!"); char cTyp( 'C' ); - xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= aName; + xCol->getPropertyValue(sPropName) >>= aName; ::rtl::OString aCol; if ( DBTypeConversion::convertUnicodeString( aName, aCol, m_eEncoding ) > nMaxFieldLength) @@ -1020,22 +1265,39 @@ BOOL ODbaseTable::CreateFile(const INetURLObject& aFile, BOOL& bCreateMemo) (*m_pFileStream) << aCol.getStr(); m_pFileStream->Write(aBuffer, 11 - aCol.getLength()); - switch (getINT32(xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)))) + sal_Int32 nPrecision = 0; + xCol->getPropertyValue(sPropPrec) >>= nPrecision; + sal_Int32 nScale = 0; + xCol->getPropertyValue(sPropScale) >>= nScale; + + bool bBinary = false; + + switch (getINT32(xCol->getPropertyValue(sPropType))) { case DataType::CHAR: case DataType::VARCHAR: cTyp = 'C'; break; + case DataType::DOUBLE: + if (getBOOL(xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)))) // Currency wird gesondert behandelt + cTyp = 'Y'; + else + cTyp = 'B'; + break; + case DataType::INTEGER: + cTyp = 'I'; + break; case DataType::TINYINT: case DataType::SMALLINT: - case DataType::INTEGER: case DataType::BIGINT: case DataType::DECIMAL: case DataType::NUMERIC: case DataType::REAL: - case DataType::DOUBLE: cTyp = 'N'; // nur dBase 3 format break; + case DataType::TIMESTAMP: + cTyp = 'T'; + break; case DataType::DATE: cTyp = 'D'; break; @@ -1043,6 +1305,8 @@ BOOL ODbaseTable::CreateFile(const INetURLObject& aFile, BOOL& bCreateMemo) cTyp = 'L'; break; case DataType::LONGVARBINARY: + bBinary = true; + // run through case DataType::LONGVARCHAR: cTyp = 'M'; break; @@ -1053,12 +1317,10 @@ BOOL ODbaseTable::CreateFile(const INetURLObject& aFile, BOOL& bCreateMemo) } (*m_pFileStream) << cTyp; - m_pFileStream->Write(aBuffer, 4); - - sal_Int32 nPrecision = 0; - xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)) >>= nPrecision; - sal_Int32 nScale = 0; - xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)) >>= nScale; + if ( nDbaseType == VisualFoxPro ) + (*m_pFileStream) << (nRecLength-1); + else + m_pFileStream->Write(aBuffer, 4); switch(cTyp) { @@ -1092,14 +1354,22 @@ BOOL ODbaseTable::CreateFile(const INetURLObject& aFile, BOOL& bCreateMemo) (*m_pFileStream) << (BYTE)( nPrec); (*m_pFileStream) << (BYTE)nScale; - nRecLength = nRecLength + (USHORT)nPrec; + nRecLength += (USHORT)nPrec; } break; case 'L': (*m_pFileStream) << (BYTE)1; (*m_pFileStream) << (BYTE)0; - nRecLength++; + ++nRecLength; + break; + case 'I': + (*m_pFileStream) << (BYTE)4; + (*m_pFileStream) << (BYTE)0; + nRecLength += 4; break; + case 'Y': + case 'B': + case 'T': case 'D': (*m_pFileStream) << (BYTE)8; (*m_pFileStream) << (BYTE)0; @@ -1110,11 +1380,14 @@ BOOL ODbaseTable::CreateFile(const INetURLObject& aFile, BOOL& bCreateMemo) (*m_pFileStream) << (BYTE)10; (*m_pFileStream) << (BYTE)0; nRecLength += 10; + if ( bBinary ) + aBuffer[0] = 0x06; break; default: throwInvalidColumnType(STR_INVALID_COLUMN_TYPE, aName); } m_pFileStream->Write(aBuffer, 14); + aBuffer[0] = 0x00; } (*m_pFileStream) << (BYTE)FIELD_DESCRIPTOR_TERMINATOR; // kopf ende @@ -1125,7 +1398,10 @@ BOOL ODbaseTable::CreateFile(const INetURLObject& aFile, BOOL& bCreateMemo) if (bCreateMemo) { m_pFileStream->Seek(0L); - (*m_pFileStream) << (BYTE) dBaseIIIMemo; + if (nDbaseType == VisualFoxPro) + (*m_pFileStream) << (BYTE) FoxProMemo; + else + (*m_pFileStream) << (BYTE) dBaseIIIMemo; } // if (bCreateMemo) } catch ( const Exception& e ) @@ -1252,7 +1528,7 @@ BOOL ODbaseTable::InsertRow(OValueRefVector& rRow, BOOL bFlush,const Reference<X RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::InsertRow" ); // Buffer mit Leerzeichen fuellen AllocBuffer(); - memset(m_pBuffer, ' ', m_aHeader.db_slng); + memset(m_pBuffer, 0, m_aHeader.db_slng); // Gesamte neue Row uebernehmen: // ... und am Ende als neuen Record hinzufuegen: @@ -1436,7 +1712,7 @@ BOOL ODbaseTable::UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,const Reference<XPropertySet> xIndex; USHORT i; ::rtl::OUString aColName; - sal_Int32 nColumnCount = m_pColumns->getCount(); + const sal_Int32 nColumnCount = m_pColumns->getCount(); ::std::vector< Reference<XPropertySet> > aIndexedCols(nColumnCount); ::comphelper::UStringMixEqual aCase(isCaseSensitive()); @@ -1490,7 +1766,11 @@ BOOL ODbaseTable::UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,const xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= aColName; xCol = NULL; } // if ( !aColName.getLength() ) - throwInvalidColumnType(STR_DUPLICATE_VALUE_IN_COLUMN,aColName); + const ::rtl::OUString sError( getConnection()->getResources().getResourceStringWithSubstitution( + STR_DUPLICATE_VALUE_IN_COLUMN + ,"$columnname$", aColName + ) ); + ::dbtools::throwGenericSQLException( sError, *this ); } } } @@ -1522,15 +1802,24 @@ BOOL ODbaseTable::UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,const } } + bool bSetZero = false; switch (nType) { - case DataType::DATE: nLen = 8; break; + case DataType::INTEGER: + case DataType::DOUBLE: + case DataType::TIMESTAMP: + bSetZero = true; + case DataType::LONGVARBINARY: + case DataType::DATE: + case DataType::BIT: + case DataType::LONGVARCHAR: + nLen = m_aRealFieldLengths[i]; + break; case DataType::DECIMAL: nLen = SvDbaseConverter::ConvertPrecisionToDbase(nLen,nScale); break; // das Vorzeichen und das Komma - case DataType::BIT: nLen = 1; break; - case DataType::LONGVARCHAR: nLen = 10; break; - default: break; + default: + break; } // switch (nType) @@ -1580,7 +1869,10 @@ BOOL ODbaseTable::UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,const char* pData = (char *)(m_pBuffer + nByteOffset); if (rRow.get()[nPos]->getValue().isNull()) { - memset(pData,' ',nLen); // Zuruecksetzen auf NULL + if ( bSetZero ) + memset(pData,0,nLen); // Zuruecksetzen auf NULL + else + memset(pData,' ',nLen); // Zuruecksetzen auf NULL nByteOffset += nLen; OSL_ENSURE( nByteOffset <= m_nBufferSize ,"ByteOffset > m_nBufferSize!"); continue; @@ -1591,6 +1883,15 @@ BOOL ODbaseTable::UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,const { switch (nType) { + case DataType::TIMESTAMP: + { + sal_Int32 nJulianDate = 0, nJulianTime = 0; + lcl_CalcJulDate(nJulianDate,nJulianTime,rRow.get()[nPos]->getValue()); + // Genau 8 Byte kopieren: + memcpy(pData,&nJulianDate,4); + memcpy(pData+4,&nJulianTime,4); + } + break; case DataType::DATE: { ::com::sun::star::util::Date aDate; @@ -1609,6 +1910,30 @@ BOOL ODbaseTable::UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,const // Genau 8 Byte kopieren: strncpy(pData,s,sizeof s - 1); } break; + case DataType::INTEGER: + { + sal_Int32 nValue = rRow.get()[nPos]->getValue(); + memcpy(pData,&nValue,nLen); + } + break; + case DataType::DOUBLE: + { + const double d = rRow.get()[nPos]->getValue(); + m_pColumns->getByIndex(i) >>= xCol; + + if (getBOOL(xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)))) // Currency wird gesondert behandelt + { + sal_Int64 nValue = 0; + if ( m_aScales[i] ) + nValue = (sal_Int64)(d * pow(10.0,(int)m_aScales[i])); + else + nValue = (sal_Int64)(d); + memcpy(pData,&nValue,nLen); + } // if (getBOOL(xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)))) // Currency wird gesondert behandelt + else + memcpy(pData,&d,nLen); + } + break; case DataType::DECIMAL: { memset(pData,' ',nLen); // Zuruecksetzen auf NULL @@ -1647,6 +1972,7 @@ BOOL ODbaseTable::UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,const case DataType::BIT: *pData = rRow.get()[nPos]->getValue().getBool() ? 'T' : 'F'; break; + case DataType::LONGVARBINARY: case DataType::LONGVARCHAR: { char cNext = pData[nLen]; // merken und temporaer durch 0 ersetzen @@ -1714,12 +2040,20 @@ BOOL ODbaseTable::WriteMemo(ORowSetValue& aVariable, ULONG& rBlockNr) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::WriteMemo" ); // wird die BlockNr 0 vorgegeben, wird der block ans Ende gehaengt - - BYTE nHeader[4]; - - ::rtl::OUString sStringToWrite( aVariable.getString() ); + ULONG nSize = 0; ::rtl::OString aStr; - ULONG nSize = DBTypeConversion::convertUnicodeString( sStringToWrite, aStr, m_eEncoding ); + ::com::sun::star::uno::Sequence<sal_Int8> aValue; + BYTE nHeader[4]; + const bool bBinary = aVariable.getTypeKind() == DataType::LONGVARBINARY && m_aMemoHeader.db_typ == MemoFoxPro; + if ( bBinary ) + { + aValue = aVariable.getSequence(); + nSize = aValue.getLength(); + } + else + { + nSize = DBTypeConversion::convertUnicodeString( aVariable.getString(), aStr, m_eEncoding ); + } // Anhaengen oder ueberschreiben BOOL bAppend = rBlockNr == 0; @@ -1779,29 +2113,28 @@ BOOL ODbaseTable::WriteMemo(ORowSetValue& aVariable, ULONG& rBlockNr) { const char cEOF = (char) DBF_EOL; nSize++; - -// if (pData) -// { -// m_pMemoStream->Write((const char*) pData->getConstArray(), pData->getLength()); -// } -// else -// { - m_pMemoStream->Write( aStr.getStr(), aStr.getLength() ); - // } - + m_pMemoStream->Write( aStr.getStr(), aStr.getLength() ); (*m_pMemoStream) << cEOF << cEOF; } break; case MemoFoxPro: case MemodBaseIV: // dBase IV-Memofeld mit Laengenangabe { - (*m_pMemoStream) << (BYTE)0xFF - << (BYTE)0xFF - << (BYTE)0x08; + if ( MemodBaseIV == m_aMemoHeader.db_typ ) + (*m_pMemoStream) << (BYTE)0xFF + << (BYTE)0xFF + << (BYTE)0x08; + else + (*m_pMemoStream) << (BYTE)0x00 + << (BYTE)0x00 + << (BYTE)0x00; UINT32 nWriteSize = nSize; if (m_aMemoHeader.db_typ == MemoFoxPro) { - (*m_pMemoStream) << (BYTE) 0x01; // ((pData = NULL) ? 0x01 : 0x00); + if ( bBinary ) + (*m_pMemoStream) << (BYTE) 0x00; // Picture + else + (*m_pMemoStream) << (BYTE) 0x01; // Memo for (int i = 4; i > 0; nWriteSize >>= 8) nHeader[--i] = (BYTE) (nWriteSize % 256); } @@ -1814,14 +2147,10 @@ BOOL ODbaseTable::WriteMemo(ORowSetValue& aVariable, ULONG& rBlockNr) } m_pMemoStream->Write(nHeader,4); -// if (pData) -// { -// m_pMemoStream->Write((const char*) pData->getConstArray(), pData->getLength()); -// } -// else -// { + if ( bBinary ) + m_pMemoStream->Write( aValue.getConstArray(), aValue.getLength() ); + else m_pMemoStream->Write( aStr.getStr(), aStr.getLength() ); - // } m_pMemoStream->Flush(); } } @@ -2419,18 +2748,18 @@ BOOL ODbaseTable::ReadMemo(ULONG nBlockNo, ORowSetValue& aVariable) // Foxpro stores text and binary data if (m_aMemoHeader.db_typ == MemoFoxPro) { - if (((BYTE)sHeader[0]) != 0 || ((BYTE)sHeader[1]) != 0 || ((BYTE)sHeader[2]) != 0) - { -// String aText = String(SdbResId(STR_STAT_IResultSetHelper::INVALID)); -// aText.SearchAndReplace(String::CreateFromAscii("%%d"),m_pMemoStream->GetFileName()); -// aText.SearchAndReplace(String::CreateFromAscii("%%t"),aStatus.TypeToString(MEMO)); -// aStatus.Set(SDB_STAT_ERROR, -// String::CreateFromAscii("01000"), -// aStatus.CreateErrorMessage(aText), -// 0, String() ); - return sal_False; - } - +// if (((BYTE)sHeader[0]) != 0 || ((BYTE)sHeader[1]) != 0 || ((BYTE)sHeader[2]) != 0) +// { +//// String aText = String(SdbResId(STR_STAT_IResultSetHelper::INVALID)); +//// aText.SearchAndReplace(String::CreateFromAscii("%%d"),m_pMemoStream->GetFileName()); +//// aText.SearchAndReplace(String::CreateFromAscii("%%t"),aStatus.TypeToString(MEMO)); +//// aStatus.Set(SDB_STAT_ERROR, +//// String::CreateFromAscii("01000"), +//// aStatus.CreateErrorMessage(aText), +//// 0, String() ); +// return sal_False; +// } +// bIsText = sHeader[3] != 0; } else if (((BYTE)sHeader[0]) != 0xFF || ((BYTE)sHeader[1]) != 0xFF || ((BYTE)sHeader[2]) != 0x08) @@ -2451,28 +2780,40 @@ BOOL ODbaseTable::ReadMemo(ULONG nBlockNo, ORowSetValue& aVariable) if (m_aMemoHeader.db_typ == MemodBaseIV) nLength -= 8; - // char cChar; - ::rtl::OUString aStr; - while ( nLength > STRING_MAXLEN ) + if ( nLength ) { - ByteString aBStr; - aBStr.Expand(STRING_MAXLEN); - m_pMemoStream->Read(aBStr.AllocBuffer(STRING_MAXLEN),STRING_MAXLEN); - aStr += ::rtl::OUString(aBStr.GetBuffer(),aBStr.Len(), m_eEncoding); - nLength -= STRING_MAXLEN; - } - if ( nLength > 0 ) - { - ByteString aBStr; - aBStr.Expand(static_cast<xub_StrLen>(nLength)); - m_pMemoStream->Read(aBStr.AllocBuffer(static_cast<xub_StrLen>(nLength)),nLength); - // aBStr.ReleaseBufferAccess(); + if ( bIsText ) + { + // char cChar; + ::rtl::OUString aStr; + while ( nLength > STRING_MAXLEN ) + { + ByteString aBStr; + aBStr.Expand(STRING_MAXLEN); + m_pMemoStream->Read(aBStr.AllocBuffer(STRING_MAXLEN),STRING_MAXLEN); + aStr += ::rtl::OUString(aBStr.GetBuffer(),aBStr.Len(), m_eEncoding); + nLength -= STRING_MAXLEN; + } + if ( nLength > 0 ) + { + ByteString aBStr; + aBStr.Expand(static_cast<xub_StrLen>(nLength)); + m_pMemoStream->Read(aBStr.AllocBuffer(static_cast<xub_StrLen>(nLength)),nLength); + // aBStr.ReleaseBufferAccess(); - aStr += ::rtl::OUString(aBStr.GetBuffer(),aBStr.Len(), m_eEncoding); + aStr += ::rtl::OUString(aBStr.GetBuffer(),aBStr.Len(), m_eEncoding); - } - if ( aStr.getLength() ) - aVariable = aStr; + } + if ( aStr.getLength() ) + aVariable = aStr; + } // if ( bIsText ) + else + { + ::com::sun::star::uno::Sequence< sal_Int8 > aData(nLength); + m_pMemoStream->Read(aData.getArray(),nLength); + aVariable = aData; + } + } // if ( nLength ) } } return sal_True; diff --git a/connectivity/source/drivers/file/fanalyzer.cxx b/connectivity/source/drivers/file/fanalyzer.cxx index c866db55275e..eceb58e10611 100644 --- a/connectivity/source/drivers/file/fanalyzer.cxx +++ b/connectivity/source/drivers/file/fanalyzer.cxx @@ -90,6 +90,9 @@ void OSQLAnalyzer::start(OSQLParseNode* pSQLParseNode) || SQL_ISRULE(pColumnRef,position_exp) || SQL_ISRULE(pColumnRef,fold) || SQL_ISRULE(pColumnRef,length_exp) + || SQL_ISRULE(pColumnRef,num_value_exp) + || SQL_ISRULE(pColumnRef,term) + || SQL_ISRULE(pColumnRef,factor) || SQL_ISRULE(pColumnRef,set_fct_spec) ) { ::vos::ORef<OPredicateCompiler> pCompiler = new OPredicateCompiler(this); diff --git a/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx b/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx index b6d18be2a346..11863be3b8bf 100644 --- a/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx +++ b/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx @@ -169,7 +169,6 @@ Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getTables( args[3].l = pObjArray; } } - // if we are to display "all catalogs", then respect m_aCatalogRestriction Any aCatalogFilter( catalog ); if ( !aCatalogFilter.hasValue() ) diff --git a/connectivity/source/drivers/jdbc/PreparedStatement.cxx b/connectivity/source/drivers/jdbc/PreparedStatement.cxx index beef4792ba1e..dbf7241885da 100644 --- a/connectivity/source/drivers/jdbc/PreparedStatement.cxx +++ b/connectivity/source/drivers/jdbc/PreparedStatement.cxx @@ -120,7 +120,7 @@ sal_Int32 SAL_CALL java_sql_PreparedStatement::executeUpdate( ) throw(::com::su checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); m_aLogger.log( LogLevel::FINE, STR_LOG_EXECUTING_PREPARED_UPDATE ); static jmethodID mID(NULL); - return impl_getProperty("executeUpdate",mID); + return callIntMethod("executeUpdate",mID); } // ------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/jdbc/ResultSet.cxx b/connectivity/source/drivers/jdbc/ResultSet.cxx index 9b8de989bb51..e78488ffbba3 100644 --- a/connectivity/source/drivers/jdbc/ResultSet.cxx +++ b/connectivity/source/drivers/jdbc/ResultSet.cxx @@ -348,6 +348,7 @@ Any SAL_CALL java_sql_ResultSet::getObject( sal_Int32 columnIndex, const Referen } //t.pEnv // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + ::dbtools::throwFunctionNotSupportedException( "XRow::getObject", *this ); return out==0 ? Any() : Any();//new java_lang_Object( t.pEnv, out ); } // ------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/mozab/MConnection.cxx b/connectivity/source/drivers/mozab/MConnection.cxx index 2f9386b09f98..6fc45d4ed07f 100644 --- a/connectivity/source/drivers/mozab/MConnection.cxx +++ b/connectivity/source/drivers/mozab/MConnection.cxx @@ -30,22 +30,26 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_connectivity.hxx" -#include "MConnection.hxx" +#include "diagnose_ex.h" +#include "MConnection.hxx" #include "MDatabaseMetaData.hxx" #include "MDriver.hxx" #include "MColumnAlias.hxx" #include "MStatement.hxx" #include "MPreparedStatement.hxx" -#include <com/sun/star/sdbc/ColumnValue.hpp> -#include <com/sun/star/sdbc/XRow.hpp> -#include <com/sun/star/sdbc/TransactionIsolation.hpp> + #include <connectivity/dbcharset.hxx> #include <connectivity/dbexception.hxx> -#include "diagnose_ex.h" +#include <connectivity/sqlerror.hxx> #include "resource/mozab_res.hrc" #include "resource/common_res.hrc" + +#include <com/sun/star/sdbc/ColumnValue.hpp> +#include <com/sun/star/sdbc/XRow.hpp> +#include <com/sun/star/sdbc/TransactionIsolation.hpp> + #include <comphelper/officeresourcebundle.hxx> #if OSL_DEBUG_LEVEL > 0 @@ -173,7 +177,7 @@ void OConnection::construct(const ::rtl::OUString& url,const Sequence< PropertyV else { OSL_TRACE( "No subschema given!!!\n"); - throwGenericSQLException( STR_URI_SYNTAX_ERROR,*this ); + throwSQLException( STR_URI_SYNTAX_ERROR, *this ); } } else @@ -284,7 +288,7 @@ void OConnection::construct(const ::rtl::OUString& url,const Sequence< PropertyV m_sMozillaURI += m_sHostName; } else - throwGenericSQLException( STR_NO_HOSTNAME ,*this); + throwSQLException( STR_NO_HOSTNAME, *this ); if ( nPortNumber > 0 ) { m_sMozillaURI += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(":") ); @@ -296,7 +300,7 @@ void OConnection::construct(const ::rtl::OUString& url,const Sequence< PropertyV m_sMozillaURI += sBaseDN; } else - throwGenericSQLException( STR_NO_BASEDN ,*this); + throwSQLException( STR_NO_BASEDN, *this ); // Addition of a fake query to enable the Mozilla LDAP directory to work correctly. m_sMozillaURI += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("?(or(DisplayName,=,DontDoThisAtHome)))")); @@ -313,7 +317,7 @@ void OConnection::construct(const ::rtl::OUString& url,const Sequence< PropertyV else { OSL_TRACE("Invalid subschema given!!!\n"); - throwGenericSQLException( STR_URI_SYNTAX_ERROR ,*this); + throwSQLException( STR_URI_SYNTAX_ERROR, *this ); } OSL_TRACE("Moz URI = %s, %s\n", ((OUtoCStr(m_sMozillaURI)) ? (OUtoCStr(m_sMozillaURI)):("NULL")), usesFactory() ? "uses factory" : "no factory"); @@ -324,12 +328,15 @@ void OConnection::construct(const ::rtl::OUString& url,const Sequence< PropertyV // The creation of the nsIAbDirectory i/f for LDAP doesn't actually test // the validity of the connection, it's normally delayed until the query // is executed, but it's a bit late then to fail... - if ( isLDAP() ) { - if ( !_aDbHelper.testLDAPConnection( this ) ) { + if ( isLDAP() ) + { + if ( !_aDbHelper.testLDAPConnection( this ) ) + { OSL_TRACE("testLDAPConnection : FAILED\n" ); - throwGenericSQLException( _aDbHelper.getErrorResourceId() ,*this); + throwSQLException( _aDbHelper.getError(), *this ); } - else { + else + { OSL_TRACE("testLDAPConnection : SUCCESS\n" ); } } @@ -337,8 +344,9 @@ void OConnection::construct(const ::rtl::OUString& url,const Sequence< PropertyV // Test connection by getting to get the Table Names ::std::vector< ::rtl::OUString > tables; ::std::vector< ::rtl::OUString > types; - if ( !_aDbHelper.getTableStrings( this, tables, types ) ) { - throwGenericSQLException( _aDbHelper.getErrorResourceId() ,*this); + if ( !_aDbHelper.getTableStrings( this, tables, types ) ) + { + throwSQLException( _aDbHelper.getError(), *this ); } } @@ -550,6 +558,50 @@ MNameMapper* OConnection::getNameMapper () return m_aNameMapper; } + +// ----------------------------------------------------------------------------- +void OConnection::throwSQLException( const ErrorDescriptor& _rError, const Reference< XInterface >& _rxContext ) +{ + if ( _rError.getResId() != 0 ) + { + OSL_ENSURE( ( _rError.getErrorCondition() == 0 ), + "OConnection::throwSQLException: unsupported error code combination!" ); + + ::rtl::OUString sParameter( _rError.getParameter() ); + if ( sParameter.getLength() ) + { + const ::rtl::OUString sError( getResources().getResourceStringWithSubstitution( + _rError.getResId(), + "$1$", sParameter + ) ); + ::dbtools::throwGenericSQLException( sError, _rxContext ); + OSL_ENSURE( false, "OConnection::throwSQLException: unreachable (1)!" ); + } + + throwGenericSQLException( _rError.getResId(), _rxContext ); + OSL_ENSURE( false, "OConnection::throwSQLException: unreachable (2)!" ); + } + + if ( _rError.getErrorCondition() != 0 ) + { + SQLError aErrorHelper( getDriver()->getMSFactory() ); + ::rtl::OUString sParameter( _rError.getParameter() ); + if ( sParameter.getLength() ) + aErrorHelper.raiseException( _rError.getErrorCondition(), _rxContext, sParameter ); + else + aErrorHelper.raiseException( _rError.getErrorCondition(), _rxContext); + OSL_ENSURE( false, "OConnection::throwSQLException: unreachable (3)!" ); + } + + throwGenericSQLException( STR_UNSPECIFIED_ERROR, _rxContext ); +} + // ----------------------------------------------------------------------------- +void OConnection::throwSQLException( const sal_uInt16 _nErrorResourceId, const Reference< XInterface >& _rxContext ) +{ + ErrorDescriptor aError; + aError.setResId( _nErrorResourceId ); + throwSQLException( aError, _rxContext ); +} } } // namespace connectivity::mozab diff --git a/connectivity/source/drivers/mozab/MConnection.hxx b/connectivity/source/drivers/mozab/MConnection.hxx index 883c003ba883..741bd9ef20e1 100644 --- a/connectivity/source/drivers/mozab/MConnection.hxx +++ b/connectivity/source/drivers/mozab/MConnection.hxx @@ -30,23 +30,19 @@ #ifndef CONNECTIVITY_SCONNECTION_HXX #define CONNECTIVITY_SCONNECTION_HXX +#include "connectivity/CommonTools.hxx"
+
+#include "MCatalog.hxx"
#include "MColumnAlias.hxx" -#ifndef _CONNECTIVITY_MAB_CATALOG_HXX_ -#include "MCatalog.hxx" -#endif - +#include "OSubComponent.hxx"
+#include "TConnection.hxx"
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/mozilla/MozillaProductType.hpp>
#include <com/sun/star/sdbc/SQLWarning.hpp> -#include <com/sun/star/beans/PropertyValue.hpp> -#include "OSubComponent.hxx" -// #include <map> #include <com/sun/star/sdbcx/XTablesSupplier.hpp> -#include "connectivity/CommonTools.hxx" -#include "TConnection.hxx" +
#include <cppuhelper/weakref.hxx> -#ifndef _COM_SUN_STAR_MOZILLA_MOZILLPRODUCTTYPE_HPP_ -#include <com/sun/star/mozilla/MozillaProductType.hpp> -#endif #include <memory> @@ -59,6 +55,7 @@ namespace connectivity class MozabDriver; class ODatabaseMetaData; class MNameMapper; + class ErrorDescriptor; namespace SDBCAddress { typedef enum { @@ -225,7 +222,12 @@ namespace connectivity void setForceLoadTables(sal_Bool aForce){ m_bForceLoadTable = aForce;} sal_Bool getForceLoadTables() { return m_bForceLoadTable;} - // End of Additions from the land of mozilla + void throwSQLException( const ErrorDescriptor& _rError, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext ); + void throwSQLException( const sal_uInt16 _nErrorResourceId, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext ); + + private: + // make this private - clients should use throwSQLException instead + using OConnection_BASE::throwGenericSQLException; }; } } diff --git a/connectivity/source/drivers/mozab/MDatabaseMetaData.cxx b/connectivity/source/drivers/mozab/MDatabaseMetaData.cxx index 6f19e821e476..55350e350474 100644 --- a/connectivity/source/drivers/mozab/MDatabaseMetaData.cxx +++ b/connectivity/source/drivers/mozab/MDatabaseMetaData.cxx @@ -97,7 +97,7 @@ ODatabaseMetaDataResultSet::ORows& SAL_CALL ODatabaseMetaData::getColumnRows( ::std::vector< ::rtl::OUString > tables; ::std::vector< ::rtl::OUString > types; if ( !m_pDbMetaDataHelper->getTableStrings( m_pConnection, tables, types) ) { - getOwnConnection()->throwGenericSQLException( m_pDbMetaDataHelper->getErrorResourceId(),*this ); + getOwnConnection()->throwSQLException( m_pDbMetaDataHelper->getError(), *this ); } // **************************************************** @@ -961,7 +961,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables( // pResultSet->setRows( aRows ); ODatabaseMetaDataResultSet::ORows _rRows; if ( !m_pDbMetaDataHelper->getTables( m_pConnection, tableNamePattern, types,_rRows ) ) { - getOwnConnection()->throwGenericSQLException( m_pDbMetaDataHelper->getErrorResourceId() ,*this); + getOwnConnection()->throwSQLException( m_pDbMetaDataHelper->getError(), *this ); } pResultSet->setRows( _rRows ); @@ -979,7 +979,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges( ::std::vector< ::rtl::OUString > tables; ::std::vector< ::rtl::OUString > types; if ( !m_pDbMetaDataHelper->getTableStrings( m_pConnection, tables, types ) ) - getOwnConnection()->throwGenericSQLException( m_pDbMetaDataHelper->getErrorResourceId() ,*this); + getOwnConnection()->throwSQLException( m_pDbMetaDataHelper->getError(), *this ); ::connectivity::ODatabaseMetaDataResultSet::ORows aRows; ::connectivity::ODatabaseMetaDataResultSet::ORow aRow(8); diff --git a/connectivity/source/drivers/mozab/MDriver.cxx b/connectivity/source/drivers/mozab/MDriver.cxx index d7f1fb9d6e2d..bdb9d9447cfe 100644 --- a/connectivity/source/drivers/mozab/MDriver.cxx +++ b/connectivity/source/drivers/mozab/MDriver.cxx @@ -304,9 +304,9 @@ bool MozabDriver::ensureInit() const ::rtl::OUString sModuleName = ::rtl::OUString::createFromAscii(SVLIBRARY( "mozabdrv" )); - // load the dbtools library + // load the mozabdrv library m_hModule = osl_loadModuleRelative(&thisModule, sModuleName.pData, 0); - OSL_ENSURE(NULL != m_hModule, "MozabDriver::ensureInit: could not load the dbtools library!"); + OSL_ENSURE(NULL != m_hModule, "MozabDriver::ensureInit: could not load the mozabdrv library!"); if ( !m_hModule ) return false; diff --git a/connectivity/source/drivers/mozab/MResultSet.cxx b/connectivity/source/drivers/mozab/MResultSet.cxx index 4ae7b695390a..a58e442fcc30 100644 --- a/connectivity/source/drivers/mozab/MResultSet.cxx +++ b/connectivity/source/drivers/mozab/MResultSet.cxx @@ -357,8 +357,9 @@ sal_Bool OResultSet::pushCard(sal_uInt32 cardNumber) throw(SQLException, Runtime // // Everything in the addressbook is a string! // - if ( !m_aQuery.setRowValue( (m_aRow->get())[i], cardNumber, m_aColumnNames[i-1], DataType::VARCHAR )) { - m_pStatement->getOwnConnection()->throwGenericSQLException( m_aQuery.getErrorResourceId(),*this ); + if ( !m_aQuery.setRowValue( (m_aRow->get())[i], cardNumber, m_aColumnNames[i-1], DataType::VARCHAR )) + { + m_pStatement->getOwnConnection()->throwSQLException( m_aQuery.getError(), *this ); } } } @@ -398,8 +399,9 @@ sal_Bool OResultSet::fetchRow(sal_Int32 cardNumber,sal_Bool bForceReload) throw( // // Everything in the addressbook is a string! // - if ( !m_aQuery.getRowValue( (m_aRow->get())[i], cardNumber, m_aColumnNames[i-1], DataType::VARCHAR )) { - m_pStatement->getOwnConnection()->throwGenericSQLException( m_aQuery.getErrorResourceId(),*this ); + if ( !m_aQuery.getRowValue( (m_aRow->get())[i], cardNumber, m_aColumnNames[i-1], DataType::VARCHAR )) + { + m_pStatement->getOwnConnection()->throwSQLException( m_aQuery.getError(), *this ); } } } @@ -613,7 +615,7 @@ void SAL_CALL OResultSet::refreshRow( ) throw(SQLException, RuntimeException) { OSL_TRACE("In/Out: OResultSet::refreshRow" ); if (fetchRow(getCurrentCardNumber(),sal_True)) //force fetch current row will cause we lose all change to the current row - m_pStatement->getOwnConnection()->throwGenericSQLException(STR_ERROR_REFRESH_ROW,*this); + m_pStatement->getOwnConnection()->throwSQLException( STR_ERROR_REFRESH_ROW, *this ); } // ------------------------------------------------------------------------- IPropertyArrayHelper* OResultSet::createArrayHelper( ) const @@ -852,7 +854,7 @@ void OResultSet::analyseWhereClause( const OSQLParseNode* parseT // odbc date (SQL_ISRULE(parseTree->getChild(2),set_fct_spec) && SQL_ISPUNCTUATION(parseTree->getChild(2)->getChild(0),"{")))) { - m_pStatement->getOwnConnection()->throwGenericSQLException(STR_QUERY_TOO_COMPLEX,*this); + m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_TOO_COMPLEX, *this ); } OSQLParseNode *pPrec = parseTree->getChild(1); @@ -889,7 +891,7 @@ void OResultSet::analyseWhereClause( const OSQLParseNode* parseT if ( !(SQL_ISRULE(parseTree->getChild(0), column_ref)) ) { - m_pStatement->getOwnConnection()->throwGenericSQLException(STR_QUERY_INVALID_LIKE_COLUMN,*this); + m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_INVALID_LIKE_COLUMN, *this ); } @@ -909,7 +911,7 @@ void OResultSet::analyseWhereClause( const OSQLParseNode* parseT { OSL_TRACE("analyseSQL : pAtom->count() = %d\n", pAtom->count() ); - m_pStatement->getOwnConnection()->throwGenericSQLException(STR_QUERY_INVALID_LIKE_STRING,*this); + m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_INVALID_LIKE_STRING, *this ); } const sal_Unicode WILDCARD = '%'; @@ -971,7 +973,7 @@ void OResultSet::analyseWhereClause( const OSQLParseNode* parseT { // We currently can't handle a 'NOT LIKE' when there are '%' or // '_' dispersed throughout - m_pStatement->getOwnConnection()->throwGenericSQLException(STR_QUERY_NOT_LIKE_TOO_COMPLEX,*this); + m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_NOT_LIKE_TOO_COMPLEX, *this ); } else { @@ -1026,7 +1028,7 @@ void OResultSet::analyseWhereClause( const OSQLParseNode* parseT if (!SQL_ISRULE(parseTree->getChild(0),column_ref)) { - m_pStatement->getOwnConnection()->throwGenericSQLException(STR_QUERY_INVALID_IS_NULL_COLUMN,*this); + m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_INVALID_IS_NULL_COLUMN, *this ); } if (SQL_ISTOKEN(parseTree->getChild(2),NOT)) @@ -1045,7 +1047,7 @@ void OResultSet::analyseWhereClause( const OSQLParseNode* parseT { OSL_TRACE( "Unexpected statement!!!" ); - m_pStatement->getOwnConnection()->throwGenericSQLException(STR_QUERY_TOO_COMPLEX,*this); + m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_TOO_COMPLEX, *this ); } } @@ -1131,7 +1133,7 @@ void OResultSet::fillRowData() sal_Int32 rv = m_aQuery.executeQuery(xConnection); if ( rv == -1 ) { - m_pStatement->getOwnConnection()->throwGenericSQLException(STR_ERR_EXECUTING_QUERY,*this); + m_pStatement->getOwnConnection()->throwSQLException( STR_ERR_EXECUTING_QUERY, *this ); } //determine whether the address book is readonly determineReadOnly(); @@ -1179,7 +1181,7 @@ sal_Int32 OResultSet::getRowForCardNumber(sal_Int32 nCardNum) } } - m_pStatement->getOwnConnection()->throwGenericSQLException(STR_INVALID_BOOKMARK,*this); + m_pStatement->getOwnConnection()->throwSQLException( STR_INVALID_BOOKMARK, *this ); return 0; } @@ -1194,7 +1196,7 @@ void SAL_CALL OResultSet::executeQuery() throw( ::com::sun::star::sdbc::SQLExcep { const OSQLTables& xTabs = m_pSQLIterator->getTables(); if ((xTabs.begin() == xTabs.end()) || !xTabs.begin()->second.is()) - m_pStatement->getOwnConnection()->throwGenericSQLException(STR_QUERY_TOO_COMPLEX,*this); + m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_TOO_COMPLEX, *this ); m_pTable = static_cast< OTable* > ((xTabs.begin()->second).get()); @@ -1219,7 +1221,7 @@ void SAL_CALL OResultSet::executeQuery() throw( ::com::sun::star::sdbc::SQLExcep } else if(isCount()) { - m_pStatement->getOwnConnection()->throwGenericSQLException(STR_NO_COUNT_SUPPORT,*this); + m_pStatement->getOwnConnection()->throwSQLException( STR_NO_COUNT_SUPPORT, *this ); } else { @@ -1284,8 +1286,9 @@ void SAL_CALL OResultSet::executeQuery() throw( ::com::sun::star::sdbc::SQLExcep OSL_TRACE("Query is to be sorted"); if( ! m_aQuery.queryComplete() ) - if ( !m_aQuery.waitForQueryComplete() ) { - m_pStatement->getOwnConnection()->throwGenericSQLException( m_aQuery.getErrorResourceId(),*this ); + if ( !m_aQuery.waitForQueryComplete() ) + { + m_pStatement->getOwnConnection()->throwSQLException( m_aQuery.getError(), *this ); } OSL_ENSURE( m_aQuery.queryComplete(), "Query not complete!!"); @@ -1360,7 +1363,7 @@ void SAL_CALL OResultSet::executeQuery() throw( ::com::sun::star::sdbc::SQLExcep case SQL_STATEMENT_INSERT: break; default: - m_pStatement->getOwnConnection()->throwGenericSQLException(STR_STMT_TYPE_NOT_SUPPORTED,*this); + m_pStatement->getOwnConnection()->throwSQLException( STR_STMT_TYPE_NOT_SUPPORTED, *this ); break; } } @@ -1472,8 +1475,9 @@ sal_Bool OResultSet::validRow( sal_uInt32 nRow ) OSL_TRACE("validRow: waiting..."); #endif m_aQuery.checkRowAvailable( nRow ); - if ( m_aQuery.errorOccurred() ) { - m_pStatement->getOwnConnection()->throwGenericSQLException( m_aQuery.getErrorResourceId() ,*this); + if ( m_aQuery.hadError() ) + { + m_pStatement->getOwnConnection()->throwSQLException( m_aQuery.getError(), *this ); } nNumberOfRecords = m_aQuery.getRealRowCount(); } @@ -1515,7 +1519,7 @@ sal_Bool OResultSet::seekRow( eRowPosition pos, sal_Int32 nOffset ) { ResultSetEntryGuard aGuard( *this ); if ( !m_pKeySet.isValid() ) - m_pStatement->getOwnConnection()->throwGenericSQLException(STR_ILLEGAL_MOVEMENT,*this); + m_pStatement->getOwnConnection()->throwSQLException( STR_ILLEGAL_MOVEMENT, *this ); sal_Int32 nNumberOfRecords = m_aQuery.getRealRowCount(); sal_Int32 nRetrivedRows = currentRowCount(); @@ -1567,8 +1571,9 @@ sal_Bool OResultSet::seekRow( eRowPosition pos, sal_Int32 nOffset ) while ( nCurCard > nNumberOfRecords && !m_aQuery.queryComplete() ) { m_aQuery.checkRowAvailable( nCurCard ); - if ( m_aQuery.errorOccurred() ) { - m_pStatement->getOwnConnection()->throwGenericSQLException( m_aQuery.getErrorResourceId(),*this ); + if ( m_aQuery.hadError() ) + { + m_pStatement->getOwnConnection()->throwSQLException( m_aQuery.getError(), *this ); } nNumberOfRecords = m_aQuery.getRealRowCount(); } @@ -1602,7 +1607,7 @@ void OResultSet::setColumnMapping(const ::std::vector<sal_Int32>& _aColumnMappin OSL_TRACE("getBookmark, m_nRowPos = %u", m_nRowPos ); ResultSetEntryGuard aGuard( *this ); if ( fetchCurrentRow() == sal_False ) - m_pStatement->getOwnConnection()->throwGenericSQLException(STR_ERROR_GET_ROW,*this); + m_pStatement->getOwnConnection()->throwSQLException( STR_ERROR_GET_ROW, *this ); OSL_ENSURE((!m_aRow->isDeleted()),"getBookmark called for deleted row"); return makeAny((sal_Int32)(m_aRow->get())[0]); @@ -1633,7 +1638,7 @@ sal_Int32 OResultSet::compareBookmarks( const ::com::sun::star::uno::Any& lhs, c sal_Int32 nResult=0; if ( !( lhs >>= nFirst ) || !( rhs >>= nSecond ) ) - m_pStatement->getOwnConnection()->throwGenericSQLException(STR_INVALID_BOOKMARK,*this); + m_pStatement->getOwnConnection()->throwSQLException( STR_INVALID_BOOKMARK, *this ); if(nFirst < nSecond) nResult = -1; @@ -1686,7 +1691,7 @@ void OResultSet::updateValue(sal_Int32 columnIndex ,const ORowSetValue& x) throw OSL_TRACE("updateValue, m_nRowPos = %u", m_nRowPos ); ResultSetEntryGuard aGuard( *this ); if ( fetchCurrentRow() == sal_False ) - m_pStatement->getOwnConnection()->throwGenericSQLException(STR_ERROR_GET_ROW,*this); + m_pStatement->getOwnConnection()->throwSQLException( STR_ERROR_GET_ROW, *this ); checkPendingUpdate(); @@ -1706,7 +1711,7 @@ void SAL_CALL OResultSet::updateNull( sal_Int32 columnIndex ) throw(SQLException OSL_TRACE("updateNull, m_nRowPos = %u", m_nRowPos ); ResultSetEntryGuard aGuard( *this ); if ( fetchCurrentRow() == sal_False ) - m_pStatement->getOwnConnection()->throwGenericSQLException(STR_ERROR_GET_ROW,*this); + m_pStatement->getOwnConnection()->throwSQLException( STR_ERROR_GET_ROW, *this ); checkPendingUpdate(); checkIndex(columnIndex ); @@ -1847,21 +1852,21 @@ void SAL_CALL OResultSet::updateRow( ) throw(::com::sun::star::sdbc::SQLExcepti impl_ensureKeySet(); if (!m_nRowPos || m_pKeySet->get().size() < m_nRowPos ) - m_pStatement->getOwnConnection()->throwGenericSQLException(STR_INVALID_ROW_UPDATE,*this); + m_pStatement->getOwnConnection()->throwSQLException( STR_INVALID_ROW_UPDATE, *this ); const sal_Int32 nCurrentCard = getCurrentCardNumber(); if (!pushCard(nCurrentCard)) { m_RowStates = RowStates_Error; - m_pStatement->getOwnConnection()->throwGenericSQLException(STR_ROW_CAN_NOT_SAVE,*this); + m_pStatement->getOwnConnection()->throwSQLException( STR_ROW_CAN_NOT_SAVE, *this ); } if (!m_aQuery.commitRow(nCurrentCard)) { m_RowStates = RowStates_Error; m_nUpdatedRow = 0; - m_pStatement->getOwnConnection()->throwGenericSQLException( m_aQuery.getErrorResourceId() ,*this); + m_pStatement->getOwnConnection()->throwSQLException( m_aQuery.getError(), *this ); } m_nUpdatedRow = 0; @@ -1874,16 +1879,16 @@ void SAL_CALL OResultSet::deleteRow( ) throw(::com::sun::star::sdbc::SQLExcepti OSL_TRACE("deleteRow, m_nRowPos = %u", m_nRowPos ); ResultSetEntryGuard aGuard( *this ); if (rowDeleted()) - m_pStatement->getOwnConnection()->throwGenericSQLException(STR_ROW_ALREADY_DELETED,*this); + m_pStatement->getOwnConnection()->throwSQLException( STR_ROW_ALREADY_DELETED, *this ); const sal_Int32 nCurrentRow = getCurrentCardNumber(); //fetchRow(nCurrentRow); if (!nCurrentRow) - m_pStatement->getOwnConnection()->throwGenericSQLException(STR_ERROR_GET_ROW,*this); + m_pStatement->getOwnConnection()->throwSQLException( STR_ERROR_GET_ROW, *this ); sal_Bool m_bRowDeleted = ( m_aQuery.deleteRow( nCurrentRow ) > 0 ); if (!m_bRowDeleted) - m_pStatement->getOwnConnection()->throwGenericSQLException( m_aQuery.getErrorResourceId() ,*this); + m_pStatement->getOwnConnection()->throwSQLException( m_aQuery.getError(), *this ); m_aQuery.setRowStates(nCurrentRow,RowStates_Deleted); m_pKeySet->get().erase(m_pKeySet->get().begin() + m_nRowPos -1); @@ -1896,7 +1901,7 @@ void SAL_CALL OResultSet::cancelRowUpdates( ) throw(::com::sun::star::sdbc::SQL ResultSetEntryGuard aGuard( *this ); OSL_TRACE("cancelRowUpdates, m_nRowPos = %u", m_nRowPos ); if (fetchRow(getCurrentCardNumber(),sal_True)) //force fetch current row will cause we lose all change to the current row - m_pStatement->getOwnConnection()->throwGenericSQLException(STR_CAN_NOT_CANCEL_ROW_UPDATE,*this); + m_pStatement->getOwnConnection()->throwSQLException( STR_CAN_NOT_CANCEL_ROW_UPDATE, *this ); } // ------------------------------------------------------------------------- void SAL_CALL OResultSet::moveToInsertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) @@ -1916,7 +1921,7 @@ void SAL_CALL OResultSet::moveToInsertRow( ) throw(::com::sun::star::sdbc::SQLE } m_nNewRow = m_aQuery.createNewCard(); if (!m_nNewRow) - m_pStatement->getOwnConnection()->throwGenericSQLException(STR_CAN_NOT_CREATE_ROW,*this); + m_pStatement->getOwnConnection()->throwSQLException( STR_CAN_NOT_CREATE_ROW, *this ); m_RowStates = RowStates_Normal; fillKeySet(m_nNewRow); diff --git a/connectivity/source/drivers/mozab/MStatement.cxx b/connectivity/source/drivers/mozab/MStatement.cxx index a74128532dc6..50d0b63941f9 100644 --- a/connectivity/source/drivers/mozab/MStatement.cxx +++ b/connectivity/source/drivers/mozab/MStatement.cxx @@ -222,7 +222,7 @@ void OStatement_Base::createTable( ) MDatabaseMetaDataHelper _aDbHelper; if (!_aDbHelper.NewAddressBook(m_pConnection,ouTableName)) { - getOwnConnection()->throwGenericSQLException( _aDbHelper.getErrorResourceId(),*this ); + getOwnConnection()->throwSQLException( _aDbHelper.getError(), *this ); } m_pSQLIterator.reset( new ::connectivity::OSQLParseTreeIterator( m_pConnection, m_pConnection->createCatalog()->getTables(), m_aParser, NULL ) ); @@ -230,7 +230,7 @@ void OStatement_Base::createTable( ) } else - getOwnConnection()->throwGenericSQLException( STR_QUERY_TOO_COMPLEX ,*this); + getOwnConnection()->throwSQLException( STR_QUERY_TOO_COMPLEX, *this ); } // ------------------------------------------------------------------------- sal_Bool OStatement_Base::parseSql( const ::rtl::OUString& sql , sal_Bool bAdjusted) @@ -256,7 +256,7 @@ sal_Bool OStatement_Base::parseSql( const ::rtl::OUString& sql , sal_Bool bAdjus m_pSQLIterator->traverseAll(); const OSQLTables& xTabs = m_pSQLIterator->getTables(); if(xTabs.empty()) - getOwnConnection()->throwGenericSQLException( STR_QUERY_AT_LEAST_ONE_TABLES,*this ); + getOwnConnection()->throwSQLException( STR_QUERY_AT_LEAST_ONE_TABLES, *this ); #if OSL_DEBUG_LEVEL > 0 OSQLTables::const_iterator citer; @@ -290,7 +290,7 @@ sal_Bool OStatement_Base::parseSql( const ::rtl::OUString& sql , sal_Bool bAdjus createTable(); return sal_False; default: - getOwnConnection()->throwGenericSQLException( STR_QUERY_TOO_COMPLEX ,*this); + getOwnConnection()->throwSQLException( STR_QUERY_TOO_COMPLEX, *this ); } } else if(!bAdjusted) //Our sql parser does not support a statement like "create table foo" @@ -299,7 +299,7 @@ sal_Bool OStatement_Base::parseSql( const ::rtl::OUString& sql , sal_Bool bAdjus return parseSql(sql + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("(""E-mail"" caracter)")),sal_True); } else - getOwnConnection()->throwGenericSQLException( STR_QUERY_TOO_COMPLEX ,*this); + getOwnConnection()->throwSQLException( STR_QUERY_TOO_COMPLEX, *this ); return sal_True; } diff --git a/connectivity/source/drivers/mozab/mozillasrc/MDatabaseMetaDataHelper.cxx b/connectivity/source/drivers/mozab/mozillasrc/MDatabaseMetaDataHelper.cxx index ee637ff763a6..f681d6953e04 100644 --- a/connectivity/source/drivers/mozab/mozillasrc/MDatabaseMetaDataHelper.cxx +++ b/connectivity/source/drivers/mozab/mozillasrc/MDatabaseMetaDataHelper.cxx @@ -64,6 +64,7 @@ static ::osl::Mutex m_aMetaMutex; #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XPropertySetInfo.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/sdb/ErrorCondition.hpp> #include <unotools/processfactory.hxx> #include <com/sun/star/mozilla/XMozillaBootstrap.hpp> @@ -86,6 +87,7 @@ using namespace com::sun::star::lang; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::sdbc; using namespace com::sun::star::mozilla; +using namespace com::sun::star::sdb; namespace connectivity { @@ -341,43 +343,43 @@ static nsresult getSubsFromURI(const rtl::OString& aUri, nsIEnumerator **aSubs) return retCode ; } -void MDatabaseMetaDataHelper::setAbSpecificError( OConnection* _pCon, sal_Bool bGivenURI ) +namespace { - if ( ! bGivenURI && m_ProductType ==::com::sun::star::mozilla::MozillaProductType_Mozilla) + static void lcl_setNoAddressBookFoundError( ErrorDescriptor& _rError, OConnection& _rCon, MozillaProductType _eProductType, + sal_Bool bGivenURI ) { - setError( STR_NO_MOZIILA_ADDRESSBOOK ); - } - else - { - if ( m_ProductType ==::com::sun::star::mozilla::MozillaProductType_Thunderbird) + sal_uInt16 nAddressBookNameRes = 0; + if ( !bGivenURI && _eProductType == MozillaProductType_Mozilla) { - setError( STR_NO_THUNDERBIRD_ADDRESSBOOK ); + nAddressBookNameRes = STR_MOZILLA_ADDRESSBOOKS; } else { - if (_pCon->usesFactory()) + if ( _eProductType == MozillaProductType_Thunderbird ) { - if ( _pCon->isOutlookExpress() ) - { - setError( STR_NO_OUTLOOKEXPRESS_ADDRESSBOOK ); - } - else - { - setError( STR_NO_OUTLOOK_ADDRESSBOOK ); - } + nAddressBookNameRes = STR_THUNDERBIRD_ADDRESSBOOKS; } else { - if (_pCon->isLDAP()) + if ( _rCon.usesFactory() ) { - setError( STR_COULDNOTCONNECT_TO_LDAP ); + if ( _rCon.isOutlookExpress() ) + { + nAddressBookNameRes = STR_OE_ADDRESSBOOK; + } + else + { + nAddressBookNameRes = STR_OUTLOOK_MAPI_ADDRESSBOOK; + } } else { - setError( STR_NO_MOZIILA_ADDRESSBOOK ); + OSL_ENSURE( !_rCon.isLDAP(), "lcl_setNoAddressBookFoundError: not to be called for LDAP connections!" ); + nAddressBookNameRes = STR_MOZILLA_ADDRESSBOOKS; } } } + _rError.set( 0, ErrorCondition::AB_ADDRESSBOOK_NOT_FOUND, _rCon.getResources().getResourceString( nAddressBookNameRes ) ); } } @@ -521,7 +523,7 @@ sal_Bool MDatabaseMetaDataHelper::getTableStrings( OConnection* nsresult rv = NS_OK; nsCOMPtr<nsIEnumerator> subDirectories; sal_Int32 nDirectoryType=0; - m_ProductType=::com::sun::star::mozilla::MozillaProductType_Mozilla; + m_ProductType = MozillaProductType_Mozilla; m_ProfileName = _pCon->getMozProfile(); @@ -530,30 +532,35 @@ sal_Bool MDatabaseMetaDataHelper::getTableStrings( OConnection* if (!bGivenURI) sAbURIString = s_pADDRESSBOOKROOTDIR; nDirectoryType = SDBCAddress::ThunderBird; - m_ProductType = ::com::sun::star::mozilla::MozillaProductType_Thunderbird; + m_ProductType = MozillaProductType_Thunderbird; } - else - if (!bGivenURI) { + else if (!bGivenURI) + { sAbURIString = s_pADDRESSBOOKROOTDIR; nDirectoryType = SDBCAddress::Mozilla; } - else { - if (_pCon->usesFactory()) { + else + { + if (_pCon->usesFactory()) + { nDirectoryType = SDBCAddress::Outlook; } - else { - if (_pCon->isLDAP()) { + else + { + if (_pCon->isLDAP()) + { nDirectoryType = SDBCAddress::LDAP; } - else { + else + { sAbURIString = s_pADDRESSBOOKROOTDIR; nDirectoryType = SDBCAddress::Mozilla; } } } - if (!m_bProfileExists) - { + if ( !_pCon->isLDAP() && !m_bProfileExists ) + { // no need to boot up a Mozilla profile for an LDAP connection Reference<XMozillaBootstrap> xMozillaBootstrap; Reference<XMultiServiceFactory> xFactory = ::comphelper::getProcessServiceFactory(); OSL_ENSURE( xFactory.is(), "can't get service factory" ); @@ -572,11 +579,14 @@ sal_Bool MDatabaseMetaDataHelper::getTableStrings( OConnection* m_bProfileExists = sal_True; } - if ( ( nDirectoryType == SDBCAddress::Mozilla - || m_ProductType ==::com::sun::star::mozilla::MozillaProductType_Thunderbird) - && !m_bProfileExists) + if ( !m_bProfileExists + && !_pCon->isLDAP() + && ( ( nDirectoryType == SDBCAddress::Mozilla ) + || ( nDirectoryType == SDBCAddress::ThunderBird ) + ) + ) { - setAbSpecificError( _pCon, bGivenURI ); + lcl_setNoAddressBookFoundError( m_aError, *_pCon, m_ProductType, bGivenURI ); return sal_False; } @@ -596,11 +606,12 @@ sal_Bool MDatabaseMetaDataHelper::getTableStrings( OConnection* args.arg5 = (void*)&m_aTableTypes; args.arg6 = (void*)&nErrorResourceId; rv = xMProxy.StartProxy(&args,m_ProductType,m_ProfileName); - setError( static_cast<sal_uInt16>(nErrorResourceId) ); + m_aError.setResId( static_cast<sal_uInt16>(nErrorResourceId) ); if (NS_FAILED(rv)) { - setAbSpecificError( _pCon, bGivenURI ); + if ( nErrorResourceId == 0 ) + m_aError.setResId( STR_UNSPECIFIED_ERROR ); return sal_False; } OSL_TRACE( "\tOUT MDatabaseMetaDataHelper::getTableStrings()\n" ); @@ -729,7 +740,7 @@ MDatabaseMetaDataHelper::testLDAPConnection( OConnection* _pCon ) osl_waitThread( &timeValue ); } } - setError( STR_COULD_NOT_CONNECT_LDAP ); + m_aError.setResId( STR_COULD_NOT_CONNECT_LDAP ); return NS_SUCCEEDED( rv ) ? sal_True : sal_False; } @@ -741,7 +752,7 @@ sal_Bool MDatabaseMetaDataHelper::NewAddressBook(OConnection* _pCon,const ::rtl: if ( !bIsMozillaAB ) { - setError( STR_NO_TABLE_CREATION_SUPPORT ); + m_aError.setResId( STR_NO_TABLE_CREATION_SUPPORT ); return sal_False; } else @@ -760,11 +771,11 @@ sal_Bool MDatabaseMetaDataHelper::NewAddressBook(OConnection* _pCon,const ::rtl: _pCon->setForceLoadTables(sal_True); //force reload table next time if (rv == NS_ERROR_FILE_IS_LOCKED) { - setError( STR_MOZILLA_IS_RUNNING ); + m_aError.setResId( STR_MOZILLA_IS_RUNNING ); } else if (NS_FAILED(rv)) { - setAbSpecificError( _pCon, !bIsMozillaAB ); + m_aError.set( STR_COULD_NOT_CREATE_ADDRESSBOOK, 0, ::rtl::OUString::valueOf( sal_Int32(rv), 16 ) ); } OSL_TRACE( "OUT MDatabaseMetaDataHelper::NewAddressBook()\n" ); return( NS_SUCCEEDED(rv) ? sal_True : sal_False ); diff --git a/connectivity/source/drivers/mozab/mozillasrc/MDatabaseMetaDataHelper.hxx b/connectivity/source/drivers/mozab/mozillasrc/MDatabaseMetaDataHelper.hxx index 9fcdc90d9a3e..8d2971f3e57f 100644 --- a/connectivity/source/drivers/mozab/mozillasrc/MDatabaseMetaDataHelper.hxx +++ b/connectivity/source/drivers/mozab/mozillasrc/MDatabaseMetaDataHelper.hxx @@ -48,7 +48,7 @@ namespace connectivity { namespace mozab { - class MDatabaseMetaDataHelper : public ErrorResourceAccess + class MDatabaseMetaDataHelper { private: sal_Bool m_bProfileExists ; @@ -56,6 +56,7 @@ namespace connectivity ::std::vector< ::rtl::OUString > m_aTableTypes; ::com::sun::star::mozilla::MozillaProductType m_ProductType; ::rtl::OUString m_ProfileName; + ErrorDescriptor m_aError; public: MDatabaseMetaDataHelper(); @@ -73,8 +74,7 @@ namespace connectivity sal_Bool testLDAPConnection( OConnection* _pCon ); sal_Bool NewAddressBook( OConnection* _pCon,const ::rtl::OUString & aTableName); - private: - void setAbSpecificError( OConnection* _pCon, sal_Bool bGivenURI ); + inline const ErrorDescriptor& getError() const { return m_aError; } }; } diff --git a/connectivity/source/drivers/mozab/mozillasrc/MErrorResource.hxx b/connectivity/source/drivers/mozab/mozillasrc/MErrorResource.hxx index 20a13554c7fa..1a644285f2cb 100644 --- a/connectivity/source/drivers/mozab/mozillasrc/MErrorResource.hxx +++ b/connectivity/source/drivers/mozab/mozillasrc/MErrorResource.hxx @@ -31,25 +31,48 @@ #ifndef CONNECITIVITY_MOZAB_ERROR_RESOURCE_HXX #define CONNECITIVITY_MOZAB_ERROR_RESOURCE_HXX -#include <sal/types.h> +#include <rtl/ustring.hxx> namespace connectivity { namespace mozab { - class ErrorResourceAccess + class ErrorDescriptor { private: - mutable sal_uInt16 m_nErrorResourceId; + sal_uInt16 m_nErrorResourceId; + sal_Int32 m_nErrorCondition; + ::rtl::OUString m_sParameter; - protected: - ErrorResourceAccess() : m_nErrorResourceId(0) { } - - inline void setError( sal_uInt16 _nErrorResourceId ) const { const_cast< ErrorResourceAccess* >( this )->m_nErrorResourceId = _nErrorResourceId; } - inline void resetError( ) const { const_cast< ErrorResourceAccess* >( this )->m_nErrorResourceId = 0; } public: - inline sal_uInt16 getErrorResourceId() const - { return m_nErrorResourceId; } + ErrorDescriptor() + :m_nErrorResourceId(0) + ,m_nErrorCondition(0) + ,m_sParameter() + { + } + + inline void set( const sal_uInt16 _nErrorResourceId, const sal_Int32 _nErrorCondition, const ::rtl::OUString& _rParam ) + { + m_nErrorResourceId = _nErrorResourceId; + m_nErrorCondition = _nErrorCondition; + m_sParameter = _rParam; + } + inline void setResId( const sal_uInt16 _nErrorResourceId ) + { + m_nErrorResourceId = _nErrorResourceId; + } + inline void reset() + { + m_nErrorResourceId = 0; + m_nErrorCondition = 0; + } + + inline sal_uInt16 getResId() const { return m_nErrorResourceId; } + inline sal_Int32 getErrorCondition() const { return m_nErrorCondition; } + inline const ::rtl::OUString& getParameter() const { return m_sParameter; } + + inline bool is() const { return ( m_nErrorResourceId != 0 ) || ( m_nErrorCondition != 0 ); } }; } } diff --git a/connectivity/source/drivers/mozab/mozillasrc/MQuery.cxx b/connectivity/source/drivers/mozab/mozillasrc/MQuery.cxx index 295231635efd..b298e56262cc 100644 --- a/connectivity/source/drivers/mozab/mozillasrc/MQuery.cxx +++ b/connectivity/source/drivers/mozab/mozillasrc/MQuery.cxx @@ -127,7 +127,7 @@ MQuery::~MQuery() void MQuery::construct() { // Set default values. (For now just as a reminder). - m_aErrorOccurred = sal_False; + m_aError.reset(); m_bQuerySubDirs = sal_True; // LDAP Queryies require this to be set! m_nMaxNrOfReturns = -1; // Unlimited number of returns. @@ -459,7 +459,7 @@ sal_Int32 MQuery::commitRow(const sal_Int32 rowIndex) args.arg2 = (void*)&rowIndex; args.arg3 = (void*)m_aQueryDirectory->directory; nsresult rv = xMProxy.StartProxy(&args,m_Product,m_Profile); - setError( m_aQueryHelper->getErrorResourceId() ); + m_aError = m_aQueryHelper->getError(); return rv; } @@ -476,7 +476,7 @@ sal_Int32 MQuery::deleteRow(const sal_Int32 rowIndex) args.arg2 = (void*)&rowIndex; args.arg3 = (void*)m_aQueryDirectory->directory; nsresult rv = xMProxy.StartProxy(&args,m_Product,m_Profile); - setError( m_aQueryHelper->getErrorResourceId() ); + m_aError = m_aQueryHelper->getError(); return rv; } @@ -623,7 +623,7 @@ sal_Int32 MQuery::executeQueryProxied(OConnection* _pCon) // Execute the query. OSL_TRACE( "****** calling DoQuery\n"); - m_aErrorOccurred = sal_False; + m_aError.reset(); m_aQueryHelper->reset(); @@ -679,7 +679,7 @@ MQuery::getRealRowCount() sal_Bool MQuery::queryComplete( void ) { - return( m_aErrorOccurred || m_aQueryHelper->queryComplete() ); + return( hadError() || m_aQueryHelper->queryComplete() ); } sal_Bool @@ -687,8 +687,7 @@ MQuery::waitForQueryComplete( void ) { if( m_aQueryHelper->waitForQueryComplete( ) ) return sal_True; - setError( m_aQueryHelper->getErrorResourceId() ); - m_aErrorOccurred = sal_True; + m_aError = m_aQueryHelper->getError(); return( sal_False ); } @@ -699,8 +698,7 @@ MQuery::checkRowAvailable( sal_Int32 nDBRow ) { while( !queryComplete() && m_aQueryHelper->getRealCount() <= (sal_uInt32)nDBRow ) if ( !m_aQueryHelper->waitForRow( nDBRow ) ) { - m_aErrorOccurred = sal_True; - setError( m_aQueryHelper->getErrorResourceId() ); + m_aError = m_aQueryHelper->getError(); return( sal_False ); } @@ -715,8 +713,7 @@ MQuery::setRowValue( ORowSetValue& rValue, sal_Int32 nDBRow,const rtl::OUString& OSL_ENSURE( xResEntry != NULL, "xResEntry == NULL"); if (xResEntry == NULL ) { - m_aErrorOccurred = sal_True; - setError( m_aQueryHelper->getErrorResourceId() ); + const_cast< MQuery* >( this )->m_aError = m_aQueryHelper->getError(); return sal_False; } switch ( nType ) @@ -741,8 +738,7 @@ MQuery::getRowValue( ORowSetValue& rValue, sal_Int32 nDBRow,const rtl::OUString& OSL_ENSURE( xResEntry != NULL, "xResEntry == NULL"); if (xResEntry == NULL ) { - m_aErrorOccurred = sal_True; - setError( m_aQueryHelper->getErrorResourceId() ); + const_cast< MQuery* >( this )->m_aError = m_aQueryHelper->getError(); rValue.setNull(); return sal_False; } @@ -768,8 +764,7 @@ MQuery::getRowStates(sal_Int32 nDBRow) OSL_ENSURE( xResEntry != NULL, "xResEntry == NULL"); if (xResEntry == NULL ) { - m_aErrorOccurred = sal_True; - setError( m_aQueryHelper->getErrorResourceId() ); + m_aError = m_aQueryHelper->getError(); return RowStates_Error; } return xResEntry->getRowStates(); @@ -782,8 +777,7 @@ MQuery::setRowStates(sal_Int32 nDBRow,sal_Int32 aState) OSL_ENSURE( xResEntry != NULL, "xResEntry == NULL"); if (xResEntry == NULL ) { - m_aErrorOccurred = sal_True; - setError( m_aQueryHelper->getErrorResourceId() ); + m_aError = m_aQueryHelper->getError(); return sal_False; } return xResEntry->setRowStates(aState); @@ -799,7 +793,7 @@ MQuery::resyncRow(sal_Int32 nDBRow) args.arg1 = (void*)m_aQueryHelper; args.arg2 = (void*)&nDBRow; nsresult rv = xMProxy.StartProxy(&args,m_Product,m_Profile); - setError( m_aQueryHelper->getErrorResourceId() ); + m_aError = m_aQueryHelper->getError(); return NS_SUCCEEDED( rv ) ? sal_True : sal_False; } @@ -815,7 +809,7 @@ MQuery::createNewCard() args.arg2 = (void*)&nNumber; nsresult rv = xMProxy.StartProxy(&args,m_Product,m_Profile); - setError( m_aQueryHelper->getErrorResourceId() ); + m_aError = m_aQueryHelper->getError(); NS_ENSURE_SUCCESS(rv,0); return nNumber; } diff --git a/connectivity/source/drivers/mozab/mozillasrc/MQuery.hxx b/connectivity/source/drivers/mozab/mozillasrc/MQuery.hxx index 75dc59732403..7ff57d8d0d23 100644 --- a/connectivity/source/drivers/mozab/mozillasrc/MQuery.hxx +++ b/connectivity/source/drivers/mozab/mozillasrc/MQuery.hxx @@ -156,7 +156,7 @@ namespace connectivity }; - class MQuery : public ErrorResourceAccess + class MQuery { /* * A query resultset with a maximum limit of @@ -211,9 +211,11 @@ namespace connectivity sal_Bool m_bQuerySubDirs; MQueryExpression m_aExpr; const OColumnAlias& m_rColumnAlias; - mutable sal_Bool m_aErrorOccurred; - ::com::sun::star::mozilla::MozillaProductType m_Product; - ::rtl::OUString m_Profile; + ::com::sun::star::mozilla::MozillaProductType + m_Product; + ::rtl::OUString m_Profile; + ErrorDescriptor m_aError; + void construct(); protected: ::osl::Mutex m_aMutex; @@ -270,8 +272,8 @@ namespace connectivity sal_Int32 getRowStates(sal_Int32 nDBRow); sal_Bool setRowStates(sal_Int32 nDBRow,sal_Int32 aState); - sal_Bool errorOccurred() const - { return m_aErrorOccurred; }; + bool hadError() const { return m_aError.is(); } + inline const ErrorDescriptor& getError() const { return m_aError; } public: // MQuery(); diff --git a/connectivity/source/drivers/mozab/mozillasrc/MQueryHelper.cxx b/connectivity/source/drivers/mozab/mozillasrc/MQueryHelper.cxx index 6e941175b59a..01fed34d8b39 100644 --- a/connectivity/source/drivers/mozab/mozillasrc/MQueryHelper.cxx +++ b/connectivity/source/drivers/mozab/mozillasrc/MQueryHelper.cxx @@ -238,16 +238,16 @@ MQueryHelper::waitForResultOrComplete( ) } if (times >= 20 && rv == ::osl::Condition::result_timeout ) { OSL_TRACE("waitForResultOrComplete() : Timeout!"); - setError( STR_TIMEOUT_WAITING ); + m_aError.setResId( STR_TIMEOUT_WAITING ); return sal_False; } if ( isError() ) { OSL_TRACE("waitForResultOrComplete() : Error returned!"); - setError( STR_ERR_EXECUTING_QUERY ); + m_aError.setResId( STR_ERR_EXECUTING_QUERY ); return sal_False; } - resetError(); + m_aError.reset(); OSL_TRACE(" Out : waitForResultOrComplete()"); return sal_True; } @@ -583,7 +583,7 @@ nsIAbCard * getUpdatedCard( nsIAbCard* card) #define ENSURE_MOZAB_PROFILE_NOT_LOOKED(directory) \ if (getDirectoryType(directory) == SDBCAddress::Mozilla && isProfileLocked(NULL)) \ { \ - setError( STR_MOZILLA_IS_RUNNIG_NO_CHANGES ); \ + m_aError.setResId( STR_MOZILLA_IS_RUNNIG_NO_CHANGES ); \ return sal_False; \ } @@ -620,7 +620,7 @@ sal_Int32 MQueryHelper::commitCard(const sal_Int32 rowIndex,nsIAbDirectory * dir } //We return NS_ERROR_FILE_ACCESS_DENIED in the case the mozillaAB has been changed out side of our process if (rv == NS_ERROR_FILE_ACCESS_DENIED ) - setError( STR_FOREIGN_PROCESS_CHANGED_AB ); + m_aError.setResId( STR_FOREIGN_PROCESS_CHANGED_AB ); return !(NS_FAILED(rv)); } @@ -668,7 +668,7 @@ sal_Int32 MQueryHelper::deleteCard(const sal_Int32 rowIndex,nsIAbDirectory * dir resEntry->setRowStates(RowStates_Deleted); //We return NS_ERROR_FILE_ACCESS_DENIED in the case the mozillaAB has been changed out side of our process if (rv == NS_ERROR_FILE_ACCESS_DENIED ) - setError( STR_FOREIGN_PROCESS_CHANGED_AB ); + m_aError.setResId( STR_FOREIGN_PROCESS_CHANGED_AB ); return !(NS_FAILED(rv)); } @@ -677,13 +677,13 @@ sal_Bool MQueryHelper::setCardValues(const sal_Int32 rowIndex) MQueryHelperResultEntry *resEntry = getByIndex(rowIndex); if (!resEntry) { - setError( STR_CANT_FIND_ROW ); + m_aError.setResId( STR_CANT_FIND_ROW ); return sal_False; } nsIAbCard *card=resEntry->getCard(); if (!card) { - setError( STR_CANT_FIND_CARD_FOR_ROW ); + m_aError.setResId( STR_CANT_FIND_CARD_FOR_ROW ); return sal_False; } @@ -967,7 +967,7 @@ sal_Bool MQueryHelper::resyncRow(sal_Int32 rowIndex) MQueryHelperResultEntry *resEntry = getByIndex(rowIndex); if (!resEntry) { - setError( STR_CANT_FIND_ROW ); + m_aError.setResId( STR_CANT_FIND_ROW ); return sal_False; } nsIAbCard *card=resEntry->getCard(); diff --git a/connectivity/source/drivers/mozab/mozillasrc/MQueryHelper.hxx b/connectivity/source/drivers/mozab/mozillasrc/MQueryHelper.hxx index a077b26f0bab..2f3f4db2d7c5 100644 --- a/connectivity/source/drivers/mozab/mozillasrc/MQueryHelper.hxx +++ b/connectivity/source/drivers/mozab/mozillasrc/MQueryHelper.hxx @@ -68,7 +68,7 @@ namespace connectivity sal_Int32 getRowStates() { return m_RowStates;}; }; - class MQueryHelper : public nsIAbDirectoryQueryResultListener, public ErrorResourceAccess + class MQueryHelper : public nsIAbDirectoryQueryResultListener { private: typedef std::vector< MQueryHelperResultEntry* > resultsArray; @@ -81,6 +81,7 @@ namespace connectivity sal_Bool m_bAtEnd; sal_Bool m_bErrorCondition; sal_Bool m_bQueryComplete; + ErrorDescriptor m_aError; void append(MQueryHelperResultEntry* resEnt ); @@ -113,6 +114,8 @@ namespace connectivity MQueryHelperResultEntry* getByIndex( sal_uInt32 nRow ); + const ErrorDescriptor& getError() const { return m_aError; } + sal_Bool isError() const; sal_Bool hasMore() const; diff --git a/connectivity/source/drivers/mysql/YDriver.cxx b/connectivity/source/drivers/mysql/YDriver.cxx index dcee418b88e5..ea5afad3719e 100644 --- a/connectivity/source/drivers/mysql/YDriver.cxx +++ b/connectivity/source/drivers/mysql/YDriver.cxx @@ -193,7 +193,7 @@ namespace connectivity else { aProps.push_back( PropertyValue( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NewURL")) + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PublicConnectionURL")) ,0 ,makeAny(_sUrl) ,PropertyState_DIRECT_VALUE) ); diff --git a/connectivity/source/inc/dbase/DTable.hxx b/connectivity/source/inc/dbase/DTable.hxx index 80aa1a10fdf5..b9965b6c85a7 100644 --- a/connectivity/source/inc/dbase/DTable.hxx +++ b/connectivity/source/inc/dbase/DTable.hxx @@ -55,6 +55,7 @@ namespace connectivity dBaseIV = 0x04, dBaseV = 0x05, VisualFoxPro = 0x30, + VisualFoxProAuto = 0x31, // Visual FoxPro w. AutoIncrement field dBaseFS = 0x43, dBaseFSMemo = 0xB3, dBaseIIIMemo = 0x83, @@ -95,6 +96,7 @@ namespace connectivity ::std::vector<sal_Int32> m_aTypes; // holds all type for columns just to avoid to ask the propertyset ::std::vector<sal_Int32> m_aPrecisions; // same as aboth ::std::vector<sal_Int32> m_aScales; + ::std::vector<sal_Int32> m_aRealFieldLengths; DBFHeader m_aHeader; DBFMemoHeader m_aMemoHeader; SvStream* m_pMemoStream; diff --git a/connectivity/source/inc/internalnode.hxx b/connectivity/source/inc/internalnode.hxx index bb2f32c24d69..d313525a6a03 100644 --- a/connectivity/source/inc/internalnode.hxx +++ b/connectivity/source/inc/internalnode.hxx @@ -40,7 +40,7 @@ namespace connectivity //========================================================================== /** special node for avoiding memory leaks */ - class OOO_DLLPUBLIC_DBTOOLS OSQLInternalNode : public OSQLParseNode + class OSQLInternalNode : public OSQLParseNode { public: OSQLInternalNode(const sal_Char* pNewValue, diff --git a/connectivity/source/inc/resource/mozab_res.hrc b/connectivity/source/inc/resource/mozab_res.hrc index 5ad8fc86e95c..c866291d1492 100644 --- a/connectivity/source/inc/resource/mozab_res.hrc +++ b/connectivity/source/inc/resource/mozab_res.hrc @@ -39,11 +39,11 @@ // = the mozab driver's resource strings // ============================================================================ -#define STR_NO_MOZIILA_ADDRESSBOOK ( STR_MOZAB_BASE + 0 ) -#define STR_NO_THUNDERBIRD_ADDRESSBOOK ( STR_MOZAB_BASE + 1 ) -#define STR_NO_OUTLOOKEXPRESS_ADDRESSBOOK ( STR_MOZAB_BASE + 2 ) -#define STR_NO_OUTLOOK_ADDRESSBOOK ( STR_MOZAB_BASE + 3 ) -#define STR_COULDNOTCONNECT_TO_LDAP ( STR_MOZAB_BASE + 4 ) +#define STR_MOZILLA_ADDRESSBOOKS ( STR_MOZAB_BASE + 0 ) +#define STR_THUNDERBIRD_ADDRESSBOOKS ( STR_MOZAB_BASE + 1 ) +#define STR_OE_ADDRESSBOOK ( STR_MOZAB_BASE + 2 ) +#define STR_OUTLOOK_MAPI_ADDRESSBOOK ( STR_MOZAB_BASE + 3 ) + // FREE #define STR_NO_TABLE_CREATION_SUPPORT ( STR_MOZAB_BASE + 5 ) #define STR_MOZILLA_IS_RUNNING ( STR_MOZAB_BASE + 6 ) #define STR_COULD_NOT_RETRIEVE_AB_ENTRY ( STR_MOZAB_BASE + 7 ) @@ -70,6 +70,8 @@ #define STR_NO_COUNT_SUPPORT ( STR_MOZAB_BASE + 28 ) #define STR_STMT_TYPE_NOT_SUPPORTED ( STR_MOZAB_BASE + 29 ) #define STR_COULD_NOT_LOAD_LIB ( STR_MOZAB_BASE + 30 ) +#define STR_UNSPECIFIED_ERROR ( STR_MOZAB_BASE + 31 ) +#define STR_COULD_NOT_CREATE_ADDRESSBOOK ( STR_MOZAB_BASE + 32 ) #endif // CONNECTIVITY_RESOURCE_MOZAB_HRC diff --git a/connectivity/source/parse/internalnode.cxx b/connectivity/source/parse/internalnode.cxx index 9b83e708e452..752211c423d2 100644 --- a/connectivity/source/parse/internalnode.cxx +++ b/connectivity/source/parse/internalnode.cxx @@ -44,7 +44,7 @@ OSQLInternalNode::OSQLInternalNode(const sal_Char* pNewValue, : OSQLParseNode(pNewValue,eNodeType,nNodeID) { OSL_ENSURE(OSQLParser::s_pGarbageCollector, "Collector not initialized"); - OSQLParser::s_pGarbageCollector->push_back(this); + (*OSQLParser::s_pGarbageCollector)->push_back(this); } //----------------------------------------------------------------------------- @@ -54,7 +54,7 @@ OSQLInternalNode::OSQLInternalNode(const ::rtl::OString &_NewValue, :OSQLParseNode(_NewValue,eNodeType,nNodeID) { OSL_ENSURE(OSQLParser::s_pGarbageCollector, "Collector not initialized"); - OSQLParser::s_pGarbageCollector->push_back(this); + (*OSQLParser::s_pGarbageCollector)->push_back(this); } //----------------------------------------------------------------------------- @@ -64,7 +64,7 @@ OSQLInternalNode::OSQLInternalNode(const sal_Unicode* pNewValue, :OSQLParseNode(pNewValue,eNodeType,nNodeID) { OSL_ENSURE(OSQLParser::s_pGarbageCollector, "Collector not initialized"); - OSQLParser::s_pGarbageCollector->push_back(this); + (*OSQLParser::s_pGarbageCollector)->push_back(this); } //----------------------------------------------------------------------------- @@ -74,7 +74,7 @@ OSQLInternalNode::OSQLInternalNode(const ::rtl::OUString &_NewValue, :OSQLParseNode(_NewValue,eNodeType,nNodeID) { OSL_ENSURE(OSQLParser::s_pGarbageCollector, "Collector not initialized"); - OSQLParser::s_pGarbageCollector->push_back(this); + (*OSQLParser::s_pGarbageCollector)->push_back(this); } @@ -82,11 +82,7 @@ OSQLInternalNode::OSQLInternalNode(const ::rtl::OUString &_NewValue, OSQLInternalNode::~OSQLInternalNode() { // remove the node from the garbage list + OSL_ENSURE(OSQLParser::s_pGarbageCollector, "Collector not initialized"); - if (!OSQLParser::s_pGarbageCollector->empty()) - { - OSQLParser::s_pGarbageCollector->erase( - ::std::find(OSQLParser::s_pGarbageCollector->begin(), OSQLParser::s_pGarbageCollector->end(), - this)); - } + (*OSQLParser::s_pGarbageCollector)->erase(this); } diff --git a/connectivity/source/parse/sqlbison.y b/connectivity/source/parse/sqlbison.y index 6f625bd2312c..a42c3cb2302c 100644 --- a/connectivity/source/parse/sqlbison.y +++ b/connectivity/source/parse/sqlbison.y @@ -90,6 +90,7 @@ #ifndef _DBHELPER_DBCONVERSION_HXX_ #include "connectivity/dbconversion.hxx" #endif +#include <rtl/ustrbuf.hxx> #if defined __GNUC__ #pragma GCC system_header @@ -3362,34 +3363,44 @@ const double fMilliSecondsPerDay = 86400000.0; //------------------------------------------------------------------ ::rtl::OUString ConvertLikeToken(const OSQLParseNode* pTokenNode, const OSQLParseNode* pEscapeNode, sal_Bool bInternational) { - ::rtl::OUString aMatchStr; + ::rtl::OUStringBuffer aMatchStr; if (pTokenNode->isToken()) { - sal_Char cEscape = 0; + sal_Unicode cEscape = 0; if (pEscapeNode->count()) - cEscape = static_cast<sal_Char>(pEscapeNode->getChild(1)->getTokenValue().toChar()); + cEscape = pEscapeNode->getChild(1)->getTokenValue().toChar(); // Platzhalter austauschen aMatchStr = pTokenNode->getTokenValue(); - sal_Int32 nLen = aMatchStr.getLength(); - const sal_Char* sSearch = bInternational ? "%_" : "*?"; - const sal_Char* sReplace = bInternational ? "*?" : "%_"; + const sal_Int32 nLen = aMatchStr.getLength(); + ::rtl::OUStringBuffer sSearch,sReplace; + if ( bInternational ) + { + sSearch.appendAscii("%_",2); + sReplace.appendAscii("*?",2); + } + else + { + sSearch.appendAscii("*?",2); + sReplace.appendAscii("%_",2); + } + for (sal_Int32 i = 0; i < nLen; i++) { - sal_Char c = static_cast<sal_Char>(aMatchStr.getStr()[i]); - if (c == sSearch[0] || c == sSearch[1]) + const sal_Unicode c = aMatchStr.charAt(i); + if (c == sSearch.charAt(0) || c == sSearch.charAt(1)) { - if (i > 0 && aMatchStr.getStr()[i-1] == cEscape) + if (i > 0 && aMatchStr.charAt(i-1) == cEscape) continue; else { - sal_Unicode cCharacter = sReplace[(c == sSearch[0]) ? 0 : 1]; - aMatchStr = aMatchStr.replaceAt(i , 1, ::rtl::OUString(&cCharacter, 1)); + const sal_Unicode cCharacter = sReplace.charAt( (c == sSearch.charAt(0)) ? 0 : 1); + aMatchStr.setCharAt(i , cCharacter); } } } } - return aMatchStr; + return aMatchStr.makeStringAndClear(); } //========================================================================== @@ -3403,7 +3414,7 @@ OParseContext OSQLParser::s_aDefaultContext; sal_Int32 OSQLParser::s_nRefCount = 0; // ::osl::Mutex OSQLParser::s_aMutex; OSQLScanner* OSQLParser::s_pScanner = 0; -OSQLParseNodes* OSQLParser::s_pGarbageCollector = 0; +OSQLParseNodesGarbageCollector* OSQLParser::s_pGarbageCollector = 0; ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XLocaleData> OSQLParser::s_xLocaleData = NULL; //----------------------------------------------------------------------------- void setParser(OSQLParser* _pParser) @@ -3449,18 +3460,12 @@ OSQLParseNode* OSQLParser::parseTree(::rtl::OUString& rErrorMessage, rErrorMessage = m_sErrorMessage; // clear the garbage collector - while (!s_pGarbageCollector->empty()) - { - OSQLParseNode* pNode = *s_pGarbageCollector->begin(); - while (pNode->getParent()) - pNode = pNode->getParent(); - delete pNode; - } + (*s_pGarbageCollector)->clearAndDelete(); return NULL; } else { - s_pGarbageCollector->clear(); + (*s_pGarbageCollector)->clear(); // Das Ergebnis liefern (den Root Parse Node): diff --git a/connectivity/source/parse/sqlflex.l b/connectivity/source/parse/sqlflex.l index 8004276e5961..19d2b8a27d8e 100644 --- a/connectivity/source/parse/sqlflex.l +++ b/connectivity/source/parse/sqlflex.l @@ -41,9 +41,7 @@ #include <string.h> #endif -#ifndef _CONNECTIVITY_SQLINTERNALNODE_HXX #include "internalnode.hxx" -#endif #ifndef _CONNECTIVITY_SQLYACC_HXX #define _CONNECTIVITY_SQLYACC_HXX @@ -54,15 +52,10 @@ #include "sqlbison.hxx" #endif -#ifndef _CONNECTIVITY_SQLSCAN_HXX #include "sqlscan.hxx" -#endif -#ifndef _OSL_DIAGNOSE_H_ #include <osl/diagnose.h> -#endif -#ifndef _CONNECTIVITY_SQLPARSE_HXX +#include <rtl/strbuf.hxx> #include <connectivity/sqlparse.hxx> -#endif #if defined __GNUC__ #pragma GCC system_header @@ -460,14 +453,8 @@ inline bool checkeof(int c) { return c == 0 || c == EOF; } */ sal_Int32 gatherString( sal_Int32 delim, sal_Int32 nTyp) { - sal_Int32 ch; - static sal_Int32 BUFFERSIZE = 256; - static sal_Char* Buffer = 0; - if(!Buffer) - Buffer = new sal_Char[BUFFERSIZE]; - - sal_Char *s = Buffer; - sal_Int32 nPos = 0; + sal_Char ch; + ::rtl::OStringBuffer sBuffer(256); while (!checkeof(ch = yyinput())) { @@ -478,40 +465,22 @@ sal_Int32 gatherString( sal_Int32 delim, sal_Int32 nTyp) if (!checkeof(ch)) unput(ch); - *s = '\0'; - switch(nTyp) { case 0: - SQL_NEW_NODE(::rtl::OUString(Buffer,nPos,RTL_TEXTENCODING_UTF8), SQL_NODE_NAME); - delete[] Buffer; - Buffer = NULL; + SQL_NEW_NODE(::rtl::OStringToOUString(sBuffer.makeStringAndClear(),RTL_TEXTENCODING_UTF8), SQL_NODE_NAME); return SQL_TOKEN_NAME; case 1: - SQL_NEW_NODE(::rtl::OUString(Buffer,nPos,RTL_TEXTENCODING_UTF8), SQL_NODE_STRING); - delete[] Buffer; - Buffer = NULL; + SQL_NEW_NODE(::rtl::OStringToOUString(sBuffer.makeStringAndClear(),RTL_TEXTENCODING_UTF8), SQL_NODE_STRING); return SQL_TOKEN_STRING; case 2: - SQL_NEW_NODE(::rtl::OUString(Buffer,nPos,RTL_TEXTENCODING_UTF8), SQL_NODE_ACCESS_DATE); - delete[] Buffer; - Buffer = NULL; + SQL_NEW_NODE(::rtl::OStringToOUString(sBuffer.makeStringAndClear(),RTL_TEXTENCODING_UTF8), SQL_NODE_ACCESS_DATE); return SQL_TOKEN_ACCESS_DATE; } } else { - *s++ = ch; - if (++nPos == BUFFERSIZE) - { - ::rtl::OString aBuf(Buffer); - delete[] Buffer; - BUFFERSIZE *=2; - Buffer = new sal_Char[BUFFERSIZE]; - for(sal_Int32 i=0;i<aBuf.getLength();++i,++Buffer) - *Buffer = aBuf.getStr()[i]; - s = &Buffer[nPos]; - } + sBuffer.append(ch); } } @@ -519,23 +488,10 @@ sal_Int32 gatherString( sal_Int32 delim, sal_Int32 nTyp) break; else { - *s++ = ch; - if (++nPos == BUFFERSIZE) - { - ::rtl::OString aBuf(Buffer); - delete[] Buffer; - BUFFERSIZE *=2; - Buffer = new sal_Char[BUFFERSIZE]; - for(sal_Int32 i=0;i<aBuf.getLength();++i,++Buffer) - *Buffer = aBuf.getStr()[i]; - s = &Buffer[nPos]; - } + sBuffer.append(ch); } } - *s = '\0'; YY_FATAL_ERROR("Unterminated name string"); - delete[] Buffer; - Buffer = NULL; return SQL_TOKEN_INVALIDSYMBOL; } diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index 4f8517d41703..23aba56aec44 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -386,17 +386,17 @@ void OSQLParseNode::impl_parseNodeToString_throw(::rtl::OUString& rString, const if(rString.getLength()) rString += ::rtl::OUString::createFromAscii(" "); if (nCount == 1) // ? - m_aChilds[0]->impl_parseNodeToString_throw( rString, rParam ); + m_aChildren[0]->impl_parseNodeToString_throw( rString, rParam ); else if (nCount == 2) // :Name { - m_aChilds[0]->impl_parseNodeToString_throw( rString, rParam ); - rString += m_aChilds[1]->m_aNodeValue; + m_aChildren[0]->impl_parseNodeToString_throw( rString, rParam ); + rString += m_aChildren[1]->m_aNodeValue; } // [Name] else { - m_aChilds[0]->impl_parseNodeToString_throw( rString, rParam ); - rString += m_aChilds[1]->m_aNodeValue; - rString += m_aChilds[2]->m_aNodeValue; + m_aChildren[0]->impl_parseNodeToString_throw( rString, rParam ); + rString += m_aChildren[1]->m_aNodeValue; + rString += m_aChildren[2]->m_aNodeValue; } bHandled = true; } @@ -443,13 +443,13 @@ void OSQLParseNode::impl_parseNodeToString_throw(::rtl::OUString& rString, const SQLParseNodeParameter aNewParam(rParam); aNewParam.bQuote = ( SQL_ISRULE(this,length_exp) || SQL_ISRULE(this,char_value_fct) ); - m_aChilds[0]->impl_parseNodeToString_throw( rString, aNewParam ); + m_aChildren[0]->impl_parseNodeToString_throw( rString, aNewParam ); aNewParam.bQuote = rParam.bQuote; //aNewParam.bPredicate = sal_False; // disable [ ] around names // look at i73215 ::rtl::OUString aStringPara; for (sal_uInt32 i=1; i<nCount; i++) { - const OSQLParseNode * pSubTree = m_aChilds[i]; + const OSQLParseNode * pSubTree = m_aChildren[i]; if (pSubTree) { pSubTree->impl_parseNodeToString_throw( aStringPara, aNewParam ); @@ -473,8 +473,8 @@ void OSQLParseNode::impl_parseNodeToString_throw(::rtl::OUString& rString, const if ( !bHandled ) { - for (OSQLParseNodes::const_iterator i = m_aChilds.begin(); - i != m_aChilds.end();) + for (OSQLParseNodes::const_iterator i = m_aChildren.begin(); + i != m_aChildren.end();) { const OSQLParseNode* pSubTree = *i; if ( !pSubTree ) @@ -508,7 +508,7 @@ void OSQLParseNode::impl_parseNodeToString_throw(::rtl::OUString& rString, const if(pSubTree->count()) { - const OSQLParseNode* pCol = pSubTree->m_aChilds[pSubTree->count()-1]; + const OSQLParseNode* pCol = pSubTree->m_aChildren[pSubTree->count()-1]; if ( ( SQL_ISRULE(pCol,column_val) && pCol->getChild(0)->getTokenValue().equalsIgnoreAsciiCase(aFieldName) ) @@ -524,7 +524,7 @@ void OSQLParseNode::impl_parseNodeToString_throw(::rtl::OUString& rString, const if (SQL_ISRULE(this, comparison_predicate)) { ++i; - if(i != m_aChilds.end()) + if(i != m_aChildren.end()) { pSubTree = *i; if (pSubTree && pSubTree->getNodeType() == SQL_NODE_EQUAL) @@ -540,7 +540,7 @@ void OSQLParseNode::impl_parseNodeToString_throw(::rtl::OUString& rString, const i++; // bei den CommaListen zwischen alle Subtrees Commas setzen - if ((m_eNodeType == SQL_NODE_COMMALISTRULE) && (i != m_aChilds.end())) + if ((m_eNodeType == SQL_NODE_COMMALISTRULE) && (i != m_aChildren.end())) rString += ::rtl::OUString::createFromAscii(","); } } @@ -550,7 +550,7 @@ void OSQLParseNode::impl_parseNodeToString_throw(::rtl::OUString& rString, const i++; // bei den CommaListen zwischen alle Subtrees Commas setzen - if ((m_eNodeType == SQL_NODE_COMMALISTRULE) && (i != m_aChilds.end())) + if ((m_eNodeType == SQL_NODE_COMMALISTRULE) && (i != m_aChildren.end())) { if (SQL_ISRULE(this,value_exp_commalist) && rParam.bPredicate) rString += ::rtl::OUString::createFromAscii(";"); @@ -668,7 +668,7 @@ void OSQLParseNode::impl_parseTableRangeNodeToString_throw(::rtl::OUString& rStr OSL_PRECOND( ( count() == 2 ) || ( count() == 3 ) || ( count() == 5 ) ,"Illegal count"); // rString += ::rtl::OUString::createFromAscii(" "); - ::std::for_each(m_aChilds.begin(),m_aChilds.end(), + ::std::for_each(m_aChildren.begin(),m_aChildren.end(), boost::bind( &OSQLParseNode::impl_parseNodeToString_throw, _1, boost::ref( rString ), boost::cref( rParam ) )); } @@ -701,9 +701,9 @@ void OSQLParseNode::impl_parseLikeNodeToString_throw( ::rtl::OUString& rString, { OSL_ENSURE( false, "OSQLParseNode::impl_parseLikeNodeToString_throw Exception occured!" ); } - if ( !m_aChilds[0]->isLeaf() ) + if ( !m_aChildren[0]->isLeaf() ) { - const OSQLParseNode* pCol = m_aChilds[0]->getChild(m_aChilds[0]->count()-1); + const OSQLParseNode* pCol = m_aChildren[0]->getChild(m_aChildren[0]->count()-1); if ((SQL_ISRULE(pCol,column_val) && pCol->getChild(0)->getTokenValue().equalsIgnoreAsciiCase(aFieldName)) || pCol->getTokenValue().equalsIgnoreAsciiCase(aFieldName) ) bAddName = sal_False; @@ -711,15 +711,15 @@ void OSQLParseNode::impl_parseLikeNodeToString_throw( ::rtl::OUString& rString, } if (bAddName) - m_aChilds[0]->impl_parseNodeToString_throw( rString, aNewParam ); + m_aChildren[0]->impl_parseNodeToString_throw( rString, aNewParam ); - m_aChilds[1]->impl_parseNodeToString_throw( rString, aNewParam ); + m_aChildren[1]->impl_parseNodeToString_throw( rString, aNewParam ); if(count() == 5) - m_aChilds[2]->impl_parseNodeToString_throw( rString, aNewParam ); + m_aChildren[2]->impl_parseNodeToString_throw( rString, aNewParam ); - sal_Int32 nCurentPos = m_aChilds.size()-2; - pParaNode = m_aChilds[nCurentPos]; - pEscNode = m_aChilds[nCurentPos+1]; + sal_Int32 nCurentPos = m_aChildren.size()-2; + pParaNode = m_aChildren[nCurentPos]; + pEscNode = m_aChildren[nCurentPos+1]; if (pParaNode->isToken()) { @@ -1255,18 +1255,12 @@ OSQLParseNode* OSQLParser::predicateTree(::rtl::OUString& rErrorMessage, const : rErrorMessage = m_sErrorMessage; // clear the garbage collector - while (!s_pGarbageCollector->empty()) - { - OSQLParseNode* pNode = *s_pGarbageCollector->begin(); - while (pNode->getParent()) - pNode = pNode->getParent(); - delete pNode; - } + (*s_pGarbageCollector)->clearAndDelete(); return NULL; } else { - s_pGarbageCollector->clear(); + (*s_pGarbageCollector)->clear(); m_sFieldName= ::rtl::OUString(); m_xField = NULL; @@ -1309,7 +1303,7 @@ OSQLParser::OSQLParser(const ::com::sun::star::uno::Reference< ::com::sun::star: { s_pScanner = new OSQLScanner(); s_pScanner->setScanner(); - s_pGarbageCollector = new OSQLParseNodes(); + s_pGarbageCollector = new OSQLParseNodesGarbageCollector(); if(!s_xLocaleData.is()) s_xLocaleData = Reference<XLocaleData>(m_xServiceFactory->createInstance(::rtl::OUString::createFromAscii("com.sun.star.i18n.LocaleData")),UNO_QUERY); @@ -1620,8 +1614,8 @@ OSQLParseNode::OSQLParseNode(const OSQLParseNode& rParseNode) // Zeigers wieder eingehangen. // wenn kein Blatt, dann SubTrees bearbeiten - for (OSQLParseNodes::const_iterator i = rParseNode.m_aChilds.begin(); - i != rParseNode.m_aChilds.end(); i++) + for (OSQLParseNodes::const_iterator i = rParseNode.m_aChildren.begin(); + i != rParseNode.m_aChildren.end(); i++) append(new OSQLParseNode(**i)); } // ----------------------------------------------------------------------------- @@ -1635,14 +1629,14 @@ OSQLParseNode& OSQLParseNode::operator=(const OSQLParseNode& rParseNode) m_eNodeType = rParseNode.m_eNodeType; m_nNodeID = rParseNode.m_nNodeID; - for (OSQLParseNodes::const_iterator i = m_aChilds.begin(); - i != m_aChilds.end(); i++) + for (OSQLParseNodes::const_iterator i = m_aChildren.begin(); + i != m_aChildren.end(); i++) delete *i; - m_aChilds.clear(); + m_aChildren.clear(); - for (OSQLParseNodes::const_iterator j = rParseNode.m_aChilds.begin(); - j != rParseNode.m_aChilds.end(); j++) + for (OSQLParseNodes::const_iterator j = rParseNode.m_aChildren.begin(); + j != rParseNode.m_aChildren.end(); j++) append(new OSQLParseNode(**j)); } return *this; @@ -1670,10 +1664,10 @@ sal_Bool OSQLParseNode::operator==(OSQLParseNode& rParseNode) const //----------------------------------------------------------------------------- OSQLParseNode::~OSQLParseNode() { - for (OSQLParseNodes::const_iterator i = m_aChilds.begin(); - i != m_aChilds.end(); i++) + for (OSQLParseNodes::const_iterator i = m_aChildren.begin(); + i != m_aChildren.end(); i++) delete *i; - m_aChilds.clear(); + m_aChildren.clear(); } //----------------------------------------------------------------------------- @@ -1683,23 +1677,23 @@ void OSQLParseNode::append(OSQLParseNode* pNewNode) OSL_ENSURE(pNewNode != NULL, "OSQLParseNode: ungueltiger NewSubTree"); OSL_ENSURE(pNewNode->getParent() == NULL, "OSQLParseNode: Knoten ist kein Waise"); - OSL_ENSURE(::std::find(m_aChilds.begin(), m_aChilds.end(), pNewNode) == m_aChilds.end(), + OSL_ENSURE(::std::find(m_aChildren.begin(), m_aChildren.end(), pNewNode) == m_aChildren.end(), "OSQLParseNode::append() Node already element of parent"); // stelle Verbindung zum getParent her: pNewNode->setParent( this ); // und haenge den SubTree hinten an - m_aChilds.push_back(pNewNode); + m_aChildren.push_back(pNewNode); } // ----------------------------------------------------------------------------- sal_Bool OSQLParseNode::addDateValue(::rtl::OUString& rString, const SQLParseNodeParameter& rParam) const { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::addDateValue" ); // special display for date/time values - if (SQL_ISRULE(this,set_fct_spec) && SQL_ISPUNCTUATION(m_aChilds[0],"{")) + if (SQL_ISRULE(this,set_fct_spec) && SQL_ISPUNCTUATION(m_aChildren[0],"{")) { - const OSQLParseNode* pODBCNode = m_aChilds[1]; - const OSQLParseNode* pODBCNodeChild = pODBCNode->m_aChilds[0]; + const OSQLParseNode* pODBCNode = m_aChildren[1]; + const OSQLParseNode* pODBCNodeChild = pODBCNode->m_aChildren[0]; if (pODBCNodeChild->getNodeType() == SQL_NODE_KEYWORD && ( SQL_ISTOKEN(pODBCNodeChild, D) || @@ -1734,7 +1728,7 @@ sal_Bool OSQLParseNode::addDateValue(::rtl::OUString& rString, const SQLParseNod if (rString.getLength()) rString += ::rtl::OUString::createFromAscii(" "); rString += suQuote; - const ::rtl::OUString sTokenValue = pODBCNode->m_aChilds[1]->getTokenValue(); + const ::rtl::OUString sTokenValue = pODBCNode->m_aChildren[1]->getTokenValue(); if (SQL_ISTOKEN(pODBCNodeChild, D)) { rString += rParam.bPredicate ? convertDateString(rParam, sTokenValue) : sTokenValue; @@ -1779,8 +1773,8 @@ OSQLParseNode* OSQLParseNode::getByRule(OSQLParseNode::Rule eRule) const pRetNode = (OSQLParseNode*)this; else { - for (OSQLParseNodes::const_iterator i = m_aChilds.begin(); - !pRetNode && i != m_aChilds.end(); i++) + for (OSQLParseNodes::const_iterator i = m_aChildren.begin(); + !pRetNode && i != m_aChildren.end(); i++) pRetNode = (*i)->getByRule(eRule); } return pRetNode; @@ -1938,7 +1932,7 @@ void OSQLParseNode::negateSearchCondition(OSQLParseNode*& pSearchCondition,sal_B OSQLParseNode *pNot = pSearchCondition->removeAt((sal_uInt32)0); delete pNot; OSQLParseNode *pBooleanTest = pSearchCondition->removeAt((sal_uInt32)0); - pBooleanTest->setParent(NULL); + // TODO is this needed // pBooleanTest->setParent(NULL); replaceAndReset(pSearchCondition,pBooleanTest); if (!bNegate) @@ -2007,7 +2001,7 @@ void OSQLParseNode::negateSearchCondition(OSQLParseNode*& pSearchCondition,sal_B else if(bNegate && (SQL_ISRULE(pSearchCondition,like_predicate))) { OSQLParseNode* pCheckForNOT = pSearchCondition->getChild( 1 ); - if ( pCheckForNOT->getNodeType() == SQL_TOKEN_NOT ) + if ( SQL_ISTOKEN(pCheckForNOT,NOT) ) delete pSearchCondition->removeAt( 1 ); else { @@ -2256,8 +2250,8 @@ void OSQLParseNode::showParseTree(::rtl::OUString& rString, sal_uInt32 nLevel) rString+= ::rtl::OUString::createFromAscii("\n"); // hol dir den ersten Subtree - for (OSQLParseNodes::const_iterator i = m_aChilds.begin(); - i != m_aChilds.end(); i++) + for (OSQLParseNodes::const_iterator i = m_aChildren.begin(); + i != m_aChildren.end(); i++) (*i)->showParseTree(rString, nLevel+1); } else @@ -2336,7 +2330,7 @@ void OSQLParseNode::insert(sal_uInt32 nPos, OSQLParseNode* pNewSubTree) // stelle Verbindung zum getParent her: pNewSubTree->setParent( this ); - m_aChilds.insert(m_aChilds.begin() + nPos, pNewSubTree); + m_aChildren.insert(m_aChildren.begin() + nPos, pNewSubTree); } // removeAt-Methoden @@ -2344,14 +2338,14 @@ void OSQLParseNode::insert(sal_uInt32 nPos, OSQLParseNode* pNewSubTree) OSQLParseNode* OSQLParseNode::removeAt(sal_uInt32 nPos) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::removeAt" ); - OSL_ENSURE(nPos < m_aChilds.size(),"Illegal position for removeAt"); - OSQLParseNodes::iterator aPos(m_aChilds.begin() + nPos); + OSL_ENSURE(nPos < m_aChildren.size(),"Illegal position for removeAt"); + OSQLParseNodes::iterator aPos(m_aChildren.begin() + nPos); OSQLParseNode* pNode = *aPos; // setze den getParent des removeten auf NULL pNode->setParent( NULL ); - m_aChilds.erase(aPos); + m_aChildren.erase(aPos); return pNode; } //----------------------------------------------------------------------------- @@ -2359,12 +2353,12 @@ OSQLParseNode* OSQLParseNode::remove(OSQLParseNode* pSubTree) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::remove" ); OSL_ENSURE(pSubTree != NULL, "OSQLParseNode: ungueltiger SubTree"); - OSQLParseNodes::iterator aPos = ::std::find(m_aChilds.begin(), m_aChilds.end(), pSubTree); - if (aPos != m_aChilds.end()) + OSQLParseNodes::iterator aPos = ::std::find(m_aChildren.begin(), m_aChildren.end(), pSubTree); + if (aPos != m_aChildren.end()) { // setze den getParent des removeten auf NULL pSubTree->setParent( NULL ); - m_aChilds.erase(aPos); + m_aChildren.erase(aPos); return pSubTree; } else @@ -2378,17 +2372,17 @@ OSQLParseNode* OSQLParseNode::replaceAt(sal_uInt32 nPos, OSQLParseNode* pNewSubN RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::replaceAt" ); OSL_ENSURE(pNewSubNode != NULL, "OSQLParseNode: invalid nodes"); OSL_ENSURE(pNewSubNode->getParent() == NULL, "OSQLParseNode: node already has getParent"); - OSL_ENSURE(nPos < m_aChilds.size(), "OSQLParseNode: invalid position"); - OSL_ENSURE(::std::find(m_aChilds.begin(), m_aChilds.end(), pNewSubNode) == m_aChilds.end(), + OSL_ENSURE(nPos < m_aChildren.size(), "OSQLParseNode: invalid position"); + OSL_ENSURE(::std::find(m_aChildren.begin(), m_aChildren.end(), pNewSubNode) == m_aChildren.end(), "OSQLParseNode::Replace() Node already element of parent"); - OSQLParseNode* pOldSubNode = m_aChilds[nPos]; + OSQLParseNode* pOldSubNode = m_aChildren[nPos]; // stelle Verbindung zum getParent her: pNewSubNode->setParent( this ); pOldSubNode->setParent( NULL ); - m_aChilds[nPos] = pNewSubNode; + m_aChildren[nPos] = pNewSubNode; return pOldSubNode; } @@ -2398,14 +2392,14 @@ OSQLParseNode* OSQLParseNode::replace (OSQLParseNode* pOldSubNode, OSQLParseNode RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::replace " ); OSL_ENSURE(pOldSubNode != NULL && pNewSubNode != NULL, "OSQLParseNode: invalid nodes"); OSL_ENSURE(pNewSubNode->getParent() == NULL, "OSQLParseNode: node already has getParent"); - OSL_ENSURE(::std::find(m_aChilds.begin(), m_aChilds.end(), pOldSubNode) != m_aChilds.end(), + OSL_ENSURE(::std::find(m_aChildren.begin(), m_aChildren.end(), pOldSubNode) != m_aChildren.end(), "OSQLParseNode::Replace() Node not element of parent"); - OSL_ENSURE(::std::find(m_aChilds.begin(), m_aChilds.end(), pNewSubNode) == m_aChilds.end(), + OSL_ENSURE(::std::find(m_aChildren.begin(), m_aChildren.end(), pNewSubNode) == m_aChildren.end(), "OSQLParseNode::Replace() Node already element of parent"); pOldSubNode->setParent( NULL ); pNewSubNode->setParent( this ); - ::std::replace(m_aChilds.begin(), m_aChilds.end(), pOldSubNode, pNewSubNode); + ::std::replace(m_aChildren.begin(), m_aChildren.end(), pOldSubNode, pNewSubNode); return pOldSubNode; } // ----------------------------------------------------------------------------- @@ -2620,5 +2614,55 @@ OSQLParseNode::Rule OSQLParseNode::getKnownRuleID() const return sTableRange; } - +// ----------------------------------------------------------------------------- +OSQLParseNodesContainer::OSQLParseNodesContainer() +{ +} +// ----------------------------------------------------------------------------- +OSQLParseNodesContainer::~OSQLParseNodesContainer() +{ +} +// ----------------------------------------------------------------------------- +void OSQLParseNodesContainer::push_back(OSQLParseNode* _pNode) +{ + ::osl::MutexGuard aGuard(m_aMutex); + m_aNodes.push_back(_pNode); +} +// ----------------------------------------------------------------------------- +void OSQLParseNodesContainer::erase(OSQLParseNode* _pNode) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if ( !m_aNodes.empty() ) + { + ::std::vector< OSQLParseNode* >::iterator aFind = ::std::find(m_aNodes.begin(), m_aNodes.end(),_pNode); + if ( aFind != m_aNodes.end() ) + m_aNodes.erase(aFind); + } +} +// ----------------------------------------------------------------------------- +bool OSQLParseNodesContainer::empty() const +{ + return m_aNodes.empty(); +} +// ----------------------------------------------------------------------------- +void OSQLParseNodesContainer::clear() +{ + ::osl::MutexGuard aGuard(m_aMutex); + m_aNodes.clear(); +} +// ----------------------------------------------------------------------------- +void OSQLParseNodesContainer::clearAndDelete() +{ + ::osl::MutexGuard aGuard(m_aMutex); + // clear the garbage collector + while ( !m_aNodes.empty() ) + { + OSQLParseNode* pNode = m_aNodes[0]; + while ( pNode->getParent() ) + { + pNode = pNode->getParent(); + } + delete pNode; + } +} } // namespace connectivity diff --git a/connectivity/source/resource/conn_error_message.src b/connectivity/source/resource/conn_error_message.src index 7833269ee5f2..48d60d424cc5 100644 --- a/connectivity/source/resource/conn_error_message.src +++ b/connectivity/source/resource/conn_error_message.src @@ -75,11 +75,15 @@ String 256 + 2*303 + 0 String 256 + 2*304 + 0 { - Text = "No connection to the database exists."; - // TODO: localize + Text [ en-US ] = "No connection to the database exists."; }; String 256 + 2*304 + 1 { Text = "08003"; }; + +String 256 + 2*500 + 0 +{ + Text [ en-US ] = "No $1$ exists."; +}; diff --git a/connectivity/source/resource/conn_shared_res.src b/connectivity/source/resource/conn_shared_res.src index bc96fab7d51c..a455aae269c2 100644 --- a/connectivity/source/resource/conn_shared_res.src +++ b/connectivity/source/resource/conn_shared_res.src @@ -28,7 +28,6 @@ * ************************************************************************/ -// #include "resource/common_res.hrc" #include "resource/mozab_res.hrc" #include "resource/macab_res.hrc" #include "resource/calc_res.hrc" @@ -44,29 +43,28 @@ // = the mozab driver's resource strings // ============================================================================ -String STR_NO_MOZIILA_ADDRESSBOOK +String STR_MOZILLA_ADDRESSBOOKS { - Text [ en-US ] = "No Mozilla Addressbook Directories Exist."; + Text [ en-US ] = "Mozilla/Seamonkey Addressbook Directory"; + Text [ x-comment ] = "This must be the term referring to address books in the user's " + "Mozilla/Seamonkey profile in the system."; }; -String STR_NO_THUNDERBIRD_ADDRESSBOOK +String STR_THUNDERBIRD_ADDRESSBOOKS { - Text [ en-US ] = "No Thunderbird Addressbook Directories Exist."; + Text [ en-US ] = "Thunderbird Addressbook Directory"; + Text [ x-comment ] = "This must be the term referring to address books in the user's " + "Thunderbird profile in the system."; }; -String STR_NO_OUTLOOKEXPRESS_ADDRESSBOOK +String STR_OE_ADDRESSBOOK { - Text [ en-US ] = "No Outlook Express Addressbook Exists."; + Text [ en-US ] = "Outlook Express Addressbook"; }; -String STR_NO_OUTLOOK_ADDRESSBOOK +String STR_OUTLOOK_MAPI_ADDRESSBOOK { - Text [ en-US ] = "No Outlook (MAPI) Addressbook Exists."; -}; - -String STR_COULDNOTCONNECT_TO_LDAP -{ - Text [ en-US ] = "Unable to connect to LDAP Server."; + Text [ en-US ] = "Outlook (MAPI) Addressbook"; }; String STR_NO_TABLE_CREATION_SUPPORT @@ -119,6 +117,96 @@ String STR_CANT_FIND_CARD_FOR_ROW Text [ en-US ] = "Can't find the card for the requested row."; }; +String STR_QUERY_AT_LEAST_ONE_TABLES +{ + Text [ en-US ] = "The query can not be executed. It needs at least one table."; +}; + +String STR_NO_COUNT_SUPPORT +{ + Text [ en-US ] = "The driver does not support the 'COUNT' function."; +}; + +String STR_STMT_TYPE_NOT_SUPPORTED +{ + Text [ en-US ] = "This statement type not supported by this database driver."; +}; + +String STR_UNSPECIFIED_ERROR +{ + Text [ en-US ] = "An unknown error occured."; +}; + +String STR_COULD_NOT_CREATE_ADDRESSBOOK +{ + Text [ en-US ] = "Could not create a new address book. Mozilla error code is $1$."; +}; + +String STR_COULD_NOT_LOAD_LIB +{ + Text [ en-US ] = "The library '$libname$' could not be loaded."; +}; + +String STR_ERROR_REFRESH_ROW +{ + Text [ en-US ] = "An error occured while refreshing the current row."; +}; + +String STR_ERROR_GET_ROW +{ + Text [ en-US ] = "An error occured while getting the current row."; +}; + +String STR_CAN_NOT_CANCEL_ROW_UPDATE +{ + Text [ en-US ] = "The row update can not be canceled."; +}; + +String STR_CAN_NOT_CREATE_ROW +{ + Text [ en-US ] = "A new row can not be created."; +}; + +String STR_QUERY_INVALID_IS_NULL_COLUMN +{ + Text [ en-US ] = "The query can not be executed. The 'IS NULL' can only be used with a column name."; +}; + +String STR_ILLEGAL_MOVEMENT +{ + Text [ en-US ] = "Illegal cursor movement occured."; +}; + +String STR_COMMIT_ROW +{ + Text [ en-US ] = "Please commit row '$position$' before update rows or insert new rows."; +}; + +String STR_INVALID_ROW_UPDATE +{ + Text [ en-US ] = "The update call can not be executed. The row is invalid."; +}; + +String STR_ROW_CAN_NOT_SAVE +{ + Text [ en-US ] = "The current row can not be saved."; +}; + +String STR_NO_HOSTNAME +{ + Text [ en-US ] = "No hostname was provided."; +}; + +String STR_NO_BASEDN +{ + Text [ en-US ] = "No Base DN was provided."; +}; + +String STR_COULD_NOT_CONNECT_LDAP +{ + Text [ en-US ] = "The connection to the LDAP server could not be established."; +}; + // ============================================================================ // = common strings // ============================================================================ @@ -235,31 +323,6 @@ String STR_COLUMN_NOT_UPDATEABLE Text [ en-US ] = "The column at position '$position$' could not be updated."; }; -// -String STR_NO_HOSTNAME -{ - Text [ en-US ] = "No hostname was provided."; -}; - -String STR_NO_BASEDN -{ - Text [ en-US ] = "No Base DN was provided."; -}; - -String STR_COULD_NOT_CONNECT_LDAP -{ - Text [ en-US ] = "The connection to the LDAP server could not be established."; -}; - -// ============================================================================ -// = the mozab driver's resource strings -// ============================================================================ - -String STR_COULD_NOT_LOAD_LIB -{ - Text [ en-US ] = "The library '$libname$' could not be loaded."; -}; - String STR_COULD_NOT_LOAD_FILE { Text [ en-US ] = "The file $filename$ could not be loaded."; @@ -270,63 +333,6 @@ String STR_LOAD_FILE_ERROR_MESSAGE Text [ en-US ] = "The attempt to load the file resulted in the following error message ($exception_type$):\n\n$error_message$"; }; -String STR_ERROR_REFRESH_ROW -{ - Text [ en-US ] = "An error occured while refreshing the current row."; -}; - -String STR_ERROR_GET_ROW -{ - Text [ en-US ] = "An error occured while getting the current row."; -}; -String STR_CAN_NOT_CANCEL_ROW_UPDATE -{ - Text [ en-US ] = "The row update can not be canceled."; -}; - -String STR_CAN_NOT_CREATE_ROW -{ - Text [ en-US ] = "A new row can not be created."; -}; - -String STR_QUERY_INVALID_IS_NULL_COLUMN -{ - Text [ en-US ] = "The query can not be executed. The 'IS NULL' can only be used with a column name."; -}; - -String STR_ILLEGAL_MOVEMENT -{ - Text [ en-US ] = "Illegal cursor movement occured."; -}; - -String STR_COMMIT_ROW -{ - Text [ en-US ] = "Please commit row '$position$' before update rows or insert new rows."; -}; - -String STR_INVALID_ROW_UPDATE -{ - Text [ en-US ] = "The update call can not be executed. The row is invalid."; -}; - -String STR_ROW_CAN_NOT_SAVE -{ - Text [ en-US ] = "The current row can not be saved."; -}; - -String STR_QUERY_AT_LEAST_ONE_TABLES -{ - Text [ en-US ] = "The query can not be executed. It needs at least one table."; -}; - -String STR_NO_COUNT_SUPPORT -{ - Text [ en-US ] = "The driver does not support the 'COUNT' function."; -}; -String STR_STMT_TYPE_NOT_SUPPORTED -{ - Text [ en-US ] = "This statement type not supported by this database driver."; -}; // ============================================================================ // = the ado driver's resource strings // ============================================================================ diff --git a/svx/inc/fmhelp.hrc b/svx/inc/fmhelp.hrc index daf2ff4c1812..c7f172cbe5db 100644 --- a/svx/inc/fmhelp.hrc +++ b/svx/inc/fmhelp.hrc @@ -43,121 +43,6 @@ #define HID_DLG_DBINFO (HID_FORMS_START + 0) #define HID_DLG_DBMSG (HID_FORMS_START + 1) -#define HID_PROP_GROUPBOX (HID_FORMS_START + 2) -#define HID_PROP_CONTROLSOURCE (HID_FORMS_START + 3) -#define HID_PROP_NAME (HID_FORMS_START + 4) -#define HID_PROP_TABINDEX (HID_FORMS_START + 5) -#define HID_PROP_MASTERFIELDS (HID_FORMS_START + 6) -#define HID_PROP_SLAVEFIELDS (HID_FORMS_START + 7) -#define HID_PROP_DATASOURCE (HID_FORMS_START + 8) -#define HID_PROP_CURSORSOURCE (HID_FORMS_START + 9) -#define HID_PROP_CURSORSOURCETYPE (HID_FORMS_START + 10) -#define HID_PROP_CURSORTYPE (HID_FORMS_START + 11) -#define HID_PROP_READONLY (HID_FORMS_START + 12) -#define HID_PROP_DATAENTRY (HID_FORMS_START + 13) -#define HID_PROP_NAVIGATION (HID_FORMS_START + 14) -#define HID_PROP_CYCLE (HID_FORMS_START + 15) -#define HID_PROP_ALLOW_ADDITIONS (HID_FORMS_START + 16) -#define HID_PROP_ALLOW_EDITS (HID_FORMS_START + 17) -#define HID_PROP_ALLOW_DELETIONS (HID_FORMS_START + 18) -#define HID_PROP_DIRTY (HID_FORMS_START + 19) -#define HID_PROP_OLDVALUE (HID_FORMS_START + 20) -#define HID_PROP_VALUE (HID_FORMS_START + 21) -#define HID_PROP_LOCKED (HID_FORMS_START + 22) -#define HID_PROP_FORMATKEY (HID_FORMS_START + 23) -#define HID_PROP_REQUIRED (HID_FORMS_START + 24) -#define HID_PROP_SCALE (HID_FORMS_START + 25) -#define HID_PROP_SIZE (HID_FORMS_START + 26) -#define HID_PROP_UNIQUE (HID_FORMS_START + 27) -#define HID_PROP_CLASSID (HID_FORMS_START + 28) -#define HID_PROP_LEFT (HID_FORMS_START + 29) -#define HID_PROP_RIGHT (HID_FORMS_START + 30) -#define HID_PROP_HEIGHT (HID_FORMS_START + 31) -#define HID_PROP_WIDTH (HID_FORMS_START + 32) -#define HID_PROP_BOUNDCOLUMN (HID_FORMS_START + 33) -#define HID_PROP_LISTSOURCETYPE (HID_FORMS_START + 34) -#define HID_PROP_LISTSOURCE (HID_FORMS_START + 35) -#define HID_PROP_LISTINDEX (HID_FORMS_START + 36) -#define HID_PROP_TEXT (HID_FORMS_START + 37) -#define HID_PROP_LABEL (HID_FORMS_START + 38) -#define HID_PROP_STRINGITEMLIST (HID_FORMS_START + 39) -#define HID_PROP_SEARCHING (HID_FORMS_START + 40) -#define HID_PROP_FONT (HID_FORMS_START + 41) -#define HID_PROP_ROWHEIGHT (HID_FORMS_START + 42) -#define HID_PROP_BACKGROUNDCOLOR (HID_FORMS_START + 43) -#define HID_PROP_FILLCOLOR (HID_FORMS_START + 44) -#define HID_PROP_TEXTCOLOR (HID_FORMS_START + 45) -#define HID_PROP_LINECOLOR (HID_FORMS_START + 46) -#define HID_PROP_BORDER (HID_FORMS_START + 47) -#define HID_PROP_ALIGN (HID_FORMS_START + 48) -#define HID_PROP_DROPDOWN (HID_FORMS_START + 49) -#define HID_PROP_MULTILINE (HID_FORMS_START + 50) -#define HID_PROP_HSCROLL (HID_FORMS_START + 51) -#define HID_PROP_VSCROLL (HID_FORMS_START + 52) -#define HID_PROP_TABSTOP (HID_FORMS_START + 53) -#define HID_PROP_REFVALUE (HID_FORMS_START + 54) -#define HID_PROP_BUTTONTYPE (HID_FORMS_START + 55) -#define HID_PROP_SUBMIT_ACTION (HID_FORMS_START + 56) -#define HID_PROP_SUBMIT_METHOD (HID_FORMS_START + 57) -#define HID_PROP_SUBMIT_ENCODING (HID_FORMS_START + 58) -#define HID_PROP_DEFAULTVALUE (HID_FORMS_START + 59) -#define HID_PROP_SUBMIT_TARGET (HID_FORMS_START + 60) -#define HID_PROP_DEFAULT_CHECKED (HID_FORMS_START + 61) -#define HID_PROP_IMAGE_URL (HID_FORMS_START + 62) -#define HID_PROP_DEFAULT_SELECT_SEQ (HID_FORMS_START + 63) -#define HID_PROP_MULTISELECTION (HID_FORMS_START + 64) - -#define HID_PROP_DATE (HID_FORMS_START + 65) -#define HID_PROP_DATEMIN (HID_FORMS_START + 66) -#define HID_PROP_DATEMAX (HID_FORMS_START + 67) -#define HID_PROP_DATEFORMAT (HID_FORMS_START + 68) -#define HID_PROP_TIME (HID_FORMS_START + 69) -#define HID_PROP_TIMEMIN (HID_FORMS_START + 70) -#define HID_PROP_TIMEMAX (HID_FORMS_START + 71) -#define HID_PROP_TIMEFORMAT (HID_FORMS_START + 72) -#define HID_PROP_VALUEMIN (HID_FORMS_START + 73) -#define HID_PROP_VALUEMAX (HID_FORMS_START + 74) -#define HID_PROP_VALUESTEP (HID_FORMS_START + 75) -#define HID_PROP_CURRENCYSYMBOL (HID_FORMS_START + 76) -#define HID_PROP_EDITMASK (HID_FORMS_START + 77) -#define HID_PROP_LITERALMASK (HID_FORMS_START + 78) -#define HID_PROP_ENABLED (HID_FORMS_START + 79) -#define HID_PROP_AUTOCOMPLETE (HID_FORMS_START + 80) -#define HID_PROP_LINECOUNT (HID_FORMS_START + 81) -#define HID_PROP_MAXTEXTLEN (HID_FORMS_START + 82) -#define HID_PROP_SPIN (HID_FORMS_START + 83) -#define HID_PROP_STRICTFORMAT (HID_FORMS_START + 84) -#define HID_PROP_SHOWTHOUSANDSEP (HID_FORMS_START + 85) - // FREE -#define HID_PROP_PRINTABLE (HID_FORMS_START + 87) -#define HID_PROP_TARGET_URL (HID_FORMS_START + 88) -#define HID_PROP_TARGET_FRAME (HID_FORMS_START + 89) -#define HID_PROP_TAG (HID_FORMS_START + 90) -#define HID_PROP_ECHO_CHAR (HID_FORMS_START + 91) -#define HID_PROP_EMPTY_IS_NULL (HID_FORMS_START + 92) -#define HID_PROP_DECIMAL_ACCURACY (HID_FORMS_START + 93) - // FREE -#define HID_PROP_DEFAULT_BUTTON (HID_FORMS_START + 95) -#define HID_PROP_HIDDEN_VALUE (HID_FORMS_START + 96) -#define HID_PROP_TRISTATE (HID_FORMS_START + 97) -#define HID_PROP_NAVIGATIONBAR (HID_FORMS_START + 98) -#define HID_PROP_FILTER_CRITERIA (HID_FORMS_START + 99) -#define HID_PROP_SORT_CRITERIA (HID_FORMS_START + 100) -#define HID_PROP_DEFAULT_LONG_VALUE (HID_FORMS_START + 101) -#define HID_PROP_DEFAULT_TIME (HID_FORMS_START + 102) -#define HID_PROP_DEFAULT_DATE (HID_FORMS_START + 103) -#define HID_PROP_HELPTEXT (HID_FORMS_START + 104) -#define HID_PROP_HELPURL (HID_FORMS_START + 105) -#define HID_PROP_RECORDMARKER (HID_FORMS_START + 106) -#define HID_PROP_FILTERPROPOSAL (HID_FORMS_START + 107) -#define HID_PROP_EFFECTIVEMIN (HID_FORMS_START + 108) -#define HID_PROP_EFFECTIVEMAX (HID_FORMS_START + 109) -#define HID_PROP_EFFECTIVEDEFAULT (HID_FORMS_START + 110) -#define HID_PROP_CONTROLLABEL (HID_FORMS_START + 111) -#define HID_PROP_CURRSYM_POSITION (HID_FORMS_START + 112) -#define HID_PROP_ESCAPE_PROCESSING (HID_FORMS_START + 113) -#define HID_PROP_IMAGE_ALIGN (HID_FORMS_START + 114) - #define HID_FM_OTHER_START (HID_FORMS_START + 300) #define HID_FORM_NAVIGATOR (HID_FM_OTHER_START + 0) #define HID_FORM_NAVIGATOR_WIN (HID_FM_OTHER_START + 1) diff --git a/svx/inc/pch/precompiled_svx.hxx b/svx/inc/pch/precompiled_svx.hxx index 283bb9b2d6fd..8e9bc4d17930 100644 --- a/svx/inc/pch/precompiled_svx.hxx +++ b/svx/inc/pch/precompiled_svx.hxx @@ -909,7 +909,7 @@ #include "unotools/configvaluecontainer.hxx" #include "unotools/localfilehelper.hxx" #include "unotools/processfactory.hxx" -#include "unotools/servicehelper.hxx" +#include "comphelper/servicehelper.hxx" #include "unotools/streamwrap.hxx" #include "unotools/textsearch.hxx" #include "unotools/transliterationwrapper.hxx" diff --git a/svx/inc/svx/fmpage.hxx b/svx/inc/svx/fmpage.hxx index 2efda5fa2cc4..1b5de5eabf08 100644 --- a/svx/inc/svx/fmpage.hxx +++ b/svx/inc/svx/fmpage.hxx @@ -59,11 +59,6 @@ public: FmFormPage(const FmFormPage& rPage); ~FmFormPage(); - using SdrPage::NbcInsertObject; - using SdrPage::NbcRemoveObject; - using SdrPage::NbcReplaceObject; - using SdrPage::ReplaceObject; - virtual void SetModel(SdrModel* pNewModel); virtual SdrPage* Clone() const; @@ -77,7 +72,9 @@ public: // Zugriff auf alle Formulare const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& GetForms( bool _bForceCreate = true ) const; - FmFormPageImpl* GetImpl() const {return m_pImpl;} +#ifndef SVX_LIGHT + FmFormPageImpl& GetImpl() const { return *m_pImpl; } +#endif // SVX_LIGHT public: const String& GetName() const { return m_sPageName; } diff --git a/svx/inc/svx/shapeproperty.hxx b/svx/inc/svx/shapeproperty.hxx new file mode 100755 index 000000000000..267b5e229d08 --- /dev/null +++ b/svx/inc/svx/shapeproperty.hxx @@ -0,0 +1,58 @@ +/************************************************************************* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2009 by Sun Microsystems, Inc. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +************************************************************************/ +
+#ifndef SVX_SHAPEPROPERTY_HXX +#define SVX_SHAPEPROPERTY_HXX + +/** === begin UNO includes === **/ +/** === end UNO includes === **/ + +//........................................................................ +namespace svx +{ +//........................................................................ + + //==================================================================== + //= ShapeProperty + //==================================================================== + enum ShapeProperty + { + // generic (UNO) shape properties + eShapePosition, + eShapeSize, + // text doc shape properties + eTextShapeAnchorType, + // spreadsheet doc shape properties + eSpreadsheetAnchor, + + // invalid, not to be used + eInvalidShapeProperty + }; + +//........................................................................ +} // namespace svx +//........................................................................ + +#endif // SVX_SHAPEPROPERTY_HXX diff --git a/svx/inc/svx/shapepropertynotifier.hxx b/svx/inc/svx/shapepropertynotifier.hxx new file mode 100644 index 000000000000..b5598e5fb0da --- /dev/null +++ b/svx/inc/svx/shapepropertynotifier.hxx @@ -0,0 +1,147 @@ +/************************************************************************* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2009 by Sun Microsystems, Inc. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +************************************************************************/ +
+#ifndef SVX_PROPERTYCHANGENOTIFIER_HXX +#define SVX_PROPERTYCHANGENOTIFIER_HXX + +#include "svx/svxdllapi.h" +#include "svx/shapeproperty.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/beans/PropertyChangeEvent.hpp> +#include <com/sun/star/beans/XPropertyChangeListener.hpp> +/** === end UNO includes === **/ + +#include <boost/noncopyable.hpp> +#include <boost/shared_ptr.hpp> +#include <memory> + +namespace cppu +{ + class OWeakObject; +} + +//........................................................................ +namespace svx +{ +//........................................................................ + + //==================================================================== + //= IPropertyValueProvider + //==================================================================== + /** a provider for a property value + */ + class SVX_DLLPUBLIC IPropertyValueProvider + { + public: + /** returns the name of the property which this provider is responsible for + */ + virtual ::rtl::OUString getPropertyName() const = 0; + + /** returns the current value of the property which the provider is responsible for + */ + virtual void getCurrentValue( ::com::sun::star::uno::Any& _out_rValue ) const = 0; + + virtual ~IPropertyValueProvider(); + }; + typedef ::boost::shared_ptr< IPropertyValueProvider > PPropertyValueProvider; + + //==================================================================== + //= PropertyValueProvider + //==================================================================== + /** default implementation of a IPropertyValueProvider + + This default implementation queries the object which it is constructed with for the XPropertySet interface, + and calls the getPropertyValue method. + */ + class SVX_DLLPUBLIC PropertyValueProvider :public IPropertyValueProvider + ,public ::boost::noncopyable + { + public: + PropertyValueProvider( ::cppu::OWeakObject& _rContext, const sal_Char* _pAsciiPropertyName ) + :m_rContext( _rContext ) + ,m_sPropertyName( ::rtl::OUString::createFromAscii( _pAsciiPropertyName ) ) + { + } + + virtual ::rtl::OUString getPropertyName() const; + virtual void getCurrentValue( ::com::sun::star::uno::Any& _out_rValue ) const; + + protected: + ::cppu::OWeakObject& getContext() const { return m_rContext; } + private: + ::cppu::OWeakObject& m_rContext; + const ::rtl::OUString m_sPropertyName; + }; + + //==================================================================== + //= PropertyChangeNotifier + //==================================================================== + struct PropertyChangeNotifier_Data; + + /** helper class for notifying XPropertyChangeListeners + + The class is intended to be held as member of the class which does the property change broadcasting. + */ + class SVX_DLLPUBLIC PropertyChangeNotifier : public ::boost::noncopyable + { + public: + /** constructs a notifier instance + + @param _rOwner + the owner instance of the notifier. Will be used as css.lang.EventObject.Source when + notifying events. + */ + PropertyChangeNotifier( ::cppu::OWeakObject& _rOwner, ::osl::Mutex& _rMutex ); + ~PropertyChangeNotifier(); + + // listener maintanance + void addPropertyChangeListener( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ); + void removePropertyChangeListener( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ); + + /** registers a IPropertyValueProvider + */ + void registerProvider( const ShapeProperty _eProperty, const PPropertyValueProvider _pProvider ); + + /** notifies changes in the given property to all registered listeners + + If no property value provider for the given property ID is registered, this is worth an assertion in a + non-product build, and otherwise ignored. + */ + void notifyPropertyChange( const ShapeProperty _eProperty ) const; + + /** is called to dispose the instance + */ + void disposing(); + + private: + ::std::auto_ptr< PropertyChangeNotifier_Data > m_pData; + }; + +//........................................................................ +} // namespace svx +//........................................................................ + +#endif // SVX_PROPERTYCHANGENOTIFIER_HXX diff --git a/svx/inc/svx/svdobj.hxx b/svx/inc/svx/svdobj.hxx index 0b6e190ff025..cc5c9be64438 100644 --- a/svx/inc/svx/svdobj.hxx +++ b/svx/inc/svx/svdobj.hxx @@ -46,6 +46,7 @@ #include <vcl/bitmapex.hxx> #include <svx/sdrobjectuser.hxx> #include "svx/svxdllapi.h" +#include "svx/shapeproperty.hxx" //************************************************************ // Vorausdeklarationen @@ -95,6 +96,11 @@ namespace sdr } // end of namespace contact } // end of namespace sdr +namespace svx +{ + class PropertyChangeNotifier; +} + //************************************************************ // Defines //************************************************************ @@ -529,9 +535,6 @@ protected: // ueberladen, wenn man sich von SdrObjPlusData abgeleitet hat: virtual SdrObjPlusData* NewPlusData() const; - // this is a weak reference to a possible living api wrapper for this shape - ::com::sun::star::uno::WeakReference< ::com::sun::star::uno::XInterface > mxUnoShape; - protected: // Diese 3 Methoden muss ein abgeleitetes Objekt ueberladen, wenn es eigene // geometrische Daten besitzt, die fuer den Undo-Fall gesichert werden @@ -1053,7 +1056,7 @@ public: //////////////////////////////////////////////////////////////////////////////////////////////////// // access to the UNO representation of the shape virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getUnoShape(); - ::com::sun::star::uno::WeakReference< ::com::sun::star::uno::XInterface > getWeakUnoShape() { return mxUnoShape; } + ::com::sun::star::uno::WeakReference< ::com::sun::star::uno::XInterface > getWeakUnoShape() const { return maWeakUnoShape; } static SdrObject* getSdrObjectFromXShape( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xInt ); @@ -1067,9 +1070,31 @@ public: // setting the UNO representation is allowed for the UNO representation itself only! void setUnoShape( - const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxUnoShape, - GrantXShapeAccess /*aGrant*/ - ); + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxUnoShape, + GrantXShapeAccess /*aGrant*/ + ) + { + impl_setUnoShape( _rxUnoShape ); + } + + /** retrieves the instance responsible for notifying changes in the properties of the shape associated with + the SdrObject + + @precond + There already exists an SvxShape instance associated with the SdrObject + @throws ::com::sun::star::uno::RuntimeException + if there does nt yet exists an SvxShape instance associated with the SdrObject. + */ + ::svx::PropertyChangeNotifier& + getShapePropertyChangeNotifier(); + + /** notifies a change in the given property, to all applicable listeners registered at the associated SvxShape + + This method is equivalent to calling getShapePropertyChangeNotifier().notifyPropertyChange( _eProperty ), + exception that it is allowed to be called when there does not yet exist an associated SvxShape - in which + case the method will silently return without doing anything. + */ + void notifyShapePropertyChange( const ::svx::ShapeProperty _eProperty ) const; //////////////////////////////////////////////////////////////////////////////////////////////////// // @@ -1110,18 +1135,17 @@ public: void SetBLIPSizeRectangle( const Rectangle& aRect ); protected: - // #b4899532# - // Force LineStyle with hard attributes to hair line in COL_LIGHTGRAY + void impl_setUnoShape( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxUnoShape ); + +private: /** only for internal use! - The returned SvxShape pointer may be null and if not it is only valid as long as you - hold the xShapeGuard reference. */ - SvxShape* getSvxShape( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xShapeGuard ); + SvxShape* getSvxShape() const; -private: /** do not use directly, always use getSvxShape() if you have to! */ - SvxShape* mpSvxShape; - + SvxShape* mpSvxShape; + ::com::sun::star::uno::WeakReference< ::com::sun::star::uno::XInterface > + maWeakUnoShape; }; //************************************************************ diff --git a/svx/inc/svx/svdouno.hxx b/svx/inc/svx/svdouno.hxx index d0dd60fd8c9a..b366c50cfc84 100644 --- a/svx/inc/svx/svdouno.hxx +++ b/svx/inc/svx/svdouno.hxx @@ -144,7 +144,7 @@ public: const String& GetUnoControlModelTypeName() const { return aUnoControlTypeName; } const String& GetUnoControlTypeName() const { return aUnoControlTypeName; } - void SetUnoControlModel(::com::sun::star::uno::Reference< com::sun::star::awt::XControlModel > xModel); + virtual void SetUnoControlModel( const ::com::sun::star::uno::Reference< com::sun::star::awt::XControlModel >& xModel ); protected: // SdrObject overridables diff --git a/svx/inc/svx/unofield.hxx b/svx/inc/svx/unofield.hxx index fbd0976db497..ad819e1b9dbe 100644 --- a/svx/inc/svx/unofield.hxx +++ b/svx/inc/svx/unofield.hxx @@ -39,7 +39,7 @@ #include <cppuhelper/component.hxx> #include "svx/svxdllapi.h" -#include <unotools/servicehelper.hxx> +#include <comphelper/servicehelper.hxx> #include <svx/mutxhelp.hxx> diff --git a/svx/inc/svx/unopage.hxx b/svx/inc/svx/unopage.hxx index f985d6e9b057..39caa0849ec6 100644 --- a/svx/inc/svx/unopage.hxx +++ b/svx/inc/svx/unopage.hxx @@ -49,7 +49,7 @@ #include "svx/svxdllapi.h" #include <cppuhelper/implbase5.hxx> -#include <unotools/servicehelper.hxx> +#include <comphelper/servicehelper.hxx> #include <svx/unoprov.hxx> diff --git a/svx/inc/svx/unoshape.hxx b/svx/inc/svx/unoshape.hxx index 54c6de369878..f400376a6937 100644 --- a/svx/inc/svx/unoshape.hxx +++ b/svx/inc/svx/unoshape.hxx @@ -60,7 +60,7 @@ #include <svx/svdouno.hxx> -#include <unotools/servicehelper.hxx> +#include <comphelper/servicehelper.hxx> #include <cppuhelper/implbase1.hxx> #include <cppuhelper/implbase12.hxx> @@ -107,8 +107,7 @@ class SVX_DLLPUBLIC SvxShape : public SvxShape_UnoImplHelper, public SfxListener, public SvxShapeMutex { - private: - SVX_DLLPRIVATE void Init() throw(); +private: ::com::sun::star::awt::Size maSize; ::com::sun::star::awt::Point maPosition; ::rtl::OUString maShapeType; @@ -128,10 +127,6 @@ protected: const SvxItemPropertySet* mpPropSet; const SfxItemPropertyMapEntry* maPropMapEntries; - // for xComponent - ::cppu::OInterfaceContainerHelper maDisposeListeners; - bool mbDisposing; - ::tools::WeakReference< SdrObject > mpObj; SdrModel* mpModel; // Umrechnungen fuer den Writer, der in TWIPS arbeitet @@ -175,8 +170,8 @@ public: virtual ~SvxShape() throw (); // Internals - void ObtainSettingsFromPropertySet(const SvxItemPropertySet& rPropSet) throw (); - virtual void Create( SdrObject* pNewOpj, SvxDrawPage* pNewPage = NULL ) throw (); + void ObtainSettingsFromPropertySet(const SvxItemPropertySet& rPropSet); + virtual void Create( SdrObject* pNewOpj, SvxDrawPage* pNewPage = NULL ); /** takes the ownership of the SdrObject. When the shape is disposed, and it has the ownership of its associated SdrObject, then @@ -194,6 +189,8 @@ public: ::com::sun::star::uno::Any GetBitmap( BOOL bMetaFile = FALSE ) const throw (); static SvxShape* GetShapeForSdrObj( SdrObject* pObj ) throw (); + ::svx::PropertyChangeNotifier& getShapePropertyChangeNotifier(); + void setShapeKind( sal_uInt32 nKind ); sal_uInt32 getShapeKind() const; @@ -232,10 +229,11 @@ public: virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) throw (); - /** called from SdrObject::SendUserCall - Currently only called for SDRUSERCALL_CHILD_CHGATTR + /** @obsolete + not used anymore */ virtual void onUserCall(SdrUserCallType eUserCall, const Rectangle& rBoundRect); + // XAggregation virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException); @@ -317,6 +315,13 @@ public: virtual void SAL_CALL removeActionLock( ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setActionLocks( sal_Int16 nLock ) throw (::com::sun::star::uno::RuntimeException); virtual sal_Int16 SAL_CALL resetActionLocks( ) throw (::com::sun::star::uno::RuntimeException); + +private: + /** initializes SdrObj-dependent members. Only to be called when GetSdrObject() != NULL + */ + SVX_DLLPRIVATE void impl_initFromSdrObject(); + /// CTOR-Impl + SVX_DLLPRIVATE void impl_construct(); }; #include <svx/unotext.hxx> @@ -346,7 +351,7 @@ public: SvxShapeText( SdrObject* pObject, const SfxItemPropertyMapEntry* pPropertyMap, const SvxItemPropertySet* pPropertySet ) throw (); virtual ~SvxShapeText() throw (); - virtual void Create( SdrObject* pNewOpj, SvxDrawPage* pNewPage = NULL ) throw (); + virtual void Create( SdrObject* pNewOpj, SvxDrawPage* pNewPage = NULL ); // XInterface virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); @@ -406,7 +411,7 @@ public: SvxShapeGroup( SdrObject* pObj,SvxDrawPage* pDrawPage ) throw (); virtual ~SvxShapeGroup() throw (); - virtual void Create( SdrObject* pNewOpj, SvxDrawPage* pNewPage = NULL ) throw (); + virtual void Create( SdrObject* pNewOpj, SvxDrawPage* pNewPage = NULL ); // XInterface virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); @@ -690,7 +695,7 @@ public: virtual ~Svx3DSceneObject() throw(); - virtual void Create( SdrObject* pNewOpj, SvxDrawPage* pNewPage = NULL ) throw(); + virtual void Create( SdrObject* pNewOpj, SvxDrawPage* pNewPage = NULL ); // XInterface virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); @@ -833,7 +838,7 @@ public: virtual ~SvxCustomShape() throw (); - virtual void Create( SdrObject* pNewOpj, SvxDrawPage* pNewPage = NULL ) throw(); + virtual void Create( SdrObject* pNewOpj, SvxDrawPage* pNewPage = NULL ); // XInterface virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); diff --git a/svx/inc/svx/unotext.hxx b/svx/inc/svx/unotext.hxx index 30b48b463c46..4fe716c259ff 100644 --- a/svx/inc/svx/unotext.hxx +++ b/svx/inc/svx/unotext.hxx @@ -73,7 +73,7 @@ #include <osl/mutex.hxx> #include "svx/svxdllapi.h" -#include <unotools/servicehelper.hxx> +#include <comphelper/servicehelper.hxx> #ifndef SEQTYPE #if defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500) diff --git a/svx/prj/d.lst b/svx/prj/d.lst index 3b70b59970fb..74236afdad1c 100644 --- a/svx/prj/d.lst +++ b/svx/prj/d.lst @@ -324,6 +324,8 @@ mkdir: %_DEST%\inc%_EXT%\svx ..\inc\svx\unopage.hxx %_DEST%\inc%_EXT%\svx\unopage.hxx ..\inc\svx\unoprnms.hxx %_DEST%\inc%_EXT%\svx\unoprnms.hxx ..\inc\svx\unoshape.hxx %_DEST%\inc%_EXT%\svx\unoshape.hxx +..\inc\svx\shapepropertynotifier.hxx %_DEST%\inc%_EXT%\svx\shapepropertynotifier.hxx +..\inc\svx\shapeproperty.hxx %_DEST%\inc%_EXT%\svx\shapeproperty.hxx ..\inc\unoshcol.hxx %_DEST%\inc%_EXT%\svx\unoshcol.hxx ..\inc\svx\unoipset.hxx %_DEST%\inc%_EXT%\svx\unoipset.hxx ..\inc\svx\unoprov.hxx %_DEST%\inc%_EXT%\svx\unoprov.hxx diff --git a/svx/source/cui/backgrnd.cxx b/svx/source/cui/backgrnd.cxx index 6d9c06484658..9ba19816b1bf 100644 --- a/svx/source/cui/backgrnd.cxx +++ b/svx/source/cui/backgrnd.cxx @@ -1204,8 +1204,6 @@ void SvxBackgroundTabPage::FillColorValueSets_Impl() const Size aSize15x15 = Size( 15, 15 ); FASTBOOL bOwn = FALSE; - DBG_ASSERT( pDocSh, "DocShell not found!" ); - if ( pDocSh && ( 0 != ( pItem = pDocSh->GetItem( SID_COLOR_TABLE ) ) ) ) pColorTable = ( (SvxColorTableItem*)pItem )->GetColorTable(); diff --git a/svx/source/cui/numfmt.cxx b/svx/source/cui/numfmt.cxx index 2f11f1af0223..a3b426c6110e 100644 --- a/svx/source/cui/numfmt.cxx +++ b/svx/source/cui/numfmt.cxx @@ -64,7 +64,9 @@ #include <svx/dialmgr.hxx> #include <sfx2/request.hxx> //CHINA001 #include <sfx2/app.hxx> //CHINA001 +#include <sfx2/basedlgs.hxx> #include "flagsdef.hxx" //CHINA001 + #define NUMKEY_UNDEFINED SAL_MAX_UINT32 // static ---------------------------------------------------------------- @@ -1278,8 +1280,18 @@ IMPL_LINK( SvxNumberFormatTabPage, DoubleClickHdl_Impl, SvxFontListBox*, pLb ) if ( pLb == &aLbFormat ) { SelFormatHdl_Impl( pLb ); - // Uebergangsloesung, sollte von SfxTabPage angeboten werden - fnOkHdl.Call( NULL ); + + if ( fnOkHdl.IsSet() ) + { // Uebergangsloesung, sollte von SfxTabPage angeboten werden + fnOkHdl.Call( NULL ); + } + else + { + SfxSingleTabDialog* pParent = dynamic_cast< SfxSingleTabDialog* >( GetParent() ); + OKButton* pOKButton = pParent ? pParent->GetOKButton() : NULL; + if ( pOKButton ) + pOKButton->Click(); + } } return 0; } diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx index 49778b7a4b69..d6cd4f2d2bae 100644 --- a/svx/source/fmcomp/gridcell.cxx +++ b/svx/source/fmcomp/gridcell.cxx @@ -172,8 +172,9 @@ void DbGridColumn::CreateControl(sal_Int32 _nFieldPos, const Reference< ::com::s case DataType::TINYINT: case DataType::SMALLINT: case DataType::INTEGER: - case DataType::REAL: case DataType::BIGINT: + case DataType::FLOAT: + case DataType::REAL: case DataType::DOUBLE: case DataType::NUMERIC: case DataType::DECIMAL: @@ -182,6 +183,7 @@ void DbGridColumn::CreateControl(sal_Int32 _nFieldPos, const Reference< ::com::s break; default: m_nAlign = ::com::sun::star::awt::TextAlign::LEFT; + break; } } diff --git a/svx/source/form/fmPropBrw.cxx b/svx/source/form/fmPropBrw.cxx index 47de621f99dd..d968342d6ef5 100644 --- a/svx/source/form/fmPropBrw.cxx +++ b/svx/source/form/fmPropBrw.cxx @@ -30,24 +30,21 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svx.hxx" + +#include "fmhelp.hrc"
+#include "fmprop.hrc"
#include "fmPropBrw.hxx" -#ifndef _SVX_SVXIDS_HRC -#include <svx/svxids.hrc> -#endif -#include <svx/fmshell.hxx> -#include "fmshimp.hxx" -#ifndef _SVX_FMPROP_HRC -#include "fmprop.hrc" -#endif -#ifndef _SVX_FMHELP_HRC -#include "fmhelp.hrc" -#endif -#include <svx/dialmgr.hxx> -#ifndef _SVX_FMRESIDS_HRC #include "fmresids.hrc" -#endif #include "fmservs.hxx" -#include <svx/svdpagv.hxx> +#include "fmshimp.hxx"
+#include "fmpgeimp.hxx"
+ +#include "svx/dialmgr.hxx"
+#include "svx/fmpage.hxx"
+#include "svx/fmshell.hxx"
+#include "svx/sdrpagewindow.hxx"
+#include "svx/svdpagv.hxx"
+#include "svx/svxids.hrc"
/** === begin UNO includes === **/ #include <com/sun/star/beans/PropertyValue.hpp> @@ -64,24 +61,22 @@ #include <com/sun/star/inspection/XObjectInspectorUI.hpp> #include <com/sun/star/inspection/DefaultHelpProvider.hpp> /** === end UNO includes === **/ + #include <comphelper/processfactory.hxx> +#include <comphelper/property.hxx>
#include <cppuhelper/component_context.hxx> -#include <tools/shl.hxx> -#include <tools/diagnose_ex.h> -#include <vcl/stdtext.hxx> -#include <sfx2/dispatch.hxx> -#include <sfx2/viewfrm.hxx> -#include <tools/debug.hxx> -#include <sfx2/objsh.hxx> #include <sfx2/bindings.hxx> #include <sfx2/childwin.hxx> +#include <sfx2/dispatch.hxx>
#include <sfx2/objitem.hxx> -#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ +#include <sfx2/objsh.hxx>
+#include <sfx2/viewfrm.hxx>
#include <toolkit/unohlp.hxx> -#endif -#include <comphelper/property.hxx> +#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <tools/shl.hxx>
#include <unotools/confignode.hxx> -#include <svx/sdrpagewindow.hxx> +#include <vcl/stdtext.hxx>
#include <algorithm> @@ -303,19 +298,24 @@ FmPropBrw::~FmPropBrw() implDetachController(); try { + // remove our own properties from the component context. We cannot ensure that the component context + // is freed (there might be refcount problems :-\), so at least ensure the context itself + // does hold the objects anymore Reference<XNameContainer> xName(m_xInspectorContext,uno::UNO_QUERY); if ( xName.is() ) { const ::rtl::OUString pProps[] = { ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ContextDocument" ) ) - , ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DialogParentWindow" ) ) - , ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ControlContext" ) )}; - for (size_t i = 0; i < sizeof(pProps)/sizeof(pProps[0]); ++i) - xName->removeByName(pProps[i]); + , ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DialogParentWindow" ) ) + , ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ControlContext" ) ) + , ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ControlShapeAccess" ) ) }; + for ( size_t i = 0; i < sizeof(pProps)/sizeof(pProps[0]); ++i ) + xName->removeByName( pProps[i] ); } } - catch(Exception&) - {} - + catch (const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } DBG_DTOR(FmPropBrw,NULL); } @@ -574,6 +574,12 @@ void FmPropBrw::impl_createPropertyBrowser_throw( FmFormShell* _pFormShell ) // the default parent window for message boxes Reference< XWindow > xParentWindow( VCLUnoHelper::GetInterface ( this ) ); + // the mapping from control models to control shapes + Reference< XMap > xControlMap; + FmFormPage* pFormPage = _pFormShell ? _pFormShell->GetCurPage() : NULL; + if ( pFormPage ) + xControlMap = pFormPage->GetImpl().getControlToShapeMap(); + // our own component context Reference< XPropertySet > xFactoryProperties( m_xORB, UNO_QUERY_THROW ); Reference< XComponentContext > xOwnContext( @@ -585,7 +591,8 @@ void FmPropBrw::impl_createPropertyBrowser_throw( FmFormShell* _pFormShell ) { ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ContextDocument" ) ), makeAny( xDocument ) ), ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DialogParentWindow" ) ), makeAny( xParentWindow ) ), - ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ControlContext" ) ), makeAny( xControlContext ) ) + ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ControlContext" ) ), makeAny( xControlContext ) ), + ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ControlShapeAccess" ) ), makeAny( xControlMap ) ) }; m_xInspectorContext.set( ::cppu::createComponentContext( aHandlerContextInfo, sizeof( aHandlerContextInfo ) / sizeof( aHandlerContextInfo[0] ), diff --git a/svx/source/form/fmobj.cxx b/svx/source/form/fmobj.cxx index fd5299fe62d5..f2773b7350fa 100644 --- a/svx/source/form/fmobj.cxx +++ b/svx/source/form/fmobj.cxx @@ -148,13 +148,17 @@ void FmFormObj::impl_isolateControlModel_nothrow() //------------------------------------------------------------------ void FmFormObj::SetPage(SdrPage* _pNewPage) { - FmFormPage* pNewFormPage = PTR_CAST(FmFormPage, _pNewPage); if ( GetPage() == _pNewPage ) { SdrUnoObj::SetPage(_pNewPage); return; } + FmFormPage* pOldFormPage = PTR_CAST( FmFormPage, GetPage() ); + if ( pOldFormPage ) + pOldFormPage->GetImpl().formObjectRemoved( *this ); + + FmFormPage* pNewFormPage = PTR_CAST( FmFormPage, _pNewPage ); if ( !pNewFormPage ) { // Maybe it makes sense to create an environment history here : if somebody set's our page to NULL, and we have a valid page before, // me may want to remember our place within the old page. For this we could create a new m_xEnvironmentHistory to store it. @@ -202,7 +206,6 @@ void FmFormObj::SetPage(SdrPage* _pNewPage) { // are we a valid part of our current page forms ? Reference< XIndexContainer > xOldForms; - FmFormPage* pOldFormPage = dynamic_cast< FmFormPage* >( GetPage() ); if ( pOldFormPage ) xOldForms.set( pOldFormPage->GetForms(), UNO_QUERY_THROW ); @@ -296,6 +299,9 @@ void FmFormObj::SetPage(SdrPage* _pNewPage) m_xEnvironmentHistory = NULL; m_aEventsHistory.realloc(0); + + if ( pNewFormPage ) + pNewFormPage->GetImpl().formObjectInserted( *this ); } //------------------------------------------------------------------ @@ -584,6 +590,14 @@ const FmFormObj* FmFormObj::GetFormObject( const SdrObject* _pSdrObject ) } //------------------------------------------------------------------ +void FmFormObj::SetUnoControlModel( const Reference< com::sun::star::awt::XControlModel >& _rxModel ) +{ + SdrUnoObj::SetUnoControlModel( _rxModel ); + + // TODO: call something like formObjectInserted at the form page, to tell it the new model +} + +//------------------------------------------------------------------ FASTBOOL FmFormObj::EndCreate( SdrDragStat& rStat, SdrCreateCmd eCmd ) { bool bResult = SdrUnoObj::EndCreate(rStat, eCmd); @@ -602,11 +616,11 @@ FASTBOOL FmFormObj::EndCreate( SdrDragStat& rStat, SdrCreateCmd eCmd ) if ( !xParentForm.is() ) { // model is not yet part of a form component hierachy - xParentForm.set( rPage.GetImpl()->findPlaceInFormComponentHierarchy( xContent ), UNO_SET_THROW ); + xParentForm.set( rPage.GetImpl().findPlaceInFormComponentHierarchy( xContent ), UNO_SET_THROW ); xFormToInsertInto.set( xParentForm, UNO_QUERY_THROW ); } - rPage.GetImpl()->setUniqueName( xContent, xParentForm ); + rPage.GetImpl().setUniqueName( xContent, xParentForm ); if ( xFormToInsertInto.is() ) xFormToInsertInto->insertByIndex( xFormToInsertInto->getCount(), makeAny( xContent ) ); diff --git a/svx/source/form/fmpage.cxx b/svx/source/form/fmpage.cxx index fc87ebc37454..0ead41eb87bc 100644 --- a/svx/source/form/fmpage.cxx +++ b/svx/source/form/fmpage.cxx @@ -95,7 +95,7 @@ TYPEINIT1(FmFormPage, SdrPage); FmFormPage::FmFormPage(FmFormModel& rModel, StarBASIC* _pBasic, FASTBOOL bMasterPage) :SdrPage(rModel, bMasterPage) #ifndef SVX_LIGHT - ,m_pImpl(new FmFormPageImpl(this)) + ,m_pImpl( new FmFormPageImpl( *this ) ) #else ,m_pImpl(NULL) #endif @@ -108,7 +108,7 @@ FmFormPage::FmFormPage(FmFormModel& rModel, StarBASIC* _pBasic, FASTBOOL bMaster FmFormPage::FmFormPage(const FmFormPage& rPage) :SdrPage(rPage) #ifndef SVX_LIGHT - ,m_pImpl(new FmFormPageImpl(this, *rPage.GetImpl())) + ,m_pImpl(new FmFormPageImpl( *this, rPage.GetImpl() ) ) #else ,m_pImpl(NULL) #endif diff --git a/svx/source/form/fmpgeimp.cxx b/svx/source/form/fmpgeimp.cxx index 41243a41bda2..a2add33b849b 100644 --- a/svx/source/form/fmpgeimp.cxx +++ b/svx/source/form/fmpgeimp.cxx @@ -30,6 +30,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svx.hxx" + #include "svxerr.hxx" #include "fmpgeimp.hxx" #include "fmundo.hxx" @@ -44,6 +45,8 @@ #include <com/sun/star/sdb/CommandType.hpp> #include <com/sun/star/util/XCloneable.hpp> +#include <com/sun/star/container/EnumerableMap.hpp> +#include <com/sun/star/drawing/XControlShape.hpp> #include <sfx2/objsh.hxx> #include <svx/fmglob.hxx> @@ -55,6 +58,7 @@ #include <vcl/stdtext.hxx> #include <svx/dialmgr.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/componentcontext.hxx> #include <comphelper/uno3.hxx> #include <comphelper/types.hxx> #include <unotools/streamwrap.hxx> @@ -69,12 +73,15 @@ using namespace ::com::sun::star::beans; using namespace ::com::sun::star::form; using ::com::sun::star::util::XCloneable; using ::com::sun::star::awt::XControlModel; +using ::com::sun::star::container::XMap; +using ::com::sun::star::container::EnumerableMap; +using ::com::sun::star::drawing::XControlShape; using namespace ::svxform; DBG_NAME(FmFormPageImpl) //------------------------------------------------------------------------------ -FmFormPageImpl::FmFormPageImpl(FmFormPage* _pPage) - :pPage(_pPage) +FmFormPageImpl::FmFormPageImpl( FmFormPage& _rPage ) + :m_rPage( _rPage ) ,m_bFirstActivation( sal_True ) ,m_bAttemptedFormCreation( false ) ,m_bInFind( false ) @@ -162,13 +169,11 @@ namespace } //------------------------------------------------------------------------------ -FmFormPageImpl::FmFormPageImpl(FmFormPage* _pPage, const FmFormPageImpl& rImpl) - :pPage(_pPage) +FmFormPageImpl::FmFormPageImpl( FmFormPage& _rPage, const FmFormPageImpl& rImpl ) + :m_rPage( _rPage ) ,m_bFirstActivation( sal_True ) ,m_bAttemptedFormCreation( false ) - ,m_bInFind( false ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPageImpl::FmFormPageImpl" ); DBG_CTOR(FmFormPageImpl,NULL); // clone the Forms collection @@ -193,8 +198,8 @@ FmFormPageImpl::FmFormPageImpl(FmFormPage* _pPage, const FmFormPageImpl& rImpl) aVisitor.process( FormComponentPair( xCloneable, m_xForms ), aAssignmentProcessor ); // assign the cloned models to their SdrObjects - SdrObjListIter aForeignIter( *rImpl.pPage ); - SdrObjListIter aOwnIter( *pPage ); + SdrObjListIter aForeignIter( rImpl.m_rPage ); + SdrObjListIter aOwnIter( m_rPage ); OSL_ENSURE( aForeignIter.IsMore() == aOwnIter.IsMore(), "FmFormPageImpl::FmFormPageImpl: inconsistent number of objects (1)!" ); while ( aForeignIter.IsMore() && aOwnIter.IsMore() ) @@ -242,6 +247,85 @@ FmFormPageImpl::FmFormPageImpl(FmFormPage* _pPage, const FmFormPageImpl& rImpl) } //------------------------------------------------------------------------------ +Reference< XMap > FmFormPageImpl::getControlToShapeMap() +{ + Reference< XMap > xControlShapeMap( m_aControlShapeMap.get(), UNO_QUERY ); + if ( xControlShapeMap.is() ) + return xControlShapeMap; + + xControlShapeMap = impl_createControlShapeMap_nothrow(); + m_aControlShapeMap = xControlShapeMap; + return xControlShapeMap; +} + +//------------------------------------------------------------------------------ +namespace +{ + static void lcl_insertFormObject_throw( const FmFormObj& _object, const Reference< XMap >& _map ) + { + // the control model + Reference< XControlModel > xControlModel( _object.GetUnoControlModel(), UNO_QUERY ); + OSL_ENSURE( xControlModel.is(), "lcl_insertFormObject_throw: suspicious: no control model!" ); + if ( !xControlModel.is() ) + return; + + Reference< XControlShape > xControlShape( const_cast< FmFormObj& >( _object ).getUnoShape(), UNO_QUERY ); + OSL_ENSURE( xControlShape.is(), "lcl_insertFormObject_throw: suspicious: no control shape!" ); + if ( !xControlShape.is() ) + return; + + _map->put( makeAny( xControlModel ), makeAny( xControlShape ) ); + } + + static void lcl_removeFormObject( const FmFormObj& _object, const Reference< XMap >& _map ) + { + // the control model + Reference< XControlModel > xControlModel( _object.GetUnoControlModel(), UNO_QUERY ); + OSL_ENSURE( xControlModel.is(), "lcl_removeFormObject: suspicious: no control model!" ); + if ( !xControlModel.is() ) + return; + + #if OSL_DEBUG_LEVEL > 0 + Any aOldAssignment = + #endif + _map->remove( makeAny( xControlModel ) ); + OSL_ENSURE( aOldAssignment == makeAny( Reference< XControlShape >( const_cast< FmFormObj& >( _object ).getUnoShape(), UNO_QUERY ) ), + "lcl_removeFormObject: map was inconsistent!" ); + } +} + +//------------------------------------------------------------------------------ +Reference< XMap > FmFormPageImpl::impl_createControlShapeMap_nothrow() +{ + Reference< XMap > xMap; + + try + { + ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); + xMap.set( EnumerableMap::create( aContext.getUNOContext(), + ::cppu::UnoType< XControlModel >::get(), + ::cppu::UnoType< XControlShape >::get() + ).get(), UNO_SET_THROW ); + + SdrObjListIter aPageIter( m_rPage ); + while ( aPageIter.IsMore() ) + { + // only FmFormObjs are what we're interested in + FmFormObj* pCurrent = FmFormObj::GetFormObject( aPageIter.Next() ); + if ( !pCurrent ) + continue; + + lcl_insertFormObject_throw( *pCurrent, xMap ); + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return xMap; +} + +//------------------------------------------------------------------------------ const Reference< XNameContainer >& FmFormPageImpl::getForms( bool _bForceCreate ) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPageImpl::getForms" ); @@ -264,7 +348,7 @@ const Reference< XNameContainer >& FmFormPageImpl::getForms( bool _bForceCreate m_aFormsCreationHdl.Call( this ); } - FmFormModel* pFormsModel = pPage ? PTR_CAST( FmFormModel, pPage->GetModel() ) : NULL; + FmFormModel* pFormsModel = PTR_CAST( FmFormModel, m_rPage.GetModel() ); // give the newly created collection a place in the universe Reference< XChild > xAsChild( m_xForms, UNO_QUERY ); @@ -354,7 +438,7 @@ Reference< XForm > FmFormPageImpl::getDefaultForm() // did not find an existing suitable form -> create a new one if ( !xForm.is() ) { - SdrModel* pModel = pPage->GetModel(); + SdrModel* pModel = m_rPage.GetModel(); if( pModel->IsUndoEnabled() ) { @@ -436,7 +520,7 @@ Reference< ::com::sun::star::form::XForm > FmFormPageImpl::findPlaceInFormCompo // wenn keine ::com::sun::star::form gefunden, dann eine neue erzeugen if (!xForm.is()) { - SdrModel* pModel = pPage->GetModel(); + SdrModel* pModel = m_rPage.GetModel(); const bool bUndo = pModel->IsUndoEnabled(); @@ -698,3 +782,38 @@ UniString FmFormPageImpl::getDefaultName( sal_Int16 _nClassId, const Reference< return sName; } + +//------------------------------------------------------------------ +void FmFormPageImpl::formObjectInserted( const FmFormObj& _object ) +{ + Reference< XMap > xControlShapeMap( m_aControlShapeMap.get(), UNO_QUERY ); + if ( !xControlShapeMap.is() ) + // our map does not exist -> not interested in this event + return; + + try + { + lcl_insertFormObject_throw( _object, xControlShapeMap ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } +} + +void FmFormPageImpl::formObjectRemoved( const FmFormObj& _object ) +{ + Reference< XMap > xControlShapeMap( m_aControlShapeMap.get(), UNO_QUERY ); + if ( !xControlShapeMap.is() ) + // our map does not exist -> not interested in this event + return; + + try + { + lcl_removeFormObject( _object, xControlShapeMap ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } +} diff --git a/svx/source/form/fmshimp.cxx b/svx/source/form/fmshimp.cxx index b9b381f767cb..87149994839b 100644 --- a/svx/source/form/fmshimp.cxx +++ b/svx/source/form/fmshimp.cxx @@ -265,6 +265,7 @@ sal_Int16 nObjectTypes[] = OBJ_FM_NAVIGATIONBAR }; +using namespace ::com::sun::star; using namespace ::com::sun::star::ui; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::sdb; @@ -2065,7 +2066,7 @@ void FmXFormShell::impl_updateCurrentForm( const Reference< XForm >& _rxNewCurFo // propagate to the FormPage(Impl) FmFormPage* pPage = m_pShell->GetCurPage(); if ( pPage ) - pPage->GetImpl()->setCurForm( m_xCurrentForm ); + pPage->GetImpl().setCurForm( m_xCurrentForm ); // ensure the UI which depends on the current form is up-to-date for ( size_t i = 0; i < sizeof( DlgSlotMap ) / sizeof( DlgSlotMap[0] ); ++i ) @@ -3968,10 +3969,10 @@ void FmXFormShell::viewDeactivated( FmFormView& _rCurrentView, sal_Bool _bDeacti } // remove callbacks at the page - if ( pPage && pPage->GetImpl() ) + if ( pPage ) { OSL_TRACE( "--- FmXFormShell::resetHandler : %p, ........, %p\n", this, pPage ); - pPage->GetImpl()->SetFormsCreationHdl( Link() ); + pPage->GetImpl().SetFormsCreationHdl( Link() ); } UpdateForms( sal_True ); } @@ -4020,9 +4021,9 @@ void FmXFormShell::viewActivated( FmFormView& _rCurrentView, sal_Bool _bSyncActi // load forms for the page the current view belongs to if ( pPage ) { - if ( !pPage->GetImpl()->hasEverBeenActivated() ) + if ( !pPage->GetImpl().hasEverBeenActivated() ) loadForms( pPage, FORMS_LOAD | ( _bSyncAction ? FORMS_SYNC : FORMS_ASYNC ) ); - pPage->GetImpl()->setHasBeenActivated( ); + pPage->GetImpl().setHasBeenActivated( ); } // first-time initializations for the views @@ -4037,10 +4038,10 @@ void FmXFormShell::viewActivated( FmFormView& _rCurrentView, sal_Bool _bSyncActi } // set callbacks at the page - if ( pPage && pPage->GetImpl() ) + if ( pPage ) { OSL_TRACE( "--- FmXFormShell::setHandler : %p, ........, %p\n", this, pPage ); - pPage->GetImpl()->SetFormsCreationHdl( LINK( this, FmXFormShell, OnFormsCreated ) ); + pPage->GetImpl().SetFormsCreationHdl( LINK( this, FmXFormShell, OnFormsCreated ) ); } UpdateForms( sal_True ); diff --git a/svx/source/form/fmtextcontrolshell.cxx b/svx/source/form/fmtextcontrolshell.cxx index cb8a46cd88a9..f7e59ce41888 100644 --- a/svx/source/form/fmtextcontrolshell.cxx +++ b/svx/source/form/fmtextcontrolshell.cxx @@ -115,7 +115,6 @@ namespace svx SID_ATTR_CHAR_CONTOUR, SID_ATTR_CHAR_STRIKEOUT, SID_ATTR_CHAR_UNDERLINE, - SID_ATTR_CHAR_OVERLINE, SID_ATTR_CHAR_FONTHEIGHT, SID_ATTR_CHAR_COLOR, SID_ATTR_CHAR_KERNING, @@ -133,6 +132,7 @@ namespace svx SID_ATTR_LRSPACE, /* 48 */ SID_ATTR_ULSPACE, /* 49 */ SID_ATTR_CHAR_AUTOKERN, + SID_ATTR_CHAR_OVERLINE, SID_SET_SUPER_SCRIPT, SID_SET_SUB_SCRIPT, SID_CHAR_DLG, diff --git a/svx/source/form/fmundo.cxx b/svx/source/form/fmundo.cxx index fa339294273d..6f4dff9d7fb3 100644 --- a/svx/source/form/fmundo.cxx +++ b/svx/source/form/fmundo.cxx @@ -336,12 +336,12 @@ void FmXUndoEnvironment::Inserted(FmFormObj* pObj) } else { - xForm.set( rPage.GetImpl()->findPlaceInFormComponentHierarchy( xContent ), UNO_SET_THROW ); + xForm.set( rPage.GetImpl().findPlaceInFormComponentHierarchy( xContent ), UNO_SET_THROW ); xNewParent.set( xForm, UNO_QUERY_THROW ); nPos = xNewParent->getCount(); } - rPage.GetImpl()->setUniqueName( xContent, xForm ); + rPage.GetImpl().setUniqueName( xContent, xForm ); xNewParent->insertByIndex( nPos, makeAny( xContent ) ); Reference< XEventAttacherManager > xManager( xNewParent, UNO_QUERY_THROW ); diff --git a/svx/source/form/fmvwimp.cxx b/svx/source/form/fmvwimp.cxx index db4c7d678dd9..46750d524a4d 100644 --- a/svx/source/form/fmvwimp.cxx +++ b/svx/source/form/fmvwimp.cxx @@ -213,7 +213,7 @@ void FmXPageViewWinRec::dispose() Reference< XChild > xControllerModel( xController->getModel(), UNO_QUERY ); if ( xControllerModel.is() ) { - Reference< XEventAttacherManager > xEventManager( xControllerModel->getParent(), UNO_QUERY ); + Reference< XEventAttacherManager > xEventManager( xControllerModel->getParent(), UNO_QUERY_THROW ); Reference< XInterface > xControllerNormalized( xController, UNO_QUERY_THROW ); xEventManager->detach( i - m_aControllerList.begin(), xControllerNormalized ); } @@ -817,14 +817,20 @@ static Reference< XControl > lcl_firstFocussableControl( const Sequence< Referen { try { + if ( !pControls->is() ) + continue; + + Reference< XPropertySet > xModelProps( (*pControls)->getModel(), UNO_QUERY_THROW ); + + // only enabled controls are allowed to participate + sal_Bool bEnabled = sal_False; + OSL_VERIFY( xModelProps->getPropertyValue( FM_PROP_ENABLED ) >>= bEnabled ); + if ( !bEnabled ) + continue; + // check the class id of the control model sal_Int16 nClassId = FormComponentType::CONTROL; - - Reference< XPropertySet > xModelProps; - if ( pControls->is() ) - xModelProps = xModelProps.query( (*pControls)->getModel() ); - if ( xModelProps.is() ) - xModelProps->getPropertyValue( FM_PROP_CLASSID ) >>= nClassId; + OSL_VERIFY( xModelProps->getPropertyValue( FM_PROP_CLASSID ) >>= nClassId ); // controls which are not focussable if ( ( FormComponentType::CONTROL != nClassId ) @@ -1115,10 +1121,10 @@ namespace Reference< XFormComponent > xFormComponent( _rSdrObj.GetUnoControlModel(), UNO_QUERY_THROW ); Reference< XForm > xTargetForm( - rPage.GetImpl()->findPlaceInFormComponentHierarchy( xFormComponent, _rxDataSource, _rDataSourceName, _rCommand, _nCommandType ), + rPage.GetImpl().findPlaceInFormComponentHierarchy( xFormComponent, _rxDataSource, _rDataSourceName, _rCommand, _nCommandType ), UNO_SET_THROW ); - rPage.GetImpl()->setUniqueName( xFormComponent, xTargetForm ); + rPage.GetImpl().setUniqueName( xFormComponent, xTargetForm ); Reference< XIndexContainer > xFormAsContainer( xTargetForm, UNO_QUERY_THROW ); xFormAsContainer->insertByIndex( xFormAsContainer->getCount(), makeAny( xFormComponent ) ); diff --git a/svx/source/form/formcontrolfactory.cxx b/svx/source/form/formcontrolfactory.cxx index 8c9065fe1a46..570fb4df15c3 100644 --- a/svx/source/form/formcontrolfactory.cxx +++ b/svx/source/form/formcontrolfactory.cxx @@ -519,6 +519,7 @@ namespace svxform { sal_Bool bDropDown = !_rControlBoundRect.IsEmpty() && ( _rControlBoundRect.GetWidth() >= 3 * _rControlBoundRect.GetHeight() ); _rxControlModel->setPropertyValue( FM_PROP_DROPDOWN, makeAny( (sal_Bool)bDropDown ) ); + _rxControlModel->setPropertyValue( FM_PROP_LINECOUNT, makeAny( sal_Int16( 20 ) ) ); } break; diff --git a/svx/source/form/navigatortree.cxx b/svx/source/form/navigatortree.cxx index e2b3992c81a5..b57863ffd5ae 100644 --- a/svx/source/form/navigatortree.cxx +++ b/svx/source/form/navigatortree.cxx @@ -1538,7 +1538,7 @@ namespace svxform SdrPageView* pPageView = pFormView->GetSdrPageView(); FmFormPage* pPage = (FmFormPage*)pPageView->GetPage(); - ::rtl::OUString sName = pPage->GetImpl()->setUniqueName( xNewComponent, xParentForm ); + ::rtl::OUString sName = pPage->GetImpl().setUniqueName( xNewComponent, xParentForm ); pNewFormControlData->SetText( sName ); diff --git a/svx/source/inc/GraphCtlAccessibleContext.hxx b/svx/source/inc/GraphCtlAccessibleContext.hxx index 906833e81251..0b862e1be691 100644 --- a/svx/source/inc/GraphCtlAccessibleContext.hxx +++ b/svx/source/inc/GraphCtlAccessibleContext.hxx @@ -57,7 +57,7 @@ #include <set> #include <map> -#include <unotools/servicehelper.hxx> +#include <comphelper/servicehelper.hxx> #include <svx/rectenum.hxx> #include <svx/AccessibleShapeTreeInfo.hxx> #include <svx/IAccessibleViewForwarder.hxx> diff --git a/svx/source/inc/fmobj.hxx b/svx/source/inc/fmobj.hxx index 236a9d2a67ca..e37b6a32e74e 100644 --- a/svx/source/inc/fmobj.hxx +++ b/svx/source/inc/fmobj.hxx @@ -109,6 +109,8 @@ public: */ sal_Int32 getType() const; + virtual void SetUnoControlModel( const ::com::sun::star::uno::Reference< com::sun::star::awt::XControlModel >& _rxModel ); + protected: virtual FASTBOOL EndCreate( SdrDragStat& rStat, SdrCreateCmd eCmd ); virtual void BrkCreate( SdrDragStat& rStat ); diff --git a/svx/source/inc/fmpgeimp.hxx b/svx/source/inc/fmpgeimp.hxx index ac2c573565dc..90a7a4027b46 100644 --- a/svx/source/inc/fmpgeimp.hxx +++ b/svx/source/inc/fmpgeimp.hxx @@ -37,10 +37,12 @@ #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/container/XMap.hpp> #include <tools/list.hxx> #include <tools/link.hxx> #include <comphelper/uno3.hxx> +#include <cppuhelper/weakref.hxx> #include "svx/svxdllapi.h" #include <map> @@ -57,8 +59,6 @@ FORWARD_DECLARE_INTERFACE(container,XIndexContainer) class SdrObjList; -DECLARE_LIST(FmObjectList, FmFormObj*) - //================================================================== // FmFormPageImpl // lauscht an allen Containern, um festzustellen, wann Objecte @@ -68,9 +68,11 @@ DECLARE_LIST(FmObjectList, FmFormObj*) class SVX_DLLPRIVATE FmFormPageImpl { ::std::map< ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent >,SdrObject* > m_aComponentMap; - ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm> xCurrentForm; - ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer> m_xForms; - FmFormPage* pPage; + ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > xCurrentForm; + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > m_xForms; + ::com::sun::star::uno::WeakReference< ::com::sun::star::container::XMap > m_aControlShapeMap; + + FmFormPage& m_rPage; Link m_aFormsCreationHdl; sal_Bool m_bFirstActivation; @@ -81,8 +83,8 @@ protected: void Init(); public: - FmFormPageImpl(FmFormPage* _pPage); - FmFormPageImpl(FmFormPage* _pPage, const FmFormPageImpl& rImpl); + FmFormPageImpl( FmFormPage& _rPage ); + FmFormPageImpl( FmFormPage& _rPage, const FmFormPageImpl& rImpl ); ~FmFormPageImpl(); // nur wichtig fuer den DesignMode @@ -137,6 +139,24 @@ protected: const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XServiceInfo >& _rxObject ) const; +public: + + static UniString getDefaultName( + sal_Int16 nClassId, + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XServiceInfo >& _rxObject + ); + + ::rtl::OUString setUniqueName(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent>& xFormComponent, const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm>& xControls); + ::rtl::OUString getUniqueName(const ::rtl::OUString& rName, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& xNamedSet) const; + + void formObjectInserted( const FmFormObj& _object ); + void formObjectRemoved( const FmFormObj& _object ); + + /** returns an object mapping from control models to drawing shapes. + */ + ::com::sun::star::uno::Reference< ::com::sun::star::container::XMap > + getControlToShapeMap(); + private: /** validates whether <member>xCurrentForm</member> is still valid and to be used @@ -153,16 +173,8 @@ private: */ bool validateCurForm(); -public: - - static UniString getDefaultName( - sal_Int16 nClassId, - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XServiceInfo >& _rxObject - ); - - ::rtl::OUString setUniqueName(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent>& xFormComponent, const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm>& xControls); - ::rtl::OUString getUniqueName(const ::rtl::OUString& rName, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& xNamedSet) const; - + ::com::sun::star::uno::Reference< ::com::sun::star::container::XMap > + impl_createControlShapeMap_nothrow(); private: FmFormPageImpl(); // never implemented diff --git a/svx/source/inc/fmshimp.hxx b/svx/source/inc/fmshimp.hxx index 9cc316ae575c..d3e8e8ce0327 100644 --- a/svx/source/inc/fmshimp.hxx +++ b/svx/source/inc/fmshimp.hxx @@ -181,6 +181,7 @@ typedef ::utl::ConfigItem FmXFormShell_CFGBASE; struct SdrViewEvent; class FmFormShell; +class FmFormView; class SAL_DLLPRIVATE FmXFormShell :public FmXFormShell_BASE ,public FmXFormShell_CFGBASE ,public ::svxform::OStaticDataAccessTools diff --git a/svx/source/inc/svxrectctaccessiblecontext.hxx b/svx/source/inc/svxrectctaccessiblecontext.hxx index c1a4c5a6ecbc..9479ed15cfc4 100644 --- a/svx/source/inc/svxrectctaccessiblecontext.hxx +++ b/svx/source/inc/svxrectctaccessiblecontext.hxx @@ -55,7 +55,7 @@ //#endif #include <comphelper/broadcasthelper.hxx> #include <cppuhelper/implbase6.hxx> -#include <unotools/servicehelper.hxx> +#include <comphelper/servicehelper.hxx> #include <svx/rectenum.hxx> namespace com { namespace sun { namespace star { namespace awt { diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx index 6ec9c607188b..c1abb3add6b9 100644 --- a/svx/source/svdraw/svdobj.cxx +++ b/svx/source/svdraw/svdobj.cxx @@ -126,6 +126,7 @@ #include <drawinglayer/processor2d/linegeometryextractor2d.hxx> #include <svx/polysc3d.hxx> #include "svx/svdotable.hxx" +#include "svx/shapepropertynotifier.hxx" using namespace ::com::sun::star; @@ -430,17 +431,18 @@ DBG_NAME(SdrObject); TYPEINIT1(SdrObject,SfxListener); SdrObject::SdrObject() -: mpProperties(0L), - mpViewContact(0L), - pObjList(NULL), - pPage(NULL), - pModel(NULL), - pUserCall(NULL), - pPlusData(NULL), - nOrdNum(0), - mnNavigationPosition(SAL_MAX_UINT32), - mnLayerID(0), - mpSvxShape(0) + :mpProperties(0L) + ,mpViewContact(0L) + ,pObjList(NULL) + ,pPage(NULL) + ,pModel(NULL) + ,pUserCall(NULL) + ,pPlusData(NULL) + ,nOrdNum(0) + ,mnNavigationPosition(SAL_MAX_UINT32) + ,mnLayerID(0) + ,mpSvxShape( NULL ) + ,maWeakUnoShape() { DBG_CTOR(SdrObject,NULL); bVirtObj =FALSE; @@ -488,13 +490,12 @@ SdrObject::~SdrObject() try { - uno::Reference< uno::XInterface > xShape; - SvxShape* pSvxShape = getSvxShape( xShape ); + SvxShape* pSvxShape = getSvxShape(); if ( pSvxShape ) { OSL_ENSURE(!pSvxShape->HasSdrObjectOwnership(),"Please check where this call come from and replace it with SdrObject::Free"); pSvxShape->InvalidateSdrObject(); - uno::Reference< lang::XComponent > xShapeComp( xShape, uno::UNO_QUERY_THROW ); + uno::Reference< lang::XComponent > xShapeComp( getWeakUnoShape(), uno::UNO_QUERY_THROW ); xShapeComp->dispose(); } } @@ -528,8 +529,7 @@ void SdrObject::Free( SdrObject*& _rpObject ) // nothing to do return; - uno::Reference< uno::XInterface > xShape; - SvxShape* pShape = pObject->getSvxShape( xShape ); + SvxShape* pShape = pObject->getSvxShape(); if ( pShape && pShape->HasSdrObjectOwnership() ) // only the shape is allowed to delete me, and will reset the ownership before doing so return; @@ -566,8 +566,7 @@ void SdrObject::SetModel(SdrModel* pNewModel) // update listeners at possible api wrapper object if( pModel != pNewModel ) { - uno::Reference< uno::XInterface > xShapeGuard; - SvxShape* pShape = getSvxShape( xShapeGuard ); + SvxShape* pShape = getSvxShape(); if( pShape ) pShape->ChangeModel( pNewModel ); } @@ -2770,15 +2769,18 @@ void SdrObject::SendUserCall(SdrUserCallType eUserCall, const Rectangle& rBoundR pGroup = NULL; } - if( eUserCall == SDRUSERCALL_CHGATTR ) + // notify our UNO shape listeners + switch ( eUserCall ) { - if( pModel && pModel->IsAllowShapePropertyChangeListener() ) - { - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xShapeGuard; - SvxShape* pShape = const_cast< SdrObject* >(this)->getSvxShape( xShapeGuard ); - if( pShape ) - pShape->onUserCall( eUserCall, rBoundRect ); - } + case SDRUSERCALL_RESIZE: + notifyShapePropertyChange( ::svx::eShapeSize ); + // fall through - RESIZE might also imply a change of the position + case SDRUSERCALL_MOVEONLY: + notifyShapePropertyChange( ::svx::eShapePosition ); + break; + default: + // not interested in + break; } } @@ -2844,30 +2846,26 @@ sal_Bool SdrObject::IsTransparent( BOOL /*bCheckForAlphaChannel*/) const return bRet; } -void SdrObject::setUnoShape( - const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxUnoShape, - SdrObject::GrantXShapeAccess /*aGrant*/ -) +void SdrObject::impl_setUnoShape( const uno::Reference< uno::XInterface >& _rxUnoShape ) { - mxUnoShape = _rxUnoShape; - mpSvxShape = 0; + maWeakUnoShape = _rxUnoShape; + mpSvxShape = SvxShape::getImplementation( _rxUnoShape ); + OSL_ENSURE( mpSvxShape || !_rxUnoShape.is(), + "SdrObject::setUnoShape: not sure it's a good idea to have an XShape which is not implemented by SvxShape ..." ); } /** only for internal use! */ -SvxShape* SdrObject::getSvxShape( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xShapeGuard ) +SvxShape* SdrObject::getSvxShape() const { - xShapeGuard = xShapeGuard.query( mxUnoShape ); - if( xShapeGuard.is() ) - { - if( !mpSvxShape ) - { - mpSvxShape = SvxShape::getImplementation( xShapeGuard ); - } - } - else if( mpSvxShape ) - { - mpSvxShape = NULL; - } + DBG_TESTSOLARMUTEX(); + // retrieving the impl pointer and subsequently using it is not thread-safe, of course, so it needs to be + // guarded by the SolarMutex + +#if OSL_DEBUG_LEVE > 0 + uno::Reference< uno::XInterface > xShape( maWeakUnoShape ); + OSL_ENSURE( !( !xShapeGuard.is() && mpSvxShape ), + "SdrObject::getSvxShape: still having IMPL-Pointer to dead object!" ); +#endif return mpSvxShape; } @@ -2875,12 +2873,12 @@ SvxShape* SdrObject::getSvxShape( ::com::sun::star::uno::Reference< ::com::sun:: ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SdrObject::getUnoShape() { // try weak reference first - uno::Reference< uno::XInterface > xShape( mxUnoShape ); + uno::Reference< uno::XInterface > xShape( getWeakUnoShape() ); if( !xShape.is() ) { + OSL_ENSURE( mpSvxShape == NULL, "SdrObject::getUnoShape: XShape already dead, but still an IMPL pointer!" ); if ( pPage ) { - mpSvxShape = 0; uno::Reference< uno::XInterface > xPage( pPage->getUnoPage() ); if( xPage.is() ) { @@ -2888,20 +2886,39 @@ SvxShape* SdrObject::getSvxShape( ::com::sun::star::uno::Reference< ::com::sun:: if( pDrawPage ) { // create one - mxUnoShape = xShape = pDrawPage->_CreateShape( this ); + xShape = pDrawPage->_CreateShape( this ); + impl_setUnoShape( xShape ); } } } else { mpSvxShape = SvxDrawPage::CreateShapeByTypeAndInventor( GetObjIdentifier(), GetObjInventor(), this, NULL ); - mxUnoShape = xShape = static_cast< ::cppu::OWeakObject* >( mpSvxShape ); + maWeakUnoShape = xShape = static_cast< ::cppu::OWeakObject* >( mpSvxShape ); } } return xShape; } +::svx::PropertyChangeNotifier& SdrObject::getShapePropertyChangeNotifier() +{ + DBG_TESTSOLARMUTEX(); + + SvxShape* pSvxShape = getSvxShape(); + ENSURE_OR_THROW( pSvxShape, "no SvxShape, yet!" ); + return pSvxShape->getShapePropertyChangeNotifier(); +} + +void SdrObject::notifyShapePropertyChange( const ::svx::ShapeProperty _eProperty ) const +{ + DBG_TESTSOLARMUTEX(); + + SvxShape* pSvxShape = const_cast< SdrObject* >( this )->getSvxShape(); + if ( pSvxShape ) + return pSvxShape->getShapePropertyChangeNotifier().notifyPropertyChange( _eProperty ); +} + //////////////////////////////////////////////////////////////////////////////////////////////////// // // transformation interface for StarOfficeAPI. This implements support for diff --git a/svx/source/svdraw/svdouno.cxx b/svx/source/svdraw/svdouno.cxx index d6020908bef0..abf9574f9172 100644 --- a/svx/source/svdraw/svdouno.cxx +++ b/svx/source/svdraw/svdouno.cxx @@ -579,7 +579,7 @@ void SdrUnoObj::CreateUnoControlModel(const String& rModelName, SetUnoControlModel(xModel); } -void SdrUnoObj::SetUnoControlModel( uno::Reference< awt::XControlModel > xModel) +void SdrUnoObj::SetUnoControlModel( const uno::Reference< awt::XControlModel >& xModel) { if (xUnoControlModel.is()) { diff --git a/svx/source/unodraw/makefile.mk b/svx/source/unodraw/makefile.mk index 3eee2c74f8d5..9b71d644f39d 100644 --- a/svx/source/unodraw/makefile.mk +++ b/svx/source/unodraw/makefile.mk @@ -70,7 +70,8 @@ SLOFILES = \ $(SLO)$/unodtabl.obj \ $(SLO)$/gluepts.obj \ $(SLO)$/recoveryui.obj \ - $(SLO)$/tableshape.obj + $(SLO)$/tableshape.obj \ + $(SLO)$/shapepropertynotifier.obj SRS1NAME=unodraw SRC1FILES = \ diff --git a/svx/source/unodraw/shapeimpl.hxx b/svx/source/unodraw/shapeimpl.hxx index b62167665fe3..131bb087f118 100644 --- a/svx/source/unodraw/shapeimpl.hxx +++ b/svx/source/unodraw/shapeimpl.hxx @@ -63,7 +63,7 @@ public: virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void Create( SdrObject* pNewOpj, SvxDrawPage* pNewPage = NULL ) throw (); + virtual void Create( SdrObject* pNewOpj, SvxDrawPage* pNewPage = NULL ); }; /*********************************************************************** @@ -84,7 +84,7 @@ public: virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void Create( SdrObject* pNewOpj, SvxDrawPage* pNewPage = NULL ) throw (); + virtual void Create( SdrObject* pNewOpj, SvxDrawPage* pNewPage = NULL ); }; /*********************************************************************** diff --git a/svx/source/unodraw/shapepropertynotifier.cxx b/svx/source/unodraw/shapepropertynotifier.cxx new file mode 100644 index 000000000000..5e6cb2345765 --- /dev/null +++ b/svx/source/unodraw/shapepropertynotifier.cxx @@ -0,0 +1,206 @@ +/************************************************************************* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2009 by Sun Microsystems, Inc. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +************************************************************************/ +
+// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +#include "svx/shapepropertynotifier.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/beans/XPropertySet.hpp> +/** === end UNO includes === **/ + +#include <comphelper/stl_types.hxx> +#include <cppuhelper/interfacecontainer.hxx> +#include <cppuhelper/weak.hxx> +#include <tools/diagnose_ex.h> + +#include <hash_map> + +namespace +{ + + struct ShapePropertyHash + { + size_t operator()( ::svx::ShapeProperty __x ) const + { + return size_t( __x ); + } + }; +} + +//........................................................................ +namespace svx +{ +//........................................................................ + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + 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::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::beans::PropertyChangeEvent; + using ::com::sun::star::beans::XPropertyChangeListener; + using ::com::sun::star::lang::EventObject; + using ::com::sun::star::beans::XPropertySet; + /** === end UNO using === **/ + + typedef ::std::hash_map< ShapeProperty, PPropertyValueProvider, ShapePropertyHash > PropertyProviders; + + typedef ::cppu::OMultiTypeInterfaceContainerHelperVar < ::rtl::OUString + , ::comphelper::UStringHash + , ::comphelper::UStringEqual + > PropertyChangeListenerContainer; + + //==================================================================== + //= IPropertyValueProvider + //==================================================================== + IPropertyValueProvider::~IPropertyValueProvider() + { + } + + //==================================================================== + //= PropertyChangeNotifier_Data + //==================================================================== + struct PropertyChangeNotifier_Data + { + ::cppu::OWeakObject& m_rContext; + PropertyProviders m_aProviders; + PropertyChangeListenerContainer m_aPropertyChangeListeners; + + PropertyChangeNotifier_Data( ::cppu::OWeakObject& _rContext, ::osl::Mutex& _rMutex ) + :m_rContext( _rContext ) + ,m_aPropertyChangeListeners( _rMutex ) + { + } + }; + //==================================================================== + //= PropertyValueProvider + //==================================================================== + //-------------------------------------------------------------------- + ::rtl::OUString PropertyValueProvider::getPropertyName() const + { + return m_sPropertyName; + } + + //-------------------------------------------------------------------- + void PropertyValueProvider::getCurrentValue( Any& _out_rValue ) const + { + Reference< XPropertySet > xContextProps( const_cast< PropertyValueProvider* >( this )->m_rContext, UNO_QUERY_THROW ); + _out_rValue = xContextProps->getPropertyValue( getPropertyName() ); + } + + //==================================================================== + //= PropertyChangeNotifier + //==================================================================== + //-------------------------------------------------------------------- + PropertyChangeNotifier::PropertyChangeNotifier( ::cppu::OWeakObject& _rOwner, ::osl::Mutex& _rMutex ) + :m_pData( new PropertyChangeNotifier_Data( _rOwner, _rMutex ) ) + { + } + + //-------------------------------------------------------------------- + PropertyChangeNotifier::~PropertyChangeNotifier() + { + } + + //-------------------------------------------------------------------- + void PropertyChangeNotifier::registerProvider( const ShapeProperty _eProperty, const PPropertyValueProvider _pProvider ) + { + ENSURE_OR_THROW( _eProperty != eInvalidShapeProperty, "Illegal ShapeProperty value!" ); + ENSURE_OR_THROW( !!_pProvider, "NULL factory not allowed." ); + + OSL_ENSURE( m_pData->m_aProviders.find( _eProperty ) == m_pData->m_aProviders.end(), + "PropertyChangeNotifier::registerProvider: factory for this ID already present!" ); + + m_pData->m_aProviders[ _eProperty ] = _pProvider; + } + + //-------------------------------------------------------------------- + void PropertyChangeNotifier::notifyPropertyChange( const ShapeProperty _eProperty ) const + { + ENSURE_OR_THROW( _eProperty != eInvalidShapeProperty, "Illegal ShapeProperty value!" ); + + PropertyProviders::const_iterator provPos = m_pData->m_aProviders.find( _eProperty ); + OSL_ENSURE( provPos != m_pData->m_aProviders.end(), "PropertyChangeNotifier::notifyPropertyChange: no factory!" ); + if ( provPos == m_pData->m_aProviders.end() ) + return; + + ::rtl::OUString sPropertyName( provPos->second->getPropertyName() ); + + ::cppu::OInterfaceContainerHelper* pPropListeners = m_pData->m_aPropertyChangeListeners.getContainer( sPropertyName ); + ::cppu::OInterfaceContainerHelper* pAllListeners = m_pData->m_aPropertyChangeListeners.getContainer( ::rtl::OUString() ); + if ( !pPropListeners && !pAllListeners ) + return; + + try + { + PropertyChangeEvent aEvent; + aEvent.Source = m_pData->m_rContext; + // Handle/OldValue not supported + aEvent.PropertyName = provPos->second->getPropertyName(); + provPos->second->getCurrentValue( aEvent.NewValue ); + + if ( pPropListeners ) + pPropListeners->notifyEach( &XPropertyChangeListener::propertyChange, aEvent ); + if ( pAllListeners ) + pAllListeners->notifyEach( &XPropertyChangeListener::propertyChange, aEvent ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + + //-------------------------------------------------------------------- + void PropertyChangeNotifier::addPropertyChangeListener( const ::rtl::OUString& _rPropertyName, const Reference< XPropertyChangeListener >& _rxListener ) + { + m_pData->m_aPropertyChangeListeners.addInterface( _rPropertyName, _rxListener ); + } + + //-------------------------------------------------------------------- + void PropertyChangeNotifier::removePropertyChangeListener( const ::rtl::OUString& _rPropertyName, const Reference< XPropertyChangeListener >& _rxListener ) + { + m_pData->m_aPropertyChangeListeners.removeInterface( _rPropertyName, _rxListener ); + } + + //-------------------------------------------------------------------- + void PropertyChangeNotifier::disposing() + { + EventObject aEvent; + aEvent.Source = m_pData->m_rContext; + m_pData->m_aPropertyChangeListeners.disposeAndClear( aEvent ); + } + +//........................................................................ +} // namespace svx +//........................................................................ diff --git a/svx/source/unodraw/unonrule.cxx b/svx/source/unodraw/unonrule.cxx index da20980e34db..7947cde7e790 100644 --- a/svx/source/unodraw/unonrule.cxx +++ b/svx/source/unodraw/unonrule.cxx @@ -50,7 +50,7 @@ #include <vos/mutex.hxx> #include <vcl/graph.hxx> -#include <unotools/servicehelper.hxx> +#include <comphelper/servicehelper.hxx> #include <toolkit/unohlp.hxx> #include <rtl/uuid.h> #include <rtl/memory.h> diff --git a/svx/source/unodraw/unoshap2.cxx b/svx/source/unodraw/unoshap2.cxx index d919a7864697..9b68e94239c5 100644 --- a/svx/source/unodraw/unoshap2.cxx +++ b/svx/source/unodraw/unoshap2.cxx @@ -111,7 +111,7 @@ SvxShapeGroup::~SvxShapeGroup() throw() } //---------------------------------------------------------------------- -void SvxShapeGroup::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage ) throw() +void SvxShapeGroup::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage ) { SvxShape::Create( pNewObj, pNewPage ); mxPage = pNewPage; @@ -1895,7 +1895,7 @@ SvxCustomShape::~SvxCustomShape() throw() //---------------------------------------------------------------------- -void SvxCustomShape::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage ) throw() +void SvxCustomShape::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage ) { SvxShapeText::Create( pNewObj, pNewPage ); } diff --git a/svx/source/unodraw/unoshap3.cxx b/svx/source/unodraw/unoshap3.cxx index 1441e2759465..dc24ad21ddca 100644 --- a/svx/source/unodraw/unoshap3.cxx +++ b/svx/source/unodraw/unoshap3.cxx @@ -92,7 +92,7 @@ Svx3DSceneObject::~Svx3DSceneObject() throw() } //---------------------------------------------------------------------- -void Svx3DSceneObject::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage ) throw() +void Svx3DSceneObject::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage ) { SvxShape::Create( pNewObj, pNewPage ); mxPage = pNewPage; diff --git a/svx/source/unodraw/unoshap4.cxx b/svx/source/unodraw/unoshap4.cxx index 6aa9ca7d6363..674cb8fdb24d 100644 --- a/svx/source/unodraw/unoshap4.cxx +++ b/svx/source/unodraw/unoshap4.cxx @@ -639,7 +639,7 @@ SvxAppletShape::~SvxAppletShape() throw() { } -void SvxAppletShape::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage ) throw () +void SvxAppletShape::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage ) { SvxShape::Create( pNewObj, pNewPage ); const SvGlobalName aAppletClassId( SO3_APPLET_CLASSID ); @@ -712,7 +712,7 @@ SvxPluginShape::~SvxPluginShape() throw() { } -void SvxPluginShape::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage ) throw () +void SvxPluginShape::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage ) { SvxShape::Create( pNewObj, pNewPage ); const SvGlobalName aPluginClassId( SO3_PLUGIN_CLASSID ); diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx index 88093d39ea95..3f7f58a1e9ad 100644 --- a/svx/source/unodraw/unoshape.cxx +++ b/svx/source/unodraw/unoshape.cxx @@ -37,7 +37,6 @@ #include <com/sun/star/awt/Rectangle.hpp> #include <com/sun/star/drawing/CircleKind.hpp> #include <com/sun/star/embed/NoVisualAreaSizeException.hpp> -#include <cppuhelper/interfacecontainer.hxx> #include <vcl/svapp.hxx> #include <svtools/itemprop.hxx> #include <svtools/fltcall.hxx> @@ -47,6 +46,7 @@ #include <svx/svdoole2.hxx> #include <osl/mutex.hxx> #include <comphelper/extract.hxx> +#include "svx/shapepropertynotifier.hxx" #include <toolkit/unohlp.hxx> @@ -84,6 +84,7 @@ #include "svx/dialogs.hrc" // #include "svx/svdocapt.hxx" #include <svx/obj3d.hxx> +#include <tools/diagnose_ex.h> #include "svx/xflftrit.hxx" #include "svx/xtable.hxx" #include "svx/xbtmpit.hxx" @@ -116,6 +117,8 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::container; +using ::svx::PropertyValueProvider; +using ::svx::IPropertyValueProvider; #define QUERYINT( xint ) \ if( rType == ::getCppuType((const uno::Reference< xint >*)0) ) \ @@ -156,15 +159,17 @@ sal_Bool ConvertGDIMetaFileToWMF( const GDIMetaFile & rMTF, SvStream & rTargetSt uno::Reference< uno::XInterface > SAL_CALL SvxUnoGluePointAccess_createInstance( SdrObject* pObject ); /*********************************************************************** -* class SvxShape * +* class SvxShapeImpl * ***********************************************************************/ struct SvxShapeImpl { + SvxShape& mrAntiImpl; SfxItemSet* mpItemSet; sal_uInt32 mnObjId; SvxShapeMaster* mpMaster; bool mbHasSdrObjectOwnership; + bool mbDisposing; /** CL, OD 2005-07-19 #i52126# - this is initially 0 and set when * a SvxShape::Create() call is executed. It is then set to the created @@ -172,58 +177,105 @@ struct SvxShapeImpl * is prohibited. */ SdrObject* mpCreatedObj; + + // for xComponent + ::cppu::OInterfaceContainerHelper maDisposeListeners; + ::svx::PropertyChangeNotifier maPropertyNotifier; + + SvxShapeImpl( SvxShape& _rAntiImpl, ::osl::Mutex& _rMutex ) + :mrAntiImpl( _rAntiImpl ) + ,mpItemSet( NULL ) + ,mnObjId( 0 ) + ,mpMaster( NULL ) + ,mbHasSdrObjectOwnership( false ) + ,mbDisposing( false ) + ,mpCreatedObj( NULL ) + ,maDisposeListeners( _rMutex ) + ,maPropertyNotifier( _rAntiImpl, _rMutex ) + { + } +}; + +/**********************************************************************/ +class ShapePositionProvider : public PropertyValueProvider +{ +public: + ShapePositionProvider( const SvxShapeImpl& _shapeImpl ) + :PropertyValueProvider( _shapeImpl.mrAntiImpl, "Position" ) + { + } + +protected: + virtual void getCurrentValue( Any& _out_rCurrentValue ) const + { + _out_rCurrentValue <<= static_cast< SvxShape& >( getContext() ).getPosition(); + } +}; + +//---------------------------------------------------------------------- +class ShapeSizeProvider : public PropertyValueProvider +{ +public: + ShapeSizeProvider( const SvxShapeImpl& _shapeImpl ) + :PropertyValueProvider( _shapeImpl.mrAntiImpl, "Size" ) + { + } + +protected: + virtual void getCurrentValue( Any& _out_rCurrentValue ) const + { + _out_rCurrentValue <<= static_cast< SvxShape& >( getContext() ).getSize(); + } }; +/*********************************************************************** +* class SvxShape * +***********************************************************************/ + DBG_NAME(SvxShape) SvxShape::SvxShape( SdrObject* pObject ) throw() : maSize(100,100) -, mpImpl(NULL) +, mpImpl( new SvxShapeImpl( *this, maMutex ) ) , mbIsMultiPropertyCall(false) , mpPropSet(aSvxMapProvider.GetPropertySet(SVXMAP_SHAPE)) , maPropMapEntries(aSvxMapProvider.GetMap(SVXMAP_SHAPE)) -, maDisposeListeners( maMutex ) -, mbDisposing( false ) , mpObj(pObject) , mpModel(NULL) , mnLockCount(0) { DBG_CTOR(SvxShape,NULL); - Init(); + impl_construct(); } //---------------------------------------------------------------------- SvxShape::SvxShape( SdrObject* pObject, const SfxItemPropertyMapEntry* pEntries, const SvxItemPropertySet* pPropertySet ) throw() : maSize(100,100) -, mpImpl(NULL) +, mpImpl( new SvxShapeImpl( *this, maMutex ) ) , mbIsMultiPropertyCall(false) , mpPropSet(pPropertySet) , maPropMapEntries(pEntries) -, maDisposeListeners( maMutex ) -, mbDisposing( false ) , mpObj(pObject) , mpModel(NULL) , mnLockCount(0) { DBG_CTOR(SvxShape,NULL); - Init(); + impl_construct(); } //---------------------------------------------------------------------- SvxShape::SvxShape() throw() : maSize(100,100) -, mpImpl(NULL) +, mpImpl( new SvxShapeImpl( *this, maMutex ) ) , mbIsMultiPropertyCall(false) , mpPropSet(aSvxMapProvider.GetPropertySet(SVXMAP_SHAPE)) , maPropMapEntries(aSvxMapProvider.GetMap(SVXMAP_SHAPE)) -, maDisposeListeners( maMutex ) -, mbDisposing( false ) , mpObj(NULL) , mpModel(NULL) , mnLockCount(0) { DBG_CTOR(SvxShape,NULL); - Init(); + impl_construct(); } //---------------------------------------------------------------------- @@ -233,12 +285,15 @@ SvxShape::~SvxShape() throw() DBG_ASSERT( mnLockCount == 0, "Locked shape was disposed!" ); - if( mpModel ) + if ( mpModel ) EndListening( *mpModel ); - if(mpImpl && mpImpl->mpMaster) + if ( mpImpl->mpMaster ) mpImpl->mpMaster->dispose(); + if ( mpObj.is() ) + mpObj->setUnoShape( NULL, SdrObject::GrantXShapeAccess() ); + if( HasSdrObjectOwnership() && mpObj.is() ) { mpImpl->mbHasSdrObjectOwnership = false; @@ -255,18 +310,13 @@ SvxShape::~SvxShape() throw() void SvxShape::TakeSdrObjectOwnership() { - if ( mpImpl ) - mpImpl->mbHasSdrObjectOwnership = true; + mpImpl->mbHasSdrObjectOwnership = true; } //---------------------------------------------------------------------- bool SvxShape::HasSdrObjectOwnership() const { - OSL_PRECOND( mpImpl, "SvxShape::HasSdrObjectOwnership: no impl!?" ); - if ( !mpImpl ) - return false; - if ( !mpImpl->mbHasSdrObjectOwnership ) return false; @@ -278,15 +328,14 @@ bool SvxShape::HasSdrObjectOwnership() const void SvxShape::setShapeKind( sal_uInt32 nKind ) { - if( mpImpl ) - mpImpl->mnObjId = nKind; + mpImpl->mnObjId = nKind; } //---------------------------------------------------------------------- sal_uInt32 SvxShape::getShapeKind() const { - return mpImpl ? mpImpl->mnObjId : (sal_uInt32)OBJ_NONE; + return mpImpl->mnObjId; } //---------------------------------------------------------------------- @@ -298,12 +347,12 @@ void SvxShape::setMaster( SvxShapeMaster* pMaster ) SvxShapeMaster* SvxShape::getMaster() { - return mpImpl ? mpImpl->mpMaster : NULL; + return mpImpl->mpMaster; } const SvxShapeMaster* SvxShape::getMaster() const { - return mpImpl ? mpImpl->mpMaster : NULL; + return mpImpl->mpMaster; } //---------------------------------------------------------------------- @@ -338,7 +387,7 @@ const ::com::sun::star::uno::Sequence< sal_Int8 > & SvxShape::getUnoTunnelId() t } //---------------------------------------------------------------------- -SvxShape* SvxShape::getImplementation( uno::Reference< uno::XInterface > xInt ) throw() +SvxShape* SvxShape::getImplementation( const uno::Reference< uno::XInterface >& xInt ) { uno::Reference< lang::XUnoTunnel > xUT( xInt, ::com::sun::star::uno::UNO_QUERY ); if( xUT.is() ) @@ -366,27 +415,30 @@ SvxShape* SvxShape::GetShapeForSdrObj( SdrObject* pObj ) throw() return getImplementation( pObj->getUnoShape() ); } -void SvxShape::Init() throw() +//---------------------------------------------------------------------- +::svx::PropertyChangeNotifier& SvxShape::getShapePropertyChangeNotifier() { - if( NULL == mpImpl ) - { - mpImpl = new SvxShapeImpl; - mpImpl->mpItemSet = NULL; - mpImpl->mpMaster = NULL; - mpImpl->mnObjId = 0; - mpImpl->mbHasSdrObjectOwnership= false; - // --> CL, OD 2005-07-19 #i52126# - mpImpl->mpCreatedObj = NULL; - // <-- - } + return mpImpl->maPropertyNotifier; +} - mbIsMultiPropertyCall = sal_False; +//---------------------------------------------------------------------- +void SvxShape::impl_construct() +{ + mpImpl->maPropertyNotifier.registerProvider( ::svx::eShapePosition, + ::svx::PPropertyValueProvider( new ShapePositionProvider( *mpImpl ) ) ); + mpImpl->maPropertyNotifier.registerProvider( ::svx::eShapeSize, + ::svx::PPropertyValueProvider( new ShapeSizeProvider( *mpImpl ) ) ); + + if ( mpObj.is() ) + impl_initFromSdrObject(); +} - // only init if we already have an object - // if we get an object later Init() will - // be called again +//---------------------------------------------------------------------- +void SvxShape::impl_initFromSdrObject() +{ DBG_TESTSOLARMUTEX(); - if(!mpObj.is()) + OSL_PRECOND( mpObj.is(), "SvxShape::impl_initFromSdrObject: not to be called without SdrObject!" ); + if ( !mpObj.is() ) return; osl_incrementInterlockedCount( &m_refCount ); @@ -437,14 +489,19 @@ void SvxShape::Init() throw() } //---------------------------------------------------------------------- -void SvxShape::Create( SdrObject* pNewObj, SvxDrawPage* /*pNewPage*/ ) throw() +void SvxShape::Create( SdrObject* pNewObj, SvxDrawPage* /*pNewPage*/ ) { - DBG_ASSERT( mpImpl, "svx::SvxShape::Create(), no mpImpl!" ); - DBG_TESTSOLARMUTEX(); + OSL_PRECOND( pNewObj, "SvxShape::Create: invalid new object!" ); + if ( !pNewObj ) + return; + + OSL_ENSURE( ( mpImpl->mpCreatedObj == NULL ) || ( mpImpl->mpCreatedObj == pNewObj ), + "SvxShape::Create: the same shape used for two different objects?! Strange ..." ); + // --> CL, OD 2005-07-19 #i52126# - correct condition - if ( pNewObj && (mpImpl && (mpImpl->mpCreatedObj != pNewObj) ) ) + if ( mpImpl->mpCreatedObj != pNewObj ) // <-- { DBG_ASSERT( pNewObj->GetModel(), "no model for SdrObject?" ); @@ -459,7 +516,11 @@ void SvxShape::Create( SdrObject* pNewObj, SvxDrawPage* /*pNewPage*/ ) throw() mpObj.reset( pNewObj ); - Init(); + OSL_ENSURE( !mbIsMultiPropertyCall, "SvxShape::Create: hmm?" ); + // this was previously set in impl_initFromSdrObject, but I think it was superfluous + // (it definitely was in the other context where it was called, but I strongly suppose + // it was also superfluous when called from here) + impl_initFromSdrObject(); ObtainSettingsFromPropertySet( *mpPropSet ); @@ -572,7 +633,7 @@ void SvxShape::ForceMetricTo100th_mm(Pair& rPoint) const throw() } //---------------------------------------------------------------------- -void SvxShape::ObtainSettingsFromPropertySet(const SvxItemPropertySet& rPropSet) throw() +void SvxShape::ObtainSettingsFromPropertySet(const SvxItemPropertySet& rPropSet) { DBG_TESTSOLARMUTEX(); if(mpObj.is() && rPropSet.AreThereOwnUsrAnys() && mpModel) @@ -973,25 +1034,9 @@ Reference< uno::XInterface > SvxShape_NewInstance() //---------------------------------------------------------------------- -/** called from SdrObject::SendUserCall - Currently only called for SDRUSERCALL_CHILD_CHGATTR -*/ -void SvxShape::onUserCall(SdrUserCallType eUserCall, const Rectangle& ) +void SvxShape::onUserCall(SdrUserCallType /*_eUserCall*/, const Rectangle& /*_rNewBoundRect*/ ) { - switch( eUserCall ) - { - case SDRUSERCALL_CHILD_CHGATTR: - { - beans::PropertyChangeEvent aEvent; - aEvent.Further = sal_False; - aEvent.PropertyHandle = 0; - aEvent.Source = static_cast< ::cppu::OWeakObject* >( this ); - maDisposeListeners.notifyEach( &beans::XPropertyChangeListener::propertyChange, aEvent ); - } - break; - default: - break; - } + // obsolete, not called anymore } //---------------------------------------------------------------------- @@ -1043,9 +1088,7 @@ void SvxShape::Notify( SfxBroadcaster&, const SfxHint& rHint ) throw() { if( !HasSdrObjectOwnership() ) mpObj.reset( NULL ); - /*mpImpl->mbHasSdrObjectOwnerhship = false; - mpObj.reset( NULL );*/ - if(!mbDisposing) + if ( !mpImpl->mbDisposing ) dispose(); } } @@ -1287,33 +1330,50 @@ void SAL_CALL SvxShape::dispose() throw(uno::RuntimeException) { OGuard aGuard( Application::GetSolarMutex() ); - if( mbDisposing ) + if( mpImpl->mbDisposing ) return; // caught a recursion - mbDisposing = true; + mpImpl->mbDisposing = true; lang::EventObject aEvt; aEvt.Source = *(OWeakAggObject*) this; - maDisposeListeners.disposeAndClear(aEvt); + mpImpl->maDisposeListeners.disposeAndClear(aEvt); + mpImpl->maPropertyNotifier.disposing(); - if(mpObj.is() && mpObj->IsInserted() && mpObj->GetPage() ) + if ( mpObj.is() ) { - SdrPage* pPage = mpObj->GetPage(); - // SdrObject aus der Page loeschen - sal_uInt32 nCount = pPage->GetObjCount(); - for( sal_uInt32 nNum = 0; nNum < nCount; nNum++ ) + bool bFreeSdrObject = false; + + if ( mpObj->IsInserted() && mpObj->GetPage() ) { - if(pPage->GetObj(nNum) == mpObj.get()) + OSL_ENSURE( HasSdrObjectOwnership(), "SvxShape::dispose: is the below code correct?" ); + // normally, we are allowed to free the SdrObject only if we have its ownership. + // Why isn't this checked here? + + SdrPage* pPage = mpObj->GetPage(); + // SdrObject aus der Page loeschen + sal_uInt32 nCount = pPage->GetObjCount(); + for ( sal_uInt32 nNum = 0; nNum < nCount; ++nNum ) { - OSL_VERIFY( pPage->RemoveObject(nNum) == mpObj.get() ); - // in case we have the ownership of the SdrObject, a Free - // would do nothing. So ensure the ownership is reset. - mpImpl->mbHasSdrObjectOwnership = false; - SdrObject* pObject = mpObj.get(); - SdrObject::Free( pObject ); - break; + if ( pPage->GetObj( nNum ) == mpObj.get() ) + { + OSL_VERIFY( pPage->RemoveObject( nNum ) == mpObj.get() ); + bFreeSdrObject = true; + break; + } } } + + mpObj->setUnoShape( NULL, SdrObject::GrantXShapeAccess() ); + + if ( bFreeSdrObject ) + { + // in case we have the ownership of the SdrObject, a Free + // would do nothing. So ensure the ownership is reset. + mpImpl->mbHasSdrObjectOwnership = false; + SdrObject* pObject = mpObj.get(); + SdrObject::Free( pObject ); + } } if( mpModel ) @@ -1328,14 +1388,14 @@ void SAL_CALL SvxShape::dispose() throw(uno::RuntimeException) void SAL_CALL SvxShape::addEventListener( const Reference< lang::XEventListener >& xListener ) throw(uno::RuntimeException) { - maDisposeListeners.addInterface(xListener); + mpImpl->maDisposeListeners.addInterface(xListener); } //---------------------------------------------------------------------- void SAL_CALL SvxShape::removeEventListener( const Reference< lang::XEventListener >& aListener ) throw(uno::RuntimeException) { - maDisposeListeners.removeInterface(aListener); + mpImpl->maDisposeListeners.removeInterface(aListener); } // XPropertySet @@ -1363,22 +1423,33 @@ Reference< beans::XPropertySetInfo > SAL_CALL //---------------------------------------------------------------------- -void SAL_CALL SvxShape::addPropertyChangeListener( const OUString& , const Reference< beans::XPropertyChangeListener >& xListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL SvxShape::addPropertyChangeListener( const OUString& _propertyName, const Reference< beans::XPropertyChangeListener >& _listener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard( maMutex ); + mpImpl->maPropertyNotifier.addPropertyChangeListener( _propertyName, _listener ); +} + +//---------------------------------------------------------------------- + +void SAL_CALL SvxShape::removePropertyChangeListener( const OUString& _propertyName, const Reference< beans::XPropertyChangeListener >& _listener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) { - maDisposeListeners.addInterface(xListener); + ::osl::MutexGuard aGuard( maMutex ); + mpImpl->maPropertyNotifier.removePropertyChangeListener( _propertyName, _listener ); } //---------------------------------------------------------------------- -void SAL_CALL SvxShape::removePropertyChangeListener( const OUString& , const Reference< beans::XPropertyChangeListener >& xListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL SvxShape::addVetoableChangeListener( const OUString& , const Reference< beans::XVetoableChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) { - maDisposeListeners.removeInterface(xListener); + OSL_ENSURE( false, "SvxShape::addVetoableChangeListener: don't have any vetoable properties, so why ...?" ); } //---------------------------------------------------------------------- -void SAL_CALL SvxShape::addVetoableChangeListener( const OUString& , const Reference< beans::XVetoableChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {} -void SAL_CALL SvxShape::removeVetoableChangeListener( const OUString& , const Reference< beans::XVetoableChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {} +void SAL_CALL SvxShape::removeVetoableChangeListener( const OUString& , const Reference< beans::XVetoableChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + OSL_ENSURE( false, "SvxShape::removeVetoableChangeListener: don't have any vetoable properties, so why ...?" ); +} //---------------------------------------------------------------------- @@ -1905,7 +1976,7 @@ void SAL_CALL SvxShape::_setPropertyValue( const OUString& rPropertyName, const uno::Any SAL_CALL SvxShape::getPropertyValue( const OUString& PropertyName ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) { - if( mpImpl && mpImpl->mpMaster ) + if ( mpImpl->mpMaster ) return mpImpl->mpMaster->getPropertyValue( PropertyName ); else return _getPropertyValue( PropertyName ); @@ -4187,7 +4258,7 @@ SvxShapeText::~SvxShapeText() throw () "svx::SvxShapeText::~SvxShapeText(), text shape with living text ranges destroyed!"); } -void SvxShapeText::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage ) throw () +void SvxShapeText::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage ) { if( pNewObj && (NULL == GetEditSource())) SetEditSource( new SvxTextEditSource( pNewObj, 0, static_cast< uno::XWeak* >(this) ) ); diff --git a/svx/source/unoedit/unotext.cxx b/svx/source/unoedit/unotext.cxx index 06c7b5ba55ae..daa7744bb8c8 100644 --- a/svx/source/unoedit/unotext.cxx +++ b/svx/source/unoedit/unotext.cxx @@ -2340,7 +2340,7 @@ const uno::Sequence< sal_Int8 > & SvxUnoTextBase::getUnoTunnelId() throw() return *pSeq; } -SvxUnoTextBase* SvxUnoTextBase::getImplementation( uno::Reference< uno::XInterface > xInt ) throw() +SvxUnoTextBase* SvxUnoTextBase::getImplementation( const uno::Reference< uno::XInterface >& xInt ) { uno::Reference< lang::XUnoTunnel > xUT( xInt, uno::UNO_QUERY ); if( xUT.is() ) @@ -2435,7 +2435,7 @@ uno::Sequence< sal_Int8 > SAL_CALL SvxUnoText::getImplementationId( ) throw( un return aId; } -SvxUnoText* SvxUnoText::getImplementation( uno::Reference< uno::XInterface > xInt ) throw() +SvxUnoText* SvxUnoText::getImplementation( const uno::Reference< uno::XInterface >& xInt ) { uno::Reference< lang::XUnoTunnel > xUT( xInt, uno::UNO_QUERY ); if( xUT.is() ) diff --git a/svx/util/hidother.src b/svx/util/hidother.src index 9da8c59bcd63..86c0edea64d3 100644 --- a/svx/util/hidother.src +++ b/svx/util/hidother.src @@ -58,109 +58,6 @@ hidspecial HID_TPCOLOR_CMYK_2 { HelpID = HID_TPCOLOR_CMYK_2; }; hidspecial HID_TPCOLOR_CMYK_3 { HelpID = HID_TPCOLOR_CMYK_3; }; hidspecial HID_REDLINING_FILTER_CB_ACTION { HelpID = HID_REDLINING_FILTER_CB_ACTION; }; -hidspecial HID_PROP_GROUPBOX { HelpID = HID_PROP_GROUPBOX; }; -hidspecial HID_PROP_CONTROLSOURCE { HelpID = HID_PROP_CONTROLSOURCE; }; -hidspecial HID_PROP_NAME { HelpID = HID_PROP_NAME; }; -hidspecial HID_PROP_TABINDEX { HelpID = HID_PROP_TABINDEX; }; -hidspecial HID_PROP_MASTERFIELDS { HelpID = HID_PROP_MASTERFIELDS; }; -hidspecial HID_PROP_SLAVEFIELDS { HelpID = HID_PROP_SLAVEFIELDS; }; -hidspecial HID_PROP_DATASOURCE { HelpID = HID_PROP_DATASOURCE; }; -hidspecial HID_PROP_CURSORSOURCE { HelpID = HID_PROP_CURSORSOURCE; }; -hidspecial HID_PROP_CURSORSOURCETYPE { HelpID = HID_PROP_CURSORSOURCETYPE; }; -hidspecial HID_PROP_ESCAPE_PROCESSING { HelpID = HID_PROP_ESCAPE_PROCESSING; }; -hidspecial HID_PROP_IMAGE_ALIGN { HelpID = HID_PROP_IMAGE_ALIGN; }; -hidspecial HID_PROP_CURSORTYPE { HelpID = HID_PROP_CURSORTYPE; }; -hidspecial HID_PROP_READONLY { HelpID = HID_PROP_READONLY; }; -hidspecial HID_PROP_DATAENTRY { HelpID = HID_PROP_DATAENTRY; }; -hidspecial HID_PROP_NAVIGATION { HelpID = HID_PROP_NAVIGATION; }; -hidspecial HID_PROP_CYCLE { HelpID = HID_PROP_CYCLE; }; -hidspecial HID_PROP_ALLOW_ADDITIONS { HelpID = HID_PROP_ALLOW_ADDITIONS ; }; -hidspecial HID_PROP_ALLOW_EDITS { HelpID = HID_PROP_ALLOW_EDITS ; }; -hidspecial HID_PROP_ALLOW_DELETIONS { HelpID = HID_PROP_ALLOW_DELETIONS ; }; -hidspecial HID_PROP_DIRTY { HelpID = HID_PROP_DIRTY; }; -hidspecial HID_PROP_OLDVALUE { HelpID = HID_PROP_OLDVALUE; }; -hidspecial HID_PROP_LOCKED { HelpID = HID_PROP_LOCKED; }; -hidspecial HID_PROP_FORMATKEY { HelpID = HID_PROP_FORMATKEY ; }; -hidspecial HID_PROP_REQUIRED { HelpID = HID_PROP_REQUIRED; }; -hidspecial HID_PROP_SCALE { HelpID = HID_PROP_SCALE; }; -hidspecial HID_PROP_SIZE { HelpID = HID_PROP_SIZE; }; -hidspecial HID_PROP_UNIQUE { HelpID = HID_PROP_UNIQUE; }; -hidspecial HID_PROP_CLASSID { HelpID = HID_PROP_CLASSID; }; -hidspecial HID_PROP_LEFT { HelpID = HID_PROP_LEFT; }; -hidspecial HID_PROP_RIGHT { HelpID = HID_PROP_RIGHT; }; -hidspecial HID_PROP_HEIGHT { HelpID = HID_PROP_HEIGHT; }; -hidspecial HID_PROP_WIDTH { HelpID = HID_PROP_WIDTH; }; -hidspecial HID_PROP_BOUNDCOLUMN { HelpID = HID_PROP_BOUNDCOLUMN; }; -hidspecial HID_PROP_LISTSOURCETYPE { HelpID = HID_PROP_LISTSOURCETYPE; }; -hidspecial HID_PROP_LISTSOURCE { HelpID = HID_PROP_LISTSOURCE; }; -hidspecial HID_PROP_LISTINDEX { HelpID = HID_PROP_LISTINDEX; }; -hidspecial HID_PROP_TEXT { HelpID = HID_PROP_TEXT; }; -hidspecial HID_PROP_LABEL { HelpID = HID_PROP_LABEL; }; -hidspecial HID_PROP_STRINGITEMLIST { HelpID = HID_PROP_STRINGITEMLIST; }; -hidspecial HID_PROP_SEARCHING { HelpID = HID_PROP_SEARCHING; }; -hidspecial HID_PROP_FONT { HelpID = HID_PROP_FONT; }; -hidspecial HID_PROP_ROWHEIGHT { HelpID = HID_PROP_ROWHEIGHT; }; -hidspecial HID_PROP_BACKGROUNDCOLOR { HelpID = HID_PROP_BACKGROUNDCOLOR ; }; -hidspecial HID_PROP_FILLCOLOR { HelpID = HID_PROP_FILLCOLOR; }; -hidspecial HID_PROP_TEXTCOLOR { HelpID = HID_PROP_TEXTCOLOR; }; -hidspecial HID_PROP_LINECOLOR { HelpID = HID_PROP_LINECOLOR; }; -hidspecial HID_PROP_BORDER { HelpID = HID_PROP_BORDER; }; -hidspecial HID_PROP_ALIGN { HelpID = HID_PROP_ALIGN; }; -hidspecial HID_PROP_DROPDOWN { HelpID = HID_PROP_DROPDOWN; }; -hidspecial HID_PROP_MULTILINE { HelpID = HID_PROP_MULTILINE; }; -hidspecial HID_PROP_HSCROLL { HelpID = HID_PROP_HSCROLL; }; -hidspecial HID_PROP_VSCROLL { HelpID = HID_PROP_VSCROLL; }; -hidspecial HID_PROP_TABSTOP { HelpID = HID_PROP_TABSTOP; }; -hidspecial HID_PROP_REFVALUE { HelpID = HID_PROP_REFVALUE; }; -hidspecial HID_PROP_BUTTONTYPE { HelpID = HID_PROP_BUTTONTYPE; }; -hidspecial HID_PROP_SUBMIT_ACTION { HelpID = HID_PROP_SUBMIT_ACTION; }; -hidspecial HID_PROP_SUBMIT_METHOD { HelpID = HID_PROP_SUBMIT_METHOD; }; -hidspecial HID_PROP_SUBMIT_ENCODING { HelpID = HID_PROP_SUBMIT_ENCODING; }; -hidspecial HID_PROP_DEFAULTVALUE { HelpID = HID_PROP_DEFAULTVALUE; }; -hidspecial HID_PROP_SUBMIT_TARGET { HelpID = HID_PROP_SUBMIT_TARGET; }; -hidspecial HID_PROP_DEFAULT_CHECKED { HelpID = HID_PROP_DEFAULT_CHECKED; }; -hidspecial HID_PROP_IMAGE_URL { HelpID = HID_PROP_IMAGE_URL; }; -hidspecial HID_PROP_DEFAULT_SELECT_SEQ { HelpID = HID_PROP_DEFAULT_SELECT_SEQ; }; -hidspecial HID_PROP_MULTISELECTION { HelpID = HID_PROP_MULTISELECTION; }; - -hidspecial HID_PROP_DATE { HelpID = HID_PROP_DATE; }; -hidspecial HID_PROP_DATEMIN { HelpID = HID_PROP_DATEMIN; }; -hidspecial HID_PROP_DATEMAX { HelpID = HID_PROP_DATEMAX; }; -hidspecial HID_PROP_DATEFORMAT { HelpID = HID_PROP_DATEFORMAT; }; -hidspecial HID_PROP_TIME { HelpID = HID_PROP_TIME; }; -hidspecial HID_PROP_TIMEMIN { HelpID = HID_PROP_TIMEMIN; }; -hidspecial HID_PROP_TIMEMAX { HelpID = HID_PROP_TIMEMAX; }; -hidspecial HID_PROP_TIMEFORMAT { HelpID = HID_PROP_TIMEFORMAT; }; -hidspecial HID_PROP_VALUEMIN { HelpID = HID_PROP_VALUEMIN; }; -hidspecial HID_PROP_VALUEMAX { HelpID = HID_PROP_VALUEMAX; }; -hidspecial HID_PROP_VALUESTEP { HelpID = HID_PROP_VALUESTEP; }; -hidspecial HID_PROP_CURRENCYSYMBOL { HelpID = HID_PROP_CURRENCYSYMBOL; }; -hidspecial HID_PROP_EDITMASK { HelpID = HID_PROP_EDITMASK; }; -hidspecial HID_PROP_LITERALMASK { HelpID = HID_PROP_LITERALMASK; }; -hidspecial HID_PROP_ENABLED { HelpID = HID_PROP_ENABLED; }; -hidspecial HID_PROP_AUTOCOMPLETE { HelpID = HID_PROP_AUTOCOMPLETE; }; -hidspecial HID_PROP_LINECOUNT { HelpID = HID_PROP_LINECOUNT; }; -hidspecial HID_PROP_MAXTEXTLEN { HelpID = HID_PROP_MAXTEXTLEN; }; -hidspecial HID_PROP_SPIN { HelpID = HID_PROP_SPIN; }; -hidspecial HID_PROP_STRICTFORMAT { HelpID = HID_PROP_STRICTFORMAT; }; -hidspecial HID_PROP_SHOWTHOUSANDSEP { HelpID = HID_PROP_SHOWTHOUSANDSEP; }; -hidspecial HID_PROP_TARGET_URL { HelpID = HID_PROP_TARGET_URL; }; -hidspecial HID_PROP_TARGET_FRAME { HelpID = HID_PROP_TARGET_FRAME; }; -hidspecial HID_PROP_TAG { HelpID = HID_PROP_TAG; }; -hidspecial HID_PROP_ECHO_CHAR { HelpID = HID_PROP_ECHO_CHAR; }; -hidspecial HID_PROP_EMPTY_IS_NULL { HelpID = HID_PROP_EMPTY_IS_NULL; }; -hidspecial HID_PROP_DECIMAL_ACCURACY { HelpID = HID_PROP_DECIMAL_ACCURACY; }; -hidspecial HID_PROP_DEFAULT_BUTTON { HelpID = HID_PROP_DEFAULT_BUTTON; }; -hidspecial HID_PROP_HIDDEN_VALUE { HelpID = HID_PROP_HIDDEN_VALUE; }; -hidspecial HID_PROP_TRISTATE { HelpID =HID_PROP_TRISTATE; }; -hidspecial HID_PROP_NAVIGATIONBAR { HelpID =HID_PROP_NAVIGATIONBAR; }; -hidspecial HID_PROP_FILTER_CRITERIA { HelpID =HID_PROP_FILTER_CRITERIA; }; -hidspecial HID_PROP_SORT_CRITERIA { HelpID =HID_PROP_SORT_CRITERIA; }; -hidspecial HID_PROP_DEFAULT_LONG_VALUE { HelpID =HID_PROP_DEFAULT_LONG_VALUE; }; -hidspecial HID_PROP_DEFAULT_TIME { HelpID =HID_PROP_DEFAULT_TIME; }; -hidspecial HID_PROP_DEFAULT_DATE { HelpID =HID_PROP_DEFAULT_DATE; }; -hidspecial HID_PROP_HELPTEXT { HelpID = HID_PROP_HELPTEXT ;}; - hidspecial HID_REDLINING_DLG { HelpID = HID_REDLINING_DLG; }; hidspecial HID_REDLINING_EDIT { HelpID = HID_REDLINING_EDIT; }; hidspecial HID_REDLINING_PREV { HelpID = HID_REDLINING_PREV; }; @@ -173,7 +70,6 @@ hidspecial HID_FIELD_SEL { HelpID =HID_FIELD_SEL hidspecial HID_FIELD_SEL_WIN { HelpID =HID_FIELD_SEL_WIN ;}; hidspecial HID_FILTER_NAVIGATOR { HelpID =HID_FILTER_NAVIGATOR ;}; hidspecial HID_FILTER_NAVIGATOR_WIN { HelpID =HID_FILTER_NAVIGATOR_WIN ;}; -hidspecial HID_PROP_PRINTABLE { HelpID =HID_PROP_PRINTABLE ;}; hidspecial HID_FM_PROPDLG_TABCTR { HelpID =HID_FM_PROPDLG_TABCTR ;}; hidspecial HID_FM_PROPDLG_TAB_GENERAL { HelpID =HID_FM_PROPDLG_TAB_GENERAL;}; @@ -185,9 +81,6 @@ hidspecial HID_VALUESET_BULLET { HelpID = HID_VALUESET_BULLET ;}; hidspecial HID_VALUESET_NUM { HelpID = HID_VALUESET_NUM ;}; hidspecial HID_VALUESET_NUMBMP { HelpID = HID_VALUESET_NUMBMP ;}; -hidspecial HID_PROP_HELPURL { HelpID = HID_PROP_HELPURL ;}; -hidspecial HID_PROP_RECORDMARKER { HelpID = HID_PROP_RECORDMARKER ;}; - hidspecial HID_OPTPATH_HEADERBAR { HelpId = HID_OPTPATH_HEADERBAR ;}; hidspecial HID_OPTCOOKIES_HEADERBAR { HelpId = HID_OPTCOOKIES_HEADERBAR ;}; @@ -200,11 +93,6 @@ hidspecial HID_TABORDER_CONTROLS { HelpId = HID_TABORDER_CONTROLS hidspecial HID_POPUP_LINEEND { HelpId = HID_POPUP_LINEEND ;}; hidspecial HID_POPUP_LINEEND_CTRL { HelpId = HID_POPUP_LINEEND_CTRL ;}; -hidspecial HID_PROP_EFFECTIVEMIN { HelpId = HID_PROP_EFFECTIVEMIN ;}; -hidspecial HID_PROP_EFFECTIVEMAX { HelpId = HID_PROP_EFFECTIVEMAX ;}; -hidspecial HID_PROP_EFFECTIVEDEFAULT { HelpId = HID_PROP_EFFECTIVEDEFAULT ;}; -hidspecial HID_PROP_CONTROLLABEL { HelpId = HID_PROP_CONTROLLABEL ;}; - hidspecial HID_GRID_TRAVEL_FIRST { HelpID = HID_GRID_TRAVEL_FIRST ;}; hidspecial HID_GRID_TRAVEL_PREV { HelpID = HID_GRID_TRAVEL_PREV ;}; hidspecial HID_GRID_TRAVEL_NEXT { HelpID = HID_GRID_TRAVEL_NEXT ;}; @@ -224,9 +112,6 @@ hidspecial HID_HYPERDLG_INET_PATH { HelpID = HID_HYPERDLG_INET_PATH ;} hidspecial HID_HYPERDLG_MAIL_PATH { HelpID = HID_HYPERDLG_MAIL_PATH ;}; hidspecial HID_HYPERDLG_DOC_PATH { HelpID = HID_HYPERDLG_DOC_PATH ;}; -hidspecial HID_PROP_FILTERPROPOSAL { HelpID = HID_PROP_FILTERPROPOSAL ;}; -hidspecial HID_PROP_CURRSYM_POSITION { HelpID = HID_PROP_CURRSYM_POSITION ;}; - //HID_AUTOCORR_HELP_START #define HID_AUTOCORR_HELP_WORD HID_AUTOCORR_HELP_START+0 #define HID_AUTOCORR_HELP_SENT HID_AUTOCORR_HELP_START+1 diff --git a/xmloff/source/chart/SchXMLCalculationSettingsContext.cxx b/xmloff/source/chart/SchXMLCalculationSettingsContext.cxx new file mode 100755 index 000000000000..4c5cad798b78 --- /dev/null +++ b/xmloff/source/chart/SchXMLCalculationSettingsContext.cxx @@ -0,0 +1,89 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: SchXMLCalculationSettingsContext.cxx,v $ + * $Revision: 1.8 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_xmloff.hxx" +#include <SchXMLCalculationSettingsContext.hxx> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/util/DateTime.hpp> +#include <xmloff/xmlimp.hxx> +#include <xmloff/nmspmap.hxx> +#include "xmlnmspe.hxx" +#include <xmloff/xmltoken.hxx> +#include <xmloff/xmluconv.hxx> + + +using ::rtl::OUString; +using ::rtl::OUStringBuffer; + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star; +using namespace ::xmloff::token; + +SchXMLCalculationSettingsContext::SchXMLCalculationSettingsContext( SvXMLImport& rImport, + sal_uInt16 p_nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList >& xAttrList ) +: SvXMLImportContext ( rImport, p_nPrefix, rLocalName ) +{ + const SvXMLNamespaceMap& rMap = GetImport().GetNamespaceMap(); + const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + const rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); + rtl::OUString aLocalName; + const sal_uInt16 nPrefix = rMap.GetKeyByAttrName(sAttrName, &aLocalName ); + if ( nPrefix == XML_NAMESPACE_TABLE && IsXMLToken( aLocalName, XML_DATE_VALUE ) ) + { + util::DateTime aNullDate; + const rtl::OUString sValue = xAttrList->getValueByIndex( i ); + GetImport().GetMM100UnitConverter().convertDateTime(aNullDate, sValue); + m_aNullDate <<= aNullDate; + } + } +} +SvXMLImportContext* SchXMLCalculationSettingsContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ) +{ + return new SchXMLCalculationSettingsContext(GetImport(),nPrefix,rLocalName,xAttrList); +} + +void SchXMLCalculationSettingsContext::EndElement() +{ + if ( m_aNullDate.hasValue() ) + { + Reference < XPropertySet > xPropSet ( GetImport().GetModel(), UNO_QUERY ); + ::rtl::OUString sNullDate( RTL_CONSTASCII_USTRINGPARAM ( "NullDate" ) ); + xPropSet->setPropertyValue ( sNullDate, m_aNullDate ); + } +} diff --git a/xmloff/source/chart/SchXMLCalculationSettingsContext.hxx b/xmloff/source/chart/SchXMLCalculationSettingsContext.hxx new file mode 100755 index 000000000000..8effa5696ed8 --- /dev/null +++ b/xmloff/source/chart/SchXMLCalculationSettingsContext.hxx @@ -0,0 +1,54 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: XMLCalculationSettingsContext.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _XMLOFF_SCHXMLCALCULATIONSETTINGSCONTEXT_HXX +#define _XMLOFF_SCHXMLCALCULATIONSETTINGSCONTEXT_HXX + +#include <xmloff/xmlictxt.hxx> + +class SchXMLCalculationSettingsContext : public SvXMLImportContext +{ + com::sun::star::uno::Any m_aNullDate; +public: + SchXMLCalculationSettingsContext( SvXMLImport& rImport, + sal_uInt16 nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList >& xAttrList ); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ); + + virtual void EndElement(); +}; + + +#endif diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx index 25b9a2b86d1a..46dd7e3da973 100644 --- a/xmloff/source/chart/SchXMLExport.cxx +++ b/xmloff/source/chart/SchXMLExport.cxx @@ -80,6 +80,7 @@ #include <com/sun/star/chart/ChartSeriesAddress.hpp> #include <com/sun/star/chart/X3DDisplay.hpp> #include <com/sun/star/chart/XStatisticDisplay.hpp> +#include <com/sun/star/chart/XSecondAxisTitleSupplier.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/chart2/XDiagram.hpp> @@ -102,7 +103,8 @@ #include <com/sun/star/drawing/XShapes.hpp> #include <com/sun/star/embed/Aspects.hpp> #include <com/sun/star/embed/XVisualObject.hpp> -#include <com/sun/star/chart/XSecondAxisTitleSupplier.hpp> +#include <com/sun/star/container/XChild.hpp> + #include "MultiPropertySetHandler.hxx" #include "PropertyMap.hxx" @@ -1023,6 +1025,7 @@ void SchXMLExportHelper::parseDocument( Reference< chart::XChartDocument >& rCha sal_Bool bHasMainTitle = sal_False; sal_Bool bHasSubTitle = sal_False; sal_Bool bHasLegend = sal_False; + util::DateTime aNullDate(0,0,0,0,30,12,1899); std::vector< XMLPropertyState > aPropertyStates; @@ -1040,11 +1043,39 @@ void SchXMLExportHelper::parseDocument( Reference< chart::XChartDocument >& rCha aAny = xDocPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "HasLegend" ))); aAny >>= bHasLegend; + if ( bIncludeTable ) + { + OUString sNullDate( RTL_CONSTASCII_USTRINGPARAM( "NullDate" )); + aAny = xDocPropSet->getPropertyValue(sNullDate); + if ( !aAny.hasValue() ) + { + Reference<container::XChild> xChild(rChartDoc, uno::UNO_QUERY ); + if ( xChild.is() ) + { + Reference< beans::XPropertySet > xParentDoc( xChild->getParent(),uno::UNO_QUERY); + if ( xParentDoc.is() && xParentDoc->getPropertySetInfo()->hasPropertyByName(sNullDate) ) + aAny = xParentDoc->getPropertyValue(sNullDate); + } + } + + aAny >>= aNullDate; + } } catch( beans::UnknownPropertyException & ) { DBG_WARNING( "Required property not found in ChartDocument" ); } + } // if( xDocPropSet.is()) + + if ( bIncludeTable && (aNullDate.Day != 30 || aNullDate.Month != 12 || aNullDate.Year != 1899 ) ) + { + SvXMLElementExport aSet( mrExport, XML_NAMESPACE_TABLE, XML_CALCULATION_SETTINGS, sal_True, sal_True ); + { + ::rtl::OUStringBuffer sBuffer; + SvXMLUnitConverter::convertDateTime(sBuffer,aNullDate); + mrExport.AddAttribute( XML_NAMESPACE_TABLE,XML_DATE_VALUE,sBuffer.makeStringAndClear()); + SvXMLElementExport aNull( mrExport, XML_NAMESPACE_TABLE, XML_NULL_DATE, sal_True, sal_True ); + } } // chart element diff --git a/xmloff/source/chart/contexts.cxx b/xmloff/source/chart/contexts.cxx index 8b8f2ee6d6f9..e3e3389e18d2 100644 --- a/xmloff/source/chart/contexts.cxx +++ b/xmloff/source/chart/contexts.cxx @@ -36,6 +36,7 @@ #include <xmloff/xmlmetai.hxx> #include <xmloff/xmlstyle.hxx> #include "SchXMLImport.hxx" +#include "SchXMLCalculationSettingsContext.hxx" // #ifndef _XMLOFF_XMLCHARTSTYLECONTEXT_HXX_ // #include "XMLChartStyleContext.hxx" @@ -225,6 +226,12 @@ SvXMLImportContext* SchXMLBodyContext::CreateChildContext( GetImport().GetModel(), xAttrList ); } + else if(nPrefix == XML_NAMESPACE_TABLE && + IsXMLToken( rLocalName, XML_CALCULATION_SETTINGS )) + { + // i99104 handle null date correctly + pContext = new SchXMLCalculationSettingsContext ( GetImport(), nPrefix, rLocalName, xAttrList); + } else { pContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList ); diff --git a/xmloff/source/chart/makefile.mk b/xmloff/source/chart/makefile.mk index 9fa346e8916e..5b47b77702d5 100644 --- a/xmloff/source/chart/makefile.mk +++ b/xmloff/source/chart/makefile.mk @@ -64,6 +64,7 @@ SLOFILES = $(SLO)$/ColorPropertySet.obj \ $(SLO)$/XMLTextOrientationHdl.obj \ $(SLO)$/XMLSymbolTypePropertyHdl.obj \ $(SLO)$/XMLAxisPositionPropertyHdl.obj \ + $(SLO)$/SchXMLCalculationSettingsContext.obj \ $(SLO)$/transporttypes.obj # --- Targets -------------------------------------------------------------- diff --git a/xmloff/source/forms/elementimport.cxx b/xmloff/source/forms/elementimport.cxx index 20e787fc4885..7bdb61ff86fd 100644 --- a/xmloff/source/forms/elementimport.cxx +++ b/xmloff/source/forms/elementimport.cxx @@ -615,8 +615,8 @@ namespace xmloff } else { - static const sal_Char* pValueAttributeName = OAttributeMetaData::getSpecialAttributeName(CCA_VALUE); - static const sal_Char* pCurrentValueAttributeName = OAttributeMetaData::getSpecialAttributeName(CCA_CURRENT_VALUE); + static const sal_Char* pValueAttributeName = OAttributeMetaData::getCommonControlAttributeName(CCA_VALUE); + static const sal_Char* pCurrentValueAttributeName = OAttributeMetaData::getCommonControlAttributeName(CCA_CURRENT_VALUE); static const sal_Char* pMinValueAttributeName = OAttributeMetaData::getSpecialAttributeName(SCA_MIN_VALUE); static const sal_Char* pMaxValueAttributeName = OAttributeMetaData::getSpecialAttributeName(SCA_MAX_VALUE); static const sal_Char* pRepeatDelayAttributeName = OAttributeMetaData::getSpecialAttributeName( SCA_REPEAT_DELAY ); diff --git a/xmloff/source/forms/propertyexport.cxx b/xmloff/source/forms/propertyexport.cxx index de9b63baf4bf..8de379cda368 100644 --- a/xmloff/source/forms/propertyexport.cxx +++ b/xmloff/source/forms/propertyexport.cxx @@ -455,8 +455,10 @@ namespace xmloff exportedProperty(PROPERTY_DATEFORMAT); exportedProperty(PROPERTY_TIMEFORMAT); - // the "VerticalAlign" property should have been exported at the shape, too + // the following properties should have been exported at the shape already: exportedProperty( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VerticalAlign" ) ) ); + exportedProperty( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "WritingMode" ) ) ); + exportedProperty( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ScaleMode" ) ) ); // ditto the TextWritingMode exportedProperty( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "WritingMode" ) ) ); } |