From d8e643124e77f166dc44100e0123747ae1097e3d Mon Sep 17 00:00:00 2001 From: Lionel Elie Mamane Date: Sat, 29 Oct 2011 08:03:28 +0200 Subject: overhaul / enhance / translate / ... comments --- connectivity/inc/connectivity/sqlnode.hxx | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/connectivity/inc/connectivity/sqlnode.hxx b/connectivity/inc/connectivity/sqlnode.hxx index 5b010bc03333..ddb058cbcd7f 100644 --- a/connectivity/inc/connectivity/sqlnode.hxx +++ b/connectivity/inc/connectivity/sqlnode.hxx @@ -333,7 +333,7 @@ namespace connectivity sal_Bool _bIntl = sal_False, sal_Bool _bQuote= sal_True) const; - // quoted und internationalisert + // quoted and internationalised void parseNodeToPredicateStr(::rtl::OUString& rString, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > & xFormatter, @@ -352,14 +352,14 @@ namespace connectivity OSQLParseNode* getByRule(OSQLParseNode::Rule eRule) const; #if OSL_DEBUG_LEVEL > 0 - // shows the ParseTree with tabs and linefeeds + // shows the ParseTree with tabs and linefeeds void showParseTree( ::rtl::OUString& rString ) const; void showParseTree( ::rtl::OUStringBuffer& _inout_rBuf, sal_uInt32 nLevel ) const; #endif SQLNodeType getNodeType() const {return m_eNodeType;}; - // RuleId returns the RuleID of the node's rule (only if IsRule()) + // RuleId returns the RuleID of the node's rule (only if IsRule()) sal_uInt32 getRuleID() const {return m_nNodeID;} /** returns the ID of the rule represented by the node @@ -392,17 +392,17 @@ namespace connectivity // e.q. (a or b) and (c or d) <=> a and c or a and d or b and c or b and d static void disjunctiveNormalForm(OSQLParseNode*& pSearchCondition); - // Simplies logic expressions - // a * a = a - // a + a = a - // a * ( a + b) = a - // a + a * b = a + // Simplifies logic expressions + // a and a = a + // a or a = a + // a and ( a + b) = a + // a or a and b = a static void absorptions(OSQLParseNode*& pSearchCondition); - // erase not nessary braces + // erase unnecessary braces static void eraseBraces(OSQLParseNode*& pSearchCondition); - // makes the logic formula a little more smaller + // makes the logic formula a little smaller static void compress(OSQLParseNode*& pSearchCondition); // return the catalog, schema and tablename form this node // _pTableNode must be a rule of that above or a SQL_TOKEN_NAME @@ -412,7 +412,7 @@ namespace connectivity ::rtl::OUString &_rTable ,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _xMetaData); - // susbtitute all occurrences of :var or [name] into the dynamic parameter ? + // substitute all occurrences of :var or [name] into the dynamic parameter ? // _pNode will be modified if parameters exists static void substituteParameterNames(OSQLParseNode* _pNode); @@ -421,7 +421,7 @@ namespace connectivity static ::rtl::OUString getTableRange(const OSQLParseNode* _pTableRef); protected: - // ParseNodeToStr konkateniert alle Token (leaves) des ParseNodes + // ParseNodeToStr concatenates all Tokens (leaves) of the ParseNodes. void parseNodeToStr(::rtl::OUString& rString, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > & xFormatter, @@ -462,7 +462,7 @@ namespace connectivity return m_aChildren.at(nPos); } - // Utility-Methoden zum Abfragen auf bestimmte Rules, Token oder Punctuation: + // utilities to query for a specific rule, token or punctuation #define SQL_ISRULE(pParseNode, eRule) ((pParseNode)->isRule() && (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::eRule)) #define SQL_ISTOKEN(pParseNode, token) ((pParseNode)->isToken() && (pParseNode)->getTokenID() == SQL_TOKEN_##token) #define SQL_ISPUNCTUATION(pParseNode, aString) ((pParseNode)->getNodeType() == SQL_NODE_PUNCTUATION && !(pParseNode)->getTokenValue().compareToAscii(aString)) -- cgit From fbf27dc44ceb4dbeb7a5b320e8d2f65cd72dd985 Mon Sep 17 00:00:00 2001 From: Lionel Elie Mamane Date: Sat, 29 Oct 2011 09:07:09 +0200 Subject: Reorganise code for more clarity; no behaviour change --- .../source/ui/querydesign/SelectionBrowseBox.cxx | 160 ++++++++++----------- 1 file changed, 79 insertions(+), 81 deletions(-) diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx index 35654a876fba..df55d495eaf2 100644 --- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx +++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx @@ -803,105 +803,103 @@ sal_Bool OSelectionBrowseBox::saveField(const String& _sFieldName,OTableFieldDes // and the function is different to count clearEntryFunctionField(_sFieldName,aSelEntry,_bListAction,nColumnId); } - else + // do we have a aggregate function and only a function? + else if ( SQL_ISRULE(pColumnRef,general_set_fct) ) { - // first check if we have a aggregate function and only a function - if ( SQL_ISRULE(pColumnRef,general_set_fct) ) + String sLocalizedFunctionName; + if ( GetFunctionName(pColumnRef->getChild(0)->getTokenID(),sLocalizedFunctionName) ) { - String sLocalizedFunctionName; - if ( GetFunctionName(pColumnRef->getChild(0)->getTokenID(),sLocalizedFunctionName) ) + String sOldLocalizedFunctionName = aSelEntry->GetFunction(); + aSelEntry->SetFunction(sLocalizedFunctionName); + sal_uInt32 nFunCount = pColumnRef->count() - 1; + sal_Int32 nFunctionType = FKT_AGGREGATE; + sal_Bool bQuote = sal_False; + // may be there exists only one parameter which is a column, fill all information into our fields + if ( nFunCount == 4 && SQL_ISRULE(pColumnRef->getChild(3),column_ref) ) + bError = fillColumnRef( pColumnRef->getChild(3), xConnection, aSelEntry, _bListAction ); + else if ( nFunCount == 3 ) // we have a COUNT(*) here, so take the first table + bError = fillColumnRef( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("*")), ::rtl::OUString(), xMetaData, aSelEntry, _bListAction ); + else { - String sOldLocalizedFunctionName = aSelEntry->GetFunction(); - aSelEntry->SetFunction(sLocalizedFunctionName); - sal_uInt32 nFunCount = pColumnRef->count() - 1; - sal_Int32 nFunctionType = FKT_AGGREGATE; - sal_Bool bQuote = sal_False; - // may be there exists only one parameter which is a column, fill all information into our fields - if ( nFunCount == 4 && SQL_ISRULE(pColumnRef->getChild(3),column_ref) ) - bError = fillColumnRef( pColumnRef->getChild(3), xConnection, aSelEntry, _bListAction ); - else if ( nFunCount == 3 ) // we have a COUNT(*) here, so take the first table - bError = fillColumnRef( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("*")), ::rtl::OUString(), xMetaData, aSelEntry, _bListAction ); - else - { - nFunctionType |= FKT_NUMERIC; - bQuote = sal_True; - aSelEntry->SetDataType(DataType::DOUBLE); - aSelEntry->SetFieldType(TAB_NORMAL_FIELD); - } + nFunctionType |= FKT_NUMERIC; + bQuote = sal_True; + aSelEntry->SetDataType(DataType::DOUBLE); + aSelEntry->SetFieldType(TAB_NORMAL_FIELD); + } - // now parse the parameters - ::rtl::OUString sParameters; - for(sal_uInt32 function = 2; function < nFunCount; ++function) // we only want to parse the parameters of the function - pColumnRef->getChild(function)->parseNodeToStr( sParameters, xConnection, &rParser.getContext(), sal_True, bQuote ); + // now parse the parameters + ::rtl::OUString sParameters; + for(sal_uInt32 function = 2; function < nFunCount; ++function) // we only want to parse the parameters of the function + pColumnRef->getChild(function)->parseNodeToStr( sParameters, xConnection, &rParser.getContext(), sal_True, bQuote ); - aSelEntry->SetFunctionType(nFunctionType); - aSelEntry->SetField(sParameters); - if ( aSelEntry->IsGroupBy() ) - { - sOldLocalizedFunctionName = m_aFunctionStrings.GetToken(m_aFunctionStrings.GetTokenCount()-1); - aSelEntry->SetGroupBy(sal_False); - } - - // append undo action - notifyFunctionFieldChanged(sOldLocalizedFunctionName,sLocalizedFunctionName,_bListAction, nColumnId); + aSelEntry->SetFunctionType(nFunctionType); + aSelEntry->SetField(sParameters); + if ( aSelEntry->IsGroupBy() ) + { + sOldLocalizedFunctionName = m_aFunctionStrings.GetToken(m_aFunctionStrings.GetTokenCount()-1); + aSelEntry->SetGroupBy(sal_False); } - else - OSL_FAIL("Unsupported function inserted!"); + // append undo action + notifyFunctionFieldChanged(sOldLocalizedFunctionName,sLocalizedFunctionName,_bListAction, nColumnId); } else + OSL_FAIL("Unsupported function inserted!"); + + } + else + { + // so we first clear the function field + clearEntryFunctionField(_sFieldName,aSelEntry,_bListAction,nColumnId); + ::rtl::OUString sFunction; + pColumnRef->parseNodeToStr( sFunction, + xConnection, + &rController.getParser().getContext(), + sal_True, + sal_True); // quote is to true because we need quoted elements inside the function + + getDesignView()->fillFunctionInfo(pColumnRef,sFunction,aSelEntry); + + if( SQL_ISRULEOR2(pColumnRef,position_exp,extract_exp) || + SQL_ISRULEOR2(pColumnRef,fold,char_substring_fct) || + SQL_ISRULEOR2(pColumnRef,length_exp,char_value_fct) ) + // a calculation has been found ( can be calc and function ) { - // so we first clear the function field - clearEntryFunctionField(_sFieldName,aSelEntry,_bListAction,nColumnId); - ::rtl::OUString sFunction; - pColumnRef->parseNodeToStr( sFunction, - xConnection, - &rController.getParser().getContext(), - sal_True, - sal_True); // quote is to true because we need quoted elements inside the function - - getDesignView()->fillFunctionInfo(pColumnRef,sFunction,aSelEntry); - - if( SQL_ISRULEOR2(pColumnRef,position_exp,extract_exp) || - SQL_ISRULEOR2(pColumnRef,fold,char_substring_fct) || - SQL_ISRULEOR2(pColumnRef,length_exp,char_value_fct) ) - // a calculation has been found ( can be calc and function ) - { - // now parse the whole statement - sal_uInt32 nFunCount = pColumnRef->count(); - ::rtl::OUString sParameters; - for(sal_uInt32 function = 0; function < nFunCount; ++function) - pColumnRef->getChild(function)->parseNodeToStr( sParameters, xConnection, &rParser.getContext(), sal_True, sal_True ); - - sOldAlias = aSelEntry->GetAlias(); - sal_Int32 nNewFunctionType = aSelEntry->GetFunctionType() | FKT_NUMERIC | FKT_OTHER; - aSelEntry->SetFunctionType(nNewFunctionType); - aSelEntry->SetField(sParameters); - } + // now parse the whole statement + sal_uInt32 nFunCount = pColumnRef->count(); + ::rtl::OUString sParameters; + for(sal_uInt32 function = 0; function < nFunCount; ++function) + pColumnRef->getChild(function)->parseNodeToStr( sParameters, xConnection, &rParser.getContext(), sal_True, sal_True ); + + sOldAlias = aSelEntry->GetAlias(); + sal_Int32 nNewFunctionType = aSelEntry->GetFunctionType() | FKT_NUMERIC | FKT_OTHER; + aSelEntry->SetFunctionType(nNewFunctionType); + aSelEntry->SetField(sParameters); + } + else + { + aSelEntry->SetFieldAlias(sColumnAlias); + if ( SQL_ISRULE(pColumnRef,set_fct_spec) ) + aSelEntry->SetFunctionType(/*FKT_NUMERIC | */FKT_OTHER); else { - aSelEntry->SetFieldAlias(sColumnAlias); - if ( SQL_ISRULE(pColumnRef,set_fct_spec) ) - aSelEntry->SetFunctionType(/*FKT_NUMERIC | */FKT_OTHER); + if ( SQL_ISRULEOR2(pColumnRef,num_value_exp,term) || SQL_ISRULE(pColumnRef,factor) ) + aSelEntry->SetDataType(DataType::DOUBLE); + else if ( SQL_ISRULE(pColumnRef,value_exp) ) + aSelEntry->SetDataType(DataType::TIMESTAMP); else - { - if ( SQL_ISRULEOR2(pColumnRef,num_value_exp,term) || SQL_ISRULE(pColumnRef,factor) ) - aSelEntry->SetDataType(DataType::DOUBLE); - else if ( SQL_ISRULE(pColumnRef,value_exp) ) - aSelEntry->SetDataType(DataType::TIMESTAMP); - else - aSelEntry->SetDataType(DataType::VARCHAR); - aSelEntry->SetFunctionType(FKT_NUMERIC | FKT_OTHER); - } - } + aSelEntry->SetDataType(DataType::VARCHAR); - aSelEntry->SetAlias(::rtl::OUString()); - notifyTableFieldChanged(sOldAlias,aSelEntry->GetAlias(),_bListAction, nColumnId); + aSelEntry->SetFunctionType(FKT_NUMERIC | FKT_OTHER); + } } + aSelEntry->SetAlias(::rtl::OUString()); + notifyTableFieldChanged(sOldAlias,aSelEntry->GetAlias(),_bListAction, nColumnId); } + if ( i > 0 && !InsertField(aSelEntry,BROWSER_INVALIDID,sal_True,sal_False).is() ) // may we have to append more than one field - { // the field could not be isnerted + { // the field could not be inserted String sErrorMessage( ModuleRes( RID_STR_FIELD_DOESNT_EXIST ) ); sErrorMessage.SearchAndReplaceAscii("$name$",aSelEntry->GetField()); OSQLWarningBox( this, sErrorMessage ).Execute(); -- cgit From 2053a71686b3a3266de2ec0199896a120874396d Mon Sep 17 00:00:00 2001 From: Lionel Elie Mamane Date: Sun, 30 Oct 2011 07:02:13 +0100 Subject: 8.5 is not an integer, but an approxnum --- connectivity/source/parse/sqlflex.l | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/connectivity/source/parse/sqlflex.l b/connectivity/source/parse/sqlflex.l index 45485fd1f370..d5166c783ac2 100755 --- a/connectivity/source/parse/sqlflex.l +++ b/connectivity/source/parse/sqlflex.l @@ -435,10 +435,10 @@ ZONE {SQL_NEW_KEYWORD(SQL_TOKEN_ZONE); } [A-Za-z\200-\277\300-\337\340-\357\360-\367\370-\373\374-\375][A-Za-z\200-\277\300-\337\340-\357\360-\367\370-\373\374-\375_0-9]* {return gatherName( SQLyytext);} -([0-9]+) | -([0-9]+"."[0-9]*) | -("."[0-9]*) {SQL_NEW_INTNUM; } +([0-9]+) {SQL_NEW_INTNUM; } +("."[0-9]*) | +([0-9]+"."[0-9]*) | [0-9]+[eE][+-]?[0-9]+ | [0-9]+"."[0-9]*[eE][+-]?[0-9]+ | "."[0-9]*[eE][+-]?[0-9]+ {SQL_NEW_APPROXNUM; } -- cgit From 98b5910149c940a62d155014f61962ceae382911 Mon Sep 17 00:00:00 2001 From: Lionel Elie Mamane Date: Sun, 30 Oct 2011 11:36:24 +0100 Subject: Introduce combined 2&3 test for SQL Token --- connectivity/inc/connectivity/sqlnode.hxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/connectivity/inc/connectivity/sqlnode.hxx b/connectivity/inc/connectivity/sqlnode.hxx index ddb058cbcd7f..69eeaba66bf0 100644 --- a/connectivity/inc/connectivity/sqlnode.hxx +++ b/connectivity/inc/connectivity/sqlnode.hxx @@ -465,6 +465,8 @@ namespace connectivity // utilities to query for a specific rule, token or punctuation #define SQL_ISRULE(pParseNode, eRule) ((pParseNode)->isRule() && (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::eRule)) #define SQL_ISTOKEN(pParseNode, token) ((pParseNode)->isToken() && (pParseNode)->getTokenID() == SQL_TOKEN_##token) + #define SQL_ISTOKENOR2(pParseNode, tok0, tok1) ((pParseNode)->isToken() && ( (pParseNode)->getTokenID() == SQL_TOKEN_##tok0 || (pParseNode)->getTokenID() == SQL_TOKEN_##tok1 )) + #define SQL_ISTOKENOR3(pParseNode, tok0, tok1, tok2) ((pParseNode)->isToken() && ( (pParseNode)->getTokenID() == SQL_TOKEN_##tok0 || (pParseNode)->getTokenID() == SQL_TOKEN_##tok1 || (pParseNode)->getTokenID() == SQL_TOKEN_##tok2 )) #define SQL_ISPUNCTUATION(pParseNode, aString) ((pParseNode)->getNodeType() == SQL_NODE_PUNCTUATION && !(pParseNode)->getTokenValue().compareToAscii(aString)) } -- cgit From 338ea7617f33d975cc35f44030f522ec5d77adfb Mon Sep 17 00:00:00 2001 From: Lionel Elie Mamane Date: Sun, 30 Oct 2011 11:40:22 +0100 Subject: Return proper UNKNOWN_RULE instead of 0 for unknown rule also make unknown rule -1 to better separate it Before, an unknown rule actually went to 0 == OSQLParser::select_statement --- connectivity/inc/connectivity/sqlnode.hxx | 2 +- connectivity/source/parse/sqlbison.y | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/connectivity/inc/connectivity/sqlnode.hxx b/connectivity/inc/connectivity/sqlnode.hxx index 69eeaba66bf0..4fd6714dd2c8 100644 --- a/connectivity/inc/connectivity/sqlnode.hxx +++ b/connectivity/inc/connectivity/sqlnode.hxx @@ -239,7 +239,7 @@ namespace connectivity between_predicate_part_2, cast_spec, rule_count, // last value - UNKNOWN_RULE // ID indicating that a node is no rule with a matching Rule-enum value (see getKnownRuleID) + UNKNOWN_RULE = -1 // ID indicating that a node is no rule with a matching Rule-enum value (see getKnownRuleID) }; // must be ascii encoding for the value diff --git a/connectivity/source/parse/sqlbison.y b/connectivity/source/parse/sqlbison.y index d559c292df63..e83a122b75a5 100755 --- a/connectivity/source/parse/sqlbison.y +++ b/connectivity/source/parse/sqlbison.y @@ -4743,7 +4743,7 @@ sal_uInt32 OSQLParser::StrToRuleID(const ::rtl::OString & rValue) } // Nicht gefunden - return 0; + return OParseNode::UNKNOWN_RULE; } //----------------------------------------------------------------------------- -- cgit From 74816f998b5d947edaba21102d6b0de28016aec7 Mon Sep 17 00:00:00 2001 From: Lionel Elie Mamane Date: Sun, 30 Oct 2011 12:32:08 +0100 Subject: translate comments --- connectivity/source/parse/sqlbison.y | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/connectivity/source/parse/sqlbison.y b/connectivity/source/parse/sqlbison.y index e83a122b75a5..455084b5767a 100755 --- a/connectivity/source/parse/sqlbison.y +++ b/connectivity/source/parse/sqlbison.y @@ -4733,8 +4733,8 @@ OSQLParseNode* OSQLParser::parseTree(::rtl::OUString& rErrorMessage, //----------------------------------------------------------------------------- sal_uInt32 OSQLParser::StrToRuleID(const ::rtl::OString & rValue) { - // In yysvar nach dem angegebenen Namen suchen, den Index zurueckliefern - // (oder 0, wenn nicht gefunden) + // Search for the given name in yysvar and return the index + // (or UNKNOWN_RULE, if not found) static sal_uInt32 nLen = SAL_N_ELEMENTS(yytname); for (sal_uInt32 i = YYTRANSLATE(SQL_TOKEN_INVALIDSYMBOL); i < (nLen-1); i++) { @@ -4742,7 +4742,7 @@ sal_uInt32 OSQLParser::StrToRuleID(const ::rtl::OString & rValue) return i; } - // Nicht gefunden + // Not found return OParseNode::UNKNOWN_RULE; } -- cgit From 70511e6e1596f98cf908938373b6bfc7f6370248 Mon Sep 17 00:00:00 2001 From: Lionel Elie Mamane Date: Sun, 30 Oct 2011 12:33:29 +0100 Subject: Errors in comments --- connectivity/source/parse/sqlbison.y | 2 +- connectivity/source/parse/sqlflex.l | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/connectivity/source/parse/sqlbison.y b/connectivity/source/parse/sqlbison.y index 455084b5767a..8ac72ac7ad65 100755 --- a/connectivity/source/parse/sqlbison.y +++ b/connectivity/source/parse/sqlbison.y @@ -4733,7 +4733,7 @@ OSQLParseNode* OSQLParser::parseTree(::rtl::OUString& rErrorMessage, //----------------------------------------------------------------------------- sal_uInt32 OSQLParser::StrToRuleID(const ::rtl::OString & rValue) { - // Search for the given name in yysvar and return the index + // Search for the given name in yytname and return the index // (or UNKNOWN_RULE, if not found) static sal_uInt32 nLen = SAL_N_ELEMENTS(yytname); for (sal_uInt32 i = YYTRANSLATE(SQL_TOKEN_INVALIDSYMBOL); i < (nLen-1); i++) diff --git a/connectivity/source/parse/sqlflex.l b/connectivity/source/parse/sqlflex.l index d5166c783ac2..d5b2f142bac0 100755 --- a/connectivity/source/parse/sqlflex.l +++ b/connectivity/source/parse/sqlflex.l @@ -598,7 +598,7 @@ sal_Int32 mapEnumToToken(IParseContext::InternationalKeyCode _eKeyCode ) } /* * Read SQL Name literal - * Valid Names or internatioanl keywords: + * Valid Names or international keywords: * As we have international keywords, we test first on them */ sal_Int32 gatherName(const sal_Char* text) -- cgit From 1f805926d825e06c859ad79954c4bc27a4467f85 Mon Sep 17 00:00:00 2001 From: Lionel Elie Mamane Date: Sun, 30 Oct 2011 12:35:22 +0100 Subject: fillFunctionInfo now also guesses the type of non-function call expressions --- dbaccess/source/ui/querydesign/QueryDesignView.cxx | 391 +++++++++++++++++++-- .../source/ui/querydesign/SelectionBrowseBox.cxx | 9 - 2 files changed, 368 insertions(+), 32 deletions(-) diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx index 44c250383c66..2b0fd2ce59e8 100644 --- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx +++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx @@ -3204,40 +3204,385 @@ bool OQueryDesignView::initByParseIterator( ::dbtools::SQLExceptionInfo* _pError } return eErrorCode == eOk; } + +// Utility function for fillFunctionInfo +namespace { + sal_Int32 char_datatype(const::connectivity::OSQLParseNode* pDataType, const unsigned int offset) { + int cnt = pDataType->count() - offset; + if ( cnt < 0 ) + { + OSL_FAIL("internal error in decoding character datatype specification"); + return DataType::VARCHAR; + } + else if ( cnt == 0 ) + { + if ( offset == 0 ) + { + // The datatype is the node itself + if ( SQL_ISTOKENOR2 (pDataType, CHARACTER, CHAR) ) + return DataType::CHAR; + else if ( SQL_ISTOKEN (pDataType, VARCHAR) ) + return DataType::VARCHAR; + else if ( SQL_ISTOKEN (pDataType, CLOB) ) + return DataType::CLOB; + else + { + OSL_FAIL("unknown/unexpected token in decoding character datatype specification"); + return DataType::VARCHAR; + } + } + else + { + // No child left to read! + OSL_FAIL("incomplete datatype in decoding character datatype specification"); + return DataType::VARCHAR; + } + } + + if ( SQL_ISTOKEN(pDataType->getChild(offset), NATIONAL) ) + return char_datatype(pDataType, offset+1); + else if ( SQL_ISTOKENOR3(pDataType->getChild(offset), CHARACTER, CHAR, NCHAR) ) + { + if ( cnt > 2 && SQL_ISTOKEN(pDataType->getChild(offset+1), LARGE) && SQL_ISTOKEN(pDataType->getChild(offset+2), OBJECT) ) + return DataType::CLOB; + else if ( cnt > 1 && SQL_ISTOKEN(pDataType->getChild(offset+1), VARYING) ) + return DataType::VARCHAR; + else + return DataType::CHAR; + } + else if ( SQL_ISTOKEN (pDataType->getChild(offset), VARCHAR) ) + return DataType::VARCHAR; + else if ( SQL_ISTOKENOR2 (pDataType->getChild(offset), CLOB, NCLOB) ) + return DataType::CLOB; + + OSL_FAIL("unrecognised character datatype"); + return DataType::VARCHAR; + } +} + //------------------------------------------------------------------------------ +// Try to guess the type of an expression in simple cases. +// Originally meant to be called only on a function call (hence the misnomer), +// but now tries to do the best it can also in other cases. +// Don't completely rely on fillFunctionInfo, +// it won't look at the function's arguments to find the return type +// (in particular, in the case of general_set_fct, +// the return type is the type of the argument; +// if that is (as is typical) a column reference, +// it is the type of the column). +// TODO: There is similar "guess the expression's type" code in several places: +// SelectionBrowseBox.cxx: OSelectionBrowseBox::saveField +// QueryDesignView.cxx: InstallFields, GetOrderCriteria, GetGroupCriteria +// If possible, they should be factorised into this function +// (which should then be renamed...) + void OQueryDesignView::fillFunctionInfo( const ::connectivity::OSQLParseNode* pNode ,const ::rtl::OUString& sFunctionTerm ,OTableFieldDescRef& aInfo) { - // get the type out of the funtion name + // get the type of the expression, as far as easily possible OQueryController& rController = static_cast(getController()); sal_Int32 nDataType = DataType::DOUBLE; ::rtl::OUString sFieldName = sFunctionTerm; - const OSQLParseNode* pFunctionName; - // Fix fdo#38286 : crash when constant in the query - // TODO : is it possible to have a child or children in the pNode ? - // if not this part could be simplified - if (pNode->count()) - { - pFunctionName = pNode->getChild(0); - } - else - { - pFunctionName = pNode; - } - if ( !SQL_ISPUNCTUATION(pFunctionName,"{") ) - { - if ( SQL_ISRULEOR2(pNode,length_exp,char_value_fct) ) - pFunctionName = pFunctionName->getChild(0); + switch(pNode->getNodeType()) + { + case SQL_NODE_CONCAT: + case SQL_NODE_STRING: + nDataType = DataType::VARCHAR; + break; + case SQL_NODE_INTNUM: + nDataType = DataType::INTEGER; + break; + case SQL_NODE_APPROXNUM: + nDataType = DataType::DOUBLE; + break; + case SQL_NODE_DATE: + case SQL_NODE_ACCESS_DATE: + nDataType = DataType::TIMESTAMP; + break; + case SQL_NODE_COMPARISON: + case SQL_NODE_EQUAL: + case SQL_NODE_LESS: + case SQL_NODE_GREAT: + case SQL_NODE_LESSEQ: + case SQL_NODE_GREATEQ: + case SQL_NODE_NOTEQUAL: + nDataType = DataType::BOOLEAN; + break; + case SQL_NODE_NAME: + case SQL_NODE_LISTRULE: + case SQL_NODE_COMMALISTRULE: + case SQL_NODE_KEYWORD: + case SQL_NODE_AMMSC: //?? + case SQL_NODE_PUNCTUATION: + OSL_FAIL("Unexpected SQL Node Type"); + break; + case SQL_NODE_RULE: + switch(pNode->getKnownRuleID()) + { + case OSQLParseNode::select_statement: + case OSQLParseNode::table_exp: + case OSQLParseNode::table_ref_commalist: + case OSQLParseNode::table_ref: + case OSQLParseNode::catalog_name: + case OSQLParseNode::schema_name: + case OSQLParseNode::table_name: + case OSQLParseNode::opt_column_commalist: + case OSQLParseNode::column_commalist: + case OSQLParseNode::column_ref_commalist: + case OSQLParseNode::column_ref: + case OSQLParseNode::opt_order_by_clause: + case OSQLParseNode::ordering_spec_commalist: + case OSQLParseNode::ordering_spec: + case OSQLParseNode::opt_asc_desc: + case OSQLParseNode::where_clause: + case OSQLParseNode::opt_where_clause: + case OSQLParseNode::opt_escape: + case OSQLParseNode::scalar_exp_commalist: + case OSQLParseNode::scalar_exp: // Seems to never be generated? + case OSQLParseNode::parameter_ref: + case OSQLParseNode::parameter: + case OSQLParseNode::range_variable: + case OSQLParseNode::delete_statement_positioned: + case OSQLParseNode::delete_statement_searched: + case OSQLParseNode::update_statement_positioned: + case OSQLParseNode::update_statement_searched: + case OSQLParseNode::assignment_commalist: + case OSQLParseNode::assignment: + case OSQLParseNode::insert_statement: + case OSQLParseNode::insert_atom_commalist: + case OSQLParseNode::insert_atom: + case OSQLParseNode::from_clause: + case OSQLParseNode::qualified_join: + case OSQLParseNode::cross_union: + case OSQLParseNode::select_sublist: + case OSQLParseNode::join_type: + case OSQLParseNode::named_columns_join: + case OSQLParseNode::joined_table: + case OSQLParseNode::sql_not: + case OSQLParseNode::manipulative_statement: + case OSQLParseNode::value_exp_commalist: + case OSQLParseNode::union_statement: + case OSQLParseNode::outer_join_type: + case OSQLParseNode::selection: + case OSQLParseNode::base_table_def: + case OSQLParseNode::base_table_element_commalist: + case OSQLParseNode::data_type: + case OSQLParseNode::column_def: + case OSQLParseNode::table_node: + case OSQLParseNode::as: // Seems to never be generated? + case OSQLParseNode::op_column_commalist: + case OSQLParseNode::table_primary_as_range_column: + case OSQLParseNode::character_string_type: + OSL_FAIL("Unexpected SQL RuleID"); + break; + case OSQLParseNode::column: + case OSQLParseNode::column_val: + OSL_FAIL("Cannot guess column type"); + break; + case OSQLParseNode::values_or_query_spec: + OSL_FAIL("Cannot guess VALUES type"); + break; + case OSQLParseNode::derived_column: + OSL_FAIL("Cannot guess computed column type"); + break; + case OSQLParseNode::subquery: + OSL_FAIL("Cannot guess subquery return type"); + break; + case OSQLParseNode::search_condition: + case OSQLParseNode::comparison_predicate: + case OSQLParseNode::between_predicate: + case OSQLParseNode::like_predicate: + case OSQLParseNode::test_for_null: + case OSQLParseNode::predicate_check: // Seems to never be generated? + case OSQLParseNode::boolean_term: + case OSQLParseNode::boolean_primary: + case OSQLParseNode::in_predicate: + case OSQLParseNode::existence_test: + case OSQLParseNode::unique_test: + case OSQLParseNode::all_or_any_predicate: + case OSQLParseNode::join_condition: + case OSQLParseNode::boolean_factor: + case OSQLParseNode::boolean_test: + case OSQLParseNode::comparison_predicate_part_2: + case OSQLParseNode::parenthesized_boolean_value_expression: + case OSQLParseNode::other_like_predicate_part_2: + case OSQLParseNode::between_predicate_part_2: + nDataType = DataType::BOOLEAN; + break; + case OSQLParseNode::num_value_exp: + case OSQLParseNode::extract_exp: + case OSQLParseNode::term: + case OSQLParseNode::factor: + // Might by an integer or a float; take the most generic + nDataType = DataType::DOUBLE; + break; + case OSQLParseNode::value_exp_primary: + case OSQLParseNode::value_exp: + case OSQLParseNode::odbc_call_spec: + // Really, we don't know. Let the default. + break; + case OSQLParseNode::position_exp: + case OSQLParseNode::length_exp: + nDataType = DataType::INTEGER; + break; + case OSQLParseNode::char_value_exp: + case OSQLParseNode::char_value_fct: + case OSQLParseNode::fold: + case OSQLParseNode::char_substring_fct: + case OSQLParseNode::char_factor: + case OSQLParseNode::concatenation: + nDataType = DataType::VARCHAR; + break; + case OSQLParseNode::datetime_primary: + nDataType = DataType::TIMESTAMP; + break; + case OSQLParseNode::bit_value_fct: + nDataType = DataType::BINARY; + break; + case OSQLParseNode::general_set_fct: // May depend on argument; ignore that for now + case OSQLParseNode::set_fct_spec: + { + if (pNode->count() == 0) + { + // This is not a function call, no sense to continue with a function return type lookup + OSL_FAIL("Got leaf SQL node where non-leaf expected"); + break; + } + const OSQLParseNode* pFunctionName = pNode->getChild(0); + if ( SQL_ISPUNCTUATION(pFunctionName,"{") ) + { + if ( pNode->count() == 3 ) + return fillFunctionInfo( pNode->getChild(1), sFunctionTerm, aInfo ); + else + OSL_FAIL("ODBC escape not in recognised form"); + break; + } + else + { + if ( SQL_ISRULEOR2(pNode,length_exp,char_value_fct) ) + pFunctionName = pFunctionName->getChild(0); - ::rtl::OUString sFunctionName = pFunctionName->getTokenValue(); - if ( !sFunctionName.getLength() ) - sFunctionName = ::rtl::OStringToOUString(OSQLParser::TokenIDToStr(pFunctionName->getTokenID()),RTL_TEXTENCODING_UTF8); + ::rtl::OUString sFunctionName = pFunctionName->getTokenValue(); + if ( !sFunctionName.getLength() ) + sFunctionName = ::rtl::OStringToOUString(OSQLParser::TokenIDToStr(pFunctionName->getTokenID()),RTL_TEXTENCODING_UTF8); - nDataType = OSQLParser::getFunctionReturnType( - sFunctionName - ,&rController.getParser().getContext()); + nDataType = OSQLParser::getFunctionReturnType( + sFunctionName + ,&rController.getParser().getContext()); + } + break; + } + case OSQLParseNode::odbc_fct_spec: + { + if (pNode->count() != 2) + { + OSL_FAIL("interior of ODBC escape not in recognised shape"); + break; + } + + const OSQLParseNode* const pEscapeType = pNode->getChild(0); + if (SQL_ISTOKEN(pEscapeType, TS)) + nDataType = DataType::TIMESTAMP; + else if (SQL_ISTOKEN(pEscapeType, D)) + nDataType = DataType::DATE; + else if (SQL_ISTOKEN(pEscapeType, T)) + nDataType = DataType::TIME; + else if (SQL_ISTOKEN(pEscapeType, FN)) + return fillFunctionInfo( pNode->getChild(1), sFunctionTerm, aInfo ); + else + OSL_FAIL("Unknown ODBC escape"); + break; + } + case OSQLParseNode::cast_spec: + { + if ( pNode->count() != 6 || !SQL_ISTOKEN(pNode->getChild(3), AS) ) + { + OSL_FAIL("CAST not in recognised shape"); + break; + } + const OSQLParseNode *pCastTarget = pNode->getChild(4); + if ( SQL_ISTOKENOR2(pCastTarget, INTEGER, INT) ) + nDataType = DataType::INTEGER; + else if ( SQL_ISTOKEN(pCastTarget, SMALLINT) ) + nDataType = DataType::SMALLINT; + else if ( SQL_ISTOKEN(pCastTarget, BIGINT) ) + nDataType = DataType::BIGINT; + else if ( SQL_ISTOKEN(pCastTarget, FLOAT) ) + nDataType = DataType::FLOAT; + else if ( SQL_ISTOKEN(pCastTarget, REAL) ) + nDataType = DataType::REAL; + else if ( SQL_ISTOKEN(pCastTarget, DOUBLE) ) + nDataType = DataType::DOUBLE; + else if ( SQL_ISTOKEN(pCastTarget, BOOLEAN) ) + nDataType = DataType::BOOLEAN; + else if ( SQL_ISTOKEN(pCastTarget, DATE) ) + nDataType = DataType::DATE; + else if ( pCastTarget->count() > 0 ) + { + const OSQLParseNode *pDataType = pCastTarget->getChild(0); + while (pDataType->count() > 0) + { + pCastTarget = pDataType; + pDataType = pDataType->getChild(0); + } + if ( SQL_ISTOKEN (pDataType, TIME) ) + nDataType = DataType::TIME; + else if ( SQL_ISTOKEN (pDataType, TIMESTAMP) ) + nDataType = DataType::TIMESTAMP; + else if ( SQL_ISTOKENOR3 (pDataType, CHARACTER, CHAR, NCHAR) ) + nDataType = char_datatype(pCastTarget, 0); + else if ( SQL_ISTOKEN (pDataType, VARCHAR) ) + nDataType = DataType::VARCHAR; + else if ( SQL_ISTOKEN (pDataType, CLOB) ) + nDataType = DataType::CLOB; + else if ( SQL_ISTOKEN (pDataType, NATIONAL) ) + nDataType = char_datatype(pCastTarget, 1); + else if ( SQL_ISTOKEN (pDataType, BINARY) ) + { + if ( pCastTarget->count() > 2 && SQL_ISTOKEN(pCastTarget->getChild(1), LARGE) && SQL_ISTOKEN(pCastTarget->getChild(2), OBJECT) ) + nDataType = DataType::BLOB; + else if ( pCastTarget->count() > 1 && SQL_ISTOKEN(pCastTarget->getChild(1), VARYING) ) + nDataType = DataType::VARBINARY; + else + nDataType = DataType::BINARY; + } + else if ( SQL_ISTOKEN (pDataType, VARBINARY) ) + nDataType = DataType::VARBINARY; + else if ( SQL_ISTOKEN (pDataType, BLOB) ) + nDataType = DataType::BLOB; + else if ( SQL_ISTOKEN (pDataType, NUMERIC) ) + nDataType = DataType::NUMERIC; + else if ( SQL_ISTOKENOR2 (pDataType, DECIMAL, DEC) ) + nDataType = DataType::DECIMAL; + else if ( SQL_ISTOKEN (pDataType, FLOAT) ) + nDataType = DataType::FLOAT; + else if ( SQL_ISTOKEN (pDataType, DOUBLE) ) + nDataType = DataType::DOUBLE; + else if ( SQL_ISTOKEN (pDataType, TIME) ) + nDataType = DataType::TIME; + else if ( SQL_ISTOKEN (pDataType, TIMESTAMP) ) + nDataType = DataType::TIMESTAMP; + else if ( SQL_ISTOKEN (pDataType, INTERVAL) ) + // Not in DataType published constant (because not in JDBC...) + nDataType = DataType::VARCHAR; + else + OSL_FAIL("Failed to decode CAST target"); + } + else + OSL_FAIL("Could not decipher CAST target"); + break; + } + default: + OSL_FAIL("Unknown SQL RuleID"); + break; + } + break; + default: + OSL_FAIL("Unknown SQL Node Type"); + break; } + aInfo->SetDataType(nDataType); aInfo->SetFieldType(TAB_NORMAL_FIELD); aInfo->SetField(sFieldName); diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx index df55d495eaf2..1b2328d8f955 100644 --- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx +++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx @@ -882,16 +882,7 @@ sal_Bool OSelectionBrowseBox::saveField(const String& _sFieldName,OTableFieldDes if ( SQL_ISRULE(pColumnRef,set_fct_spec) ) aSelEntry->SetFunctionType(/*FKT_NUMERIC | */FKT_OTHER); else - { - if ( SQL_ISRULEOR2(pColumnRef,num_value_exp,term) || SQL_ISRULE(pColumnRef,factor) ) - aSelEntry->SetDataType(DataType::DOUBLE); - else if ( SQL_ISRULE(pColumnRef,value_exp) ) - aSelEntry->SetDataType(DataType::TIMESTAMP); - else - aSelEntry->SetDataType(DataType::VARCHAR); - aSelEntry->SetFunctionType(FKT_NUMERIC | FKT_OTHER); - } } aSelEntry->SetAlias(::rtl::OUString()); -- cgit From 2cd03f687f349c6f0352eac72b2dec327d64d800 Mon Sep 17 00:00:00 2001 From: Lionel Elie Mamane Date: Sat, 29 Oct 2011 07:54:41 +0200 Subject: Typo/spelling in comment --- connectivity/inc/connectivity/sqlnode.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connectivity/inc/connectivity/sqlnode.hxx b/connectivity/inc/connectivity/sqlnode.hxx index 4fd6714dd2c8..0abfdb2bbe75 100644 --- a/connectivity/inc/connectivity/sqlnode.hxx +++ b/connectivity/inc/connectivity/sqlnode.hxx @@ -289,7 +289,7 @@ namespace connectivity /** parses the node to a string which can be passed to a driver's connection for execution Any particles of the parse tree which represent application-level features - such - as queries appearing in the FROM part - are subsituted, so that the resulting statement can + as queries appearing in the FROM part - are substituted, so that the resulting statement can be executed at an SDBC-level connection. @param _out_rString -- cgit From be1bc3c80a684e68743a020f64c2e665c11ea635 Mon Sep 17 00:00:00 2001 From: Lionel Elie Mamane Date: Sat, 29 Oct 2011 07:55:06 +0200 Subject: wrong logic in comment --- connectivity/inc/connectivity/sqlnode.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connectivity/inc/connectivity/sqlnode.hxx b/connectivity/inc/connectivity/sqlnode.hxx index 0abfdb2bbe75..932970273bb3 100644 --- a/connectivity/inc/connectivity/sqlnode.hxx +++ b/connectivity/inc/connectivity/sqlnode.hxx @@ -315,7 +315,7 @@ namespace connectivity Currently, there's only one condition how this method can fail: If it contains a nested query which causes a cycle. E.g., consider a statement SELECT * from "foo", - where bar is a query defined as SELECT * FROM "bar", where + where foo is a query defined as SELECT * FROM "bar", where bar is defined as SELECT * FROM "foo". This statement obviously cannot be parsed to an executable statement. -- cgit From 60812ff7b6439c879d1c008db5b09d0417288329 Mon Sep 17 00:00:00 2001 From: Julien Nabet Date: Sun, 30 Oct 2011 12:52:30 +0100 Subject: Fix some typo (verion -> version) --- configure.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index 3b48331e43b1..65b81c124b56 100644 --- a/configure.in +++ b/configure.in @@ -2004,14 +2004,14 @@ if test "$_os" = "Darwin" ; then ;; esac - AC_MSG_CHECKING([that macosx-verion-min-required is coherent with macosx-version-max-allowed]) + AC_MSG_CHECKING([that macosx-version-min-required is coherent with macosx-version-max-allowed]) if test $MAC_OS_X_VERSION_MIN_REQUIRED -gt $MAC_OS_X_VERSION_MAX_ALLOWED ; then AC_MSG_ERROR([the version minimumn required must be inferior or equal to the version maximum allowed]) else AC_MSG_RESULT([ok]) fi - AC_MSG_CHECKING([that macosx-verion-max-allowed is coherent macos-with-sdk]) + AC_MSG_CHECKING([that macosx-version-max-allowed is coherent macos-with-sdk]) if test $MAC_OS_X_VERSION_MAX_ALLOWED -gt $macosx_sdk_value ; then AC_MSG_ERROR([the version maximum allowed cannot be greater thatn the sdk level]) else -- cgit From 14e3351b22789706e2360936433ebca062bed272 Mon Sep 17 00:00:00 2001 From: Julien Nabet Date: Sun, 30 Oct 2011 13:32:11 +0100 Subject: Small fix OParseNode->OSQLParseNode --- connectivity/source/parse/sqlbison.y | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connectivity/source/parse/sqlbison.y b/connectivity/source/parse/sqlbison.y index 8ac72ac7ad65..41da5b07091d 100755 --- a/connectivity/source/parse/sqlbison.y +++ b/connectivity/source/parse/sqlbison.y @@ -4743,7 +4743,7 @@ sal_uInt32 OSQLParser::StrToRuleID(const ::rtl::OString & rValue) } // Not found - return OParseNode::UNKNOWN_RULE; + return OSQLParseNode::UNKNOWN_RULE; } //----------------------------------------------------------------------------- -- cgit From 788283383e93a646a397d9a14847128b354f18bb Mon Sep 17 00:00:00 2001 From: Lionel Elie Mamane Date: Sun, 30 Oct 2011 13:05:17 +0100 Subject: Remove unnecessary variable --- dbaccess/source/ui/querydesign/QueryDesignView.cxx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx index 2b0fd2ce59e8..13ef270fc455 100644 --- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx +++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx @@ -3283,7 +3283,6 @@ void OQueryDesignView::fillFunctionInfo( const ::connectivity::OSQLParseNode* p // get the type of the expression, as far as easily possible OQueryController& rController = static_cast(getController()); sal_Int32 nDataType = DataType::DOUBLE; - ::rtl::OUString sFieldName = sFunctionTerm; switch(pNode->getNodeType()) { case SQL_NODE_CONCAT: @@ -3585,7 +3584,7 @@ void OQueryDesignView::fillFunctionInfo( const ::connectivity::OSQLParseNode* p aInfo->SetDataType(nDataType); aInfo->SetFieldType(TAB_NORMAL_FIELD); - aInfo->SetField(sFieldName); + aInfo->SetField(sFunctionTerm); aInfo->SetTabWindow(NULL); } // ----------------------------------------------------------------------------- -- cgit From eaa8cb8ee384f4edbe77aaa9a533d62064622fbf Mon Sep 17 00:00:00 2001 From: Lionel Elie Mamane Date: Sun, 30 Oct 2011 13:17:52 +0100 Subject: add const --- dbaccess/source/ui/querydesign/QueryDesignView.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx index 13ef270fc455..45bce3e50c2f 100644 --- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx +++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx @@ -2225,8 +2225,8 @@ namespace { if ( pParamRef && pParamRef->getTokenValue().toChar() == '*' ) { - OJoinTableView::OTableWindowMap::iterator aIter = pTabList->begin(); - OJoinTableView::OTableWindowMap::iterator aEnd = pTabList->end(); + OJoinTableView::OTableWindowMap::iterator aIter = pTabList->begin(); + const OJoinTableView::OTableWindowMap::const_iterator aEnd = pTabList->end(); for(;aIter != aEnd;++aIter) { OQueryTableWindow* pTabWin = static_cast(aIter->second); -- cgit From 6efdf794cdd0c979ffead0e5051309f711b23997 Mon Sep 17 00:00:00 2001 From: Lionel Elie Mamane Date: Sun, 30 Oct 2011 13:34:01 +0100 Subject: factorise multiple SQL_ISRULEOR2 implementations into one --- connectivity/inc/connectivity/sqlnode.hxx | 7 ++++++ connectivity/source/parse/sqliterator.cxx | 4 ---- dbaccess/source/ui/querydesign/QueryDesignView.cxx | 26 +++++++++------------- .../source/ui/querydesign/SelectionBrowseBox.cxx | 10 ++------- 4 files changed, 19 insertions(+), 28 deletions(-) diff --git a/connectivity/inc/connectivity/sqlnode.hxx b/connectivity/inc/connectivity/sqlnode.hxx index 932970273bb3..1d8381a9a321 100644 --- a/connectivity/inc/connectivity/sqlnode.hxx +++ b/connectivity/inc/connectivity/sqlnode.hxx @@ -464,6 +464,13 @@ namespace connectivity // utilities to query for a specific rule, token or punctuation #define SQL_ISRULE(pParseNode, eRule) ((pParseNode)->isRule() && (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::eRule)) + #define SQL_ISRULEOR2(pParseNode, e1, e2) ((pParseNode)->isRule() && ( \ + (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::e1) || \ + (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::e2))) + #define SQL_ISRULEOR3(pParseNode, e1, e2, e3) ((pParseNode)->isRule() && ( \ + (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::e1) || \ + (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::e2) || \ + (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::e3))) #define SQL_ISTOKEN(pParseNode, token) ((pParseNode)->isToken() && (pParseNode)->getTokenID() == SQL_TOKEN_##token) #define SQL_ISTOKENOR2(pParseNode, tok0, tok1) ((pParseNode)->isToken() && ( (pParseNode)->getTokenID() == SQL_TOKEN_##tok0 || (pParseNode)->getTokenID() == SQL_TOKEN_##tok1 )) #define SQL_ISTOKENOR3(pParseNode, tok0, tok1, tok2) ((pParseNode)->isToken() && ( (pParseNode)->getTokenID() == SQL_TOKEN_##tok0 || (pParseNode)->getTokenID() == SQL_TOKEN_##tok1 || (pParseNode)->getTokenID() == SQL_TOKEN_##tok2 )) diff --git a/connectivity/source/parse/sqliterator.cxx b/connectivity/source/parse/sqliterator.cxx index 0c3b6a0cd958..325523c9f8e4 100644 --- a/connectivity/source/parse/sqliterator.cxx +++ b/connectivity/source/parse/sqliterator.cxx @@ -51,10 +51,6 @@ #include "diagnose_ex.h" #include -#define SQL_ISRULEOR2(pParseNode, e1,e2) ((pParseNode)->isRule() && (\ - (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::e1) || \ - (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::e2))) - using namespace ::comphelper; using namespace ::connectivity; using namespace ::connectivity::sdbcx; diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx index 45bce3e50c2f..455b343e30fa 100644 --- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx +++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx @@ -76,10 +76,6 @@ using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::container; -#define SQL_ISRULEOR2(pParseNode, e1,e2) ((pParseNode)->isRule() && (\ - (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::e1) || \ - (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::e2))) - // here we define our functions used in the anonymous namespace to get our header file smaller // please look at the book LargeScale C++ to know why namespace @@ -1432,10 +1428,9 @@ namespace _pSelectionBrw->AddCondition(aDragLeft, aCondition, nLevel,bAddOrOnOneLine); } } - else if(SQL_ISRULEOR2(pValueExp,general_set_fct ,set_fct_spec) || - SQL_ISRULEOR2(pValueExp,position_exp,extract_exp) || - SQL_ISRULEOR2(pValueExp,fold,char_substring_fct) || - SQL_ISRULEOR2(pValueExp,length_exp,char_value_fct)) + else if(SQL_ISRULEOR3(pValueExp, general_set_fct, set_fct_spec, position_exp) || + SQL_ISRULEOR3(pValueExp, extract_exp, fold, char_substring_fct) || + SQL_ISRULEOR2(pValueExp, length_exp, char_value_fct)) { AddFunctionCondition( _pView, _pSelectionBrw, @@ -1528,10 +1523,10 @@ namespace OSQLParseNode* pFunction = pCondition->getChild(0); - OSL_ENSURE(SQL_ISRULEOR2(pFunction,general_set_fct ,set_fct_spec) || - SQL_ISRULEOR2(pFunction,position_exp,extract_exp) || - SQL_ISRULEOR2(pFunction,fold,char_substring_fct) || - SQL_ISRULEOR2(pFunction,length_exp,char_value_fct),"Illegal call!"); + OSL_ENSURE(SQL_ISRULEOR3(pFunction, general_set_fct, set_fct_spec, position_exp) || + SQL_ISRULEOR3(pFunction, extract_exp, fold, char_substring_fct) || + SQL_ISRULEOR2(pFunction,length_exp,char_value_fct), + "Illegal call!"); ::rtl::OUString aCondition; OTableFieldDescRef aDragLeft = new OTableFieldDesc(); @@ -2196,10 +2191,9 @@ namespace eErrorCode = _pView->InsertField(aInfo, sal_True, bFirstField); bFirstField = sal_False; } - else if(SQL_ISRULEOR2(pColumnRef,general_set_fct ,set_fct_spec) || - SQL_ISRULEOR2(pColumnRef,position_exp,extract_exp) || - SQL_ISRULEOR2(pColumnRef,fold,char_substring_fct) || - SQL_ISRULEOR2(pColumnRef,length_exp,char_value_fct)) + else if(SQL_ISRULEOR3(pColumnRef, general_set_fct, set_fct_spec, position_exp) || + SQL_ISRULEOR3(pColumnRef, extract_exp, fold, char_substring_fct) || + SQL_ISRULEOR2(pColumnRef,length_exp,char_value_fct)) { ::rtl::OUString aColumns; pColumnRef->parseNodeToPredicateStr(aColumns, diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx index 1b2328d8f955..8b9330e0b7cd 100644 --- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx +++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx @@ -71,11 +71,6 @@ const String g_strZero = String::CreateFromAscii("0"); #define HANDLE_ID 0 #define HANDLE_COLUMN_WITDH 70 -#define SQL_ISRULEOR2(pParseNode, e1,e2) ((pParseNode)->isRule() && (\ - (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::e1) || \ - (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::e2))) - - // ----------------------------------------------------------------------------- namespace { @@ -860,9 +855,8 @@ sal_Bool OSelectionBrowseBox::saveField(const String& _sFieldName,OTableFieldDes getDesignView()->fillFunctionInfo(pColumnRef,sFunction,aSelEntry); - if( SQL_ISRULEOR2(pColumnRef,position_exp,extract_exp) || - SQL_ISRULEOR2(pColumnRef,fold,char_substring_fct) || - SQL_ISRULEOR2(pColumnRef,length_exp,char_value_fct) ) + if( SQL_ISRULEOR3(pColumnRef, position_exp, extract_exp, fold) || + SQL_ISRULEOR3(pColumnRef, char_substring_fct, length_exp, char_value_fct) ) // a calculation has been found ( can be calc and function ) { // now parse the whole statement -- cgit From e382cc5c08d0339e5ab7325f1e989222d0e261f5 Mon Sep 17 00:00:00 2001 From: Lionel Elie Mamane Date: Sun, 30 Oct 2011 15:51:00 +0100 Subject: fdo#33047: no data accessible if filename contains "?" --- connectivity/source/drivers/hsqldb/StorageFileAccess.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/connectivity/source/drivers/hsqldb/StorageFileAccess.cxx b/connectivity/source/drivers/hsqldb/StorageFileAccess.cxx index 8a719ee3f638..208717c3c9e9 100644 --- a/connectivity/source/drivers/hsqldb/StorageFileAccess.cxx +++ b/connectivity/source/drivers/hsqldb/StorageFileAccess.cxx @@ -84,6 +84,9 @@ SAL_DLLPUBLIC_EXPORT jboolean JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_Storag catch(const NoSuchElementException&) { } + catch(const IllegalArgumentException&) + { + } return aStoragePair.first.first->isStreamElement(StorageContainer::removeURLPrefix(sName,aStoragePair.first.second)); } catch(const NoSuchElementException&) -- cgit From eda6d8971dd5b33d572a123198bf0cca63120cf9 Mon Sep 17 00:00:00 2001 From: Ivan Timofeev Date: Sun, 30 Oct 2011 20:59:31 +0400 Subject: fix fdo#31966: inserting empty slide when printing handouts --- sd/source/ui/view/DocumentRenderer.cxx | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/sd/source/ui/view/DocumentRenderer.cxx b/sd/source/ui/view/DocumentRenderer.cxx index 9966f6c7b993..4c9228d7e48c 100644 --- a/sd/source/ui/view/DocumentRenderer.cxx +++ b/sd/source/ui/view/DocumentRenderer.cxx @@ -1894,21 +1894,17 @@ private: ::std::vector aPageIndices; sal_uInt16 nPrinterPageIndex = 0; StringRangeEnumerator::Iterator it = aRangeEnum.begin(), itEnd = aRangeEnum.end(); - bool bLastLoop = false; + bool bLastLoop = (it == itEnd); while (!bLastLoop) { - if (it != itEnd) - { - sal_Int32 nPageIndex = *it; - ++it; - if (GetFilteredPage(nPageIndex, PK_STANDARD) == NULL) - continue; + sal_Int32 nPageIndex = *it; + ++it; + bLastLoop = (it == itEnd); + + if (GetFilteredPage(nPageIndex, PK_STANDARD)) aPageIndices.push_back(nPageIndex); - } - else - { - bLastLoop = true; - } + else if (!bLastLoop) + continue; // Create a printer page when we have found one page for each // placeholder or when this is the last (and special) loop. -- cgit From 184653370717f99e0cce817822caecde01d20006 Mon Sep 17 00:00:00 2001 From: Andras Timar Date: Sun, 30 Oct 2011 21:47:13 +0100 Subject: enable localization of extension descriptions in sdext --- sdext/source/minimizer/description-en-US.txt | 2 ++ sdext/source/minimizer/description.xml | 2 +- sdext/source/minimizer/help/component.txt | 2 -- sdext/source/minimizer/makefile.mk | 18 ++++++++++++--- sdext/source/pdfimport/config/component.txt | 1 - sdext/source/pdfimport/config/description.xml | 33 --------------------------- sdext/source/pdfimport/description-en-US.txt | 1 + sdext/source/pdfimport/description.xml | 33 +++++++++++++++++++++++++++ sdext/source/pdfimport/makefile.mk | 18 +++++++++------ sdext/source/presenter/description-en-US.txt | 2 ++ sdext/source/presenter/description.xml | 2 +- sdext/source/presenter/help/component.txt | 2 -- sdext/source/presenter/makefile.mk | 16 +++++++------ 13 files changed, 75 insertions(+), 57 deletions(-) create mode 100644 sdext/source/minimizer/description-en-US.txt delete mode 100755 sdext/source/minimizer/help/component.txt delete mode 100644 sdext/source/pdfimport/config/component.txt delete mode 100644 sdext/source/pdfimport/config/description.xml create mode 100644 sdext/source/pdfimport/description-en-US.txt create mode 100644 sdext/source/pdfimport/description.xml create mode 100644 sdext/source/presenter/description-en-US.txt delete mode 100755 sdext/source/presenter/help/component.txt diff --git a/sdext/source/minimizer/description-en-US.txt b/sdext/source/minimizer/description-en-US.txt new file mode 100644 index 000000000000..98f2687800ff --- /dev/null +++ b/sdext/source/minimizer/description-en-US.txt @@ -0,0 +1,2 @@ +The Presentation Minimizer is used to reduce the file size of the current presentation. Images will be compressed, and data that is no longer needed will be removed. +The Presentation Minimizer can optimize the image quality size. Presentations designed for screen or projector do not require the same high quality as presentations designed for print. diff --git a/sdext/source/minimizer/description.xml b/sdext/source/minimizer/description.xml index f8762c7fee7b..eef22a750af6 100644 --- a/sdext/source/minimizer/description.xml +++ b/sdext/source/minimizer/description.xml @@ -28,7 +28,7 @@ - + diff --git a/sdext/source/minimizer/help/component.txt b/sdext/source/minimizer/help/component.txt deleted file mode 100755 index 98f2687800ff..000000000000 --- a/sdext/source/minimizer/help/component.txt +++ /dev/null @@ -1,2 +0,0 @@ -The Presentation Minimizer is used to reduce the file size of the current presentation. Images will be compressed, and data that is no longer needed will be removed. -The Presentation Minimizer can optimize the image quality size. Presentations designed for screen or projector do not require the same high quality as presentations designed for print. diff --git a/sdext/source/minimizer/makefile.mk b/sdext/source/minimizer/makefile.mk index fcca6aa3a37c..09139210885c 100644 --- a/sdext/source/minimizer/makefile.mk +++ b/sdext/source/minimizer/makefile.mk @@ -103,11 +103,15 @@ COMPONENT_IMAGES=\ # rather freestyle or common to all? COMPONENT_HELP= \ $(EXTENSIONDIR)$/help$/help_de.odt \ - $(EXTENSIONDIR)$/help$/help_en-US.odt \ - $(EXTENSIONDIR)$/help$/component.txt + $(EXTENSIONDIR)$/help$/help_en-US.odt + +DESCRIPTION_SRC:=$(MISC)/$(EXTENSIONNAME)_in/description.xml + +COMPONENT_DESCRIPTION= \ + $(foreach,lang,$(alllangiso) $(EXTENSIONDIR)$/description-$(lang).txt) # make sure to add your custom files here -EXTENSION_PACKDEPS=$(COMPONENT_BITMAPS) $(COMPONENT_IMAGES) $(COMPONENT_HELP) +EXTENSION_PACKDEPS=$(COMPONENT_BITMAPS) $(COMPONENT_IMAGES) $(COMPONENT_HELP) $(COMPONENT_DESCRIPTION) ZIP2TARGET= presentation_minimizer_develop .IF "$(WITH_LANG)"!="" @@ -143,4 +147,12 @@ $(COMPONENT_HELP) : help$/$$(@:f) @@-$(MKDIRHIER) $(@:d) $(COPY) $< $@ +$(DESCRIPTION_SRC) : description.xml + @@-$(MKDIRHIER) $(@:d) + $(COMMAND_ECHO)$(XRMEX) -p $(PRJNAME) -i $< -o $@ -m $(LOCALIZESDF) -l all + +$(COMPONENT_DESCRIPTION) : $(DESCRIPTION) + $(COPY) description-en-US.txt $(EXTENSIONDIR) + $(COPY) $(MISC)/$(EXTENSIONNAME)_in/description-*.txt $(EXTENSIONDIR) + .ENDIF # L10N_framework diff --git a/sdext/source/pdfimport/config/component.txt b/sdext/source/pdfimport/config/component.txt deleted file mode 100644 index 969581ef2fbf..000000000000 --- a/sdext/source/pdfimport/config/component.txt +++ /dev/null @@ -1 +0,0 @@ -The PDF Import Extension allows you to import and modify PDF documents. Best results with 100% layout accuracy can be achieved with the "PDF/ODF hybrid file" format, which this extension also enables. A hybrid PDF/ODF file is a PDF file that contains an embedded ODF source file. Hybrid PDF/ODF files will be opened in OpenOffice.org as an ODF file without any layout changes. diff --git a/sdext/source/pdfimport/config/description.xml b/sdext/source/pdfimport/config/description.xml deleted file mode 100644 index ac0d50286cab..000000000000 --- a/sdext/source/pdfimport/config/description.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - The Document Foundation - - - - PDF Import - - - - - - - - - - - diff --git a/sdext/source/pdfimport/description-en-US.txt b/sdext/source/pdfimport/description-en-US.txt new file mode 100644 index 000000000000..0cde58a8ad50 --- /dev/null +++ b/sdext/source/pdfimport/description-en-US.txt @@ -0,0 +1 @@ +The PDF Import Extension allows you to import and modify PDF documents. Best results with 100% layout accuracy can be achieved with the "PDF/ODF hybrid file" format, which this extension also enables. A hybrid PDF/ODF file is a PDF file that contains an embedded ODF source file. Hybrid PDF/ODF files will be opened in LibreOffice as an ODF file without any layout changes. diff --git a/sdext/source/pdfimport/description.xml b/sdext/source/pdfimport/description.xml new file mode 100644 index 000000000000..503753af178c --- /dev/null +++ b/sdext/source/pdfimport/description.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + The Document Foundation + + + + PDF Import + + + + + + + + + + + diff --git a/sdext/source/pdfimport/makefile.mk b/sdext/source/pdfimport/makefile.mk index 02d22132efe5..3606a768b356 100644 --- a/sdext/source/pdfimport/makefile.mk +++ b/sdext/source/pdfimport/makefile.mk @@ -97,7 +97,7 @@ DEF1NAME=$(SHL1TARGET) # --- Extension packaging ------------------------------------------ -DESCRIPTION_SRC:=config$/description.xml +DESCRIPTION_SRC:=$(MISC)/$(EXTENSIONNAME)_in/description.xml MANIFEST_SRC:=config$/manifest.xml COMPONENT_CONFIGDIR:=config COMPONENT_CONFIGDEST:=. @@ -117,8 +117,8 @@ COMPONENT_DIALOGS= \ $(EXTENSIONDIR)$/basic$/writer.png \ $(EXTENSIONDIR)$/xpdfimport_err.pdf -COMPONENT_HELP= \ - $(EXTENSIONDIR)$/component.txt +COMPONENT_DESCRIPTION= \ + $(foreach,lang,$(alllangiso) $(EXTENSIONDIR)$/description-$(lang).txt) # native libraries COMPONENT_LIBRARIES= \ @@ -127,7 +127,7 @@ COMPONENT_LIBRARIES= \ COMPONENT_IMAGES=\ $(EXTENSIONDIR)$/images$/extension_32.png -EXTENSION_PACKDEPS=$(CONVERTER_FILE) $(COMPONENT_DIALOGS) $(COMPONENT_HELP) $(COMPONENT_IMAGES) makefile.mk +EXTENSION_PACKDEPS=$(CONVERTER_FILE) $(COMPONENT_DIALOGS) $(COMPONENT_DESCRIPTION) $(COMPONENT_IMAGES) makefile.mk .INCLUDE : extension_pre.mk .ENDIF # L10N_framework @@ -135,6 +135,10 @@ EXTENSION_PACKDEPS=$(CONVERTER_FILE) $(COMPONENT_DIALOGS) $(COMPONENT_HELP) $(CO .IF "$(L10N_framework)"=="" .INCLUDE : extension_post.mk +$(DESCRIPTION_SRC) : description.xml + @@-$(MKDIRHIER) $(@:d) + $(COMMAND_ECHO)$(XRMEX) -p $(PRJNAME) -i $< -o $@ -m $(LOCALIZESDF) -l all + $(CONVERTER_FILE) : $(BIN)$/$$(@:f) @@-$(MKDIRHIER) $(@:d) $(COPY) $< $@ @@ -143,9 +147,9 @@ $(COMPONENT_DIALOGS) : dialogs$/$$(@:f) @@-$(MKDIRHIER) $(@:d) $(COPY) $< $@ -$(COMPONENT_HELP) : config$/$$(@:f) - @@-$(MKDIRHIER) $(@:d) - $(COPY) $< $@ +$(COMPONENT_DESCRIPTION) : $(DESCRIPTION) + $(COPY) description-en-US.txt $(EXTENSIONDIR) + $(COPY) $(MISC)/$(EXTENSIONNAME)_in/description-*.txt $(EXTENSIONDIR) $(COMPONENT_IMAGES) : $(SOLARSRC)$/$(RSCDEFIMG)$/desktop$/res$/$$(@:f) @@-$(MKDIRHIER) $(@:d) diff --git a/sdext/source/presenter/description-en-US.txt b/sdext/source/presenter/description-en-US.txt new file mode 100644 index 000000000000..26a10c622fe9 --- /dev/null +++ b/sdext/source/presenter/description-en-US.txt @@ -0,0 +1,2 @@ +The Presenter Console Extension provides more control over your slide show presentation, such as the ability to see the upcoming slide, the slide notes, and a presentation timer whereas the audience see only the current slide. +To avoid confusions by displaying a large number of presentation elements, the Presenter Console displays the elements on three different easily changeable views. diff --git a/sdext/source/presenter/description.xml b/sdext/source/presenter/description.xml index bf9ce7260751..22e51199bf09 100644 --- a/sdext/source/presenter/description.xml +++ b/sdext/source/presenter/description.xml @@ -28,7 +28,7 @@ - + diff --git a/sdext/source/presenter/help/component.txt b/sdext/source/presenter/help/component.txt deleted file mode 100755 index 26a10c622fe9..000000000000 --- a/sdext/source/presenter/help/component.txt +++ /dev/null @@ -1,2 +0,0 @@ -The Presenter Console Extension provides more control over your slide show presentation, such as the ability to see the upcoming slide, the slide notes, and a presentation timer whereas the audience see only the current slide. -To avoid confusions by displaying a large number of presentation elements, the Presenter Console displays the elements on three different easily changeable views. diff --git a/sdext/source/presenter/makefile.mk b/sdext/source/presenter/makefile.mk index 1afbb1e68093..edf39197c6a9 100644 --- a/sdext/source/presenter/makefile.mk +++ b/sdext/source/presenter/makefile.mk @@ -247,9 +247,11 @@ COMPONENT_LIBRARY= \ PLATFORMID:=$(RTL_OS:l)_$(RTL_ARCH:l) COMPONENT_HELP= \ - $(ZIP1DIR)$/help/component.txt \ $(foreach,l,$(alllangiso) $(ZIP1DIR)$/help$/$l$/com.sun.PresenterScreen-$(PLATFORMID)$/presenter.xhp) +COMPONENT_DESCRIPTION= \ + $(foreach,lang,$(alllangiso) $(ZIP1DIR)$/description-$(lang).txt) + ZIP1DEPS= \ $(DESCRIPTION) \ $(COMPONENT_MANIFEST) \ @@ -257,6 +259,7 @@ ZIP1DEPS= \ $(COMPONENT_BITMAPS) \ $(COMPONENT_IMAGES) \ $(COMPONENT_LIBRARY) \ + $(COMPONENT_DESCRIPTION) \ $(COMPONENT_HELP) LINKNAME:=help @@ -284,10 +287,6 @@ $(COMPONENT_MANIFEST) : $$(@:f) @-$(MKDIRHIER) $(@:d) +$(TYPE) $< | $(SED) "s/SHARED_EXTENSION/$(DLLPOST)/" > $@ -$(ZIP1DIR)$/help$/component.txt : help$/$$(@:f) - @@-$(MKDIRHIER) $(@:d) - $(COPY) $< $@ - $(ZIP1DIR)$/help$/%$/com.sun.PresenterScreen-$(PLATFORMID)$/presenter.xhp : $(COMMONMISC)$/%$/com.sun.PresenterScreen$/presenter.xhp @echo creating $@ @-$(MKDIRHIER) $(@:d) @@ -351,7 +350,7 @@ $(COMPONENT_LIBRARY) : $(DLLDEST)$/$$(@:f) .ENDIF #"$(COM)"=="GCC" .ENDIF #"$(OS)$(CPU)"=="WNTI" && "$(WITH_EXTENSION_INTEGRATION)"!="YES" - +$(COMPONENT_DESCRIPTION) : $(DESCRIPTION) $(ZIP1DIR)/%.xcu : %.xcu @@-$(MKDIRHIER) $(@:d) @@ -368,7 +367,10 @@ PHONYDESC=.PHONY $(DESCRIPTION) $(PHONYDESC) : $$(@:f) @-$(MKDIRHIER) $(@:d) @echo LAST_WITH_LANG=$(WITH_LANG) > $(ZIP1DIR)_lang_track.mk - $(TYPE) description.xml | sed s/UPDATED_PLATFORM/$(PLATFORMID)/ > $@ + $(GNUCOPY) description-en-US.txt $(ZIP1DIR)/description-en-US.txt + $(XRMEX) -p $(PRJNAME) -i description.xml -o $@ -m $(LOCALIZESDF) -l all + $(TYPE) $@ | sed s/UPDATED_PLATFORM/$(PLATFORMID)/ > $@.new + mv $@.new $@ ALLTAR: $(MISC)/../bin/presenter-screen.oxt # hotfix to missing localizations -- cgit From 726fe9cc4e89f1c4bcd74c64bcfc5b7785b6e642 Mon Sep 17 00:00:00 2001 From: Andras Timar Date: Sun, 30 Oct 2011 22:25:12 +0100 Subject: enable localization of extension descriptions in mysqlc --- mysqlc/source/description-en-US.txt | 1 + mysqlc/source/description.xml | 4 +-- mysqlc/source/description/description_de.txt | 1 - mysqlc/source/description/description_en-US.txt | 1 - mysqlc/source/description/description_es.txt | 1 - mysqlc/source/description/description_fr.txt | 1 - mysqlc/source/description/description_hu.txt | 1 - mysqlc/source/description/description_it.txt | 1 - mysqlc/source/description/description_ja.txt | 1 - mysqlc/source/description/description_ko.txt | 1 - mysqlc/source/description/description_nl.txt | 1 - mysqlc/source/description/description_pl.txt | 1 - mysqlc/source/description/description_pt-BR.txt | 1 - mysqlc/source/description/description_pt.txt | 1 - mysqlc/source/description/description_ru.txt | 1 - mysqlc/source/description/description_sv.txt | 1 - mysqlc/source/description/description_zh-CN.txt | 1 - mysqlc/source/description/description_zh-TW.txt | 1 - mysqlc/source/makefile.mk | 41 +++++-------------------- mysqlc/version.mk | 8 ----- 20 files changed, 10 insertions(+), 60 deletions(-) create mode 100644 mysqlc/source/description-en-US.txt delete mode 100644 mysqlc/source/description/description_de.txt delete mode 100755 mysqlc/source/description/description_en-US.txt delete mode 100644 mysqlc/source/description/description_es.txt delete mode 100644 mysqlc/source/description/description_fr.txt delete mode 100644 mysqlc/source/description/description_hu.txt delete mode 100644 mysqlc/source/description/description_it.txt delete mode 100644 mysqlc/source/description/description_ja.txt delete mode 100644 mysqlc/source/description/description_ko.txt delete mode 100644 mysqlc/source/description/description_nl.txt delete mode 100644 mysqlc/source/description/description_pl.txt delete mode 100644 mysqlc/source/description/description_pt-BR.txt delete mode 100644 mysqlc/source/description/description_pt.txt delete mode 100644 mysqlc/source/description/description_ru.txt delete mode 100644 mysqlc/source/description/description_sv.txt delete mode 100644 mysqlc/source/description/description_zh-CN.txt delete mode 100644 mysqlc/source/description/description_zh-TW.txt diff --git a/mysqlc/source/description-en-US.txt b/mysqlc/source/description-en-US.txt new file mode 100644 index 000000000000..d99ac31d4374 --- /dev/null +++ b/mysqlc/source/description-en-US.txt @@ -0,0 +1 @@ +MySQL Connector installs a native MySQL database driver. It is faster, seamless integrated, easier to administrate and there is no need to install and setup a JDBC or ODBC driver separately. It was never easier to use MySQL databases in LibreOffice Base. diff --git a/mysqlc/source/description.xml b/mysqlc/source/description.xml index ca9c1e77613f..53f483b7c5cf 100644 --- a/mysqlc/source/description.xml +++ b/mysqlc/source/description.xml @@ -6,7 +6,7 @@ - #TITLE# + MySQL Connector @@ -18,6 +18,6 @@ - + diff --git a/mysqlc/source/description/description_de.txt b/mysqlc/source/description/description_de.txt deleted file mode 100644 index acdaea342571..000000000000 --- a/mysqlc/source/description/description_de.txt +++ /dev/null @@ -1 +0,0 @@ -Verbindet OpenOffice.org direkt mit MySQL-Servern \ No newline at end of file diff --git a/mysqlc/source/description/description_en-US.txt b/mysqlc/source/description/description_en-US.txt deleted file mode 100755 index a8ddd5985cfc..000000000000 --- a/mysqlc/source/description/description_en-US.txt +++ /dev/null @@ -1 +0,0 @@ -The MySQL Connector for OpenOffice.org installs a native MySQL database driver. It is faster, seamless integrated, easier to administrate and there is no need to install and setup a JDBC or ODBC driver separately. It was never easier to use MySQL databases in OpenOffice.org Base. diff --git a/mysqlc/source/description/description_es.txt b/mysqlc/source/description/description_es.txt deleted file mode 100644 index 9e04c85fbd84..000000000000 --- a/mysqlc/source/description/description_es.txt +++ /dev/null @@ -1 +0,0 @@ -Conecta OpenOffice.org directamente con los servidores de MySQL \ No newline at end of file diff --git a/mysqlc/source/description/description_fr.txt b/mysqlc/source/description/description_fr.txt deleted file mode 100644 index ca3073273834..000000000000 --- a/mysqlc/source/description/description_fr.txt +++ /dev/null @@ -1 +0,0 @@ -Connexion directe d'OpenOffice.org avec les serveurs MySQL. \ No newline at end of file diff --git a/mysqlc/source/description/description_hu.txt b/mysqlc/source/description/description_hu.txt deleted file mode 100644 index 0b60de706018..000000000000 --- a/mysqlc/source/description/description_hu.txt +++ /dev/null @@ -1 +0,0 @@ -Közvetlen kapcsolatot teremt az OpenOffice.org és a MySQL-kiszolgálók között. \ No newline at end of file diff --git a/mysqlc/source/description/description_it.txt b/mysqlc/source/description/description_it.txt deleted file mode 100644 index 36326e214bf6..000000000000 --- a/mysqlc/source/description/description_it.txt +++ /dev/null @@ -1 +0,0 @@ -Consente la connessione diretta tra OpenOffice.org e i server MySQL \ No newline at end of file diff --git a/mysqlc/source/description/description_ja.txt b/mysqlc/source/description/description_ja.txt deleted file mode 100644 index 3d6a70eb9489..000000000000 --- a/mysqlc/source/description/description_ja.txt +++ /dev/null @@ -1 +0,0 @@ -OpenOffice.org を MySQL サーバーと直接に接続させる \ No newline at end of file diff --git a/mysqlc/source/description/description_ko.txt b/mysqlc/source/description/description_ko.txt deleted file mode 100644 index 6b4ca29be8ce..000000000000 --- a/mysqlc/source/description/description_ko.txt +++ /dev/null @@ -1 +0,0 @@ -MySQL 서버를 통해 OpenOffice.org에 직접 연결합니다. \ No newline at end of file diff --git a/mysqlc/source/description/description_nl.txt b/mysqlc/source/description/description_nl.txt deleted file mode 100644 index 1405fd0b2ff1..000000000000 --- a/mysqlc/source/description/description_nl.txt +++ /dev/null @@ -1 +0,0 @@ -Verbindt OpenOffice.org direct met MySQL Servers \ No newline at end of file diff --git a/mysqlc/source/description/description_pl.txt b/mysqlc/source/description/description_pl.txt deleted file mode 100644 index 03e0f23bbc99..000000000000 --- a/mysqlc/source/description/description_pl.txt +++ /dev/null @@ -1 +0,0 @@ -Laczy witryne OpenOffice.org bezposrednio z systemem MySQL Servers \ No newline at end of file diff --git a/mysqlc/source/description/description_pt-BR.txt b/mysqlc/source/description/description_pt-BR.txt deleted file mode 100644 index 21d3ba28a5da..000000000000 --- a/mysqlc/source/description/description_pt-BR.txt +++ /dev/null @@ -1 +0,0 @@ -Conecta o OpenOffice.org diretamente aos servidores MySQL \ No newline at end of file diff --git a/mysqlc/source/description/description_pt.txt b/mysqlc/source/description/description_pt.txt deleted file mode 100644 index 1f05c487e03e..000000000000 --- a/mysqlc/source/description/description_pt.txt +++ /dev/null @@ -1 +0,0 @@ -Liga o OpenOffice.org directamente aos servidores MySQL \ No newline at end of file diff --git a/mysqlc/source/description/description_ru.txt b/mysqlc/source/description/description_ru.txt deleted file mode 100644 index 633b2c9514df..000000000000 --- a/mysqlc/source/description/description_ru.txt +++ /dev/null @@ -1 +0,0 @@ -Подключает OpenOffice.org напрямую к серверам MySQL diff --git a/mysqlc/source/description/description_sv.txt b/mysqlc/source/description/description_sv.txt deleted file mode 100644 index d7fc80975763..000000000000 --- a/mysqlc/source/description/description_sv.txt +++ /dev/null @@ -1 +0,0 @@ -Ansluter OpenOffice.org direkt till MySQL-servrarna \ No newline at end of file diff --git a/mysqlc/source/description/description_zh-CN.txt b/mysqlc/source/description/description_zh-CN.txt deleted file mode 100644 index c38bc47a41a8..000000000000 --- a/mysqlc/source/description/description_zh-CN.txt +++ /dev/null @@ -1 +0,0 @@ -将 OpenOffice.org 与 MySQL 服务器直接相连 \ No newline at end of file diff --git a/mysqlc/source/description/description_zh-TW.txt b/mysqlc/source/description/description_zh-TW.txt deleted file mode 100644 index de628909d369..000000000000 --- a/mysqlc/source/description/description_zh-TW.txt +++ /dev/null @@ -1 +0,0 @@ -將 OpenOffice.org 直接連線至 MySQL 伺服器 \ No newline at end of file diff --git a/mysqlc/source/makefile.mk b/mysqlc/source/makefile.mk index 9af646c0f383..faec1024cfc7 100644 --- a/mysqlc/source/makefile.mk +++ b/mysqlc/source/makefile.mk @@ -48,13 +48,7 @@ EXTENSION_VERSION_BASE=$(MYSQLC_VERSION_MAJOR).$(MYSQLC_VERSION_MINOR).$(MYSQLC_ EXTENSION_VERSION=$(EXTENSION_VERSION_BASE) #---- extension title package name -.IF "$(MYSQLC_STATUS)" == "final" - EXTENSION_TITLE:=$(MYSQLC_TITLE) - EXTENSION_ZIPNAME:=$(EXTENSIONNAME) -.ELSE - EXTENSION_TITLE:=$(MYSQLC_TITLE) ($(MYSQLC_STATUS)) - EXTENSION_ZIPNAME:=$(EXTENSIONNAME) -.ENDIF +EXTENSION_ZIPNAME:=$(EXTENSIONNAME) #------------------------------------------------------------------- @@ -224,22 +218,10 @@ DESC_LANGS=$(WITH_LANG) .IF "$(DESC_LANGS)" == "" DESC_LANGS=en-US .ENDIF -COMPONENT_DESCRIPTIONS=$/$(foreach,lang,$(DESC_LANGS) description$/description_$(lang).txt) +COMPONENT_DESCRIPTIONS=$/$(foreach,lang,$(DESC_LANGS) description-$(lang).txt) COMPONENT_DESCRIPTIONS_PACKDEP= \ $(foreach,i,$(COMPONENT_DESCRIPTIONS) $(EXTENSIONDIR)$/$i) -# WITH_LANG might contain languages which we actually do not have a description for (yet) -# Find those, and treat the specially - -# first, find those locales which we actually have a description file for -EXISTING_DESCRIPTIONS=$(foreach,i,$(shell $(FIND) .$/description -name "description_*.txt") $(i:f)) -EXISTING_LANGS=$(foreach,i,$(EXISTING_DESCRIPTIONS) $(i:s,description_,,:s,.txt,,)) - -# then, create a version of WITH_LANG where we stripped all those locales -EXISTING_LANGS_NORMALIZED=$(strip $(EXISTING_LANGS)) -EXISTING_LANGS_NORMALIZED:=+$(EXISTING_LANGS_NORMALIZED:s/ /+/)+ -MISSING_LANGS=$(foreach,lang,$(WITH_LANG) $(eq,$(EXISTING_LANGS_NORMALIZED:s/+$(lang)+//),$(EXISTING_LANGS_NORMALIZED) $(lang) )) - # ........ dependencies for packaging the extension ........ EXTENSION_PACKDEPS=makefile.mk $(COMPONENT_IMAGES) $(COMPONENT_DESCRIPTIONS_PACKDEP) $(COMPONENT_MERGED_XCU) @@ -260,11 +242,6 @@ $(COMPONENT_IMAGES) : $(SOLARSRC)$/$(RSCDEFIMG)$/desktop$/res$/$$(@:f) @@-$(MKDIRHIER) $(@:d) $(COPY) $< $@ -# existing descriptions: just copy -$(EXTENSIONDIR)$/description$/%.txt: .$/description$/%.txt - @@-$(MKDIRHIER) $(@:d) - @$(COPY) $< $@ > $(NULLDEV) - # xcu files: copy # the following is a hack for now - need to find out the generic mechanism later @@ -272,17 +249,13 @@ $(EXTENSIONDIR)$/registry$/data$/org$/openoffice$/Office$/DataAccess$/Drivers.xc @@-$(MKDIRHIER) $(EXTENSIONDIR)$/registry$/data$/org$/openoffice$/Office$/DataAccess @$(COPY) $< $(EXTENSIONDIR)$/registry$/data$/org$/openoffice$/Office$/DataAccess$/Drivers.xcu > $(NULLDEV) -# non-existing descriptions: copy from the English version -.IF "$(strip $(MISSING_LANGS))" != "" -$(foreach,i,$(MISSING_LANGS) $(EXTENSIONDIR)$/description$/description_$i.txt): .$/description$/description_en-US.txt - @echo ------ WARNING: .$/description$/$(@:f) not found, falling back to English description - @@-$(MKDIRHIER) $(@:d) - @$(COPY) $< $@ > $(NULLDEV) -.ENDIF - $(DESCRIPTION_SRC): description.xml +-$(RM) $@ - $(TYPE) description.xml | $(SED) "s/#VERSION#/$(EXTENSION_VERSION)/" | $(SED) "s,#TITLE#,$(EXTENSION_TITLE)," > $@ + $(XRMEX) -p $(PRJNAME) -i $< -o $@ -m $(LOCALIZESDF) -l all + $(SED) "s/#VERSION#/$(EXTENSION_VERSION)/" < $@ > $@.new + mv $@.new $@ + @$(COPY) $(@:d)/description-*.txt $(EXTENSIONDIR) + @$(COPY) description-en-US.txt $(EXTENSIONDIR) .IF "$(SYSTEM_MYSQL)" != "YES" # --- the MySQL client lib needs to be copied diff --git a/mysqlc/version.mk b/mysqlc/version.mk index 5713d5265258..1ca2272bdafa 100644 --- a/mysqlc/version.mk +++ b/mysqlc/version.mk @@ -28,11 +28,3 @@ MYSQLC_VERSION_MAJOR=1 MYSQLC_VERSION_MINOR=0 MYSQLC_VERSION_MICRO=1 - -# the title, as displayed in the Extension Manager -MYSQLC_TITLE=MySQL Connector - -# the status of the extension -# if this is different from "final", it will be appended to the title displayed in the Extension Manager -# and also added to the file name of the resulting .oxt file -MYSQLC_STATUS=final -- cgit From 9ab6ecf33192750cc0353aa806e8ca2479f09224 Mon Sep 17 00:00:00 2001 From: Andras Timar Date: Sun, 30 Oct 2011 22:55:29 +0100 Subject: fix en-US only build --- mysqlc/source/makefile.mk | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/mysqlc/source/makefile.mk b/mysqlc/source/makefile.mk index faec1024cfc7..9405defd4bb6 100644 --- a/mysqlc/source/makefile.mk +++ b/mysqlc/source/makefile.mk @@ -214,11 +214,7 @@ COMPONENT_IMAGES= \ # ........ component description ........ # one file for each WITH_LANG token -DESC_LANGS=$(WITH_LANG) -.IF "$(DESC_LANGS)" == "" - DESC_LANGS=en-US -.ENDIF -COMPONENT_DESCRIPTIONS=$/$(foreach,lang,$(DESC_LANGS) description-$(lang).txt) +COMPONENT_DESCRIPTIONS=$/$(foreach,lang,$(alllangiso) description-$(lang).txt) COMPONENT_DESCRIPTIONS_PACKDEP= \ $(foreach,i,$(COMPONENT_DESCRIPTIONS) $(EXTENSIONDIR)$/$i) @@ -249,12 +245,18 @@ $(EXTENSIONDIR)$/registry$/data$/org$/openoffice$/Office$/DataAccess$/Drivers.xc @@-$(MKDIRHIER) $(EXTENSIONDIR)$/registry$/data$/org$/openoffice$/Office$/DataAccess @$(COPY) $< $(EXTENSIONDIR)$/registry$/data$/org$/openoffice$/Office$/DataAccess$/Drivers.xcu > $(NULLDEV) +$(COMPONENT_DESCRIPTIONS_PACKDEP) : $(DESCRIPTION) + $(DESCRIPTION_SRC): description.xml +-$(RM) $@ +.IF "$(WITH_LANG)" != "" $(XRMEX) -p $(PRJNAME) -i $< -o $@ -m $(LOCALIZESDF) -l all $(SED) "s/#VERSION#/$(EXTENSION_VERSION)/" < $@ > $@.new mv $@.new $@ @$(COPY) $(@:d)/description-*.txt $(EXTENSIONDIR) +.ELSE + $(SED) "s/#VERSION#/$(EXTENSION_VERSION)/" < $< > $@ +.ENDIF @$(COPY) description-en-US.txt $(EXTENSIONDIR) .IF "$(SYSTEM_MYSQL)" != "YES" -- cgit From a18bfb0830796fbbb2f2699e9213d29045a7ef19 Mon Sep 17 00:00:00 2001 From: Andras Timar Date: Sun, 30 Oct 2011 22:56:43 +0100 Subject: Revert "enable localization of extension descriptions in sdext" This reverts commit 184653370717f99e0cce817822caecde01d20006. --- sdext/source/minimizer/description-en-US.txt | 2 -- sdext/source/minimizer/description.xml | 2 +- sdext/source/minimizer/help/component.txt | 2 ++ sdext/source/minimizer/makefile.mk | 18 +++------------ sdext/source/pdfimport/config/component.txt | 1 + sdext/source/pdfimport/config/description.xml | 33 +++++++++++++++++++++++++++ sdext/source/pdfimport/description-en-US.txt | 1 - sdext/source/pdfimport/description.xml | 33 --------------------------- sdext/source/pdfimport/makefile.mk | 18 ++++++--------- sdext/source/presenter/description-en-US.txt | 2 -- sdext/source/presenter/description.xml | 2 +- sdext/source/presenter/help/component.txt | 2 ++ sdext/source/presenter/makefile.mk | 16 ++++++------- 13 files changed, 57 insertions(+), 75 deletions(-) delete mode 100644 sdext/source/minimizer/description-en-US.txt create mode 100755 sdext/source/minimizer/help/component.txt create mode 100644 sdext/source/pdfimport/config/component.txt create mode 100644 sdext/source/pdfimport/config/description.xml delete mode 100644 sdext/source/pdfimport/description-en-US.txt delete mode 100644 sdext/source/pdfimport/description.xml delete mode 100644 sdext/source/presenter/description-en-US.txt create mode 100755 sdext/source/presenter/help/component.txt diff --git a/sdext/source/minimizer/description-en-US.txt b/sdext/source/minimizer/description-en-US.txt deleted file mode 100644 index 98f2687800ff..000000000000 --- a/sdext/source/minimizer/description-en-US.txt +++ /dev/null @@ -1,2 +0,0 @@ -The Presentation Minimizer is used to reduce the file size of the current presentation. Images will be compressed, and data that is no longer needed will be removed. -The Presentation Minimizer can optimize the image quality size. Presentations designed for screen or projector do not require the same high quality as presentations designed for print. diff --git a/sdext/source/minimizer/description.xml b/sdext/source/minimizer/description.xml index eef22a750af6..f8762c7fee7b 100644 --- a/sdext/source/minimizer/description.xml +++ b/sdext/source/minimizer/description.xml @@ -28,7 +28,7 @@ - + diff --git a/sdext/source/minimizer/help/component.txt b/sdext/source/minimizer/help/component.txt new file mode 100755 index 000000000000..98f2687800ff --- /dev/null +++ b/sdext/source/minimizer/help/component.txt @@ -0,0 +1,2 @@ +The Presentation Minimizer is used to reduce the file size of the current presentation. Images will be compressed, and data that is no longer needed will be removed. +The Presentation Minimizer can optimize the image quality size. Presentations designed for screen or projector do not require the same high quality as presentations designed for print. diff --git a/sdext/source/minimizer/makefile.mk b/sdext/source/minimizer/makefile.mk index 09139210885c..fcca6aa3a37c 100644 --- a/sdext/source/minimizer/makefile.mk +++ b/sdext/source/minimizer/makefile.mk @@ -103,15 +103,11 @@ COMPONENT_IMAGES=\ # rather freestyle or common to all? COMPONENT_HELP= \ $(EXTENSIONDIR)$/help$/help_de.odt \ - $(EXTENSIONDIR)$/help$/help_en-US.odt - -DESCRIPTION_SRC:=$(MISC)/$(EXTENSIONNAME)_in/description.xml - -COMPONENT_DESCRIPTION= \ - $(foreach,lang,$(alllangiso) $(EXTENSIONDIR)$/description-$(lang).txt) + $(EXTENSIONDIR)$/help$/help_en-US.odt \ + $(EXTENSIONDIR)$/help$/component.txt # make sure to add your custom files here -EXTENSION_PACKDEPS=$(COMPONENT_BITMAPS) $(COMPONENT_IMAGES) $(COMPONENT_HELP) $(COMPONENT_DESCRIPTION) +EXTENSION_PACKDEPS=$(COMPONENT_BITMAPS) $(COMPONENT_IMAGES) $(COMPONENT_HELP) ZIP2TARGET= presentation_minimizer_develop .IF "$(WITH_LANG)"!="" @@ -147,12 +143,4 @@ $(COMPONENT_HELP) : help$/$$(@:f) @@-$(MKDIRHIER) $(@:d) $(COPY) $< $@ -$(DESCRIPTION_SRC) : description.xml - @@-$(MKDIRHIER) $(@:d) - $(COMMAND_ECHO)$(XRMEX) -p $(PRJNAME) -i $< -o $@ -m $(LOCALIZESDF) -l all - -$(COMPONENT_DESCRIPTION) : $(DESCRIPTION) - $(COPY) description-en-US.txt $(EXTENSIONDIR) - $(COPY) $(MISC)/$(EXTENSIONNAME)_in/description-*.txt $(EXTENSIONDIR) - .ENDIF # L10N_framework diff --git a/sdext/source/pdfimport/config/component.txt b/sdext/source/pdfimport/config/component.txt new file mode 100644 index 000000000000..969581ef2fbf --- /dev/null +++ b/sdext/source/pdfimport/config/component.txt @@ -0,0 +1 @@ +The PDF Import Extension allows you to import and modify PDF documents. Best results with 100% layout accuracy can be achieved with the "PDF/ODF hybrid file" format, which this extension also enables. A hybrid PDF/ODF file is a PDF file that contains an embedded ODF source file. Hybrid PDF/ODF files will be opened in OpenOffice.org as an ODF file without any layout changes. diff --git a/sdext/source/pdfimport/config/description.xml b/sdext/source/pdfimport/config/description.xml new file mode 100644 index 000000000000..ac0d50286cab --- /dev/null +++ b/sdext/source/pdfimport/config/description.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + The Document Foundation + + + + PDF Import + + + + + + + + + + + diff --git a/sdext/source/pdfimport/description-en-US.txt b/sdext/source/pdfimport/description-en-US.txt deleted file mode 100644 index 0cde58a8ad50..000000000000 --- a/sdext/source/pdfimport/description-en-US.txt +++ /dev/null @@ -1 +0,0 @@ -The PDF Import Extension allows you to import and modify PDF documents. Best results with 100% layout accuracy can be achieved with the "PDF/ODF hybrid file" format, which this extension also enables. A hybrid PDF/ODF file is a PDF file that contains an embedded ODF source file. Hybrid PDF/ODF files will be opened in LibreOffice as an ODF file without any layout changes. diff --git a/sdext/source/pdfimport/description.xml b/sdext/source/pdfimport/description.xml deleted file mode 100644 index 503753af178c..000000000000 --- a/sdext/source/pdfimport/description.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - The Document Foundation - - - - PDF Import - - - - - - - - - - - diff --git a/sdext/source/pdfimport/makefile.mk b/sdext/source/pdfimport/makefile.mk index 3606a768b356..02d22132efe5 100644 --- a/sdext/source/pdfimport/makefile.mk +++ b/sdext/source/pdfimport/makefile.mk @@ -97,7 +97,7 @@ DEF1NAME=$(SHL1TARGET) # --- Extension packaging ------------------------------------------ -DESCRIPTION_SRC:=$(MISC)/$(EXTENSIONNAME)_in/description.xml +DESCRIPTION_SRC:=config$/description.xml MANIFEST_SRC:=config$/manifest.xml COMPONENT_CONFIGDIR:=config COMPONENT_CONFIGDEST:=. @@ -117,8 +117,8 @@ COMPONENT_DIALOGS= \ $(EXTENSIONDIR)$/basic$/writer.png \ $(EXTENSIONDIR)$/xpdfimport_err.pdf -COMPONENT_DESCRIPTION= \ - $(foreach,lang,$(alllangiso) $(EXTENSIONDIR)$/description-$(lang).txt) +COMPONENT_HELP= \ + $(EXTENSIONDIR)$/component.txt # native libraries COMPONENT_LIBRARIES= \ @@ -127,7 +127,7 @@ COMPONENT_LIBRARIES= \ COMPONENT_IMAGES=\ $(EXTENSIONDIR)$/images$/extension_32.png -EXTENSION_PACKDEPS=$(CONVERTER_FILE) $(COMPONENT_DIALOGS) $(COMPONENT_DESCRIPTION) $(COMPONENT_IMAGES) makefile.mk +EXTENSION_PACKDEPS=$(CONVERTER_FILE) $(COMPONENT_DIALOGS) $(COMPONENT_HELP) $(COMPONENT_IMAGES) makefile.mk .INCLUDE : extension_pre.mk .ENDIF # L10N_framework @@ -135,10 +135,6 @@ EXTENSION_PACKDEPS=$(CONVERTER_FILE) $(COMPONENT_DIALOGS) $(COMPONENT_DESCRIPTIO .IF "$(L10N_framework)"=="" .INCLUDE : extension_post.mk -$(DESCRIPTION_SRC) : description.xml - @@-$(MKDIRHIER) $(@:d) - $(COMMAND_ECHO)$(XRMEX) -p $(PRJNAME) -i $< -o $@ -m $(LOCALIZESDF) -l all - $(CONVERTER_FILE) : $(BIN)$/$$(@:f) @@-$(MKDIRHIER) $(@:d) $(COPY) $< $@ @@ -147,9 +143,9 @@ $(COMPONENT_DIALOGS) : dialogs$/$$(@:f) @@-$(MKDIRHIER) $(@:d) $(COPY) $< $@ -$(COMPONENT_DESCRIPTION) : $(DESCRIPTION) - $(COPY) description-en-US.txt $(EXTENSIONDIR) - $(COPY) $(MISC)/$(EXTENSIONNAME)_in/description-*.txt $(EXTENSIONDIR) +$(COMPONENT_HELP) : config$/$$(@:f) + @@-$(MKDIRHIER) $(@:d) + $(COPY) $< $@ $(COMPONENT_IMAGES) : $(SOLARSRC)$/$(RSCDEFIMG)$/desktop$/res$/$$(@:f) @@-$(MKDIRHIER) $(@:d) diff --git a/sdext/source/presenter/description-en-US.txt b/sdext/source/presenter/description-en-US.txt deleted file mode 100644 index 26a10c622fe9..000000000000 --- a/sdext/source/presenter/description-en-US.txt +++ /dev/null @@ -1,2 +0,0 @@ -The Presenter Console Extension provides more control over your slide show presentation, such as the ability to see the upcoming slide, the slide notes, and a presentation timer whereas the audience see only the current slide. -To avoid confusions by displaying a large number of presentation elements, the Presenter Console displays the elements on three different easily changeable views. diff --git a/sdext/source/presenter/description.xml b/sdext/source/presenter/description.xml index 22e51199bf09..bf9ce7260751 100644 --- a/sdext/source/presenter/description.xml +++ b/sdext/source/presenter/description.xml @@ -28,7 +28,7 @@ - + diff --git a/sdext/source/presenter/help/component.txt b/sdext/source/presenter/help/component.txt new file mode 100755 index 000000000000..26a10c622fe9 --- /dev/null +++ b/sdext/source/presenter/help/component.txt @@ -0,0 +1,2 @@ +The Presenter Console Extension provides more control over your slide show presentation, such as the ability to see the upcoming slide, the slide notes, and a presentation timer whereas the audience see only the current slide. +To avoid confusions by displaying a large number of presentation elements, the Presenter Console displays the elements on three different easily changeable views. diff --git a/sdext/source/presenter/makefile.mk b/sdext/source/presenter/makefile.mk index edf39197c6a9..1afbb1e68093 100644 --- a/sdext/source/presenter/makefile.mk +++ b/sdext/source/presenter/makefile.mk @@ -247,11 +247,9 @@ COMPONENT_LIBRARY= \ PLATFORMID:=$(RTL_OS:l)_$(RTL_ARCH:l) COMPONENT_HELP= \ + $(ZIP1DIR)$/help/component.txt \ $(foreach,l,$(alllangiso) $(ZIP1DIR)$/help$/$l$/com.sun.PresenterScreen-$(PLATFORMID)$/presenter.xhp) -COMPONENT_DESCRIPTION= \ - $(foreach,lang,$(alllangiso) $(ZIP1DIR)$/description-$(lang).txt) - ZIP1DEPS= \ $(DESCRIPTION) \ $(COMPONENT_MANIFEST) \ @@ -259,7 +257,6 @@ ZIP1DEPS= \ $(COMPONENT_BITMAPS) \ $(COMPONENT_IMAGES) \ $(COMPONENT_LIBRARY) \ - $(COMPONENT_DESCRIPTION) \ $(COMPONENT_HELP) LINKNAME:=help @@ -287,6 +284,10 @@ $(COMPONENT_MANIFEST) : $$(@:f) @-$(MKDIRHIER) $(@:d) +$(TYPE) $< | $(SED) "s/SHARED_EXTENSION/$(DLLPOST)/" > $@ +$(ZIP1DIR)$/help$/component.txt : help$/$$(@:f) + @@-$(MKDIRHIER) $(@:d) + $(COPY) $< $@ + $(ZIP1DIR)$/help$/%$/com.sun.PresenterScreen-$(PLATFORMID)$/presenter.xhp : $(COMMONMISC)$/%$/com.sun.PresenterScreen$/presenter.xhp @echo creating $@ @-$(MKDIRHIER) $(@:d) @@ -350,7 +351,7 @@ $(COMPONENT_LIBRARY) : $(DLLDEST)$/$$(@:f) .ENDIF #"$(COM)"=="GCC" .ENDIF #"$(OS)$(CPU)"=="WNTI" && "$(WITH_EXTENSION_INTEGRATION)"!="YES" -$(COMPONENT_DESCRIPTION) : $(DESCRIPTION) + $(ZIP1DIR)/%.xcu : %.xcu @@-$(MKDIRHIER) $(@:d) @@ -367,10 +368,7 @@ PHONYDESC=.PHONY $(DESCRIPTION) $(PHONYDESC) : $$(@:f) @-$(MKDIRHIER) $(@:d) @echo LAST_WITH_LANG=$(WITH_LANG) > $(ZIP1DIR)_lang_track.mk - $(GNUCOPY) description-en-US.txt $(ZIP1DIR)/description-en-US.txt - $(XRMEX) -p $(PRJNAME) -i description.xml -o $@ -m $(LOCALIZESDF) -l all - $(TYPE) $@ | sed s/UPDATED_PLATFORM/$(PLATFORMID)/ > $@.new - mv $@.new $@ + $(TYPE) description.xml | sed s/UPDATED_PLATFORM/$(PLATFORMID)/ > $@ ALLTAR: $(MISC)/../bin/presenter-screen.oxt # hotfix to missing localizations -- cgit From 0c13fbb5bd4cbb0dd8c26b6a168d22a695dd11d6 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 31 Oct 2011 09:04:33 +0100 Subject: Improved an OSL_FAIL. --- desktop/source/deployment/registry/dp_backend.cxx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/desktop/source/deployment/registry/dp_backend.cxx b/desktop/source/deployment/registry/dp_backend.cxx index cbb0bf53abad..672364d9645f 100644 --- a/desktop/source/deployment/registry/dp_backend.cxx +++ b/desktop/source/deployment/registry/dp_backend.cxx @@ -677,8 +677,13 @@ void Package::processPackage_impl( xCmdEnv ); } } - catch (RuntimeException &) { - OSL_FAIL( "### unexpected RuntimeException!" ); + catch (RuntimeException &e) { + (void) e; // avoid warnings + OSL_FAIL( + OSL_FORMAT( + "unexpected RuntimeException \"%s\"", + (rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8). + getStr()))); throw; } catch (CommandFailedException &) { -- cgit From ff290dac977017f6c5114077f28f668432b7180a Mon Sep 17 00:00:00 2001 From: Andras Timar Date: Mon, 31 Oct 2011 12:15:35 +0100 Subject: change address of extensions' website --- sysui/desktop/man/unopkg.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysui/desktop/man/unopkg.1 b/sysui/desktop/man/unopkg.1 index b98a30d5f5ea..dad74dd48164 100644 --- a/sysui/desktop/man/unopkg.1 +++ b/sysui/desktop/man/unopkg.1 @@ -25,7 +25,7 @@ LibreOffice is a fully featured office suite for the daily use with all features you would normally expect in an office suite. There exists many LibreOffice extensions all over the word. For example, see -\fBhttp://extensions.services.openoffice.org/\fR +\fBhttp://extensions.libreoffice.org/\fR This tool allows to manage the extensions from the command line. -- cgit From cedad6e08b5b820e2cb295ddebd431f576fb6f18 Mon Sep 17 00:00:00 2001 From: Andras Timar Date: Mon, 31 Oct 2011 12:16:39 +0100 Subject: change wiki's address --- swext/mediawiki/help/wikiaccount.xhp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swext/mediawiki/help/wikiaccount.xhp b/swext/mediawiki/help/wikiaccount.xhp index 3254de7e8128..b27ea09278e4 100644 --- a/swext/mediawiki/help/wikiaccount.xhp +++ b/swext/mediawiki/help/wikiaccount.xhp @@ -49,7 +49,7 @@ Enter your password on the MediaWiki server. Leave empty for anonymous access.Save password Enable to store your password between sessions. The master password must be enabled, see Tools - Options - %PRODUCTNAME - Security. -Enter the Internet address of a Wiki server in a format like http://wiki.services.openoffice.org/wiki or copy the URL from a web browser. +Enter the Internet address of a Wiki server in a format like http://wiki.documentfoundation.org or copy the URL from a web browser. If the Wiki allows anonymous access, you can leave the account text boxes empty. Else enter your user name and password. If you have enabled the master password feature on the Security tab page of the Tools - Options - %PRODUCTNAME dialog, then the software can store your password and automatically insert the data where necessary. Enable the "Save password" checkbox to store your password. -- cgit From b67ae8dd02a1b9aeb35ef123017d8c02d1d8aaf5 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 31 Oct 2011 12:39:38 +0100 Subject: Make sure COMPONENT_EXTJARFILES are included in report-builder.oxt. --- reportbuilder/util/makefile.mk | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/reportbuilder/util/makefile.mk b/reportbuilder/util/makefile.mk index 8e838e7036dc..c099efb256e1 100644 --- a/reportbuilder/util/makefile.mk +++ b/reportbuilder/util/makefile.mk @@ -86,12 +86,13 @@ COMPONENT_HELP= \ # .jar files from solver COMPONENT_EXTJARFILES = \ - $(EXTENSIONDIR)$/sun-report-builder.jar \ + $(EXTENSIONDIR)$/sun-report-builder.jar +COMPONENT_EXTJARFILES_COPY = \ $(OUTDIR)$/bin$/reportbuilderwizard.jar .IF "$(SYSTEM_JFREEREPORT)" != "YES" .INCLUDE : $(OUTDIR)/bin/jfreereport_version.mk -COMPONENT_EXTJARFILES += \ +COMPONENT_EXTJARFILES_COPY += \ $(OUTDIR)$/bin$/flute-$(FLUTE_VERSION).jar \ $(OUTDIR)$/bin$/libserializer-$(LIBSERIALIZER_VERSION).jar \ $(OUTDIR)$/bin$/libbase-$(LIBBASE_VERSION).jar \ @@ -105,7 +106,7 @@ COMPONENT_EXTJARFILES += \ $(OUTDIR)$/bin$/sac.jar .ENDIF .IF "$(SYSTEM_APACHE_COMMONS)" != "YES" -COMPONENT_EXTJARFILES += \ +COMPONENT_EXTJARFILES_COPY += \ $(OUTDIR)$/bin$/commons-logging-1.1.1.jar .ENDIF @@ -113,7 +114,7 @@ COMPONENT_MANIFEST_GENERIC:=TRUE COMPONENT_MANIFEST_SEARCHDIR:=registry # make sure to add your custom files here -EXTENSION_PACKDEPS=$(COMPONENT_EXTJARFILES) $(COMPONENT_HTMLFILES) $(COMPONENT_OTR_FILES) $(COMPONENT_HELP) $(COMPONENT_IMAGES) +EXTENSION_PACKDEPS=$(COMPONENT_EXTJARFILES) $(MISC)/$(TARGET).copied $(COMPONENT_HTMLFILES) $(COMPONENT_OTR_FILES) $(COMPONENT_HELP) $(COMPONENT_IMAGES) .ENDIF # --- Targets ---------------------------------- @@ -144,6 +145,11 @@ $(COMPONENT_HELP) : $$(@:f) $(DESCRIPTION_SRC): description.xml +-$(RM) $@ $(TYPE) description.xml | $(SED) "s/#VERSION#/$(EXTENSION_VERSION)/" > $@ + +$(MISC)/$(TARGET).copied: $(COMPONENT_EXTJARFILES_COPY) + @@-$(MKDIRHIER) $(EXTENSIONDIR) + : $(foreach,i,$(COMPONENT_EXTJARFILES_COPY) && $(COPY) $i $(EXTENSIONDIR)/) + $(TOUCH) $@ .ENDIF .ELSE # "$(SOLAR_JAVA)"!="" .INCLUDE : target.mk -- cgit From c8278a72b36adfd7f0a44dbedc558961dfd0dd24 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Mon, 31 Oct 2011 14:15:02 +0000 Subject: gtk: tolerate NULL from gdk_screen_get_monitor_plug_name --- vcl/unx/gtk/app/gtksys.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcl/unx/gtk/app/gtksys.cxx b/vcl/unx/gtk/app/gtksys.cxx index b752cce84891..dbe1c47c7e89 100644 --- a/vcl/unx/gtk/app/gtksys.cxx +++ b/vcl/unx/gtk/app/gtksys.cxx @@ -118,7 +118,7 @@ static int _fallback_get_primary_monitor (GdkScreen *pScreen) for (int i = 0; i < max && ret < 0; i++) { char *name = gdk_screen_get_monitor_plug_name (pScreen, i); - if (!g_ascii_strncasecmp (name, "LVDS", 4)) + if (name && !g_ascii_strncasecmp (name, "LVDS", 4)) ret = i; g_free (name); } -- cgit From 3c3f1e3959ccfbd6427ae6610daa4c961559ba69 Mon Sep 17 00:00:00 2001 From: Andras Timar Date: Mon, 31 Oct 2011 13:23:36 +0100 Subject: enable localization of extension descriptions in sdext --- sdext/source/minimizer/description-en-US.txt | 2 ++ sdext/source/minimizer/description.xml | 2 +- sdext/source/minimizer/help/component.txt | 2 -- sdext/source/minimizer/makefile.mk | 24 ++++++++++++++++--- sdext/source/pdfimport/config/component.txt | 1 - sdext/source/pdfimport/config/description.xml | 33 --------------------------- sdext/source/pdfimport/description-en-US.txt | 1 + sdext/source/pdfimport/description.xml | 33 +++++++++++++++++++++++++++ sdext/source/pdfimport/makefile.mk | 24 +++++++++++++------ sdext/source/presenter/description-en-US.txt | 2 ++ sdext/source/presenter/description.xml | 2 +- sdext/source/presenter/help/component.txt | 2 -- sdext/source/presenter/makefile.mk | 20 ++++++++++------ 13 files changed, 91 insertions(+), 57 deletions(-) create mode 100644 sdext/source/minimizer/description-en-US.txt delete mode 100755 sdext/source/minimizer/help/component.txt delete mode 100644 sdext/source/pdfimport/config/component.txt delete mode 100644 sdext/source/pdfimport/config/description.xml create mode 100644 sdext/source/pdfimport/description-en-US.txt create mode 100644 sdext/source/pdfimport/description.xml create mode 100644 sdext/source/presenter/description-en-US.txt delete mode 100755 sdext/source/presenter/help/component.txt diff --git a/sdext/source/minimizer/description-en-US.txt b/sdext/source/minimizer/description-en-US.txt new file mode 100644 index 000000000000..98f2687800ff --- /dev/null +++ b/sdext/source/minimizer/description-en-US.txt @@ -0,0 +1,2 @@ +The Presentation Minimizer is used to reduce the file size of the current presentation. Images will be compressed, and data that is no longer needed will be removed. +The Presentation Minimizer can optimize the image quality size. Presentations designed for screen or projector do not require the same high quality as presentations designed for print. diff --git a/sdext/source/minimizer/description.xml b/sdext/source/minimizer/description.xml index f8762c7fee7b..eef22a750af6 100644 --- a/sdext/source/minimizer/description.xml +++ b/sdext/source/minimizer/description.xml @@ -28,7 +28,7 @@ - + diff --git a/sdext/source/minimizer/help/component.txt b/sdext/source/minimizer/help/component.txt deleted file mode 100755 index 98f2687800ff..000000000000 --- a/sdext/source/minimizer/help/component.txt +++ /dev/null @@ -1,2 +0,0 @@ -The Presentation Minimizer is used to reduce the file size of the current presentation. Images will be compressed, and data that is no longer needed will be removed. -The Presentation Minimizer can optimize the image quality size. Presentations designed for screen or projector do not require the same high quality as presentations designed for print. diff --git a/sdext/source/minimizer/makefile.mk b/sdext/source/minimizer/makefile.mk index fcca6aa3a37c..7932e59949fe 100644 --- a/sdext/source/minimizer/makefile.mk +++ b/sdext/source/minimizer/makefile.mk @@ -103,11 +103,15 @@ COMPONENT_IMAGES=\ # rather freestyle or common to all? COMPONENT_HELP= \ $(EXTENSIONDIR)$/help$/help_de.odt \ - $(EXTENSIONDIR)$/help$/help_en-US.odt \ - $(EXTENSIONDIR)$/help$/component.txt + $(EXTENSIONDIR)$/help$/help_en-US.odt + +DESCRIPTION_SRC:=$(MISC)/$(EXTENSIONNAME)_in/description.xml + +COMPONENT_DESCRIPTION= \ + $(foreach,lang,$(alllangiso) $(EXTENSIONDIR)$/description-$(lang).txt) # make sure to add your custom files here -EXTENSION_PACKDEPS=$(COMPONENT_BITMAPS) $(COMPONENT_IMAGES) $(COMPONENT_HELP) +EXTENSION_PACKDEPS=$(COMPONENT_BITMAPS) $(COMPONENT_IMAGES) $(COMPONENT_HELP) $(COMPONENT_DESCRIPTION) ZIP2TARGET= presentation_minimizer_develop .IF "$(WITH_LANG)"!="" @@ -143,4 +147,18 @@ $(COMPONENT_HELP) : help$/$$(@:f) @@-$(MKDIRHIER) $(@:d) $(COPY) $< $@ +$(DESCRIPTION_SRC) : description.xml + @@-$(MKDIRHIER) $(@:d) +.IF "$(WITH_LANG)" != "" + $(COMMAND_ECHO)$(XRMEX) -p $(PRJNAME) -i $< -o $@ -m $(LOCALIZESDF) -l all +.ELSE + $(COPY) $< $@ +.ENDIF + +$(COMPONENT_DESCRIPTION) : $(DESCRIPTION) + $(COPY) description-en-US.txt $(EXTENSIONDIR) +.IF "$(WITH_LANG)" != "" + $(COPY) $(MISC)/$(EXTENSIONNAME)_in/description-*.txt $(EXTENSIONDIR) +.ENDIF + .ENDIF # L10N_framework diff --git a/sdext/source/pdfimport/config/component.txt b/sdext/source/pdfimport/config/component.txt deleted file mode 100644 index 969581ef2fbf..000000000000 --- a/sdext/source/pdfimport/config/component.txt +++ /dev/null @@ -1 +0,0 @@ -The PDF Import Extension allows you to import and modify PDF documents. Best results with 100% layout accuracy can be achieved with the "PDF/ODF hybrid file" format, which this extension also enables. A hybrid PDF/ODF file is a PDF file that contains an embedded ODF source file. Hybrid PDF/ODF files will be opened in OpenOffice.org as an ODF file without any layout changes. diff --git a/sdext/source/pdfimport/config/description.xml b/sdext/source/pdfimport/config/description.xml deleted file mode 100644 index ac0d50286cab..000000000000 --- a/sdext/source/pdfimport/config/description.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - The Document Foundation - - - - PDF Import - - - - - - - - - - - diff --git a/sdext/source/pdfimport/description-en-US.txt b/sdext/source/pdfimport/description-en-US.txt new file mode 100644 index 000000000000..0cde58a8ad50 --- /dev/null +++ b/sdext/source/pdfimport/description-en-US.txt @@ -0,0 +1 @@ +The PDF Import Extension allows you to import and modify PDF documents. Best results with 100% layout accuracy can be achieved with the "PDF/ODF hybrid file" format, which this extension also enables. A hybrid PDF/ODF file is a PDF file that contains an embedded ODF source file. Hybrid PDF/ODF files will be opened in LibreOffice as an ODF file without any layout changes. diff --git a/sdext/source/pdfimport/description.xml b/sdext/source/pdfimport/description.xml new file mode 100644 index 000000000000..503753af178c --- /dev/null +++ b/sdext/source/pdfimport/description.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + The Document Foundation + + + + PDF Import + + + + + + + + + + + diff --git a/sdext/source/pdfimport/makefile.mk b/sdext/source/pdfimport/makefile.mk index 02d22132efe5..8e0dfa0b48c2 100644 --- a/sdext/source/pdfimport/makefile.mk +++ b/sdext/source/pdfimport/makefile.mk @@ -97,7 +97,7 @@ DEF1NAME=$(SHL1TARGET) # --- Extension packaging ------------------------------------------ -DESCRIPTION_SRC:=config$/description.xml +DESCRIPTION_SRC:=$(MISC)/$(EXTENSIONNAME)_in/description.xml MANIFEST_SRC:=config$/manifest.xml COMPONENT_CONFIGDIR:=config COMPONENT_CONFIGDEST:=. @@ -117,8 +117,8 @@ COMPONENT_DIALOGS= \ $(EXTENSIONDIR)$/basic$/writer.png \ $(EXTENSIONDIR)$/xpdfimport_err.pdf -COMPONENT_HELP= \ - $(EXTENSIONDIR)$/component.txt +COMPONENT_DESCRIPTION= \ + $(foreach,lang,$(alllangiso) $(EXTENSIONDIR)$/description-$(lang).txt) # native libraries COMPONENT_LIBRARIES= \ @@ -127,7 +127,7 @@ COMPONENT_LIBRARIES= \ COMPONENT_IMAGES=\ $(EXTENSIONDIR)$/images$/extension_32.png -EXTENSION_PACKDEPS=$(CONVERTER_FILE) $(COMPONENT_DIALOGS) $(COMPONENT_HELP) $(COMPONENT_IMAGES) makefile.mk +EXTENSION_PACKDEPS=$(CONVERTER_FILE) $(COMPONENT_DIALOGS) $(COMPONENT_DESCRIPTION) $(COMPONENT_IMAGES) makefile.mk .INCLUDE : extension_pre.mk .ENDIF # L10N_framework @@ -135,18 +135,28 @@ EXTENSION_PACKDEPS=$(CONVERTER_FILE) $(COMPONENT_DIALOGS) $(COMPONENT_HELP) $(CO .IF "$(L10N_framework)"=="" .INCLUDE : extension_post.mk -$(CONVERTER_FILE) : $(BIN)$/$$(@:f) +$(DESCRIPTION_SRC) : description.xml @@-$(MKDIRHIER) $(@:d) +.IF "$(WITH_LANG)" != "" + $(COMMAND_ECHO)$(XRMEX) -p $(PRJNAME) -i $< -o $@ -m $(LOCALIZESDF) -l all +.ELSE $(COPY) $< $@ +.ENDIF -$(COMPONENT_DIALOGS) : dialogs$/$$(@:f) +$(CONVERTER_FILE) : $(BIN)$/$$(@:f) @@-$(MKDIRHIER) $(@:d) $(COPY) $< $@ -$(COMPONENT_HELP) : config$/$$(@:f) +$(COMPONENT_DIALOGS) : dialogs$/$$(@:f) @@-$(MKDIRHIER) $(@:d) $(COPY) $< $@ +$(COMPONENT_DESCRIPTION) : $(DESCRIPTION) + $(COPY) description-en-US.txt $(EXTENSIONDIR) +.IF "$(WITH_LANG)" != "" + $(COPY) $(MISC)/$(EXTENSIONNAME)_in/description-*.txt $(EXTENSIONDIR) +.ENDIF + $(COMPONENT_IMAGES) : $(SOLARSRC)$/$(RSCDEFIMG)$/desktop$/res$/$$(@:f) @@-$(MKDIRHIER) $(@:d) $(COPY) $< $@ diff --git a/sdext/source/presenter/description-en-US.txt b/sdext/source/presenter/description-en-US.txt new file mode 100644 index 000000000000..26a10c622fe9 --- /dev/null +++ b/sdext/source/presenter/description-en-US.txt @@ -0,0 +1,2 @@ +The Presenter Console Extension provides more control over your slide show presentation, such as the ability to see the upcoming slide, the slide notes, and a presentation timer whereas the audience see only the current slide. +To avoid confusions by displaying a large number of presentation elements, the Presenter Console displays the elements on three different easily changeable views. diff --git a/sdext/source/presenter/description.xml b/sdext/source/presenter/description.xml index bf9ce7260751..22e51199bf09 100644 --- a/sdext/source/presenter/description.xml +++ b/sdext/source/presenter/description.xml @@ -28,7 +28,7 @@ - + diff --git a/sdext/source/presenter/help/component.txt b/sdext/source/presenter/help/component.txt deleted file mode 100755 index 26a10c622fe9..000000000000 --- a/sdext/source/presenter/help/component.txt +++ /dev/null @@ -1,2 +0,0 @@ -The Presenter Console Extension provides more control over your slide show presentation, such as the ability to see the upcoming slide, the slide notes, and a presentation timer whereas the audience see only the current slide. -To avoid confusions by displaying a large number of presentation elements, the Presenter Console displays the elements on three different easily changeable views. diff --git a/sdext/source/presenter/makefile.mk b/sdext/source/presenter/makefile.mk index 1afbb1e68093..9ced62ec2dad 100644 --- a/sdext/source/presenter/makefile.mk +++ b/sdext/source/presenter/makefile.mk @@ -247,9 +247,11 @@ COMPONENT_LIBRARY= \ PLATFORMID:=$(RTL_OS:l)_$(RTL_ARCH:l) COMPONENT_HELP= \ - $(ZIP1DIR)$/help/component.txt \ $(foreach,l,$(alllangiso) $(ZIP1DIR)$/help$/$l$/com.sun.PresenterScreen-$(PLATFORMID)$/presenter.xhp) +COMPONENT_DESCRIPTION= \ + $(foreach,lang,$(alllangiso) $(ZIP1DIR)$/description-$(lang).txt) + ZIP1DEPS= \ $(DESCRIPTION) \ $(COMPONENT_MANIFEST) \ @@ -257,6 +259,7 @@ ZIP1DEPS= \ $(COMPONENT_BITMAPS) \ $(COMPONENT_IMAGES) \ $(COMPONENT_LIBRARY) \ + $(COMPONENT_DESCRIPTION) \ $(COMPONENT_HELP) LINKNAME:=help @@ -284,10 +287,6 @@ $(COMPONENT_MANIFEST) : $$(@:f) @-$(MKDIRHIER) $(@:d) +$(TYPE) $< | $(SED) "s/SHARED_EXTENSION/$(DLLPOST)/" > $@ -$(ZIP1DIR)$/help$/component.txt : help$/$$(@:f) - @@-$(MKDIRHIER) $(@:d) - $(COPY) $< $@ - $(ZIP1DIR)$/help$/%$/com.sun.PresenterScreen-$(PLATFORMID)$/presenter.xhp : $(COMMONMISC)$/%$/com.sun.PresenterScreen$/presenter.xhp @echo creating $@ @-$(MKDIRHIER) $(@:d) @@ -351,7 +350,7 @@ $(COMPONENT_LIBRARY) : $(DLLDEST)$/$$(@:f) .ENDIF #"$(COM)"=="GCC" .ENDIF #"$(OS)$(CPU)"=="WNTI" && "$(WITH_EXTENSION_INTEGRATION)"!="YES" - +$(COMPONENT_DESCRIPTION) : $(DESCRIPTION) $(ZIP1DIR)/%.xcu : %.xcu @@-$(MKDIRHIER) $(@:d) @@ -368,7 +367,14 @@ PHONYDESC=.PHONY $(DESCRIPTION) $(PHONYDESC) : $$(@:f) @-$(MKDIRHIER) $(@:d) @echo LAST_WITH_LANG=$(WITH_LANG) > $(ZIP1DIR)_lang_track.mk - $(TYPE) description.xml | sed s/UPDATED_PLATFORM/$(PLATFORMID)/ > $@ + $(GNUCOPY) description-en-US.txt $(ZIP1DIR)/description-en-US.txt +.IF "$(WITH_LANG)" != "" + $(XRMEX) -p $(PRJNAME) -i description.xml -o $@ -m $(LOCALIZESDF) -l all + sed s/UPDATED_PLATFORM/$(PLATFORMID)/ < $@ > $@.new + mv $@.new $@ +.ELSE + sed s/UPDATED_PLATFORM/$(PLATFORMID)/ < description.xml > $@ +.ENDIF ALLTAR: $(MISC)/../bin/presenter-screen.oxt # hotfix to missing localizations -- cgit From 79228bb177bc9ebe847509d761630663b9c488ef Mon Sep 17 00:00:00 2001 From: Jan Holesovsky Date: Mon, 31 Oct 2011 15:25:14 +0100 Subject: The -something switches are obsolete, use --something instead. --- desktop/win32/source/applauncher/sbase.cxx | 2 +- desktop/win32/source/applauncher/scalc.cxx | 2 +- desktop/win32/source/applauncher/sdraw.cxx | 2 +- desktop/win32/source/applauncher/simpress.cxx | 2 +- desktop/win32/source/applauncher/smath.cxx | 2 +- desktop/win32/source/applauncher/sweb.cxx | 2 +- desktop/win32/source/applauncher/swriter.cxx | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/desktop/win32/source/applauncher/sbase.cxx b/desktop/win32/source/applauncher/sbase.cxx index 9a1f31d3dce0..5fbbd157927f 100644 --- a/desktop/win32/source/applauncher/sbase.cxx +++ b/desktop/win32/source/applauncher/sbase.cxx @@ -32,6 +32,6 @@ #include "launcher.hxx" -_TCHAR APPLICATION_SWITCH[] = _T( "-base" ); +_TCHAR APPLICATION_SWITCH[] = _T( "--base" ); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/desktop/win32/source/applauncher/scalc.cxx b/desktop/win32/source/applauncher/scalc.cxx index ceca63e14450..1a56bd635980 100644 --- a/desktop/win32/source/applauncher/scalc.cxx +++ b/desktop/win32/source/applauncher/scalc.cxx @@ -32,6 +32,6 @@ #include "launcher.hxx" -_TCHAR APPLICATION_SWITCH[] = _T( "-calc" ); +_TCHAR APPLICATION_SWITCH[] = _T( "--calc" ); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/desktop/win32/source/applauncher/sdraw.cxx b/desktop/win32/source/applauncher/sdraw.cxx index 034a7c4f949c..e3f0a5364769 100644 --- a/desktop/win32/source/applauncher/sdraw.cxx +++ b/desktop/win32/source/applauncher/sdraw.cxx @@ -32,6 +32,6 @@ #include "launcher.hxx" -_TCHAR APPLICATION_SWITCH[] = _T( "-draw" ); +_TCHAR APPLICATION_SWITCH[] = _T( "--draw" ); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/desktop/win32/source/applauncher/simpress.cxx b/desktop/win32/source/applauncher/simpress.cxx index cd01d01b346d..9397e246b437 100644 --- a/desktop/win32/source/applauncher/simpress.cxx +++ b/desktop/win32/source/applauncher/simpress.cxx @@ -32,6 +32,6 @@ #include "launcher.hxx" -_TCHAR APPLICATION_SWITCH[] = _T( "-impress" ); +_TCHAR APPLICATION_SWITCH[] = _T( "--impress" ); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/desktop/win32/source/applauncher/smath.cxx b/desktop/win32/source/applauncher/smath.cxx index 3e670cd8e692..d1e50c5c9642 100644 --- a/desktop/win32/source/applauncher/smath.cxx +++ b/desktop/win32/source/applauncher/smath.cxx @@ -32,6 +32,6 @@ #include "launcher.hxx" -_TCHAR APPLICATION_SWITCH[] = _T( "-math" ); +_TCHAR APPLICATION_SWITCH[] = _T( "--math" ); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/desktop/win32/source/applauncher/sweb.cxx b/desktop/win32/source/applauncher/sweb.cxx index 1c2fd8eabd6c..bbe2c7724bda 100644 --- a/desktop/win32/source/applauncher/sweb.cxx +++ b/desktop/win32/source/applauncher/sweb.cxx @@ -32,6 +32,6 @@ #include "launcher.hxx" -_TCHAR APPLICATION_SWITCH[] = _T( "-web" ); +_TCHAR APPLICATION_SWITCH[] = _T( "--web" ); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/desktop/win32/source/applauncher/swriter.cxx b/desktop/win32/source/applauncher/swriter.cxx index 1909cb97cded..5e4100387a2e 100644 --- a/desktop/win32/source/applauncher/swriter.cxx +++ b/desktop/win32/source/applauncher/swriter.cxx @@ -30,6 +30,6 @@ #include "launcher.hxx" -_TCHAR APPLICATION_SWITCH[] = _T( "-writer" ); +_TCHAR APPLICATION_SWITCH[] = _T( "--writer" ); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit From d5486145c510de842a17f906fd8a7119d30d9993 Mon Sep 17 00:00:00 2001 From: Andras Timar Date: Mon, 31 Oct 2011 15:51:35 +0100 Subject: enable localization of extension description in reportbuilder --- reportbuilder/util/component.txt | 1 - reportbuilder/util/description-en-US.txt | 1 + reportbuilder/util/description.xml | 2 +- reportbuilder/util/makefile.mk | 21 ++++++++++++++------- reportbuilder/util/makefile.pmk | 0 5 files changed, 16 insertions(+), 9 deletions(-) delete mode 100755 reportbuilder/util/component.txt create mode 100644 reportbuilder/util/description-en-US.txt mode change 100755 => 100644 reportbuilder/util/makefile.pmk diff --git a/reportbuilder/util/component.txt b/reportbuilder/util/component.txt deleted file mode 100755 index 21a1f1e2d145..000000000000 --- a/reportbuilder/util/component.txt +++ /dev/null @@ -1 +0,0 @@ -Create with the Report Builder stylish, smart-looking database reports. The flexible report editor can define group and page headers as well as group and page footers and even calculation fields are available to accomplish complex database reports. diff --git a/reportbuilder/util/description-en-US.txt b/reportbuilder/util/description-en-US.txt new file mode 100644 index 000000000000..21a1f1e2d145 --- /dev/null +++ b/reportbuilder/util/description-en-US.txt @@ -0,0 +1 @@ +Create with the Report Builder stylish, smart-looking database reports. The flexible report editor can define group and page headers as well as group and page footers and even calculation fields are available to accomplish complex database reports. diff --git a/reportbuilder/util/description.xml b/reportbuilder/util/description.xml index 78ae10843da3..f048b86743af 100644 --- a/reportbuilder/util/description.xml +++ b/reportbuilder/util/description.xml @@ -17,7 +17,7 @@ - + diff --git a/reportbuilder/util/makefile.mk b/reportbuilder/util/makefile.mk index c099efb256e1..99752c22d9a8 100644 --- a/reportbuilder/util/makefile.mk +++ b/reportbuilder/util/makefile.mk @@ -81,8 +81,8 @@ COMPONENT_HTMLFILES = $(EXTENSIONDIR)$/THIRDPARTYREADMELICENSE.html \ COMPONENT_JARFILES = \ $(EXTENSIONDIR)$/sun-report-builder.jar -COMPONENT_HELP= \ - $(EXTENSIONDIR)$/component.txt +COMPONENT_DESCRIPTION= \ + $(foreach,lang,$(alllangiso) $(EXTENSIONDIR)$/description-$(lang).txt) # .jar files from solver COMPONENT_EXTJARFILES = \ @@ -114,7 +114,7 @@ COMPONENT_MANIFEST_GENERIC:=TRUE COMPONENT_MANIFEST_SEARCHDIR:=registry # make sure to add your custom files here -EXTENSION_PACKDEPS=$(COMPONENT_EXTJARFILES) $(MISC)/$(TARGET).copied $(COMPONENT_HTMLFILES) $(COMPONENT_OTR_FILES) $(COMPONENT_HELP) $(COMPONENT_IMAGES) +EXTENSION_PACKDEPS=$(COMPONENT_EXTJARFILES) $(MISC)/$(TARGET).copied $(COMPONENT_HTMLFILES) $(COMPONENT_OTR_FILES) $(COMPONENT_DESCRIPTION) $(COMPONENT_IMAGES) .ENDIF # --- Targets ---------------------------------- @@ -138,13 +138,20 @@ $(EXTENSIONDIR)$/THIRDPARTYREADMELICENSE.html : $(PRJ)$/license$/THIRDPARTYREADM @@-$(MKDIRHIER) $(@:d) $(COPY) $< $@ -$(COMPONENT_HELP) : $$(@:f) - @@-$(MKDIRHIER) $(@:d) - $(COPY) $< $@ +$(COMPONENT_DESCRIPTION) : $(DESCRIPTION) + $(DESCRIPTION_SRC): description.xml +-$(RM) $@ - $(TYPE) description.xml | $(SED) "s/#VERSION#/$(EXTENSION_VERSION)/" > $@ + $(COPY) description-en-US.txt $(EXTENSIONDIR)/description-en-US.txt +.IF "$(WITH_LANG)" != "" + $(XRMEX) -p $(PRJNAME) -i description.xml -o $@ -m $(LOCALIZESDF) -l all + $(SED) "s/#VERSION#/$(EXTENSION_VERSION)/" < $@ > $@.new + mv $@.new $@ + @$(COPY) $(@:d)/description-*.txt $(EXTENSIONDIR) +.ELSE + $(SED) "s/#VERSION#/$(EXTENSION_VERSION)/" < $< > $@ +.ENDIF $(MISC)/$(TARGET).copied: $(COMPONENT_EXTJARFILES_COPY) @@-$(MKDIRHIER) $(EXTENSIONDIR) diff --git a/reportbuilder/util/makefile.pmk b/reportbuilder/util/makefile.pmk old mode 100755 new mode 100644 -- cgit From 2ed58be87924acc4aec81407ba93641afe776b35 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Mon, 31 Oct 2011 15:03:56 +0000 Subject: make --last-working checkout the last working version thanks to Bjoern and Christian for tips. --- g | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/g b/g index 66c1cb2178db..f09caf09258f 100755 --- a/g +++ b/g @@ -242,7 +242,13 @@ for REPO in $DIRS ; do elif [ -d "$DIR" -a "z$LAST_WORKING" != "z" ]; then echo "fetching notes for $REPO ..." (cd $DIR && git fetch origin 'refs/notes/*:refs/notes/*') - # FIXME: we need to grep the git log for a known good note name... + hash=`(cd $DIR && git log --pretty='%H %N' | grep 'win32 working build' | head -n1 | sed 's/ win32.*//')` + if test "z$hash" != "z"; then + echo "update to $hash" + (cd $DIR && git checkout $hash) + else + echo "Warning: missing known working note on repo $REPO" + fi elif [ -d "$DIR" -a "z$SET_LAST_WORKING" != "z" ]; then echo "fetching notes for $REPO ..." (cd $DIR && git fetch origin 'refs/notes/*:refs/notes/*') -- cgit From 983360d3bed84981650adfb30e2759bf6fa30e61 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 31 Oct 2011 16:49:56 +0100 Subject: Removed obsolete gid_Profile_Soffice_Ini items. They have been duplicated to gid_Brand_Profile_Soffice_Ini a long time ago. --- scp2/source/ooo/profileitem_ooo.scp | 61 ------------------------------------- 1 file changed, 61 deletions(-) diff --git a/scp2/source/ooo/profileitem_ooo.scp b/scp2/source/ooo/profileitem_ooo.scp index 10ab481cc688..3fd83da8e391 100644 --- a/scp2/source/ooo/profileitem_ooo.scp +++ b/scp2/source/ooo/profileitem_ooo.scp @@ -103,67 +103,6 @@ End #endif -ProfileItem gid_Profileitem_Soffice_Logo - ProfileID = gid_Profile_Soffice_Ini; - ModuleID = gid_Module_Root; - Section = "Bootstrap"; - Order = 1; - Key = "Logo"; - Value = "1"; -End - -ProfileItem gid_Profileitem_Soffice_ProgressBarColor - ProfileID = gid_Profile_Soffice_Ini; - ModuleID = gid_Module_Root; - Section = "Bootstrap"; - Order = 2; - Key = "ProgressBarColor"; - Value = "0,0,128"; -End - -ProfileItem gid_Profileitem_Soffice_ProgressSize - ProfileID = gid_Profile_Soffice_Ini; - ModuleID = gid_Module_Root; - Section = "Bootstrap"; - Order = 3; - Key = "ProgressSize"; - Value = "-1,6"; -End - -ProfileItem gid_Profileitem_Soffice_ProgressPosition - ProfileID = gid_Profile_Soffice_Ini; - ModuleID = gid_Module_Root; - Section = "Bootstrap"; - Order = 4; - Key = "ProgressPosition"; - Value = "-1,-1"; -End - -ProfileItem gid_Profileitem_Soffice_NativeProgress - ProfileID = gid_Profile_Soffice_Ini; - ModuleID = gid_Module_Root; - Section = "Bootstrap"; - Order = 6; - Key = "NativeProgress"; - Value = "true"; -End - -#ifdef WNT - -ProfileItem gid_Profileitem_Soffice_Hideeula - ProfileID = gid_Profile_Soffice_Ini; - ModuleID = gid_Module_Root; - Section = "Bootstrap"; - Order = 8; - Key = "HideEula"; - Value = "[HIDEEULA]"; - Inifiletablekey = "HideEula"; - Inifiletableaction = "1"; - Styles = (INIFILETABLE); -End - -#endif - ProfileItem gid_Profileitem_Uno_Uno_Bundled_Extensions ProfileID = gid_Profile_Uno_Ini; ModuleID = gid_Module_Root; -- cgit From a334403eb22f3d812549b5ce9b390fecdee9be31 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 31 Oct 2011 16:51:35 +0100 Subject: Cleaned up configmgr initialization. Added CONFIGURATION_LAYERS bootstrap variable. Removed OOO_CONFIG_REGISTRY[_EXTRA]_DIR bootstrap variables. --- configmgr/source/components.cxx | 213 ++++++++++++++++++++------------------ configmgr/source/components.hxx | 7 +- sc/CppunitTest_sc_filters_test.mk | 3 +- sc/CppunitTest_sc_macros_test.mk | 4 +- scp2/source/ooo/common_brand.scp | 12 +++ 5 files changed, 135 insertions(+), 104 deletions(-) diff --git a/configmgr/source/components.cxx b/configmgr/source/components.cxx index 3724b16075f0..456bdfc27d1a 100644 --- a/configmgr/source/components.cxx +++ b/configmgr/source/components.cxx @@ -304,12 +304,12 @@ bool Components::hasModifications() const void Components::writeModifications() { - if (!hasModifications()) + if (!hasModifications() || modificationFileUrl_.isEmpty()) return; if (!writeThread_.is()) { writeThread_ = new WriteThread( - &writeThread_, *this, getModificationFileUrl(), data_); + &writeThread_, *this, modificationFileUrl_, data_); writeThread_->create(); } } @@ -329,8 +329,9 @@ void Components::flushModifications() { void Components::insertExtensionXcsFile( bool shared, rtl::OUString const & fileUri) { + int layer = getExtensionLayer(shared); try { - parseXcsFile(fileUri, shared ? 9 : 13, data_, 0, 0, 0); + parseXcsFile(fileUri, layer, data_, 0, 0, 0); } catch (css::container::NoSuchElementException & e) { throw css::uno::RuntimeException( (rtl::OUString( @@ -345,7 +346,7 @@ void Components::insertExtensionXcuFile( bool shared, rtl::OUString const & fileUri, Modifications * modifications) { OSL_ASSERT(modifications != 0); - int layer = shared ? 10 : 14; + int layer = getExtensionLayer(shared) + 1; Additions * adds = data_.addExtensionXcuAdditions(fileUri, layer); try { parseXcuFile(fileUri, layer, data_, 0, modifications, adds); @@ -506,96 +507,108 @@ css::beans::Optional< css::uno::Any > Components::getExternalValue( Components::Components( css::uno::Reference< css::uno::XComponentContext > const & context): - context_(context) + context_(context), sharedExtensionLayer_(-1), userExtensionLayer_(-1) { - lock_ = lock(); - OSL_ASSERT(context.is()); - - // Check if we are being used for in-tree unit tests ... - rtl::OUString aUnitTestDir; - if (rtl::Bootstrap::get( rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("OOO_CONFIG_REGISTRY_DIR") ), aUnitTestDir)) - { - parseXcsXcuLayer( 0, aUnitTestDir ); - // next is required for the (somewhat strange) filter configuration - parseModuleLayer( 2, aUnitTestDir + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/spool"))); - // allow a directory to be specified to allow extra configuration to be stored - // for example to place a registrymodifications.xcu to override some configuration - rtl::OUString extra; - if (rtl::Bootstrap::get( + lock_ = lock(); + rtl::OUString conf( + expand( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("${CONFIGURATION_LAYERS}")))); + RTL_LOGFILE_TRACE("configmgr : begin parsing"); + int layer = 0; + for (sal_Int32 i = 0;;) { + while (i != conf.getLength() && conf[i] == ' ') { + ++i; + } + if (i == conf.getLength()) { + break; + } + if (!modificationFileUrl_.isEmpty()) { + throw css::uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "OOO_CONFIG_REGISTRY_EXTRA_DIR")), - extra)) + "CONFIGURATION_LAYERS: \"user\" followed by further" + " layers")), + css::uno::Reference< css::uno::XInterface >()); + } + sal_Int32 c = i; + for (;; ++c) { + if (c == conf.getLength() || conf[c] == ' ') { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "CONFIGURATION_LAYERS: missing \":\"")), + css::uno::Reference< css::uno::XInterface >()); + } + if (conf[c] == ':') { + break; + } + } + sal_Int32 n = conf.indexOf(' ', c + 1); + if (n == -1) { + n = conf.getLength(); + } + rtl::OUString type(conf.copy(i, c - i)); + rtl::OUString url(expand(conf.copy(c + 1, n - c - 1))); + if (type.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("xcsxcu"))) { + parseXcsXcuLayer(layer, url); + layer += 2; //TODO: overflow + } else if (type.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("bundledext"))) { - parseXcsXcuLayer(3, extra); + parseXcsXcuIniLayer(layer, url, false); + layer += 2; //TODO: overflow + } else if (type.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("sharedext"))) { + if (sharedExtensionLayer_ != -1) { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "CONFIGURATION_LAYERS: multiple \"sharedext\"" + " layers")), + css::uno::Reference< css::uno::XInterface >()); + } + sharedExtensionLayer_ = layer; + parseXcsXcuIniLayer(layer, url, true); + layer += 2; //TODO: overflow + } else if (type.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("userext"))) { + if (userExtensionLayer_ != -1) { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "CONFIGURATION_LAYERS: multiple \"userext\"" + " layers")), + css::uno::Reference< css::uno::XInterface >()); + } + userExtensionLayer_ = layer; + parseXcsXcuIniLayer(layer, url, true); + layer += 2; //TODO: overflow + } else if (type.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("module"))) { + parseModuleLayer(layer, url); + ++layer; //TODO: overflow + } else if (type.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("res"))) { + parseResLayer(layer, url); + ++layer; //TODO: overflow + } else if (type.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("user"))) { + if (url.isEmpty()) { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "CONFIGURATION_LAYERS: empty \"user\" URL")), + css::uno::Reference< css::uno::XInterface >()); + } + modificationFileUrl_ = url; + parseModificationLayer(url); + } else { + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "CONFIGURATION_LAYERS: unknown layer type \"")) + + type + + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\""))), + css::uno::Reference< css::uno::XInterface >()); } - return; + i = n; } - - RTL_LOGFILE_TRACE("configmgr : begin parsing"); - - parseXcsXcuLayer( - 0, - expand( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( - "$BRAND_BASE_DIR/share/registry")))); - parseModuleLayer( - 2, - expand( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( - "$BRAND_BASE_DIR/share/registry/modules")))); - parseResLayer( - 3, - expand( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( - "$BRAND_BASE_DIR/share/registry")))); - parseXcsXcuIniLayer( - 4, - expand( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( - "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE("uno") - ":BUNDLED_EXTENSIONS_USER}/registry/" - "com.sun.star.comp.deployment.configuration." - "PackageRegistryBackend/configmgr.ini"))), - false); - parseXcsXcuIniLayer( - 6, - expand( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( - "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE("uno") - ":SHARED_EXTENSIONS_USER}/registry/" - "com.sun.star.comp.deployment.configuration." - "PackageRegistryBackend/configmgr.ini"))), - true); - parseXcsXcuLayer( - 8, - expand( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( - "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE("uno") - ":UNO_USER_PACKAGES_CACHE}/registry/" - "com.sun.star.comp.deployment.configuration." - "PackageRegistryBackend/registry")))); - // can be dropped once old UserInstallation format can no longer exist - // (probably OOo 4) - parseXcsXcuIniLayer( - 10, - expand( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( - "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE("uno") - ":UNO_USER_PACKAGES_CACHE}/registry/" - "com.sun.star.comp.deployment.configuration." - "PackageRegistryBackend/configmgr.ini"))), - true); - parseModificationLayer(); RTL_LOGFILE_TRACE("configmgr : end parsing"); } @@ -858,19 +871,9 @@ void Components::parseResLayer(int layer, rtl::OUString const & url) { &parseXcuFile, resUrl, false); } -rtl::OUString Components::getModificationFileUrl() const { - return expand( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( - "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE("bootstrap") - ":UserInstallation}/user/registrymodifications.xcu"))); -} - -void Components::parseModificationLayer() { +void Components::parseModificationLayer(rtl::OUString const & url) { try { - parseFileLeniently( - &parseXcuFile, getModificationFileUrl(), Data::NO_LAYER, data_, 0, - 0, 0); + parseFileLeniently(&parseXcuFile, url, Data::NO_LAYER, data_, 0, 0, 0); } catch (css::container::NoSuchElementException &) { OSL_TRACE( "configmgr user registrymodifications.xcu does not (yet) exist"); @@ -889,6 +892,18 @@ void Components::parseModificationLayer() { } } +int Components::getExtensionLayer(bool shared) { + int layer = shared ? sharedExtensionLayer_ : userExtensionLayer_; + if (layer == -1) { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "insert extension xcs/xcu file into undefined layer")), + css::uno::Reference< css::uno::XInterface >()); + } + return layer; +} + } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/configmgr/source/components.hxx b/configmgr/source/components.hxx index 26af3fbdecea..bc4c5d0b9513 100644 --- a/configmgr/source/components.hxx +++ b/configmgr/source/components.hxx @@ -155,9 +155,9 @@ private: void parseResLayer(int layer, rtl::OUString const & url); - rtl::OUString getModificationFileUrl() const; + void parseModificationLayer(rtl::OUString const & url); - void parseModificationLayer(); + int getExtensionLayer(bool shared); typedef std::set< RootAccess * > WeakRootSet; @@ -176,6 +176,9 @@ private: WeakRootSet roots_; ExternalServices externalServices_; rtl::Reference< WriteThread > writeThread_; + int sharedExtensionLayer_; + int userExtensionLayer_; + rtl::OUString modificationFileUrl_; boost::shared_ptr lock_; }; diff --git a/sc/CppunitTest_sc_filters_test.mk b/sc/CppunitTest_sc_filters_test.mk index e40ae2e63e33..3260d32d0605 100644 --- a/sc/CppunitTest_sc_filters_test.mk +++ b/sc/CppunitTest_sc_filters_test.mk @@ -99,8 +99,9 @@ $(eval $(call gb_CppunitTest_add_service_rdbs,sc_filters_test,\ $(eval $(call gb_CppunitTest_set_args,sc_filters_test,\ --headless \ --protector unoexceptionprotector$(gb_Library_DLLEXT) unoexceptionprotector \ - -env:OOO_CONFIG_REGISTRY_DIR=$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry) \ + "-env:CONFIGURATION_LAYERS=xcsxcu:$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry) module:$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry/spool)" \ )) + # .../spool is required for the (somewhat strange) filter configuration # we need to # a) explicitly depend on library msword because it is not implied by a link diff --git a/sc/CppunitTest_sc_macros_test.mk b/sc/CppunitTest_sc_macros_test.mk index 0da63485bfe7..5d39769a3f15 100644 --- a/sc/CppunitTest_sc_macros_test.mk +++ b/sc/CppunitTest_sc_macros_test.mk @@ -99,9 +99,9 @@ $(eval $(call gb_CppunitTest_add_service_rdbs,sc_macros_test,\ $(eval $(call gb_CppunitTest_set_args,sc_macros_test,\ --headless \ --protector unoexceptionprotector$(gb_Library_DLLEXT) unoexceptionprotector \ - -env:OOO_CONFIG_REGISTRY_DIR=$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry) \ - -env:OOO_CONFIG_REGISTRY_EXTRA_DIR=$(call gb_CppunitTarget__make_url,$(OUTDIR)/unittest/user) \ + "-env:CONFIGURATION_LAYERS=xcsxcu:$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry) module:$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry/spool) xcsxcu:$(call gb_CppunitTarget__make_url,$(OUTDIR)/unittest/user)" \ )) + # .../spool is required for the (somewhat strange) filter configuration # we need to # a) explicitly depend on library msword because it is not implied by a link diff --git a/scp2/source/ooo/common_brand.scp b/scp2/source/ooo/common_brand.scp index 01d0cecc5c77..d9baffadd402 100644 --- a/scp2/source/ooo/common_brand.scp +++ b/scp2/source/ooo/common_brand.scp @@ -927,6 +927,18 @@ ProfileItem gid_Brand_Profileitem_Soffice_Startlang End #endif +ProfileItem gid_Brand_Profileitem_Soffice_ConfigurationLayers + ProfileID = gid_Brand_Profile_Soffice_Ini; + ModuleID = gid_Module_Root_Brand; + Section = "Bootstrap"; + Key = "CONFIGURATION_LAYERS"; + Value = "xcsxcu:${BRAND_BASE_DIR}/share/registry module:${BRAND_BASE_DIR}/share/registry/modules res:${BRAND_BASE_DIR}/share/registry bundledext:${${BRAND_BASE_DIR}/program/" PROFILENAME(uno) ":BUNDLED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini sharedext:${${BRAND_BASE_DIR}/program/" PROFILENAME(uno) ":SHARED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini xcsxcu:${${BRAND_BASE_DIR}/program/" PROFILENAME(uno) ":UNO_USER_PACKAGES_CACHE}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/registry userext:${${BRAND_BASE_DIR}/program/" PROFILENAME(uno) ":UNO_USER_PACKAGES_CACHE}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini user:${$BRAND_BASE_DIR/program/" PROFILENAME(bootstrap) ":UserInstallation}/user/registrymodifications.xcu"; + // "xcsxcu:${${BRAND_BASE_DIR}/program/"PROFILENAME(uno) + // ":UNO_USER_PACKAGES_CACHE}/registry/com.sun.star.comp.deployment." + // "configuration.PackageRegistryBackend/registry" can be dropped once + // old UserInstallation format can no longer exist (probably OOo 4) +End + ProfileItem gid_Brand_Profileitem_Version_Buildid ProfileID = gid_Brand_Profile_Version_Ini; ModuleID = gid_Module_Root_Brand; -- cgit From cb8b7a86176a0684751354fa957ca18e6eb366d0 Mon Sep 17 00:00:00 2001 From: Philipp Weissenbacher Date: Fri, 28 Oct 2011 22:03:40 +0200 Subject: Translate German comments --- sw/source/core/doc/docfld.cxx | 409 ++++++++++++++++++++---------------------- 1 file changed, 199 insertions(+), 210 deletions(-) diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx index 239238e23417..3a81493629f9 100644 --- a/sw/source/core/doc/docfld.cxx +++ b/sw/source/core/doc/docfld.cxx @@ -52,7 +52,7 @@ #include #include #include -#include // fuer Expression-Felder +#include // for expression fields #include #include #include @@ -69,7 +69,7 @@ #include #include #include -#include // fuer InitFldTypes +#include // for InitFldTypes #include #include "switerator.hxx" @@ -82,12 +82,11 @@ extern sal_Bool IsFrameBehind( const SwTxtNode& rMyNd, sal_uInt16 nMySttPos, SV_IMPL_OP_PTRARR_SORT( _SetGetExpFlds, _SetGetExpFldPtr ) /*-------------------------------------------------------------------- - Beschreibung: Feldtypen einfuegen + Description: Insert field types --------------------------------------------------------------------*/ /* - * Implementierung der Feldfunktionen am Doc - * Return immer einen gueltigen Pointer auf den Typ. Wenn er also neu - * zugefuegt oder schon vorhanden ist. + * Implementation of field methods at the Doc + * Always returns a pointer to the type, if it's new or already added. */ SwFieldType* SwDoc::InsertFldType(const SwFieldType &rFldTyp) { @@ -99,14 +98,13 @@ SwFieldType* SwDoc::InsertFldType(const SwFieldType &rFldTyp) switch( nFldWhich ) { case RES_SETEXPFLD: - //JP 29.01.96: SequenceFelder beginnen aber bei INIT_FLDTYPES - 3!! - // Sonst gibt es doppelte Nummernkreise!! - //MIB 14.03.95: Ab sofort verlaesst sich auch der SW3-Reader - //beim Aufbau der String-Pools und beim Einlesen von SetExp-Feldern - //hierauf + //JP 29.01.96: SequenceFields start at INIT_FLDTYPES - 3!! + // Or we get doubble number circles!! + //MIB 14.03.95: From now on also the SW3-Reader relies on this, when + //constructing string pools and when reading SetExp fields if( nsSwGetSetExpType::GSE_SEQ & ((SwSetExpFieldType&)rFldTyp).GetType() ) i -= INIT_SEQ_FLDTYPES; - // kein break; + // no break; case RES_DBFLD: case RES_USERFLD: case RES_DDEFLD: @@ -149,7 +147,7 @@ SwFieldType* SwDoc::InsertFldType(const SwFieldType &rFldTyp) case RES_USERFLD: case RES_SETEXPFLD: ((SwValueFieldType*)pNew)->SetDoc( this ); - // JP 29.07.96: opt. FeldListe fuer den Calculator vorbereiten: + // JP 29.07.96: Optionally prepare FieldList for Calculator: pUpdtFlds->InsertFldType( *pNew ); break; case RES_AUTHORITY : @@ -165,18 +163,17 @@ SwFieldType* SwDoc::InsertFldType(const SwFieldType &rFldTyp) void SwDoc::InsDeletedFldType( SwFieldType& rFldTyp ) { - // der FeldTyp wurde als geloescht gekennzeichnet und aus dem - // Array entfernt. Nun muss man nach diesem wieder suchen. - // - Ist der nicht vorhanden, dann kann er eingefuegt werden. - // - Wird genau der gleiche Typ gefunden, dann muss der geloeschte - // einen anderen Namen erhalten. + // The FldType was marked as deleted and removed from the array. + // One has to look this up again, now. + // - If it's not present, it can be re-inserted. + // - If the same type is found, the deleted one has to be renamed. sal_uInt16 nSize = pFldTypes->Count(), nFldWhich = rFldTyp.Which(); sal_uInt16 i = INIT_FLDTYPES; OSL_ENSURE( RES_SETEXPFLD == nFldWhich || RES_USERFLD == nFldWhich || - RES_DDEFLD == nFldWhich, "Falscher FeldTyp" ); + RES_DDEFLD == nFldWhich, "Wrong FldType" ); const ::utl::TransliterationWrapper& rSCmp = GetAppCmpStrIgnore(); const String& rFldNm = rFldTyp.GetName(); @@ -186,7 +183,7 @@ void SwDoc::InsDeletedFldType( SwFieldType& rFldTyp ) if( nFldWhich == (pFnd = (*pFldTypes)[i])->Which() && rSCmp.isEqual( rFldNm, pFnd->GetName() ) ) { - // neuen Namen suchen + // find new name sal_uInt16 nNum = 1; do { String sSrch( rFldNm ); @@ -196,17 +193,17 @@ void SwDoc::InsDeletedFldType( SwFieldType& rFldTyp ) rSCmp.isEqual( sSrch, pFnd->GetName() ) ) break; - if( i >= nSize ) // nicht gefunden + if( i >= nSize ) // not found { ((String&)rFldNm) = sSrch; - break; // raus aus der While-Schleife + break; // exit while loop } ++nNum; } while( sal_True ); break; } - // nicht gefunden, also eintragen und Flag loeschen + // not found, so insert and delete flag pFldTypes->Insert( &rFldTyp, nSize ); switch( nFldWhich ) { @@ -223,27 +220,27 @@ void SwDoc::InsDeletedFldType( SwFieldType& rFldTyp ) } /*-------------------------------------------------------------------- - Beschreibung: Feldtypen loeschen + Description: Remove field type --------------------------------------------------------------------*/ void SwDoc::RemoveFldType(sal_uInt16 nFld) { - OSL_ENSURE( INIT_FLDTYPES <= nFld, "keine InitFields loeschen" ); + OSL_ENSURE( INIT_FLDTYPES <= nFld, "don't remove InitFlds" ); /* - * Abheangige Felder vorhanden -> ErrRaise + * Dependent fields present -> ErrRaise */ sal_uInt16 nSize = pFldTypes->Count(); if(nFld < nSize) { SwFieldType* pTmp = (*pFldTypes)[nFld]; - // JP 29.07.96: opt. FeldListe fuer den Calculator vorbereiten: + // JP 29.07.96: Optionally prepare FldLst for Calculator sal_uInt16 nWhich = pTmp->Which(); switch( nWhich ) { case RES_SETEXPFLD: case RES_USERFLD: pUpdtFlds->RemoveFldType( *pTmp ); - // kein break; + // no break; case RES_DDEFLD: if( pTmp->GetDepends() && !IsUsed( *pTmp ) ) { @@ -260,8 +257,8 @@ void SwDoc::RemoveFldType(sal_uInt16 nFld) if( nWhich ) { - OSL_ENSURE( !pTmp->GetDepends(), "Abhaengige vorh.!" ); - // Feldtype loschen + OSL_ENSURE( !pTmp->GetDepends(), "Dependent fields present!" ); + // delete field type delete pTmp; } pFldTypes->Remove( nFld ); @@ -275,7 +272,7 @@ const SwFldTypes* SwDoc::GetFldTypes() const } /*-------------------------------------------------------------------- - Beschreibung: Den ersten Typen mit ResId und Namen finden + Description: Find first type with ResId and name --------------------------------------------------------------------*/ SwFieldType* SwDoc::GetFldType( sal_uInt16 nResId, const String& rName, bool bDbFieldMatching // used in some UNO calls for RES_DBFLD @@ -289,11 +286,10 @@ SwFieldType* SwDoc::GetFldType( sal_uInt16 nResId, const String& rName, switch( nResId ) { case RES_SETEXPFLD: - //JP 29.01.96: SequenceFelder beginnen aber bei INIT_FLDTYPES - 3!! - // Sonst gibt es doppelte Nummernkreise!! - //MIB 14.03.95: Ab sofort verlaesst sich auch der SW3-Reader - //beim Aufbau der String-Pools und beim Einlesen von SetExp-Feldern - //hierauf + //JP 29.01.96: SequenceFields start at INIT_FLDTYPES - 3!! + // Or we get doubble number circles!! + //MIB 14.03.95: From now on also the SW3-Reader relies on this, when + //constructing string pools and when reading SetExp fields i = INIT_FLDTYPES - INIT_SEQ_FLDTYPES; break; @@ -325,28 +321,28 @@ SwFieldType* SwDoc::GetFldType( sal_uInt16 nResId, const String& rName, } /************************************************************************* -|* SwDoc::UpdateFlds() -|* Beschreibung Felder updaten +|* SwDoc::UpdateFlds() +|* Description: Update fields *************************************************************************/ /* - * Alle sollen neu evaluiert werden. + * All have to be re-evaluated. */ void SwDoc::UpdateFlds( SfxPoolItem *pNewHt, bool bCloseDB ) { - // Modify() fuer jeden Feldtypen rufen, - // abhaengige SwTxtFld werden benachrichtigt ... + // Call modify() for every field type, + // dependent SwTxtFld get notified ... for( sal_uInt16 i=0; i < pFldTypes->Count(); ++i) { switch( (*pFldTypes)[i]->Which() ) { - // Tabellen-Felder als vorletztes Updaten - // Referenzen als letztes Updaten + // Update table fields second to last + // Update references at last case RES_GETREFFLD: case RES_TABLEFLD: case RES_DBFLD: case RES_JUMPEDITFLD: - case RES_REFPAGESETFLD: // werden nie expandiert! + case RES_REFPAGESETFLD: // are never expanded! break; case RES_DDEFLD: @@ -364,7 +360,7 @@ void SwDoc::UpdateFlds( SfxPoolItem *pNewHt, bool bCloseDB ) case RES_SETEXPFLD: case RES_HIDDENTXTFLD: case RES_HIDDENPARAFLD: - // Expression-Felder werden gesondert behandelt + // Expression fields are treated seperately if( !pNewHt ) break; default: @@ -373,18 +369,18 @@ void SwDoc::UpdateFlds( SfxPoolItem *pNewHt, bool bCloseDB ) } if( !IsExpFldsLocked() ) - UpdateExpFlds( 0, sal_False ); // Expression-Felder Updaten + UpdateExpFlds( 0, sal_False ); // update expression fields - // Tabellen + // Tables UpdateTblFlds(pNewHt); - // Referenzen + // References UpdateRefFlds(pNewHt); if( bCloseDB ) GetNewDBMgr()->CloseAll(); - // Nur bei KomplettUpdate evaluieren + // Only evaluate on CompleteUpdate SetModified(); } @@ -411,7 +407,7 @@ void SwDoc::UpdateUsrFlds() } /*-------------------------------------------------------------------- - Beschreibung: Referenzfelder und TableFelder erneuern + Description: Update reference and table fields --------------------------------------------------------------------*/ void SwDoc::UpdateRefFlds( SfxPoolItem* pHt ) { @@ -424,7 +420,7 @@ void SwDoc::UpdateRefFlds( SfxPoolItem* pHt ) void SwDoc::UpdateTblFlds( SfxPoolItem* pHt ) { OSL_ENSURE( !pHt || RES_TABLEFML_UPDATE == pHt->Which(), - "Was ist das fuer ein MessageItem?" ); + "What MessageItem is this?" ); SwFieldType* pFldType(0); @@ -445,7 +441,7 @@ void SwDoc::UpdateTblFlds( SfxPoolItem* pHt ) if( pUpdtFld ) { - // bestimme Tabelle, in der das Feld steht + // table where this field is located const SwTableNode* pTblNd; const SwTxtNode& rTxtNd = pFmtFld->GetTxtFld()->GetTxtNode(); if( !rTxtNd.GetNodes().IsDocNodes() || @@ -455,30 +451,30 @@ void SwDoc::UpdateTblFlds( SfxPoolItem* pHt ) switch( pUpdtFld->eFlags ) { case TBL_CALC: - // setze das Value-Flag zurueck - // JP 17.06.96: interne Darstellung auf alle Formeln - // (Referenzen auf andere Tabellen!!!) + // re-set the value flag + // JP 17.06.96: internal representation of all formulas + // (reference to other table!!!) if( nsSwExtendedSubType::SUB_CMD & pFld->GetSubType() ) pFld->PtrToBoxNm( pUpdtFld->pTbl ); else pFld->ChgValid( sal_False ); break; case TBL_BOXNAME: - // ist es die gesuchte Tabelle ?? + // is this the wanted table? if( &pTblNd->GetTable() == pUpdtFld->pTbl ) - // zur externen Darstellung + // to the external representation pFld->PtrToBoxNm( pUpdtFld->pTbl ); break; case TBL_BOXPTR: - // zur internen Darstellung - // JP 17.06.96: interne Darstellung auf alle Formeln - // (Referenzen auf andere Tabellen!!!) + // to the internal representation + // JP 17.06.96: internal representation on all formulas + // (reference to other table!!!) pFld->BoxNmToPtr( pUpdtFld->pTbl ); break; case TBL_RELBOXNAME: - // ist es die gesuchte Tabelle ?? + // is this the wanted table? if( &pTblNd->GetTable() == pUpdtFld->pTbl ) - // zur relativen Darstellung + // to the relative representation pFld->ToRelBoxNm( pUpdtFld->pTbl ); break; default: @@ -486,7 +482,7 @@ void SwDoc::UpdateTblFlds( SfxPoolItem* pHt ) } } else - // setze bei allen das Value-Flag zurueck + // reset the value flag for all pFld->ChgValid( sal_False ); } } @@ -496,7 +492,7 @@ void SwDoc::UpdateTblFlds( SfxPoolItem* pHt ) pFldType = 0; } - // und dann noch alle Tabellen Box Formeln abklappern + // process all table box formuals const SfxPoolItem* pItem; sal_uInt32 nMaxItems = GetAttrPool().GetItemCount2( RES_BOXATR_FORMULA ); for (sal_uInt32 i = 0; i < nMaxItems; ++i) @@ -509,7 +505,7 @@ void SwDoc::UpdateTblFlds( SfxPoolItem* pHt ) } - // alle Felder/Boxen sind jetzt invalide, also kann das Rechnen anfangen + // all fields/boxes are now invalid, so we can start to calculate if( pHt && ( RES_TABLEFML_UPDATE != pHt->Which() || TBL_CALC != ((SwTableFmlUpdate*)pHt)->eFlags )) return ; @@ -530,10 +526,10 @@ void SwDoc::UpdateTblFlds( SfxPoolItem* pHt ) (pFld = (SwTblField*)pFmtFld->GetFld())->GetSubType() )) continue; - // muss neu berechnet werden (und ist keine textuelle Anzeige) + // needs to be recalculated (and is no textual note) if( !pFld->IsValid() ) { - // bestimme Tabelle, in der das Feld steht + // table where this field is located const SwTxtNode& rTxtNd = pFmtFld->GetTxtFld()->GetTxtNode(); if( !rTxtNd.GetNodes().IsDocNodes() ) continue; @@ -541,8 +537,7 @@ void SwDoc::UpdateTblFlds( SfxPoolItem* pHt ) if( !pTblNd ) continue; - // falls dieses Feld nicht in der zu updatenden - // Tabelle steht, ueberspringen !! + // if this field is not in the to-be-updated table, skip it if( pHt && &pTblNd->GetTable() != ((SwTableFmlUpdate*)pHt)->pTbl ) continue; @@ -550,13 +545,13 @@ void SwDoc::UpdateTblFlds( SfxPoolItem* pHt ) if( !pCalc ) pCalc = new SwCalc( *this ); - // bestimme die Werte aller SetExpresion Felder, die - // bis zur Tabelle gueltig sind + // get the values of all SetExpresion fields, that are valid + // until the table SwFrm* pFrm = 0; if( pTblNd->GetIndex() < GetNodes().GetEndOfExtras().GetIndex() ) { - // steht im Sonderbereich, wird teuer !! - Point aPt; // den im Layout 1. Frame returnen - Tab.Kopfzeile !! + // is in the special section, that's expensive! + Point aPt; // return the first frame of the layout - Tab.Headline!! pFrm = rTxtNd.getLayoutFrm( GetCurrentLayout(), &aPt ); if( pFrm ) { @@ -571,7 +566,7 @@ void SwDoc::UpdateTblFlds( SfxPoolItem* pHt ) } if( !pFrm ) { - // einen Index fuers bestimmen vom TextNode anlegen + // create index to determine the TextNode SwNodeIndex aIdx( rTxtNd ); FldsToCalc( *pCalc, _SetGetExpFld( aIdx, pFmtFld->GetTxtFld() )); @@ -586,8 +581,8 @@ void SwDoc::UpdateTblFlds( SfxPoolItem* pHt ) #if OSL_DEBUG_LEVEL > 1 else { - // mind. ein ASSERT - OSL_ENSURE( !this, "die Kettenformel konnte nicht errechnet werden" ); + // at least one ASSERT + OSL_ENSURE( !this, "the chained formula could no be calculated" ); } #endif } @@ -597,7 +592,7 @@ void SwDoc::UpdateTblFlds( SfxPoolItem* pHt ) } } - // dann berechene noch die Formeln an den Boxen + // calculate the formula at the boxes for (sal_uInt32 i = 0; i < nMaxItems; ++i ) { if( 0 != (pItem = GetAttrPool().GetItem2( RES_BOXATR_FORMULA, i ) ) && @@ -617,13 +612,13 @@ void SwDoc::UpdateTblFlds( SfxPoolItem* pHt ) if( !pCalc ) pCalc = new SwCalc( *this ); - // bestimme die Werte aller SetExpresion Felder, die - // bis zur Tabelle gueltig sind + // get the values of all SetExpresion fields, that are valid + // until the table SwFrm* pFrm = 0; if( pTblNd->GetIndex() < GetNodes().GetEndOfExtras().GetIndex() ) { - // steht im Sonderbereich, wird teuer !! - Point aPt; // den im Layout 1. Frame returnen - Tab.Kopfzeile !! + // is in the special section, that's expensive! + Point aPt; // return the first frame of the layout - Tab.Headline!! SwNodeIndex aCNdIdx( *pTblNd, +2 ); SwCntntNode* pCNd = aCNdIdx.GetNode().GetCntntNode(); if( !pCNd ) @@ -640,7 +635,7 @@ void SwDoc::UpdateTblFlds( SfxPoolItem* pHt ) } if( !pFrm ) { - // einen Index fuers bestimmen vom TextNode anlegen + // create index to determine the TextNode SwNodeIndex aIdx( *pTblNd ); FldsToCalc( *pCalc, _SetGetExpFld( aIdx )); } @@ -655,8 +650,8 @@ void SwDoc::UpdateTblFlds( SfxPoolItem* pHt ) #if OSL_DEBUG_LEVEL > 1 else { - // mind. ein ASSERT - OSL_ENSURE( !this, "die Kettenformel konnte nicht errechnet werden" ); + // at least one ASSERT + OSL_ENSURE( !this, "the chained formula could no be calculated" ); } #endif } @@ -701,7 +696,7 @@ void SwDoc::UpdatePageFlds( SfxPoolItem* pMsgHnt ) SetNewFldLst(true); } -// ---- Loesche alle nicht referenzierten FeldTypen eines Dokumentes -- +// ---- Remove all unreferenced field types of a document -- void SwDoc::GCFieldTypes() { for( sal_uInt16 n = pFldTypes->Count(); n > INIT_FLDTYPES; ) @@ -740,8 +735,8 @@ void SwDoc::SetNewFldLst(bool bFlag) mbNewFldLst = bFlag; } -// der StartIndex kann optional mit angegeben werden (z.B. wenn dieser -// zuvor schon mal erfragt wurde - ist sonst eine virtuelle Methode !!) +// the StartIndex can be supplied optionally (e.g. if it was queried before - is a virtual +// method otherwise!) _SetGetExpFld::_SetGetExpFld( const SwNodeIndex& rNdIdx, const SwTxtFld* pFld, const SwIndex* pIdx ) { @@ -768,9 +763,9 @@ _SetGetExpFld::_SetGetExpFld( const SwNodeIndex& rNdIdx, nCntnt = *rINet.GetStart(); } -// Erweiterung fuer Sections: -// diese haben immer als Content-Position 0xffff !! -// Auf dieser steht nie ein Feld, maximal bis STRING_MAXLEN moeglich +// Extension for Sections: +// these always have content position 0xffff! +// There is never a field on this, only up to STRING_MAXLEN possible _SetGetExpFld::_SetGetExpFld( const SwSectionNode& rSectNd, const SwPosition* pPos ) { @@ -884,7 +879,7 @@ void _SetGetExpFld::SetBodyPos( const SwCntntFrm& rFrm ) SwDoc& rDoc = *aIdx.GetNodes().GetDoc(); SwPosition aPos( aIdx ); #if OSL_DEBUG_LEVEL > 1 - OSL_ENSURE( ::GetBodyTxtNode( rDoc, aPos, rFrm ), "wo steht das Feld" ); + OSL_ENSURE( ::GetBodyTxtNode( rDoc, aPos, rFrm ), "Where is the field?" ); #else ::GetBodyTxtNode( rDoc, aPos, rFrm ); #endif @@ -903,14 +898,14 @@ sal_Bool _SetGetExpFld::operator<( const _SetGetExpFld& rFld ) const const SwNode *pFirst = GetNodeFromCntnt(), *pNext = rFld.GetNodeFromCntnt(); - // Position gleich: nur weiter wenn beide FeldPointer besetzt sind !! + // Position is the same: continue only if both field pointers are set! if( !pFirst || !pNext ) return sal_False; - // gleiche Section ?? + // same Section? if( pFirst->StartOfSectionNode() != pNext->StartOfSectionNode() ) { - // sollte einer in der Tabelle stehen ? + // is one in the table? const SwNode *pFirstStt, *pNextStt; const SwTableNode* pTblNd = pFirst->FindTableNode(); if( pTblNd ) @@ -935,11 +930,11 @@ sal_Bool _SetGetExpFld::operator<( const _SetGetExpFld& rFld ) const } } - // ist gleiche Section, dann Feld im gleichen Node ? + // if it is the same section, then the field is in the same Node if( pFirst != pNext ) return pFirst->GetIndex() < pNext->GetIndex(); - // gleicher Node in der Section, dann Position im Node + // same Node in the Section, then Position in the Node return GetCntPosFromCntnt() < rFld.GetCntPosFromCntnt(); } @@ -1014,8 +1009,7 @@ _HashStr::_HashStr( const String& rName, const String& rText, pNext = pNxt; } -// suche nach dem Namen, ist er vorhanden, returne seinen String, sonst -// einen LeerString +// Look up the Name, if it is present, return it's String, otherwise return an empty String void LookString( SwHash** ppTbl, sal_uInt16 nSize, const String& rName, String& rRet, sal_uInt16* pPos ) { @@ -1062,10 +1056,10 @@ void lcl_CalcFld( SwDoc& rDoc, SwCalc& rCalc, const _SetGetExpFld& rSGEFld, if( nsSwGetSetExpType::GSE_EXPR & pFld->GetSubType() ) aValue.PutDouble( ((SwSetExpField*)pFld)->GetValue() ); else - // Erweiterung fuers Rechnen mit Strings + // Extension to calculate with Strings aValue.PutString( ((SwSetExpField*)pFld)->GetExpStr() ); - // setze im Calculator den neuen Wert + // set the new value in Calculator rCalc.VarChange( pFld->GetTyp()->GetName(), aValue ); } else if( pMgr ) @@ -1105,7 +1099,7 @@ void lcl_CalcFld( SwDoc& rDoc, SwCalc& rCalc, const _SetGetExpFld& rSGEFld, void SwDoc::FldsToCalc( SwCalc& rCalc, const _SetGetExpFld& rToThisFld ) { - // erzeuge die Sortierteliste aller SetFelder + // create the sorted list of all SetFields pUpdtFlds->MakeFldList( *this, mbNewFldLst, GETFLD_CALC ); mbNewFldLst = sal_False; @@ -1129,7 +1123,7 @@ void SwDoc::FldsToCalc( SwCalc& rCalc, const _SetGetExpFld& rToThisFld ) void SwDoc::FldsToCalc( SwCalc& rCalc, sal_uLong nLastNd, sal_uInt16 nLastCnt ) { - // erzeuge die Sortierteliste aller SetFelder + // create the sorted list of all SetFields pUpdtFlds->MakeFldList( *this, mbNewFldLst, GETFLD_CALC ); mbNewFldLst = sal_False; @@ -1152,12 +1146,12 @@ void SwDoc::FldsToCalc( SwCalc& rCalc, sal_uLong nLastNd, sal_uInt16 nLastCnt ) void SwDoc::FldsToExpand( SwHash**& ppHashTbl, sal_uInt16& rTblSize, const _SetGetExpFld& rToThisFld ) { - // erzeuge die Sortierteliste aller SetFelder + // create the sorted list of all SetFields pUpdtFlds->MakeFldList( *this, mbNewFldLst, GETFLD_EXPAND ); mbNewFldLst = sal_False; - // HashTabelle fuer alle String Ersetzungen, wird "one the fly" gefuellt - // (versuche eine "ungerade"-Zahl zu erzeugen) + // Hash table for all string replacements is filled on-the-fly. + // Try to fabricate an uneven number. rTblSize = (( pUpdtFlds->GetSortLst()->Count() / 7 ) + 1 ) * 7; ppHashTbl = new SwHash*[ rTblSize ]; memset( ppHashTbl, 0, sizeof( _HashStr* ) * rTblSize ); @@ -1185,27 +1179,27 @@ void SwDoc::FldsToExpand( SwHash**& ppHashTbl, sal_uInt16& rTblSize, case RES_SETEXPFLD: if( nsSwGetSetExpType::GSE_STRING & pFld->GetSubType() ) { - // setze in der HashTabelle den neuen Wert - // ist die "Formel" ein Feld ?? + // set the new value in the hash table + // is the formula a field? SwSetExpField* pSFld = (SwSetExpField*)pFld; LookString( ppHashTbl, rTblSize, pSFld->GetFormula(), aNew ); - if( !aNew.Len() ) // nichts gefunden, dann ist - aNew = pSFld->GetFormula(); // die Formel der neue Wert + if( !aNew.Len() ) // nothing found, then the formula is + aNew = pSFld->GetFormula(); // the new value // #i3141# - update expression of field as in method // for string/text fields pSFld->ChgExpStr( aNew ); - // suche den Namen vom Feld + // look up the field's name aNew = ((SwSetExpFieldType*)pSFld->GetTyp())->GetSetRefName(); - // Eintrag vorhanden ? + // Entry present? pFnd = Find( aNew, ppHashTbl, rTblSize, &nPos ); if( pFnd ) - // Eintrag in der HashTabelle aendern + // modify entry in the hash table ((_HashStr*)pFnd)->aSetStr = pSFld->GetExpStr(); else - // neuen Eintrag einfuegen + // insert the new entry *(ppHashTbl + nPos ) = new _HashStr( aNew, pSFld->GetExpStr(), (_HashStr*)*(ppHashTbl + nPos) ); } @@ -1214,18 +1208,18 @@ void SwDoc::FldsToExpand( SwHash**& ppHashTbl, sal_uInt16& rTblSize, { const String& rName = pFld->GetTyp()->GetName(); - // Eintrag in den HashTable eintragen - // Eintrag vorhanden ? + // Insert entry in the hash table + // Entry present? pFnd = Find( rName, ppHashTbl, rTblSize, &nPos ); String const value(pFld->ExpandField(IsClipBoard())); if( pFnd ) { - // Eintrag in der HashTabelle aendern + // modify entry in the hash table static_cast<_HashStr*>(pFnd)->aSetStr = value; } else { - // neuen Eintrag einfuegen + // insert the new entry *(ppHashTbl + nPos ) = new _HashStr( rName, value, static_cast<_HashStr *>(*(ppHashTbl + nPos))); } @@ -1258,30 +1252,30 @@ void SwDoc::UpdateExpFlds( SwTxtFld* pUpdtFld, bool bUpdRefFlds ) sal_uInt16 nWhich, n; - // HashTabelle fuer alle String Ersetzungen, wird "one the fly" gefuellt - // (versuche eine "ungerade"-Zahl zu erzeugen) + // Hash table for all string replacements is filled on-the-fly. + // Try to fabricate an uneven number. sal_uInt16 nStrFmtCnt = (( pFldTypes->Count() / 7 ) + 1 ) * 7; SwHash** pHashStrTbl = new SwHash*[ nStrFmtCnt ]; memset( pHashStrTbl, 0, sizeof( _HashStr* ) * nStrFmtCnt ); { const SwFieldType* pFldType; - // gesondert behandeln: + // process seperately: for( n = pFldTypes->Count(); n; ) switch( ( pFldType = (*pFldTypes)[ --n ] )->Which() ) { case RES_USERFLD: { - // Eintrag vorhanden ? + // Entry present? sal_uInt16 nPos; const String& rNm = pFldType->GetName(); String sExpand(((SwUserFieldType*)pFldType)->Expand(nsSwGetSetExpType::GSE_STRING, 0, 0)); SwHash* pFnd = Find( rNm, pHashStrTbl, nStrFmtCnt, &nPos ); if( pFnd ) - // Eintrag in der HashTabelle aendern ?? + // modify entry in the hash table ((_HashStr*)pFnd)->aSetStr = sExpand; else - // neuen Eintrag einfuegen + // insert the new entry *(pHashStrTbl + nPos ) = new _HashStr( rNm, sExpand, (_HashStr*)*(pHashStrTbl + nPos) ); } @@ -1292,12 +1286,12 @@ void SwDoc::UpdateExpFlds( SwTxtFld* pUpdtFld, bool bUpdRefFlds ) } } - // Ok, das Array ist soweit mit allen Feldern gefuellt, dann rechne mal + // The array is filled with all fields; start calculation. SwCalc aCalc( *this ); String sDBNumNm( SwFieldType::GetTypeStr( TYP_DBSETNUMBERFLD ) ); - // aktuelle Datensatznummer schon vorher einstellen + // already set the current record number SwNewDBMgr* pMgr = GetNewDBMgr(); pMgr->CloseAll(sal_False); @@ -1319,7 +1313,7 @@ void SwDoc::UpdateExpFlds( SwTxtFld* pUpdtFld, bool bUpdRefFlds ) SwTxtFld* pTxtFld = (SwTxtFld*)(*ppSortLst)->GetFld(); if( !pTxtFld ) { - OSL_ENSURE( !this, "was ist es denn nun" ); + OSL_ENSURE( !this, "what's wrong now'" ); continue; } @@ -1336,7 +1330,7 @@ void SwDoc::UpdateExpFlds( SwTxtFld* pUpdtFld, bool bUpdRefFlds ) if(!aValue.IsVoidValue()) { pHFld->SetValue( bValue ); - // Feld Evaluieren + // evaluate field pHFld->Evaluate(this); } } @@ -1362,7 +1356,7 @@ void SwDoc::UpdateExpFlds( SwTxtFld* pUpdtFld, bool bUpdRefFlds ) break; case RES_DBFLD: { - // Feld Evaluieren + // evaluate field ((SwDBField*)pFld)->Evaluate(); SwDBData aTmpDBData(((SwDBField*)pFld)->GetDBData()); @@ -1372,25 +1366,25 @@ void SwDoc::UpdateExpFlds( SwTxtFld* pUpdtFld, bool bUpdRefFlds ) const String& rName = pFld->GetTyp()->GetName(); - // Wert fuer den Calculator setzen -//JP 10.02.96: GetValue macht hier doch keinen Sinn + // Set value for Calculator +//JP 10.02.96: GetValue doesn't make sense here // ((SwDBField*)pFld)->GetValue(); //!OK aCalc.VarChange(aName, ((SwDBField*)pFld)->GetValue(aCalc)); - // Eintrag in den HashTable eintragen - // Eintrag vorhanden ? + // Add entry to hash table + // Entry present? sal_uInt16 nPos; SwHash* pFnd = Find( rName, pHashStrTbl, nStrFmtCnt, &nPos ); String const value(pFld->ExpandField(IsClipBoard())); if( pFnd ) { - // Eintrag in der HashTabelle aendern + // Modify entry in the hash table static_cast<_HashStr*>(pFnd)->aSetStr = value; } else { - // neuen Eintrag einfuegen + // insert new entry *(pHashStrTbl + nPos ) = new _HashStr( rName, value, static_cast<_HashStr *>(*(pHashStrTbl + nPos))); } @@ -1399,7 +1393,7 @@ void SwDoc::UpdateExpFlds( SwTxtFld* pUpdtFld, bool bUpdRefFlds ) case RES_GETEXPFLD: case RES_SETEXPFLD: { - if( nsSwGetSetExpType::GSE_STRING & pFld->GetSubType() ) // String Ersetzung + if( nsSwGetSetExpType::GSE_STRING & pFld->GetSubType() ) // replace String { if( RES_GETEXPFLD == nWhich ) { @@ -1416,38 +1410,38 @@ void SwDoc::UpdateExpFlds( SwTxtFld* pUpdtFld, bool bUpdRefFlds ) else { SwSetExpField* pSFld = (SwSetExpField*)pFld; - // ist die "Formel" ein Feld ?? + // is the "formula" a field? LookString( pHashStrTbl, nStrFmtCnt, pSFld->GetFormula(), aNew ); - if( !aNew.Len() ) // nichts gefunden, dann ist die - aNew = pSFld->GetFormula(); // Formel der neue Wert + if( !aNew.Len() ) // nothing found then the formula is the new value + aNew = pSFld->GetFormula(); - // nur ein spezielles FeldUpdaten ? + // only update one field if( !pUpdtFld || pUpdtFld == pTxtFld ) pSFld->ChgExpStr( aNew ); - // suche den Namen vom Feld + // lookup the field's name aNew = ((SwSetExpFieldType*)pSFld->GetTyp())->GetSetRefName(); - // Eintrag vorhanden ? + // Entry present? sal_uInt16 nPos; SwHash* pFnd = Find( aNew, pHashStrTbl, nStrFmtCnt, &nPos ); if( pFnd ) - // Eintrag in der HashTabelle aendern + // Modify entry in the hash table ((_HashStr*)pFnd)->aSetStr = pSFld->GetExpStr(); else - // neuen Eintrag einfuegen + // insert new entry *(pHashStrTbl + nPos ) = pFnd = new _HashStr( aNew, pSFld->GetExpStr(), (_HashStr*)*(pHashStrTbl + nPos) ); - // Erweiterung fuers Rechnen mit Strings + // Extension for calculation with Strings SwSbxValue aValue; aValue.PutString( ((_HashStr*)pFnd)->aSetStr ); aCalc.VarChange( aNew, aValue ); } } - else // Formel neu berechnen + else // recalculate formula { if( RES_GETEXPFLD == nWhich ) { @@ -1475,7 +1469,7 @@ void SwDoc::UpdateExpFlds( SwTxtFld* pUpdtFld, bool bUpdRefFlds ) const sal_uInt8 nLvl = pSFldTyp->GetOutlineLvl(); if( MAXLEVEL > nLvl ) { - // dann teste, ob die Nummer neu aufsetzen muss + // test if the Number needs to be updated pSeqNd = GetNodes()[ (*ppSortLst)->GetNode() ]; const SwTxtNode* pOutlNd = pSeqNd-> @@ -1493,7 +1487,7 @@ void SwDoc::UpdateExpFlds( SwTxtFld* pUpdtFld, bool bUpdRefFlds ) SwSbxValue aValue = aCalc.Calculate( aNew ); double nErg = aValue.GetDouble(); - // nur ein spezielles Feld updaten ? + // only update one field if( !aValue.IsVoidValue() && (!pUpdtFld || pUpdtFld == pTxtFld) ) { pSFld->SetValue( nErg ); @@ -1506,23 +1500,23 @@ void SwDoc::UpdateExpFlds( SwTxtFld* pUpdtFld, bool bUpdRefFlds ) } } // switch - pFmtFld->ModifyNotification( 0, 0 ); // Formatierung anstossen + pFmtFld->ModifyNotification( 0, 0 ); // trigger formatting - if( pUpdtFld == pTxtFld ) // sollte nur dieses geupdatet werden + if( pUpdtFld == pTxtFld ) // if only this one is updated { - if( RES_GETEXPFLD == nWhich || // nur GetFeld oder + if( RES_GETEXPFLD == nWhich || // only GetField or RES_HIDDENTXTFLD == nWhich || // HiddenTxt? RES_HIDDENPARAFLD == nWhich) // HiddenParaFld? - break; // beenden - pUpdtFld = 0; // ab jetzt alle Updaten + break; // quit + pUpdtFld = 0; // update all from here on } } pMgr->CloseAll(sal_False); - // HashTabelle wieder loeschen + // delete hash table ::DeleteHashTable( pHashStrTbl, nStrFmtCnt ); - // Referenzfelder updaten + // update reference fields if( bUpdRefFlds ) UpdateRefFlds(NULL); @@ -1545,7 +1539,7 @@ void SwDoc::UpdateDBNumFlds( SwDBNameInfField& rDBFld, SwCalc& rCalc ) if( rDBFld.GetRealDBData().sDataSource.getLength() ) { - // Eine bestimmte Datenbank bearbeiten + // Edit a certain database if( RES_DBNEXTSETFLD == nFldType ) ((SwDBNextSetField&)rDBFld).Evaluate(this); else @@ -1563,9 +1557,9 @@ void SwDoc::UpdateDBNumFlds( SwDBNameInfField& rDBFld, SwCalc& rCalc ) } } -void SwDoc::_InitFieldTypes() // wird vom CTOR gerufen!! +void SwDoc::_InitFieldTypes() // is being called by the CTOR { - // Feldtypen + // Field types sal_uInt16 nFldType = 0; pFldTypes->Insert( new SwDateTimeFieldType(this), nFldType++ ); pFldTypes->Insert( new SwChapterFieldType, nFldType++ ); @@ -1596,10 +1590,10 @@ void SwDoc::_InitFieldTypes() // wird vom CTOR gerufen!! pFldTypes->Insert( new SwCombinedCharFieldType, nFldType++ ); pFldTypes->Insert( new SwDropDownFieldType, nFldType++ ); - // Types muessen am Ende stehen !! - // Im InsertFldType wird davon ausgegangen !!!! - // MIB 14.04.95: Im Sw3StringPool::Setup (sw3imp.cxx) und - // lcl_sw3io_InSetExpField (sw3field.cxx) jetzt auch + // Types have to be at the end! + // We expect this in the InsertFldType! + // MIB 14.04.95: In Sw3StringPool::Setup (sw3imp.cxx) and + // lcl_sw3io_InSetExpField (sw3field.cxx) now also pFldTypes->Insert( new SwSetExpFieldType(this, SW_RESSTR(STR_POOLCOLL_LABEL_ABB), nsSwGetSetExpType::GSE_SEQ), nFldType++); pFldTypes->Insert( new SwSetExpFieldType(this, @@ -1672,7 +1666,7 @@ void SwDoc::SetInitDBFields( sal_Bool b ) } /*-------------------------------------------------------------------- - Beschreibung: Alle von Feldern verwendete Datenbanken herausfinden + Description: Get all databases that are used by fields --------------------------------------------------------------------*/ String lcl_DBDataToString(const SwDBData& rData) { @@ -1740,7 +1734,7 @@ void SwDoc::GetAllUsedDB( SvStringsDtor& rDBNameList, case RES_DBNEXTSETFLD: AddUsedDBToList( rDBNameList, lcl_DBDataToString(((SwDBNameInfField*)pFld)->GetRealDBData() )); - // kein break // JP: ist das so richtig ?? + // no break // JP: is that right like that? case RES_HIDDENTXTFLD: case RES_HIDDENPARAFLD: @@ -1794,7 +1788,7 @@ SvStringsDtor& SwDoc::FindUsedDBs( const SvStringsDtor& rAllDBNames, sFormel.GetChar( nPos + pStr->Len() ) == '.' && (!nPos || !rCC.isLetterNumeric( sFormel, nPos - 1 ))) { - // Tabellenname suchen + // Look up table name xub_StrLen nEndPos; nPos += pStr->Len() + 1; if( STRING_NOTFOUND != (nEndPos = sFormel.Search('.', nPos)) ) @@ -1918,7 +1912,7 @@ void SwDoc::ChangeDBFields( const SvStringsDtor& rOldNames, ((SwDBNameInfField*)pFld)->SetDBData(aNewDBData); bExpand = sal_True; } - // kein break; + // no break; case RES_HIDDENTXTFLD: case RES_HIDDENPARAFLD: sFormel = pFld->GetPar1(); @@ -2020,7 +2014,7 @@ void SwDoc::SetFixFields( bool bOnlyTimeDate, const DateTime* pNewDateTime ) /*1*/ RES_AUTHORFLD, /*2*/ RES_EXTUSERFLD, /*3*/ RES_FILENAMEFLD, - /*4*/ RES_DATETIMEFLD }; // MUSS am Ende stehen!! + /*4*/ RES_DATETIMEFLD }; // MUST be at the end! sal_uInt16 nStt = bOnlyTimeDate ? 4 : 0; @@ -2094,7 +2088,7 @@ void SwDoc::SetFixFields( bool bOnlyTimeDate, const DateTime* pNewDateTime ) break; } - // Formatierung anstossen + // Trigger formatting if( bChgd ) pFld->ModifyNotification( 0, 0 ); } @@ -2107,11 +2101,11 @@ void SwDoc::SetFixFields( bool bOnlyTimeDate, const DateTime* pNewDateTime ) bool SwDoc::SetFieldsDirty( bool b, const SwNode* pChk, sal_uLong nLen ) { - // teste ggfs. mal, ob die angegbenen Nodes ueberhaupt Felder beinhalten. - // wenn nicht, braucht das Flag nicht veraendert werden. + // See if the supplied nodes actually contain fields. + // If they don't, the flag doesn't need to be changed. sal_Bool bFldsFnd = sal_False; if( b && pChk && !GetUpdtFlds().IsFieldsDirty() && !IsInDtor() - // ?? was ist mit Undo, da will man es doch auch haben !! + // ?? what's up with Undo, this is also wanted there! /*&& &pChk->GetNodes() == &GetNodes()*/ ) { b = sal_False; @@ -2125,7 +2119,7 @@ bool SwDoc::SetFieldsDirty( bool b, const SwNode* pChk, sal_uLong nLen ) if( pTNd ) { if( pTNd->GetAttrOutlineLevel() != 0 ) - // Kapitelfelder aktualisieren + // update chapter fields b = sal_True; else if( pTNd->GetpSwpHints() && pTNd->GetSwpHints().Count() ) for( sal_uInt16 n = 0, nEnd = pTNd->GetSwpHints().Count(); @@ -2179,7 +2173,7 @@ void SwDocUpdtFld::InsDelFldInFldLst( sal_Bool bIns, const SwTxtFld& rFld ) case RES_DBNEXTSETFLD: case RES_DBSETNUMBERFLD: case RES_GETEXPFLD: - break; // diese muessen ein-/ausgetragen werden! + break; // these have to be added/removed! default: return; @@ -2188,22 +2182,21 @@ void SwDocUpdtFld::InsDelFldInFldLst( sal_Bool bIns, const SwTxtFld& rFld ) SetFieldsDirty( sal_True ); if( !pFldSortLst ) { - if( !bIns ) // keine Liste vorhanden und loeschen - return; // dann nichts tun + if( !bIns ) // if list is present and deleted + return; // don't do a thing pFldSortLst = new _SetGetExpFlds( 64, 16 ); } - if( bIns ) // neu einfuegen: + if( bIns ) // insert anew: GetBodyNode( rFld, nWhich ); else { - // ueber den pTxtFld Pointer suchen. Ist zwar eine Sortierte - // Liste, aber nach Node-Positionen sortiert. Bis dieser - // bestimmt ist, ist das Suchen nach dem Pointer schon fertig + // look up via the pTxtFld pointer. It is a sorted list, but it's sorted by node + // position. Until this is found, the search for the pointer is already done. for( sal_uInt16 n = 0; n < pFldSortLst->Count(); ++n ) if( &rFld == (*pFldSortLst)[ n ]->GetPointer() ) pFldSortLst->DeleteAndDestroy( n--, 1 ); - // ein Feld kann mehrfach vorhanden sein! + // one field can occur multiple times } } @@ -2216,7 +2209,7 @@ void SwDocUpdtFld::MakeFldList( SwDoc& rDoc, int bAll, int eGetMode ) void SwDocUpdtFld::_MakeFldList( SwDoc& rDoc, int eGetMode ) { - // neue Version: gehe ueber alle Felder vom Attribut-Pool + // new version: walk all fields of the attribute pool if( pFldSortLst ) delete pFldSortLst; pFldSortLst = new _SetGetExpFlds( 64, 16 ); @@ -2234,12 +2227,11 @@ void SwDocUpdtFld::_MakeFldList( SwDoc& rDoc, int eGetMode ) /// have to be known in order to insert the hide condition as a new /// expression field into the sorted field list (). if ( eGetMode == GETFLD_ALL ) - // zuerst die Bereiche einsammeln. Alle die ueber Bedingung - // gehiddet sind, wieder mit Frames versorgen, damit die darin - // enthaltenen Felder richtig einsortiert werden!!! + // Collect the ranges first. Supply all with frames, which are hidden by condition, + // so that the contained fields are not sorted. { - // damit die Frames richtig angelegt werden, muessen sie in der - // Reihenfolgen von oben nach unten expandiert werden + // In order for the frames to be created the right way, they have to be expanded + // from top to bottom std::vector aTmpArr; SwSectionFmts& rArr = rDoc.GetSections(); SwSectionNode* pSectNd; @@ -2260,23 +2252,22 @@ void SwDocUpdtFld::_MakeFldList( SwDoc& rDoc, int eGetMode ) } std::sort(aTmpArr.begin(), aTmpArr.end()); - // erst alle anzeigen, damit die Frames vorhanden sind. Mit deren - // Position wird das BodyAnchor ermittelt. - // Dafuer erst den ContentBereich, dann die Sonderbereiche!!! + // Display all first so that we have frames. The BodyAnchor is defined by that. + // First the ContentArea, then the special areas! for (sal_uInt16 n = nArrStt; n < aTmpArr.size(); ++n) { pSectNd = rDoc.GetNodes()[ aTmpArr[ n ] ]->GetSectionNode(); - OSL_ENSURE( pSectNd, "Wo ist mein SectionNode" ); + OSL_ENSURE( pSectNd, "Where is my SectionNode" ); pSectNd->GetSection().SetCondHidden( sal_False ); } for (sal_uInt16 n = 0; n < nArrStt; ++n) { pSectNd = rDoc.GetNodes()[ aTmpArr[ n ] ]->GetSectionNode(); - OSL_ENSURE( pSectNd, "Wo ist mein SectionNode" ); + OSL_ENSURE( pSectNd, "Where is my SectionNode" ); pSectNd->GetSection().SetCondHidden( sal_False ); } - // so, erst jetzt alle sortiert in die Liste eintragen + // add all to the list so that they are sorted for (sal_uInt16 n = 0; n < aTmpArr.size(); ++n) { GetBodyNode( *rDoc.GetNodes()[ aTmpArr[ n ] ]->GetSectionNode() ); @@ -2337,7 +2328,7 @@ void SwDocUpdtFld::_MakeFldList( SwDoc& rDoc, int eGetMode ) break; pFormel = 0; - // Formatierung anstossen + // trigger formatting ((SwFmtFld*)pFmtFld)->ModifyNotification( 0, 0 ); } break; @@ -2355,9 +2346,9 @@ void SwDocUpdtFld::_MakeFldList( SwDoc& rDoc, int eGetMode ) pFormel = 0; - // Feld Evaluieren + // evaluate field ((SwHiddenTxtField*)pFld)->Evaluate(&rDoc); - // Formatierung anstossen + // trigger formatting ((SwFmtFld*)pFmtFld)->ModifyNotification( 0, 0 ); } break; @@ -2405,7 +2396,7 @@ void SwDocUpdtFld::GetBodyNode( const SwTxtFld& rTFld, sal_uInt16 nFldWhich ) const SwTxtNode& rTxtNd = rTFld.GetTxtNode(); const SwDoc& rDoc = *rTxtNd.GetDoc(); - // immer den ersten !! (in Tab-Headline, Kopf-/Fuss ) + // always the first! (in tab headline, header-/footer) Point aPt; const SwCntntFrm* pFrm = rTxtNd.getLayoutFrm( rDoc.GetCurrentLayout(), &aPt, 0, sal_False ); @@ -2414,7 +2405,7 @@ void SwDocUpdtFld::GetBodyNode( const SwTxtFld& rTFld, sal_uInt16 nFldWhich ) if( !pFrm || pFrm->IsInDocBody() ) { - // einen Index fuers bestimmen vom TextNode anlegen + // create index to determine the TextNode SwNodeIndex aIdx( rTxtNd ); bIsInBody = rDoc.GetNodes().GetEndOfExtras().GetIndex() < aIdx.GetIndex(); @@ -2427,7 +2418,7 @@ void SwDocUpdtFld::GetBodyNode( const SwTxtFld& rTFld, sal_uInt16 nFldWhich ) } else { - // einen Index fuers bestimmen vom TextNode anlegen + // create index to determine the TextNode SwPosition aPos( rDoc.GetNodes().GetEndOfPostIts() ); #if OSL_DEBUG_LEVEL > 1 OSL_ENSURE( GetBodyTxtNode( rDoc, aPos, *pFrm ), "wo steht das Feld" ); @@ -2437,7 +2428,7 @@ void SwDocUpdtFld::GetBodyNode( const SwTxtFld& rTFld, sal_uInt16 nFldWhich ) pNew = new _SetGetExpFld( aPos.nNode, &rTFld, &aPos.nContent ); } - // bei GetExp.-/DB.-Felder immer das BodyTxtFlag setzen + // always set the BodyTxtFlag in GetExp or DB fields if( RES_GETEXPFLD == nFldWhich ) { SwGetExpField* pGetFld = (SwGetExpField*)rTFld.GetFld().GetFld(); @@ -2463,15 +2454,15 @@ void SwDocUpdtFld::GetBodyNode( const SwSectionNode& rSectNd ) { do { // middle check loop - // dann muessen wir uns mal den Anker besorgen! - // einen Index fuers bestimmen vom TextNode anlegen + // we need to get the anchor first + // create index to determine the TextNode SwPosition aPos( rSectNd ); - SwCntntNode* pCNd = rDoc.GetNodes().GoNext( &aPos.nNode ); // zum naechsten ContentNode + SwCntntNode* pCNd = rDoc.GetNodes().GoNext( &aPos.nNode ); // to the next ContentNode if( !pCNd || !pCNd->IsTxtNode() ) break; - // immer den ersten !! (in Tab-Headline, Kopf-/Fuss ) + // always the first! (in tab headline, header-/footer) Point aPt; const SwCntntFrm* pFrm = pCNd->getLayoutFrm( rDoc.GetCurrentLayout(), &aPt, 0, sal_False ); if( !pFrm ) @@ -2512,7 +2503,7 @@ void SwDocUpdtFld::InsertFldType( const SwFieldType& rType ) if( sFldName.Len() ) { SetFieldsDirty( sal_True ); - // suchen und aus der HashTabelle entfernen + // look up and remove from the hash table GetAppCharClass().toLower( sFldName ); sal_uInt16 n; @@ -2543,7 +2534,7 @@ void SwDocUpdtFld::RemoveFldType( const SwFieldType& rType ) if( sFldName.Len() ) { SetFieldsDirty( sal_True ); - // suchen und aus der HashTabelle entfernen + // look up and remove from the hash table GetAppCharClass().toLower( sFldName ); sal_uInt16 n; @@ -2654,9 +2645,8 @@ bool SwDoc::UpdateFld(SwTxtFld * pDstTxtFld, SwField & rSrcFld, case RES_DBFLD: { - // JP 10.02.96: ChgValue aufrufen, damit - //die Format- aenderung den ContentString - //richtig setzt + // JP 10.02.96: call ChgValue, so that the style change sets the + // ContentString correctly SwDBField* pDBFld = (SwDBField*)pNewFld; if (pDBFld->IsInitialized()) pDBFld->ChgValue( pDBFld->GetValue(), sal_True ); @@ -2664,14 +2654,13 @@ bool SwDoc::UpdateFld(SwTxtFld * pDstTxtFld, SwField & rSrcFld, pDBFld->ClearInitialized(); pDBFld->InitContent(); } - // kein break; + // no break; default: pDstFmtFld->ModifyNotification( 0, pMsgHnt ); } - // Die Felder die wir berechnen koennen werden hier expli. - // zum Update angestossen. + // The fields we can calculate here are being triggered for an update here explicitily. if( nFldWhich == RES_USERFLD ) UpdateUsrFlds(); } -- cgit From 249faa5cb64a7270e852862a26b4a5e3a69a9895 Mon Sep 17 00:00:00 2001 From: Kevin Hunter Date: Mon, 31 Oct 2011 13:23:06 -0400 Subject: Move ScPostIt storage from ScBaseCell->ScDocument ScPostIt is the behind-the-scenes name for Notes. This move removes a usually empty pointer for each ScBaseCell to list of pointers within ScDocument. The advantage is basically a reduction in size of 8 bytes per cell. The current sizeof(ScBaseCell) is 16. Here are the highlights: * Remove mpNote from ScBaseCell, and add a std::map (data structure) to ScDocument to store notes and associate with addresses. * Remove ScPostIt accessors and mutators from ScTable, ScColumn, and ScBaseCell * Replace ScPostIt accessors and mutators in ScDocument with ones to handle move of data structure from ScBaseCell to ScDocument * Rename ScPostIt.CloneWithoutNote to ScPostIt.Clone, while completely removing ScPostIt.CloneWithNote. Any cloning of cell notes must now be handled outside external to the ScPostIt class, through ScDocument.*Note() functions. * Rename ScNoteCell to a more ScEmptyCell. I expect this can be completely removed at some point the future, if we can handle broadcasters external to the cell logic. * Add ScDocument and ScTable to ScUsedAreaIterator data structure to accomodate for new placement of ScPostIt objects in ScDocument. * Convert CELLTYPE_NOTE to CELLTYPE_EMPTY (and all ensuing uses). * Wherever possible, respect 80-columns. * New ScDocument based API (individually block-comment documented before their definitions): SC_DLLPUBLIC ScPostIt* GetNote( ScAddress const & ); SC_DLLPUBLIC ScPostIt* GetOrCreateNote( const ScAddress& rPos ); bool SetNote( ScAddress const &, ScPostIt* ); bool MoveNote( ScAddress const & from, ScAddress const & to ); bool SwapNotes( ScAddress const &, ScAddress const & ); ScPostIt* ReleaseNote( ScAddress const & ); void DeleteNote( ScAddress const & ); Of note, TakeNote has been replaced with SetNote, which returns true on success, and false on failure. TakeNote indicated failure by removing the passed note. The SetNote approach leaves room for the caller to attempt to fix the issue, but also means the caller is now on the hook to cleanup the memory. For now, the Calc-internal API is lazy and does not take advantage of this, but merely says "You failed? Oh well, delete the note." ... which is exactly what TakeNote did. This means, the lazy-programmer's idiom for SetNote use is: if ( ! pDoc->SetNote( aAddress, pNotePointer ) ) DELETEZ( pNotePointer ); --- sc/inc/cell.hxx | 64 +++---- sc/inc/column.hxx | 9 - sc/inc/dociter.hxx | 2 + sc/inc/document.hxx | 19 +- sc/inc/global.hxx | 2 +- sc/inc/table.hxx | 8 - sc/source/core/data/autonamecache.cxx | 2 +- sc/source/core/data/cell.cxx | 86 +++------ sc/source/core/data/cell2.cxx | 2 +- sc/source/core/data/column.cxx | 66 ++++--- sc/source/core/data/column2.cxx | 112 +++++++++--- sc/source/core/data/column3.cxx | 195 ++++++++++----------- sc/source/core/data/dociter.cxx | 18 +- sc/source/core/data/documen2.cxx | 1 - sc/source/core/data/documen4.cxx | 16 +- sc/source/core/data/document.cxx | 188 +++++++++++++++++--- sc/source/core/data/fillinfo.cxx | 2 +- sc/source/core/data/postit.cxx | 22 +-- sc/source/core/data/table1.cxx | 4 +- sc/source/core/data/table2.cxx | 57 ++---- sc/source/core/data/table3.cxx | 11 +- sc/source/core/data/table4.cxx | 6 +- sc/source/core/data/table6.cxx | 30 ++-- sc/source/core/tool/chartlis.cxx | 2 +- sc/source/core/tool/chgtrack.cxx | 10 +- sc/source/core/tool/compiler.cxx | 4 +- sc/source/core/tool/interpr1.cxx | 14 +- sc/source/core/tool/interpr2.cxx | 13 +- sc/source/core/tool/interpr4.cxx | 4 +- sc/source/filter/dif/difexp.cxx | 2 +- sc/source/filter/excel/xetable.cxx | 4 +- sc/source/filter/html/htmlexp.cxx | 2 +- sc/source/filter/lotus/expop.cxx | 2 +- sc/source/filter/rtf/rtfexp.cxx | 2 +- .../filter/xml/XMLChangeTrackingImportHelper.cxx | 6 +- sc/source/filter/xml/xmlcelli.cxx | 2 +- sc/source/ui/docshell/dbdocfun.cxx | 5 +- sc/source/ui/docshell/docfunc.cxx | 6 +- sc/source/ui/docshell/docsh.cxx | 4 +- sc/source/ui/docshell/docsh8.cxx | 4 +- sc/source/ui/docshell/impex.cxx | 4 +- sc/source/ui/navipi/content.cxx | 8 +- sc/source/ui/undo/undocell.cxx | 11 +- sc/source/ui/unoobj/cellsuno.cxx | 18 +- sc/source/ui/unoobj/chart2uno.cxx | 2 +- sc/source/ui/unoobj/docuno.cxx | 9 +- sc/source/ui/unoobj/funcuno.cxx | 2 +- sc/source/ui/view/cellsh.cxx | 2 +- sc/source/ui/view/gridwin.cxx | 2 +- sc/source/ui/view/output.cxx | 27 ++- sc/source/ui/view/output2.cxx | 2 +- sc/source/ui/view/printfun.cxx | 8 +- sc/source/ui/view/spelleng.cxx | 4 +- sc/source/ui/view/viewfunc.cxx | 6 +- 54 files changed, 633 insertions(+), 480 deletions(-) diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx index 7551ba693b15..c1d5cf2a2873 100644 --- a/sc/inc/cell.hxx +++ b/sc/inc/cell.hxx @@ -65,7 +65,7 @@ class ScPatternAttr; // ============================================================================ /** Default cell clone flags: do not start listening, do not adjust 3D refs to - old position, clone note captions of cell notes. */ + old position. Note: Notes must be cloned separately, through ScDocument.*/ const int SC_CLONECELL_DEFAULT = 0x0000; /** If set, cloned formula cells will start to listen to the document. */ @@ -92,27 +92,29 @@ public: /** Base copy constructor. Does NOT clone cell note or broadcaster! */ ScBaseCell( const ScBaseCell& rCell ); - /** Returns a clone of this cell at the same position, cell note and - broadcaster will not be cloned. */ - ScBaseCell* CloneWithoutNote( ScDocument& rDestDoc, int nCloneFlags = SC_CLONECELL_DEFAULT ) const; + /** Returns a clone of this cell at the same position; cell broadcaster + will not be cloned. */ + ScBaseCell* Clone( ScDocument& rDestDoc, + int nCloneFlags = SC_CLONECELL_DEFAULT ) const; /** Returns a clone of this cell for the passed document position, cell - note and broadcaster will not be cloned. */ - ScBaseCell* CloneWithoutNote( ScDocument& rDestDoc, const ScAddress& rDestPos, int nCloneFlags = SC_CLONECELL_DEFAULT ) const; - - /** Returns a clone of this cell, clones cell note and caption object too - (unless SC_CLONECELL_NOCAPTION flag is set). Broadcaster will not be cloned. */ - ScBaseCell* CloneWithNote( const ScAddress& rOwnPos, ScDocument& rDestDoc, const ScAddress& rDestPos, int nCloneFlags = SC_CLONECELL_DEFAULT ) const; + broadcaster will not be cloned. */ + ScBaseCell* Clone( ScDocument& rDestDoc, const ScAddress& rDestPos, + int nCloneFlags = SC_CLONECELL_DEFAULT ) const; /** Due to the fact that ScBaseCell does not have a vtable, this function - deletes the cell by calling the appropriate d'tor of the derived class. */ + deletes the cell by calling the appropriate d'tor of the derived class. + */ void Delete(); inline CellType GetCellType() const { return (CellType)eCellType; } - /** Returns true, if the cell is empty (neither value nor formula nor cell note). - Returns false for formula cells returning nothing, use HasEmptyData() for that. */ - bool IsBlank( bool bIgnoreNotes = false ) const; + /** Returns true, if the cell is empty (neither value nor formula). + Returns false for formula cells returning nothing; use HasEmptyData() + for that. + Does *not* check for notes; use ScDocument.GetNote() for that. + */ + bool IsBlank( ) const; // for idle-calculations inline sal_uInt16 GetTextWidth() const { return nTextWidth; } @@ -121,18 +123,6 @@ public: inline sal_uInt8 GetScriptType() const { return nScriptType; } inline void SetScriptType( sal_uInt8 nNew ) { nScriptType = nNew; } - /** Returns true, if the cell contains a note. */ - inline bool HasNote() const { return mpNote != 0; } - /** Returns the pointer to a cell note object (read-only). */ - inline const ScPostIt* GetNote() const { return mpNote; } - /** Returns the pointer to a cell note object. */ - inline ScPostIt* GetNote() { return mpNote; } - /** Takes ownership of the passed cell note object. */ - void TakeNote( ScPostIt* pNote ); - /** Returns and forgets the own cell note object. Caller takes ownership! */ - ScPostIt* ReleaseNote(); - /** Deletes the own cell note object. */ - void DeleteNote(); /** Returns true, if the cell contains a broadcaster. */ inline bool HasBroadcaster() const { return mpBroadcaster != 0; } @@ -156,20 +146,20 @@ public: /** Error code if ScFormulaCell, else 0. */ sal_uInt16 GetErrorCode() const; - /** ScFormulaCell with formula::svEmptyCell result, or ScNoteCell (may have been - created due to reference to empty cell). */ + + /** ScFormulaCell with formula::svEmptyCell result, or ScEmptyCell */ bool HasEmptyData() const; bool HasValueData() const; bool HasStringData() const; String GetStringData() const; // only real strings + static bool CellEqual( const ScBaseCell* pCell1, const ScBaseCell* pCell2 ); private: ScBaseCell& operator=( const ScBaseCell& ); private: - ScPostIt* mpNote; /// The cell note. Cell takes ownership! SvtBroadcaster* mpBroadcaster; /// Broadcaster for changed values. Cell takes ownership! protected: @@ -180,26 +170,24 @@ protected: // ============================================================================ -class SC_DLLPUBLIC ScNoteCell : public ScBaseCell + +// Empty cell to take broadcaster +class SC_DLLPUBLIC ScEmptyCell : public ScBaseCell { public: #ifdef USE_MEMPOOL - DECL_FIXEDMEMPOOL_NEWDEL( ScNoteCell ) + DECL_FIXEDMEMPOOL_NEWDEL( ScEmptyCell ) #endif /** Cell takes ownership of the passed broadcaster. */ - explicit ScNoteCell( SvtBroadcaster* pBC = 0 ); - /** Cell takes ownership of the passed note and broadcaster. */ - explicit ScNoteCell( ScPostIt* pNote, SvtBroadcaster* pBC = 0 ); + explicit ScEmptyCell( SvtBroadcaster* pBC = 0 ); #if OSL_DEBUG_LEVEL > 0 - ~ScNoteCell(); + ~ScEmptyCell(); #endif - -private: - ScNoteCell( const ScNoteCell& ); }; + class SC_DLLPUBLIC ScValueCell : public ScBaseCell { public: diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index 7e21ba884740..b665e399aaee 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -265,15 +265,6 @@ public: bool HasValueData( SCROW nRow ) const; bool HasStringCells( SCROW nStartRow, SCROW nEndRow ) const; - /** Returns the pointer to a cell note object at the passed row. */ - ScPostIt* GetNote( SCROW nRow ); - /** Sets the passed cell note object at the passed row. Takes ownership! */ - void TakeNote( SCROW nRow, ScPostIt* pNote ); - /** Returns and forgets a cell note object at the passed row. */ - ScPostIt* ReleaseNote( SCROW nRow ); - /** Deletes the note at the passed row. */ - void DeleteNote( SCROW nRow ); - void SetDirty(); void SetDirty( const ScRange& ); void SetDirtyVar(); diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx index c06b9935e1b1..43e13bf3788f 100644 --- a/sc/inc/dociter.hxx +++ b/sc/inc/dociter.hxx @@ -479,6 +479,8 @@ private: ScHorizontalCellIterator aCellIter; ScHorizontalAttrIterator aAttrIter; + ScDocument * pDoc; + const SCTAB nTable; SCCOL nNextCol; SCROW nNextRow; diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index a7ae1c3bb576..cbcc3b1021ec 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -273,6 +273,7 @@ private: ::std::auto_ptr pExternalRefMgr; ::std::auto_ptr mpMacroMgr; + std::map< const ScAddress, ScPostIt* > pNotes; // mutable for lazy construction mutable ::std::auto_ptr< ScFormulaParserPool > @@ -802,16 +803,16 @@ public: /** Returns true, if there is any data to create a selection list for rPos. */ sal_Bool HasSelectionData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const; - /** Returns the pointer to a cell note object at the passed cell address. */ - SC_DLLPUBLIC ScPostIt* GetNote( const ScAddress& rPos ); - /** Sets the passed note at the cell with the passed cell address. */ - void TakeNote( const ScAddress& rPos, ScPostIt*& rpNote ); - /** Returns and forgets the cell note object at the passed cell address. */ - ScPostIt* ReleaseNote( const ScAddress& rPos ); - /** Returns the pointer to an existing or created cell note object at the passed cell address. */ + /* Note management API + */ + SC_DLLPUBLIC ScPostIt* GetNote( ScAddress const & ); SC_DLLPUBLIC ScPostIt* GetOrCreateNote( const ScAddress& rPos ); - /** Deletes the note at the passed cell address. */ - void DeleteNote( const ScAddress& rPos ); + bool SetNote( ScAddress const &, ScPostIt* ); + bool MoveNote( ScAddress const & from, ScAddress const & to ); + bool SwapNotes( ScAddress const &, ScAddress const & ); + ScPostIt* ReleaseNote( ScAddress const & ); + void DeleteNote( ScAddress const & ); + /** Creates the captions of all uninitialized cell notes in the specified sheet. @param bForced True = always create all captions, false = skip when Undo is disabled. */ void InitializeNoteCaptions( SCTAB nTab, bool bForced = false ); diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx index e8f7da17e4f5..7d72340ff943 100644 --- a/sc/inc/global.hxx +++ b/sc/inc/global.hxx @@ -273,7 +273,7 @@ enum CellType CELLTYPE_VALUE, CELLTYPE_STRING, CELLTYPE_FORMULA, - CELLTYPE_NOTE, + CELLTYPE_EMPTY, CELLTYPE_EDIT, CELLTYPE_SYMBOLS // for load/save #if OSL_DEBUG_LEVEL > 0 diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index 9cd3c573a072..2859dd008778 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -340,14 +340,6 @@ public: void GetFirstDataPos(SCCOL& rCol, SCROW& rRow) const; void GetLastDataPos(SCCOL& rCol, SCROW& rRow) const; - /** Returns the pointer to a cell note object at the passed cell address. */ - ScPostIt* GetNote( SCCOL nCol, SCROW nRow ); - /** Sets the passed cell note object at the passed cell address. Takes ownership! */ - void TakeNote( SCCOL nCol, SCROW nRow, ScPostIt*& rpNote ); - /** Returns and forgets the cell note object at the passed cell address. */ - ScPostIt* ReleaseNote( SCCOL nCol, SCROW nRow ); - /** Deletes the note at the passed cell address. */ - void DeleteNote( SCCOL nCol, SCROW nRow ); /** Creates the captions of all uninitialized cell notes. @param bForced True = always create all captions, false = skip when Undo is disabled. */ void InitializeNoteCaptions( bool bForced = false ); diff --git a/sc/source/core/data/autonamecache.cxx b/sc/source/core/data/autonamecache.cxx index 44f5cd58019e..df8462c590a6 100644 --- a/sc/source/core/data/autonamecache.cxx +++ b/sc/source/core/data/autonamecache.cxx @@ -90,7 +90,7 @@ const ScAutoNameAddresses& ScAutoNameCache::GetNameOccurrences( const String& rN break; case CELLTYPE_NONE: case CELLTYPE_VALUE: - case CELLTYPE_NOTE: + case CELLTYPE_EMPTY: case CELLTYPE_SYMBOLS: #if OSL_DEBUG_LEVEL > 0 case CELLTYPE_DESTROYED: diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx index 49c94a50ea56..c56cb239681c 100644 --- a/sc/source/core/data/cell.cxx +++ b/sc/source/core/data/cell.cxx @@ -72,20 +72,20 @@ const sal_uInt16 MAXRECURSION = 400; #ifdef USE_MEMPOOL // MemPools auf 4k Boundaries - 64 Bytes ausrichten -const sal_uInt16 nMemPoolValueCell = (0x8000 - 64) / sizeof(ScValueCell); +const sal_uInt16 nMemPoolEmptyCell = (0x8000 - 64) / sizeof(ScEmptyCell); +const sal_uInt16 nMemPoolValueCell = (0x8000 - 64) / sizeof(ScValueCell); const sal_uInt16 nMemPoolFormulaCell = (0x8000 - 64) / sizeof(ScFormulaCell); -const sal_uInt16 nMemPoolStringCell = (0x4000 - 64) / sizeof(ScStringCell); -const sal_uInt16 nMemPoolNoteCell = (0x1000 - 64) / sizeof(ScNoteCell); -IMPL_FIXEDMEMPOOL_NEWDEL( ScValueCell, nMemPoolValueCell, nMemPoolValueCell ) +const sal_uInt16 nMemPoolStringCell = (0x4000 - 64) / sizeof(ScStringCell); + +IMPL_FIXEDMEMPOOL_NEWDEL( ScEmptyCell, nMemPoolEmptyCell, nMemPoolEmptyCell ) +IMPL_FIXEDMEMPOOL_NEWDEL( ScValueCell, nMemPoolValueCell, nMemPoolValueCell ) IMPL_FIXEDMEMPOOL_NEWDEL( ScFormulaCell, nMemPoolFormulaCell, nMemPoolFormulaCell ) -IMPL_FIXEDMEMPOOL_NEWDEL( ScStringCell, nMemPoolStringCell, nMemPoolStringCell ) -IMPL_FIXEDMEMPOOL_NEWDEL( ScNoteCell, nMemPoolNoteCell, nMemPoolNoteCell ) +IMPL_FIXEDMEMPOOL_NEWDEL( ScStringCell, nMemPoolStringCell, nMemPoolStringCell ) #endif // ============================================================================ ScBaseCell::ScBaseCell( CellType eNewType ) : - mpNote( 0 ), mpBroadcaster( 0 ), nTextWidth( TEXTWIDTH_DIRTY ), eCellType( sal::static_int_cast(eNewType) ), @@ -94,7 +94,6 @@ ScBaseCell::ScBaseCell( CellType eNewType ) : } ScBaseCell::ScBaseCell( const ScBaseCell& rCell ) : - mpNote( 0 ), mpBroadcaster( 0 ), nTextWidth( rCell.nTextWidth ), eCellType( rCell.eCellType ), @@ -104,7 +103,6 @@ ScBaseCell::ScBaseCell( const ScBaseCell& rCell ) : ScBaseCell::~ScBaseCell() { - delete mpNote; delete mpBroadcaster; OSL_ENSURE( eCellType == CELLTYPE_DESTROYED, "BaseCell Destructor" ); } @@ -123,9 +121,9 @@ ScBaseCell* lclCloneCell( const ScBaseCell& rSrcCell, ScDocument& rDestDoc, cons return new ScEditCell( static_cast< const ScEditCell& >( rSrcCell ), rDestDoc ); case CELLTYPE_FORMULA: return new ScFormulaCell( static_cast< const ScFormulaCell& >( rSrcCell ), rDestDoc, rDestPos, nCloneFlags ); - case CELLTYPE_NOTE: - return new ScNoteCell; - default:; + case CELLTYPE_EMPTY: + return new ScEmptyCell; + default:; } OSL_FAIL( "lclCloneCell - unknown cell type" ); return 0; @@ -227,7 +225,7 @@ void adjustDBRange(ScToken* pToken, ScDocument& rNewDoc, const ScDocument* pOldD } // namespace -ScBaseCell* ScBaseCell::CloneWithoutNote( ScDocument& rDestDoc, int nCloneFlags ) const +ScBaseCell* ScBaseCell::Clone( ScDocument& rDestDoc, int nCloneFlags ) const { // notes will not be cloned -> cell address only needed for formula cells ScAddress aDestPos; @@ -236,27 +234,14 @@ ScBaseCell* ScBaseCell::CloneWithoutNote( ScDocument& rDestDoc, int nCloneFlags return lclCloneCell( *this, rDestDoc, aDestPos, nCloneFlags ); } -ScBaseCell* ScBaseCell::CloneWithoutNote( ScDocument& rDestDoc, const ScAddress& rDestPos, int nCloneFlags ) const +ScBaseCell* ScBaseCell::Clone( ScDocument& rDestDoc, const ScAddress& rDestPos, int nCloneFlags ) const { return lclCloneCell( *this, rDestDoc, rDestPos, nCloneFlags ); } -ScBaseCell* ScBaseCell::CloneWithNote( const ScAddress& rOwnPos, ScDocument& rDestDoc, const ScAddress& rDestPos, int nCloneFlags ) const -{ - ScBaseCell* pNewCell = lclCloneCell( *this, rDestDoc, rDestPos, nCloneFlags ); - if( mpNote ) - { - if( !pNewCell ) - pNewCell = new ScNoteCell; - bool bCloneCaption = (nCloneFlags & SC_CLONECELL_NOCAPTION) == 0; - pNewCell->TakeNote( mpNote->Clone( rOwnPos, rDestDoc, rDestPos, bCloneCaption ) ); - } - return pNewCell; -} void ScBaseCell::Delete() { - DeleteNote(); switch (eCellType) { case CELLTYPE_VALUE: @@ -271,8 +256,8 @@ void ScBaseCell::Delete() case CELLTYPE_FORMULA: delete (ScFormulaCell*) this; break; - case CELLTYPE_NOTE: - delete (ScNoteCell*) this; + case CELLTYPE_EMPTY: + delete (ScEmptyCell*) this; break; default: OSL_FAIL("Attempt to Delete() an unknown CELLTYPE"); @@ -280,28 +265,12 @@ void ScBaseCell::Delete() } } -bool ScBaseCell::IsBlank( bool bIgnoreNotes ) const -{ - return (eCellType == CELLTYPE_NOTE) && (bIgnoreNotes || !mpNote); -} - -void ScBaseCell::TakeNote( ScPostIt* pNote ) -{ - delete mpNote; - mpNote = pNote; -} -ScPostIt* ScBaseCell::ReleaseNote() +bool ScBaseCell::IsBlank( ) const { - ScPostIt* pNote = mpNote; - mpNote = 0; - return pNote; + return (CELLTYPE_EMPTY == eCellType); } -void ScBaseCell::DeleteNote() -{ - DELETEZ( mpNote ); -} void ScBaseCell::TakeBroadcaster( SvtBroadcaster* pBroadcaster ) { @@ -518,7 +487,7 @@ bool ScBaseCell::HasEmptyData() const { switch ( eCellType ) { - case CELLTYPE_NOTE : + case CELLTYPE_EMPTY : return true; case CELLTYPE_FORMULA : return ((ScFormulaCell*)this)->IsEmpty(); @@ -581,17 +550,17 @@ bool ScBaseCell::CellEqual( const ScBaseCell* pCell1, const ScBaseCell* pCell2 ) if ( pCell1 ) { eType1 = pCell1->GetCellType(); - if (eType1 == CELLTYPE_EDIT) + if (CELLTYPE_EDIT == eType1) eType1 = CELLTYPE_STRING; - else if (eType1 == CELLTYPE_NOTE) + else if (CELLTYPE_EMPTY == eType1) eType1 = CELLTYPE_NONE; } if ( pCell2 ) { eType2 = pCell2->GetCellType(); - if (eType2 == CELLTYPE_EDIT) + if (CELLTYPE_EDIT == eType2) eType2 = CELLTYPE_STRING; - else if (eType2 == CELLTYPE_NOTE) + else if (CELLTYPE_EMPTY == eType2) eType2 = CELLTYPE_NONE; } if ( eType1 != eType2 ) @@ -654,26 +623,21 @@ bool ScBaseCell::CellEqual( const ScBaseCell* pCell1, const ScBaseCell* pCell2 ) // ============================================================================ -ScNoteCell::ScNoteCell( SvtBroadcaster* pBC ) : - ScBaseCell( CELLTYPE_NOTE ) +ScEmptyCell::ScEmptyCell( SvtBroadcaster* pBC ) : + ScBaseCell( CELLTYPE_EMPTY ) { TakeBroadcaster( pBC ); } -ScNoteCell::ScNoteCell( ScPostIt* pNote, SvtBroadcaster* pBC ) : - ScBaseCell( CELLTYPE_NOTE ) -{ - TakeNote( pNote ); - TakeBroadcaster( pBC ); -} #if OSL_DEBUG_LEVEL > 0 -ScNoteCell::~ScNoteCell() +ScEmptyCell::~ScEmptyCell() { eCellType = CELLTYPE_DESTROYED; } #endif + // ============================================================================ ScValueCell::ScValueCell() : diff --git a/sc/source/core/data/cell2.cxx b/sc/source/core/data/cell2.cxx index 28fb6348ebc8..2c8d341c8141 100644 --- a/sc/source/core/data/cell2.cxx +++ b/sc/source/core/data/cell2.cxx @@ -61,7 +61,7 @@ using namespace formula; // STATIC DATA ----------------------------------------------------------- #ifdef USE_MEMPOOL -const sal_uInt16 nMemPoolEditCell = (0x1000 - 64) / sizeof(ScNoteCell); +const sal_uInt16 nMemPoolEditCell = (0x1000 - 64) / sizeof(ScEmptyCell); IMPL_FIXEDMEMPOOL_NEWDEL( ScEditCell, nMemPoolEditCell, nMemPoolEditCell ) #endif diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index fc1178f4a622..89e635427a10 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -840,7 +840,7 @@ void lclTakeBroadcaster( ScBaseCell*& rpCell, SvtBroadcaster* pBC ) if( rpCell ) rpCell->TakeBroadcaster( pBC ); else - rpCell = new ScNoteCell( pBC ); + rpCell = new ScEmptyCell( pBC ); } } @@ -908,11 +908,10 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2) } else { - ScNoteCell* pDummyCell = pBC1 ? new ScNoteCell( pBC1 ) : 0; - if ( pDummyCell ) + if ( pBC1 ) { // insert dummy note cell (without note) containing old broadcaster - pItems[nIndex1].pCell = pDummyCell; + pItems[nIndex1].pCell = new ScEmptyCell( pBC1 ); } else { @@ -962,9 +961,8 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2) // do not swap formula cells with equal formulas, but swap notes if (bEqual) { - ScPostIt* pNote1 = pCell1->ReleaseNote(); - pCell1->TakeNote( pCell2->ReleaseNote() ); - pCell2->TakeNote( pNote1 ); + pDocument->SwapNotes( aPos1, aPos2 ); + return; } } @@ -973,17 +971,14 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2) /* Create clone of pCell1 at position of pCell2 (pCell1 exists always, see variable swapping above). Do not clone the note, but move pointer of old note to new cell. */ - ScBaseCell* pNew2 = pCell1->CloneWithoutNote( *pDocument, aPos2, SC_CLONECELL_ADJUST3DREL ); - pNew2->TakeNote( pCell1->ReleaseNote() ); + ScBaseCell* pNew2 = pCell1->Clone( *pDocument, aPos2, SC_CLONECELL_ADJUST3DREL ); - /* Create clone of pCell2 at position of pCell1. Do not clone the note, - but move pointer of old note to new cell. */ ScBaseCell* pNew1 = 0; if ( pCell2 ) { - pNew1 = pCell2->CloneWithoutNote( *pDocument, aPos1, SC_CLONECELL_ADJUST3DREL ); - pNew1->TakeNote( pCell2->ReleaseNote() ); + pNew1 = pCell2->Clone( *pDocument, aPos1, SC_CLONECELL_ADJUST3DREL ); } + pDocument->SwapNotes( aPos1, aPos2 ); // move old broadcasters new cells at the same old position SvtBroadcaster* pBC1 = pCell1->ReleaseBroadcaster(); @@ -1079,10 +1074,17 @@ bool ScColumn::TestInsertCol( SCROW nStartRow, SCROW nEndRow) const if (!IsEmpty()) { bool bTest = true; - if (pItems) - for (SCSIZE i=0; (i nEndRow) - || pItems[i].pCell->IsBlank(); + if (pItems) { + ScAddress pos( nCol, 0, nTab ); + for (SCSIZE i=0; (iIsBlank()) + || (0 == pDocument->GetNote( pos )) + ); + } + } // AttrArray testet nur zusammengefasste @@ -1199,6 +1201,9 @@ void ScColumn::InsertRow( SCROW nStartRow, SCSIZE nSize ) for (i = 0; i < nDelCount; i++) { ScBaseCell* pCell = ppDelCells[i]; + // Oct, 2011: Perhaps need to update IsBlank call in ENSURE to check + // for notes (via ScDocument.GetNote), but I'm not sure the current + // code (above and below this comment) is even correct. OSL_ENSURE( pCell->IsBlank(), "sichtbare Zelle weggeschoben" ); SvtBroadcaster* pBC = pCell->GetBroadcaster(); if (pBC) @@ -1247,6 +1252,8 @@ void ScColumn::CopyToClip(SCROW nRow1, SCROW nRow2, ScColumn& rColumn, bool bKee if (nBlockCount) { int nCloneFlags = bCloneNoteCaptions ? SC_CLONECELL_DEFAULT : SC_CLONECELL_NOCAPTION; + ScDocument * rDestDoc = rColumn.pDocument; + rColumn.Resize( rColumn.GetCellCount() + nBlockCount ); ScAddress aOwnPos( nCol, 0, nTab ); ScAddress aDestPos( rColumn.nCol, 0, rColumn.nTab ); @@ -1254,7 +1261,15 @@ void ScColumn::CopyToClip(SCROW nRow1, SCROW nRow2, ScColumn& rColumn, bool bKee { aOwnPos.SetRow( pItems[i].nRow ); aDestPos.SetRow( pItems[i].nRow ); - ScBaseCell* pNewCell = pItems[i].pCell->CloneWithNote( aOwnPos, *rColumn.pDocument, aDestPos, nCloneFlags ); + ScBaseCell* pNewCell = pItems[i].pCell->Clone( + *rDestDoc, aDestPos, nCloneFlags + ); + ScPostIt* pNewNote = pDocument->GetNote( aOwnPos ); + if (pNewNote) + pNewNote = new ScPostIt( *rDestDoc, aDestPos, *pNewNote ); + if ( ! rDestDoc->SetNote( aDestPos, pNewNote ) ) + DELETEZ( pNewNote ); // apparently unsuccessful; don't leak + rColumn.Append( aDestPos.Row(), pNewCell ); } } @@ -1383,7 +1398,12 @@ void ScColumn::CopyUpdated( const ScColumn& rPosCol, ScColumn& rDestCol ) const SCSIZE nThisIndex; if ( Search( aDestPos.Row(), nThisIndex ) ) { - ScBaseCell* pNew = pItems[nThisIndex].pCell->CloneWithNote( aOwnPos, rDestDoc, aDestPos ); + ScBaseCell* pNew = pItems[nThisIndex].pCell->Clone( rDestDoc, aDestPos ); + ScPostIt* pNewNote = pDocument->GetNote( aOwnPos ); + pNewNote = new ScPostIt( rDestDoc, aDestPos, pNewNote ); + if ( ! rDestDoc.SetNote( aDestPos, pNewNote ) ) + DELETEZ( pNewNote ); // apparently unsuccessful; don't leak + rDestCol.Insert( aDestPos.Row(), pNew ); } } @@ -1591,7 +1611,7 @@ void ScColumn::MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol) ScAddress aAdr( nCol, 0, nTab ); ScHint aHint( SC_HINT_DYING, aAdr, NULL ); // areas only ScAddress& rAddress = aHint.GetAddress(); - ScNoteCell* pNoteCell = new ScNoteCell; // Dummy like in DeleteRange + ScEmptyCell* pEmptyCell = new ScEmptyCell; // Dummy like in DeleteRange // must iterate backwards, because indexes of following cells become invalid for (EntryPosPairs::reverse_iterator it( aEntries.rbegin()); @@ -1600,7 +1620,7 @@ void ScColumn::MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol) nStartPos = (*it).first; nStopPos = (*it).second; for (i=nStartPos; iDelete(); + pEmptyCell->Delete(); pItems[nCount].nRow = 0; pItems[nCount].pCell = NULL; } @@ -1786,7 +1806,7 @@ void ScColumn::UpdateDeleteTab( SCTAB nTable, bool bIsMove, ScColumn* pRefUndo, /* Do not copy cell note to the undo document. Undo will copy back the formula cell while keeping the original note. */ - ScBaseCell* pSave = pRefUndo ? pOld->CloneWithoutNote( *pDocument ) : 0; + ScBaseCell* pSave = pRefUndo ? pOld->Clone( *pDocument ) : 0; bool bChanged = pOld->UpdateDeleteTab(nTable, bIsMove, nSheets); if ( nRow != pItems[i].nRow ) diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index 83ecd3cc1036..547e83307669 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -946,7 +946,7 @@ void ScColumn::RemoveAutoSpellObj() String aText = ScEditUtil::GetSpaceDelimitedString( *pEngine ); ScBaseCell* pNewCell = new ScStringCell( aText ); pNewCell->TakeBroadcaster( pOldCell->ReleaseBroadcaster() ); - pNewCell->TakeNote( pOldCell->ReleaseNote() ); + pItems[i].pCell = pNewCell; delete pOldCell; } @@ -1018,7 +1018,7 @@ void ScColumn::RemoveEditAttribs( SCROW nStartRow, SCROW nEndRow ) String aText = ScEditUtil::GetSpaceDelimitedString( *pEngine ); ScBaseCell* pNewCell = new ScStringCell( aText ); pNewCell->TakeBroadcaster( pOldCell->ReleaseBroadcaster() ); - pNewCell->TakeNote( pOldCell->ReleaseNote() ); + pItems[i].pCell = pNewCell; delete pOldCell; } @@ -1150,7 +1150,11 @@ bool ScColumn::IsEmptyVisData(bool bNotes) const for (i=0; iGetCellType() != CELLTYPE_NOTE || (bNotes && pCell->HasNote()) ) + ScPostIt *note = pDocument->GetNote( + ScAddress( nCol, pItems[i].nRow, nTab ) + ); + + if (pCell->GetCellType() != CELLTYPE_EMPTY || (bNotes && 0 != note)) bVisData = true; } return !bVisData; @@ -1167,7 +1171,7 @@ SCSIZE ScColumn::VisibleCount( SCROW nStartRow, SCROW nEndRow ) const while ( nIndex < nCount && pItems[nIndex].nRow <= nEndRow ) { if ( pItems[nIndex].nRow >= nStartRow && - pItems[nIndex].pCell->GetCellType() != CELLTYPE_NOTE ) + pItems[nIndex].pCell->GetCellType() != CELLTYPE_EMPTY ) { ++nVisCount; } @@ -1187,7 +1191,9 @@ SCROW ScColumn::GetLastVisDataPos(bool bNotes) const { --i; ScBaseCell* pCell = pItems[i].pCell; - if ( pCell->GetCellType() != CELLTYPE_NOTE || (bNotes && pCell->HasNote()) ) + ScPostIt *note = pDocument->GetNote( ScAddress(nCol, pItems[i].nRow, nTab) ); + + if (pCell->GetCellType() != CELLTYPE_EMPTY || (bNotes && 0 != note)) { bFound = true; nRet = pItems[i].nRow; @@ -1207,7 +1213,9 @@ SCROW ScColumn::GetFirstVisDataPos(bool bNotes) const for (i=0; iGetCellType() != CELLTYPE_NOTE || (bNotes && pCell->HasNote()) ) + ScPostIt *note = pDocument->GetNote( ScAddress(nCol, pItems[i].nRow, nTab) ); + + if (pCell->GetCellType() != CELLTYPE_EMPTY || (bNotes && 0 != note)) { bFound = true; nRet = pItems[i].nRow; @@ -1220,9 +1228,11 @@ SCROW ScColumn::GetFirstVisDataPos(bool bNotes) const bool ScColumn::HasVisibleDataAt(SCROW nRow) const { SCSIZE nIndex; - if (Search(nRow, nIndex)) - if (!pItems[nIndex].pCell->IsBlank()) + if (Search(nRow, nIndex)) { + ScAddress aPos( nCol, nRow, nTab ); + if (!pItems[nIndex].pCell->IsBlank() || pDocument->GetNote(aPos)) return true; + } return false; } @@ -1249,8 +1259,10 @@ bool ScColumn::IsEmptyBlock(SCROW nStartRow, SCROW nEndRow, bool bIgnoreNotes) c Search( nStartRow, nIndex ); while ( nIndex < nCount && pItems[nIndex].nRow <= nEndRow ) { - if ( !pItems[nIndex].pCell->IsBlank( bIgnoreNotes ) ) // found a cell - return false; // not empty + if ( ( ! pItems[nIndex].pCell->IsBlank() ) + || ( ! bIgnoreNotes && pDocument->GetNote( ScAddress( nCol, pItems[nIndex].nRow, nTab ))) + ) + return false; // not empty if even one cell is not blank or has a note ++nIndex; } return true; // no cell found @@ -1263,6 +1275,7 @@ SCSIZE ScColumn::GetEmptyLinesInBlock( SCROW nStartRow, SCROW nEndRow, ScDirecti SCSIZE i; if (pItems && (nCount > 0)) { + ScAddress aPos( nCol, 0, nTab ); if (eDir == DIR_BOTTOM) { i = nCount; @@ -1271,7 +1284,9 @@ SCSIZE ScColumn::GetEmptyLinesInBlock( SCROW nStartRow, SCROW nEndRow, ScDirecti i--; if ( pItems[i].nRow < nStartRow ) break; - bFound = pItems[i].nRow <= nEndRow && !pItems[i].pCell->IsBlank(); + aPos.SetRow( pItems[i].nRow ); + ScPostIt* aNote = pDocument->GetNote( aPos ); + bFound = pItems[i].nRow <= nEndRow && (!pItems[i].pCell->IsBlank() || aNote ); } if (bFound) nLines = static_cast(nEndRow - pItems[i].nRow); @@ -1285,7 +1300,9 @@ SCSIZE ScColumn::GetEmptyLinesInBlock( SCROW nStartRow, SCROW nEndRow, ScDirecti { if ( pItems[i].nRow > nEndRow ) break; - bFound = pItems[i].nRow >= nStartRow && !pItems[i].pCell->IsBlank(); + aPos.SetRow( pItems[i].nRow ); + ScPostIt* aNote = pDocument->GetNote( aPos ); + bFound = pItems[i].nRow >= nStartRow && (!pItems[i].pCell->IsBlank() || aNote ); i++; } if (bFound) @@ -1348,8 +1365,14 @@ void ScColumn::FindDataAreaPos(SCROW& rRow, long nMovY) const SCSIZE nIndex; bool bThere = Search(rRow, nIndex); - if (bThere && pItems[nIndex].pCell->IsBlank()) - bThere = false; + ScAddress aPos( nCol, 0, nTab ); + if (bThere) { + aPos.SetRow(pItems[nIndex].nRow); + if ( pItems[nIndex].pCell->IsBlank() + && (0 == pDocument->GetNote( aPos ) ) + ) + bThere = false; + } if (bThere) { @@ -1360,14 +1383,22 @@ void ScColumn::FindDataAreaPos(SCROW& rRow, long nMovY) const if (nIndexIsBlank()) + aPos.SetRow( pItems[nIndex].nRow ); + while ( nIndex < nCount -1 + && pItems[nIndex].nRow == nLast +1 + && ( ! pItems[nIndex].pCell->IsBlank() + || pDocument->GetNote( aPos ) ) + ) { ++nIndex; ++nLast; + aPos.SetRow( pItems[nIndex].nRow ); } - if (nIndex==nCount-1) - if (pItems[nIndex].nRow==nLast+1 && !pItems[nIndex].pCell->IsBlank()) + if ( nIndex == nCount -1 ) + if ( pItems[nIndex].nRow == nLast +1 + && ( ! pItems[nIndex].pCell->IsBlank() + || pDocument->GetNote( aPos ) ) + ) ++nLast; } } @@ -1376,14 +1407,22 @@ void ScColumn::FindDataAreaPos(SCROW& rRow, long nMovY) const if (nIndex>0) { --nIndex; - while (nIndex>0 && pItems[nIndex].nRow+1==nLast - && !pItems[nIndex].pCell->IsBlank()) + aPos.SetRow( pItems[nIndex].nRow ); + while ( nIndex > 0 + && pItems[nIndex].nRow +1 == nLast + && ( ! pItems[nIndex].pCell->IsBlank() + || pDocument->GetNote( aPos ) ) + ) { --nIndex; --nLast; + aPos.SetRow( pItems[nIndex].nRow ); } - if (nIndex==0) - if (pItems[nIndex].nRow+1==nLast && !pItems[nIndex].pCell->IsBlank()) + if ( 0 == nIndex ) + if ( pItems[nIndex].nRow +1 == nLast + && ( ! pItems[nIndex].pCell->IsBlank() + || pDocument->GetNote( aPos ) ) + ) --nLast; } } @@ -1398,10 +1437,17 @@ void ScColumn::FindDataAreaPos(SCROW& rRow, long nMovY) const if (!bThere) { + aPos.SetRow( pItems[nIndex].nRow ); if (bForward) { - while (nIndexIsBlank()) + while ( nIndex < nCount + && ( pItems[nIndex].pCell->IsBlank() + && (0 == pDocument->GetNote( aPos )) ) + ) + { ++nIndex; + aPos.SetRow( pItems[nIndex].nRow ); + } if (nIndex0 && pItems[nIndex-1].pCell->IsBlank()) + while ( nIndex > 0 + && ( pItems[nIndex-1].pCell->IsBlank() + && (0 == pDocument->GetNote( aPos )) ) + ) + { --nIndex; + aPos.SetRow( pItems[nIndex].nRow ); + } if (nIndex>0) rRow = pItems[nIndex-1].nRow; else @@ -1426,7 +1478,9 @@ bool ScColumn::HasDataAt(SCROW nRow) const SCSIZE nIndex; if (Search(nRow, nIndex)) - if (!pItems[nIndex].pCell->IsBlank()) + if ( ! pItems[nIndex].pCell->IsBlank() + || pDocument->GetNote( ScAddress( nCol, nRow, nTab )) + ) return true; return false; @@ -1503,7 +1557,7 @@ void ScColumn::StartListening( SvtListener& rLst, SCROW nRow ) } else { - pCell = new ScNoteCell; + pCell = new ScEmptyCell; Insert(nRow, pCell); } @@ -1528,7 +1582,7 @@ void ScColumn::MoveListeners( SvtBroadcaster& rSource, SCROW nDestRow ) } else { - pCell = new ScNoteCell; + pCell = new ScEmptyCell; Insert(nDestRow, pCell); } @@ -1562,7 +1616,7 @@ void ScColumn::EndListening( SvtListener& rLst, SCROW nRow ) if (!pBC->HasListeners()) { - if (pCell->IsBlank()) + if (pCell->IsBlank() && (0 == pDocument->GetNote(ScAddress(nCol, nRow, nTab))) ) DeleteAtIndex(nIndex); else pCell->DeleteBroadcaster(); @@ -1645,7 +1699,7 @@ void lcl_UpdateSubTotal( ScFunctionData& rData, ScBaseCell* pCell ) } } break; - case CELLTYPE_NOTE: + case CELLTYPE_EMPTY: bCell = false; break; // bei Strings nichts diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index baa05185ce8e..e39cbe1cfea1 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -88,12 +88,17 @@ void ScColumn::Insert( SCROW nRow, ScBaseCell* pNewCell ) if (Search(nRow, nIndex)) { ScBaseCell* pOldCell = pItems[nIndex].pCell; + ScAddress oldAddy( nCol, pItems[nIndex].nRow, nTab ); + ScAddress newAddy( nCol, nRow, nTab ); + ScPostIt* oldNote = pDocument->GetNote( oldAddy ); + ScPostIt* newNote = pDocument->GetNote( newAddy ); // move broadcaster and note to new cell, if not existing in new cell if (pOldCell->HasBroadcaster() && !pNewCell->HasBroadcaster()) pNewCell->TakeBroadcaster( pOldCell->ReleaseBroadcaster() ); - if (pOldCell->HasNote() && !pNewCell->HasNote()) - pNewCell->TakeNote( pOldCell->ReleaseNote() ); + + if ( oldNote && !newNote ) + pDocument->MoveNote( oldAddy, newAddy ); if ( pOldCell->GetCellType() == CELLTYPE_FORMULA && !pDocument->IsClipOrUndo() ) { @@ -148,7 +153,7 @@ void ScColumn::Insert( SCROW nRow, ScBaseCell* pNewCell ) CellType eCellType = pNewCell->GetCellType(); // Notizzelle entsteht beim Laden nur durch StartListeningCell, // ausloesende Formelzelle muss sowieso dirty sein. - if ( !(pDocument->IsCalcingAfterLoad() && eCellType == CELLTYPE_NOTE) ) + if ( !(pDocument->IsCalcingAfterLoad() && eCellType == CELLTYPE_EMPTY) ) { if ( eCellType == CELLTYPE_FORMULA ) ((ScFormulaCell*)pNewCell)->SetDirty(); @@ -212,17 +217,17 @@ void ScColumn::Delete( SCROW nRow ) if (Search(nRow, nIndex)) { ScBaseCell* pCell = pItems[nIndex].pCell; - ScNoteCell* pNoteCell = new ScNoteCell; - pItems[nIndex].pCell = pNoteCell; // Dummy fuer Interpret + ScEmptyCell* pEmptyCell = new ScEmptyCell; + pItems[nIndex].pCell = pEmptyCell; // Dummy, for Interpret pDocument->Broadcast( ScHint( SC_HINT_DYING, ScAddress( nCol, nRow, nTab ), pCell ) ); if ( SvtBroadcaster* pBC = pCell->ReleaseBroadcaster() ) { - pNoteCell->TakeBroadcaster( pBC ); + pEmptyCell->TakeBroadcaster( pBC ); } else { - pNoteCell->Delete(); + pEmptyCell->Delete(); --nCount; memmove( &pItems[nIndex], &pItems[nIndex + 1], (nCount - nIndex) * sizeof(ColEntry) ); pItems[nCount].nRow = 0; @@ -238,11 +243,11 @@ void ScColumn::Delete( SCROW nRow ) void ScColumn::DeleteAtIndex( SCSIZE nIndex ) { ScBaseCell* pCell = pItems[nIndex].pCell; - ScNoteCell* pNoteCell = new ScNoteCell; - pItems[nIndex].pCell = pNoteCell; // Dummy fuer Interpret + ScEmptyCell* pEmptyCell = new ScEmptyCell; + pItems[nIndex].pCell = pEmptyCell; // Dummy, for Interpret pDocument->Broadcast( ScHint( SC_HINT_DYING, ScAddress( nCol, pItems[nIndex].nRow, nTab ), pCell ) ); - pNoteCell->Delete(); + pEmptyCell->Delete(); --nCount; memmove( &pItems[nIndex], &pItems[nIndex + 1], (nCount - nIndex) * sizeof(ColEntry) ); pItems[nCount].nRow = 0; @@ -374,13 +379,20 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe drawing undo. */ bool bDeleteNote = (nDelFlag & IDF_NOTE) != 0; bool bNoCaptions = (nDelFlag & IDF_NOCAPTIONS) != 0; - if (bDeleteNote && bNoCaptions) - for ( SCSIZE nIdx = nStartIndex; nIdx <= nEndIndex; ++nIdx ) - if ( ScPostIt* pNote = pItems[ nIdx ].pCell->GetNote() ) + + if (bDeleteNote && bNoCaptions) { + for ( SCSIZE nIdx = nStartIndex; nIdx <= nEndIndex; ++nIdx ) { + ScPostIt* pNote = pDocument->GetNote( + ScAddress( nCol, pItems[ nIdx ].nRow, nTab ) + ); + if ( pNote ) pNote->ForgetCaption(); + } + } ScHint aHint( SC_HINT_DYING, ScAddress( nCol, 0, nTab ), 0 ); + // cache all formula cells, they will be deleted at end of this function typedef ::std::vector< ScFormulaCell* > FormulaCellVector; FormulaCellVector aDelCells; @@ -391,7 +403,7 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe SCSIZE nFirst(nStartIndex); // dummy replacement for old cells, to prevent that interpreter uses old cell - boost::scoped_ptr pDummyCell(new ScNoteCell); + boost::scoped_ptr pDummyCell(new ScEmptyCell); for ( SCSIZE nIdx = nStartIndex; nIdx <= nEndIndex; ++nIdx ) { @@ -424,7 +436,7 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe bDelete = true; else { - // decide whether to delete the cell object according to passed + // decide whether to delete the cell object according to passed // flags switch ( eCellType ) { @@ -455,7 +467,7 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe bDelete = (nDelFlag & IDF_FORMULA) != 0; break; - case CELLTYPE_NOTE: + case CELLTYPE_EMPTY: // do note delete note cell with broadcaster bDelete = bDeleteNote && !pOldCell->GetBroadcaster(); break; @@ -467,23 +479,28 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe if (bDelete) { // try to create a replacement note cell, if note or broadcaster exists - ScNoteCell* pNoteCell = 0; - if (eCellType != CELLTYPE_NOTE) + ScEmptyCell* pEmptyCell = 0; + if (eCellType != CELLTYPE_EMPTY) { - // do not rescue note if it has to be deleted according to passed flags - ScPostIt* pNote = bDeleteNote ? 0 : pOldCell->ReleaseNote(); - // #i99844# do not release broadcaster from old cell, it still has to notify deleted content + // do not rescue note if it has to be deleted according to + // passed flags + // #i99844# do not release broadcaster from old cell, it + // still has to notify deleted content SvtBroadcaster* pBC = pOldCell->GetBroadcaster(); - if( pNote || pBC ) - pNoteCell = new ScNoteCell( pNote, pBC ); + if ( ! bDeleteNote || pBC ) + pEmptyCell = new ScEmptyCell( pBC ); + else + pDocument->DeleteNote( + ScAddress(nCol, pItems[nIdx].nRow, nTab) + ); } // remove cell entry in cell item list SCROW nOldRow = pItems[nIdx].nRow; - if (pNoteCell) + if (pEmptyCell) { // replace old cell with the replacement note cell - pItems[nIdx].pCell = pNoteCell; + pItems[nIdx].pCell = pEmptyCell; // ... so it's not really deleted bDelete = false; } @@ -500,16 +517,15 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe aHint.GetAddress().SetRow( nOldRow ); aHint.SetCell( pOldCell ); pDocument->Broadcast( aHint ); - // #i99844# after broadcasting, old cell has to forget the broadcaster (owned by pNoteCell) + // #i99844# after broadcasting, old cell has to forget the broadcaster (owned by pEmptyCell) pOldCell->ReleaseBroadcaster(); pOldCell->Delete(); } } else { - // delete cell note if (bDeleteNote) - pItems[nIdx].pCell->DeleteNote(); + pDocument->DeleteNote( ScAddress(nCol, pItems[nIdx].nRow, nTab) ); } if (!bDelete) @@ -543,7 +559,7 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe { // this segment removed if (!bRemoved) nStartSegment = aIt->first; - // The first of removes in a row sets start (they should be + // The first of removes in a row sets start (they should be // alternating removed/notremoved anyway). bRemoved = true; } @@ -562,7 +578,7 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe } ++aIt; } - // The last removed segment up to nCount is discarded, there's nothing + // The last removed segment up to nCount is discarded, there's nothing // following to be moved. if (bRemoved) nShift += nCount - nStartSegment; @@ -730,7 +746,7 @@ void ScColumn::CopyFromClip(SCROW nRow1, SCROW nRow2, long nDy, while ( nStartIndex < rColumn.nCount && rColumn.pItems[nStartIndex].nRow <= nRow2-nDy ) { SCSIZE nEndIndex = nStartIndex; - if ( rColumn.pItems[nStartIndex].pCell->GetCellType() != CELLTYPE_NOTE ) + if ( rColumn.pItems[nStartIndex].pCell->GetCellType() != CELLTYPE_EMPTY ) { SCROW nStartRow = rColumn.pItems[nStartIndex].nRow; SCROW nEndRow = nStartRow; @@ -740,7 +756,7 @@ void ScColumn::CopyFromClip(SCROW nRow1, SCROW nRow2, long nDy, while ( nEndRow < nRow2-nDy && nEndIndex+1 < rColumn.nCount && rColumn.pItems[nEndIndex+1].nRow == nEndRow+1 && - rColumn.pItems[nEndIndex+1].pCell->GetCellType() != CELLTYPE_NOTE ) + rColumn.pItems[nEndIndex+1].pCell->GetCellType() != CELLTYPE_EMPTY ) { ++nEndIndex; ++nEndRow; @@ -825,25 +841,29 @@ void ScColumn::CopyFromClip(SCROW nRow1, SCROW nRow2, long nDy, passed together with IDF_NOTE in nInsFlag. Of course, there is still the need to create a new cell, if there is no cell at the destination position at all. */ - ScBaseCell* pAddNoteCell = bAddNotes ? GetCell( aDestPos.Row() ) : 0; - if (pAddNoteCell) + ScBaseCell* pNewCell = bAddNotes ? GetCell( aDestPos.Row() ) : 0; + if (pNewCell) { // do nothing if source cell does not contain a note - const ScBaseCell* pSourceCell = rColumn.pItems[i].pCell; - const ScPostIt* pSourceNote = pSourceCell ? pSourceCell->GetNote() : 0; - if (pSourceNote) + ScPostIt* pSourceNote = 0; + ScAddress aSourcePos( rColumn.nCol, rColumn.pItems[i].nRow, rColumn.nTab ); + if ( rColumn.pItems[i].pCell ) + pSourceNote = pDocument->GetNote( aSourcePos ); + + if ( pSourceNote ) { - OSL_ENSURE( !pAddNoteCell->HasNote(), "ScColumn::CopyFromClip - unexpected note at destination cell" ); bool bCloneCaption = (nInsFlag & IDF_NOCAPTIONS) == 0; // #i52342# if caption is cloned, the note must be constructed with the destination document - ScAddress aSourcePos( rColumn.nCol, rColumn.pItems[i].nRow, rColumn.nTab ); ScPostIt* pNewNote = pSourceNote->Clone( aSourcePos, *pDocument, aDestPos, bCloneCaption ); - pAddNoteCell->TakeNote( pNewNote ); + ScAddress newAddy( nCol, aDestPos.Row(), nTab ); + + if ( ! pDocument->SetNote( newAddy, pNewNote ) ) + DELETEZ( pNewNote ); // apparently unsuccessful; no leak } } else { - ScBaseCell* pNewCell = bAsLink ? + pNewCell = bAsLink ? rColumn.CreateRefCell( pDocument, aDestPos, i, nInsFlag ) : rColumn.CloneCell( i, nInsFlag, *pDocument, aDestPos ); if (pNewCell) @@ -887,7 +907,7 @@ ScBaseCell* ScColumn::CloneCell(SCSIZE nIndex, sal_uInt16 nFlags, ScDocument& rD ScBaseCell& rSource = *pItems[nIndex].pCell; switch (rSource.GetCellType()) { - case CELLTYPE_NOTE: + case CELLTYPE_EMPTY: // note will be cloned below break; @@ -895,13 +915,13 @@ ScBaseCell* ScColumn::CloneCell(SCSIZE nIndex, sal_uInt16 nFlags, ScDocument& rD case CELLTYPE_EDIT: // note will be cloned below if (bCloneString) - pNew = rSource.CloneWithoutNote( rDestDoc, rDestPos ); + pNew = rSource.Clone( rDestDoc, rDestPos ); break; case CELLTYPE_VALUE: // note will be cloned below if (lclCanCloneValue( *pDocument, *this, pItems[nIndex].nRow, bCloneValue, bCloneDateTime )) - pNew = rSource.CloneWithoutNote( rDestDoc, rDestPos ); + pNew = rSource.Clone( rDestDoc, rDestPos ); break; case CELLTYPE_FORMULA: @@ -919,7 +939,7 @@ ScBaseCell* ScColumn::CloneCell(SCSIZE nIndex, sal_uInt16 nFlags, ScDocument& rD if (bForceFormula || bCloneFormula) { // note will be cloned below - pNew = rSource.CloneWithoutNote( rDestDoc, rDestPos ); + pNew = rSource.Clone( rDestDoc, rDestPos ); } else if ( (bCloneValue || bCloneDateTime || bCloneString) && !rDestDoc.IsUndo() ) { @@ -971,16 +991,20 @@ ScBaseCell* ScColumn::CloneCell(SCSIZE nIndex, sal_uInt16 nFlags, ScDocument& rD // clone the cell note if (bCloneNote) { - if (ScPostIt* pNote = rSource.GetNote()) + ScAddress aOwnPos( nCol, pItems[nIndex].nRow, nTab ); + ScPostIt* pNote = pDocument->GetNote( aOwnPos ); + + if ( pNote ) { bool bCloneCaption = (nFlags & IDF_NOCAPTIONS) == 0; - // #i52342# if caption is cloned, the note must be constructed with the destination document - ScAddress aOwnPos( nCol, pItems[nIndex].nRow, nTab ); + // #i52342# if caption is cloned, the note must be constructed + // with the destination document ScPostIt* pNewNote = pNote->Clone( aOwnPos, rDestDoc, rDestPos, bCloneCaption ); + if ( ! rDestDoc.SetNote( rDestPos, pNewNote ) ) + DELETEZ( pNewNote ); // apparently unsuccessful; don't leak + if (!pNew) - pNew = new ScNoteCell( pNewNote ); - else - pNew->TakeNote( pNewNote ); + pNew = new ScEmptyCell(); } } @@ -1086,14 +1110,14 @@ void ScColumn::MixData( SCROW nRow1, SCROW nRow2, CellType eSrcType = pSrc ? pSrc->GetCellType() : CELLTYPE_NONE; CellType eDestType = pDest ? pDest->GetCellType() : CELLTYPE_NONE; - sal_Bool bSrcEmpty = ( eSrcType == CELLTYPE_NONE || eSrcType == CELLTYPE_NOTE ); - sal_Bool bDestEmpty = ( eDestType == CELLTYPE_NONE || eDestType == CELLTYPE_NOTE ); + sal_Bool bSrcEmpty = ( eSrcType == CELLTYPE_NONE || eSrcType == CELLTYPE_EMPTY ); + sal_Bool bDestEmpty = ( eDestType == CELLTYPE_NONE || eDestType == CELLTYPE_EMPTY ); if ( bSkipEmpty && bDestEmpty ) // Originalzelle wiederherstellen { if ( pSrc ) // war da eine Zelle? { - pNew = pSrc->CloneWithoutNote( *pDocument ); + pNew = pSrc->Clone( *pDocument ); } } else if ( nFunction ) // wirklich Rechenfunktion angegeben @@ -1149,7 +1173,7 @@ void ScColumn::MixData( SCROW nRow1, SCROW nRow2, // mit Texten wird nicht gerechnet - immer "alte" Zelle, also pSrc if (pSrc) - pNew = pSrc->CloneWithoutNote( *pDocument ); + pNew = pSrc->Clone( *pDocument ); else if (pDest) bDelete = sal_True; } @@ -1192,7 +1216,7 @@ void ScColumn::MixData( SCROW nRow1, SCROW nRow2, if (pDest && !pNew) // alte Zelle da ? { if ( pDest->GetBroadcaster() ) - pNew = new ScNoteCell; // Broadcaster uebernehmen + pNew = new ScEmptyCell; // Broadcaster uebernehmen else Delete(nRow); // -> loeschen } @@ -1395,7 +1419,7 @@ bool ScColumn::SetString( SCROW nRow, SCTAB nTabP, const String& rString, if ( rString == aStr ) bIsText = true; break; - case CELLTYPE_NOTE : // durch =Formel referenziert + case CELLTYPE_EMPTY : // durch =Formel referenziert break; default: if ( i == nCount - 1 ) @@ -1515,14 +1539,17 @@ bool ScColumn::SetString( SCROW nRow, SCTAB nTabP, const String& rString, if (Search(nRow, i)) { ScBaseCell* pOldCell = pItems[i].pCell; - ScPostIt* pNote = pOldCell->ReleaseNote(); SvtBroadcaster* pBC = pOldCell->ReleaseBroadcaster(); + + ScPostIt* pNote = pDocument->GetNote( + ScAddress( nCol, pItems[i].nRow, nTab ) + ); + if (pNewCell || pNote || pBC) { - if (pNewCell) - pNewCell->TakeNote( pNote ); - else - pNewCell = new ScNoteCell( pNote ); + if ( ! pNewCell ) + pNewCell = new ScEmptyCell(); + if (pBC) { pNewCell->TakeBroadcaster(pBC); @@ -1786,7 +1813,7 @@ void ScColumn::GetString( SCROW nRow, String& rString ) const if (Search(nRow, nIndex)) { ScBaseCell* pCell = pItems[nIndex].pCell; - if (pCell->GetCellType() != CELLTYPE_NOTE) + if (pCell->GetCellType() != CELLTYPE_EMPTY) { sal_uLong nFormat = GetNumberFormat( nRow ); ScCellFormat::GetString( pCell, nFormat, rString, &pColor, *(pDocument->GetFormatTable()) ); @@ -1805,7 +1832,7 @@ void ScColumn::GetInputString( SCROW nRow, String& rString ) const if (Search(nRow, nIndex)) { ScBaseCell* pCell = pItems[nIndex].pCell; - if (pCell->GetCellType() != CELLTYPE_NOTE) + if (pCell->GetCellType() != CELLTYPE_EMPTY) { sal_uLong nFormat = GetNumberFormat( nRow ); ScCellFormat::GetInputString( pCell, nFormat, rString, *(pDocument->GetFormatTable()) ); @@ -1921,44 +1948,6 @@ bool ScColumn::HasStringCells( SCROW nStartRow, SCROW nEndRow ) const } -ScPostIt* ScColumn::GetNote( SCROW nRow ) -{ - SCSIZE nIndex; - return Search( nRow, nIndex ) ? pItems[ nIndex ].pCell->GetNote() : 0; -} - - -void ScColumn::TakeNote( SCROW nRow, ScPostIt* pNote ) -{ - SCSIZE nIndex; - if( Search( nRow, nIndex ) ) - pItems[ nIndex ].pCell->TakeNote( pNote ); - else - Insert( nRow, new ScNoteCell( pNote ) ); -} - - -ScPostIt* ScColumn::ReleaseNote( SCROW nRow ) -{ - ScPostIt* pNote = 0; - SCSIZE nIndex; - if( Search( nRow, nIndex ) ) - { - ScBaseCell* pCell = pItems[ nIndex ].pCell; - pNote = pCell->ReleaseNote(); - if( (pCell->GetCellType() == CELLTYPE_NOTE) && !pCell->GetBroadcaster() ) - DeleteAtIndex( nIndex ); - } - return pNote; -} - - -void ScColumn::DeleteNote( SCROW nRow ) -{ - delete ReleaseNote( nRow ); -} - - sal_Int32 ScColumn::GetMaxStringLen( SCROW nRowStart, SCROW nRowEnd, CharSet eCharSet ) const { sal_Int32 nStringLen = 0; @@ -1974,7 +1963,7 @@ sal_Int32 ScColumn::GetMaxStringLen( SCROW nRowStart, SCROW nRowEnd, CharSet eCh while ( nIndex < nCount && (nRow = pItems[nIndex].nRow) <= nRowEnd ) { ScBaseCell* pCell = pItems[nIndex].pCell; - if ( pCell->GetCellType() != CELLTYPE_NOTE ) + if ( pCell->GetCellType() != CELLTYPE_EMPTY ) { Color* pColor; sal_uLong nFormat = (sal_uLong) ((SfxUInt32Item*) GetAttr( diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx index bc9689bddb0c..b4e0681e73f4 100644 --- a/sc/source/core/data/dociter.cxx +++ b/sc/source/core/data/dociter.cxx @@ -1160,7 +1160,7 @@ ScBaseCell* ScQueryCellIterator::GetThis() (nRow = pCol->pItems[nColRow].nRow) <= aParam.nRow2 ) { ScBaseCell* pCell = pCol->pItems[nColRow].pCell; - if ( pCell->GetCellType() == CELLTYPE_NOTE ) + if ( pCell->GetCellType() == CELLTYPE_EMPTY ) ++nRow; else if (bAllStringIgnore && pCell->HasStringData()) ++nRow; @@ -1472,7 +1472,7 @@ ScBaseCell* ScQueryCellIterator::BinarySearch() { SCSIZE nMid = (nLo+nHi)/2; SCSIZE i = nMid; - while (i <= nHi && pItems[i].pCell->GetCellType() == CELLTYPE_NOTE) + while (i <= nHi && pItems[i].pCell->GetCellType() == CELLTYPE_EMPTY) ++i; if (i > nHi) { @@ -1920,10 +1920,12 @@ inline sal_Bool IsGreater( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) return ( nRow1 > nRow2 ) || ( nRow1 == nRow2 && nCol1 > nCol2 ); } -ScUsedAreaIterator::ScUsedAreaIterator( ScDocument* pDocument, SCTAB nTable, +ScUsedAreaIterator::ScUsedAreaIterator( ScDocument* pDocument, SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) : - aCellIter( pDocument, nTable, nCol1, nRow1, nCol2, nRow2 ), - aAttrIter( pDocument, nTable, nCol1, nRow1, nCol2, nRow2 ), + aCellIter( pDocument, nTab, nCol1, nRow1, nCol2, nRow2 ), + aAttrIter( pDocument, nTab, nCol1, nRow1, nCol2, nRow2 ), + pDoc( pDocument ), + nTable( nTab ), nNextCol( nCol1 ), nNextRow( nRow1 ) { @@ -1942,7 +1944,11 @@ sal_Bool ScUsedAreaIterator::GetNext() if ( pCell && IsGreater( nNextCol, nNextRow, nCellCol, nCellRow ) ) pCell = aCellIter.GetNext( nCellCol, nCellRow ); - while ( pCell && pCell->IsBlank() ) + while ( pCell + && ( pCell->IsBlank() + && (0 == pDoc->GetNote( ScAddress(nCellCol, nCellRow, nTable))) + ) + ) pCell = aCellIter.GetNext( nCellCol, nCellRow ); if ( pPattern && IsGreater( nNextCol, nNextRow, nAttrCol2, nAttrRow ) ) diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index 97d834455659..e6b4c51cb1c4 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -124,7 +124,6 @@ private: }; // STATIC DATA ----------------------------------------------------------- - ScDocument::ScDocument( ScDocumentMode eMode, SfxObjectShell* pDocShell ) : xServiceManager( ::comphelper::getProcessServiceFactory() ), diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx index f821ccfb2cbc..bb3230d55b61 100644 --- a/sc/source/core/data/documen4.cxx +++ b/sc/source/core/data/documen4.cxx @@ -76,12 +76,12 @@ sal_Bool ScDocument::Solver(SCCOL nFCol, SCROW nFRow, SCTAB nFTab, CellType eFType, eVType; GetCellType(nFCol, nFRow, nFTab, eFType); GetCellType(nVCol, nVRow, nVTab, eVType); - // CELLTYPE_NOTE: no value, but referenced by formula + // CELLTYPE_EMPTY: no value, but referenced by formula // #i108005# convert target value to number using default format, // as previously done in ScInterpreter::GetDouble double nTargetVal = 0.0; sal_uInt32 nFIndex = 0; - if (eFType == CELLTYPE_FORMULA && (eVType == CELLTYPE_VALUE || eVType == CELLTYPE_NOTE) && + if (CELLTYPE_FORMULA == eFType && (CELLTYPE_VALUE == eVType || CELLTYPE_EMPTY == eVType) && GetFormatTable()->IsNumberFormat(sValStr, nFIndex, nTargetVal)) { ScSingleRefData aRefData; @@ -172,7 +172,7 @@ void ScDocument::InsertMatrixFormula(SCCOL nCol1, SCROW nRow1, if (*itr == nTab1) maTabs[*itr]->PutCell(nCol1, nRow1, pCell); else - maTabs[*itr]->PutCell(nCol1, nRow1, pCell->CloneWithoutNote(*this, ScAddress( nCol1, nRow1, *itr), SC_CLONECELL_STARTLISTENING)); + maTabs[*itr]->PutCell(nCol1, nRow1, pCell->Clone(*this, ScAddress( nCol1, nRow1, *itr), SC_CLONECELL_STARTLISTENING)); } } @@ -308,7 +308,7 @@ void ScDocument::InsertTableOp(const ScTabOpParam& rParam, // Mehrfachopera itr = rMark.begin(); for (; itr != itrEnd && *itr < nMax; ++itr) if( maTabs[*itr] ) - maTabs[*itr]->PutCell( j, k, aRefCell.CloneWithoutNote( *this, ScAddress( j, k, *itr ), SC_CLONECELL_STARTLISTENING ) ); + maTabs[*itr]->PutCell( j, k, aRefCell.Clone( *this, ScAddress( j, k, *itr ), SC_CLONECELL_STARTLISTENING ) ); } } @@ -836,8 +836,8 @@ sal_uInt16 ScDocument::RowDifferences( SCROW nThisRow, SCTAB nThisTab, nDif += 4; // Inhalt <-> leer zaehlt mehr } - if ( ( pThisCell && pThisCell->GetCellType()!=CELLTYPE_NOTE ) || - ( pOtherCell && pOtherCell->GetCellType()!=CELLTYPE_NOTE ) ) + if ( (pThisCell && pThisCell->GetCellType() != CELLTYPE_EMPTY) || + (pOtherCell && pOtherCell->GetCellType() != CELLTYPE_EMPTY) ) ++nUsed; } } @@ -877,8 +877,8 @@ sal_uInt16 ScDocument::ColDifferences( SCCOL nThisCol, SCTAB nThisTab, nDif += 4; // Inhalt <-> leer zaehlt mehr } - if ( ( pThisCell && pThisCell->GetCellType()!=CELLTYPE_NOTE ) || - ( pOtherCell && pOtherCell->GetCellType()!=CELLTYPE_NOTE ) ) + if ( (pThisCell && pThisCell->GetCellType() != CELLTYPE_EMPTY) || + (pOtherCell && pOtherCell->GetCellType() != CELLTYPE_EMPTY) ) ++nUsed; } } diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index b9526d31f272..2cf366f9dcb0 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -1895,8 +1895,9 @@ void ScDocument::CopyToClip(const ScClipParam& rClipParam, i = nTab; nEndTab = nTab; } - else + else { pClipDoc->ResetClip(this, pMarks); + } if ( bUseRangeForVBA ) CopyRangeNamesToClip(pClipDoc, aClipRange, nTab ); @@ -3261,45 +3262,192 @@ sal_Bool ScDocument::HasSelectionData( SCCOL nCol, SCROW nRow, SCTAB nTab ) cons } -ScPostIt* ScDocument::GetNote( const ScAddress& rPos ) +/** ScPostIt* ScDocument::GetNote( ScAddress const & aPos ) + +Returns the ScPostIt object pointer associated with the document address aPos. +If the specific cell does not have a note, returns the NULL pointer. + +Notes: + +- If an ScPostIt* exists for the specified address, but the cell is no + longer addressable (e.g. if the sheet was deleted, but the note was not + properly removed), this function will remove the note before returning NULL. +*/ +ScPostIt* ScDocument::GetNote( ScAddress const & aPos ) { - ScTable* pTable = ValidTab( rPos.Tab() ) && rPos.Tab() < static_cast(maTabs.size()) ? maTabs[ rPos.Tab() ] : 0; - return pTable ? pTable->GetNote( rPos.Col(), rPos.Row() ) : 0; + std::map< const ScAddress, ScPostIt* >::iterator it; + it = pNotes.find( aPos ); + + if ( pNotes.end() == it ) + return( 0 ); + + if (! ( ValidTab( aPos.Tab() ) + && aPos.Tab() < static_cast(maTabs.size()) ) + ) + { + DELETEZ( it->second ); + pNotes.erase(it); + return( 0 ); + } + + return( it->second ); } -void ScDocument::TakeNote( const ScAddress& rPos, ScPostIt*& rpNote ) +/** bool ScDocument::SetNote( ScAddress const & aPos, ScPostIt* pNote ) + +Set the ScPostIt for the cell at aPos to pNote. + +Returns true on success, or false if unable to set pNote for aPos. + +Notes: +- If a note already exists at 'aPos', it will first be deleted, before putting + pNote as the new ScPostIt for 'aPos'. +*/ +bool ScDocument::SetNote( ScAddress const & aPos, ScPostIt* pNote ) { - if( ValidTab( rPos.Tab() ) && rPos.Tab() < static_cast(maTabs.size()) && maTabs[ rPos.Tab() ] ) - maTabs[ rPos.Tab() ]->TakeNote( rPos.Col(), rPos.Row(), rpNote ); - else - DELETEZ( rpNote ); + std::map< const ScAddress, ScPostIt* >::iterator it; + it = pNotes.find( aPos ); + + if ( pNotes.end() != it ) { + // if the note is the same as what's already there, do nothing ... + if ( it->second == pNote ) + return true; + + // ... otherwise, remove old note, before ... + DELETEZ( it->second ); + pNotes.erase( it ); + } + + if ( ! ( ValidTab( aPos.Tab() ) + && aPos.Tab() < static_cast(maTabs.size()) ) + ) + return false; + + if ( pNote ) // no sense adding an empty pointer + pNotes[ aPos ] = pNote; + + return true; } -ScPostIt* ScDocument::ReleaseNote( const ScAddress& rPos ) +/** ScPostIt* ScDocument::ReleaseNote( ScAddress const & aPos ) + +Returns a pointer to the ScPostIt assigned to the document position aPos, +removing it from cell address aPos. + +Notes: +- When this function completes, the document will have no ScPostIt* + assigned to aPos. Thus, the caller must dispose of, or otherwise deal with, + the returned *ScPostIt object. +*/ +ScPostIt* ScDocument::ReleaseNote( ScAddress const & aPos ) +{ + ScPostIt* pNote = 0; + std::map< const ScAddress, ScPostIt* >::iterator it; + + it = pNotes.find( aPos ); + + if ( pNotes.end() != it ) + { + pNote = it->second; + pNotes.erase( it ); + } + + return( pNote ); +} + + +/** void ScDocument::DeleteNote( ScAddress const & aPos ) + +Removes the ScPostIt object, if any, assigned to the document address aPos. +*/ +void ScDocument::DeleteNote( ScAddress const & aPos ) { - ScTable* pTable = ValidTab( rPos.Tab() ) && rPos.Tab() < static_cast(maTabs.size())? maTabs[ rPos.Tab() ] : 0; - return pTable ? pTable->ReleaseNote( rPos.Col(), rPos.Row() ) : 0; + ScPostIt* pNote = ReleaseNote( aPos ); + DELETEZ( pNote ); } +/** bool ScDocument::MoveNote( ScAddress const & aFrom, ScAddress const & aTo ) + +Moves the ScPostIt object associated with aFrom to aTo. + +Returns true on success, false on failure. + +Notes: +- Any ScPostIt object that exists at aTo is properly removed before insertion. +- Not transactional. If the function fails, there is no guarantee that any + ScPostIt at aTo or aFrom will still exist, although they will be properly + cleaned up if they don't. +*/ +bool ScDocument::MoveNote( ScAddress const & aFrom, ScAddress const & aTo ) +{ + ScPostIt* pFromNote = ReleaseNote( aFrom ); + if ( SetNote( aTo, pFromNote ) ) + return true; + + // Doh! An error occurred. Attempt to not lose note, or at least + // don't leak the memory + if ( ! SetNote( aFrom, pFromNote ) ) + DELETEZ( pFromNote ); + + return false; +} + + +/** bool ScDocument::SwapNotes( ScAddress const & aOne, ScAddress const & aTwo ) + +Swap the notes assigned to positions aOne and aTwo. + +Returns true on success, false on failure. + +Notes: +- Not transactional. If a failure occurs, the ScPostIt objects at aOne or aTwo + may (not) be set. Any ScPostIt that is not set, however, will be properly + cleaned up. +*/ +bool ScDocument::SwapNotes( ScAddress const & aOne, ScAddress const & aTwo ) +{ + ScPostIt* pNoteA = ReleaseNote( aOne ); + ScPostIt* pNoteB = ReleaseNote( aTwo ); + + if ( ! SetNote( aTwo, pNoteA ) ) { + DELETEZ( pNoteA ); + if ( ! SetNote( aOne, pNoteB ) ) + DELETEZ( pNoteB ); + return false; + } + else + { + if ( ! SetNote( aOne, pNoteB ) ) { + DELETEZ( pNoteB ); + return false; + } + } + + return true; +} + + +/** ScPostIt* ScDocument::GetOrCreateNote( const ScAddress& rPos ) + +Returns the pointer to the ScPostIt at rPos. + +If no ScPostIt exists at rPos, create a new one for rPos and return pointer + to newly created ScPostIt. +*/ ScPostIt* ScDocument::GetOrCreateNote( const ScAddress& rPos ) { ScPostIt* pNote = GetNote( rPos ); if( !pNote ) { pNote = new ScPostIt( *this, rPos, false ); - TakeNote( rPos, pNote ); + if ( ! SetNote( rPos, pNote ) ) + DELETEZ( pNote ); //apparently unsuccessful; don't leak memory } - return pNote; -} - -void ScDocument::DeleteNote( const ScAddress& rPos ) -{ - if( ValidTab( rPos.Tab() ) && rPos.Tab() < static_cast(maTabs.size()) && maTabs[ rPos.Tab() ] ) - maTabs[ rPos.Tab() ]->DeleteNote( rPos.Col(), rPos.Row() ); + return pNote; } diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx index 0d70c48bf568..df0ec520b073 100644 --- a/sc/source/core/data/fillinfo.cxx +++ b/sc/source/core/data/fillinfo.cxx @@ -406,7 +406,7 @@ void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX RowInfo* pThisRowInfo = &pRowInfo[nArrY]; CellInfo* pInfo = &pThisRowInfo->pCellInfo[nArrX]; pInfo->pCell = pThisCol->pItems[nUIndex].pCell; - if (pInfo->pCell->GetCellType() != CELLTYPE_NOTE) + if (pInfo->pCell->GetCellType() != CELLTYPE_EMPTY) { pThisRowInfo->bEmptyText = false; // Zeile nicht leer pInfo->bEmptyCellText = false; // Zelle nicht leer diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx index ddf0941d1b44..ad6ee1a0c11c 100644 --- a/sc/source/core/data/postit.cxx +++ b/sc/source/core/data/postit.cxx @@ -855,13 +855,14 @@ ScPostIt* ScNoteUtil::CreateNoteFromCaption( aNoteData.mpCaption = &rCaption; ScPostIt* pNote = new ScPostIt( rDoc, rPos, aNoteData, false ); pNote->AutoStamp(); - rDoc.TakeNote( rPos, pNote ); - // if pNote still points to the note after TakeNote(), insertion was successful - if( pNote ) - { - // ScNoteCaptionCreator c'tor updates the caption object to be part of a note + + if ( rDoc.SetNote( rPos, pNote ) ) + // ScNoteCaptionCreator c'tor updates the caption object to be part + // of a note ScNoteCaptionCreator aCreator( rDoc, rPos, rCaption, bShown ); - } + else + DELETEZ( pNote ); // SetNote was apparently not successful. + return pNote; } @@ -892,8 +893,9 @@ ScPostIt* ScNoteUtil::CreateNoteFromObjectData( visible, the caption object will be created automatically. */ ScPostIt* pNote = new ScPostIt( rDoc, rPos, aNoteData, bAlwaysCreateCaption ); pNote->AutoStamp(); - rDoc.TakeNote( rPos, pNote ); - // if pNote still points to the note after TakeNote(), insertion was successful + if ( ! rDoc.SetNote( rPos, pNote ) ) + DELETEZ( pNote ); // SetNote was apparently not successful + return pNote; } @@ -914,8 +916,8 @@ ScPostIt* ScNoteUtil::CreateNoteFromString( visible, the caption object will be created automatically. */ pNote = new ScPostIt( rDoc, rPos, aNoteData, bAlwaysCreateCaption ); pNote->AutoStamp(); - rDoc.TakeNote( rPos, pNote ); - // if pNote still points to the note after TakeNote(), insertion was successful + if ( ! rDoc.SetNote( rPos, pNote ) ) + DELETEZ( pNote ); // SetNote was apparently not successful } return pNote; } diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx index 941ca3668926..7c2edc2b01b3 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -1239,7 +1239,7 @@ bool ScTable::GetNextMarkedCell( SCCOL& rCol, SCROW& rRow, const ScMarkData& rMa ScBaseCell* pCell = NULL; while ( aColIter.Next( nCellRow, pCell ) ) { - if ( pCell && pCell->GetCellType() != CELLTYPE_NOTE ) + if ( pCell && pCell->GetCellType() != CELLTYPE_EMPTY ) { rRow = nCellRow; return true; // Zelle gefunden @@ -1655,7 +1655,7 @@ void ScTable::MaybeAddExtraColumn(SCCOL& rCol, SCROW nRow, OutputDevice* pDev, d while (nMissing > 0 && nNewCol < MAXCOL) { ScBaseCell* pNextCell = aCol[nNewCol+1].GetCell(nRow); - if (pNextCell && pNextCell->GetCellType() != CELLTYPE_NOTE) + if (pNextCell && pNextCell->GetCellType() != CELLTYPE_EMPTY) // Cell content in a next column ends display of this string. nMissing = 0; else diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index 6b1835970f14..84fb8f1bbf4e 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -630,9 +630,15 @@ void ScTable::TransposeClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, else // kopieren { ScAddress aOwnPos( nCol, nRow, nTab ); + ScPostIt* pNewNote = pDocument->GetNote(aOwnPos); + if ( pNewNote ) + pNewNote = new ScPostIt( *pDestDoc, aDestPos, *pNewNote); + if ( ! pDestDoc->SetNote( aDestPos, pNewNote ) ) + DELETEZ( pNewNote ); // if unsuccessful, don't leak mem + if (pCell->GetCellType() == CELLTYPE_FORMULA) { - pNew = pCell->CloneWithNote( aOwnPos, *pDestDoc, aDestPos, SC_CLONECELL_STARTLISTENING ); + pNew = pCell->Clone( *pDestDoc, aDestPos, SC_CLONECELL_STARTLISTENING ); // Referenzen drehen // bei Cut werden Referenzen spaeter per UpdateTranspose angepasst @@ -642,7 +648,7 @@ void ScTable::TransposeClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, } else { - pNew = pCell->CloneWithNote( aOwnPos, *pDestDoc, aDestPos ); + pNew = pCell->Clone( *pDestDoc, aDestPos ); } } pTransClip->PutCell( static_cast(nRow-nRow1), static_cast(nCol-nCol1), pNew ); @@ -1092,50 +1098,15 @@ void ScTable::GetFormula( SCCOL nCol, SCROW nRow, String& rFormula ) } -ScPostIt* ScTable::GetNote( SCCOL nCol, SCROW nRow ) -{ - return ValidColRow( nCol, nRow ) ? aCol[ nCol ].GetNote( nRow ) : 0; -} - - -void ScTable::TakeNote( SCCOL nCol, SCROW nRow, ScPostIt*& rpNote ) -{ - if( ValidColRow( nCol, nRow ) ) - { - aCol[ nCol ].TakeNote( nRow, rpNote ); - if( rpNote && rpNote->GetNoteData().mxInitData.get() ) - { - if( !mxUninitNotes.get() ) - mxUninitNotes.reset( new ScAddress2DVec ); - mxUninitNotes->push_back( ScAddress2D( nCol, nRow ) ); - } - InvalidateTableArea(); - } - else - DELETEZ( rpNote ); -} - - -ScPostIt* ScTable::ReleaseNote( SCCOL nCol, SCROW nRow ) -{ - return ValidColRow( nCol, nRow ) ? aCol[ nCol ].ReleaseNote( nRow ) : 0; -} - - -void ScTable::DeleteNote( SCCOL nCol, SCROW nRow ) -{ - if( ValidColRow( nCol, nRow ) ) - aCol[ nCol ].DeleteNote( nRow ); -} - - void ScTable::InitializeNoteCaptions( bool bForced ) { if( mxUninitNotes.get() && (bForced || pDocument->IsUndoEnabled()) ) { - for( ScAddress2DVec::iterator aIt = mxUninitNotes->begin(), aEnd = mxUninitNotes->end(); aIt != aEnd; ++aIt ) - if( ScPostIt* pNote = GetNote( aIt->first, aIt->second ) ) - pNote->GetOrCreateCaption( ScAddress( aIt->first, aIt->second, nTab ) ); + for( ScAddress2DVec::iterator aIt = mxUninitNotes->begin(), aEnd = mxUninitNotes->end(); aIt != aEnd; ++aIt ) { + ScAddress aPos( aIt->first, aIt->second, nTab ); + if( ScPostIt* pNote = pDocument->GetNote( aPos ) ) + pNote->GetOrCreateCaption( aPos ); + } mxUninitNotes.reset(); } } @@ -2970,7 +2941,7 @@ void ScTable::CopyData( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW n ScBaseCell* pCell = GetCell( nCol, nRow ); if (pCell) { - pCell = pCell->CloneWithoutNote( *pDocument ); + pCell = pCell->Clone( *pDocument ); if (pCell->GetCellType() == CELLTYPE_FORMULA) { ((ScFormulaCell*)pCell)->UpdateReference( URM_COPY, aRange, diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx index 047a7f60bcdd..2f9f8f086c3b 100644 --- a/sc/source/core/data/table3.cxx +++ b/sc/source/core/data/table3.cxx @@ -387,13 +387,13 @@ short ScTable::CompareCell( sal_uInt16 nSort, if (pCell1) { eType1 = pCell1->GetCellType(); - if (eType1 == CELLTYPE_NOTE) + if ( CELLTYPE_EMPTY == eType1) pCell1 = NULL; } if (pCell2) { eType2 = pCell2->GetCellType(); - if (eType2 == CELLTYPE_NOTE) + if ( CELLTYPE_EMPTY == eType2 ) pCell2 = NULL; } @@ -1202,7 +1202,7 @@ bool ScTable::ValidQuery(SCROW nRow, const ScQueryParam& rParam, bMatchWholeCell = false; if ( pCell ) { - if (pCell->GetCellType() != CELLTYPE_NOTE) + if (pCell->GetCellType() != CELLTYPE_EMPTY) { sal_uLong nFormat = GetNumberFormat( static_cast(rEntry.nField), nRow ); ScCellFormat::GetInputString( pCell, nFormat, aCellStr, *(pDocument->GetFormatTable()) ); @@ -1451,8 +1451,9 @@ void ScTable::TopTenQuery( ScQueryParam& rParam ) ScSortInfo** ppInfo = pArray->GetFirstArray(); SCSIZE nValidCount = nCount; // keine Note-/Leerzellen zaehlen, sind ans Ende sortiert - while ( nValidCount > 0 && ( ppInfo[nValidCount-1]->pCell == NULL || - ppInfo[nValidCount-1]->pCell->GetCellType() == CELLTYPE_NOTE ) ) + while ( nValidCount > 0 + && ( NULL == ppInfo[nValidCount-1]->pCell + || CELLTYPE_EMPTY == ppInfo[nValidCount-1]->pCell->GetCellType() ) ) nValidCount--; // keine Strings zaehlen, sind zwischen Value und Leer while ( nValidCount > 0 diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx index 4854f493581e..556dd416903b 100644 --- a/sc/source/core/data/table4.cxx +++ b/sc/source/core/data/table4.cxx @@ -808,7 +808,7 @@ void ScTable::FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, { case CELLTYPE_STRING: case CELLTYPE_EDIT: - aCol[nCol].Insert( aDestPos.Row(), pSrcCell->CloneWithoutNote( *pDocument ) ); + aCol[nCol].Insert( aDestPos.Row(), pSrcCell->Clone( *pDocument ) ); break; default: { @@ -1357,14 +1357,14 @@ void ScTable::FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, rProgress.SetStateOnPercent( ++nProgress ); } } - else if (eCellType != CELLTYPE_NOTE) + else if (eCellType != CELLTYPE_EMPTY) { for (rInner = nIMin; rInner <= nIMax; rInner++) { if (pDocument->RowFiltered( rInner, nTab)) continue; ScAddress aDestPos( static_cast(nCol), static_cast(nRow), nTab ); - aCol[nCol].Insert( aDestPos.Row(), pSrcCell->CloneWithoutNote( *pDocument ) ); + aCol[nCol].Insert( aDestPos.Row(), pSrcCell->Clone( *pDocument ) ); } nProgress += nIMax - nIMin + 1; rProgress.SetStateOnPercent( nProgress ); diff --git a/sc/source/core/data/table6.cxx b/sc/source/core/data/table6.cxx index 4edb697ad976..291f6a6ddba4 100644 --- a/sc/source/core/data/table6.cxx +++ b/sc/source/core/data/table6.cxx @@ -78,6 +78,7 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRo if ( bDoSearch && ((pCell = aCol[nCol].GetCell( nRow )) != NULL) ) { bool bMultiLine = false; + ScAddress cellPos( nCol, nRow, nTab ); CellType eCellType = pCell->GetCellType(); switch (rSearchItem.GetCellType()) { @@ -102,7 +103,7 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRo break; case SVX_SEARCHIN_NOTE: { - if(const ScPostIt* pNote = pCell->GetNote()) + if (const ScPostIt* pNote = pDocument->GetNote( cellPos )) { aString = pNote->GetText(); bMultiLine = pNote->HasMultiLineText(); @@ -156,9 +157,8 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRo rUndoStr = aString; else if (pUndoDoc) { - ScAddress aAdr( nCol, nRow, nTab ); - ScBaseCell* pUndoCell = pCell->CloneWithoutNote( *pUndoDoc ); - pUndoDoc->PutCell( aAdr, pUndoCell); + ScBaseCell* pUndoCell = pCell->Clone( *pUndoDoc ); + pUndoDoc->PutCell( cellPos, pUndoCell); } bool bRepeat = !rSearchItem.GetWordOnly(); do @@ -219,8 +219,8 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRo { // NB: rich text format is lost. // This is also true of Cells. - if( ScPostIt* pNote = pCell->GetNote() ) - pNote->SetText( ScAddress( nCol, nRow, nTab ), aString ); + if ( ScPostIt* pNote = pDocument->GetNote( cellPos ) ) + pNote->SetText( cellPos, aString ); } else if ( cMatrixFlag != MM_NONE ) { // Matrix nicht zerreissen @@ -231,8 +231,7 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRo if ( aString.GetChar(0) == '{' ) aString.Erase( 0, 1 ); } - ScAddress aAdr( nCol, nRow, nTab ); - ScFormulaCell* pFCell = new ScFormulaCell( pDocument, aAdr, + ScFormulaCell* pFCell = new ScFormulaCell( pDocument, cellPos, aString,formula::FormulaGrammar::GRAM_NATIVE_UI, cMatrixFlag ); SCCOL nMatCols; SCROW nMatRows; @@ -830,7 +829,7 @@ bool lcl_maybeReplaceCellString( ScColumn& rColObj, SCCOL& rCol, SCROW& rRow, rtl::OUString& rUndoStr, SCCOL nCol, SCROW nRow, const SvxSearchItem& rSearchItem) { ScBaseCell* pCell = rColObj.GetCell(nRow); - if (!pCell || pCell->GetCellType() == CELLTYPE_NOTE) + if (!pCell || CELLTYPE_EMPTY == pCell->GetCellType() ) { // empty cell found. rCol = nCol; @@ -1025,7 +1024,7 @@ bool ScTable::SearchRangeForAllEmptyCells( pUndoDoc->PutCell(nCol, nRow, nTab, new ScStringCell(String())); } } - else if (pCell->GetCellType() == CELLTYPE_NOTE) + else if ( CELLTYPE_EMPTY == pCell->GetCellType() ) { rMatchedRanges.Join(ScRange(nCol, nRow, nTab)); bFound = true; @@ -1034,8 +1033,15 @@ bool ScTable::SearchRangeForAllEmptyCells( { if (pUndoDoc) { - ScAddress aCellPos(nCol, nRow, nTab); - pUndoDoc->PutCell(nCol, nRow, nTab, pCell->CloneWithNote(aCellPos, *pUndoDoc, aCellPos)); + ScAddress aPos(nCol, nRow, nTab); + ScBaseCell* pNewCell = pCell->Clone(*pUndoDoc, aPos); + + ScPostIt* pNewNote = pDocument->GetNote( aPos ); + pNewNote = new ScPostIt( *pUndoDoc, aPos, *pNewNote ); + + pUndoDoc->PutCell(nCol, nRow, nTab, pNewCell); + if ( ! pUndoDoc->SetNote(aPos, pNewNote) ) + DELETEZ( pNewNote ); // don't leak mem on failure } aCol[nCol].SetString(nRow, nTab, rSearchItem.GetReplaceString()); } diff --git a/sc/source/core/tool/chartlis.cxx b/sc/source/core/tool/chartlis.cxx index 6f9129de95f5..f4093df94b75 100644 --- a/sc/source/core/tool/chartlis.cxx +++ b/sc/source/core/tool/chartlis.cxx @@ -483,7 +483,7 @@ ScChartListenerCollection::~ScChartListenerCollection() { // remove ChartListener objects before aTimer dtor is called, because // ScChartListener::EndListeningTo may cause ScChartListenerCollection::StartTimer - // to be called if an empty ScNoteCell is deleted + // to be called if an empty ScEmptyCell is deleted if (GetCount()) FreeAll(); diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx index 8a341a6c4a7d..a3c61333d96d 100644 --- a/sc/source/core/tool/chgtrack.cxx +++ b/sc/source/core/tool/chgtrack.cxx @@ -1686,7 +1686,7 @@ void ScChangeActionContent::SetValue( String& rStr, ScBaseCell*& pCell, pCell->Delete(); if ( ScChangeActionContent::GetContentCellType( pOrgCell ) ) { - pCell = pOrgCell->CloneWithoutNote( *pToDoc ); + pCell = pOrgCell->Clone( *pToDoc ); switch ( pOrgCell->GetCellType() ) { case CELLTYPE_VALUE : @@ -1846,7 +1846,7 @@ void ScChangeActionContent::PutValueToDoc( ScBaseCell* pCell, // nothing break; default: - pDoc->PutCell( aPos, pCell->CloneWithoutNote( *pDoc ) ); + pDoc->PutCell( aPos, pCell->Clone( *pDoc ) ); } } } @@ -4399,7 +4399,7 @@ ScChangeTrack* ScChangeTrack::Clone( ScDocument* pDocument ) const const ScBaseCell* pNewCell = pContent->GetNewCell(); if ( pNewCell ) { - ScBaseCell* pClonedNewCell = pNewCell->CloneWithoutNote( *pDocument ); + ScBaseCell* pClonedNewCell = pNewCell->Clone( *pDocument ); String aNewValue; pContent->GetNewString( aNewValue ); pClonedTrack->nGeneratedMin = pGenerated->GetActionNumber() + 1; @@ -4483,7 +4483,7 @@ ScChangeTrack* ScChangeTrack::Clone( ScDocument* pDocument ) const const ScChangeActionContent* pContent = dynamic_cast< const ScChangeActionContent* >( pAction ); OSL_ENSURE( pContent, "ScChangeTrack::Clone: pContent is null!" ); const ScBaseCell* pOldCell = pContent->GetOldCell(); - ScBaseCell* pClonedOldCell = pOldCell ? pOldCell->CloneWithoutNote( *pDocument ) : 0; + ScBaseCell* pClonedOldCell = pOldCell ? pOldCell->Clone( *pDocument ) : 0; String aOldValue; pContent->GetOldString( aOldValue ); @@ -4502,7 +4502,7 @@ ScChangeTrack* ScChangeTrack::Clone( ScDocument* pDocument ) const const ScBaseCell* pNewCell = pContent->GetNewCell(); if ( pNewCell ) { - ScBaseCell* pClonedNewCell = pNewCell->CloneWithoutNote( *pDocument ); + ScBaseCell* pClonedNewCell = pNewCell->Clone( *pDocument ); pClonedContent->SetNewValue( pClonedNewCell, pDocument ); } diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index 1a484ef65bf4..c43f6f9f5763 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -3091,7 +3091,7 @@ bool ScCompiler::IsColRowName( const String& rName ) break; case CELLTYPE_NONE: case CELLTYPE_VALUE: - case CELLTYPE_NOTE: + case CELLTYPE_EMPTY: case CELLTYPE_SYMBOLS: #if OSL_DEBUG_LEVEL > 0 case CELLTYPE_DESTROYED: @@ -3220,7 +3220,7 @@ bool ScCompiler::IsColRowName( const String& rName ) break; case CELLTYPE_NONE: case CELLTYPE_VALUE: - case CELLTYPE_NOTE: + case CELLTYPE_EMPTY: case CELLTYPE_SYMBOLS: #if OSL_DEBUG_LEVEL > 0 case CELLTYPE_DESTROYED: diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index 3fc28bbcea1f..c4ec87742381 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -1762,7 +1762,7 @@ void ScInterpreter::ScIsEmpty() // ScCountEmptyCells(). // if (HasCellEmptyData( GetCell( aAdr))) CellType eCellType = GetCellType( GetCell( aAdr ) ); - if((eCellType == CELLTYPE_NONE) || (eCellType == CELLTYPE_NOTE)) + if ( (CELLTYPE_NONE == eCellType) || (CELLTYPE_EMPTY == eCellType) ) nRes = 1; } break; @@ -1926,7 +1926,7 @@ void ScInterpreter::ScType() switch ( GetCellType( pCell ) ) { // NOTE: this is Xcl nonsense! - case CELLTYPE_NOTE : + case CELLTYPE_EMPTY : nType = 1; // empty cell is value (0) break; case CELLTYPE_STRING : @@ -3492,7 +3492,7 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) if( eFunc == ifCOUNT2 ) { CellType eCellType = pCell->GetCellType(); - if (eCellType != CELLTYPE_NONE && eCellType != CELLTYPE_NOTE) + if (eCellType != CELLTYPE_NONE && eCellType != CELLTYPE_EMPTY) nCount++; if ( nGlobalError ) nGlobalError = 0; @@ -3555,7 +3555,7 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) do { CellType eType = pCell->GetCellType(); - if( eType != CELLTYPE_NONE && eType != CELLTYPE_NOTE ) + if( eType != CELLTYPE_NONE && eType != CELLTYPE_EMPTY ) nCount++; } while ( (pCell = aIter.GetNext()) != NULL ); @@ -4704,7 +4704,7 @@ void ScInterpreter::ScCountEmptyCells() ScAddress aAdr; PopSingleRef( aAdr ); eCellType = GetCellType( GetCell( aAdr ) ); - if (eCellType != CELLTYPE_NONE && eCellType != CELLTYPE_NOTE) + if (eCellType != CELLTYPE_NONE && eCellType != CELLTYPE_EMPTY) nCount = 1; } break; @@ -4728,7 +4728,7 @@ void ScInterpreter::ScCountEmptyCells() do { if ((eCellType = pCell->GetCellType()) != CELLTYPE_NONE - && eCellType != CELLTYPE_NOTE) + && eCellType != CELLTYPE_EMPTY) nCount++; } while ( (pCell = aDocIter.GetNext()) != NULL ); } @@ -6170,7 +6170,7 @@ bool ScInterpreter::FillEntry(ScQueryEntry& rEntry) } else { - if ( GetCellType( pCell ) == CELLTYPE_NOTE ) + if ( CELLTYPE_EMPTY == GetCellType( pCell ) ) { rEntry.bQueryByString = false; rEntry.nVal = 0.0; diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx index bbde6aaad2c0..008a8835847a 100644 --- a/sc/source/core/tool/interpr2.cxx +++ b/sc/source/core/tool/interpr2.cxx @@ -1607,8 +1607,8 @@ void ScInterpreter::ScBackSolver() if (nGlobalError == 0) { ScBaseCell* pVCell = GetCell( aValueAdr ); - // CELLTYPE_NOTE: kein Value aber von Formel referiert - bool bTempCell = (!pVCell || pVCell->GetCellType() == CELLTYPE_NOTE); + // CELLTYPE_EMPTY: kein Value aber von Formel referiert + bool bTempCell = (!pVCell || CELLTYPE_EMPTY == pVCell->GetCellType() ); ScBaseCell* pFCell = GetCell( aFormulaAdr ); if ( ((pVCell && pVCell->GetCellType() == CELLTYPE_VALUE) || bTempCell) @@ -1620,7 +1620,7 @@ void ScInterpreter::ScBackSolver() if ( bTempCell ) { - pNote = pVCell ? pVCell->ReleaseNote() : 0; + pNote = pDok->GetNote( aValueAdr ); fSaveVal = 0.0; pVCell = new ScValueCell( fSaveVal ); pDok->PutCell( aValueAdr, pVCell ); @@ -1769,7 +1769,12 @@ void ScInterpreter::ScBackSolver() } if ( bTempCell ) { - pVCell = pNote ? new ScNoteCell( pNote ) : 0; + pVCell = 0; + if ( pNote ) { + pVCell = new ScEmptyCell(); + if ( ! pDok->SetNote( aValueAdr, pNote ) ) + DELETEZ( pNote ); + } pDok->PutCell( aValueAdr, pVCell ); } else diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index 261403e6ed90..ade3e2361d8a 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -493,7 +493,7 @@ double ScInterpreter::GetCellValueOrZero( const ScAddress& rPos, const ScBaseCel } break; case CELLTYPE_NONE: - case CELLTYPE_NOTE: + case CELLTYPE_EMPTY: fValue = 0.0; // empty or broadcaster cell break; case CELLTYPE_SYMBOLS: @@ -2677,7 +2677,7 @@ void ScInterpreter::ScExternal() } else if ( ( aUnoName = ScGlobal::GetAddInCollection()->FindFunction(aFuncName, false) ).Len() ) { - // bLocalFirst=false in FindFunction, cFunc should be the stored + // bLocalFirst=false in FindFunction, cFunc should be the stored // internal name ScUnoAddInCall aCall( *ScGlobal::GetAddInCollection(), aUnoName, nParamCount ); diff --git a/sc/source/filter/dif/difexp.cxx b/sc/source/filter/dif/difexp.cxx index 980ca093f1fa..30ec33e580f0 100644 --- a/sc/source/filter/dif/difexp.cxx +++ b/sc/source/filter/dif/difexp.cxx @@ -175,7 +175,7 @@ FltError ScFormatFilterPluginImpl::ScExportDif( SvStream& rOut, ScDocument* pDoc switch( pAkt->GetCellType() ) { case CELLTYPE_NONE: - case CELLTYPE_NOTE: + case CELLTYPE_EMPTY: aOS.AssignAscii( pEmptyData ); break; case CELLTYPE_VALUE: diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx index e6621f000b40..a36b08190ce0 100644 --- a/sc/source/filter/excel/xetable.cxx +++ b/sc/source/filter/excel/xetable.cxx @@ -2329,7 +2329,7 @@ XclExpCellTable::XclExpCellTable( const XclExpRoot& rRoot ) : OSL_FAIL( "XclExpCellTable::XclExpCellTable - unknown cell type" ); // run-through! case CELLTYPE_NONE: - case CELLTYPE_NOTE: + case CELLTYPE_EMPTY: { xCell.reset( new XclExpBlankCell( GetRoot(), aXclPos, nLastXclCol, pPattern, nMergeBaseXFId ) ); @@ -2342,7 +2342,7 @@ XclExpCellTable::XclExpCellTable( const XclExpRoot& rRoot ) : maRowBfr.AppendCell( xCell, bIsMergedBase ); // notes - const ScPostIt* pScNote = pScCell ? pScCell->GetNote() : 0; + const ScPostIt* pScNote = rDoc.GetNote(aScPos); if( pScNote || (aAddNoteText.Len() > 0) ) mxNoteList->AppendNewRecord( new XclExpNote( GetRoot(), aScPos, pScNote, aAddNoteText ) ); diff --git a/sc/source/filter/html/htmlexp.cxx b/sc/source/filter/html/htmlexp.cxx index 84c734e7fd13..c7ceea9bd37e 100644 --- a/sc/source/filter/html/htmlexp.cxx +++ b/sc/source/filter/html/htmlexp.cxx @@ -1181,7 +1181,7 @@ void ScHTMLExport::WriteCell( SCCOL nCol, SCROW nRow, SCTAB nTab ) Color* pColor; switch ( pCell->GetCellType() ) { - case CELLTYPE_NOTE : + case CELLTYPE_EMPTY : // nothing break; case CELLTYPE_EDIT : diff --git a/sc/source/filter/lotus/expop.cxx b/sc/source/filter/lotus/expop.cxx index c1b0ae23a4e2..f1b5a8dcbe8f 100644 --- a/sc/source/filter/lotus/expop.cxx +++ b/sc/source/filter/lotus/expop.cxx @@ -393,7 +393,7 @@ FltError ExportWK1::Write() WKString( nCol, nRow, ( ScFormulaCell * ) pCell, *pPatAttr ); } break; - case CELLTYPE_NOTE: + case CELLTYPE_EMPTY: case CELLTYPE_NONE: break; default: diff --git a/sc/source/filter/rtf/rtfexp.cxx b/sc/source/filter/rtf/rtfexp.cxx index ffef3ce6a782..a1d78f26ba0e 100644 --- a/sc/source/filter/rtf/rtfexp.cxx +++ b/sc/source/filter/rtf/rtfexp.cxx @@ -195,7 +195,7 @@ void ScRTFExport::WriteCell( SCTAB nTab, SCROW nRow, SCCOL nCol ) { switch ( pCell->GetCellType() ) { - case CELLTYPE_NOTE : + case CELLTYPE_EMPTY : bValueData = false; break; // nix case CELLTYPE_EDIT : diff --git a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx index d5259697fbb9..5808ac9b2122 100644 --- a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx +++ b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx @@ -101,7 +101,7 @@ ScBaseCell* ScMyCellInfo::CreateCell(ScDocument* pDoc) } } - return pCell ? pCell->CloneWithoutNote( *pDoc ) : 0; + return pCell ? pCell->Clone( *pDoc ) : 0; } ScMyDeleted::ScMyDeleted() @@ -682,7 +682,7 @@ void ScXMLChangeTrackingImportHelper::SetContentDependencies(ScMyContentAction* const ScBaseCell* pOldCell = pActContent->GetOldCell(); if (pOldCell) { - ScBaseCell* pNewCell = pOldCell->CloneWithoutNote( *pDoc ); + ScBaseCell* pNewCell = pOldCell->Clone( *pDoc ); if (pNewCell) { pPrevActContent->SetNewCell(pNewCell, pDoc, EMPTY_STRING); @@ -774,7 +774,7 @@ void ScXMLChangeTrackingImportHelper::SetNewCell(ScMyContentAction* pAction) { ScBaseCell* pNewCell = NULL; if (pCell->GetCellType() != CELLTYPE_FORMULA) - pNewCell = pCell->CloneWithoutNote( *pDoc ); + pNewCell = pCell->Clone( *pDoc ); else { sal_uInt8 nMatrixFlag = static_cast(pCell)->GetMatrixFlag(); diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx index 06d80ced67cf..2a13153b35af 100644 --- a/sc/source/filter/xml/xmlcelli.cxx +++ b/sc/source/filter/xml/xmlcelli.cxx @@ -761,7 +761,7 @@ bool lcl_IsEmptyOrNote( ScDocument* pDoc, const table::CellAddress& rCurrentPos ScAddress aScAddress; ScUnoConversion::FillScAddress( aScAddress, rCurrentPos ); ScBaseCell* pCell = pDoc->GetCell( aScAddress ); - return ( !pCell || pCell->GetCellType() == CELLTYPE_NOTE ); + return ( !pCell || CELLTYPE_EMPTY == pCell->GetCellType() ); } void ScXMLTableRowCellContext::EndElement() diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx index 6bf85b573937..d316aedea925 100644 --- a/sc/source/ui/docshell/dbdocfun.cxx +++ b/sc/source/ui/docshell/dbdocfun.cxx @@ -1178,9 +1178,10 @@ sal_Bool lcl_EmptyExcept( ScDocument* pDoc, const ScRange& rRange, const ScRange ScBaseCell* pCell = aIter.GetFirst(); while (pCell) { - if ( !pCell->IsBlank() ) // real content? + ScAddress aPos( aIter.GetPos() ); + if ( !pCell->IsBlank() || pDoc->GetNote( aPos ) ) // real content? { - if ( !rExcept.In( ScAddress( aIter.GetCol(), aIter.GetRow(), aIter.GetTab() ) ) ) + if ( !rExcept.In( aPos ) ) return false; // cell found } pCell = aIter.GetNext(); diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index f218b8b0ac21..f260d798aba8 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -791,7 +791,7 @@ sal_Bool ScDocFunc::SetNormalString( const ScAddress& rPos, const String& rText, pTabs = new SCTAB[1]; pTabs[0] = rPos.Tab(); ppOldCells = new ScBaseCell*[1]; - ppOldCells[0] = pDocCell ? pDocCell->CloneWithoutNote( *pDoc ) : 0; + ppOldCells[0] = pDocCell ? pDocCell->Clone( *pDoc ) : 0; pHasFormat = new sal_Bool[1]; pOldFormats = new sal_uLong[1]; @@ -855,8 +855,8 @@ sal_Bool ScDocFunc::PutCell( const ScAddress& rPos, ScBaseCell* pNewCell, sal_Bo sal_Bool bHeight = ( bEditDeleted || bEditCell || pDoc->HasAttrib( ScRange(rPos), HASATTR_NEEDHEIGHT ) ); - ScBaseCell* pUndoCell = (bUndo && pDocCell) ? pDocCell->CloneWithoutNote( *pDoc, rPos ) : 0; - ScBaseCell* pRedoCell = (bUndo && pNewCell) ? pNewCell->CloneWithoutNote( *pDoc, rPos ) : 0; + ScBaseCell* pUndoCell = (bUndo && pDocCell) ? pDocCell->Clone( *pDoc, rPos ) : 0; + ScBaseCell* pRedoCell = (bUndo && pNewCell) ? pNewCell->Clone( *pDoc, rPos ) : 0; pDoc->PutCell( rPos, pNewCell ); diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index d09eb8f33647..047cbf54235b 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -270,7 +270,7 @@ sal_uInt16 ScDocShell::GetHiddenInformationState( sal_uInt16 nStates ) { ScCellIterator aCellIter( &aDocument, 0,0, nTable, MAXCOL,MAXROW, nTable ); for( ScBaseCell* pCell = aCellIter.GetFirst(); pCell && !bFound; pCell = aCellIter.GetNext() ) - if (pCell->HasNote()) + if (aDocument.GetNote( aCellIter.GetPos() )) bFound = sal_True; nTable++; } @@ -1798,7 +1798,7 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt sal_Bool bString; switch ( eType ) { - case CELLTYPE_NOTE: + case CELLTYPE_EMPTY: case CELLTYPE_NONE: aString.Erase(); bString = false; diff --git a/sc/source/ui/docshell/docsh8.cxx b/sc/source/ui/docshell/docsh8.cxx index c33b76a923c6..ec4c0a4678ca 100644 --- a/sc/source/ui/docshell/docsh8.cxx +++ b/sc/source/ui/docshell/docsh8.cxx @@ -973,7 +973,7 @@ sal_uLong ScDocShell::DBaseExport( const String& rFullFileName, CharSet eCharSet { ScBaseCell* pCell; aDocument.GetCell( nDocCol, nDocRow, nTab, pCell ); - if ( pCell && pCell->GetCellType() != CELLTYPE_NOTE ) + if ( pCell && pCell->GetCellType() != CELLTYPE_EMPTY ) { if ( pCell->GetCellType() == CELLTYPE_EDIT ) { // Paragraphs erhalten @@ -1090,7 +1090,7 @@ sal_uLong ScDocShell::DBaseExport( const String& rFullFileName, CharSet eCharSet { case sdbc::DataType::LONGVARCHAR: { - if ( pCell->GetCellType() != CELLTYPE_NOTE ) + if ( pCell->GetCellType() != CELLTYPE_EMPTY ) { if ( pCell->GetCellType() == CELLTYPE_EDIT ) lcl_getLongVarCharEditString( aString, diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx index 830d832399c0..a77065d613c3 100644 --- a/sc/source/ui/docshell/impex.cxx +++ b/sc/source/ui/docshell/impex.cxx @@ -1362,7 +1362,7 @@ const sal_Unicode* ScImportExport::ScanNextFieldFromString( const sal_Unicode* p const sal_Unicode cBlank = ' '; if (!ScGlobal::UnicodeStrChr( pSeps, cBlank)) { - // Cope with broken generators that put leading blanks before a quoted + // Cope with broken generators that put leading blanks before a quoted // field, like "field1", "field2", "..." // NOTE: this is not in conformance with http://tools.ietf.org/html/rfc4180 const sal_Unicode* pb = p; @@ -1495,7 +1495,7 @@ sal_Bool ScImportExport::Doc2Text( SvStream& rStrm ) lcl_WriteSimpleString( rStrm, aCell ); } break; - case CELLTYPE_NOTE: + case CELLTYPE_EMPTY: case CELLTYPE_NONE: break; default: diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx index 25330e7ca78c..85dd15da18fb 100644 --- a/sc/source/ui/navipi/content.cxx +++ b/sc/source/ui/navipi/content.cxx @@ -878,7 +878,7 @@ void ScContentTree::GetNoteStrings() { ScCellIterator aIter( pDoc, 0,0,nTab, MAXCOL,MAXROW,nTab ); for( ScBaseCell* pCell = aIter.GetFirst(); pCell; pCell = aIter.GetNext() ) - if( const ScPostIt* pNote = pCell->GetNote() ) + if ( const ScPostIt* pNote = pDoc->GetNote( aIter.GetPos() ) ) InsertContent( SC_CONTENT_NOTE, lcl_NoteString( *pNote ) ); } } @@ -897,10 +897,10 @@ ScAddress ScContentTree::GetNotePos( sal_uLong nIndex ) ScBaseCell* pCell = aIter.GetFirst(); while (pCell) { - if( pCell->HasNote() ) + if( pDoc->GetNote( aIter.GetPos() ) ) { if (nFound == nIndex) - return ScAddress( aIter.GetCol(), aIter.GetRow(), nTab ); // gefunden + return aIter.GetPos(); ++nFound; } pCell = aIter.GetNext(); @@ -931,7 +931,7 @@ sal_Bool ScContentTree::NoteStringsChanged() ScBaseCell* pCell = aIter.GetFirst(); while (pCell && bEqual) { - if( const ScPostIt* pNote = pCell->GetNote() ) + if ( const ScPostIt* pNote = pDoc->GetNote( aIter.GetPos() ) ) { if ( !pEntry ) bEqual = false; diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx index a4c6c6dc529f..1fb2d3ac6304 100644 --- a/sc/source/ui/undo/undocell.cxx +++ b/sc/source/ui/undo/undocell.cxx @@ -278,7 +278,7 @@ void ScUndoEnterData::Undo() ScDocument* pDoc = pDocShell->GetDocument(); for (sal_uInt16 i=0; iCloneWithoutNote( *pDoc, SC_CLONECELL_STARTLISTENING ) : 0; + ScBaseCell* pNewCell = ppOldCells[i] ? ppOldCells[i]->Clone( *pDoc, SC_CLONECELL_STARTLISTENING ) : 0; pDoc->PutCell( nCol, nRow, pTabs[i], pNewCell ); if (pHasFormat && pOldFormats) @@ -411,7 +411,7 @@ void ScUndoEnterValue::Undo() BeginUndo(); ScDocument* pDoc = pDocShell->GetDocument(); - ScBaseCell* pNewCell = pOldCell ? pOldCell->CloneWithoutNote( *pDoc, SC_CLONECELL_STARTLISTENING ) : 0; + ScBaseCell* pNewCell = pOldCell ? pOldCell->Clone( *pDoc, SC_CLONECELL_STARTLISTENING ) : 0; pDoc->PutCell( aPos, pNewCell ); @@ -497,7 +497,7 @@ void ScUndoPutCell::Undo() BeginUndo(); ScDocument* pDoc = pDocShell->GetDocument(); - ScBaseCell* pNewCell = pOldCell ? pOldCell->CloneWithoutNote( *pDoc, aPos, SC_CLONECELL_STARTLISTENING ) : 0; + ScBaseCell* pNewCell = pOldCell ? pOldCell->Clone( *pDoc, aPos, SC_CLONECELL_STARTLISTENING ) : 0; pDoc->PutCell( aPos.Col(), aPos.Row(), aPos.Tab(), pNewCell ); @@ -515,7 +515,7 @@ void ScUndoPutCell::Redo() BeginRedo(); ScDocument* pDoc = pDocShell->GetDocument(); - ScBaseCell* pNewCell = pEnteredCell ? pEnteredCell->CloneWithoutNote( *pDoc, aPos, SC_CLONECELL_STARTLISTENING ) : 0; + ScBaseCell* pNewCell = pEnteredCell ? pEnteredCell->Clone( *pDoc, aPos, SC_CLONECELL_STARTLISTENING ) : 0; pDoc->PutCell( aPos.Col(), aPos.Row(), aPos.Tab(), pNewCell ); @@ -901,7 +901,8 @@ void ScUndoReplaceNote::DoInsertNote( const ScNoteData& rNoteData ) ScDocument& rDoc = *pDocShell->GetDocument(); OSL_ENSURE( !rDoc.GetNote( maPos ), "ScUndoReplaceNote::DoInsertNote - unexpected cell note" ); ScPostIt* pNote = new ScPostIt( rDoc, maPos, rNoteData, false ); - rDoc.TakeNote( maPos, pNote ); + if ( ! rDoc.SetNote( maPos, pNote ) ) + DELETEZ( pNote ); // Apparently unsuccesful, so don't leak memory. } } diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index 748b3c0b3cc1..7b6cd4c6338b 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -1276,7 +1276,7 @@ String lcl_GetInputString( ScDocument* pDoc, const ScAddress& rPosition, sal_Boo if ( pDoc ) { ScBaseCell* pCell = pDoc->GetCell( rPosition ); - if ( pCell && pCell->GetCellType() != CELLTYPE_NOTE ) + if ( pCell && pCell->GetCellType() != CELLTYPE_EMPTY ) { CellType eType = pCell->GetCellType(); if ( eType == CELLTYPE_FORMULA ) @@ -3446,10 +3446,9 @@ uno::Reference SAL_CALL ScCellRangesBase::queryEmptyCel while (pCell) { // Notizen zaehlen als nicht-leer - if ( !pCell->IsBlank() ) - aMarkData.SetMultiMarkArea( - ScRange( aIter.GetCol(), aIter.GetRow(), aIter.GetTab() ), - false ); + ScAddress aPos( aIter.GetPos() ); + if ( !pCell->IsBlank() || pDoc->GetNote( aPos ) ) + aMarkData.SetMultiMarkArea( ScRange( aPos ), false ); pCell = aIter.GetNext(); } @@ -3487,7 +3486,8 @@ uno::Reference SAL_CALL ScCellRangesBase::queryContentC while (pCell) { sal_Bool bAdd = false; - if ( pCell->HasNote() && ( nContentFlags & sheet::CellFlags::ANNOTATION ) ) + if ( pDoc->GetNote( aIter.GetPos() ) + && ( nContentFlags & sheet::CellFlags::ANNOTATION ) ) bAdd = sal_True; else switch ( pCell->GetCellType() ) @@ -3639,7 +3639,7 @@ uno::Reference ScCellRangesBase::QueryDifferences_Impl( ScBaseCell* pCmpCell = aCmpIter.GetFirst(); while (pCmpCell) { - if (pCmpCell->GetCellType() != CELLTYPE_NOTE) + if (pCmpCell->GetCellType() != CELLTYPE_EMPTY) { SCCOLROW nCellPos = bColumnDiff ? static_cast(aCmpIter.GetCol()) : static_cast(aCmpIter.GetRow()); if (bColumnDiff) @@ -6174,7 +6174,7 @@ String ScCellObj::GetOutputString_Impl(ScDocument* pDoc, const ScAddress& aCellP if ( pDoc ) { ScBaseCell* pCell = pDoc->GetCell( aCellPos ); - if ( pCell && pCell->GetCellType() != CELLTYPE_NOTE ) + if ( pCell && pCell->GetCellType() != CELLTYPE_EMPTY ) { if ( pCell->GetCellType() == CELLTYPE_EDIT ) { @@ -9201,7 +9201,7 @@ void ScCellsEnumeration::CheckPos_Impl() sal_Bool bFound = false; ScDocument* pDoc = pDocShell->GetDocument(); ScBaseCell* pCell = pDoc->GetCell(aPos); - if ( pCell && pCell->GetCellType() != CELLTYPE_NOTE ) + if ( pCell && pCell->GetCellType() != CELLTYPE_EMPTY ) { if (!pMark) { diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx index 757edb66d1ed..f3b91a589e1e 100644 --- a/sc/source/ui/unoobj/chart2uno.cxx +++ b/sc/source/ui/unoobj/chart2uno.cxx @@ -2451,7 +2451,7 @@ void ScChart2DataSequence::BuildDataCache() #endif case CELLTYPE_EDIT: case CELLTYPE_NONE: - case CELLTYPE_NOTE: + case CELLTYPE_EMPTY: case CELLTYPE_STRING: case CELLTYPE_SYMBOLS: default: diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index 4d4d5880a2a2..73fa37ce8323 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -3397,11 +3397,11 @@ bool ScAnnotationsObj::GetAddressByIndex_Impl( sal_Int32 nIndex, ScAddress& rPos ScCellIterator aCellIter( pDoc, 0,0, nTab, MAXCOL,MAXROW, nTab ); for( ScBaseCell* pCell = aCellIter.GetFirst(); pCell; pCell = aCellIter.GetNext() ) { - if (pCell->HasNote()) + if ( pDoc->GetNote( aCellIter.GetPos() ) ) { if (nFound == nIndex) { - rPos = ScAddress( aCellIter.GetCol(), aCellIter.GetRow(), aCellIter.GetTab() ); + rPos = aCellIter.GetPos(); return true; } ++nFound; @@ -3476,9 +3476,10 @@ sal_Int32 SAL_CALL ScAnnotationsObj::getCount() throw(uno::RuntimeException) sal_uLong nCount = 0; if (pDocShell) { - ScCellIterator aCellIter( pDocShell->GetDocument(), 0,0, nTab, MAXCOL,MAXROW, nTab ); + ScDocument* pDoc = pDocShell->GetDocument(); + ScCellIterator aCellIter( pDoc, 0,0, nTab, MAXCOL,MAXROW, nTab ); for( ScBaseCell* pCell = aCellIter.GetFirst(); pCell; pCell = aCellIter.GetNext() ) - if (pCell->HasNote()) + if ( pDoc->GetNote( aCellIter.GetPos() ) ) ++nCount; } return nCount; diff --git a/sc/source/ui/unoobj/funcuno.cxx b/sc/source/ui/unoobj/funcuno.cxx index f49a2402ed85..bc78043cb7b0 100644 --- a/sc/source/ui/unoobj/funcuno.cxx +++ b/sc/source/ui/unoobj/funcuno.cxx @@ -193,7 +193,7 @@ sal_Bool lcl_CopyData( ScDocument* pSrcDoc, const ScRange& rSrcRange, { if (pCell->GetCellType() == CELLTYPE_FORMULA) { - ScAddress aCellPos = aIter.GetPos(); + ScAddress aCellPos( aIter.GetPos() ); sal_uInt32 nFormat = pClipDoc->GetNumberFormat(aCellPos); if ( (nFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 ) { diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx index 531ac702250d..d27bba70128b 100644 --- a/sc/source/ui/view/cellsh.cxx +++ b/sc/source/ui/view/cellsh.cxx @@ -936,7 +936,7 @@ void ScCellShell::GetState(SfxItemSet &rSet) { ScCellIterator aCellIter(pDoc, *aRanges[nPos]); for( ScBaseCell* pCell = aCellIter.GetFirst(); pCell && !bEnable; pCell = aCellIter.GetNext() ) - if ( pCell->HasNote() ) + if ( pDoc->GetNote( aCellIter.GetPos() ) ) bEnable = sal_True; // note found } } diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 69c7a52d7c58..14609a7d15e0 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -387,7 +387,7 @@ sal_Bool lcl_GetHyperlinkCell(ScDocument* pDoc, SCCOL& rPosX, SCROW& rPosY, SCTA do { pDoc->GetCell( rPosX, rPosY, nTab, rpCell ); - if ( !rpCell || rpCell->GetCellType() == CELLTYPE_NOTE ) + if ( !rpCell || CELLTYPE_EMPTY == rpCell->GetCellType() ) { if ( rPosX <= 0 ) return false; // alles leer bis links diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx index 35fbedc52469..14515f68ce1f 100644 --- a/sc/source/ui/view/output.cxx +++ b/sc/source/ui/view/output.cxx @@ -2096,6 +2096,7 @@ void ScOutputData::DrawNoteMarks() { CellInfo* pInfo = &pThisRowInfo->pCellInfo[nX+1]; ScBaseCell* pCell = pInfo->pCell; + ScAddress aPos( nX, pThisRowInfo->nRowNo, nTab ); sal_Bool bIsMerged = false; if ( nX==nX1 && pInfo->bHOverlapped && !pInfo->bVOverlapped ) @@ -2106,12 +2107,17 @@ void ScOutputData::DrawNoteMarks() SCCOL nMergeX = nX; SCROW nMergeY = nY; pDoc->ExtendOverlapped( nMergeX, nMergeY, nX, nY, nTab ); - pCell = pDoc->GetCell( ScAddress(nMergeX,nMergeY,nTab) ); + aPos.SetCol( nMergeX ); + aPos.SetRow( nMergeY ); + pCell = pDoc->GetCell( aPos ); // use origin's pCell for NotePtr test below } - if ( pCell && pCell->HasNote() && ( bIsMerged || - ( !pInfo->bHOverlapped && !pInfo->bVOverlapped ) ) ) + if ( pCell + && pDoc->GetNote( aPos ) + && ( bIsMerged + || ( !pInfo->bHOverlapped && !pInfo->bVOverlapped ) ) + ) { if (bFirst) { @@ -2178,18 +2184,24 @@ void ScOutputData::AddPDFNotes() SCROW nY = pRowInfo[nArrY].nRowNo; SCCOL nMergeX = nX; SCROW nMergeY = nY; + ScAddress aPos( nX, nY, nTab ); if ( nX==nX1 && pInfo->bHOverlapped && !pInfo->bVOverlapped ) { // find start of merged cell bIsMerged = sal_True; pDoc->ExtendOverlapped( nMergeX, nMergeY, nX, nY, nTab ); - pCell = pDoc->GetCell( ScAddress(nMergeX,nMergeY,nTab) ); + aPos.SetCol( nMergeX ); + aPos.SetRow( nMergeY ); + pCell = pDoc->GetCell( aPos ); // use origin's pCell for NotePtr test below } - if ( pCell && pCell->HasNote() && ( bIsMerged || - ( !pInfo->bHOverlapped && !pInfo->bVOverlapped ) ) ) + const ScPostIt* pNote = pDoc->GetNote( aPos ); + if ( pCell && pNote + && ( bIsMerged + || ( !pInfo->bHOverlapped && !pInfo->bVOverlapped ) ) + ) { long nNoteWidth = (long)( SC_CLIPMARK_SIZE * nPPTX ); long nNoteHeight = (long)( SC_CLIPMARK_SIZE * nPPTY ); @@ -2208,11 +2220,10 @@ void ScOutputData::AddPDFNotes() if ( bLayoutRTL ? ( nMarkX >= 0 ) : ( nMarkX < nScrX+nScrW ) ) { Rectangle aNoteRect( nMarkX, nPosY, nMarkX+nNoteWidth*nLayoutSign, nPosY+nNoteHeight ); - const ScPostIt* pNote = pCell->GetNote(); // Note title is the cell address (as on printed note pages) String aTitle; - ScAddress aAddress( nMergeX, nMergeY, nTab ); + ScAddress aAddress( aPos ); aAddress.Format( aTitle, SCA_VALID, pDoc, pDoc->GetAddressConvention() ); // Content has to be a simple string without line breaks diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index b0dba17f4507..0082cdf92052 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -1088,7 +1088,7 @@ sal_Bool ScOutputData::IsAvailable( SCCOL nX, SCROW nY ) // where a note is empty as well as a cell that's hidden by protection settings const ScBaseCell* pCell = pDoc->GetCell( ScAddress( nX, nY, nTab ) ); - if ( pCell && pCell->GetCellType() != CELLTYPE_NOTE && !IsEmptyCellText( NULL, nX, nY ) ) + if ( pCell && pCell->GetCellType() != CELLTYPE_EMPTY && !IsEmptyCellText( NULL, nX, nY ) ) { return false; } diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx index 7c07e11c714f..4dee3fb68ce4 100644 --- a/sc/source/ui/view/printfun.cxx +++ b/sc/source/ui/view/printfun.cxx @@ -1924,8 +1924,7 @@ long ScPrintFunc::DoNotes( long nNoteStart, sal_Bool bDoPrint, ScPreviewLocation { ScAddress &rPos = aNotePosList[ nNoteStart + nCount ]; - ScBaseCell* pCell = pDoc->GetCell( rPos); - if( const ScPostIt* pNote = pCell->GetNote() ) + if( const ScPostIt* pNote = pDoc->GetNote( rPos ) ) { if(const EditTextObject *pEditText = pNote->GetEditTextObject()) pEditEngine->SetText(*pEditText); @@ -2565,9 +2564,10 @@ long ScPrintFunc::CountNotePages() ScBaseCell* pCell = aIter.GetNext( nCol, nRow ); while (pCell) { - if (pCell->HasNote()) + ScAddress aPos( nCol, nRow, nPrintTab ); + if ( pDoc->GetNote( aPos ) ) { - aNotePosList.push_back( ScAddress( nCol,nRow,nPrintTab ) ); + aNotePosList.push_back( aPos ); ++nCount; } diff --git a/sc/source/ui/view/spelleng.cxx b/sc/source/ui/view/spelleng.cxx index 10d517b31a5e..1b047acc8e87 100644 --- a/sc/source/ui/view/spelleng.cxx +++ b/sc/source/ui/view/spelleng.cxx @@ -136,7 +136,7 @@ bool ScConversionEngineBase::FindNextConversionCell() if( mpUndoDoc && pCell ) { - ScBaseCell* pUndoCell = pCell->CloneWithoutNote( *mpUndoDoc ); + ScBaseCell* pUndoCell = pCell->Clone( *mpUndoDoc ); mpUndoDoc->PutCell( aPos, pUndoCell ); } @@ -157,7 +157,7 @@ bool ScConversionEngineBase::FindNextConversionCell() if( mpRedoDoc && pCell ) { - ScBaseCell* pRedoCell = pCell->CloneWithoutNote( *mpRedoDoc ); + ScBaseCell* pRedoCell = pCell->Clone( *mpRedoDoc ); mpRedoDoc->PutCell( aPos, pRedoCell ); } diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index dacdb113f932..dcea6d5ee24c 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -397,7 +397,7 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rS pDoc->GetCell( nCol, nRow, i, pDocCell ); if ( pDocCell ) { - ppOldCells[nUndoPos] = pDocCell->CloneWithoutNote( *pDoc ); + ppOldCells[nUndoPos] = pDocCell->Clone( *pDoc ); if ( pDocCell->GetCellType() == CELLTYPE_EDIT ) bEditDeleted = sal_True; @@ -709,7 +709,7 @@ void ScViewFunc::EnterValue( SCCOL nCol, SCROW nRow, SCTAB nTab, const double& r nCol,nRow,nTab, nCol,nRow,nTab, HASATTR_NEEDHEIGHT ); // Undo - ScBaseCell* pUndoCell = (bUndo && pOldCell) ? pOldCell->CloneWithoutNote( *pDoc ) : 0; + ScBaseCell* pUndoCell = (bUndo && pOldCell) ? pOldCell->Clone( *pDoc ) : 0; pDoc->SetValue( nCol, nRow, nTab, rValue ); @@ -804,7 +804,7 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const EditTextOb pTabs[nPos] = *itr; ScBaseCell* pDocCell; pDoc->GetCell( nCol, nRow, *itr, pDocCell ); - ppOldCells[nPos] = pDocCell ? pDocCell->CloneWithoutNote( *pDoc ) : 0; + ppOldCells[nPos] = pDocCell ? pDocCell->Clone( *pDoc ) : 0; ++nPos; } -- cgit From c8656960d96c1d4b7d4e43403ad08105bfb2d706 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Mon, 31 Oct 2011 18:01:30 +0000 Subject: Revert "Move ScPostIt storage from ScBaseCell->ScDocument" This reverts commit 249faa5cb64a7270e852862a26b4a5e3a69a9895. --- sc/inc/cell.hxx | 64 ++++--- sc/inc/column.hxx | 9 + sc/inc/dociter.hxx | 2 - sc/inc/document.hxx | 19 +- sc/inc/global.hxx | 2 +- sc/inc/table.hxx | 8 + sc/source/core/data/autonamecache.cxx | 2 +- sc/source/core/data/cell.cxx | 86 ++++++--- sc/source/core/data/cell2.cxx | 2 +- sc/source/core/data/column.cxx | 66 +++---- sc/source/core/data/column2.cxx | 112 +++--------- sc/source/core/data/column3.cxx | 195 +++++++++++---------- sc/source/core/data/dociter.cxx | 18 +- sc/source/core/data/documen2.cxx | 1 + sc/source/core/data/documen4.cxx | 16 +- sc/source/core/data/document.cxx | 188 +++----------------- sc/source/core/data/fillinfo.cxx | 2 +- sc/source/core/data/postit.cxx | 22 ++- sc/source/core/data/table1.cxx | 4 +- sc/source/core/data/table2.cxx | 57 ++++-- sc/source/core/data/table3.cxx | 11 +- sc/source/core/data/table4.cxx | 6 +- sc/source/core/data/table6.cxx | 30 ++-- sc/source/core/tool/chartlis.cxx | 2 +- sc/source/core/tool/chgtrack.cxx | 10 +- sc/source/core/tool/compiler.cxx | 4 +- sc/source/core/tool/interpr1.cxx | 14 +- sc/source/core/tool/interpr2.cxx | 13 +- sc/source/core/tool/interpr4.cxx | 4 +- sc/source/filter/dif/difexp.cxx | 2 +- sc/source/filter/excel/xetable.cxx | 4 +- sc/source/filter/html/htmlexp.cxx | 2 +- sc/source/filter/lotus/expop.cxx | 2 +- sc/source/filter/rtf/rtfexp.cxx | 2 +- .../filter/xml/XMLChangeTrackingImportHelper.cxx | 6 +- sc/source/filter/xml/xmlcelli.cxx | 2 +- sc/source/ui/docshell/dbdocfun.cxx | 5 +- sc/source/ui/docshell/docfunc.cxx | 6 +- sc/source/ui/docshell/docsh.cxx | 4 +- sc/source/ui/docshell/docsh8.cxx | 4 +- sc/source/ui/docshell/impex.cxx | 4 +- sc/source/ui/navipi/content.cxx | 8 +- sc/source/ui/undo/undocell.cxx | 11 +- sc/source/ui/unoobj/cellsuno.cxx | 18 +- sc/source/ui/unoobj/chart2uno.cxx | 2 +- sc/source/ui/unoobj/docuno.cxx | 9 +- sc/source/ui/unoobj/funcuno.cxx | 2 +- sc/source/ui/view/cellsh.cxx | 2 +- sc/source/ui/view/gridwin.cxx | 2 +- sc/source/ui/view/output.cxx | 27 +-- sc/source/ui/view/output2.cxx | 2 +- sc/source/ui/view/printfun.cxx | 8 +- sc/source/ui/view/spelleng.cxx | 4 +- sc/source/ui/view/viewfunc.cxx | 6 +- 54 files changed, 480 insertions(+), 633 deletions(-) diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx index c1d5cf2a2873..7551ba693b15 100644 --- a/sc/inc/cell.hxx +++ b/sc/inc/cell.hxx @@ -65,7 +65,7 @@ class ScPatternAttr; // ============================================================================ /** Default cell clone flags: do not start listening, do not adjust 3D refs to - old position. Note: Notes must be cloned separately, through ScDocument.*/ + old position, clone note captions of cell notes. */ const int SC_CLONECELL_DEFAULT = 0x0000; /** If set, cloned formula cells will start to listen to the document. */ @@ -92,29 +92,27 @@ public: /** Base copy constructor. Does NOT clone cell note or broadcaster! */ ScBaseCell( const ScBaseCell& rCell ); - /** Returns a clone of this cell at the same position; cell broadcaster - will not be cloned. */ - ScBaseCell* Clone( ScDocument& rDestDoc, - int nCloneFlags = SC_CLONECELL_DEFAULT ) const; + /** Returns a clone of this cell at the same position, cell note and + broadcaster will not be cloned. */ + ScBaseCell* CloneWithoutNote( ScDocument& rDestDoc, int nCloneFlags = SC_CLONECELL_DEFAULT ) const; /** Returns a clone of this cell for the passed document position, cell - broadcaster will not be cloned. */ - ScBaseCell* Clone( ScDocument& rDestDoc, const ScAddress& rDestPos, - int nCloneFlags = SC_CLONECELL_DEFAULT ) const; + note and broadcaster will not be cloned. */ + ScBaseCell* CloneWithoutNote( ScDocument& rDestDoc, const ScAddress& rDestPos, int nCloneFlags = SC_CLONECELL_DEFAULT ) const; + + /** Returns a clone of this cell, clones cell note and caption object too + (unless SC_CLONECELL_NOCAPTION flag is set). Broadcaster will not be cloned. */ + ScBaseCell* CloneWithNote( const ScAddress& rOwnPos, ScDocument& rDestDoc, const ScAddress& rDestPos, int nCloneFlags = SC_CLONECELL_DEFAULT ) const; /** Due to the fact that ScBaseCell does not have a vtable, this function - deletes the cell by calling the appropriate d'tor of the derived class. - */ + deletes the cell by calling the appropriate d'tor of the derived class. */ void Delete(); inline CellType GetCellType() const { return (CellType)eCellType; } - /** Returns true, if the cell is empty (neither value nor formula). - Returns false for formula cells returning nothing; use HasEmptyData() - for that. - Does *not* check for notes; use ScDocument.GetNote() for that. - */ - bool IsBlank( ) const; + /** Returns true, if the cell is empty (neither value nor formula nor cell note). + Returns false for formula cells returning nothing, use HasEmptyData() for that. */ + bool IsBlank( bool bIgnoreNotes = false ) const; // for idle-calculations inline sal_uInt16 GetTextWidth() const { return nTextWidth; } @@ -123,6 +121,18 @@ public: inline sal_uInt8 GetScriptType() const { return nScriptType; } inline void SetScriptType( sal_uInt8 nNew ) { nScriptType = nNew; } + /** Returns true, if the cell contains a note. */ + inline bool HasNote() const { return mpNote != 0; } + /** Returns the pointer to a cell note object (read-only). */ + inline const ScPostIt* GetNote() const { return mpNote; } + /** Returns the pointer to a cell note object. */ + inline ScPostIt* GetNote() { return mpNote; } + /** Takes ownership of the passed cell note object. */ + void TakeNote( ScPostIt* pNote ); + /** Returns and forgets the own cell note object. Caller takes ownership! */ + ScPostIt* ReleaseNote(); + /** Deletes the own cell note object. */ + void DeleteNote(); /** Returns true, if the cell contains a broadcaster. */ inline bool HasBroadcaster() const { return mpBroadcaster != 0; } @@ -146,20 +156,20 @@ public: /** Error code if ScFormulaCell, else 0. */ sal_uInt16 GetErrorCode() const; - - /** ScFormulaCell with formula::svEmptyCell result, or ScEmptyCell */ + /** ScFormulaCell with formula::svEmptyCell result, or ScNoteCell (may have been + created due to reference to empty cell). */ bool HasEmptyData() const; bool HasValueData() const; bool HasStringData() const; String GetStringData() const; // only real strings - static bool CellEqual( const ScBaseCell* pCell1, const ScBaseCell* pCell2 ); private: ScBaseCell& operator=( const ScBaseCell& ); private: + ScPostIt* mpNote; /// The cell note. Cell takes ownership! SvtBroadcaster* mpBroadcaster; /// Broadcaster for changed values. Cell takes ownership! protected: @@ -170,23 +180,25 @@ protected: // ============================================================================ - -// Empty cell to take broadcaster -class SC_DLLPUBLIC ScEmptyCell : public ScBaseCell +class SC_DLLPUBLIC ScNoteCell : public ScBaseCell { public: #ifdef USE_MEMPOOL - DECL_FIXEDMEMPOOL_NEWDEL( ScEmptyCell ) + DECL_FIXEDMEMPOOL_NEWDEL( ScNoteCell ) #endif /** Cell takes ownership of the passed broadcaster. */ - explicit ScEmptyCell( SvtBroadcaster* pBC = 0 ); + explicit ScNoteCell( SvtBroadcaster* pBC = 0 ); + /** Cell takes ownership of the passed note and broadcaster. */ + explicit ScNoteCell( ScPostIt* pNote, SvtBroadcaster* pBC = 0 ); #if OSL_DEBUG_LEVEL > 0 - ~ScEmptyCell(); + ~ScNoteCell(); #endif -}; +private: + ScNoteCell( const ScNoteCell& ); +}; class SC_DLLPUBLIC ScValueCell : public ScBaseCell { diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index b665e399aaee..7e21ba884740 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -265,6 +265,15 @@ public: bool HasValueData( SCROW nRow ) const; bool HasStringCells( SCROW nStartRow, SCROW nEndRow ) const; + /** Returns the pointer to a cell note object at the passed row. */ + ScPostIt* GetNote( SCROW nRow ); + /** Sets the passed cell note object at the passed row. Takes ownership! */ + void TakeNote( SCROW nRow, ScPostIt* pNote ); + /** Returns and forgets a cell note object at the passed row. */ + ScPostIt* ReleaseNote( SCROW nRow ); + /** Deletes the note at the passed row. */ + void DeleteNote( SCROW nRow ); + void SetDirty(); void SetDirty( const ScRange& ); void SetDirtyVar(); diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx index 43e13bf3788f..c06b9935e1b1 100644 --- a/sc/inc/dociter.hxx +++ b/sc/inc/dociter.hxx @@ -479,8 +479,6 @@ private: ScHorizontalCellIterator aCellIter; ScHorizontalAttrIterator aAttrIter; - ScDocument * pDoc; - const SCTAB nTable; SCCOL nNextCol; SCROW nNextRow; diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index cbcc3b1021ec..a7ae1c3bb576 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -273,7 +273,6 @@ private: ::std::auto_ptr pExternalRefMgr; ::std::auto_ptr mpMacroMgr; - std::map< const ScAddress, ScPostIt* > pNotes; // mutable for lazy construction mutable ::std::auto_ptr< ScFormulaParserPool > @@ -803,16 +802,16 @@ public: /** Returns true, if there is any data to create a selection list for rPos. */ sal_Bool HasSelectionData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const; - /* Note management API - */ - SC_DLLPUBLIC ScPostIt* GetNote( ScAddress const & ); + /** Returns the pointer to a cell note object at the passed cell address. */ + SC_DLLPUBLIC ScPostIt* GetNote( const ScAddress& rPos ); + /** Sets the passed note at the cell with the passed cell address. */ + void TakeNote( const ScAddress& rPos, ScPostIt*& rpNote ); + /** Returns and forgets the cell note object at the passed cell address. */ + ScPostIt* ReleaseNote( const ScAddress& rPos ); + /** Returns the pointer to an existing or created cell note object at the passed cell address. */ SC_DLLPUBLIC ScPostIt* GetOrCreateNote( const ScAddress& rPos ); - bool SetNote( ScAddress const &, ScPostIt* ); - bool MoveNote( ScAddress const & from, ScAddress const & to ); - bool SwapNotes( ScAddress const &, ScAddress const & ); - ScPostIt* ReleaseNote( ScAddress const & ); - void DeleteNote( ScAddress const & ); - + /** Deletes the note at the passed cell address. */ + void DeleteNote( const ScAddress& rPos ); /** Creates the captions of all uninitialized cell notes in the specified sheet. @param bForced True = always create all captions, false = skip when Undo is disabled. */ void InitializeNoteCaptions( SCTAB nTab, bool bForced = false ); diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx index 7d72340ff943..e8f7da17e4f5 100644 --- a/sc/inc/global.hxx +++ b/sc/inc/global.hxx @@ -273,7 +273,7 @@ enum CellType CELLTYPE_VALUE, CELLTYPE_STRING, CELLTYPE_FORMULA, - CELLTYPE_EMPTY, + CELLTYPE_NOTE, CELLTYPE_EDIT, CELLTYPE_SYMBOLS // for load/save #if OSL_DEBUG_LEVEL > 0 diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index 2859dd008778..9cd3c573a072 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -340,6 +340,14 @@ public: void GetFirstDataPos(SCCOL& rCol, SCROW& rRow) const; void GetLastDataPos(SCCOL& rCol, SCROW& rRow) const; + /** Returns the pointer to a cell note object at the passed cell address. */ + ScPostIt* GetNote( SCCOL nCol, SCROW nRow ); + /** Sets the passed cell note object at the passed cell address. Takes ownership! */ + void TakeNote( SCCOL nCol, SCROW nRow, ScPostIt*& rpNote ); + /** Returns and forgets the cell note object at the passed cell address. */ + ScPostIt* ReleaseNote( SCCOL nCol, SCROW nRow ); + /** Deletes the note at the passed cell address. */ + void DeleteNote( SCCOL nCol, SCROW nRow ); /** Creates the captions of all uninitialized cell notes. @param bForced True = always create all captions, false = skip when Undo is disabled. */ void InitializeNoteCaptions( bool bForced = false ); diff --git a/sc/source/core/data/autonamecache.cxx b/sc/source/core/data/autonamecache.cxx index df8462c590a6..44f5cd58019e 100644 --- a/sc/source/core/data/autonamecache.cxx +++ b/sc/source/core/data/autonamecache.cxx @@ -90,7 +90,7 @@ const ScAutoNameAddresses& ScAutoNameCache::GetNameOccurrences( const String& rN break; case CELLTYPE_NONE: case CELLTYPE_VALUE: - case CELLTYPE_EMPTY: + case CELLTYPE_NOTE: case CELLTYPE_SYMBOLS: #if OSL_DEBUG_LEVEL > 0 case CELLTYPE_DESTROYED: diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx index c56cb239681c..49c94a50ea56 100644 --- a/sc/source/core/data/cell.cxx +++ b/sc/source/core/data/cell.cxx @@ -72,20 +72,20 @@ const sal_uInt16 MAXRECURSION = 400; #ifdef USE_MEMPOOL // MemPools auf 4k Boundaries - 64 Bytes ausrichten -const sal_uInt16 nMemPoolEmptyCell = (0x8000 - 64) / sizeof(ScEmptyCell); -const sal_uInt16 nMemPoolValueCell = (0x8000 - 64) / sizeof(ScValueCell); +const sal_uInt16 nMemPoolValueCell = (0x8000 - 64) / sizeof(ScValueCell); const sal_uInt16 nMemPoolFormulaCell = (0x8000 - 64) / sizeof(ScFormulaCell); -const sal_uInt16 nMemPoolStringCell = (0x4000 - 64) / sizeof(ScStringCell); - -IMPL_FIXEDMEMPOOL_NEWDEL( ScEmptyCell, nMemPoolEmptyCell, nMemPoolEmptyCell ) -IMPL_FIXEDMEMPOOL_NEWDEL( ScValueCell, nMemPoolValueCell, nMemPoolValueCell ) +const sal_uInt16 nMemPoolStringCell = (0x4000 - 64) / sizeof(ScStringCell); +const sal_uInt16 nMemPoolNoteCell = (0x1000 - 64) / sizeof(ScNoteCell); +IMPL_FIXEDMEMPOOL_NEWDEL( ScValueCell, nMemPoolValueCell, nMemPoolValueCell ) IMPL_FIXEDMEMPOOL_NEWDEL( ScFormulaCell, nMemPoolFormulaCell, nMemPoolFormulaCell ) -IMPL_FIXEDMEMPOOL_NEWDEL( ScStringCell, nMemPoolStringCell, nMemPoolStringCell ) +IMPL_FIXEDMEMPOOL_NEWDEL( ScStringCell, nMemPoolStringCell, nMemPoolStringCell ) +IMPL_FIXEDMEMPOOL_NEWDEL( ScNoteCell, nMemPoolNoteCell, nMemPoolNoteCell ) #endif // ============================================================================ ScBaseCell::ScBaseCell( CellType eNewType ) : + mpNote( 0 ), mpBroadcaster( 0 ), nTextWidth( TEXTWIDTH_DIRTY ), eCellType( sal::static_int_cast(eNewType) ), @@ -94,6 +94,7 @@ ScBaseCell::ScBaseCell( CellType eNewType ) : } ScBaseCell::ScBaseCell( const ScBaseCell& rCell ) : + mpNote( 0 ), mpBroadcaster( 0 ), nTextWidth( rCell.nTextWidth ), eCellType( rCell.eCellType ), @@ -103,6 +104,7 @@ ScBaseCell::ScBaseCell( const ScBaseCell& rCell ) : ScBaseCell::~ScBaseCell() { + delete mpNote; delete mpBroadcaster; OSL_ENSURE( eCellType == CELLTYPE_DESTROYED, "BaseCell Destructor" ); } @@ -121,9 +123,9 @@ ScBaseCell* lclCloneCell( const ScBaseCell& rSrcCell, ScDocument& rDestDoc, cons return new ScEditCell( static_cast< const ScEditCell& >( rSrcCell ), rDestDoc ); case CELLTYPE_FORMULA: return new ScFormulaCell( static_cast< const ScFormulaCell& >( rSrcCell ), rDestDoc, rDestPos, nCloneFlags ); - case CELLTYPE_EMPTY: - return new ScEmptyCell; - default:; + case CELLTYPE_NOTE: + return new ScNoteCell; + default:; } OSL_FAIL( "lclCloneCell - unknown cell type" ); return 0; @@ -225,7 +227,7 @@ void adjustDBRange(ScToken* pToken, ScDocument& rNewDoc, const ScDocument* pOldD } // namespace -ScBaseCell* ScBaseCell::Clone( ScDocument& rDestDoc, int nCloneFlags ) const +ScBaseCell* ScBaseCell::CloneWithoutNote( ScDocument& rDestDoc, int nCloneFlags ) const { // notes will not be cloned -> cell address only needed for formula cells ScAddress aDestPos; @@ -234,14 +236,27 @@ ScBaseCell* ScBaseCell::Clone( ScDocument& rDestDoc, int nCloneFlags ) const return lclCloneCell( *this, rDestDoc, aDestPos, nCloneFlags ); } -ScBaseCell* ScBaseCell::Clone( ScDocument& rDestDoc, const ScAddress& rDestPos, int nCloneFlags ) const +ScBaseCell* ScBaseCell::CloneWithoutNote( ScDocument& rDestDoc, const ScAddress& rDestPos, int nCloneFlags ) const { return lclCloneCell( *this, rDestDoc, rDestPos, nCloneFlags ); } +ScBaseCell* ScBaseCell::CloneWithNote( const ScAddress& rOwnPos, ScDocument& rDestDoc, const ScAddress& rDestPos, int nCloneFlags ) const +{ + ScBaseCell* pNewCell = lclCloneCell( *this, rDestDoc, rDestPos, nCloneFlags ); + if( mpNote ) + { + if( !pNewCell ) + pNewCell = new ScNoteCell; + bool bCloneCaption = (nCloneFlags & SC_CLONECELL_NOCAPTION) == 0; + pNewCell->TakeNote( mpNote->Clone( rOwnPos, rDestDoc, rDestPos, bCloneCaption ) ); + } + return pNewCell; +} void ScBaseCell::Delete() { + DeleteNote(); switch (eCellType) { case CELLTYPE_VALUE: @@ -256,8 +271,8 @@ void ScBaseCell::Delete() case CELLTYPE_FORMULA: delete (ScFormulaCell*) this; break; - case CELLTYPE_EMPTY: - delete (ScEmptyCell*) this; + case CELLTYPE_NOTE: + delete (ScNoteCell*) this; break; default: OSL_FAIL("Attempt to Delete() an unknown CELLTYPE"); @@ -265,12 +280,28 @@ void ScBaseCell::Delete() } } +bool ScBaseCell::IsBlank( bool bIgnoreNotes ) const +{ + return (eCellType == CELLTYPE_NOTE) && (bIgnoreNotes || !mpNote); +} + +void ScBaseCell::TakeNote( ScPostIt* pNote ) +{ + delete mpNote; + mpNote = pNote; +} -bool ScBaseCell::IsBlank( ) const +ScPostIt* ScBaseCell::ReleaseNote() { - return (CELLTYPE_EMPTY == eCellType); + ScPostIt* pNote = mpNote; + mpNote = 0; + return pNote; } +void ScBaseCell::DeleteNote() +{ + DELETEZ( mpNote ); +} void ScBaseCell::TakeBroadcaster( SvtBroadcaster* pBroadcaster ) { @@ -487,7 +518,7 @@ bool ScBaseCell::HasEmptyData() const { switch ( eCellType ) { - case CELLTYPE_EMPTY : + case CELLTYPE_NOTE : return true; case CELLTYPE_FORMULA : return ((ScFormulaCell*)this)->IsEmpty(); @@ -550,17 +581,17 @@ bool ScBaseCell::CellEqual( const ScBaseCell* pCell1, const ScBaseCell* pCell2 ) if ( pCell1 ) { eType1 = pCell1->GetCellType(); - if (CELLTYPE_EDIT == eType1) + if (eType1 == CELLTYPE_EDIT) eType1 = CELLTYPE_STRING; - else if (CELLTYPE_EMPTY == eType1) + else if (eType1 == CELLTYPE_NOTE) eType1 = CELLTYPE_NONE; } if ( pCell2 ) { eType2 = pCell2->GetCellType(); - if (CELLTYPE_EDIT == eType2) + if (eType2 == CELLTYPE_EDIT) eType2 = CELLTYPE_STRING; - else if (CELLTYPE_EMPTY == eType2) + else if (eType2 == CELLTYPE_NOTE) eType2 = CELLTYPE_NONE; } if ( eType1 != eType2 ) @@ -623,21 +654,26 @@ bool ScBaseCell::CellEqual( const ScBaseCell* pCell1, const ScBaseCell* pCell2 ) // ============================================================================ -ScEmptyCell::ScEmptyCell( SvtBroadcaster* pBC ) : - ScBaseCell( CELLTYPE_EMPTY ) +ScNoteCell::ScNoteCell( SvtBroadcaster* pBC ) : + ScBaseCell( CELLTYPE_NOTE ) { TakeBroadcaster( pBC ); } +ScNoteCell::ScNoteCell( ScPostIt* pNote, SvtBroadcaster* pBC ) : + ScBaseCell( CELLTYPE_NOTE ) +{ + TakeNote( pNote ); + TakeBroadcaster( pBC ); +} #if OSL_DEBUG_LEVEL > 0 -ScEmptyCell::~ScEmptyCell() +ScNoteCell::~ScNoteCell() { eCellType = CELLTYPE_DESTROYED; } #endif - // ============================================================================ ScValueCell::ScValueCell() : diff --git a/sc/source/core/data/cell2.cxx b/sc/source/core/data/cell2.cxx index 2c8d341c8141..28fb6348ebc8 100644 --- a/sc/source/core/data/cell2.cxx +++ b/sc/source/core/data/cell2.cxx @@ -61,7 +61,7 @@ using namespace formula; // STATIC DATA ----------------------------------------------------------- #ifdef USE_MEMPOOL -const sal_uInt16 nMemPoolEditCell = (0x1000 - 64) / sizeof(ScEmptyCell); +const sal_uInt16 nMemPoolEditCell = (0x1000 - 64) / sizeof(ScNoteCell); IMPL_FIXEDMEMPOOL_NEWDEL( ScEditCell, nMemPoolEditCell, nMemPoolEditCell ) #endif diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index 89e635427a10..fc1178f4a622 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -840,7 +840,7 @@ void lclTakeBroadcaster( ScBaseCell*& rpCell, SvtBroadcaster* pBC ) if( rpCell ) rpCell->TakeBroadcaster( pBC ); else - rpCell = new ScEmptyCell( pBC ); + rpCell = new ScNoteCell( pBC ); } } @@ -908,10 +908,11 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2) } else { - if ( pBC1 ) + ScNoteCell* pDummyCell = pBC1 ? new ScNoteCell( pBC1 ) : 0; + if ( pDummyCell ) { // insert dummy note cell (without note) containing old broadcaster - pItems[nIndex1].pCell = new ScEmptyCell( pBC1 ); + pItems[nIndex1].pCell = pDummyCell; } else { @@ -961,8 +962,9 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2) // do not swap formula cells with equal formulas, but swap notes if (bEqual) { - pDocument->SwapNotes( aPos1, aPos2 ); - + ScPostIt* pNote1 = pCell1->ReleaseNote(); + pCell1->TakeNote( pCell2->ReleaseNote() ); + pCell2->TakeNote( pNote1 ); return; } } @@ -971,14 +973,17 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2) /* Create clone of pCell1 at position of pCell2 (pCell1 exists always, see variable swapping above). Do not clone the note, but move pointer of old note to new cell. */ - ScBaseCell* pNew2 = pCell1->Clone( *pDocument, aPos2, SC_CLONECELL_ADJUST3DREL ); + ScBaseCell* pNew2 = pCell1->CloneWithoutNote( *pDocument, aPos2, SC_CLONECELL_ADJUST3DREL ); + pNew2->TakeNote( pCell1->ReleaseNote() ); + /* Create clone of pCell2 at position of pCell1. Do not clone the note, + but move pointer of old note to new cell. */ ScBaseCell* pNew1 = 0; if ( pCell2 ) { - pNew1 = pCell2->Clone( *pDocument, aPos1, SC_CLONECELL_ADJUST3DREL ); + pNew1 = pCell2->CloneWithoutNote( *pDocument, aPos1, SC_CLONECELL_ADJUST3DREL ); + pNew1->TakeNote( pCell2->ReleaseNote() ); } - pDocument->SwapNotes( aPos1, aPos2 ); // move old broadcasters new cells at the same old position SvtBroadcaster* pBC1 = pCell1->ReleaseBroadcaster(); @@ -1074,17 +1079,10 @@ bool ScColumn::TestInsertCol( SCROW nStartRow, SCROW nEndRow) const if (!IsEmpty()) { bool bTest = true; - if (pItems) { - ScAddress pos( nCol, 0, nTab ); - for (SCSIZE i=0; (iIsBlank()) - || (0 == pDocument->GetNote( pos )) - ); - } - } + if (pItems) + for (SCSIZE i=0; (i nEndRow) + || pItems[i].pCell->IsBlank(); // AttrArray testet nur zusammengefasste @@ -1201,9 +1199,6 @@ void ScColumn::InsertRow( SCROW nStartRow, SCSIZE nSize ) for (i = 0; i < nDelCount; i++) { ScBaseCell* pCell = ppDelCells[i]; - // Oct, 2011: Perhaps need to update IsBlank call in ENSURE to check - // for notes (via ScDocument.GetNote), but I'm not sure the current - // code (above and below this comment) is even correct. OSL_ENSURE( pCell->IsBlank(), "sichtbare Zelle weggeschoben" ); SvtBroadcaster* pBC = pCell->GetBroadcaster(); if (pBC) @@ -1252,8 +1247,6 @@ void ScColumn::CopyToClip(SCROW nRow1, SCROW nRow2, ScColumn& rColumn, bool bKee if (nBlockCount) { int nCloneFlags = bCloneNoteCaptions ? SC_CLONECELL_DEFAULT : SC_CLONECELL_NOCAPTION; - ScDocument * rDestDoc = rColumn.pDocument; - rColumn.Resize( rColumn.GetCellCount() + nBlockCount ); ScAddress aOwnPos( nCol, 0, nTab ); ScAddress aDestPos( rColumn.nCol, 0, rColumn.nTab ); @@ -1261,15 +1254,7 @@ void ScColumn::CopyToClip(SCROW nRow1, SCROW nRow2, ScColumn& rColumn, bool bKee { aOwnPos.SetRow( pItems[i].nRow ); aDestPos.SetRow( pItems[i].nRow ); - ScBaseCell* pNewCell = pItems[i].pCell->Clone( - *rDestDoc, aDestPos, nCloneFlags - ); - ScPostIt* pNewNote = pDocument->GetNote( aOwnPos ); - if (pNewNote) - pNewNote = new ScPostIt( *rDestDoc, aDestPos, *pNewNote ); - if ( ! rDestDoc->SetNote( aDestPos, pNewNote ) ) - DELETEZ( pNewNote ); // apparently unsuccessful; don't leak - + ScBaseCell* pNewCell = pItems[i].pCell->CloneWithNote( aOwnPos, *rColumn.pDocument, aDestPos, nCloneFlags ); rColumn.Append( aDestPos.Row(), pNewCell ); } } @@ -1398,12 +1383,7 @@ void ScColumn::CopyUpdated( const ScColumn& rPosCol, ScColumn& rDestCol ) const SCSIZE nThisIndex; if ( Search( aDestPos.Row(), nThisIndex ) ) { - ScBaseCell* pNew = pItems[nThisIndex].pCell->Clone( rDestDoc, aDestPos ); - ScPostIt* pNewNote = pDocument->GetNote( aOwnPos ); - pNewNote = new ScPostIt( rDestDoc, aDestPos, pNewNote ); - if ( ! rDestDoc.SetNote( aDestPos, pNewNote ) ) - DELETEZ( pNewNote ); // apparently unsuccessful; don't leak - + ScBaseCell* pNew = pItems[nThisIndex].pCell->CloneWithNote( aOwnPos, rDestDoc, aDestPos ); rDestCol.Insert( aDestPos.Row(), pNew ); } } @@ -1611,7 +1591,7 @@ void ScColumn::MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol) ScAddress aAdr( nCol, 0, nTab ); ScHint aHint( SC_HINT_DYING, aAdr, NULL ); // areas only ScAddress& rAddress = aHint.GetAddress(); - ScEmptyCell* pEmptyCell = new ScEmptyCell; // Dummy like in DeleteRange + ScNoteCell* pNoteCell = new ScNoteCell; // Dummy like in DeleteRange // must iterate backwards, because indexes of following cells become invalid for (EntryPosPairs::reverse_iterator it( aEntries.rbegin()); @@ -1620,7 +1600,7 @@ void ScColumn::MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol) nStartPos = (*it).first; nStopPos = (*it).second; for (i=nStartPos; iDelete(); + pNoteCell->Delete(); pItems[nCount].nRow = 0; pItems[nCount].pCell = NULL; } @@ -1806,7 +1786,7 @@ void ScColumn::UpdateDeleteTab( SCTAB nTable, bool bIsMove, ScColumn* pRefUndo, /* Do not copy cell note to the undo document. Undo will copy back the formula cell while keeping the original note. */ - ScBaseCell* pSave = pRefUndo ? pOld->Clone( *pDocument ) : 0; + ScBaseCell* pSave = pRefUndo ? pOld->CloneWithoutNote( *pDocument ) : 0; bool bChanged = pOld->UpdateDeleteTab(nTable, bIsMove, nSheets); if ( nRow != pItems[i].nRow ) diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index 547e83307669..83ecd3cc1036 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -946,7 +946,7 @@ void ScColumn::RemoveAutoSpellObj() String aText = ScEditUtil::GetSpaceDelimitedString( *pEngine ); ScBaseCell* pNewCell = new ScStringCell( aText ); pNewCell->TakeBroadcaster( pOldCell->ReleaseBroadcaster() ); - + pNewCell->TakeNote( pOldCell->ReleaseNote() ); pItems[i].pCell = pNewCell; delete pOldCell; } @@ -1018,7 +1018,7 @@ void ScColumn::RemoveEditAttribs( SCROW nStartRow, SCROW nEndRow ) String aText = ScEditUtil::GetSpaceDelimitedString( *pEngine ); ScBaseCell* pNewCell = new ScStringCell( aText ); pNewCell->TakeBroadcaster( pOldCell->ReleaseBroadcaster() ); - + pNewCell->TakeNote( pOldCell->ReleaseNote() ); pItems[i].pCell = pNewCell; delete pOldCell; } @@ -1150,11 +1150,7 @@ bool ScColumn::IsEmptyVisData(bool bNotes) const for (i=0; iGetNote( - ScAddress( nCol, pItems[i].nRow, nTab ) - ); - - if (pCell->GetCellType() != CELLTYPE_EMPTY || (bNotes && 0 != note)) + if ( pCell->GetCellType() != CELLTYPE_NOTE || (bNotes && pCell->HasNote()) ) bVisData = true; } return !bVisData; @@ -1171,7 +1167,7 @@ SCSIZE ScColumn::VisibleCount( SCROW nStartRow, SCROW nEndRow ) const while ( nIndex < nCount && pItems[nIndex].nRow <= nEndRow ) { if ( pItems[nIndex].nRow >= nStartRow && - pItems[nIndex].pCell->GetCellType() != CELLTYPE_EMPTY ) + pItems[nIndex].pCell->GetCellType() != CELLTYPE_NOTE ) { ++nVisCount; } @@ -1191,9 +1187,7 @@ SCROW ScColumn::GetLastVisDataPos(bool bNotes) const { --i; ScBaseCell* pCell = pItems[i].pCell; - ScPostIt *note = pDocument->GetNote( ScAddress(nCol, pItems[i].nRow, nTab) ); - - if (pCell->GetCellType() != CELLTYPE_EMPTY || (bNotes && 0 != note)) + if ( pCell->GetCellType() != CELLTYPE_NOTE || (bNotes && pCell->HasNote()) ) { bFound = true; nRet = pItems[i].nRow; @@ -1213,9 +1207,7 @@ SCROW ScColumn::GetFirstVisDataPos(bool bNotes) const for (i=0; iGetNote( ScAddress(nCol, pItems[i].nRow, nTab) ); - - if (pCell->GetCellType() != CELLTYPE_EMPTY || (bNotes && 0 != note)) + if ( pCell->GetCellType() != CELLTYPE_NOTE || (bNotes && pCell->HasNote()) ) { bFound = true; nRet = pItems[i].nRow; @@ -1228,11 +1220,9 @@ SCROW ScColumn::GetFirstVisDataPos(bool bNotes) const bool ScColumn::HasVisibleDataAt(SCROW nRow) const { SCSIZE nIndex; - if (Search(nRow, nIndex)) { - ScAddress aPos( nCol, nRow, nTab ); - if (!pItems[nIndex].pCell->IsBlank() || pDocument->GetNote(aPos)) + if (Search(nRow, nIndex)) + if (!pItems[nIndex].pCell->IsBlank()) return true; - } return false; } @@ -1259,10 +1249,8 @@ bool ScColumn::IsEmptyBlock(SCROW nStartRow, SCROW nEndRow, bool bIgnoreNotes) c Search( nStartRow, nIndex ); while ( nIndex < nCount && pItems[nIndex].nRow <= nEndRow ) { - if ( ( ! pItems[nIndex].pCell->IsBlank() ) - || ( ! bIgnoreNotes && pDocument->GetNote( ScAddress( nCol, pItems[nIndex].nRow, nTab ))) - ) - return false; // not empty if even one cell is not blank or has a note + if ( !pItems[nIndex].pCell->IsBlank( bIgnoreNotes ) ) // found a cell + return false; // not empty ++nIndex; } return true; // no cell found @@ -1275,7 +1263,6 @@ SCSIZE ScColumn::GetEmptyLinesInBlock( SCROW nStartRow, SCROW nEndRow, ScDirecti SCSIZE i; if (pItems && (nCount > 0)) { - ScAddress aPos( nCol, 0, nTab ); if (eDir == DIR_BOTTOM) { i = nCount; @@ -1284,9 +1271,7 @@ SCSIZE ScColumn::GetEmptyLinesInBlock( SCROW nStartRow, SCROW nEndRow, ScDirecti i--; if ( pItems[i].nRow < nStartRow ) break; - aPos.SetRow( pItems[i].nRow ); - ScPostIt* aNote = pDocument->GetNote( aPos ); - bFound = pItems[i].nRow <= nEndRow && (!pItems[i].pCell->IsBlank() || aNote ); + bFound = pItems[i].nRow <= nEndRow && !pItems[i].pCell->IsBlank(); } if (bFound) nLines = static_cast(nEndRow - pItems[i].nRow); @@ -1300,9 +1285,7 @@ SCSIZE ScColumn::GetEmptyLinesInBlock( SCROW nStartRow, SCROW nEndRow, ScDirecti { if ( pItems[i].nRow > nEndRow ) break; - aPos.SetRow( pItems[i].nRow ); - ScPostIt* aNote = pDocument->GetNote( aPos ); - bFound = pItems[i].nRow >= nStartRow && (!pItems[i].pCell->IsBlank() || aNote ); + bFound = pItems[i].nRow >= nStartRow && !pItems[i].pCell->IsBlank(); i++; } if (bFound) @@ -1365,14 +1348,8 @@ void ScColumn::FindDataAreaPos(SCROW& rRow, long nMovY) const SCSIZE nIndex; bool bThere = Search(rRow, nIndex); - ScAddress aPos( nCol, 0, nTab ); - if (bThere) { - aPos.SetRow(pItems[nIndex].nRow); - if ( pItems[nIndex].pCell->IsBlank() - && (0 == pDocument->GetNote( aPos ) ) - ) - bThere = false; - } + if (bThere && pItems[nIndex].pCell->IsBlank()) + bThere = false; if (bThere) { @@ -1383,22 +1360,14 @@ void ScColumn::FindDataAreaPos(SCROW& rRow, long nMovY) const if (nIndexIsBlank() - || pDocument->GetNote( aPos ) ) - ) + while (nIndexIsBlank()) { ++nIndex; ++nLast; - aPos.SetRow( pItems[nIndex].nRow ); } - if ( nIndex == nCount -1 ) - if ( pItems[nIndex].nRow == nLast +1 - && ( ! pItems[nIndex].pCell->IsBlank() - || pDocument->GetNote( aPos ) ) - ) + if (nIndex==nCount-1) + if (pItems[nIndex].nRow==nLast+1 && !pItems[nIndex].pCell->IsBlank()) ++nLast; } } @@ -1407,22 +1376,14 @@ void ScColumn::FindDataAreaPos(SCROW& rRow, long nMovY) const if (nIndex>0) { --nIndex; - aPos.SetRow( pItems[nIndex].nRow ); - while ( nIndex > 0 - && pItems[nIndex].nRow +1 == nLast - && ( ! pItems[nIndex].pCell->IsBlank() - || pDocument->GetNote( aPos ) ) - ) + while (nIndex>0 && pItems[nIndex].nRow+1==nLast + && !pItems[nIndex].pCell->IsBlank()) { --nIndex; --nLast; - aPos.SetRow( pItems[nIndex].nRow ); } - if ( 0 == nIndex ) - if ( pItems[nIndex].nRow +1 == nLast - && ( ! pItems[nIndex].pCell->IsBlank() - || pDocument->GetNote( aPos ) ) - ) + if (nIndex==0) + if (pItems[nIndex].nRow+1==nLast && !pItems[nIndex].pCell->IsBlank()) --nLast; } } @@ -1437,17 +1398,10 @@ void ScColumn::FindDataAreaPos(SCROW& rRow, long nMovY) const if (!bThere) { - aPos.SetRow( pItems[nIndex].nRow ); if (bForward) { - while ( nIndex < nCount - && ( pItems[nIndex].pCell->IsBlank() - && (0 == pDocument->GetNote( aPos )) ) - ) - { + while (nIndexIsBlank()) ++nIndex; - aPos.SetRow( pItems[nIndex].nRow ); - } if (nIndex 0 - && ( pItems[nIndex-1].pCell->IsBlank() - && (0 == pDocument->GetNote( aPos )) ) - ) - { + while (nIndex>0 && pItems[nIndex-1].pCell->IsBlank()) --nIndex; - aPos.SetRow( pItems[nIndex].nRow ); - } if (nIndex>0) rRow = pItems[nIndex-1].nRow; else @@ -1478,9 +1426,7 @@ bool ScColumn::HasDataAt(SCROW nRow) const SCSIZE nIndex; if (Search(nRow, nIndex)) - if ( ! pItems[nIndex].pCell->IsBlank() - || pDocument->GetNote( ScAddress( nCol, nRow, nTab )) - ) + if (!pItems[nIndex].pCell->IsBlank()) return true; return false; @@ -1557,7 +1503,7 @@ void ScColumn::StartListening( SvtListener& rLst, SCROW nRow ) } else { - pCell = new ScEmptyCell; + pCell = new ScNoteCell; Insert(nRow, pCell); } @@ -1582,7 +1528,7 @@ void ScColumn::MoveListeners( SvtBroadcaster& rSource, SCROW nDestRow ) } else { - pCell = new ScEmptyCell; + pCell = new ScNoteCell; Insert(nDestRow, pCell); } @@ -1616,7 +1562,7 @@ void ScColumn::EndListening( SvtListener& rLst, SCROW nRow ) if (!pBC->HasListeners()) { - if (pCell->IsBlank() && (0 == pDocument->GetNote(ScAddress(nCol, nRow, nTab))) ) + if (pCell->IsBlank()) DeleteAtIndex(nIndex); else pCell->DeleteBroadcaster(); @@ -1699,7 +1645,7 @@ void lcl_UpdateSubTotal( ScFunctionData& rData, ScBaseCell* pCell ) } } break; - case CELLTYPE_EMPTY: + case CELLTYPE_NOTE: bCell = false; break; // bei Strings nichts diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index e39cbe1cfea1..baa05185ce8e 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -88,17 +88,12 @@ void ScColumn::Insert( SCROW nRow, ScBaseCell* pNewCell ) if (Search(nRow, nIndex)) { ScBaseCell* pOldCell = pItems[nIndex].pCell; - ScAddress oldAddy( nCol, pItems[nIndex].nRow, nTab ); - ScAddress newAddy( nCol, nRow, nTab ); - ScPostIt* oldNote = pDocument->GetNote( oldAddy ); - ScPostIt* newNote = pDocument->GetNote( newAddy ); // move broadcaster and note to new cell, if not existing in new cell if (pOldCell->HasBroadcaster() && !pNewCell->HasBroadcaster()) pNewCell->TakeBroadcaster( pOldCell->ReleaseBroadcaster() ); - - if ( oldNote && !newNote ) - pDocument->MoveNote( oldAddy, newAddy ); + if (pOldCell->HasNote() && !pNewCell->HasNote()) + pNewCell->TakeNote( pOldCell->ReleaseNote() ); if ( pOldCell->GetCellType() == CELLTYPE_FORMULA && !pDocument->IsClipOrUndo() ) { @@ -153,7 +148,7 @@ void ScColumn::Insert( SCROW nRow, ScBaseCell* pNewCell ) CellType eCellType = pNewCell->GetCellType(); // Notizzelle entsteht beim Laden nur durch StartListeningCell, // ausloesende Formelzelle muss sowieso dirty sein. - if ( !(pDocument->IsCalcingAfterLoad() && eCellType == CELLTYPE_EMPTY) ) + if ( !(pDocument->IsCalcingAfterLoad() && eCellType == CELLTYPE_NOTE) ) { if ( eCellType == CELLTYPE_FORMULA ) ((ScFormulaCell*)pNewCell)->SetDirty(); @@ -217,17 +212,17 @@ void ScColumn::Delete( SCROW nRow ) if (Search(nRow, nIndex)) { ScBaseCell* pCell = pItems[nIndex].pCell; - ScEmptyCell* pEmptyCell = new ScEmptyCell; - pItems[nIndex].pCell = pEmptyCell; // Dummy, for Interpret + ScNoteCell* pNoteCell = new ScNoteCell; + pItems[nIndex].pCell = pNoteCell; // Dummy fuer Interpret pDocument->Broadcast( ScHint( SC_HINT_DYING, ScAddress( nCol, nRow, nTab ), pCell ) ); if ( SvtBroadcaster* pBC = pCell->ReleaseBroadcaster() ) { - pEmptyCell->TakeBroadcaster( pBC ); + pNoteCell->TakeBroadcaster( pBC ); } else { - pEmptyCell->Delete(); + pNoteCell->Delete(); --nCount; memmove( &pItems[nIndex], &pItems[nIndex + 1], (nCount - nIndex) * sizeof(ColEntry) ); pItems[nCount].nRow = 0; @@ -243,11 +238,11 @@ void ScColumn::Delete( SCROW nRow ) void ScColumn::DeleteAtIndex( SCSIZE nIndex ) { ScBaseCell* pCell = pItems[nIndex].pCell; - ScEmptyCell* pEmptyCell = new ScEmptyCell; - pItems[nIndex].pCell = pEmptyCell; // Dummy, for Interpret + ScNoteCell* pNoteCell = new ScNoteCell; + pItems[nIndex].pCell = pNoteCell; // Dummy fuer Interpret pDocument->Broadcast( ScHint( SC_HINT_DYING, ScAddress( nCol, pItems[nIndex].nRow, nTab ), pCell ) ); - pEmptyCell->Delete(); + pNoteCell->Delete(); --nCount; memmove( &pItems[nIndex], &pItems[nIndex + 1], (nCount - nIndex) * sizeof(ColEntry) ); pItems[nCount].nRow = 0; @@ -379,20 +374,13 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe drawing undo. */ bool bDeleteNote = (nDelFlag & IDF_NOTE) != 0; bool bNoCaptions = (nDelFlag & IDF_NOCAPTIONS) != 0; - - if (bDeleteNote && bNoCaptions) { - for ( SCSIZE nIdx = nStartIndex; nIdx <= nEndIndex; ++nIdx ) { - ScPostIt* pNote = pDocument->GetNote( - ScAddress( nCol, pItems[ nIdx ].nRow, nTab ) - ); - if ( pNote ) + if (bDeleteNote && bNoCaptions) + for ( SCSIZE nIdx = nStartIndex; nIdx <= nEndIndex; ++nIdx ) + if ( ScPostIt* pNote = pItems[ nIdx ].pCell->GetNote() ) pNote->ForgetCaption(); - } - } ScHint aHint( SC_HINT_DYING, ScAddress( nCol, 0, nTab ), 0 ); - // cache all formula cells, they will be deleted at end of this function typedef ::std::vector< ScFormulaCell* > FormulaCellVector; FormulaCellVector aDelCells; @@ -403,7 +391,7 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe SCSIZE nFirst(nStartIndex); // dummy replacement for old cells, to prevent that interpreter uses old cell - boost::scoped_ptr pDummyCell(new ScEmptyCell); + boost::scoped_ptr pDummyCell(new ScNoteCell); for ( SCSIZE nIdx = nStartIndex; nIdx <= nEndIndex; ++nIdx ) { @@ -436,7 +424,7 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe bDelete = true; else { - // decide whether to delete the cell object according to passed + // decide whether to delete the cell object according to passed // flags switch ( eCellType ) { @@ -467,7 +455,7 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe bDelete = (nDelFlag & IDF_FORMULA) != 0; break; - case CELLTYPE_EMPTY: + case CELLTYPE_NOTE: // do note delete note cell with broadcaster bDelete = bDeleteNote && !pOldCell->GetBroadcaster(); break; @@ -479,28 +467,23 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe if (bDelete) { // try to create a replacement note cell, if note or broadcaster exists - ScEmptyCell* pEmptyCell = 0; - if (eCellType != CELLTYPE_EMPTY) + ScNoteCell* pNoteCell = 0; + if (eCellType != CELLTYPE_NOTE) { - // do not rescue note if it has to be deleted according to - // passed flags - // #i99844# do not release broadcaster from old cell, it - // still has to notify deleted content + // do not rescue note if it has to be deleted according to passed flags + ScPostIt* pNote = bDeleteNote ? 0 : pOldCell->ReleaseNote(); + // #i99844# do not release broadcaster from old cell, it still has to notify deleted content SvtBroadcaster* pBC = pOldCell->GetBroadcaster(); - if ( ! bDeleteNote || pBC ) - pEmptyCell = new ScEmptyCell( pBC ); - else - pDocument->DeleteNote( - ScAddress(nCol, pItems[nIdx].nRow, nTab) - ); + if( pNote || pBC ) + pNoteCell = new ScNoteCell( pNote, pBC ); } // remove cell entry in cell item list SCROW nOldRow = pItems[nIdx].nRow; - if (pEmptyCell) + if (pNoteCell) { // replace old cell with the replacement note cell - pItems[nIdx].pCell = pEmptyCell; + pItems[nIdx].pCell = pNoteCell; // ... so it's not really deleted bDelete = false; } @@ -517,15 +500,16 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe aHint.GetAddress().SetRow( nOldRow ); aHint.SetCell( pOldCell ); pDocument->Broadcast( aHint ); - // #i99844# after broadcasting, old cell has to forget the broadcaster (owned by pEmptyCell) + // #i99844# after broadcasting, old cell has to forget the broadcaster (owned by pNoteCell) pOldCell->ReleaseBroadcaster(); pOldCell->Delete(); } } else { + // delete cell note if (bDeleteNote) - pDocument->DeleteNote( ScAddress(nCol, pItems[nIdx].nRow, nTab) ); + pItems[nIdx].pCell->DeleteNote(); } if (!bDelete) @@ -559,7 +543,7 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe { // this segment removed if (!bRemoved) nStartSegment = aIt->first; - // The first of removes in a row sets start (they should be + // The first of removes in a row sets start (they should be // alternating removed/notremoved anyway). bRemoved = true; } @@ -578,7 +562,7 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe } ++aIt; } - // The last removed segment up to nCount is discarded, there's nothing + // The last removed segment up to nCount is discarded, there's nothing // following to be moved. if (bRemoved) nShift += nCount - nStartSegment; @@ -746,7 +730,7 @@ void ScColumn::CopyFromClip(SCROW nRow1, SCROW nRow2, long nDy, while ( nStartIndex < rColumn.nCount && rColumn.pItems[nStartIndex].nRow <= nRow2-nDy ) { SCSIZE nEndIndex = nStartIndex; - if ( rColumn.pItems[nStartIndex].pCell->GetCellType() != CELLTYPE_EMPTY ) + if ( rColumn.pItems[nStartIndex].pCell->GetCellType() != CELLTYPE_NOTE ) { SCROW nStartRow = rColumn.pItems[nStartIndex].nRow; SCROW nEndRow = nStartRow; @@ -756,7 +740,7 @@ void ScColumn::CopyFromClip(SCROW nRow1, SCROW nRow2, long nDy, while ( nEndRow < nRow2-nDy && nEndIndex+1 < rColumn.nCount && rColumn.pItems[nEndIndex+1].nRow == nEndRow+1 && - rColumn.pItems[nEndIndex+1].pCell->GetCellType() != CELLTYPE_EMPTY ) + rColumn.pItems[nEndIndex+1].pCell->GetCellType() != CELLTYPE_NOTE ) { ++nEndIndex; ++nEndRow; @@ -841,29 +825,25 @@ void ScColumn::CopyFromClip(SCROW nRow1, SCROW nRow2, long nDy, passed together with IDF_NOTE in nInsFlag. Of course, there is still the need to create a new cell, if there is no cell at the destination position at all. */ - ScBaseCell* pNewCell = bAddNotes ? GetCell( aDestPos.Row() ) : 0; - if (pNewCell) + ScBaseCell* pAddNoteCell = bAddNotes ? GetCell( aDestPos.Row() ) : 0; + if (pAddNoteCell) { // do nothing if source cell does not contain a note - ScPostIt* pSourceNote = 0; - ScAddress aSourcePos( rColumn.nCol, rColumn.pItems[i].nRow, rColumn.nTab ); - if ( rColumn.pItems[i].pCell ) - pSourceNote = pDocument->GetNote( aSourcePos ); - - if ( pSourceNote ) + const ScBaseCell* pSourceCell = rColumn.pItems[i].pCell; + const ScPostIt* pSourceNote = pSourceCell ? pSourceCell->GetNote() : 0; + if (pSourceNote) { + OSL_ENSURE( !pAddNoteCell->HasNote(), "ScColumn::CopyFromClip - unexpected note at destination cell" ); bool bCloneCaption = (nInsFlag & IDF_NOCAPTIONS) == 0; // #i52342# if caption is cloned, the note must be constructed with the destination document + ScAddress aSourcePos( rColumn.nCol, rColumn.pItems[i].nRow, rColumn.nTab ); ScPostIt* pNewNote = pSourceNote->Clone( aSourcePos, *pDocument, aDestPos, bCloneCaption ); - ScAddress newAddy( nCol, aDestPos.Row(), nTab ); - - if ( ! pDocument->SetNote( newAddy, pNewNote ) ) - DELETEZ( pNewNote ); // apparently unsuccessful; no leak + pAddNoteCell->TakeNote( pNewNote ); } } else { - pNewCell = bAsLink ? + ScBaseCell* pNewCell = bAsLink ? rColumn.CreateRefCell( pDocument, aDestPos, i, nInsFlag ) : rColumn.CloneCell( i, nInsFlag, *pDocument, aDestPos ); if (pNewCell) @@ -907,7 +887,7 @@ ScBaseCell* ScColumn::CloneCell(SCSIZE nIndex, sal_uInt16 nFlags, ScDocument& rD ScBaseCell& rSource = *pItems[nIndex].pCell; switch (rSource.GetCellType()) { - case CELLTYPE_EMPTY: + case CELLTYPE_NOTE: // note will be cloned below break; @@ -915,13 +895,13 @@ ScBaseCell* ScColumn::CloneCell(SCSIZE nIndex, sal_uInt16 nFlags, ScDocument& rD case CELLTYPE_EDIT: // note will be cloned below if (bCloneString) - pNew = rSource.Clone( rDestDoc, rDestPos ); + pNew = rSource.CloneWithoutNote( rDestDoc, rDestPos ); break; case CELLTYPE_VALUE: // note will be cloned below if (lclCanCloneValue( *pDocument, *this, pItems[nIndex].nRow, bCloneValue, bCloneDateTime )) - pNew = rSource.Clone( rDestDoc, rDestPos ); + pNew = rSource.CloneWithoutNote( rDestDoc, rDestPos ); break; case CELLTYPE_FORMULA: @@ -939,7 +919,7 @@ ScBaseCell* ScColumn::CloneCell(SCSIZE nIndex, sal_uInt16 nFlags, ScDocument& rD if (bForceFormula || bCloneFormula) { // note will be cloned below - pNew = rSource.Clone( rDestDoc, rDestPos ); + pNew = rSource.CloneWithoutNote( rDestDoc, rDestPos ); } else if ( (bCloneValue || bCloneDateTime || bCloneString) && !rDestDoc.IsUndo() ) { @@ -991,20 +971,16 @@ ScBaseCell* ScColumn::CloneCell(SCSIZE nIndex, sal_uInt16 nFlags, ScDocument& rD // clone the cell note if (bCloneNote) { - ScAddress aOwnPos( nCol, pItems[nIndex].nRow, nTab ); - ScPostIt* pNote = pDocument->GetNote( aOwnPos ); - - if ( pNote ) + if (ScPostIt* pNote = rSource.GetNote()) { bool bCloneCaption = (nFlags & IDF_NOCAPTIONS) == 0; - // #i52342# if caption is cloned, the note must be constructed - // with the destination document + // #i52342# if caption is cloned, the note must be constructed with the destination document + ScAddress aOwnPos( nCol, pItems[nIndex].nRow, nTab ); ScPostIt* pNewNote = pNote->Clone( aOwnPos, rDestDoc, rDestPos, bCloneCaption ); - if ( ! rDestDoc.SetNote( rDestPos, pNewNote ) ) - DELETEZ( pNewNote ); // apparently unsuccessful; don't leak - if (!pNew) - pNew = new ScEmptyCell(); + pNew = new ScNoteCell( pNewNote ); + else + pNew->TakeNote( pNewNote ); } } @@ -1110,14 +1086,14 @@ void ScColumn::MixData( SCROW nRow1, SCROW nRow2, CellType eSrcType = pSrc ? pSrc->GetCellType() : CELLTYPE_NONE; CellType eDestType = pDest ? pDest->GetCellType() : CELLTYPE_NONE; - sal_Bool bSrcEmpty = ( eSrcType == CELLTYPE_NONE || eSrcType == CELLTYPE_EMPTY ); - sal_Bool bDestEmpty = ( eDestType == CELLTYPE_NONE || eDestType == CELLTYPE_EMPTY ); + sal_Bool bSrcEmpty = ( eSrcType == CELLTYPE_NONE || eSrcType == CELLTYPE_NOTE ); + sal_Bool bDestEmpty = ( eDestType == CELLTYPE_NONE || eDestType == CELLTYPE_NOTE ); if ( bSkipEmpty && bDestEmpty ) // Originalzelle wiederherstellen { if ( pSrc ) // war da eine Zelle? { - pNew = pSrc->Clone( *pDocument ); + pNew = pSrc->CloneWithoutNote( *pDocument ); } } else if ( nFunction ) // wirklich Rechenfunktion angegeben @@ -1173,7 +1149,7 @@ void ScColumn::MixData( SCROW nRow1, SCROW nRow2, // mit Texten wird nicht gerechnet - immer "alte" Zelle, also pSrc if (pSrc) - pNew = pSrc->Clone( *pDocument ); + pNew = pSrc->CloneWithoutNote( *pDocument ); else if (pDest) bDelete = sal_True; } @@ -1216,7 +1192,7 @@ void ScColumn::MixData( SCROW nRow1, SCROW nRow2, if (pDest && !pNew) // alte Zelle da ? { if ( pDest->GetBroadcaster() ) - pNew = new ScEmptyCell; // Broadcaster uebernehmen + pNew = new ScNoteCell; // Broadcaster uebernehmen else Delete(nRow); // -> loeschen } @@ -1419,7 +1395,7 @@ bool ScColumn::SetString( SCROW nRow, SCTAB nTabP, const String& rString, if ( rString == aStr ) bIsText = true; break; - case CELLTYPE_EMPTY : // durch =Formel referenziert + case CELLTYPE_NOTE : // durch =Formel referenziert break; default: if ( i == nCount - 1 ) @@ -1539,17 +1515,14 @@ bool ScColumn::SetString( SCROW nRow, SCTAB nTabP, const String& rString, if (Search(nRow, i)) { ScBaseCell* pOldCell = pItems[i].pCell; + ScPostIt* pNote = pOldCell->ReleaseNote(); SvtBroadcaster* pBC = pOldCell->ReleaseBroadcaster(); - - ScPostIt* pNote = pDocument->GetNote( - ScAddress( nCol, pItems[i].nRow, nTab ) - ); - if (pNewCell || pNote || pBC) { - if ( ! pNewCell ) - pNewCell = new ScEmptyCell(); - + if (pNewCell) + pNewCell->TakeNote( pNote ); + else + pNewCell = new ScNoteCell( pNote ); if (pBC) { pNewCell->TakeBroadcaster(pBC); @@ -1813,7 +1786,7 @@ void ScColumn::GetString( SCROW nRow, String& rString ) const if (Search(nRow, nIndex)) { ScBaseCell* pCell = pItems[nIndex].pCell; - if (pCell->GetCellType() != CELLTYPE_EMPTY) + if (pCell->GetCellType() != CELLTYPE_NOTE) { sal_uLong nFormat = GetNumberFormat( nRow ); ScCellFormat::GetString( pCell, nFormat, rString, &pColor, *(pDocument->GetFormatTable()) ); @@ -1832,7 +1805,7 @@ void ScColumn::GetInputString( SCROW nRow, String& rString ) const if (Search(nRow, nIndex)) { ScBaseCell* pCell = pItems[nIndex].pCell; - if (pCell->GetCellType() != CELLTYPE_EMPTY) + if (pCell->GetCellType() != CELLTYPE_NOTE) { sal_uLong nFormat = GetNumberFormat( nRow ); ScCellFormat::GetInputString( pCell, nFormat, rString, *(pDocument->GetFormatTable()) ); @@ -1948,6 +1921,44 @@ bool ScColumn::HasStringCells( SCROW nStartRow, SCROW nEndRow ) const } +ScPostIt* ScColumn::GetNote( SCROW nRow ) +{ + SCSIZE nIndex; + return Search( nRow, nIndex ) ? pItems[ nIndex ].pCell->GetNote() : 0; +} + + +void ScColumn::TakeNote( SCROW nRow, ScPostIt* pNote ) +{ + SCSIZE nIndex; + if( Search( nRow, nIndex ) ) + pItems[ nIndex ].pCell->TakeNote( pNote ); + else + Insert( nRow, new ScNoteCell( pNote ) ); +} + + +ScPostIt* ScColumn::ReleaseNote( SCROW nRow ) +{ + ScPostIt* pNote = 0; + SCSIZE nIndex; + if( Search( nRow, nIndex ) ) + { + ScBaseCell* pCell = pItems[ nIndex ].pCell; + pNote = pCell->ReleaseNote(); + if( (pCell->GetCellType() == CELLTYPE_NOTE) && !pCell->GetBroadcaster() ) + DeleteAtIndex( nIndex ); + } + return pNote; +} + + +void ScColumn::DeleteNote( SCROW nRow ) +{ + delete ReleaseNote( nRow ); +} + + sal_Int32 ScColumn::GetMaxStringLen( SCROW nRowStart, SCROW nRowEnd, CharSet eCharSet ) const { sal_Int32 nStringLen = 0; @@ -1963,7 +1974,7 @@ sal_Int32 ScColumn::GetMaxStringLen( SCROW nRowStart, SCROW nRowEnd, CharSet eCh while ( nIndex < nCount && (nRow = pItems[nIndex].nRow) <= nRowEnd ) { ScBaseCell* pCell = pItems[nIndex].pCell; - if ( pCell->GetCellType() != CELLTYPE_EMPTY ) + if ( pCell->GetCellType() != CELLTYPE_NOTE ) { Color* pColor; sal_uLong nFormat = (sal_uLong) ((SfxUInt32Item*) GetAttr( diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx index b4e0681e73f4..bc9689bddb0c 100644 --- a/sc/source/core/data/dociter.cxx +++ b/sc/source/core/data/dociter.cxx @@ -1160,7 +1160,7 @@ ScBaseCell* ScQueryCellIterator::GetThis() (nRow = pCol->pItems[nColRow].nRow) <= aParam.nRow2 ) { ScBaseCell* pCell = pCol->pItems[nColRow].pCell; - if ( pCell->GetCellType() == CELLTYPE_EMPTY ) + if ( pCell->GetCellType() == CELLTYPE_NOTE ) ++nRow; else if (bAllStringIgnore && pCell->HasStringData()) ++nRow; @@ -1472,7 +1472,7 @@ ScBaseCell* ScQueryCellIterator::BinarySearch() { SCSIZE nMid = (nLo+nHi)/2; SCSIZE i = nMid; - while (i <= nHi && pItems[i].pCell->GetCellType() == CELLTYPE_EMPTY) + while (i <= nHi && pItems[i].pCell->GetCellType() == CELLTYPE_NOTE) ++i; if (i > nHi) { @@ -1920,12 +1920,10 @@ inline sal_Bool IsGreater( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) return ( nRow1 > nRow2 ) || ( nRow1 == nRow2 && nCol1 > nCol2 ); } -ScUsedAreaIterator::ScUsedAreaIterator( ScDocument* pDocument, SCTAB nTab, +ScUsedAreaIterator::ScUsedAreaIterator( ScDocument* pDocument, SCTAB nTable, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) : - aCellIter( pDocument, nTab, nCol1, nRow1, nCol2, nRow2 ), - aAttrIter( pDocument, nTab, nCol1, nRow1, nCol2, nRow2 ), - pDoc( pDocument ), - nTable( nTab ), + aCellIter( pDocument, nTable, nCol1, nRow1, nCol2, nRow2 ), + aAttrIter( pDocument, nTable, nCol1, nRow1, nCol2, nRow2 ), nNextCol( nCol1 ), nNextRow( nRow1 ) { @@ -1944,11 +1942,7 @@ sal_Bool ScUsedAreaIterator::GetNext() if ( pCell && IsGreater( nNextCol, nNextRow, nCellCol, nCellRow ) ) pCell = aCellIter.GetNext( nCellCol, nCellRow ); - while ( pCell - && ( pCell->IsBlank() - && (0 == pDoc->GetNote( ScAddress(nCellCol, nCellRow, nTable))) - ) - ) + while ( pCell && pCell->IsBlank() ) pCell = aCellIter.GetNext( nCellCol, nCellRow ); if ( pPattern && IsGreater( nNextCol, nNextRow, nAttrCol2, nAttrRow ) ) diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index e6b4c51cb1c4..97d834455659 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -124,6 +124,7 @@ private: }; // STATIC DATA ----------------------------------------------------------- + ScDocument::ScDocument( ScDocumentMode eMode, SfxObjectShell* pDocShell ) : xServiceManager( ::comphelper::getProcessServiceFactory() ), diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx index bb3230d55b61..f821ccfb2cbc 100644 --- a/sc/source/core/data/documen4.cxx +++ b/sc/source/core/data/documen4.cxx @@ -76,12 +76,12 @@ sal_Bool ScDocument::Solver(SCCOL nFCol, SCROW nFRow, SCTAB nFTab, CellType eFType, eVType; GetCellType(nFCol, nFRow, nFTab, eFType); GetCellType(nVCol, nVRow, nVTab, eVType); - // CELLTYPE_EMPTY: no value, but referenced by formula + // CELLTYPE_NOTE: no value, but referenced by formula // #i108005# convert target value to number using default format, // as previously done in ScInterpreter::GetDouble double nTargetVal = 0.0; sal_uInt32 nFIndex = 0; - if (CELLTYPE_FORMULA == eFType && (CELLTYPE_VALUE == eVType || CELLTYPE_EMPTY == eVType) && + if (eFType == CELLTYPE_FORMULA && (eVType == CELLTYPE_VALUE || eVType == CELLTYPE_NOTE) && GetFormatTable()->IsNumberFormat(sValStr, nFIndex, nTargetVal)) { ScSingleRefData aRefData; @@ -172,7 +172,7 @@ void ScDocument::InsertMatrixFormula(SCCOL nCol1, SCROW nRow1, if (*itr == nTab1) maTabs[*itr]->PutCell(nCol1, nRow1, pCell); else - maTabs[*itr]->PutCell(nCol1, nRow1, pCell->Clone(*this, ScAddress( nCol1, nRow1, *itr), SC_CLONECELL_STARTLISTENING)); + maTabs[*itr]->PutCell(nCol1, nRow1, pCell->CloneWithoutNote(*this, ScAddress( nCol1, nRow1, *itr), SC_CLONECELL_STARTLISTENING)); } } @@ -308,7 +308,7 @@ void ScDocument::InsertTableOp(const ScTabOpParam& rParam, // Mehrfachopera itr = rMark.begin(); for (; itr != itrEnd && *itr < nMax; ++itr) if( maTabs[*itr] ) - maTabs[*itr]->PutCell( j, k, aRefCell.Clone( *this, ScAddress( j, k, *itr ), SC_CLONECELL_STARTLISTENING ) ); + maTabs[*itr]->PutCell( j, k, aRefCell.CloneWithoutNote( *this, ScAddress( j, k, *itr ), SC_CLONECELL_STARTLISTENING ) ); } } @@ -836,8 +836,8 @@ sal_uInt16 ScDocument::RowDifferences( SCROW nThisRow, SCTAB nThisTab, nDif += 4; // Inhalt <-> leer zaehlt mehr } - if ( (pThisCell && pThisCell->GetCellType() != CELLTYPE_EMPTY) || - (pOtherCell && pOtherCell->GetCellType() != CELLTYPE_EMPTY) ) + if ( ( pThisCell && pThisCell->GetCellType()!=CELLTYPE_NOTE ) || + ( pOtherCell && pOtherCell->GetCellType()!=CELLTYPE_NOTE ) ) ++nUsed; } } @@ -877,8 +877,8 @@ sal_uInt16 ScDocument::ColDifferences( SCCOL nThisCol, SCTAB nThisTab, nDif += 4; // Inhalt <-> leer zaehlt mehr } - if ( (pThisCell && pThisCell->GetCellType() != CELLTYPE_EMPTY) || - (pOtherCell && pOtherCell->GetCellType() != CELLTYPE_EMPTY) ) + if ( ( pThisCell && pThisCell->GetCellType()!=CELLTYPE_NOTE ) || + ( pOtherCell && pOtherCell->GetCellType()!=CELLTYPE_NOTE ) ) ++nUsed; } } diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 2cf366f9dcb0..b9526d31f272 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -1895,9 +1895,8 @@ void ScDocument::CopyToClip(const ScClipParam& rClipParam, i = nTab; nEndTab = nTab; } - else { + else pClipDoc->ResetClip(this, pMarks); - } if ( bUseRangeForVBA ) CopyRangeNamesToClip(pClipDoc, aClipRange, nTab ); @@ -3262,195 +3261,48 @@ sal_Bool ScDocument::HasSelectionData( SCCOL nCol, SCROW nRow, SCTAB nTab ) cons } -/** ScPostIt* ScDocument::GetNote( ScAddress const & aPos ) - -Returns the ScPostIt object pointer associated with the document address aPos. -If the specific cell does not have a note, returns the NULL pointer. - -Notes: - -- If an ScPostIt* exists for the specified address, but the cell is no - longer addressable (e.g. if the sheet was deleted, but the note was not - properly removed), this function will remove the note before returning NULL. -*/ -ScPostIt* ScDocument::GetNote( ScAddress const & aPos ) +ScPostIt* ScDocument::GetNote( const ScAddress& rPos ) { - std::map< const ScAddress, ScPostIt* >::iterator it; - it = pNotes.find( aPos ); - - if ( pNotes.end() == it ) - return( 0 ); - - if (! ( ValidTab( aPos.Tab() ) - && aPos.Tab() < static_cast(maTabs.size()) ) - ) - { - DELETEZ( it->second ); - pNotes.erase(it); - return( 0 ); - } - - return( it->second ); + ScTable* pTable = ValidTab( rPos.Tab() ) && rPos.Tab() < static_cast(maTabs.size()) ? maTabs[ rPos.Tab() ] : 0; + return pTable ? pTable->GetNote( rPos.Col(), rPos.Row() ) : 0; } -/** bool ScDocument::SetNote( ScAddress const & aPos, ScPostIt* pNote ) - -Set the ScPostIt for the cell at aPos to pNote. - -Returns true on success, or false if unable to set pNote for aPos. - -Notes: -- If a note already exists at 'aPos', it will first be deleted, before putting - pNote as the new ScPostIt for 'aPos'. -*/ -bool ScDocument::SetNote( ScAddress const & aPos, ScPostIt* pNote ) +void ScDocument::TakeNote( const ScAddress& rPos, ScPostIt*& rpNote ) { - std::map< const ScAddress, ScPostIt* >::iterator it; - it = pNotes.find( aPos ); - - if ( pNotes.end() != it ) { - // if the note is the same as what's already there, do nothing ... - if ( it->second == pNote ) - return true; - - // ... otherwise, remove old note, before ... - DELETEZ( it->second ); - pNotes.erase( it ); - } - - if ( ! ( ValidTab( aPos.Tab() ) - && aPos.Tab() < static_cast(maTabs.size()) ) - ) - return false; - - if ( pNote ) // no sense adding an empty pointer - pNotes[ aPos ] = pNote; - - return true; -} - - -/** ScPostIt* ScDocument::ReleaseNote( ScAddress const & aPos ) - -Returns a pointer to the ScPostIt assigned to the document position aPos, -removing it from cell address aPos. - -Notes: -- When this function completes, the document will have no ScPostIt* - assigned to aPos. Thus, the caller must dispose of, or otherwise deal with, - the returned *ScPostIt object. -*/ -ScPostIt* ScDocument::ReleaseNote( ScAddress const & aPos ) -{ - ScPostIt* pNote = 0; - std::map< const ScAddress, ScPostIt* >::iterator it; - - it = pNotes.find( aPos ); - - if ( pNotes.end() != it ) - { - pNote = it->second; - pNotes.erase( it ); - } - - return( pNote ); -} - - -/** void ScDocument::DeleteNote( ScAddress const & aPos ) - -Removes the ScPostIt object, if any, assigned to the document address aPos. -*/ -void ScDocument::DeleteNote( ScAddress const & aPos ) -{ - ScPostIt* pNote = ReleaseNote( aPos ); - DELETEZ( pNote ); -} - - -/** bool ScDocument::MoveNote( ScAddress const & aFrom, ScAddress const & aTo ) - -Moves the ScPostIt object associated with aFrom to aTo. - -Returns true on success, false on failure. - -Notes: -- Any ScPostIt object that exists at aTo is properly removed before insertion. -- Not transactional. If the function fails, there is no guarantee that any - ScPostIt at aTo or aFrom will still exist, although they will be properly - cleaned up if they don't. -*/ -bool ScDocument::MoveNote( ScAddress const & aFrom, ScAddress const & aTo ) -{ - ScPostIt* pFromNote = ReleaseNote( aFrom ); - if ( SetNote( aTo, pFromNote ) ) - return true; - - // Doh! An error occurred. Attempt to not lose note, or at least - // don't leak the memory - if ( ! SetNote( aFrom, pFromNote ) ) - DELETEZ( pFromNote ); - - return false; + if( ValidTab( rPos.Tab() ) && rPos.Tab() < static_cast(maTabs.size()) && maTabs[ rPos.Tab() ] ) + maTabs[ rPos.Tab() ]->TakeNote( rPos.Col(), rPos.Row(), rpNote ); + else + DELETEZ( rpNote ); } -/** bool ScDocument::SwapNotes( ScAddress const & aOne, ScAddress const & aTwo ) - -Swap the notes assigned to positions aOne and aTwo. - -Returns true on success, false on failure. - -Notes: -- Not transactional. If a failure occurs, the ScPostIt objects at aOne or aTwo - may (not) be set. Any ScPostIt that is not set, however, will be properly - cleaned up. -*/ -bool ScDocument::SwapNotes( ScAddress const & aOne, ScAddress const & aTwo ) +ScPostIt* ScDocument::ReleaseNote( const ScAddress& rPos ) { - ScPostIt* pNoteA = ReleaseNote( aOne ); - ScPostIt* pNoteB = ReleaseNote( aTwo ); - - if ( ! SetNote( aTwo, pNoteA ) ) { - DELETEZ( pNoteA ); - if ( ! SetNote( aOne, pNoteB ) ) - DELETEZ( pNoteB ); - return false; - } - else - { - if ( ! SetNote( aOne, pNoteB ) ) { - DELETEZ( pNoteB ); - return false; - } - } - - return true; + ScTable* pTable = ValidTab( rPos.Tab() ) && rPos.Tab() < static_cast(maTabs.size())? maTabs[ rPos.Tab() ] : 0; + return pTable ? pTable->ReleaseNote( rPos.Col(), rPos.Row() ) : 0; } -/** ScPostIt* ScDocument::GetOrCreateNote( const ScAddress& rPos ) - -Returns the pointer to the ScPostIt at rPos. - -If no ScPostIt exists at rPos, create a new one for rPos and return pointer - to newly created ScPostIt. -*/ ScPostIt* ScDocument::GetOrCreateNote( const ScAddress& rPos ) { ScPostIt* pNote = GetNote( rPos ); if( !pNote ) { pNote = new ScPostIt( *this, rPos, false ); - if ( ! SetNote( rPos, pNote ) ) - DELETEZ( pNote ); //apparently unsuccessful; don't leak memory + TakeNote( rPos, pNote ); } - return pNote; } +void ScDocument::DeleteNote( const ScAddress& rPos ) +{ + if( ValidTab( rPos.Tab() ) && rPos.Tab() < static_cast(maTabs.size()) && maTabs[ rPos.Tab() ] ) + maTabs[ rPos.Tab() ]->DeleteNote( rPos.Col(), rPos.Row() ); +} + + void ScDocument::InitializeNoteCaptions( SCTAB nTab, bool bForced ) { if( ValidTab( nTab ) && nTab < static_cast(maTabs.size()) && maTabs[ nTab ] ) diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx index df0ec520b073..0d70c48bf568 100644 --- a/sc/source/core/data/fillinfo.cxx +++ b/sc/source/core/data/fillinfo.cxx @@ -406,7 +406,7 @@ void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX RowInfo* pThisRowInfo = &pRowInfo[nArrY]; CellInfo* pInfo = &pThisRowInfo->pCellInfo[nArrX]; pInfo->pCell = pThisCol->pItems[nUIndex].pCell; - if (pInfo->pCell->GetCellType() != CELLTYPE_EMPTY) + if (pInfo->pCell->GetCellType() != CELLTYPE_NOTE) { pThisRowInfo->bEmptyText = false; // Zeile nicht leer pInfo->bEmptyCellText = false; // Zelle nicht leer diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx index ad6ee1a0c11c..ddf0941d1b44 100644 --- a/sc/source/core/data/postit.cxx +++ b/sc/source/core/data/postit.cxx @@ -855,14 +855,13 @@ ScPostIt* ScNoteUtil::CreateNoteFromCaption( aNoteData.mpCaption = &rCaption; ScPostIt* pNote = new ScPostIt( rDoc, rPos, aNoteData, false ); pNote->AutoStamp(); - - if ( rDoc.SetNote( rPos, pNote ) ) - // ScNoteCaptionCreator c'tor updates the caption object to be part - // of a note + rDoc.TakeNote( rPos, pNote ); + // if pNote still points to the note after TakeNote(), insertion was successful + if( pNote ) + { + // ScNoteCaptionCreator c'tor updates the caption object to be part of a note ScNoteCaptionCreator aCreator( rDoc, rPos, rCaption, bShown ); - else - DELETEZ( pNote ); // SetNote was apparently not successful. - + } return pNote; } @@ -893,9 +892,8 @@ ScPostIt* ScNoteUtil::CreateNoteFromObjectData( visible, the caption object will be created automatically. */ ScPostIt* pNote = new ScPostIt( rDoc, rPos, aNoteData, bAlwaysCreateCaption ); pNote->AutoStamp(); - if ( ! rDoc.SetNote( rPos, pNote ) ) - DELETEZ( pNote ); // SetNote was apparently not successful - + rDoc.TakeNote( rPos, pNote ); + // if pNote still points to the note after TakeNote(), insertion was successful return pNote; } @@ -916,8 +914,8 @@ ScPostIt* ScNoteUtil::CreateNoteFromString( visible, the caption object will be created automatically. */ pNote = new ScPostIt( rDoc, rPos, aNoteData, bAlwaysCreateCaption ); pNote->AutoStamp(); - if ( ! rDoc.SetNote( rPos, pNote ) ) - DELETEZ( pNote ); // SetNote was apparently not successful + rDoc.TakeNote( rPos, pNote ); + // if pNote still points to the note after TakeNote(), insertion was successful } return pNote; } diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx index 7c2edc2b01b3..941ca3668926 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -1239,7 +1239,7 @@ bool ScTable::GetNextMarkedCell( SCCOL& rCol, SCROW& rRow, const ScMarkData& rMa ScBaseCell* pCell = NULL; while ( aColIter.Next( nCellRow, pCell ) ) { - if ( pCell && pCell->GetCellType() != CELLTYPE_EMPTY ) + if ( pCell && pCell->GetCellType() != CELLTYPE_NOTE ) { rRow = nCellRow; return true; // Zelle gefunden @@ -1655,7 +1655,7 @@ void ScTable::MaybeAddExtraColumn(SCCOL& rCol, SCROW nRow, OutputDevice* pDev, d while (nMissing > 0 && nNewCol < MAXCOL) { ScBaseCell* pNextCell = aCol[nNewCol+1].GetCell(nRow); - if (pNextCell && pNextCell->GetCellType() != CELLTYPE_EMPTY) + if (pNextCell && pNextCell->GetCellType() != CELLTYPE_NOTE) // Cell content in a next column ends display of this string. nMissing = 0; else diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index 84fb8f1bbf4e..6b1835970f14 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -630,15 +630,9 @@ void ScTable::TransposeClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, else // kopieren { ScAddress aOwnPos( nCol, nRow, nTab ); - ScPostIt* pNewNote = pDocument->GetNote(aOwnPos); - if ( pNewNote ) - pNewNote = new ScPostIt( *pDestDoc, aDestPos, *pNewNote); - if ( ! pDestDoc->SetNote( aDestPos, pNewNote ) ) - DELETEZ( pNewNote ); // if unsuccessful, don't leak mem - if (pCell->GetCellType() == CELLTYPE_FORMULA) { - pNew = pCell->Clone( *pDestDoc, aDestPos, SC_CLONECELL_STARTLISTENING ); + pNew = pCell->CloneWithNote( aOwnPos, *pDestDoc, aDestPos, SC_CLONECELL_STARTLISTENING ); // Referenzen drehen // bei Cut werden Referenzen spaeter per UpdateTranspose angepasst @@ -648,7 +642,7 @@ void ScTable::TransposeClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, } else { - pNew = pCell->Clone( *pDestDoc, aDestPos ); + pNew = pCell->CloneWithNote( aOwnPos, *pDestDoc, aDestPos ); } } pTransClip->PutCell( static_cast(nRow-nRow1), static_cast(nCol-nCol1), pNew ); @@ -1098,15 +1092,50 @@ void ScTable::GetFormula( SCCOL nCol, SCROW nRow, String& rFormula ) } +ScPostIt* ScTable::GetNote( SCCOL nCol, SCROW nRow ) +{ + return ValidColRow( nCol, nRow ) ? aCol[ nCol ].GetNote( nRow ) : 0; +} + + +void ScTable::TakeNote( SCCOL nCol, SCROW nRow, ScPostIt*& rpNote ) +{ + if( ValidColRow( nCol, nRow ) ) + { + aCol[ nCol ].TakeNote( nRow, rpNote ); + if( rpNote && rpNote->GetNoteData().mxInitData.get() ) + { + if( !mxUninitNotes.get() ) + mxUninitNotes.reset( new ScAddress2DVec ); + mxUninitNotes->push_back( ScAddress2D( nCol, nRow ) ); + } + InvalidateTableArea(); + } + else + DELETEZ( rpNote ); +} + + +ScPostIt* ScTable::ReleaseNote( SCCOL nCol, SCROW nRow ) +{ + return ValidColRow( nCol, nRow ) ? aCol[ nCol ].ReleaseNote( nRow ) : 0; +} + + +void ScTable::DeleteNote( SCCOL nCol, SCROW nRow ) +{ + if( ValidColRow( nCol, nRow ) ) + aCol[ nCol ].DeleteNote( nRow ); +} + + void ScTable::InitializeNoteCaptions( bool bForced ) { if( mxUninitNotes.get() && (bForced || pDocument->IsUndoEnabled()) ) { - for( ScAddress2DVec::iterator aIt = mxUninitNotes->begin(), aEnd = mxUninitNotes->end(); aIt != aEnd; ++aIt ) { - ScAddress aPos( aIt->first, aIt->second, nTab ); - if( ScPostIt* pNote = pDocument->GetNote( aPos ) ) - pNote->GetOrCreateCaption( aPos ); - } + for( ScAddress2DVec::iterator aIt = mxUninitNotes->begin(), aEnd = mxUninitNotes->end(); aIt != aEnd; ++aIt ) + if( ScPostIt* pNote = GetNote( aIt->first, aIt->second ) ) + pNote->GetOrCreateCaption( ScAddress( aIt->first, aIt->second, nTab ) ); mxUninitNotes.reset(); } } @@ -2941,7 +2970,7 @@ void ScTable::CopyData( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW n ScBaseCell* pCell = GetCell( nCol, nRow ); if (pCell) { - pCell = pCell->Clone( *pDocument ); + pCell = pCell->CloneWithoutNote( *pDocument ); if (pCell->GetCellType() == CELLTYPE_FORMULA) { ((ScFormulaCell*)pCell)->UpdateReference( URM_COPY, aRange, diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx index 2f9f8f086c3b..047a7f60bcdd 100644 --- a/sc/source/core/data/table3.cxx +++ b/sc/source/core/data/table3.cxx @@ -387,13 +387,13 @@ short ScTable::CompareCell( sal_uInt16 nSort, if (pCell1) { eType1 = pCell1->GetCellType(); - if ( CELLTYPE_EMPTY == eType1) + if (eType1 == CELLTYPE_NOTE) pCell1 = NULL; } if (pCell2) { eType2 = pCell2->GetCellType(); - if ( CELLTYPE_EMPTY == eType2 ) + if (eType2 == CELLTYPE_NOTE) pCell2 = NULL; } @@ -1202,7 +1202,7 @@ bool ScTable::ValidQuery(SCROW nRow, const ScQueryParam& rParam, bMatchWholeCell = false; if ( pCell ) { - if (pCell->GetCellType() != CELLTYPE_EMPTY) + if (pCell->GetCellType() != CELLTYPE_NOTE) { sal_uLong nFormat = GetNumberFormat( static_cast(rEntry.nField), nRow ); ScCellFormat::GetInputString( pCell, nFormat, aCellStr, *(pDocument->GetFormatTable()) ); @@ -1451,9 +1451,8 @@ void ScTable::TopTenQuery( ScQueryParam& rParam ) ScSortInfo** ppInfo = pArray->GetFirstArray(); SCSIZE nValidCount = nCount; // keine Note-/Leerzellen zaehlen, sind ans Ende sortiert - while ( nValidCount > 0 - && ( NULL == ppInfo[nValidCount-1]->pCell - || CELLTYPE_EMPTY == ppInfo[nValidCount-1]->pCell->GetCellType() ) ) + while ( nValidCount > 0 && ( ppInfo[nValidCount-1]->pCell == NULL || + ppInfo[nValidCount-1]->pCell->GetCellType() == CELLTYPE_NOTE ) ) nValidCount--; // keine Strings zaehlen, sind zwischen Value und Leer while ( nValidCount > 0 diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx index 556dd416903b..4854f493581e 100644 --- a/sc/source/core/data/table4.cxx +++ b/sc/source/core/data/table4.cxx @@ -808,7 +808,7 @@ void ScTable::FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, { case CELLTYPE_STRING: case CELLTYPE_EDIT: - aCol[nCol].Insert( aDestPos.Row(), pSrcCell->Clone( *pDocument ) ); + aCol[nCol].Insert( aDestPos.Row(), pSrcCell->CloneWithoutNote( *pDocument ) ); break; default: { @@ -1357,14 +1357,14 @@ void ScTable::FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, rProgress.SetStateOnPercent( ++nProgress ); } } - else if (eCellType != CELLTYPE_EMPTY) + else if (eCellType != CELLTYPE_NOTE) { for (rInner = nIMin; rInner <= nIMax; rInner++) { if (pDocument->RowFiltered( rInner, nTab)) continue; ScAddress aDestPos( static_cast(nCol), static_cast(nRow), nTab ); - aCol[nCol].Insert( aDestPos.Row(), pSrcCell->Clone( *pDocument ) ); + aCol[nCol].Insert( aDestPos.Row(), pSrcCell->CloneWithoutNote( *pDocument ) ); } nProgress += nIMax - nIMin + 1; rProgress.SetStateOnPercent( nProgress ); diff --git a/sc/source/core/data/table6.cxx b/sc/source/core/data/table6.cxx index 291f6a6ddba4..4edb697ad976 100644 --- a/sc/source/core/data/table6.cxx +++ b/sc/source/core/data/table6.cxx @@ -78,7 +78,6 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRo if ( bDoSearch && ((pCell = aCol[nCol].GetCell( nRow )) != NULL) ) { bool bMultiLine = false; - ScAddress cellPos( nCol, nRow, nTab ); CellType eCellType = pCell->GetCellType(); switch (rSearchItem.GetCellType()) { @@ -103,7 +102,7 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRo break; case SVX_SEARCHIN_NOTE: { - if (const ScPostIt* pNote = pDocument->GetNote( cellPos )) + if(const ScPostIt* pNote = pCell->GetNote()) { aString = pNote->GetText(); bMultiLine = pNote->HasMultiLineText(); @@ -157,8 +156,9 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRo rUndoStr = aString; else if (pUndoDoc) { - ScBaseCell* pUndoCell = pCell->Clone( *pUndoDoc ); - pUndoDoc->PutCell( cellPos, pUndoCell); + ScAddress aAdr( nCol, nRow, nTab ); + ScBaseCell* pUndoCell = pCell->CloneWithoutNote( *pUndoDoc ); + pUndoDoc->PutCell( aAdr, pUndoCell); } bool bRepeat = !rSearchItem.GetWordOnly(); do @@ -219,8 +219,8 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRo { // NB: rich text format is lost. // This is also true of Cells. - if ( ScPostIt* pNote = pDocument->GetNote( cellPos ) ) - pNote->SetText( cellPos, aString ); + if( ScPostIt* pNote = pCell->GetNote() ) + pNote->SetText( ScAddress( nCol, nRow, nTab ), aString ); } else if ( cMatrixFlag != MM_NONE ) { // Matrix nicht zerreissen @@ -231,7 +231,8 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRo if ( aString.GetChar(0) == '{' ) aString.Erase( 0, 1 ); } - ScFormulaCell* pFCell = new ScFormulaCell( pDocument, cellPos, + ScAddress aAdr( nCol, nRow, nTab ); + ScFormulaCell* pFCell = new ScFormulaCell( pDocument, aAdr, aString,formula::FormulaGrammar::GRAM_NATIVE_UI, cMatrixFlag ); SCCOL nMatCols; SCROW nMatRows; @@ -829,7 +830,7 @@ bool lcl_maybeReplaceCellString( ScColumn& rColObj, SCCOL& rCol, SCROW& rRow, rtl::OUString& rUndoStr, SCCOL nCol, SCROW nRow, const SvxSearchItem& rSearchItem) { ScBaseCell* pCell = rColObj.GetCell(nRow); - if (!pCell || CELLTYPE_EMPTY == pCell->GetCellType() ) + if (!pCell || pCell->GetCellType() == CELLTYPE_NOTE) { // empty cell found. rCol = nCol; @@ -1024,7 +1025,7 @@ bool ScTable::SearchRangeForAllEmptyCells( pUndoDoc->PutCell(nCol, nRow, nTab, new ScStringCell(String())); } } - else if ( CELLTYPE_EMPTY == pCell->GetCellType() ) + else if (pCell->GetCellType() == CELLTYPE_NOTE) { rMatchedRanges.Join(ScRange(nCol, nRow, nTab)); bFound = true; @@ -1033,15 +1034,8 @@ bool ScTable::SearchRangeForAllEmptyCells( { if (pUndoDoc) { - ScAddress aPos(nCol, nRow, nTab); - ScBaseCell* pNewCell = pCell->Clone(*pUndoDoc, aPos); - - ScPostIt* pNewNote = pDocument->GetNote( aPos ); - pNewNote = new ScPostIt( *pUndoDoc, aPos, *pNewNote ); - - pUndoDoc->PutCell(nCol, nRow, nTab, pNewCell); - if ( ! pUndoDoc->SetNote(aPos, pNewNote) ) - DELETEZ( pNewNote ); // don't leak mem on failure + ScAddress aCellPos(nCol, nRow, nTab); + pUndoDoc->PutCell(nCol, nRow, nTab, pCell->CloneWithNote(aCellPos, *pUndoDoc, aCellPos)); } aCol[nCol].SetString(nRow, nTab, rSearchItem.GetReplaceString()); } diff --git a/sc/source/core/tool/chartlis.cxx b/sc/source/core/tool/chartlis.cxx index f4093df94b75..6f9129de95f5 100644 --- a/sc/source/core/tool/chartlis.cxx +++ b/sc/source/core/tool/chartlis.cxx @@ -483,7 +483,7 @@ ScChartListenerCollection::~ScChartListenerCollection() { // remove ChartListener objects before aTimer dtor is called, because // ScChartListener::EndListeningTo may cause ScChartListenerCollection::StartTimer - // to be called if an empty ScEmptyCell is deleted + // to be called if an empty ScNoteCell is deleted if (GetCount()) FreeAll(); diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx index a3c61333d96d..8a341a6c4a7d 100644 --- a/sc/source/core/tool/chgtrack.cxx +++ b/sc/source/core/tool/chgtrack.cxx @@ -1686,7 +1686,7 @@ void ScChangeActionContent::SetValue( String& rStr, ScBaseCell*& pCell, pCell->Delete(); if ( ScChangeActionContent::GetContentCellType( pOrgCell ) ) { - pCell = pOrgCell->Clone( *pToDoc ); + pCell = pOrgCell->CloneWithoutNote( *pToDoc ); switch ( pOrgCell->GetCellType() ) { case CELLTYPE_VALUE : @@ -1846,7 +1846,7 @@ void ScChangeActionContent::PutValueToDoc( ScBaseCell* pCell, // nothing break; default: - pDoc->PutCell( aPos, pCell->Clone( *pDoc ) ); + pDoc->PutCell( aPos, pCell->CloneWithoutNote( *pDoc ) ); } } } @@ -4399,7 +4399,7 @@ ScChangeTrack* ScChangeTrack::Clone( ScDocument* pDocument ) const const ScBaseCell* pNewCell = pContent->GetNewCell(); if ( pNewCell ) { - ScBaseCell* pClonedNewCell = pNewCell->Clone( *pDocument ); + ScBaseCell* pClonedNewCell = pNewCell->CloneWithoutNote( *pDocument ); String aNewValue; pContent->GetNewString( aNewValue ); pClonedTrack->nGeneratedMin = pGenerated->GetActionNumber() + 1; @@ -4483,7 +4483,7 @@ ScChangeTrack* ScChangeTrack::Clone( ScDocument* pDocument ) const const ScChangeActionContent* pContent = dynamic_cast< const ScChangeActionContent* >( pAction ); OSL_ENSURE( pContent, "ScChangeTrack::Clone: pContent is null!" ); const ScBaseCell* pOldCell = pContent->GetOldCell(); - ScBaseCell* pClonedOldCell = pOldCell ? pOldCell->Clone( *pDocument ) : 0; + ScBaseCell* pClonedOldCell = pOldCell ? pOldCell->CloneWithoutNote( *pDocument ) : 0; String aOldValue; pContent->GetOldString( aOldValue ); @@ -4502,7 +4502,7 @@ ScChangeTrack* ScChangeTrack::Clone( ScDocument* pDocument ) const const ScBaseCell* pNewCell = pContent->GetNewCell(); if ( pNewCell ) { - ScBaseCell* pClonedNewCell = pNewCell->Clone( *pDocument ); + ScBaseCell* pClonedNewCell = pNewCell->CloneWithoutNote( *pDocument ); pClonedContent->SetNewValue( pClonedNewCell, pDocument ); } diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index c43f6f9f5763..1a484ef65bf4 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -3091,7 +3091,7 @@ bool ScCompiler::IsColRowName( const String& rName ) break; case CELLTYPE_NONE: case CELLTYPE_VALUE: - case CELLTYPE_EMPTY: + case CELLTYPE_NOTE: case CELLTYPE_SYMBOLS: #if OSL_DEBUG_LEVEL > 0 case CELLTYPE_DESTROYED: @@ -3220,7 +3220,7 @@ bool ScCompiler::IsColRowName( const String& rName ) break; case CELLTYPE_NONE: case CELLTYPE_VALUE: - case CELLTYPE_EMPTY: + case CELLTYPE_NOTE: case CELLTYPE_SYMBOLS: #if OSL_DEBUG_LEVEL > 0 case CELLTYPE_DESTROYED: diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index c4ec87742381..3fc28bbcea1f 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -1762,7 +1762,7 @@ void ScInterpreter::ScIsEmpty() // ScCountEmptyCells(). // if (HasCellEmptyData( GetCell( aAdr))) CellType eCellType = GetCellType( GetCell( aAdr ) ); - if ( (CELLTYPE_NONE == eCellType) || (CELLTYPE_EMPTY == eCellType) ) + if((eCellType == CELLTYPE_NONE) || (eCellType == CELLTYPE_NOTE)) nRes = 1; } break; @@ -1926,7 +1926,7 @@ void ScInterpreter::ScType() switch ( GetCellType( pCell ) ) { // NOTE: this is Xcl nonsense! - case CELLTYPE_EMPTY : + case CELLTYPE_NOTE : nType = 1; // empty cell is value (0) break; case CELLTYPE_STRING : @@ -3492,7 +3492,7 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) if( eFunc == ifCOUNT2 ) { CellType eCellType = pCell->GetCellType(); - if (eCellType != CELLTYPE_NONE && eCellType != CELLTYPE_EMPTY) + if (eCellType != CELLTYPE_NONE && eCellType != CELLTYPE_NOTE) nCount++; if ( nGlobalError ) nGlobalError = 0; @@ -3555,7 +3555,7 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) do { CellType eType = pCell->GetCellType(); - if( eType != CELLTYPE_NONE && eType != CELLTYPE_EMPTY ) + if( eType != CELLTYPE_NONE && eType != CELLTYPE_NOTE ) nCount++; } while ( (pCell = aIter.GetNext()) != NULL ); @@ -4704,7 +4704,7 @@ void ScInterpreter::ScCountEmptyCells() ScAddress aAdr; PopSingleRef( aAdr ); eCellType = GetCellType( GetCell( aAdr ) ); - if (eCellType != CELLTYPE_NONE && eCellType != CELLTYPE_EMPTY) + if (eCellType != CELLTYPE_NONE && eCellType != CELLTYPE_NOTE) nCount = 1; } break; @@ -4728,7 +4728,7 @@ void ScInterpreter::ScCountEmptyCells() do { if ((eCellType = pCell->GetCellType()) != CELLTYPE_NONE - && eCellType != CELLTYPE_EMPTY) + && eCellType != CELLTYPE_NOTE) nCount++; } while ( (pCell = aDocIter.GetNext()) != NULL ); } @@ -6170,7 +6170,7 @@ bool ScInterpreter::FillEntry(ScQueryEntry& rEntry) } else { - if ( CELLTYPE_EMPTY == GetCellType( pCell ) ) + if ( GetCellType( pCell ) == CELLTYPE_NOTE ) { rEntry.bQueryByString = false; rEntry.nVal = 0.0; diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx index 008a8835847a..bbde6aaad2c0 100644 --- a/sc/source/core/tool/interpr2.cxx +++ b/sc/source/core/tool/interpr2.cxx @@ -1607,8 +1607,8 @@ void ScInterpreter::ScBackSolver() if (nGlobalError == 0) { ScBaseCell* pVCell = GetCell( aValueAdr ); - // CELLTYPE_EMPTY: kein Value aber von Formel referiert - bool bTempCell = (!pVCell || CELLTYPE_EMPTY == pVCell->GetCellType() ); + // CELLTYPE_NOTE: kein Value aber von Formel referiert + bool bTempCell = (!pVCell || pVCell->GetCellType() == CELLTYPE_NOTE); ScBaseCell* pFCell = GetCell( aFormulaAdr ); if ( ((pVCell && pVCell->GetCellType() == CELLTYPE_VALUE) || bTempCell) @@ -1620,7 +1620,7 @@ void ScInterpreter::ScBackSolver() if ( bTempCell ) { - pNote = pDok->GetNote( aValueAdr ); + pNote = pVCell ? pVCell->ReleaseNote() : 0; fSaveVal = 0.0; pVCell = new ScValueCell( fSaveVal ); pDok->PutCell( aValueAdr, pVCell ); @@ -1769,12 +1769,7 @@ void ScInterpreter::ScBackSolver() } if ( bTempCell ) { - pVCell = 0; - if ( pNote ) { - pVCell = new ScEmptyCell(); - if ( ! pDok->SetNote( aValueAdr, pNote ) ) - DELETEZ( pNote ); - } + pVCell = pNote ? new ScNoteCell( pNote ) : 0; pDok->PutCell( aValueAdr, pVCell ); } else diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index ade3e2361d8a..261403e6ed90 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -493,7 +493,7 @@ double ScInterpreter::GetCellValueOrZero( const ScAddress& rPos, const ScBaseCel } break; case CELLTYPE_NONE: - case CELLTYPE_EMPTY: + case CELLTYPE_NOTE: fValue = 0.0; // empty or broadcaster cell break; case CELLTYPE_SYMBOLS: @@ -2677,7 +2677,7 @@ void ScInterpreter::ScExternal() } else if ( ( aUnoName = ScGlobal::GetAddInCollection()->FindFunction(aFuncName, false) ).Len() ) { - // bLocalFirst=false in FindFunction, cFunc should be the stored + // bLocalFirst=false in FindFunction, cFunc should be the stored // internal name ScUnoAddInCall aCall( *ScGlobal::GetAddInCollection(), aUnoName, nParamCount ); diff --git a/sc/source/filter/dif/difexp.cxx b/sc/source/filter/dif/difexp.cxx index 30ec33e580f0..980ca093f1fa 100644 --- a/sc/source/filter/dif/difexp.cxx +++ b/sc/source/filter/dif/difexp.cxx @@ -175,7 +175,7 @@ FltError ScFormatFilterPluginImpl::ScExportDif( SvStream& rOut, ScDocument* pDoc switch( pAkt->GetCellType() ) { case CELLTYPE_NONE: - case CELLTYPE_EMPTY: + case CELLTYPE_NOTE: aOS.AssignAscii( pEmptyData ); break; case CELLTYPE_VALUE: diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx index a36b08190ce0..e6621f000b40 100644 --- a/sc/source/filter/excel/xetable.cxx +++ b/sc/source/filter/excel/xetable.cxx @@ -2329,7 +2329,7 @@ XclExpCellTable::XclExpCellTable( const XclExpRoot& rRoot ) : OSL_FAIL( "XclExpCellTable::XclExpCellTable - unknown cell type" ); // run-through! case CELLTYPE_NONE: - case CELLTYPE_EMPTY: + case CELLTYPE_NOTE: { xCell.reset( new XclExpBlankCell( GetRoot(), aXclPos, nLastXclCol, pPattern, nMergeBaseXFId ) ); @@ -2342,7 +2342,7 @@ XclExpCellTable::XclExpCellTable( const XclExpRoot& rRoot ) : maRowBfr.AppendCell( xCell, bIsMergedBase ); // notes - const ScPostIt* pScNote = rDoc.GetNote(aScPos); + const ScPostIt* pScNote = pScCell ? pScCell->GetNote() : 0; if( pScNote || (aAddNoteText.Len() > 0) ) mxNoteList->AppendNewRecord( new XclExpNote( GetRoot(), aScPos, pScNote, aAddNoteText ) ); diff --git a/sc/source/filter/html/htmlexp.cxx b/sc/source/filter/html/htmlexp.cxx index c7ceea9bd37e..84c734e7fd13 100644 --- a/sc/source/filter/html/htmlexp.cxx +++ b/sc/source/filter/html/htmlexp.cxx @@ -1181,7 +1181,7 @@ void ScHTMLExport::WriteCell( SCCOL nCol, SCROW nRow, SCTAB nTab ) Color* pColor; switch ( pCell->GetCellType() ) { - case CELLTYPE_EMPTY : + case CELLTYPE_NOTE : // nothing break; case CELLTYPE_EDIT : diff --git a/sc/source/filter/lotus/expop.cxx b/sc/source/filter/lotus/expop.cxx index f1b5a8dcbe8f..c1b0ae23a4e2 100644 --- a/sc/source/filter/lotus/expop.cxx +++ b/sc/source/filter/lotus/expop.cxx @@ -393,7 +393,7 @@ FltError ExportWK1::Write() WKString( nCol, nRow, ( ScFormulaCell * ) pCell, *pPatAttr ); } break; - case CELLTYPE_EMPTY: + case CELLTYPE_NOTE: case CELLTYPE_NONE: break; default: diff --git a/sc/source/filter/rtf/rtfexp.cxx b/sc/source/filter/rtf/rtfexp.cxx index a1d78f26ba0e..ffef3ce6a782 100644 --- a/sc/source/filter/rtf/rtfexp.cxx +++ b/sc/source/filter/rtf/rtfexp.cxx @@ -195,7 +195,7 @@ void ScRTFExport::WriteCell( SCTAB nTab, SCROW nRow, SCCOL nCol ) { switch ( pCell->GetCellType() ) { - case CELLTYPE_EMPTY : + case CELLTYPE_NOTE : bValueData = false; break; // nix case CELLTYPE_EDIT : diff --git a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx index 5808ac9b2122..d5259697fbb9 100644 --- a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx +++ b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx @@ -101,7 +101,7 @@ ScBaseCell* ScMyCellInfo::CreateCell(ScDocument* pDoc) } } - return pCell ? pCell->Clone( *pDoc ) : 0; + return pCell ? pCell->CloneWithoutNote( *pDoc ) : 0; } ScMyDeleted::ScMyDeleted() @@ -682,7 +682,7 @@ void ScXMLChangeTrackingImportHelper::SetContentDependencies(ScMyContentAction* const ScBaseCell* pOldCell = pActContent->GetOldCell(); if (pOldCell) { - ScBaseCell* pNewCell = pOldCell->Clone( *pDoc ); + ScBaseCell* pNewCell = pOldCell->CloneWithoutNote( *pDoc ); if (pNewCell) { pPrevActContent->SetNewCell(pNewCell, pDoc, EMPTY_STRING); @@ -774,7 +774,7 @@ void ScXMLChangeTrackingImportHelper::SetNewCell(ScMyContentAction* pAction) { ScBaseCell* pNewCell = NULL; if (pCell->GetCellType() != CELLTYPE_FORMULA) - pNewCell = pCell->Clone( *pDoc ); + pNewCell = pCell->CloneWithoutNote( *pDoc ); else { sal_uInt8 nMatrixFlag = static_cast(pCell)->GetMatrixFlag(); diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx index 2a13153b35af..06d80ced67cf 100644 --- a/sc/source/filter/xml/xmlcelli.cxx +++ b/sc/source/filter/xml/xmlcelli.cxx @@ -761,7 +761,7 @@ bool lcl_IsEmptyOrNote( ScDocument* pDoc, const table::CellAddress& rCurrentPos ScAddress aScAddress; ScUnoConversion::FillScAddress( aScAddress, rCurrentPos ); ScBaseCell* pCell = pDoc->GetCell( aScAddress ); - return ( !pCell || CELLTYPE_EMPTY == pCell->GetCellType() ); + return ( !pCell || pCell->GetCellType() == CELLTYPE_NOTE ); } void ScXMLTableRowCellContext::EndElement() diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx index d316aedea925..6bf85b573937 100644 --- a/sc/source/ui/docshell/dbdocfun.cxx +++ b/sc/source/ui/docshell/dbdocfun.cxx @@ -1178,10 +1178,9 @@ sal_Bool lcl_EmptyExcept( ScDocument* pDoc, const ScRange& rRange, const ScRange ScBaseCell* pCell = aIter.GetFirst(); while (pCell) { - ScAddress aPos( aIter.GetPos() ); - if ( !pCell->IsBlank() || pDoc->GetNote( aPos ) ) // real content? + if ( !pCell->IsBlank() ) // real content? { - if ( !rExcept.In( aPos ) ) + if ( !rExcept.In( ScAddress( aIter.GetCol(), aIter.GetRow(), aIter.GetTab() ) ) ) return false; // cell found } pCell = aIter.GetNext(); diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index f260d798aba8..f218b8b0ac21 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -791,7 +791,7 @@ sal_Bool ScDocFunc::SetNormalString( const ScAddress& rPos, const String& rText, pTabs = new SCTAB[1]; pTabs[0] = rPos.Tab(); ppOldCells = new ScBaseCell*[1]; - ppOldCells[0] = pDocCell ? pDocCell->Clone( *pDoc ) : 0; + ppOldCells[0] = pDocCell ? pDocCell->CloneWithoutNote( *pDoc ) : 0; pHasFormat = new sal_Bool[1]; pOldFormats = new sal_uLong[1]; @@ -855,8 +855,8 @@ sal_Bool ScDocFunc::PutCell( const ScAddress& rPos, ScBaseCell* pNewCell, sal_Bo sal_Bool bHeight = ( bEditDeleted || bEditCell || pDoc->HasAttrib( ScRange(rPos), HASATTR_NEEDHEIGHT ) ); - ScBaseCell* pUndoCell = (bUndo && pDocCell) ? pDocCell->Clone( *pDoc, rPos ) : 0; - ScBaseCell* pRedoCell = (bUndo && pNewCell) ? pNewCell->Clone( *pDoc, rPos ) : 0; + ScBaseCell* pUndoCell = (bUndo && pDocCell) ? pDocCell->CloneWithoutNote( *pDoc, rPos ) : 0; + ScBaseCell* pRedoCell = (bUndo && pNewCell) ? pNewCell->CloneWithoutNote( *pDoc, rPos ) : 0; pDoc->PutCell( rPos, pNewCell ); diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 047cbf54235b..d09eb8f33647 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -270,7 +270,7 @@ sal_uInt16 ScDocShell::GetHiddenInformationState( sal_uInt16 nStates ) { ScCellIterator aCellIter( &aDocument, 0,0, nTable, MAXCOL,MAXROW, nTable ); for( ScBaseCell* pCell = aCellIter.GetFirst(); pCell && !bFound; pCell = aCellIter.GetNext() ) - if (aDocument.GetNote( aCellIter.GetPos() )) + if (pCell->HasNote()) bFound = sal_True; nTable++; } @@ -1798,7 +1798,7 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt sal_Bool bString; switch ( eType ) { - case CELLTYPE_EMPTY: + case CELLTYPE_NOTE: case CELLTYPE_NONE: aString.Erase(); bString = false; diff --git a/sc/source/ui/docshell/docsh8.cxx b/sc/source/ui/docshell/docsh8.cxx index ec4c0a4678ca..c33b76a923c6 100644 --- a/sc/source/ui/docshell/docsh8.cxx +++ b/sc/source/ui/docshell/docsh8.cxx @@ -973,7 +973,7 @@ sal_uLong ScDocShell::DBaseExport( const String& rFullFileName, CharSet eCharSet { ScBaseCell* pCell; aDocument.GetCell( nDocCol, nDocRow, nTab, pCell ); - if ( pCell && pCell->GetCellType() != CELLTYPE_EMPTY ) + if ( pCell && pCell->GetCellType() != CELLTYPE_NOTE ) { if ( pCell->GetCellType() == CELLTYPE_EDIT ) { // Paragraphs erhalten @@ -1090,7 +1090,7 @@ sal_uLong ScDocShell::DBaseExport( const String& rFullFileName, CharSet eCharSet { case sdbc::DataType::LONGVARCHAR: { - if ( pCell->GetCellType() != CELLTYPE_EMPTY ) + if ( pCell->GetCellType() != CELLTYPE_NOTE ) { if ( pCell->GetCellType() == CELLTYPE_EDIT ) lcl_getLongVarCharEditString( aString, diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx index a77065d613c3..830d832399c0 100644 --- a/sc/source/ui/docshell/impex.cxx +++ b/sc/source/ui/docshell/impex.cxx @@ -1362,7 +1362,7 @@ const sal_Unicode* ScImportExport::ScanNextFieldFromString( const sal_Unicode* p const sal_Unicode cBlank = ' '; if (!ScGlobal::UnicodeStrChr( pSeps, cBlank)) { - // Cope with broken generators that put leading blanks before a quoted + // Cope with broken generators that put leading blanks before a quoted // field, like "field1", "field2", "..." // NOTE: this is not in conformance with http://tools.ietf.org/html/rfc4180 const sal_Unicode* pb = p; @@ -1495,7 +1495,7 @@ sal_Bool ScImportExport::Doc2Text( SvStream& rStrm ) lcl_WriteSimpleString( rStrm, aCell ); } break; - case CELLTYPE_EMPTY: + case CELLTYPE_NOTE: case CELLTYPE_NONE: break; default: diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx index 85dd15da18fb..25330e7ca78c 100644 --- a/sc/source/ui/navipi/content.cxx +++ b/sc/source/ui/navipi/content.cxx @@ -878,7 +878,7 @@ void ScContentTree::GetNoteStrings() { ScCellIterator aIter( pDoc, 0,0,nTab, MAXCOL,MAXROW,nTab ); for( ScBaseCell* pCell = aIter.GetFirst(); pCell; pCell = aIter.GetNext() ) - if ( const ScPostIt* pNote = pDoc->GetNote( aIter.GetPos() ) ) + if( const ScPostIt* pNote = pCell->GetNote() ) InsertContent( SC_CONTENT_NOTE, lcl_NoteString( *pNote ) ); } } @@ -897,10 +897,10 @@ ScAddress ScContentTree::GetNotePos( sal_uLong nIndex ) ScBaseCell* pCell = aIter.GetFirst(); while (pCell) { - if( pDoc->GetNote( aIter.GetPos() ) ) + if( pCell->HasNote() ) { if (nFound == nIndex) - return aIter.GetPos(); + return ScAddress( aIter.GetCol(), aIter.GetRow(), nTab ); // gefunden ++nFound; } pCell = aIter.GetNext(); @@ -931,7 +931,7 @@ sal_Bool ScContentTree::NoteStringsChanged() ScBaseCell* pCell = aIter.GetFirst(); while (pCell && bEqual) { - if ( const ScPostIt* pNote = pDoc->GetNote( aIter.GetPos() ) ) + if( const ScPostIt* pNote = pCell->GetNote() ) { if ( !pEntry ) bEqual = false; diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx index 1fb2d3ac6304..a4c6c6dc529f 100644 --- a/sc/source/ui/undo/undocell.cxx +++ b/sc/source/ui/undo/undocell.cxx @@ -278,7 +278,7 @@ void ScUndoEnterData::Undo() ScDocument* pDoc = pDocShell->GetDocument(); for (sal_uInt16 i=0; iClone( *pDoc, SC_CLONECELL_STARTLISTENING ) : 0; + ScBaseCell* pNewCell = ppOldCells[i] ? ppOldCells[i]->CloneWithoutNote( *pDoc, SC_CLONECELL_STARTLISTENING ) : 0; pDoc->PutCell( nCol, nRow, pTabs[i], pNewCell ); if (pHasFormat && pOldFormats) @@ -411,7 +411,7 @@ void ScUndoEnterValue::Undo() BeginUndo(); ScDocument* pDoc = pDocShell->GetDocument(); - ScBaseCell* pNewCell = pOldCell ? pOldCell->Clone( *pDoc, SC_CLONECELL_STARTLISTENING ) : 0; + ScBaseCell* pNewCell = pOldCell ? pOldCell->CloneWithoutNote( *pDoc, SC_CLONECELL_STARTLISTENING ) : 0; pDoc->PutCell( aPos, pNewCell ); @@ -497,7 +497,7 @@ void ScUndoPutCell::Undo() BeginUndo(); ScDocument* pDoc = pDocShell->GetDocument(); - ScBaseCell* pNewCell = pOldCell ? pOldCell->Clone( *pDoc, aPos, SC_CLONECELL_STARTLISTENING ) : 0; + ScBaseCell* pNewCell = pOldCell ? pOldCell->CloneWithoutNote( *pDoc, aPos, SC_CLONECELL_STARTLISTENING ) : 0; pDoc->PutCell( aPos.Col(), aPos.Row(), aPos.Tab(), pNewCell ); @@ -515,7 +515,7 @@ void ScUndoPutCell::Redo() BeginRedo(); ScDocument* pDoc = pDocShell->GetDocument(); - ScBaseCell* pNewCell = pEnteredCell ? pEnteredCell->Clone( *pDoc, aPos, SC_CLONECELL_STARTLISTENING ) : 0; + ScBaseCell* pNewCell = pEnteredCell ? pEnteredCell->CloneWithoutNote( *pDoc, aPos, SC_CLONECELL_STARTLISTENING ) : 0; pDoc->PutCell( aPos.Col(), aPos.Row(), aPos.Tab(), pNewCell ); @@ -901,8 +901,7 @@ void ScUndoReplaceNote::DoInsertNote( const ScNoteData& rNoteData ) ScDocument& rDoc = *pDocShell->GetDocument(); OSL_ENSURE( !rDoc.GetNote( maPos ), "ScUndoReplaceNote::DoInsertNote - unexpected cell note" ); ScPostIt* pNote = new ScPostIt( rDoc, maPos, rNoteData, false ); - if ( ! rDoc.SetNote( maPos, pNote ) ) - DELETEZ( pNote ); // Apparently unsuccesful, so don't leak memory. + rDoc.TakeNote( maPos, pNote ); } } diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index 7b6cd4c6338b..748b3c0b3cc1 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -1276,7 +1276,7 @@ String lcl_GetInputString( ScDocument* pDoc, const ScAddress& rPosition, sal_Boo if ( pDoc ) { ScBaseCell* pCell = pDoc->GetCell( rPosition ); - if ( pCell && pCell->GetCellType() != CELLTYPE_EMPTY ) + if ( pCell && pCell->GetCellType() != CELLTYPE_NOTE ) { CellType eType = pCell->GetCellType(); if ( eType == CELLTYPE_FORMULA ) @@ -3446,9 +3446,10 @@ uno::Reference SAL_CALL ScCellRangesBase::queryEmptyCel while (pCell) { // Notizen zaehlen als nicht-leer - ScAddress aPos( aIter.GetPos() ); - if ( !pCell->IsBlank() || pDoc->GetNote( aPos ) ) - aMarkData.SetMultiMarkArea( ScRange( aPos ), false ); + if ( !pCell->IsBlank() ) + aMarkData.SetMultiMarkArea( + ScRange( aIter.GetCol(), aIter.GetRow(), aIter.GetTab() ), + false ); pCell = aIter.GetNext(); } @@ -3486,8 +3487,7 @@ uno::Reference SAL_CALL ScCellRangesBase::queryContentC while (pCell) { sal_Bool bAdd = false; - if ( pDoc->GetNote( aIter.GetPos() ) - && ( nContentFlags & sheet::CellFlags::ANNOTATION ) ) + if ( pCell->HasNote() && ( nContentFlags & sheet::CellFlags::ANNOTATION ) ) bAdd = sal_True; else switch ( pCell->GetCellType() ) @@ -3639,7 +3639,7 @@ uno::Reference ScCellRangesBase::QueryDifferences_Impl( ScBaseCell* pCmpCell = aCmpIter.GetFirst(); while (pCmpCell) { - if (pCmpCell->GetCellType() != CELLTYPE_EMPTY) + if (pCmpCell->GetCellType() != CELLTYPE_NOTE) { SCCOLROW nCellPos = bColumnDiff ? static_cast(aCmpIter.GetCol()) : static_cast(aCmpIter.GetRow()); if (bColumnDiff) @@ -6174,7 +6174,7 @@ String ScCellObj::GetOutputString_Impl(ScDocument* pDoc, const ScAddress& aCellP if ( pDoc ) { ScBaseCell* pCell = pDoc->GetCell( aCellPos ); - if ( pCell && pCell->GetCellType() != CELLTYPE_EMPTY ) + if ( pCell && pCell->GetCellType() != CELLTYPE_NOTE ) { if ( pCell->GetCellType() == CELLTYPE_EDIT ) { @@ -9201,7 +9201,7 @@ void ScCellsEnumeration::CheckPos_Impl() sal_Bool bFound = false; ScDocument* pDoc = pDocShell->GetDocument(); ScBaseCell* pCell = pDoc->GetCell(aPos); - if ( pCell && pCell->GetCellType() != CELLTYPE_EMPTY ) + if ( pCell && pCell->GetCellType() != CELLTYPE_NOTE ) { if (!pMark) { diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx index f3b91a589e1e..757edb66d1ed 100644 --- a/sc/source/ui/unoobj/chart2uno.cxx +++ b/sc/source/ui/unoobj/chart2uno.cxx @@ -2451,7 +2451,7 @@ void ScChart2DataSequence::BuildDataCache() #endif case CELLTYPE_EDIT: case CELLTYPE_NONE: - case CELLTYPE_EMPTY: + case CELLTYPE_NOTE: case CELLTYPE_STRING: case CELLTYPE_SYMBOLS: default: diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index 73fa37ce8323..4d4d5880a2a2 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -3397,11 +3397,11 @@ bool ScAnnotationsObj::GetAddressByIndex_Impl( sal_Int32 nIndex, ScAddress& rPos ScCellIterator aCellIter( pDoc, 0,0, nTab, MAXCOL,MAXROW, nTab ); for( ScBaseCell* pCell = aCellIter.GetFirst(); pCell; pCell = aCellIter.GetNext() ) { - if ( pDoc->GetNote( aCellIter.GetPos() ) ) + if (pCell->HasNote()) { if (nFound == nIndex) { - rPos = aCellIter.GetPos(); + rPos = ScAddress( aCellIter.GetCol(), aCellIter.GetRow(), aCellIter.GetTab() ); return true; } ++nFound; @@ -3476,10 +3476,9 @@ sal_Int32 SAL_CALL ScAnnotationsObj::getCount() throw(uno::RuntimeException) sal_uLong nCount = 0; if (pDocShell) { - ScDocument* pDoc = pDocShell->GetDocument(); - ScCellIterator aCellIter( pDoc, 0,0, nTab, MAXCOL,MAXROW, nTab ); + ScCellIterator aCellIter( pDocShell->GetDocument(), 0,0, nTab, MAXCOL,MAXROW, nTab ); for( ScBaseCell* pCell = aCellIter.GetFirst(); pCell; pCell = aCellIter.GetNext() ) - if ( pDoc->GetNote( aCellIter.GetPos() ) ) + if (pCell->HasNote()) ++nCount; } return nCount; diff --git a/sc/source/ui/unoobj/funcuno.cxx b/sc/source/ui/unoobj/funcuno.cxx index bc78043cb7b0..f49a2402ed85 100644 --- a/sc/source/ui/unoobj/funcuno.cxx +++ b/sc/source/ui/unoobj/funcuno.cxx @@ -193,7 +193,7 @@ sal_Bool lcl_CopyData( ScDocument* pSrcDoc, const ScRange& rSrcRange, { if (pCell->GetCellType() == CELLTYPE_FORMULA) { - ScAddress aCellPos( aIter.GetPos() ); + ScAddress aCellPos = aIter.GetPos(); sal_uInt32 nFormat = pClipDoc->GetNumberFormat(aCellPos); if ( (nFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 ) { diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx index d27bba70128b..531ac702250d 100644 --- a/sc/source/ui/view/cellsh.cxx +++ b/sc/source/ui/view/cellsh.cxx @@ -936,7 +936,7 @@ void ScCellShell::GetState(SfxItemSet &rSet) { ScCellIterator aCellIter(pDoc, *aRanges[nPos]); for( ScBaseCell* pCell = aCellIter.GetFirst(); pCell && !bEnable; pCell = aCellIter.GetNext() ) - if ( pDoc->GetNote( aCellIter.GetPos() ) ) + if ( pCell->HasNote() ) bEnable = sal_True; // note found } } diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 14609a7d15e0..69c7a52d7c58 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -387,7 +387,7 @@ sal_Bool lcl_GetHyperlinkCell(ScDocument* pDoc, SCCOL& rPosX, SCROW& rPosY, SCTA do { pDoc->GetCell( rPosX, rPosY, nTab, rpCell ); - if ( !rpCell || CELLTYPE_EMPTY == rpCell->GetCellType() ) + if ( !rpCell || rpCell->GetCellType() == CELLTYPE_NOTE ) { if ( rPosX <= 0 ) return false; // alles leer bis links diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx index 14515f68ce1f..35fbedc52469 100644 --- a/sc/source/ui/view/output.cxx +++ b/sc/source/ui/view/output.cxx @@ -2096,7 +2096,6 @@ void ScOutputData::DrawNoteMarks() { CellInfo* pInfo = &pThisRowInfo->pCellInfo[nX+1]; ScBaseCell* pCell = pInfo->pCell; - ScAddress aPos( nX, pThisRowInfo->nRowNo, nTab ); sal_Bool bIsMerged = false; if ( nX==nX1 && pInfo->bHOverlapped && !pInfo->bVOverlapped ) @@ -2107,17 +2106,12 @@ void ScOutputData::DrawNoteMarks() SCCOL nMergeX = nX; SCROW nMergeY = nY; pDoc->ExtendOverlapped( nMergeX, nMergeY, nX, nY, nTab ); - aPos.SetCol( nMergeX ); - aPos.SetRow( nMergeY ); - pCell = pDoc->GetCell( aPos ); + pCell = pDoc->GetCell( ScAddress(nMergeX,nMergeY,nTab) ); // use origin's pCell for NotePtr test below } - if ( pCell - && pDoc->GetNote( aPos ) - && ( bIsMerged - || ( !pInfo->bHOverlapped && !pInfo->bVOverlapped ) ) - ) + if ( pCell && pCell->HasNote() && ( bIsMerged || + ( !pInfo->bHOverlapped && !pInfo->bVOverlapped ) ) ) { if (bFirst) { @@ -2184,24 +2178,18 @@ void ScOutputData::AddPDFNotes() SCROW nY = pRowInfo[nArrY].nRowNo; SCCOL nMergeX = nX; SCROW nMergeY = nY; - ScAddress aPos( nX, nY, nTab ); if ( nX==nX1 && pInfo->bHOverlapped && !pInfo->bVOverlapped ) { // find start of merged cell bIsMerged = sal_True; pDoc->ExtendOverlapped( nMergeX, nMergeY, nX, nY, nTab ); - aPos.SetCol( nMergeX ); - aPos.SetRow( nMergeY ); - pCell = pDoc->GetCell( aPos ); + pCell = pDoc->GetCell( ScAddress(nMergeX,nMergeY,nTab) ); // use origin's pCell for NotePtr test below } - const ScPostIt* pNote = pDoc->GetNote( aPos ); - if ( pCell && pNote - && ( bIsMerged - || ( !pInfo->bHOverlapped && !pInfo->bVOverlapped ) ) - ) + if ( pCell && pCell->HasNote() && ( bIsMerged || + ( !pInfo->bHOverlapped && !pInfo->bVOverlapped ) ) ) { long nNoteWidth = (long)( SC_CLIPMARK_SIZE * nPPTX ); long nNoteHeight = (long)( SC_CLIPMARK_SIZE * nPPTY ); @@ -2220,10 +2208,11 @@ void ScOutputData::AddPDFNotes() if ( bLayoutRTL ? ( nMarkX >= 0 ) : ( nMarkX < nScrX+nScrW ) ) { Rectangle aNoteRect( nMarkX, nPosY, nMarkX+nNoteWidth*nLayoutSign, nPosY+nNoteHeight ); + const ScPostIt* pNote = pCell->GetNote(); // Note title is the cell address (as on printed note pages) String aTitle; - ScAddress aAddress( aPos ); + ScAddress aAddress( nMergeX, nMergeY, nTab ); aAddress.Format( aTitle, SCA_VALID, pDoc, pDoc->GetAddressConvention() ); // Content has to be a simple string without line breaks diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index 0082cdf92052..b0dba17f4507 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -1088,7 +1088,7 @@ sal_Bool ScOutputData::IsAvailable( SCCOL nX, SCROW nY ) // where a note is empty as well as a cell that's hidden by protection settings const ScBaseCell* pCell = pDoc->GetCell( ScAddress( nX, nY, nTab ) ); - if ( pCell && pCell->GetCellType() != CELLTYPE_EMPTY && !IsEmptyCellText( NULL, nX, nY ) ) + if ( pCell && pCell->GetCellType() != CELLTYPE_NOTE && !IsEmptyCellText( NULL, nX, nY ) ) { return false; } diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx index 4dee3fb68ce4..7c07e11c714f 100644 --- a/sc/source/ui/view/printfun.cxx +++ b/sc/source/ui/view/printfun.cxx @@ -1924,7 +1924,8 @@ long ScPrintFunc::DoNotes( long nNoteStart, sal_Bool bDoPrint, ScPreviewLocation { ScAddress &rPos = aNotePosList[ nNoteStart + nCount ]; - if( const ScPostIt* pNote = pDoc->GetNote( rPos ) ) + ScBaseCell* pCell = pDoc->GetCell( rPos); + if( const ScPostIt* pNote = pCell->GetNote() ) { if(const EditTextObject *pEditText = pNote->GetEditTextObject()) pEditEngine->SetText(*pEditText); @@ -2564,10 +2565,9 @@ long ScPrintFunc::CountNotePages() ScBaseCell* pCell = aIter.GetNext( nCol, nRow ); while (pCell) { - ScAddress aPos( nCol, nRow, nPrintTab ); - if ( pDoc->GetNote( aPos ) ) + if (pCell->HasNote()) { - aNotePosList.push_back( aPos ); + aNotePosList.push_back( ScAddress( nCol,nRow,nPrintTab ) ); ++nCount; } diff --git a/sc/source/ui/view/spelleng.cxx b/sc/source/ui/view/spelleng.cxx index 1b047acc8e87..10d517b31a5e 100644 --- a/sc/source/ui/view/spelleng.cxx +++ b/sc/source/ui/view/spelleng.cxx @@ -136,7 +136,7 @@ bool ScConversionEngineBase::FindNextConversionCell() if( mpUndoDoc && pCell ) { - ScBaseCell* pUndoCell = pCell->Clone( *mpUndoDoc ); + ScBaseCell* pUndoCell = pCell->CloneWithoutNote( *mpUndoDoc ); mpUndoDoc->PutCell( aPos, pUndoCell ); } @@ -157,7 +157,7 @@ bool ScConversionEngineBase::FindNextConversionCell() if( mpRedoDoc && pCell ) { - ScBaseCell* pRedoCell = pCell->Clone( *mpRedoDoc ); + ScBaseCell* pRedoCell = pCell->CloneWithoutNote( *mpRedoDoc ); mpRedoDoc->PutCell( aPos, pRedoCell ); } diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index dcea6d5ee24c..dacdb113f932 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -397,7 +397,7 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rS pDoc->GetCell( nCol, nRow, i, pDocCell ); if ( pDocCell ) { - ppOldCells[nUndoPos] = pDocCell->Clone( *pDoc ); + ppOldCells[nUndoPos] = pDocCell->CloneWithoutNote( *pDoc ); if ( pDocCell->GetCellType() == CELLTYPE_EDIT ) bEditDeleted = sal_True; @@ -709,7 +709,7 @@ void ScViewFunc::EnterValue( SCCOL nCol, SCROW nRow, SCTAB nTab, const double& r nCol,nRow,nTab, nCol,nRow,nTab, HASATTR_NEEDHEIGHT ); // Undo - ScBaseCell* pUndoCell = (bUndo && pOldCell) ? pOldCell->Clone( *pDoc ) : 0; + ScBaseCell* pUndoCell = (bUndo && pOldCell) ? pOldCell->CloneWithoutNote( *pDoc ) : 0; pDoc->SetValue( nCol, nRow, nTab, rValue ); @@ -804,7 +804,7 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const EditTextOb pTabs[nPos] = *itr; ScBaseCell* pDocCell; pDoc->GetCell( nCol, nRow, *itr, pDocCell ); - ppOldCells[nPos] = pDocCell ? pDocCell->Clone( *pDoc ) : 0; + ppOldCells[nPos] = pDocCell ? pDocCell->CloneWithoutNote( *pDoc ) : 0; ++nPos; } -- cgit From 34191b3c0f2fe349293068a0b968c7c68724dea7 Mon Sep 17 00:00:00 2001 From: Andras Timar Date: Mon, 31 Oct 2011 19:06:15 +0100 Subject: towards enabling l10n of extension description in swext --- swext/Extension_wiki-publisher.mk | 2 +- swext/Zip_mediawiki_develop.mk | 2 +- swext/mediawiki/src/component.txt | 1 - swext/mediawiki/src/description-en-US.txt | 1 + swext/mediawiki/src/description.xml | 2 +- 5 files changed, 4 insertions(+), 4 deletions(-) delete mode 100755 swext/mediawiki/src/component.txt create mode 100644 swext/mediawiki/src/description-en-US.txt diff --git a/swext/Extension_wiki-publisher.mk b/swext/Extension_wiki-publisher.mk index bdf0855660ec..d4c64d505e98 100644 --- a/swext/Extension_wiki-publisher.mk +++ b/swext/Extension_wiki-publisher.mk @@ -53,7 +53,7 @@ $(eval $(call gb_Extension_add_file,wiki-publisher,WikiEditor/script.xlb,$(WIKIS $(eval $(call gb_Extension_add_file,wiki-publisher,WikiEditor/dialog.xlb,$(WIKISRC)/dialogs/dialog.xlb)) $(eval $(call gb_Extension_add_file,wiki-publisher,WikiEditor/SendToMediaWiki.xdl,$(WIKISRC)/dialogs/SendToMediaWiki.xdl)) $(eval $(call gb_Extension_add_file,wiki-publisher,filter/odt2mediawiki.xsl,$(WIKISRC)/src/filter/odt2mediawiki.xsl)) -$(eval $(call gb_Extension_add_file,wiki-publisher,component.txt,$(WIKISRC)/src/component.txt)) +$(eval $(call gb_Extension_add_file,wiki-publisher,description-en-US.txt,$(WIKISRC)/src/description-en-US.txt)) $(eval $(call gb_Extension_add_file,wiki-publisher,help/en-US/com.sun.wiki-publisher/wikisend.xhp,$(WIKISRC)/help/wikisend.xhp)) $(eval $(call gb_Extension_add_file,wiki-publisher,help/en-US/com.sun.wiki-publisher/wikiformats.xhp,$(WIKISRC)/help/wikiformats.xhp)) $(eval $(call gb_Extension_add_file,wiki-publisher,help/en-US/com.sun.wiki-publisher/wikiaccount.xhp,$(WIKISRC)/help/wikiaccount.xhp)) diff --git a/swext/Zip_mediawiki_develop.mk b/swext/Zip_mediawiki_develop.mk index cb99ce894cd1..f682b074e82d 100644 --- a/swext/Zip_mediawiki_develop.mk +++ b/swext/Zip_mediawiki_develop.mk @@ -49,7 +49,7 @@ $(eval $(call gb_Zip_add_file,mediawiki_develop,WikiEditor/script.xlb,$(WIKISRC) $(eval $(call gb_Zip_add_file,mediawiki_develop,WikiEditor/dialog.xlb,$(WIKISRC)/dialogs/dialog.xlb)) $(eval $(call gb_Zip_add_file,mediawiki_develop,WikiEditor/SendToMediaWiki.xdl,$(WIKISRC)/dialogs/SendToMediaWiki.xdl)) $(eval $(call gb_Zip_add_file,mediawiki_develop,filter/odt2mediawiki.xsl,$(WIKISRC)/src/filter/odt2mediawiki.xsl)) -$(eval $(call gb_Zip_add_file,mediawiki_develop,component.txt,$(WIKISRC)/src/component.txt)) +$(eval $(call gb_Zip_add_file,mediawiki_develop,description-en-US.txt,$(WIKISRC)/src/description-en-US.txt)) $(eval $(call gb_Zip_add_file,mediawiki_develop,help/en-US/com.sun.wiki-publisher/wikisend.xhp,$(WIKISRC)/help/wikisend.xhp)) $(eval $(call gb_Zip_add_file,mediawiki_develop,help/en-US/com.sun.wiki-publisher/wikiformats.xhp,$(WIKISRC)/help/wikiformats.xhp)) $(eval $(call gb_Zip_add_file,mediawiki_develop,help/en-US/com.sun.wiki-publisher/wikiaccount.xhp,$(WIKISRC)/help/wikiaccount.xhp)) diff --git a/swext/mediawiki/src/component.txt b/swext/mediawiki/src/component.txt deleted file mode 100755 index d993ce105691..000000000000 --- a/swext/mediawiki/src/component.txt +++ /dev/null @@ -1 +0,0 @@ -The Wiki Publisher enables you to create Wiki articles on MediaWiki servers without having to know the syntax of the MediaWiki markup language. Publish your new and existing documents transparently with the Writer to a wiki page. diff --git a/swext/mediawiki/src/description-en-US.txt b/swext/mediawiki/src/description-en-US.txt new file mode 100644 index 000000000000..d993ce105691 --- /dev/null +++ b/swext/mediawiki/src/description-en-US.txt @@ -0,0 +1 @@ +The Wiki Publisher enables you to create Wiki articles on MediaWiki servers without having to know the syntax of the MediaWiki markup language. Publish your new and existing documents transparently with the Writer to a wiki page. diff --git a/swext/mediawiki/src/description.xml b/swext/mediawiki/src/description.xml index 31dcfe3d9840..11d10b5bb8db 100644 --- a/swext/mediawiki/src/description.xml +++ b/swext/mediawiki/src/description.xml @@ -12,6 +12,6 @@ The Document Foundation - + -- cgit From 0ca429a00b6fca4eed328d106e95b447dd813e58 Mon Sep 17 00:00:00 2001 From: Andras Timar Date: Mon, 31 Oct 2011 20:50:17 +0100 Subject: l10n update --- nlpsolver/locale/NLPSolverCommon_gd.properties | 22 +++++++++++++++++ nlpsolver/locale/NLPSolverCommon_nb.properties | 2 +- .../locale/NLPSolverStatusDialog_gd.properties | 28 ++++++++++++++++++++++ .../locale/NLPSolverStatusDialog_is.properties | 2 +- 4 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 nlpsolver/locale/NLPSolverCommon_gd.properties create mode 100644 nlpsolver/locale/NLPSolverStatusDialog_gd.properties diff --git a/nlpsolver/locale/NLPSolverCommon_gd.properties b/nlpsolver/locale/NLPSolverCommon_gd.properties new file mode 100644 index 000000000000..83fa72834fde --- /dev/null +++ b/nlpsolver/locale/NLPSolverCommon_gd.properties @@ -0,0 +1,22 @@ +# x-no-translate +#BaseNLPSolver +NLPSolverCommon.Properties.AssumeNonNegative=Cuir mar fhiacham caochladairean neo-\u00E0icheil +#BaseEvolutionarySolver +NLPSolverCommon.Properties.SwarmSize=Meud an sgaotha +NLPSolverCommon.Properties.LibrarySize=Meud na leabhar-lainn +NLPSolverCommon.Properties.LearningCycles=Cuairtean ionnsachaidh +NLPSolverCommon.Properties.GuessVariableRange=Tomhas air cr\u00ECochan nan caochladairean +NLPSolverCommon.Properties.VariableRangeThreshold=Stairsneach cr\u00ECochan nan caochladairean (nuair a nithear tomhas) +NLPSolverCommon.Properties.UseACRComparator=Cleachd coimeasaiche ACR (an \u00E0ite BCH) +NLPSolverCommon.Properties.UseRandomStartingPoint=Cleachd puing t\u00F2iseachaidh air thuaiream +NLPSolverCommon.Properties.StagnationLimit=Cr\u00ECoch na neo-ghluasadachd +NLPSolverCommon.Properties.Tolerance=Fulangas na neo-ghluasadachd +NLPSolverCommon.Properties.EnhancedSolverStatus=Seall staid mheudaichte an fhuasglair +#DEPS +NLPSolverCommon.Properties.AgentSwitchRate=Reat suidseadh \u00E0idseint (Coltachd DE) +NLPSolverCommon.Properties.DEFactor=DE: Factar sg\u00E8ilidh (0-1.2) +NLPSolverCommon.Properties.DECR=DE: Coltachd Crossover (0-1) +NLPSolverCommon.Properties.PSC1=PS: Cunbhalachan cognatach +NLPSolverCommon.Properties.PSC2=PS: Cunbhalachan s\u00F2isealta +NLPSolverCommon.Properties.PSWeight=PS: Co-\u00E8ifeachd cuingealachaidh +NLPSolverCommon.Properties.PSCL=PS: Coltachd m\u00F9thaidh (0-0.005) diff --git a/nlpsolver/locale/NLPSolverCommon_nb.properties b/nlpsolver/locale/NLPSolverCommon_nb.properties index 3b88d95b50f8..477fea9c0f99 100644 --- a/nlpsolver/locale/NLPSolverCommon_nb.properties +++ b/nlpsolver/locale/NLPSolverCommon_nb.properties @@ -1,6 +1,6 @@ # x-no-translate #BaseNLPSolver -NLPSolverCommon.Properties.AssumeNonNegative=Assume Non-Negative Variables +NLPSolverCommon.Properties.AssumeNonNegative=Anta positive variabler #BaseEvolutionarySolver NLPSolverCommon.Properties.SwarmSize=Size of Swarm NLPSolverCommon.Properties.LibrarySize=Bibliotekst\u00F8rrelse diff --git a/nlpsolver/locale/NLPSolverStatusDialog_gd.properties b/nlpsolver/locale/NLPSolverStatusDialog_gd.properties new file mode 100644 index 000000000000..4bbe57a62118 --- /dev/null +++ b/nlpsolver/locale/NLPSolverStatusDialog_gd.properties @@ -0,0 +1,28 @@ +# x-no-translate +#Dialog +NLPSolverStatusDialog.Dialog.Caption=Staid an fhuasglair +#Controls +NLPSolverStatusDialog.Controls.lblSolution=Am fuasgladh l\u00E0ithreach: +NLPSolverStatusDialog.Controls.lblIteration=Ath-nochdaidhean: +NLPSolverStatusDialog.Controls.lblStagnation=Neo-ghluasadachd: +NLPSolverStatusDialog.Controls.lblRuntime=\u00D9ine ruith: +NLPSolverStatusDialog.Controls.btnStop=Cuir stad air +NLPSolverStatusDialog.Controls.btnOK=Ceart ma-th\u00E0 +NLPSolverStatusDialog.Controls.btnContinue=Lean air adhart +#Messages +NLPSolverStatusDialog.Message.StopIteration=R\u00E0inig thu na tha ceadaichte de ath-nochdaidhean. +NLPSolverStatusDialog.Message.StopStagnation=Stad am pr\u00F2iseas air sg\u00E0th neo-ghluasadachd. +NLPSolverStatusDialog.Message.StopUser=Stad an cleachdaiche am pr\u00F2iseas. +NLPSolverStatusDialog.Message.CurrentIteration=Stad am pr\u00F2iseas aig ath-nochdadh %d \u00E0 %d. +#Time formatting +NLPSolverStatusDialog.Time.Nanoseconds=Nano-dhiogan +NLPSolverStatusDialog.Time.Microseconds=Micreo-dhiogan +NLPSolverStatusDialog.Time.Milliseconds=Mille-dhiogan +NLPSolverStatusDialog.Time.Second=Diog +NLPSolverStatusDialog.Time.Seconds=Diogan +NLPSolverStatusDialog.Time.Minute=Mionaid +NLPSolverStatusDialog.Time.Minutes=Mionaidean +NLPSolverStatusDialog.Time.Hour=Uair a th\u00ECde +NLPSolverStatusDialog.Time.Hours=Uairean a th\u00ECde +NLPSolverStatusDialog.Time.Day=Latha +NLPSolverStatusDialog.Time.Days=L\u00E0ithean diff --git a/nlpsolver/locale/NLPSolverStatusDialog_is.properties b/nlpsolver/locale/NLPSolverStatusDialog_is.properties index 74a8b69a0bc0..f037c9a4fdf2 100644 --- a/nlpsolver/locale/NLPSolverStatusDialog_is.properties +++ b/nlpsolver/locale/NLPSolverStatusDialog_is.properties @@ -25,4 +25,4 @@ NLPSolverStatusDialog.Time.Minutes=M\u00EDn\u00FAtur NLPSolverStatusDialog.Time.Hour=Klukkustund NLPSolverStatusDialog.Time.Hours=Klukkustundir NLPSolverStatusDialog.Time.Day=Dagur -NLPSolverStatusDialog.Time.Days=Days +NLPSolverStatusDialog.Time.Days=Dagur -- cgit From 88f91adf266f19659014df22e09ce6c6761fb6f1 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Mon, 31 Oct 2011 21:38:44 +0100 Subject: update first ScMarkData before setting cursor (fdo#42432) our ScMarkData instance might be used to set the cursor which will result in a crash if the selected sheet has been deleted already --- sc/source/ui/view/tabview3.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx index de2d683d4ad0..fdb0b923bfd9 100644 --- a/sc/source/ui/view/tabview3.cxx +++ b/sc/source/ui/view/tabview3.cxx @@ -1511,7 +1511,6 @@ void ScTabView::SetTabNo( SCTAB nTab, bool bNew, bool bExtendSelection, bool bSa // Fenster findet (wird aus SetCursor gerufen) UpdateShow(); aViewData.ResetOldCursor(); - SetCursor( aViewData.GetCurX(), aViewData.GetCurY(), true ); SfxBindings& rBindings = aViewData.GetBindings(); ScMarkData& rMark = aViewData.GetMarkData(); @@ -1548,6 +1547,7 @@ void ScTabView::SetTabNo( SCTAB nTab, bool bNew, bool bExtendSelection, bool bSa rBindings.Invalidate( FID_TAB_DESELECTALL ); } + SetCursor( aViewData.GetCurX(), aViewData.GetCurY(), true ); bool bUnoRefDialog = pScMod->IsRefDialogOpen() && pScMod->GetCurRefDlgId() == WID_SIMPLE_REF; // recalc zoom-dependent values (before TabChanged, before UpdateEditViewPos) -- cgit From 1635f66a3dd35c5bf34143956940ec44fda751c2 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 31 Oct 2011 23:47:02 +0100 Subject: Moved CONFIGURATION_LAYERS from soffice to fundamental ini. ...so that unopkg uses it, too. --- scp2/source/ooo/common_brand.scp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/scp2/source/ooo/common_brand.scp b/scp2/source/ooo/common_brand.scp index d9baffadd402..9b75f369d578 100644 --- a/scp2/source/ooo/common_brand.scp +++ b/scp2/source/ooo/common_brand.scp @@ -927,18 +927,6 @@ ProfileItem gid_Brand_Profileitem_Soffice_Startlang End #endif -ProfileItem gid_Brand_Profileitem_Soffice_ConfigurationLayers - ProfileID = gid_Brand_Profile_Soffice_Ini; - ModuleID = gid_Module_Root_Brand; - Section = "Bootstrap"; - Key = "CONFIGURATION_LAYERS"; - Value = "xcsxcu:${BRAND_BASE_DIR}/share/registry module:${BRAND_BASE_DIR}/share/registry/modules res:${BRAND_BASE_DIR}/share/registry bundledext:${${BRAND_BASE_DIR}/program/" PROFILENAME(uno) ":BUNDLED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini sharedext:${${BRAND_BASE_DIR}/program/" PROFILENAME(uno) ":SHARED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini xcsxcu:${${BRAND_BASE_DIR}/program/" PROFILENAME(uno) ":UNO_USER_PACKAGES_CACHE}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/registry userext:${${BRAND_BASE_DIR}/program/" PROFILENAME(uno) ":UNO_USER_PACKAGES_CACHE}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini user:${$BRAND_BASE_DIR/program/" PROFILENAME(bootstrap) ":UserInstallation}/user/registrymodifications.xcu"; - // "xcsxcu:${${BRAND_BASE_DIR}/program/"PROFILENAME(uno) - // ":UNO_USER_PACKAGES_CACHE}/registry/com.sun.star.comp.deployment." - // "configuration.PackageRegistryBackend/registry" can be dropped once - // old UserInstallation format can no longer exist (probably OOo 4) -End - ProfileItem gid_Brand_Profileitem_Version_Buildid ProfileID = gid_Brand_Profile_Version_Ini; ModuleID = gid_Module_Root_Brand; @@ -1256,6 +1244,18 @@ ProfileItem gid_Brand_Profileitem_Fundamental_Ure_Lib_Dir #endif End +ProfileItem gid_Brand_Profileitem_Fundamental_Configuration_Layers + ProfileID = gid_Brand_Profile_Fundamental_Ini; + ModuleID = gid_Module_Root_Brand; + Section = "Bootstrap"; + Key = "CONFIGURATION_LAYERS"; + Value = "xcsxcu:${BRAND_BASE_DIR}/share/registry module:${BRAND_BASE_DIR}/share/registry/modules res:${BRAND_BASE_DIR}/share/registry bundledext:${${BRAND_BASE_DIR}/program/" PROFILENAME(uno) ":BUNDLED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini sharedext:${${BRAND_BASE_DIR}/program/" PROFILENAME(uno) ":SHARED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini xcsxcu:${${BRAND_BASE_DIR}/program/" PROFILENAME(uno) ":UNO_USER_PACKAGES_CACHE}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/registry userext:${${BRAND_BASE_DIR}/program/" PROFILENAME(uno) ":UNO_USER_PACKAGES_CACHE}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini user:${$BRAND_BASE_DIR/program/" PROFILENAME(bootstrap) ":UserInstallation}/user/registrymodifications.xcu"; + // "xcsxcu:${${BRAND_BASE_DIR}/program/"PROFILENAME(uno) + // ":UNO_USER_PACKAGES_CACHE}/registry/com.sun.star.comp.deployment." + // "configuration.PackageRegistryBackend/registry" can be dropped once + // old UserInstallation format can no longer exist (probably OOo 4) +End + #if !defined MACOSX ProfileItem gid_Brand_Profileitem_Redirect_Ure_Bootstrap ModuleID = gid_Module_Root_Brand; -- cgit From 125aa32e71eb9a8de6214a7f7bc3e3be13b14a7a Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Tue, 1 Nov 2011 00:51:46 +0100 Subject: we need to assign this value also for non unix platforms (fdo#40801) --- tools/source/stream/stream.cxx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx index 34dc93d66bd7..2b9295b436a4 100644 --- a/tools/source/stream/stream.cxx +++ b/tools/source/stream/stream.cxx @@ -1308,10 +1308,8 @@ SvStream& SvStream::operator>>(double& r) #if defined UNX if (bSwap) SwapDouble(n); - r = n; -#else - (void) r; #endif + r = n; } return *this; } -- cgit From 0ba264cc9f8ab33c7081223a3612cfe6604b150f Mon Sep 17 00:00:00 2001 From: Joseph Powers Date: Mon, 31 Oct 2011 21:29:39 -0700 Subject: Delete some unused .hxx files from autodoc --- autodoc/inc/ary/actions.hxx | 105 ------------------ autodoc/inc/ary/doc/d_parametrized.hxx | 124 ---------------------- autodoc/inc/ary/doc/ht/dht_interpreter.hxx | 79 -------------- autodoc/inc/ary/udmhost.hxx | 65 ------------ autodoc/inc/autodoc/dsp_txt_flist.hxx | 67 ------------ autodoc/source/ary/inc/cross_refs.hxx | 101 ------------------ autodoc/source/ary/inc/sorted_idset.hxx | 99 ----------------- autodoc/source/ary/inc/traits_impl.hxx | 122 --------------------- autodoc/source/inc/manip.hxx | 63 ----------- autodoc/source/parser_i/inc/s2_luidl/pe_modul.hxx | 65 ------------ autodoc/source/parser_i/inc/s2_luidl/smp_uidl.hxx | 84 --------------- 11 files changed, 974 deletions(-) delete mode 100644 autodoc/inc/ary/actions.hxx delete mode 100644 autodoc/inc/ary/doc/d_parametrized.hxx delete mode 100644 autodoc/inc/ary/doc/ht/dht_interpreter.hxx delete mode 100644 autodoc/inc/ary/udmhost.hxx delete mode 100644 autodoc/inc/autodoc/dsp_txt_flist.hxx delete mode 100644 autodoc/source/ary/inc/cross_refs.hxx delete mode 100644 autodoc/source/ary/inc/sorted_idset.hxx delete mode 100644 autodoc/source/ary/inc/traits_impl.hxx delete mode 100644 autodoc/source/inc/manip.hxx delete mode 100644 autodoc/source/parser_i/inc/s2_luidl/pe_modul.hxx delete mode 100644 autodoc/source/parser_i/inc/s2_luidl/smp_uidl.hxx diff --git a/autodoc/inc/ary/actions.hxx b/autodoc/inc/ary/actions.hxx deleted file mode 100644 index 5e2536ccd063..000000000000 --- a/autodoc/inc/ary/actions.hxx +++ /dev/null @@ -1,105 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef ARY_ACTIONS_HXX -#define ARY_ACTIONS_HXX -// KORR_DEPRECATED_3.0 - - -// USED SERVICES - // BASE CLASSES - // COMPONENTS - // PARAMETERS - - -namespace ary -{ - class RepositoryCenter; - - -/* -enum E_Action -{ - action_Parse, - action_SecondaryProductions, - action_Save, - action_Load, - action_ReadyForRead -}; -*/ - - -/** @resp - Performs such commands on the repository, which refer to - large parts of it. - - @collab ::ary::Repository - and its components and derivates. - @descr - This class works in kind of double dispatch way: - - // Client code: - Command_Xy aMyCommand; - ary::Repository::The_().PerformCommand( aMyCommand ); - - // Repository_Implementation::PerformCommand() code: - aMyCommand.Run(*this); - - // Command_Xy::Run(Repository_Implementation & rRepository) code: - rRepository.Run_Command_Xy(*this); -*/ -class Command -{ - public: - virtual ~Command() {} - - void Run( - n22::RepositoryCenter & - io_rReposy ); - private: - virtual void do_Run( - n22::RepositoryCenter & - io_rReposy ) = 0; -}; - - -// IMPLEMENTATION - -inline void -Command::Run(n22::RepositoryCenter & io_rReposy) - { do_Run(io_rReposy); } - - -} // namespace ary - - -#endif - - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/inc/ary/doc/d_parametrized.hxx b/autodoc/inc/ary/doc/d_parametrized.hxx deleted file mode 100644 index 78659e701441..000000000000 --- a/autodoc/inc/ary/doc/d_parametrized.hxx +++ /dev/null @@ -1,124 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef ARY_DOC_D_PARAMETER_HXX -#define ARY_DOC_D_PARAMETER_HXX - -// USED SERVICES - // BASE CLASSES -#include - -namespace ary -{ -namespace doc -{ - - -/** Documentation unit with Parameter. -*/ -template -class Parametrized : public Node -{ - public: - // LIFECYCLE - explicit Parametrized( - nodetype::id i_id, - T i_Parameter ); - virtual ~Parametrized(); - - // INQUIRY - const HyperText & Doc() const; - const T & Parameter() const; - - // ACESS - HyperText & Doc(); - void Set_Parameter( - const T & i_param ); - private: - // Interface csv::ConstProcessorClient: - virtual void do_Accept( - csv::ProcessorIfc & io_processor ) const; - // DATA - HyperText aDoc; - T aParameter; -}; - - - - -// IMPLEMENTATION -template -Parametrized::Parametrized( nodetype::id i_id, - T i_Parameter ) - : Node(i_id), - aDoc(), - aParameter(i_Parameter) -{ -} - -template -Parametrized::~Parametrized() -{ -} - -template -const HyperText & -Parametrized::Doc() const -{ - return aDoc; -} - -template -const T & -Parametrized::Parameter() const -{ - return aParameter; -} - -template -HyperText & -Parametrized::Doc() -{ - return aDoc; -} - -template -inline void -Parametrized::Set_Parameter(const T & i_param) -{ - aParameter = i_param; -} - - - - -} // namespace doc -} // namespace ary -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/inc/ary/doc/ht/dht_interpreter.hxx b/autodoc/inc/ary/doc/ht/dht_interpreter.hxx deleted file mode 100644 index 874f3425bf48..000000000000 --- a/autodoc/inc/ary/doc/ht/dht_interpreter.hxx +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef ARY_DHT_INTERPRETER_HXX -#define ARY_DHT_INTERPRETER_HXX - - - - -namespace ary -{ -namespace doc -{ -namespace ht -{ - class Processor; - - -/** Interface for all interpreters of a ->Component. -*/ -class Interpreter -{ - public: - virtual ~Interpreter() {} - - void Accept( - Processor & io_processor, - const String & i_data ) const; - private: - virtual void do_Accept( - Processor & io_processor, - const String & i_data ) const = 0; -}; - - - - -// IMPLEMENTATION -inline void -Interpreter::Accept( Processor & io_processor, - const String & i_data ) const -{ - do_Accept(io_processor, i_data); -} - - - - -} // namespace ht -} // namespace doc -} // namespace ary -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/inc/ary/udmhost.hxx b/autodoc/inc/ary/udmhost.hxx deleted file mode 100644 index 13d8c2377d82..000000000000 --- a/autodoc/inc/ary/udmhost.hxx +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef ARY_UDMHOST_HXX -#define ARY_UDMHOST_HXX -// KORR_DEPRECATED_3.0 - - - -// USED SERVICES - // BASE CLASSES -#include - // COMPONENTS - // PARAMETERS - -namespace ary -{ - - - -class UdmHost : public Host -{ - public: - enum E_ClassId { class_id = 1000 }; - - UdmHost(); - virtual ~UdmHost(); - - private: - virtual Host_ClassId - inq_ClassId() const; -}; - - - - -} // namespace ary -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/inc/autodoc/dsp_txt_flist.hxx b/autodoc/inc/autodoc/dsp_txt_flist.hxx deleted file mode 100644 index 1b655bd939aa..000000000000 --- a/autodoc/inc/autodoc/dsp_txt_flist.hxx +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef AUTODOC_DSP_TXT_FLIST_HXX -#define AUTODOC_DSP_TXT_FLIST_HXX - -#include - - -namespace ary -{ - namespace cpp - { - class DisplayGate; - } -} - - -namespace autodoc -{ - -class TextDisplay_FunctionList_Ifc -{ - public: - virtual ~TextDisplay_FunctionList_Ifc() {} - - /** Displays the names of all C++ functions and methods within the - given namespace (or the global namespace as default). All - subnamespaces are included. - */ - virtual void Run( - ostream & o_rStream, - const ary::cpp::DisplayGate & - i_rAryGate ) = 0; /// If i_pNamespace == 0, the global namespace is displayed. -}; - - -} // namespace autodoc - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/source/ary/inc/cross_refs.hxx b/autodoc/source/ary/inc/cross_refs.hxx deleted file mode 100644 index d07a629a4797..000000000000 --- a/autodoc/source/ary/inc/cross_refs.hxx +++ /dev/null @@ -1,101 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef ARY_CROSS_REFS_HXX -#define ARY_CROSS_REFS_HXX - - - -// USED SERVICES - // BASE CLASSES - // COMPONENTS - // PARAMETERS -#include "sorted_idset.hxx" - - -template -class CrossReferences -{ - public: - typedef TYPES::element_type element; - - /// Checks for double occurrences - void Add( - VALUE_LIST::index_type - i_nPosition - const element & i_rElem ); - void Get_List( - Dyn_StdConstIterator & - o_rResult ) const; - private: - SortedIdSet aData[VALUE_LIST::max]; -}; - - - -namespace ary -{ - -template -class SortedIdSet -{ - public: - typedef typename TYPES::element_type element; - typedef typename TYPES::sort_type sorter; - typedef typename TYPES::find_type finder; - - SortedIdSet( - const finder & i_rFinder ) - : aSorter(i_rFinder), - aData(aSorter) {} - ~SortedIdSet() {} - - void Get_Begin( - Dyn_StdConstIterator & - o_rResult ) - { o_rResult = new SCI_Set(aData); } - void Add( - const element & i_rElement ) - { aData.insert(i_rElement); } - - private: - typedef std::set Set; - - // DATA - sorter aSorter; - Set aData; -}; - - -} // namespace ary - - - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/source/ary/inc/sorted_idset.hxx b/autodoc/source/ary/inc/sorted_idset.hxx deleted file mode 100644 index 4113bfb3f47d..000000000000 --- a/autodoc/source/ary/inc/sorted_idset.hxx +++ /dev/null @@ -1,99 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef ARY_SORTED_IDSET_HXX -#define ARY_SORTED_IDSET_HXX - - - -// USED SERVICES - // BASE CLASSES - // COMPONENTS -#include - // PARAMETERS -#include "csi_impl.hxx" - - -template class SortedIdSet; - -class Interface_2s -{ - public: - /// Checks for double occurrences - void Add_ExportingService( - Ce_id i_nId ); - void Get_ExportingServices( - Dyn_StdConstIterator & - o_rResult ) const; - private: - Dyn pExportingServices; -}; - - - -namespace ary -{ - -template -class SortedIdSet -{ - public: - typedef typename TYPES::element_type element; - typedef typename TYPES::sort_type sorter; - typedef typename TYPES::find_type finder; - - SortedIdSet( - const finder & i_rFinder ) - : aSorter(i_rFinder), - aData(aSorter) {} - ~SortedIdSet() {} - - void Get_Begin( - Dyn_StdConstIterator & - o_rResult ) - { o_rResult = new SCI_Set(aData); } - void Add( - const element & i_rElement ) - { aData.insert(i_rElement); } - - private: - typedef std::set Set; - - // DATA - sorter aSorter; - Set aData; -}; - - -} // namespace ary - - - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/source/ary/inc/traits_impl.hxx b/autodoc/source/ary/inc/traits_impl.hxx deleted file mode 100644 index b7ac789e486b..000000000000 --- a/autodoc/source/ary/inc/traits_impl.hxx +++ /dev/null @@ -1,122 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef ARY_TRAITS_IMPL_HXX -#define ARY_TRAITS_IMPL_HXX - - -// USED SERVICES -#include - - -namespace ary -{ -namespace traits -{ - - -/** Finds the node assigned to an entity, if that entity has a specific - actual type. - - @tpl NODE - The assumed actual type of io_node. -*/ -template -const typename NODE::node_t * - NodeOf( - const typename NODE::traits_t::entity_base_type & - io_node ); - -/** Finds the node assigned to an entity, if that entity has a specific - actual type. - - @tpl NODE - The assumed actual type of io_node. -*/ -template -typename NODE::node_t * - NodeOf( - typename NODE::traits_t::entity_base_type & - io_node ); - -/** Finds a child to a node. -*/ -template -typename NODE::traits_t::id_type - Search_Child( - const typename NODE::traits_t::entity_base_type & - i_node, - const KEY & i_localKey ); - - - - -// IMPLEMENTATION - -template -const typename NODE::node_t * -NodeOf(const typename NODE::traits_t::entity_base_type & io_node) -{ - const NODE * - pn = ary_cast(&io_node); - if (pn != 0) - return & pn->AsNode(); - return 0; -} - -template -typename NODE::node_t * -NodeOf(typename NODE::traits_t::entity_base_type & io_node) -{ - NODE * - pn = ary_cast(&io_node); - if (pn != 0) - return & pn->AsNode(); - return 0; -} - -template -typename NODE::traits_t::id_type -Search_Child( const typename NODE::traits_t::entity_base_type & i_node, - const KEY & i_localKey ) -{ - const NODE * - pn = ary_cast(&i_node); - if (pn != 0) - return pn->Search_Child(i_localKey); - return typename NODE::traits_t::id_type(0); -} - - - - -} // namespace traits -} // namespace ary -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/source/inc/manip.hxx b/autodoc/source/inc/manip.hxx deleted file mode 100644 index cd07815d3fd9..000000000000 --- a/autodoc/source/inc/manip.hxx +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef ARY_MANIP_HXX -#define ARY_MANIP_HXX - -template -class Manipulator -{ - public: - virtual ~Manipulator() {} - - void operator()( - XY & io_r ) const - { op_fcall(io_r); } - private: - virtual void op_fcall( - XY & io_r ) const = 0; -}; - -template -class Const_Manipulator -{ - public: - virtual ~Const_Manipulator() {} - - void operator()( - const XY & io_r ) const - { op_fcall(io_r); } - private: - virtual void op_fcall( - const XY & io_r ) const = 0; -}; - - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/source/parser_i/inc/s2_luidl/pe_modul.hxx b/autodoc/source/parser_i/inc/s2_luidl/pe_modul.hxx deleted file mode 100644 index 1c75d25203d1..000000000000 --- a/autodoc/source/parser_i/inc/s2_luidl/pe_modul.hxx +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef LUIDL_PE_MODUL_HXX -#define LUIDL_PE_MODUL_HXX - - - -// USED SERVICES - // BASE CLASSES -#include - // COMPONENTS - // PARAMETERS - - -namespace csi -{ -namespace uidl -{ - - - -class PE_Module : public ::ParseEnvironment -{ - public: - - virtual void Enter( - E_EnvStackAction i_eWayOfEntering ); - virtual void Leave( - E_EnvStackAction i_eWayOfLeaving ); - - private: -}; - - -} // namespace uidl -} // namespace csi - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/source/parser_i/inc/s2_luidl/smp_uidl.hxx b/autodoc/source/parser_i/inc/s2_luidl/smp_uidl.hxx deleted file mode 100644 index c29f7297c181..000000000000 --- a/autodoc/source/parser_i/inc/s2_luidl/smp_uidl.hxx +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef ADC_SMP_HXX -#define ADC_SMP_HXX - - - -// USED SERVICES - // BASE CLASSES -#include -#include - // COMPONENTS - // PARAMETERS - -namespace csi -{ -namespace uidl -{ - - - -/** is an implementation class for ParseEnvironment -*/ -class SemanticParser : public csi::uidl::Token_Receiver, - public csi::dsapi::Token_Receiver -{ - public: - typedef std::deque< DYN TextToken * > TokenQueue; - - ~SemanticParser(); - - - void Receive( - DYN csi::uidl::Token & - let_drToken ); - void Receive( - DYN csi::dsapi::Token & - let_drToken ); - - private: - // DATA - TokenQueue aTokenQueue; - - -}; - - - -// IMPLEMENTATION - - -} // namespace uidl -} // namespace csi - -#endif - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit From 65a697fdfd8b0db09c7ea50667dc8f0c26f59de8 Mon Sep 17 00:00:00 2001 From: Lionel Elie Mamane Date: Tue, 1 Nov 2011 07:39:27 +0100 Subject: typo in comment --- svx/source/fmcomp/fmgridif.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/svx/source/fmcomp/fmgridif.cxx b/svx/source/fmcomp/fmgridif.cxx index 63dc2348e703..12405622c3e5 100644 --- a/svx/source/fmcomp/fmgridif.cxx +++ b/svx/source/fmcomp/fmgridif.cxx @@ -1541,7 +1541,7 @@ void FmXGridPeer::propertyChange(const PropertyChangeEvent& evt) throw( RuntimeE } else if (evt.PropertyName == FM_PROP_ALIGN) { - // it design mode it doesn't matter + // in design mode it doesn't matter if (!isDesignMode()) { DbGridColumn* pCol = pGrid->GetColumns().at( i ); -- cgit From 3a183d773f837a57671377a22808f66b2ff535ca Mon Sep 17 00:00:00 2001 From: Lionel Elie Mamane Date: Tue, 1 Nov 2011 08:04:28 +0100 Subject: translate comments --- svx/source/fmcomp/fmgridif.cxx | 61 +++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/svx/source/fmcomp/fmgridif.cxx b/svx/source/fmcomp/fmgridif.cxx index 12405622c3e5..1367c9fc0d27 100644 --- a/svx/source/fmcomp/fmgridif.cxx +++ b/svx/source/fmcomp/fmgridif.cxx @@ -527,8 +527,8 @@ void SAL_CALL FmXGridControl::createPeer(const Reference< ::com::sun::star::awt: if (!getPeer().is()) { mbCreatingPeer = sal_True; - // mbCreatingPeer is virtually the same as m_nPeerCreationLevel, but it's the base class' method - // to prevent recursion. + // mbCreatingPeer is virtually the same as m_nPeerCreationLevel, but it's the base class' method + // to prevent recursion. Window* pParentWin = NULL; if (rParentPeer.is()) @@ -542,19 +542,17 @@ void SAL_CALL FmXGridControl::createPeer(const Reference< ::com::sun::star::awt: DBG_ASSERT(pPeer != NULL, "FmXGridControl::createPeer : imp_CreatePeer didn't return a peer !"); setPeer( pPeer ); - // lesen der properties aus dem model + // reading the properties from the model // ++m_nPeerCreationLevel; updateFromModel(); - // folgendes unschoene Szenario : updateFromModel fuehrt zu einem propertiesChanged am Control, - // das stellt fest, dass sich eine 'kritische' Property geaendert hat (zum Beispiel "Border") und - // legt daraufhin eine neue Peer an, was wieder hier im createPeer landet, wir legen also eine - // zweite FmXGridPeer an und initialisieren die. Dann kommen wir in der ersten Inkarnation aus - // dem updsateFromModel raus und arbeiten dort weiter mit dem pPeer, das jetzt eigentlich schon - // veraltet ist (da ja in der zweiten Inkarnation eine andere Peer angelegt wurde). - // Deswegen also der Aufwand mit dem PeerCreationLevel, das stellt sicher, dass wir die in dem - // tiefsten Level angelegte Peer wirklich verwenden, sie aber erst im top-level - // initialisieren. + // consider the following ugly scenario: updateFromModel leads to a propertiesChanges on the Control, + // which determines, dat a "critical" property has changed (e.g. "Border") and therefore starts a new + // Peer, which lands again here in createPeerm we also start a second FmXGridPeer and initialise it. + // Then we exit from the first incarnation's updateFromModel and continue working with the pPeer, + // that is in fact now already obsolete (as another peer is being started in the second incarnation). + // Therefore the effort with the PeerCreationLevel, which ensures that we really use the Peer + // created at the deepest level, but first initialise it in the top-level. // if (--m_nPeerCreationLevel == 0) { DBG_ASSERT(getPeer().is(), "FmXGridControl::createPeer : something went wrong ... no top level peer !"); @@ -601,9 +599,9 @@ void SAL_CALL FmXGridControl::createPeer(const Reference< ::com::sun::star::awt: // forward the design mode sal_Bool bForceAlivePeer = m_bInDraw && !maComponentInfos.bVisible; - // (we force a alive-mode peer if we're in "draw", cause in this case the peer will be used for drawing in - // foreign devices. We ensure this with the visibility check as an living peer is assumed to be noncritical - // only if invisible) + // (we force an alive-mode peer if we're in "draw", cause in this case the peer will be used for drawing in + // foreign devices. We ensure this with the visibility check as an living peer is assumed to be noncritical + // only if invisible) Any aOldCursorBookmark; if (!mbDesignMode || bForceAlivePeer) { @@ -1145,7 +1143,7 @@ FmXGridPeer::FmXGridPeer(const Reference< XMultiServiceFactory >& _rxFactory) ,m_pGridListener(NULL) ,m_xServiceFactory(_rxFactory) { - // nach diesem Constructor muss Create gerufen werden ! + // Create must be called after this constructure m_pGridListener = new GridListenerDelegator( this ); } @@ -1167,7 +1165,7 @@ void FmXGridPeer::Create(Window* pParent, WinBits nStyle) // want to hear about row selections pWin->setGridListener( m_pGridListener ); - // Init mu immer aufgerufen werden + // Init must always be called pWin->Init(); pWin->SetComponentInterface(this); @@ -1392,7 +1390,7 @@ Sequence< Any > SAL_CALL FmXGridPeer::queryFieldData( sal_Int32 nRow, const Type DbGridRowRef xPaintRow = pGrid->GetPaintRow(); ENSURE_OR_THROW( xPaintRow.Is(), "invalid paint row" ); - // die Columns des Controls brauche ich fuer GetFieldText + // I need the columns of the control for GetFieldText DbGridColumns aColumns = pGrid->GetColumns(); // und durch alle Spalten durch @@ -1428,14 +1426,14 @@ Sequence< Any > SAL_CALL FmXGridPeer::queryFieldData( sal_Int32 nRow, const Type { switch (xType.getTypeClass()) { - // Strings werden direkt ueber das GetFieldText abgehandelt + // Strings are dealt with directly by the GetFieldText case TypeClass_STRING : { String sText = aColumns[ nModelPos ]->GetCellText( xPaintRow, pGrid->getNumberFormatter() ); pReturnArray[i] <<= ::rtl::OUString(sText); } break; - // alles andere wird an der DatabaseVariant erfragt + // everything else is requested in the DatabaseVariant case TypeClass_FLOAT : pReturnArray[i] <<= xFieldContent->getFloat(); break; case TypeClass_DOUBLE : pReturnArray[i] <<= xFieldContent->getDouble(); break; case TypeClass_SHORT : pReturnArray[i] <<= (sal_Int16)xFieldContent->getShort(); break; @@ -1474,13 +1472,13 @@ void FmXGridPeer::propertyChange(const PropertyChangeEvent& evt) throw( RuntimeE if (!pGrid) return; - // DatenbankEvent + // Database event Reference< XRowSet > xCursor(evt.Source, UNO_QUERY); if (evt.PropertyName == FM_PROP_VALUE || m_xCursor == evt.Source) pGrid->propertyChange(evt); else if (pGrid && m_xColumns.is() && m_xColumns->hasElements()) { - // zunaechst raussuchen welche Column sich geaendert hat + // next find which column has changed ::comphelper::InterfaceRef xCurrent; sal_Int32 i; @@ -2085,8 +2083,8 @@ void FmXGridPeer::setProperty( const ::rtl::OUString& PropertyName, const Any& V sal_Bool bValue( sal_True ); OSL_VERIFY( Value >>= bValue ); - // Im DesignModus nur das Datenfenster disablen - // Sonst kann das Control nicht mehr konfiguriert werden + // In design mode, disable only the data window. + // Else the control cannot be configured anymore. if (isDesignMode()) pGrid->GetDataWindow().Enable( bValue ); else @@ -2231,7 +2229,7 @@ void FmXGridPeer::startCursorListening() if (xReset.is()) xReset->addResetListener(this); - // alle Listener anmelden + // register all listeners Reference< XPropertySet > xSet(m_xCursor, UNO_QUERY); if (xSet.is()) { @@ -2284,7 +2282,7 @@ void FmXGridPeer::setRowSet(const Reference< XRowSet >& _rDatabaseCursor) throw( FmGridControl* pGrid = (FmGridControl*) GetWindow(); if (!pGrid || !m_xColumns.is() || !m_xColumns->getCount()) return; - // alle Listener abmelden + // unregister all listeners if (m_xCursor.is()) { Reference< XLoadable > xLoadable(m_xCursor, UNO_QUERY); @@ -2370,14 +2368,15 @@ void FmXGridPeer::selectionChanged(const EventObject& evt) throw( RuntimeExcepti break; } } - // fuer das VCL-Control muessen die Columns 1-basiert sein - // die Selektion an das VCL-Control weiterreichen, wenn noetig + // The columns have to be 1-based for the VCL control. + // If necessary, pass on the selection to the VCL control if ( i != pGrid->GetSelectedColumn() ) { // (wenn das nicht greift, wurde das selectionChanged implizit von dem Control selber ausgeloest + // if this does not ?hold?catch?, the selectionChanged is cleared by the Control itself if ( i < nColCount ) { pGrid->SelectColumnPos(pGrid->GetViewColumnPos(pGrid->GetColumnIdFromModelPos( (sal_uInt16)i )) + 1, sal_True); - // SelectColumnPos hat wieder zu einem impliziten ActivateCell gefuehrt + // SelectColumnPos has led to an implicit ActivateCell again if (pGrid->IsEditing()) pGrid->DeactivateCell(); } @@ -2551,8 +2550,8 @@ Reference< ::com::sun::star::frame::XDispatch > FmXGridPeer::queryDispatch(cons if (m_xFirstDispatchInterceptor.is() && !m_bInterceptingDispatch) { m_bInterceptingDispatch = sal_True; - // safety against recursion : as we are master of the first chain element and slave of the last one we would - // have an infinite loop without this if no dispatcher can fullfill the rewuest) + // safety against recursion : as we are master of the first chain element and slave of the last one we would + // have an infinite loop without this if no dispatcher can fullfill the request xResult = m_xFirstDispatchInterceptor->queryDispatch(aURL, aTargetFrameName, nSearchFlags); m_bInterceptingDispatch = sal_False; } -- cgit From 812aff65ad0661fed9687a429c763dc8f2144a0c Mon Sep 17 00:00:00 2001 From: Arnaud Versini Date: Tue, 25 Oct 2011 19:49:34 +0200 Subject: Fix fdo#41245 : Auto fit text VIEWING too small in PPT --- filter/source/msfilter/svdfppt.cxx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx index bb1e8b3fb650..fc987b8d123c 100644 --- a/filter/source/msfilter/svdfppt.cxx +++ b/filter/source/msfilter/svdfppt.cxx @@ -1073,12 +1073,10 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, voi } pTObj->SetMergedItem( SvxFrameDirectionItem( bVerticalText ? FRMDIR_VERT_TOP_RIGHT : FRMDIR_HORI_LEFT_TOP, EE_PARA_WRITINGDIR ) ); - if (bAutoFit) + //Autofit text only if there is no auto grow height and width + //See fdo#41245 + if (bAutoFit && !bAutoGrowHeight && !bAutoGrowWidth) { - // disable both, defeats purpose of autofit - // otherwise - bAutoGrowHeight = sal_False; - bAutoGrowWidth = sal_False; pTObj->SetMergedItem( SdrTextFitToSizeTypeItem(SDRTEXTFIT_AUTOFIT) ); } -- cgit From bc58a79f825bd7b8a8eabe728b783ce2c62d0805 Mon Sep 17 00:00:00 2001 From: Andras Timar Date: Tue, 1 Nov 2011 09:54:43 +0100 Subject: typo fix in UI --- filter/source/xsltdialog/xmlfiltertabpagexslt.src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filter/source/xsltdialog/xmlfiltertabpagexslt.src b/filter/source/xsltdialog/xmlfiltertabpagexslt.src index e86111265008..d82bb30cd771 100644 --- a/filter/source/xsltdialog/xmlfiltertabpagexslt.src +++ b/filter/source/xsltdialog/xmlfiltertabpagexslt.src @@ -179,7 +179,7 @@ TabPage RID_XML_FILTER_TABPAGE_XSLT { Pos = MAP_APPFONT ( FIRST_ROW_X , FIRST_ROW_Y + 5 * ROW_HEIGHT + 5 * SPACING + FIXED_TEXT_OFFSET + EDIT_OFFSET ) ; Size = MAP_APPFONT ( FIRST_ROW_WIDTH , 8 ) ; - Text [ en-US ] = "XSLT Tranformation Service"; + Text [ en-US ] = "XSLT Transformation Service"; }; Edit ED_XML_TRANSFORM_SERVICE -- cgit From 3acbdb2dee458cba6904a636733f1777b47e9fc1 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Tue, 1 Nov 2011 10:07:44 +0100 Subject: let PgUp/Down go to the first/last line --- svtools/source/control/valueset.cxx | 54 ++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx index 5834f59f722f..a3d38f03eca4 100644 --- a/svtools/source/control/valueset.cxx +++ b/svtools/source/control/valueset.cxx @@ -1318,6 +1318,20 @@ void ValueSet::Tracking( const TrackingEvent& rTEvt ) // ----------------------------------------------------------------------- +namespace +{ + +size_t +lcl_gotoLastLine(size_t const nLastPos, size_t const nCols, size_t const nCurPos) +{ + size_t nItemPos = ((((nLastPos+1)/nCols)-1)*nCols)+(nCurPos%nCols); + if ( nItemPos+nCols <= nLastPos ) + nItemPos = nItemPos + nCols; + return nItemPos; +} + +} + void ValueSet::KeyInput( const KeyEvent& rKEvt ) { size_t nLastItem = mpImpl->mpItemList->size(); @@ -1419,16 +1433,18 @@ void ValueSet::KeyInput( const KeyEvent& rKEvt ) if ( nLastItem+1 <= mnCols ) nItemPos = mnCurCol; else - { - nItemPos = ((((nLastItem+1)/mnCols)-1)*mnCols)+(mnCurCol%mnCols); - if ( nItemPos+mnCols <= nLastItem ) - nItemPos = nItemPos + mnCols; - } + nItemPos = lcl_gotoLastLine(nLastItem, mnCols, mnCurCol); } - else if ( nCalcPos >= ( nLineCount * mnCols ) ) - nItemPos = sal::static_int_cast< sal_uInt16 >( - nCalcPos - ( nLineCount * mnCols )); - else + else if ( nCalcPos >= mnCols ) // we can go up + { + if ( nCalcPos >= ( nLineCount * mnCols ) ) + nItemPos = sal::static_int_cast< sal_uInt16 >( + nCalcPos - ( nLineCount * mnCols )); + else + // Go to the first line. This can only happen for KEY_PAGEUP + nItemPos = nCalcPos % mnCols; + } + else // wrap around { if ( mpNoneItem ) { @@ -1440,11 +1456,7 @@ void ValueSet::KeyInput( const KeyEvent& rKEvt ) if ( nLastItem+1 <= mnCols ) nItemPos = nCalcPos; else - { - nItemPos = ((((nLastItem+1)/mnCols)-1)*mnCols)+(nCalcPos%mnCols); - if ( nItemPos+mnCols <= nLastItem ) - nItemPos = nItemPos + mnCols; - } + nItemPos = lcl_gotoLastLine(nLastItem, mnCols, nCalcPos); } } nCalcPos = nItemPos; @@ -1467,10 +1479,16 @@ void ValueSet::KeyInput( const KeyEvent& rKEvt ) { if ( nCalcPos == VALUESET_ITEM_NONEITEM ) nItemPos = mnCurCol; - else if ( nCalcPos + ( nLineCount * mnCols ) <= nLastItem ) - nItemPos = sal::static_int_cast< sal_uInt16 >( - nCalcPos + ( nLineCount * mnCols )); - else + else if ( nCalcPos + mnCols <= nLastItem ) // we can go down + { + if ( nCalcPos + ( nLineCount * mnCols ) <= nLastItem ) + nItemPos = sal::static_int_cast< sal_uInt16 >( + nCalcPos + ( nLineCount * mnCols )); + else + // Go to the last line. This can only happen for KEY_PAGEDOWN + nItemPos = lcl_gotoLastLine(nLastItem, mnCols, nCalcPos); + } + else // wrap around { { if ( mpNoneItem ) -- cgit From 77090e4e2515aefe547618487cdc96fde567e595 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Tue, 1 Nov 2011 10:10:03 +0100 Subject: remove superfluous casts --- svtools/source/control/valueset.cxx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx index a3d38f03eca4..1a75dd2a4492 100644 --- a/svtools/source/control/valueset.cxx +++ b/svtools/source/control/valueset.cxx @@ -1438,8 +1438,7 @@ void ValueSet::KeyInput( const KeyEvent& rKEvt ) else if ( nCalcPos >= mnCols ) // we can go up { if ( nCalcPos >= ( nLineCount * mnCols ) ) - nItemPos = sal::static_int_cast< sal_uInt16 >( - nCalcPos - ( nLineCount * mnCols )); + nItemPos = nCalcPos - ( nLineCount * mnCols ); else // Go to the first line. This can only happen for KEY_PAGEUP nItemPos = nCalcPos % mnCols; @@ -1482,8 +1481,7 @@ void ValueSet::KeyInput( const KeyEvent& rKEvt ) else if ( nCalcPos + mnCols <= nLastItem ) // we can go down { if ( nCalcPos + ( nLineCount * mnCols ) <= nLastItem ) - nItemPos = sal::static_int_cast< sal_uInt16 >( - nCalcPos + ( nLineCount * mnCols )); + nItemPos = nCalcPos + ( nLineCount * mnCols ); else // Go to the last line. This can only happen for KEY_PAGEDOWN nItemPos = lcl_gotoLastLine(nLastItem, mnCols, nCalcPos); -- cgit From e2e684a49a8651ccc38a83e7d05ac756c6c4c2ed Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 28 Oct 2011 21:44:12 +0100 Subject: ByteString->rtl::OString --- reportdesign/source/ui/dlg/Formula.cxx | 2 +- sfx2/source/dialog/basedlgs.cxx | 2 +- sfx2/source/dialog/tabdlg.cxx | 2 +- sw/inc/swabstdlg.hxx | 8 ++++---- sw/inc/swtypes.hxx | 1 - sw/source/ui/config/optpage.cxx | 2 +- sw/source/ui/dbui/dbinsdlg.cxx | 2 +- sw/source/ui/dialog/swdlgfact.cxx | 8 ++++---- sw/source/ui/dialog/swdlgfact.hxx | 8 ++++---- sw/source/ui/inc/wrtsh.hxx | 4 ++-- sw/source/ui/index/cntex.cxx | 2 +- sw/source/ui/wrtsh/wrtsh2.cxx | 10 +++++----- 12 files changed, 25 insertions(+), 26 deletions(-) diff --git a/reportdesign/source/ui/dlg/Formula.cxx b/reportdesign/source/ui/dlg/Formula.cxx index 5092c43265c2..7a1c929873cd 100644 --- a/reportdesign/source/ui/dlg/Formula.cxx +++ b/reportdesign/source/ui/dlg/Formula.cxx @@ -215,7 +215,7 @@ void FormulaDialog::ToggleCollapsed( RefEdit* _pEdit, RefButton* _pButton) SvtViewOptions aDlgOpt( E_WINDOW, String::CreateFromAscii( HID_RPT_FIELD_SEL_WIN ) ); if ( aDlgOpt.Exists() ) { - m_pAddField->SetWindowState( ByteString( aDlgOpt.GetWindowState().getStr(), RTL_TEXTENCODING_ASCII_US ) ); + m_pAddField->SetWindowState(::rtl::OUStringToOString(aDlgOpt.GetWindowState().getStr(), RTL_TEXTENCODING_ASCII_US)); } diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx index e1d90733c480..84e9a8a6d1a0 100644 --- a/sfx2/source/dialog/basedlgs.cxx +++ b/sfx2/source/dialog/basedlgs.cxx @@ -148,7 +148,7 @@ void SfxModalDialog::GetDialogData_Impl() if ( aDlgOpt.Exists() ) { // load settings - SetWindowState( ByteString( aDlgOpt.GetWindowState().getStr(), RTL_TEXTENCODING_ASCII_US ) ); + SetWindowState( rtl::OUStringToOString( aDlgOpt.GetWindowState().getStr(), RTL_TEXTENCODING_ASCII_US ) ); Any aUserItem = aDlgOpt.GetUserItem( USERITEM_NAME ); OUString aTemp; if ( aUserItem >>= aTemp ) diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx index 57e60136b617..cb1f2d8fa1d8 100644 --- a/sfx2/source/dialog/tabdlg.cxx +++ b/sfx2/source/dialog/tabdlg.cxx @@ -738,7 +738,7 @@ void SfxTabDialog::Start_Impl() if ( aDlgOpt.Exists() ) { #if !ENABLE_LAYOUT_SFX_TABDIALOG - SetWindowState( ByteString( aDlgOpt.GetWindowState().getStr(), RTL_TEXTENCODING_ASCII_US ) ); + SetWindowState(rtl::OUStringToOString(aDlgOpt.GetWindowState().getStr(), RTL_TEXTENCODING_ASCII_US)); #endif /* !ENABLE_LAYOUT_SFX_TABDIALOG */ // initial TabPage from Program/Help/config diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx index b92816993740..9a685db6b506 100644 --- a/sw/inc/swabstdlg.hxx +++ b/sw/inc/swabstdlg.hxx @@ -114,8 +114,8 @@ class AbstractFldInputDlg : public VclAbstractDialog //add for SwFldInputDlg { public: //from class SalFrame - virtual void SetWindowState( const ByteString& rStr ) = 0; - virtual ByteString GetWindowState( sal_uLong nMask = WINDOWSTATE_MASK_ALL ) const = 0; + virtual void SetWindowState( const rtl::OString & rStr ) = 0; + virtual rtl::OString GetWindowState( sal_uLong nMask = WINDOWSTATE_MASK_ALL ) const = 0; }; class AbstractInsFootNoteDlg : public VclAbstractDialog //add for SwInsFootNoteDlg @@ -256,8 +256,8 @@ public: class AbstractDropDownFieldDialog : public VclAbstractDialog //add for DropDownFieldDialog { public: - virtual ByteString GetWindowState( sal_uLong nMask = WINDOWSTATE_MASK_ALL ) const = 0; //this method inherit from SystemWindow - virtual void SetWindowState( const ByteString& rStr ) =0;//this method inherit from SystemWindow + virtual rtl::OString GetWindowState( sal_uLong nMask = WINDOWSTATE_MASK_ALL ) const = 0; //this method inherit from SystemWindow + virtual void SetWindowState( const rtl::OString & rStr ) =0;//this method inherit from SystemWindow }; class AbstractSwLabDlg : public SfxAbstractTabDialog //add for SwLabDlg diff --git a/sw/inc/swtypes.hxx b/sw/inc/swtypes.hxx index ca036da3a048..2b1ee116b6fb 100644 --- a/sw/inc/swtypes.hxx +++ b/sw/inc/swtypes.hxx @@ -57,7 +57,6 @@ namespace utl{ class Size; class ResMgr; class UniString; -class ByteString; class SwPathFinder; class Graphic; class OutputDevice; diff --git a/sw/source/ui/config/optpage.cxx b/sw/source/ui/config/optpage.cxx index e9b21008762d..8c352243fdd3 100644 --- a/sw/source/ui/config/optpage.cxx +++ b/sw/source/ui/config/optpage.cxx @@ -1775,7 +1775,7 @@ SwTestTabPage::SwTestTabPage( Window* pParent, lcl_SetPosSize(aTest9CBox , Point(116, 53), Size(74 , 10)); lcl_SetPosSize(aTest10CBox , Point(116, 66), Size(74 , 10)); - aTestFL.SetText( String(ByteString("Einstellungen nur f\xFCr Testzwecke" ), RTL_TEXTENCODING_MS_1252)); + aTestFL.SetText(rtl::OUString(RTL_CONSTASCII_STRINGPARAM("Settings only for testpurposes", RTL_TEXTENCODING_ASCII_US)); aTest1CBox .SetText( C2S("unused")); aTest2CBox .SetText( C2S("dynamic")); aTest3CBox .SetText( C2S("No calm" )); diff --git a/sw/source/ui/dbui/dbinsdlg.cxx b/sw/source/ui/dbui/dbinsdlg.cxx index e059ab1114f6..4dc1204d6119 100644 --- a/sw/source/ui/dbui/dbinsdlg.cxx +++ b/sw/source/ui/dbui/dbinsdlg.cxx @@ -1179,7 +1179,7 @@ void SwInsertDBColAutoPilot::DataToDoc( const Sequence& rSelection, catch (const Exception& rExcept) { #if OSL_DEBUG_LEVEL > 1 - OSL_FAIL(ByteString(String(rExcept.Message), gsl_getSystemTextEncoding()).GetBuffer()); + OSL_FAIL(rtl::OUStringToOString(rExcept.Message, osl_getThreadTextEncoding()).getStr()); #else (void)rExcept; #endif diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx index 1b5f9adc1dfe..03b5b0c3978a 100644 --- a/sw/source/ui/dialog/swdlgfact.cxx +++ b/sw/source/ui/dialog/swdlgfact.cxx @@ -244,12 +244,12 @@ void AbstractSwInsertDBColAutoPilot_Impl::DataToDoc( const uno::Sequence< uno::A pDlg->DataToDoc(rSelection, rxSource, xConnection, xResultSet); } -ByteString AbstractDropDownFieldDialog_Impl::GetWindowState( sal_uLong nMask ) const +rtl::OString AbstractDropDownFieldDialog_Impl::GetWindowState( sal_uLong nMask ) const { return pDlg->GetWindowState(nMask); } -void AbstractDropDownFieldDialog_Impl::SetWindowState( const ByteString& rStr ) +void AbstractDropDownFieldDialog_Impl::SetWindowState( const rtl::OString& rStr ) { pDlg->SetWindowState(rStr); } @@ -400,12 +400,12 @@ String AbstractGlossaryDlg_Impl::GetCurrShortName() const return pDlg->GetCurrShortName(); } -void AbstractFldInputDlg_Impl::SetWindowState( const ByteString& rStr ) +void AbstractFldInputDlg_Impl::SetWindowState( const rtl::OString& rStr ) { pDlg->SetWindowState( rStr ); } -ByteString AbstractFldInputDlg_Impl::GetWindowState( sal_uLong nMask ) const +rtl::OString AbstractFldInputDlg_Impl::GetWindowState( sal_uLong nMask ) const { return pDlg->GetWindowState( nMask ); } diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx index e13ccfd7e84e..b4ee0910b7e8 100644 --- a/sw/source/ui/dialog/swdlgfact.hxx +++ b/sw/source/ui/dialog/swdlgfact.hxx @@ -175,8 +175,8 @@ class AbstractSwInsertDBColAutoPilot_Impl : public AbstractSwInsertDBColAutoPil class AbstractDropDownFieldDialog_Impl : public AbstractDropDownFieldDialog //add for DropDownFieldDialog { DECL_ABSTDLG_BASE(AbstractDropDownFieldDialog_Impl, sw::DropDownFieldDialog) - virtual ByteString GetWindowState( sal_uLong nMask = WINDOWSTATE_MASK_ALL ) const; //this method inherit from SystemWindow - virtual void SetWindowState( const ByteString& rStr );//this method inherit from SystemWindow + virtual rtl::OString GetWindowState( sal_uLong nMask = WINDOWSTATE_MASK_ALL ) const; //this method inherit from SystemWindow + virtual void SetWindowState( const rtl::OString& rStr );//this method inherit from SystemWindow }; //add for DropDownFieldDialog end @@ -269,8 +269,8 @@ class AbstractFldInputDlg_Impl : public AbstractFldInputDlg { DECL_ABSTDLG_BASE(AbstractFldInputDlg_Impl,SwFldInputDlg) //from class SalFrame - virtual void SetWindowState( const ByteString& rStr ) ; - virtual ByteString GetWindowState( sal_uLong nMask = WINDOWSTATE_MASK_ALL ) const ; + virtual void SetWindowState( const rtl::OString & rStr ) ; + virtual rtl::OString GetWindowState( sal_uLong nMask = WINDOWSTATE_MASK_ALL ) const ; }; //for SwFldInputDlg end diff --git a/sw/source/ui/inc/wrtsh.hxx b/sw/source/ui/inc/wrtsh.hxx index 3a71ca85ef84..9d6c0a97d5e0 100644 --- a/sw/source/ui/inc/wrtsh.hxx +++ b/sw/source/ui/inc/wrtsh.hxx @@ -400,9 +400,9 @@ typedef sal_Bool (SwWrtShell:: *FNSimpleMove)(); void MoveCrsr( sal_Bool bWithSelect = sal_False ); // update input fields - sal_Bool StartInputFldDlg(SwField*, sal_Bool bNextButton, Window* pParentWin = 0, ByteString* pWindowState = 0); + sal_Bool StartInputFldDlg(SwField*, sal_Bool bNextButton, Window* pParentWin = 0, rtl::OString* pWindowState = 0); // update DropDown fields - sal_Bool StartDropDownFldDlg(SwField*, sal_Bool bNextButton, ByteString* pWindowState = 0); + sal_Bool StartDropDownFldDlg(SwField*, sal_Bool bNextButton, rtl::OString* pWindowState = 0); //"Handler" for changes at DrawView - for controls. virtual void DrawSelChanged( ); diff --git a/sw/source/ui/index/cntex.cxx b/sw/source/ui/index/cntex.cxx index 4ffc8f7af846..b5c595b31d5e 100644 --- a/sw/source/ui/index/cntex.cxx +++ b/sw/source/ui/index/cntex.cxx @@ -463,7 +463,7 @@ void SwMultiTOXTabDialog::CreateOrUpdateExample( sPropName += String::CreateFromInt32( i ); lcl_SetProp(xInfo, xIdxProps, - ByteString(sPropName, RTL_TEXTENCODING_ASCII_US).GetBuffer(), + rtl::OUStringToOString(sPropName, RTL_TEXTENCODING_ASCII_US).getStr(), pForm->GetTemplate(i + nOffset)); } } diff --git a/sw/source/ui/wrtsh/wrtsh2.cxx b/sw/source/ui/wrtsh/wrtsh2.cxx index 172500cd3fd0..9d3118277cb4 100644 --- a/sw/source/ui/wrtsh/wrtsh2.cxx +++ b/sw/source/ui/wrtsh/wrtsh2.cxx @@ -119,7 +119,7 @@ void SwWrtShell::UpdateInputFlds( SwInputFieldList* pLst, sal_Bool bOnlyInSel ) pTmp->PushCrsr(); sal_Bool bCancel = sal_False; - ByteString aDlgPos; + rtl::OString aDlgPos; for( sal_uInt16 i = 0; i < nCnt && !bCancel; ++i ) { pTmp->GotoFieldPos( i ); @@ -147,7 +147,7 @@ void SwWrtShell::UpdateInputFlds( SwInputFieldList* pLst, sal_Bool bOnlyInSel ) sal_Bool SwWrtShell::StartInputFldDlg( SwField* pFld, sal_Bool bNextButton, - Window* pParentWin, ByteString* pWindowState ) + Window* pParentWin, rtl::OString* pWindowState ) { SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); @@ -155,7 +155,7 @@ sal_Bool SwWrtShell::StartInputFldDlg( SwField* pFld, sal_Bool bNextButton, AbstractFldInputDlg* pDlg = pFact->CreateFldInputDlg( DLG_FLD_INPUT, pParentWin, *this, pFld, bNextButton); OSL_ENSURE(pDlg, "Dialogdiet fail!"); - if(pWindowState && pWindowState->Len()) + if(pWindowState && pWindowState->getLength()) pDlg->SetWindowState(*pWindowState); sal_Bool bRet = RET_CANCEL == pDlg->Execute(); if(pWindowState) @@ -166,14 +166,14 @@ sal_Bool SwWrtShell::StartInputFldDlg( SwField* pFld, sal_Bool bNextButton, return bRet; } -sal_Bool SwWrtShell::StartDropDownFldDlg(SwField* pFld, sal_Bool bNextButton, ByteString* pWindowState) +sal_Bool SwWrtShell::StartDropDownFldDlg(SwField* pFld, sal_Bool bNextButton, rtl::OString* pWindowState) { SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!"); AbstractDropDownFieldDialog* pDlg = pFact->CreateDropDownFieldDialog( NULL, *this, pFld, DLG_FLD_DROPDOWN ,bNextButton ); OSL_ENSURE(pDlg, "Dialogdiet fail!"); - if(pWindowState && pWindowState->Len()) + if(pWindowState && pWindowState->getLength()) pDlg->SetWindowState(*pWindowState); sal_uInt16 nRet = pDlg->Execute(); if(pWindowState) -- cgit From 9dc14818d588c13d7cea9814c8227a438c7a30de Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 28 Oct 2011 22:04:16 +0100 Subject: callcatcher: various unused methods --- svx/inc/svx/svdcrtv.hxx | 1 - svx/inc/svx/svdedxv.hxx | 12 -------- svx/inc/svx/svdetc.hxx | 6 ---- svx/inc/svx/svdxcgv.hxx | 9 ------ svx/source/svdraw/svdcrtv.cxx | 4 --- svx/source/svdraw/svdedxv.cxx | 69 ------------------------------------------- svx/source/svdraw/svdetc.cxx | 11 ------- svx/source/svdraw/svdxcgv.cxx | 47 ----------------------------- unusedcode.easy | 10 ------- 9 files changed, 169 deletions(-) diff --git a/svx/inc/svx/svdcrtv.hxx b/svx/inc/svx/svdcrtv.hxx index 3e2993bdfe76..b72b0bea259a 100644 --- a/svx/inc/svx/svdcrtv.hxx +++ b/svx/inc/svx/svdcrtv.hxx @@ -87,7 +87,6 @@ protected: private: SVX_DLLPRIVATE void ImpClearVars(); SVX_DLLPRIVATE void ImpMakeCreateAttr(); - SVX_DLLPRIVATE void ImpDelCreateAttr(); protected: sal_Bool ImpBegCreateObj(sal_uInt32 nInvent, sal_uInt16 nIdent, const Point& rPnt, OutputDevice* pOut, diff --git a/svx/inc/svx/svdedxv.hxx b/svx/inc/svx/svdedxv.hxx index 742473fc1d8b..a383a3723b87 100644 --- a/svx/inc/svx/svdedxv.hxx +++ b/svx/inc/svx/svdedxv.hxx @@ -195,11 +195,6 @@ public: virtual SdrEndTextEditKind SdrEndTextEdit(sal_Bool bDontDeleteReally = sal_False); virtual bool IsTextEdit() const; - // sal_True=Es wird ein Textrahmen (OBJ_TEXT,OBJ_OUTLINETEXT,...) editiert - // ansonsten handelt es sich um ein beschriftetes Zeichenobjekt, an dem - // der Text ja bekanntlich hor. und vert. zentriert wird. - sal_Bool IsTextEditFrame() const; - // Diese Methode liefert sal_True, wenn der Punkt rHit innerhalb der // des Objektbereichs oder der OutlinerView liegt. sal_Bool IsTextEditHit(const Point& rHit, short nTol) const; @@ -213,10 +208,6 @@ public: // MouseButtonUp liefert diese Methode immer TRUE. sal_Bool IsTextEditInSelectionMode() const; - // Folgende Methode addiert einen passenden Offset zum MouseEvent - // um diesen an den Outliner weiterzureichen. - void AddTextEditOfs(MouseEvent& rMEvt) const; - // Wer das z.Zt. im TextEdit befindliche Objekt braucht: SdrObject* GetTextEditObject() const { return mxTextEditObj.get(); } @@ -240,9 +231,6 @@ public: virtual sal_Bool MouseButtonUp(const MouseEvent& rMEvt, Window* pWin); virtual sal_Bool MouseMove(const MouseEvent& rMEvt, Window* pWin); virtual sal_Bool Command(const CommandEvent& rCEvt, Window* pWin); - sal_Bool Cut(sal_uIntPtr nFormat=SDR_ANYFORMAT); - sal_Bool Yank(sal_uIntPtr nFormat=SDR_ANYFORMAT); - sal_Bool Paste(Window* pWin=NULL, sal_uIntPtr nFormat=SDR_ANYFORMAT); // #97766# make virtual to change implementation e.g. for SdOutlineView virtual sal_uInt16 GetScriptType() const; diff --git a/svx/inc/svx/svdetc.hxx b/svx/inc/svx/svdetc.hxx index da0d1407f121..9100b5bf9911 100644 --- a/svx/inc/svx/svdetc.hxx +++ b/svx/inc/svx/svdetc.hxx @@ -106,12 +106,6 @@ public: // Default MapFraction ist 1/1. static void SetMapFraction(const Fraction& rMap) { GetDefaults().aMapFraction=rMap; } static Fraction GetMapFraction() { return GetDefaults().aMapFraction; } - // Der Aufruf der folgenden Methode veranlasst die Engine - // ihre sprachabhaengigen Resourcen neu zu initiallisieren. - // Bereits bestehende Undotexte, etc. bleiben jedoch in der - // sprache erhalten, in der sie erzeugt wurden. - static void LanguageHasChanged(); - // Einen Outliner mit den engineglobalen // Defaulteinstellungen auf dem Heap erzeugen. diff --git a/svx/inc/svx/svdxcgv.hxx b/svx/inc/svx/svdxcgv.hxx index f76d5c9ef7c0..90074daf29b5 100644 --- a/svx/inc/svx/svdxcgv.hxx +++ b/svx/inc/svx/svdxcgv.hxx @@ -57,7 +57,6 @@ protected: void ImpGetPasteObjList(Point& rPos, SdrObjList*& rpLst); void ImpPasteObject(SdrObject* pObj, SdrObjList& rLst, const Point& rCenter, const Size& rSiz, const MapMode& rMap, sal_uInt32 nOptions); sal_Bool ImpGetPasteLayer(const SdrObjList* pObjList, SdrLayerID& rLayer) const; - Point GetPastePos(SdrObjList* pLst, OutputDevice* pOut=NULL); // liefert True, wenn rPt geaendert wurde sal_Bool ImpLimitToWorkArea(Point& rPt) const; @@ -132,16 +131,8 @@ public: // View angezeigt wird. // Gueltige Werte fuer nOptions sind SDRINSERT_DONTMARK und // SDRINSERT_ADDMARK (siehe svdedtv.hxx). - sal_Bool Paste(const GDIMetaFile& rMtf, SdrObjList* pLst=NULL, OutputDevice* pOut=NULL, sal_uInt32 nOptions=0) { return Paste(rMtf,GetPastePos(pLst,pOut),pLst,nOptions); } - sal_Bool Paste(const GDIMetaFile& rMtf, const Point& rPos, SdrObjList* pLst=NULL, sal_uInt32 nOptions=0); - sal_Bool Paste(const Bitmap& rBmp, SdrObjList* pLst=NULL, OutputDevice* pOut=NULL, sal_uInt32 nOptions=0) { return Paste(rBmp,GetPastePos(pLst,pOut),pLst,nOptions); } - sal_Bool Paste(const Bitmap& rBmp, const Point& rPos, SdrObjList* pLst=NULL, sal_uInt32 nOptions=0); - sal_Bool Paste(const SdrModel& rMod, SdrObjList* pLst=NULL, OutputDevice* pOut=NULL, sal_uInt32 nOptions=0) { return Paste(rMod,GetPastePos(pLst,pOut),pLst,nOptions); } virtual sal_Bool Paste(const SdrModel& rMod, const Point& rPos, SdrObjList* pLst=NULL, sal_uInt32 nOptions=0); - sal_Bool Paste(const String& rStr, SdrObjList* pLst=NULL, OutputDevice* pOut=NULL, sal_uInt32 nOptions=0) { return Paste(rStr,GetPastePos(pLst,pOut),pLst,nOptions); } sal_Bool Paste(const String& rStr, const Point& rPos, SdrObjList* pLst=NULL, sal_uInt32 nOptions=0); - // der sal_uInt16 eFormat nimmt Werte des enum EETextFormat entgegen - sal_Bool Paste(SvStream& rInput, const String& rBaseURL, sal_uInt16 eFormat, SdrObjList* pLst=NULL, OutputDevice* pOut=NULL, sal_uInt32 nOptions=0) { return Paste(rInput,rBaseURL,eFormat,GetPastePos(pLst,pOut),pLst,nOptions); } sal_Bool Paste(SvStream& rInput, const String& rBaseURL, sal_uInt16 eFormat, const Point& rPos, SdrObjList* pLst=NULL, sal_uInt32 nOptions=0); sal_Bool Cut( sal_uIntPtr nFormat = SDR_ANYFORMAT ); diff --git a/svx/source/svdraw/svdcrtv.cxx b/svx/source/svdraw/svdcrtv.cxx index 8849ca59958b..54e80fbfe262 100644 --- a/svx/source/svdraw/svdcrtv.cxx +++ b/svx/source/svdraw/svdcrtv.cxx @@ -246,10 +246,6 @@ SdrCreateView::~SdrCreateView() SdrObject::Free( pAktCreate ); } -void SdrCreateView::ImpDelCreateAttr() -{ -} - sal_Bool SdrCreateView::IsAction() const { return SdrDragView::IsAction() || pAktCreate!=NULL; diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx index 18876c50a14d..d4464b6ccdbb 100644 --- a/svx/source/svdraw/svdedxv.cxx +++ b/svx/source/svdraw/svdedxv.cxx @@ -461,12 +461,6 @@ OutlinerView* SdrObjEditView::ImpMakeOutlinerView(Window* pWin, sal_Bool /*bNoPa return pOutlView; } -sal_Bool SdrObjEditView::IsTextEditFrame() const -{ - SdrTextObj* pText = dynamic_cast< SdrTextObj* >( mxTextEditObj.get() ); - return pText!=NULL && pText->IsTextFrame(); -} - IMPL_LINK(SdrObjEditView,ImpOutlinerStatusEventHdl,EditStatus*,pEditStat) { if(pTextEditOutliner ) @@ -1124,24 +1118,6 @@ sal_Bool SdrObjEditView::IsTextEditFrameHit(const Point& rHit) const return bOk; } -void SdrObjEditView::AddTextEditOfs(MouseEvent& rMEvt) const -{ - if(mxTextEditObj.is()) - { - Point aPvOfs; - SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mxTextEditObj.get() ); - - if( pTextObj ) - { - // #108784# - aPvOfs += pTextObj->GetTextEditOffset(); - } - - Point aObjOfs(mxTextEditObj->GetLogicRect().TopLeft()); - (Point&)(rMEvt.GetPosPixel())+=aPvOfs+aObjOfs; - } -} - //////////////////////////////////////////////////////////////////////////////////////////////////// sal_Bool SdrObjEditView::KeyInput(const KeyEvent& rKEvt, Window* pWin) @@ -1317,51 +1293,6 @@ sal_Bool SdrObjEditView::Command(const CommandEvent& rCEvt, Window* pWin) return SdrGlueEditView::Command(rCEvt,pWin); } -sal_Bool SdrObjEditView::Cut(sal_uIntPtr nFormat) -{ - if (pTextEditOutliner!=NULL) { - pTextEditOutlinerView->Cut(); -#ifdef DBG_UTIL - if (pItemBrowser!=NULL) pItemBrowser->SetDirty(); -#endif - ImpMakeTextCursorAreaVisible(); - return sal_True; - } else { - return SdrGlueEditView::Cut(nFormat); - } -} - -sal_Bool SdrObjEditView::Yank(sal_uIntPtr nFormat) -{ - if (pTextEditOutliner!=NULL) { - pTextEditOutlinerView->Copy(); - return sal_True; - } else { - return SdrGlueEditView::Yank(nFormat); - } -} - -sal_Bool SdrObjEditView::Paste(Window* pWin, sal_uIntPtr nFormat) -{ - if (pTextEditOutliner!=NULL) { - if (pWin!=NULL) { - OutlinerView* pNewView=ImpFindOutlinerView(pWin); - if (pNewView!=NULL) { - pNewView->Paste(); - } - } else { - pTextEditOutlinerView->Paste(); - } -#ifdef DBG_UTIL - if (pItemBrowser!=NULL) pItemBrowser->SetDirty(); -#endif - ImpMakeTextCursorAreaVisible(); - return sal_True; - } else { - return SdrGlueEditView::Paste(pWin,nFormat); - } -} - //////////////////////////////////////////////////////////////////////////////////////////////////// sal_Bool SdrObjEditView::ImpIsTextEditAllSelected() const diff --git a/svx/source/svdraw/svdetc.cxx b/svx/source/svdraw/svdetc.cxx index 453800ffac0d..d1fc85affb5a 100644 --- a/svx/source/svdraw/svdetc.cxx +++ b/svx/source/svdraw/svdetc.cxx @@ -487,17 +487,6 @@ SdrEngineDefaults& SdrEngineDefaults::GetDefaults() //////////////////////////////////////////////////////////////////////////////////////////////////// -void SdrEngineDefaults::LanguageHasChanged() -{ - SdrGlobalData& rGlobalData=GetSdrGlobalData(); - if (rGlobalData.pResMgr!=NULL) { - delete rGlobalData.pResMgr; - rGlobalData.pResMgr=NULL; - } -} - -//////////////////////////////////////////////////////////////////////////////////////////////////// - SdrOutliner* SdrMakeOutliner( sal_uInt16 nOutlinerMode, SdrModel* pModel ) { //SdrEngineDefaults& rDefaults = SdrEngineDefaults::GetDefaults(); diff --git a/svx/source/svdraw/svdxcgv.cxx b/svx/source/svdraw/svdxcgv.cxx index 13ea61e2217d..89b48c61ede0 100644 --- a/svx/source/svdraw/svdxcgv.cxx +++ b/svx/source/svdraw/svdxcgv.cxx @@ -92,19 +92,6 @@ Point SdrExchangeView::GetViewCenter(const OutputDevice* pOut) const return aCenter; } -Point SdrExchangeView::GetPastePos(SdrObjList* pLst, OutputDevice* pOut) -{ - Point aP(GetViewCenter(pOut)); - SdrPage* pPg=NULL; - if (pLst!=NULL) pPg=pLst->GetPage(); - if (pPg!=NULL) { - Size aSiz(pPg->GetSize()); - aP.X()=aSiz.Width()/2; - aP.Y()=aSiz.Height()/2; - } - return aP; -} - sal_Bool SdrExchangeView::ImpLimitToWorkArea(Point& rPt) const { sal_Bool bRet(sal_False); @@ -168,40 +155,6 @@ sal_Bool SdrExchangeView::ImpGetPasteLayer(const SdrObjList* pObjList, SdrLayerI return bRet; } -//////////////////////////////////////////////////////////////////////////////////////////////////// - -sal_Bool SdrExchangeView::Paste(const GDIMetaFile& rMtf, const Point& rPos, SdrObjList* pLst, sal_uInt32 nOptions) -{ - Point aPos(rPos); - ImpGetPasteObjList(aPos,pLst); - ImpLimitToWorkArea( aPos ); - if (pLst==NULL) return sal_False; - SdrLayerID nLayer; - if (!ImpGetPasteLayer(pLst,nLayer)) return sal_False; - sal_Bool bUnmark=(nOptions&(SDRINSERT_DONTMARK|SDRINSERT_ADDMARK))==0 && !IsTextEdit(); - if (bUnmark) UnmarkAllObj(); - SdrGrafObj* pObj=new SdrGrafObj(Graphic(rMtf)); - pObj->SetLayer(nLayer); - ImpPasteObject(pObj,*pLst,aPos,rMtf.GetPrefSize(),rMtf.GetPrefMapMode(),nOptions); - return sal_True; -} - -sal_Bool SdrExchangeView::Paste(const Bitmap& rBmp, const Point& rPos, SdrObjList* pLst, sal_uInt32 nOptions) -{ - Point aPos(rPos); - ImpGetPasteObjList(aPos,pLst); - ImpLimitToWorkArea( aPos ); - if (pLst==NULL) return sal_False; - SdrLayerID nLayer; - if (!ImpGetPasteLayer(pLst,nLayer)) return sal_False; - sal_Bool bUnmark=(nOptions&(SDRINSERT_DONTMARK|SDRINSERT_ADDMARK))==0 && !IsTextEdit(); - if (bUnmark) UnmarkAllObj(); - SdrGrafObj* pObj=new SdrGrafObj(Graphic(rBmp)); - pObj->SetLayer(nLayer); - ImpPasteObject(pObj,*pLst,aPos,rBmp.GetSizePixel(),MapMode(MAP_PIXEL),nOptions); - return sal_True; -} - sal_Bool SdrExchangeView::Paste(const XubString& rStr, const Point& rPos, SdrObjList* pLst, sal_uInt32 nOptions) { if(!rStr.Len()) diff --git a/unusedcode.easy b/unusedcode.easy index 319cb240807f..13cbb9d13217 100644 --- a/unusedcode.easy +++ b/unusedcode.easy @@ -571,16 +571,11 @@ ScrollableWindow::ScrollableWindow(Window*, ResId const&, unsigned short) ScrollableWindow::SetLineSize(unsigned long, unsigned long) ScrollableWindow::SetVisibleSize(Size const&) SdFilterDetect::impl_createFactory(com::sun::star::uno::Reference const&) -SdrCreateView::ImpDelCreateAttr() SdrCustomShapeDataItem::SdrCustomShapeDataItem(String const&) SdrCustomShapeEngineItem::SdrCustomShapeEngineItem(String const&) SdrCustomShapeGeometryItem::ClearPropertyValue(rtl::OUString const&, rtl::OUString const&) SdrCustomShapeReplacementURLItem::SdrCustomShapeReplacementURLItem(String const&) SdrEditView::MoveLayer(String const&, unsigned short) -SdrEngineDefaults::LanguageHasChanged() -SdrExchangeView::GetPastePos(SdrObjList*, OutputDevice*) -SdrExchangeView::Paste(Bitmap const&, Point const&, SdrObjList*, unsigned int) -SdrExchangeView::Paste(GDIMetaFile const&, Point const&, SdrObjList*, unsigned int) SdrGlobalData::GetCharClass() SdrGlobalData::~SdrGlobalData() SdrGluePoint::Draw(OutputDevice&, SdrObject const*) const @@ -608,11 +603,6 @@ SdrModel::CheckConsistence() const SdrModel::GetNumberFormatter() const SdrModel::HasTransparentObjects(bool) const SdrModel::IsAllowShapePropertyChangeListener() const -SdrObjEditView::AddTextEditOfs(MouseEvent&) const -SdrObjEditView::Cut(unsigned long) -SdrObjEditView::IsTextEditFrame() const -SdrObjEditView::Paste(Window*, unsigned long) -SdrObjEditView::Yank(unsigned long) SdrObjFactory::MakeNewObjUserData(unsigned int, unsigned short, SdrObject*) SdrObject::ClearObjectItem(unsigned short) SdrObject::FreeGlobalDrawObjectItemPool() -- cgit From 489272ce9e0d655a833fa7add2ed8cfb87349edb Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 28 Oct 2011 22:37:01 +0100 Subject: add and use an OString::equalsIgnoreAsciiCaseAsciiL equivalent to OUString one --- sal/inc/rtl/string.hxx | 28 ++++++++++++++++++++++++++++ vcl/inc/vcl/metaact.hxx | 8 ++++---- vcl/source/gdi/gdimtf.cxx | 18 +++++++++--------- vcl/source/gdi/metaact.cxx | 17 ++++++++++------- vcl/source/gdi/pdfwriter_impl2.cxx | 8 ++++---- 5 files changed, 55 insertions(+), 24 deletions(-) diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx index 22de6dd5be5c..7555464c4674 100644 --- a/sal/inc/rtl/string.hxx +++ b/sal/inc/rtl/string.hxx @@ -396,6 +396,34 @@ public: str.pData->buffer, str.pData->length ) == 0; } + /** + Perform a ASCII lowercase comparison of two strings. + + The result is true if and only if second string + represents the same sequence of characters as the first string, + ignoring the case. + Character values between 65 and 90 (ASCII A-Z) are interpreted as + values between 97 and 122 (ASCII a-z). + Since this method is optimized for performance, the ASCII character + values are not converted in any way. The caller has to make sure that + all ASCII characters are in the allowed range between 0 and + 127. The ASCII string must be greater or equal in length as asciiStrLength. + This function can't be used for language specific comparison. + + @param asciiStr the 8-Bit ASCII character string to be compared. + @param asciiStrLength the length of the ascii string + @return sal_True if the strings are equal; + sal_False, otherwise. + */ + sal_Bool equalsIgnoreAsciiCaseAsciiL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const SAL_THROW(()) + { + if ( pData->length != asciiStrLength ) + return sal_False; + + return rtl_str_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, + asciiStr, asciiStrLength ) == 0; + } + /** Match against a substring appearing in this string. diff --git a/vcl/inc/vcl/metaact.hxx b/vcl/inc/vcl/metaact.hxx index 87bc75fab2a0..64800fd6d0c8 100644 --- a/vcl/inc/vcl/metaact.hxx +++ b/vcl/inc/vcl/metaact.hxx @@ -1489,10 +1489,10 @@ class VCL_DLLPUBLIC MetaCommentAction : public MetaAction { private: - ByteString maComment; + rtl::OString maComment; sal_Int32 mnValue; sal_uInt32 mnDataSize; - sal_uInt8* mpData; + sal_uInt8* mpData; SAL_DLLPRIVATE void ImplInitDynamicData( const sal_uInt8* pData, sal_uInt32 nDataSize ); virtual sal_Bool Compare( const MetaAction& ) const; @@ -1503,7 +1503,7 @@ protected: public: MetaCommentAction( sal_Int32 nValue = 0L ); MetaCommentAction( const MetaCommentAction& rAct ); - MetaCommentAction( const ByteString& rComment, sal_Int32 nValue = 0L, const sal_uInt8* pData = NULL, sal_uInt32 nDataSize = 0UL ); + MetaCommentAction( const rtl::OString& rComment, sal_Int32 nValue = 0L, const sal_uInt8* pData = NULL, sal_uInt32 nDataSize = 0UL ); MetaCommentAction( const sal_uInt8* pData, sal_uInt32 nDataSize ); virtual void Move( long nHorzMove, long nVertMove ); @@ -1514,7 +1514,7 @@ public: virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ); virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ); - const ByteString& GetComment() const { return maComment; } + const rtl::OString& GetComment() const { return maComment; } sal_Int32 GetValue() const { return mnValue; } sal_uInt32 GetDataSize() const { return mnDataSize; } const sal_uInt8* GetData() const { return mpData; } diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx index fffde0472b75..7ab555db7880 100644 --- a/vcl/source/gdi/gdimtf.cxx +++ b/vcl/source/gdi/gdimtf.cxx @@ -556,7 +556,7 @@ void GDIMetaFile::Play( OutputDevice* pOut, size_t nPos ) { MetaCommentAction* pCommentAct = static_cast(pAction); if( pAction->GetType() == META_COMMENT_ACTION && - pCommentAct->GetComment().Equals("DELEGATE_PLUGGABLE_RENDERER") ) + pCommentAct->GetComment().equalsL(RTL_CONSTASCII_STRINGPARAM("DELEGATE_PLUGGABLE_RENDERER")) ) { ImplDelegate2PluggableRenderer(pCommentAct, pOut); } @@ -658,7 +658,7 @@ bool GDIMetaFile::ImplPlayWithRenderer( OutputDevice* pOut, const Point& rPos, S void GDIMetaFile::ImplDelegate2PluggableRenderer( const MetaCommentAction* pAct, OutputDevice* pOut ) { - OSL_ASSERT( pAct->GetComment().Equals("DELEGATE_PLUGGABLE_RENDERER") ); + OSL_ASSERT( pAct->GetComment().equalsL(RTL_CONSTASCII_STRINGPARAM("DELEGATE_PLUGGABLE_RENDERER")) ); // read payload - string of service name, followed by raw render input const sal_uInt8* pData = pAct->GetData(); @@ -1534,7 +1534,7 @@ void GDIMetaFile::Rotate( long nAngle10 ) case( META_COMMENT_ACTION ): { MetaCommentAction* pCommentAct = (MetaCommentAction*) pAction; - if( pCommentAct->GetComment().Equals( "XGRAD_SEQ_BEGIN" ) ) + if( pCommentAct->GetComment().equalsL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_BEGIN")) ) { int nBeginComments( 1 ); pAction = NextAction(); @@ -1555,7 +1555,7 @@ void GDIMetaFile::Rotate( long nAngle10 ) else if( META_COMMENT_ACTION == nType) { MetaCommentAction* pAct = (MetaCommentAction*) pAction; - if( pAct->GetComment().Equals( "XGRAD_SEQ_END" ) ) + if( pAct->GetComment().equalsL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_END")) ) { // handle nested blocks --nBeginComments; @@ -1564,7 +1564,7 @@ void GDIMetaFile::Rotate( long nAngle10 ) if( !nBeginComments ) break; } - else if( pAct->GetComment().Equals( "XGRAD_SEQ_BEGIN" ) ) + else if( pAct->GetComment().equalsL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_BEGIN")) ) { // handle nested blocks ++nBeginComments; @@ -1577,8 +1577,8 @@ void GDIMetaFile::Rotate( long nAngle10 ) } else { - sal_Bool bPathStroke = pCommentAct->GetComment().Equals( "XPATHSTROKE_SEQ_BEGIN" ); - if ( bPathStroke || pCommentAct->GetComment().Equals( "XPATHFILL_SEQ_BEGIN" ) ) + sal_Bool bPathStroke = pCommentAct->GetComment().equalsL(RTL_CONSTASCII_STRINGPARAM("XPATHSTROKE_SEQ_BEGIN")); + if ( bPathStroke || pCommentAct->GetComment().equalsL(RTL_CONSTASCII_STRINGPARAM("XPATHFILL_SEQ_BEGIN")) ) { if ( pCommentAct->GetDataSize() ) { @@ -1608,8 +1608,8 @@ void GDIMetaFile::Rotate( long nAngle10 ) } } } - else if ( pCommentAct->GetComment().Equals( "XPATHSTROKE_SEQ_END" ) - || pCommentAct->GetComment().Equals( "XPATHFILL_SEQ_END" ) ) + else if ( pCommentAct->GetComment().equalsL(RTL_CONSTASCII_STRINGPARAM("XPATHSTROKE_SEQ_END")) + || pCommentAct->GetComment().equalsL(RTL_CONSTASCII_STRINGPARAM("XPATHFILL_SEQ_END")) ) { pAction->Execute( &aMapVDev ); pAction->Duplicate(); diff --git a/vcl/source/gdi/metaact.cxx b/vcl/source/gdi/metaact.cxx index 99e56ece49ad..03c5390e6f36 100644 --- a/vcl/source/gdi/metaact.cxx +++ b/vcl/source/gdi/metaact.cxx @@ -4019,7 +4019,7 @@ MetaCommentAction::MetaCommentAction( const MetaCommentAction& rAct ) : // ------------------------------------------------------------------------ -MetaCommentAction::MetaCommentAction( const ByteString& rComment, sal_Int32 nValue, const sal_uInt8* pData, sal_uInt32 nDataSize ) : +MetaCommentAction::MetaCommentAction( const rtl::OString& rComment, sal_Int32 nValue, const sal_uInt8* pData, sal_uInt32 nDataSize ) : MetaAction ( META_COMMENT_ACTION ), maComment ( rComment ), mnValue ( nValue ) @@ -4086,8 +4086,8 @@ void MetaCommentAction::Move( long nXMove, long nYMove ) { if ( mnDataSize && mpData ) { - sal_Bool bPathStroke = maComment.Equals( "XPATHSTROKE_SEQ_BEGIN" ); - if ( bPathStroke || maComment.Equals( "XPATHFILL_SEQ_BEGIN" ) ) + sal_Bool bPathStroke = maComment.equalsL(RTL_CONSTASCII_STRINGPARAM("XPATHSTROKE_SEQ_BEGIN")); + if ( bPathStroke || maComment.equalsL(RTL_CONSTASCII_STRINGPARAM("XPATHFILL_SEQ_BEGIN")) ) { SvMemoryStream aMemStm( (void*)mpData, mnDataSize, STREAM_READ ); SvMemoryStream aDest; @@ -4129,8 +4129,8 @@ void MetaCommentAction::Scale( double fXScale, double fYScale ) { if ( mnDataSize && mpData ) { - sal_Bool bPathStroke = maComment.Equals( "XPATHSTROKE_SEQ_BEGIN" ); - if ( bPathStroke || maComment.Equals( "XPATHFILL_SEQ_BEGIN" ) ) + sal_Bool bPathStroke = maComment.equalsL(RTL_CONSTASCII_STRINGPARAM("XPATHSTROKE_SEQ_BEGIN")); + if ( bPathStroke || maComment.equalsL(RTL_CONSTASCII_STRINGPARAM("XPATHFILL_SEQ_BEGIN")) ) { SvMemoryStream aMemStm( (void*)mpData, mnDataSize, STREAM_READ ); SvMemoryStream aDest; @@ -4156,7 +4156,7 @@ void MetaCommentAction::Scale( double fXScale, double fYScale ) } delete[] mpData; ImplInitDynamicData( static_cast( aDest.GetData() ), aDest.Tell() ); - } else if( maComment.Equals( "EMF_PLUS_HEADER_INFO" ) ) { + } else if( maComment.equalsL(RTL_CONSTASCII_STRINGPARAM("EMF_PLUS_HEADER_INFO")) ){ SvMemoryStream aMemStm( (void*)mpData, mnDataSize, STREAM_READ ); SvMemoryStream aDest; @@ -4213,7 +4213,10 @@ void MetaCommentAction::Write( SvStream& rOStm, ImplMetaWriteData* pData ) void MetaCommentAction::Read( SvStream& rIStm, ImplMetaReadData* ) { COMPAT( rIStm ); - rIStm >> maComment >> mnValue >> mnDataSize; + ByteString sTmp; + rIStm >> sTmp; + maComment = sTmp; + rIStm >> mnValue >> mnDataSize; if( mpData ) delete[] mpData; diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx index f7a1ad5bcb56..50ae86268e0c 100644 --- a/vcl/source/gdi/pdfwriter_impl2.cxx +++ b/vcl/source/gdi/pdfwriter_impl2.cxx @@ -523,7 +523,7 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa const MetaCommentAction* pA = (const MetaCommentAction*) pAction; String aSkipComment; - if( pA->GetComment().CompareIgnoreCaseToAscii( "XGRAD_SEQ_BEGIN" ) == COMPARE_EQUAL ) + if( pA->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_BEGIN"))) { const MetaGradientExAction* pGradAction = NULL; sal_Bool bDone = sal_False; @@ -535,7 +535,7 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa if( pAction->GetType() == META_GRADIENTEX_ACTION ) pGradAction = (const MetaGradientExAction*) pAction; else if( ( pAction->GetType() == META_COMMENT_ACTION ) && - ( ( (const MetaCommentAction*) pAction )->GetComment().CompareIgnoreCaseToAscii( "XGRAD_SEQ_END" ) == COMPARE_EQUAL ) ) + ( ( (const MetaCommentAction*) pAction )->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_END"))) ) { bDone = sal_True; } @@ -559,7 +559,7 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa sal_Bool bSkipSequence = sal_False; rtl::OString sSeqEnd; - if( pA->GetComment().Equals( "XPATHSTROKE_SEQ_BEGIN" ) ) + if( pA->GetComment().equalsL(RTL_CONSTASCII_STRINGPARAM("XPATHSTROKE_SEQ_BEGIN")) ) { sSeqEnd = rtl::OString(RTL_CONSTASCII_STRINGPARAM("XPATHSTROKE_SEQ_END")); SvtGraphicStroke aStroke; @@ -644,7 +644,7 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa } } } - else if ( pA->GetComment().Equals( "XPATHFILL_SEQ_BEGIN" ) ) + else if ( pA->GetComment().equalsL(RTL_CONSTASCII_STRINGPARAM("XPATHFILL_SEQ_BEGIN")) ) { sSeqEnd = rtl::OString(RTL_CONSTASCII_STRINGPARAM("XPATHFILL_SEQ_END")); SvtGraphicFill aFill; -- cgit From 67cf9cbeebaa258cb790e71b559586fd3299017b Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 28 Oct 2011 23:07:15 +0100 Subject: add and use an OString::equalsIgnoreAsciiCaseAscii equivalent to OUString one --- cppcanvas/source/mtfrenderer/implrenderer.cxx | 18 +++++++++--------- sal/inc/rtl/string.hxx | 24 ++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/cppcanvas/source/mtfrenderer/implrenderer.cxx b/cppcanvas/source/mtfrenderer/implrenderer.cxx index 065aae480cce..32456e445106 100644 --- a/cppcanvas/source/mtfrenderer/implrenderer.cxx +++ b/cppcanvas/source/mtfrenderer/implrenderer.cxx @@ -516,8 +516,8 @@ namespace cppcanvas ++io_rCurrActionIndex; if( pCurrAct->GetType() == META_COMMENT_ACTION && - static_cast(pCurrAct)->GetComment().CompareIgnoreCaseToAscii( - pCommentString ) == COMPARE_EQUAL ) + static_cast(pCurrAct)->GetComment().equalsIgnoreAsciiCaseAscii( + pCommentString) ) { // requested comment found, done return; @@ -551,8 +551,8 @@ namespace cppcanvas } if( pCurrAct->GetType() == META_COMMENT_ACTION && - static_cast(pCurrAct)->GetComment().CompareIgnoreCaseToAscii( - pCommentString ) == COMPARE_EQUAL ) + static_cast(pCurrAct)->GetComment().equalsIgnoreAsciiCaseAscii( + pCommentString) ) { // delimiting end comment found, done bRet = false; // not yet found @@ -1686,7 +1686,7 @@ namespace cppcanvas MetaCommentAction* pAct = static_cast(pCurrAct); // Handle gradients - if ( pAct->GetComment().CompareIgnoreCaseToAscii( "XGRAD_SEQ_BEGIN" ) == COMPARE_EQUAL ) + if (pAct->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_BEGIN"))) { MetaGradientExAction* pGradAction = NULL; bool bDone( false ); @@ -1702,7 +1702,7 @@ namespace cppcanvas // skip broken-down rendering, output gradient when sequence is ended case META_COMMENT_ACTION: - if( static_cast(pCurrAct)->GetComment().CompareIgnoreCaseToAscii( "XGRAD_SEQ_END" ) == COMPARE_EQUAL ) + if( static_cast(pCurrAct)->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_END")) ) { bDone = true; @@ -1723,7 +1723,7 @@ namespace cppcanvas // XPATHSTROKE_SEQ_BEGIN comment // Handle drawing layer fills - else if( pAct->GetComment().Equals( "XPATHFILL_SEQ_BEGIN" ) ) + else if( pAct->GetComment().equalsL(RTL_CONSTASCII_STRINGPARAM("XPATHFILL_SEQ_BEGIN")) ) { const sal_uInt8* pData = pAct->GetData(); if ( pData ) @@ -1839,7 +1839,7 @@ namespace cppcanvas } } // Handle drawing layer fills - else if( pAct->GetComment().Equals( "EMF_PLUS" ) ) { + else if( pAct->GetComment().equalsL(RTL_CONSTASCII_STRINGPARAM("EMF_PLUS")) ) { static int count = -1, limit = 0x7fffffff; if (count == -1) { count = 0; @@ -1852,7 +1852,7 @@ namespace cppcanvas if (count < limit) processEMFPlus( pAct, rFactoryParms, getState( rStates ), rCanvas ); count ++; - } else if( pAct->GetComment().Equals( "EMF_PLUS_HEADER_INFO" ) ) { + } else if( pAct->GetComment().equalsL(RTL_CONSTASCII_STRINGPARAM("EMF_PLUS_HEADER_INFO")) ) { EMFP_DEBUG (printf ("EMF+ passed to canvas mtf renderer - header info, size: %u\n", (unsigned int)pAct->GetDataSize ())); SvMemoryStream rMF ((void*) pAct->GetData (), pAct->GetDataSize (), STREAM_READ); diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx index 7555464c4674..23fee9d7674e 100644 --- a/sal/inc/rtl/string.hxx +++ b/sal/inc/rtl/string.hxx @@ -396,6 +396,30 @@ public: str.pData->buffer, str.pData->length ) == 0; } + /** + Perform a ASCII lowercase comparison of two strings. + + The result is true if and only if second string + represents the same sequence of characters as the first string, + ignoring the case. + Character values between 65 and 90 (ASCII A-Z) are interpreted as + values between 97 and 122 (ASCII a-z). + Since this method is optimized for performance, the ASCII character + values are not converted in any way. The caller has to make sure that + all ASCII characters are in the allowed range between 0 and + 127. The ASCII string must be NULL-terminated. + This function can't be used for language specific comparison. + + @param asciiStr the 8-Bit ASCII character string to be compared. + @return sal_True if the strings are equal; + sal_False, otherwise. + */ + sal_Bool equalsIgnoreAsciiCaseAscii( const sal_Char * asciiStr ) const SAL_THROW(()) + { + return rtl_str_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, + asciiStr, rtl_str_getLength(asciiStr) ) == 0; + } + /** Perform a ASCII lowercase comparison of two strings. -- cgit From 6a73e43b718cc22a6cec0b2fada8bb6ada3893bf Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sat, 29 Oct 2011 08:25:10 +0100 Subject: MetaCommentAction now using rtl::OString --- drawinglayer/source/primitive2d/metafileprimitive2d.cxx | 4 ++-- svx/source/svdraw/svdfmtf.cxx | 4 ++-- svx/source/xml/xmlgrhlp.cxx | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drawinglayer/source/primitive2d/metafileprimitive2d.cxx b/drawinglayer/source/primitive2d/metafileprimitive2d.cxx index e2e0c5994142..685c4fc00c87 100644 --- a/drawinglayer/source/primitive2d/metafileprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/metafileprimitive2d.cxx @@ -3107,7 +3107,7 @@ namespace // and makes the code less dependent from those Metafile Add-Ons const MetaCommentAction* pA = (const MetaCommentAction*)pAction; - if(COMPARE_EQUAL == pA->GetComment().CompareIgnoreCaseToAscii("XGRAD_SEQ_BEGIN")) + if (pA->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_BEGIN"))) { // XGRAD_SEQ_BEGIN, XGRAD_SEQ_END should be supported since the // pure recorded paint of the gradients uses the XOR paint functionality @@ -3127,7 +3127,7 @@ namespace } else if(META_COMMENT_ACTION == pAction->GetType()) { - if(COMPARE_EQUAL == ((const MetaCommentAction*)pAction)->GetComment().CompareIgnoreCaseToAscii("XGRAD_SEQ_END")) + if (((const MetaCommentAction*)pAction)->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_END"))) { bDone = true; } diff --git a/svx/source/svdraw/svdfmtf.cxx b/svx/source/svdraw/svdfmtf.cxx index 0be5e6843903..9fe3753ef64b 100644 --- a/svx/source/svdraw/svdfmtf.cxx +++ b/svx/source/svdraw/svdfmtf.cxx @@ -956,7 +956,7 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaCommentAction& rAct, GDIMetaFile* pM { ByteString aSkipComment; - if( rAct.GetComment().CompareIgnoreCaseToAscii( "XGRAD_SEQ_BEGIN" ) == COMPARE_EQUAL ) + if (rAct.GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_BEGIN"))) { MetaGradientExAction* pAct = (MetaGradientExAction*) pMtf->NextAction(); @@ -1019,7 +1019,7 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaCommentAction& rAct, GDIMetaFile* pM while( pSkipAct && ((pSkipAct->GetType() != META_COMMENT_ACTION ) - || (((MetaCommentAction*)pSkipAct)->GetComment().CompareIgnoreCaseToAscii(aSkipComment.GetBuffer()) != COMPARE_EQUAL))) + || !(((MetaCommentAction*)pSkipAct)->GetComment().equalsIgnoreAsciiCase(aSkipComment)))) { pSkipAct = pMtf->NextAction(); } diff --git a/svx/source/xml/xmlgrhlp.cxx b/svx/source/xml/xmlgrhlp.cxx index 9c47a215fbb0..f7330dc40ec3 100644 --- a/svx/source/xml/xmlgrhlp.cxx +++ b/svx/source/xml/xmlgrhlp.cxx @@ -72,13 +72,12 @@ using ::com::sun::star::lang::XMultiServiceFactory; const MetaCommentAction* ImplCheckForEPS( GDIMetaFile& rMtf ) { - static ByteString aComment( (const sal_Char*)"EPSReplacementGraphic" ); const MetaCommentAction* pComment = NULL; if ( ( rMtf.GetActionSize() >= 2 ) && ( rMtf.FirstAction()->GetType() == META_EPS_ACTION ) && ( ((const MetaAction*)rMtf.GetAction( 1 ))->GetType() == META_COMMENT_ACTION ) - && ( ((const MetaCommentAction*)rMtf.GetAction( 1 ))->GetComment() == aComment ) ) + && ( ((const MetaCommentAction*)rMtf.GetAction( 1 ))->GetComment().equalsL(RTL_CONSTASCII_STRINGPARAM("EPSReplacementGraphic")) ) ) pComment = (const MetaCommentAction*)rMtf.GetAction( 1 ); return pComment; -- cgit From 4403ef6fa8c680fa230ead3a338fb8343e644461 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sat, 29 Oct 2011 09:24:16 +0100 Subject: ByteString->rtl::OString --- filter/source/flash/swfwriter1.cxx | 36 ++++------------------ filter/source/graphicfilter/eps/eps.cxx | 12 ++++---- filter/source/svg/svgwriter.cxx | 14 ++++----- slideshow/source/engine/shapes/drawshape.cxx | 10 +++--- .../source/engine/shapes/drawshapesubsetting.cxx | 16 +++++----- slideshow/source/engine/shapes/gdimtftools.cxx | 14 +++++---- 6 files changed, 39 insertions(+), 63 deletions(-) diff --git a/filter/source/flash/swfwriter1.cxx b/filter/source/flash/swfwriter1.cxx index ebb5238cc954..027e21ac4301 100644 --- a/filter/source/flash/swfwriter1.cxx +++ b/filter/source/flash/swfwriter1.cxx @@ -1658,7 +1658,7 @@ void Writer::Impl_writeActions( const GDIMetaFile& rMtf ) const sal_uInt8* pData = pA->GetData(); String aSkipComment; - if( pA->GetComment().CompareIgnoreCaseToAscii( "XGRAD_SEQ_BEGIN" ) == COMPARE_EQUAL ) + if( pA->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_BEGIN")) ) { const MetaGradientExAction* pGradAction = NULL; sal_Bool bDone = sal_False; @@ -1670,7 +1670,7 @@ void Writer::Impl_writeActions( const GDIMetaFile& rMtf ) if( pAction->GetType() == META_GRADIENTEX_ACTION ) pGradAction = (const MetaGradientExAction*) pAction; else if( ( pAction->GetType() == META_COMMENT_ACTION ) && - ( ( (const MetaCommentAction*) pAction )->GetComment().CompareIgnoreCaseToAscii( "XGRAD_SEQ_END" ) == COMPARE_EQUAL ) ) + ( ( (const MetaCommentAction*) pAction )->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_END")) ) ) { bDone = sal_True; } @@ -1679,7 +1679,7 @@ void Writer::Impl_writeActions( const GDIMetaFile& rMtf ) if( pGradAction ) Impl_writeGradientEx( pGradAction->GetPolyPolygon(), pGradAction->GetGradient()); } - else if( pA->GetComment().CompareIgnoreCaseToAscii( "XPATHFILL_SEQ_BEGIN" ) == COMPARE_EQUAL && + else if( pA->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XPATHFILL_SEQ_BEGIN")) && pData ) { @@ -1703,14 +1703,14 @@ void Writer::Impl_writeActions( const GDIMetaFile& rMtf ) pAction = rMtf.GetAction( i ); if( ( pAction->GetType() == META_COMMENT_ACTION ) && - ( ( (const MetaCommentAction*) pAction )->GetComment().CompareIgnoreCaseToAscii( "XPATHFILL_SEQ_END" ) == COMPARE_EQUAL ) ) + ( ( (const MetaCommentAction*) pAction )->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XPATHFILL_SEQ_END")) ) ) { bDone = sal_True; } } } } - else if( pA->GetComment().CompareIgnoreCaseToAscii( "XPATHSTROKE_SEQ_BEGIN" ) == COMPARE_EQUAL && + else if( pA->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XPATHSTROKE_SEQ_BEGIN")) && pData ) { @@ -1734,37 +1734,13 @@ void Writer::Impl_writeActions( const GDIMetaFile& rMtf ) pAction = rMtf.GetAction( i ); if( ( pAction->GetType() == META_COMMENT_ACTION ) && - ( ( (const MetaCommentAction*) pAction )->GetComment().CompareIgnoreCaseToAscii( "XPATHSTROKE_SEQ_END" ) == COMPARE_EQUAL ) ) + ( ( (const MetaCommentAction*) pAction )->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XPATHSTROKE_SEQ_END")) ) ) { bDone = sal_True; } } } } -#if 0 - else if( pA->GetComment().CompareIgnoreCaseToAscii( "FIELD_SEQ_BEGIN;PageField" ) == COMPARE_EQUAL ) - { - bool bDone = sal_False; - - while( !bDone && ( ++i < nCount ) ) - { - pAction = rMtf.GetAction( i ); - - if( pAction->GetType() == META_TEXTARRAY_ACTION ) - { - const MetaTextArrayAction* pA = (const MetaTextArrayAction*) pAction; - Rectangle aRect( pA->GetPoint(), Size( 100, 100 ) ); - Impl_writePageField( aRect ); - } - - if( ( pAction->GetType() == META_COMMENT_ACTION ) && - ( ( (const MetaCommentAction*) pAction )->GetComment().CompareIgnoreCaseToAscii( "FIELD_SEQ_END" ) == COMPARE_EQUAL ) ) - { - bDone = sal_True; - } - } - } -#endif } break; diff --git a/filter/source/graphicfilter/eps/eps.cxx b/filter/source/graphicfilter/eps/eps.cxx index e385a4a8f0ad..aad48765dc0d 100644 --- a/filter/source/graphicfilter/eps/eps.cxx +++ b/filter/source/graphicfilter/eps/eps.cxx @@ -1244,7 +1244,7 @@ void PSWriter::ImplWriteActions( const GDIMetaFile& rMtf, VirtualDevice& rVDev ) case META_COMMENT_ACTION: { const MetaCommentAction* pA = (const MetaCommentAction*) pMA; - if ( pA->GetComment().CompareIgnoreCaseToAscii( "XGRAD_SEQ_BEGIN" ) == COMPARE_EQUAL ) + if ( pA->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_BEGIN")) ) { const MetaGradientExAction* pGradAction = NULL; while( ++nCurAction < nCount ) @@ -1253,7 +1253,7 @@ void PSWriter::ImplWriteActions( const GDIMetaFile& rMtf, VirtualDevice& rVDev ) if( pAction->GetType() == META_GRADIENTEX_ACTION ) pGradAction = (const MetaGradientExAction*) pAction; else if( ( pAction->GetType() == META_COMMENT_ACTION ) && - ( ( (const MetaCommentAction*) pAction )->GetComment().CompareIgnoreCaseToAscii( "XGRAD_SEQ_END" ) == COMPARE_EQUAL ) ) + ( ( (const MetaCommentAction*) pAction )->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_END")) ) ) { break; } @@ -1261,7 +1261,7 @@ void PSWriter::ImplWriteActions( const GDIMetaFile& rMtf, VirtualDevice& rVDev ) if( pGradAction ) ImplWriteGradient( pGradAction->GetPolyPolygon(), pGradAction->GetGradient(), rVDev ); } - else if ( pA->GetComment().Equals( "XPATHFILL_SEQ_END" ) ) + else if ( pA->GetComment().equalsL(RTL_CONSTASCII_STRINGPARAM("XPATHFILL_SEQ_END")) ) { if ( aFillPath.Count() ) { @@ -1278,7 +1278,7 @@ void PSWriter::ImplWriteActions( const GDIMetaFile& rMtf, VirtualDevice& rVDev ) sal_Bool bSkipSequence = sal_False; ByteString sSeqEnd; - if( pA->GetComment().Equals( "XPATHSTROKE_SEQ_BEGIN" ) ) + if( pA->GetComment().equalsL(RTL_CONSTASCII_STRINGPARAM( "XPATHSTROKE_SEQ_BEGIN" )) ) { sSeqEnd = ByteString( "XPATHSTROKE_SEQ_END" ); SvtGraphicStroke aStroke; @@ -1314,7 +1314,7 @@ void PSWriter::ImplWriteActions( const GDIMetaFile& rMtf, VirtualDevice& rVDev ) ImplPolyLine( aPath ); } } - else if( pA->GetComment().Equals( "XPATHFILL_SEQ_BEGIN" ) ) + else if (pA->GetComment().equalsL(RTL_CONSTASCII_STRINGPARAM("XPATHFILL_SEQ_BEGIN"))) { sSeqEnd = ByteString( "XPATHFILL_SEQ_END" ); SvtGraphicFill aFill; @@ -1386,7 +1386,7 @@ void PSWriter::ImplWriteActions( const GDIMetaFile& rMtf, VirtualDevice& rVDev ) break; case META_COMMENT_ACTION : { - if (((const MetaCommentAction*)pAction)->GetComment().Equals( "XPATHFILL_SEQ_END" )) + if (((const MetaCommentAction*)pAction)->GetComment().equalsL(RTL_CONSTASCII_STRINGPARAM("XPATHFILL_SEQ_END"))) bOk = sal_False; } break; diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx index 66ca7bd5156c..1e6d11584170 100644 --- a/filter/source/svg/svgwriter.cxx +++ b/filter/source/svg/svgwriter.cxx @@ -1627,7 +1627,7 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, const MetaCommentAction* pA = (const MetaCommentAction*) pAction; String aSkipComment; - if( ( pA->GetComment().CompareIgnoreCaseToAscii( "XGRAD_SEQ_BEGIN" ) == COMPARE_EQUAL ) && + if( ( pA->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_BEGIN")) ) && ( nWriteFlags & SVGWRITER_WRITE_FILL ) ) { const MetaGradientExAction* pGradAction = NULL; @@ -1641,7 +1641,7 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, pGradAction = (const MetaGradientExAction*) pAction; else if( ( pAction->GetType() == META_COMMENT_ACTION ) && ( ( (const MetaCommentAction*) pAction )->GetComment(). - CompareIgnoreCaseToAscii( "XGRAD_SEQ_END" ) == COMPARE_EQUAL ) ) + equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_END")) ) ) { bDone = sal_True; } @@ -1650,7 +1650,7 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, if( pGradAction ) ImplWriteGradientEx( pGradAction->GetPolyPolygon(), pGradAction->GetGradient(), nWriteFlags ); } - else if( ( pA->GetComment().CompareIgnoreCaseToAscii( "XPATHFILL_SEQ_BEGIN" ) == COMPARE_EQUAL ) && + else if( ( pA->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XPATHFILL_SEQ_BEGIN")) ) && ( nWriteFlags & SVGWRITER_WRITE_FILL ) && !( nWriteFlags & SVGWRITER_NO_SHAPE_COMMENTS ) && pA->GetDataSize() ) { @@ -1697,7 +1697,7 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, if( ( pAction->GetType() == META_COMMENT_ACTION ) && ( ( (const MetaCommentAction*) pAction )->GetComment(). - CompareIgnoreCaseToAscii( "XPATHFILL_SEQ_END" ) == COMPARE_EQUAL ) ) + equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XPATHFILL_SEQ_END")) ) ) { bSkip = sal_False; } @@ -1725,13 +1725,13 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, if( ( pAction->GetType() == META_COMMENT_ACTION ) && ( ( (const MetaCommentAction*) pAction )->GetComment(). - CompareIgnoreCaseToAscii( "XPATHFILL_SEQ_END" ) == COMPARE_EQUAL ) ) + equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XPATHFILL_SEQ_END")) ) ) { bSkip = sal_False; } } } - else if( ( pA->GetComment().CompareIgnoreCaseToAscii( "XPATHSTROKE_SEQ_BEGIN" ) == COMPARE_EQUAL ) && + else if( ( pA->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XPATHSTROKE_SEQ_BEGIN")) ) && ( nWriteFlags & SVGWRITER_WRITE_FILL ) && !( nWriteFlags & SVGWRITER_NO_SHAPE_COMMENTS ) && pA->GetDataSize() ) { @@ -1781,7 +1781,7 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, if( ( pAction->GetType() == META_COMMENT_ACTION ) && ( ( (const MetaCommentAction*) pAction )->GetComment(). - CompareIgnoreCaseToAscii( "XPATHSTROKE_SEQ_END" ) == COMPARE_EQUAL ) ) + equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XPATHSTROKE_SEQ_END")) ) ) { bSkip = sal_False; } diff --git a/slideshow/source/engine/shapes/drawshape.cxx b/slideshow/source/engine/shapes/drawshape.cxx index e2492a4ddd3a..d3b9a2fab89b 100644 --- a/slideshow/source/engine/shapes/drawshape.cxx +++ b/slideshow/source/engine/shapes/drawshape.cxx @@ -1090,9 +1090,8 @@ namespace slideshow MetaCommentAction * pAct = static_cast(pCurrAct); // skip comment if not a special XTEXT comment - if (pAct->GetComment().CompareIgnoreCaseToAscii( - RTL_CONSTASCII_STRINGPARAM("FIELD_SEQ_BEGIN") ) == - COMPARE_EQUAL && + if (pAct->GetComment().equalsIgnoreAsciiCaseAsciiL( + RTL_CONSTASCII_STRINGPARAM("FIELD_SEQ_BEGIN") ) && // e.g. date field doesn't have data! // currently assuming that only url field, this is // somehow fragile! xxx todo if possible @@ -1117,9 +1116,8 @@ namespace slideshow pAct->GetDataSize() / sizeof(sal_Unicode) ) ) ); } - else if (pAct->GetComment().CompareIgnoreCaseToAscii( - RTL_CONSTASCII_STRINGPARAM("FIELD_SEQ_END")) == - COMPARE_EQUAL && + else if (pAct->GetComment().equalsIgnoreAsciiCaseAsciiL( + RTL_CONSTASCII_STRINGPARAM("FIELD_SEQ_END")) && // pending end is expected: !maHyperlinkIndices.empty() && maHyperlinkIndices.back().second == -1) diff --git a/slideshow/source/engine/shapes/drawshapesubsetting.cxx b/slideshow/source/engine/shapes/drawshapesubsetting.cxx index bfe36dcc6c27..b474c05ad8a4 100644 --- a/slideshow/source/engine/shapes/drawshapesubsetting.cxx +++ b/slideshow/source/engine/shapes/drawshapesubsetting.cxx @@ -91,14 +91,14 @@ namespace slideshow MetaCommentAction* pAct = static_cast(pCurrAct); // skip comment if not a special XTEXT comment - if( pAct->GetComment().CompareIgnoreCaseToAscii( "XTEXT", 5 ) == COMPARE_EQUAL ) + if( pAct->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XTEXT")) ) { // fill classification vector with NOOPs, // then insert corresponding classes at // the given index maActionClassVector.resize( nActionIndex+1, CLASS_NOOP ); - if( pAct->GetComment().CompareIgnoreCaseToAscii( "XTEXT_EOC" ) == COMPARE_EQUAL ) + if( pAct->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XTEXT_EOC")) ) { // special, because can happen // in-between of portions - set @@ -112,7 +112,7 @@ namespace slideshow maActionClassVector[ nIndex ] = CLASS_CHARACTER_CELL_END; } - else if( pAct->GetComment().CompareIgnoreCaseToAscii( "XTEXT_EOW" ) == COMPARE_EQUAL ) + else if( pAct->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XTEXT_EOW")) ) { // special, because can happen // in-between of portions - set @@ -126,7 +126,7 @@ namespace slideshow maActionClassVector[ nIndex ] = CLASS_WORD_END; } - else if( pAct->GetComment().CompareIgnoreCaseToAscii( "XTEXT_EOS" ) == COMPARE_EQUAL ) + else if( pAct->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM( "XTEXT_EOS" )) ) { // special, because can happen // in-between of portions - set @@ -140,19 +140,19 @@ namespace slideshow maActionClassVector[ nIndex ] = CLASS_SENTENCE_END; } - else if( pAct->GetComment().CompareIgnoreCaseToAscii( "XTEXT_EOL" ) == COMPARE_EQUAL ) + else if( pAct->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XTEXT_EOL")) ) { maActionClassVector[ nActionIndex ] = CLASS_LINE_END; } - else if( pAct->GetComment().CompareIgnoreCaseToAscii( "XTEXT_EOP" ) == COMPARE_EQUAL ) + else if( pAct->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XTEXT_EOP")) ) { maActionClassVector[ nActionIndex ] = CLASS_PARAGRAPH_END; } - else if( pAct->GetComment().CompareIgnoreCaseToAscii( "XTEXT_PAINTSHAPE_END" ) == COMPARE_EQUAL ) + else if( pAct->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XTEXT_PAINTSHAPE_END")) ) { maActionClassVector[ nActionIndex ] = CLASS_SHAPE_END; } - else if( pAct->GetComment().CompareIgnoreCaseToAscii( "XTEXT_PAINTSHAPE_BEGIN" ) == COMPARE_EQUAL ) + else if( pAct->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XTEXT_PAINTSHAPE_BEGIN")) ) { maActionClassVector[ nActionIndex ] = CLASS_SHAPE_START; } diff --git a/slideshow/source/engine/shapes/gdimtftools.cxx b/slideshow/source/engine/shapes/gdimtftools.cxx index aed27647642c..ab85873ceb2c 100644 --- a/slideshow/source/engine/shapes/gdimtftools.cxx +++ b/slideshow/source/engine/shapes/gdimtftools.cxx @@ -481,19 +481,21 @@ bool getRectanglesFromScrollMtf( ::basegfx::B2DRectangle& o_rScrollRect, MetaCommentAction * pAct = static_cast(pCurrAct); // skip comment if not a special XTEXT comment - if (pAct->GetComment().CompareIgnoreCaseToAscii( - RTL_CONSTASCII_STRINGPARAM("XTEXT") ) == COMPARE_EQUAL) + if (pAct->GetComment().equalsIgnoreAsciiCaseAsciiL( + RTL_CONSTASCII_STRINGPARAM("XTEXT") )) { - if (pAct->GetComment().CompareIgnoreCaseToAscii( - "XTEXT_SCROLLRECT" ) == COMPARE_EQUAL) { + if (pAct->GetComment().equalsIgnoreAsciiCaseAsciiL( + RTL_CONSTASCII_STRINGPARAM("XTEXT_SCROLLRECT") )) + { o_rScrollRect = ::vcl::unotools::b2DRectangleFromRectangle( *reinterpret_cast( pAct->GetData() ) ); bScrollRectSet = true; } - else if (pAct->GetComment().CompareIgnoreCaseToAscii( - "XTEXT_PAINTRECT" ) == COMPARE_EQUAL) { + else if (pAct->GetComment().equalsIgnoreAsciiCaseAsciiL( + RTL_CONSTASCII_STRINGPARAM("XTEXT_PAINTRECT")) ) + { o_rPaintRect = ::vcl::unotools::b2DRectangleFromRectangle( *reinterpret_cast( pAct->GetData() ) ); -- cgit From 4847ef98f6a9448c3c4a52eacd8dd540e59fea4e Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sun, 30 Oct 2011 07:50:19 +0000 Subject: drop unused GetViewCenter --- svx/inc/svx/svdxcgv.hxx | 3 --- svx/source/svdraw/svdxcgv.cxx | 20 -------------------- 2 files changed, 23 deletions(-) diff --git a/svx/inc/svx/svdxcgv.hxx b/svx/inc/svx/svdxcgv.hxx index 90074daf29b5..30fe9df55e14 100644 --- a/svx/inc/svx/svdxcgv.hxx +++ b/svx/inc/svx/svdxcgv.hxx @@ -111,9 +111,6 @@ public: */ static Graphic GetObjGraphic( const SdrModel* pModel, const SdrObject* pObj ); - // Bestimmung des View-Mittelpunktes, z.B. zum Pasten - Point GetViewCenter(const OutputDevice* pOut=NULL) const; - // Bei allen Paste-Methoden werden die neuen Draw-Objekte markiert. // Wird der Parameter bAddMark auf sal_True gesetzt, so werden die neuen // DrawObjekte zu einer bereits bestehenden Selektion "hinzumarkiert". diff --git a/svx/source/svdraw/svdxcgv.cxx b/svx/source/svdraw/svdxcgv.cxx index 89b48c61ede0..301958f60838 100644 --- a/svx/source/svdraw/svdxcgv.cxx +++ b/svx/source/svdraw/svdxcgv.cxx @@ -72,26 +72,6 @@ SdrExchangeView::SdrExchangeView(SdrModel* pModel1, OutputDevice* pOut): { } -//////////////////////////////////////////////////////////////////////////////////////////////////// - -Point SdrExchangeView::GetViewCenter(const OutputDevice* pOut) const -{ - Point aCenter; - if (pOut==NULL) - { - pOut = GetFirstOutputDevice(); - } - if (pOut!=NULL) { - Point aOfs=pOut->GetMapMode().GetOrigin(); - Size aOutSiz=pOut->GetOutputSize(); - aOutSiz.Width()/=2; - aOutSiz.Height()/=2; - aCenter.X()=aOutSiz.Width() -aOfs.X(); - aCenter.Y()=aOutSiz.Height()-aOfs.Y(); - } - return aCenter; -} - sal_Bool SdrExchangeView::ImpLimitToWorkArea(Point& rPt) const { sal_Bool bRet(sal_False); -- cgit From 120d1614d3267d9f2844391c72024b61f97348e4 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sun, 30 Oct 2011 07:56:10 +0000 Subject: can go behind appropiate ifdef --- editeng/source/editeng/editdbg.cxx | 2 ++ editeng/source/editeng/editdoc.hxx | 3 ++- unusedcode.easy | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/editeng/source/editeng/editdbg.cxx b/editeng/source/editeng/editdbg.cxx index 80193d018589..764ecead5e96 100644 --- a/editeng/source/editeng/editdbg.cxx +++ b/editeng/source/editeng/editdbg.cxx @@ -487,6 +487,7 @@ void EditDbg::ShowEditEngineData( EditEngine* pEE, sal_Bool bInfoBox ) InfoBox(0, String( RTL_CONSTASCII_USTRINGPARAM( "D:\\DEBUG.LOG !" ) ) ).Execute(); } +#if OSL_DEBUG_LEVEL > 2 sal_Bool ParaPortion::DbgCheckTextPortions() { // check, if Portion length ok: @@ -495,6 +496,7 @@ sal_Bool ParaPortion::DbgCheckTextPortions() nXLen = nXLen + aTextPortionList[nPortion]->GetLen(); return nXLen == pNode->Len() ? sal_True : sal_False; } +#endif sal_Bool CheckOrderedList( CharAttribArray& rAttribs, sal_Bool bStart ) { diff --git a/editeng/source/editeng/editdoc.hxx b/editeng/source/editeng/editdoc.hxx index a51d07122f37..a8e29bc28454 100644 --- a/editeng/source/editeng/editdoc.hxx +++ b/editeng/source/editeng/editdoc.hxx @@ -627,8 +627,9 @@ public: short GetInvalidDiff() const { return nInvalidDiff; } void CorrectValuesBehindLastFormattedLine( sal_uInt16 nLastFormattedLine ); - +#if OSL_DEBUG_LEVEL > 2 sal_Bool DbgCheckTextPortions(); +#endif }; typedef ParaPortion* ParaPortionPtr; diff --git a/unusedcode.easy b/unusedcode.easy index 13cbb9d13217..747291b7714e 100644 --- a/unusedcode.easy +++ b/unusedcode.easy @@ -342,9 +342,9 @@ OutputDevice::PixelToLogic(basegfx::B2DPolyPolygon const&) const OutputDevice::PixelToLogic(basegfx::B2DPolygon const&) const PageSpan::getMarginLeft() const PageSpan::getMarginRight() const -ParaPortion::DbgCheckTextPortions() ParaPortionList::DbgCheck(EditDoc&) ParagraphObj::ParagraphObj(ParagraphObj&) +ParagraphStyleManager::get(WPXString const&) const PathDialog::SetPath(Edit const&) PatternBox::GetString(unsigned short) const PatternBox::GetStringPos(String const&) const @@ -743,6 +743,7 @@ SotFactory::TestInvariant() SotObject::RemoveOwnerLock() SotStorage::GetProperty(String const&, String const&, com::sun::star::uno::Any&) SourceTreeIterator::EndExecute() +SpanStyleManager::get(WPXString const&) const SpinButton::SpinButton(Window*, ResId const&) SplitWindow::CalcWindowSizePixel(Size const&, WindowAlign, long, unsigned char) SplitWindow::GetItemWindow(unsigned short) const -- cgit From fef11229e6231814a9d5aa9227b17fbac4878731 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sun, 30 Oct 2011 12:03:49 +0000 Subject: ByteString->rtl::OString --- sw/source/core/swg/SwXMLTextBlocks.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sw/source/core/swg/SwXMLTextBlocks.cxx b/sw/source/core/swg/SwXMLTextBlocks.cxx index 58e56feadfce..a181532ab8c7 100644 --- a/sw/source/core/swg/SwXMLTextBlocks.cxx +++ b/sw/source/core/swg/SwXMLTextBlocks.cxx @@ -559,7 +559,7 @@ void SwXMLTextBlocks::GeneratePackageName ( const String& rShort, String& rPacka rPackageName = rShort; xub_StrLen nPos = 0; sal_Unicode pDelims[] = { '!', '/', ':', '.', '\\', 0 }; - ByteString sByte ( rPackageName, RTL_TEXTENCODING_UTF7); + rtl::OString sByte(rtl::OUStringToOString(rPackageName, RTL_TEXTENCODING_UTF7)); rPackageName = String (sByte, RTL_TEXTENCODING_ASCII_US); while( STRING_NOTFOUND != ( nPos = rPackageName.SearchChar( pDelims, nPos ))) { -- cgit From 76e37b7f798a211a9a3f3110f30d65a2c93dba4b Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sun, 30 Oct 2011 21:20:45 +0000 Subject: adapt naming scheme --- cppcanvas/source/mtfrenderer/implrenderer.cxx | 8 ++++---- drawinglayer/source/primitive2d/metafileprimitive2d.cxx | 4 ++-- filter/source/flash/swfwriter1.cxx | 12 ++++++------ filter/source/graphicfilter/eps/eps.cxx | 4 ++-- filter/source/svg/svgwriter.cxx | 14 +++++++------- sal/inc/rtl/string.hxx | 7 +++---- slideshow/source/engine/shapes/drawshape.cxx | 4 ++-- slideshow/source/engine/shapes/drawshapesubsetting.cxx | 16 ++++++++-------- slideshow/source/engine/shapes/gdimtftools.cxx | 6 +++--- svx/source/svdraw/svdfmtf.cxx | 2 +- vcl/source/gdi/pdfwriter_impl2.cxx | 4 ++-- 11 files changed, 40 insertions(+), 41 deletions(-) diff --git a/cppcanvas/source/mtfrenderer/implrenderer.cxx b/cppcanvas/source/mtfrenderer/implrenderer.cxx index 32456e445106..1ddfc69f7dc7 100644 --- a/cppcanvas/source/mtfrenderer/implrenderer.cxx +++ b/cppcanvas/source/mtfrenderer/implrenderer.cxx @@ -516,7 +516,7 @@ namespace cppcanvas ++io_rCurrActionIndex; if( pCurrAct->GetType() == META_COMMENT_ACTION && - static_cast(pCurrAct)->GetComment().equalsIgnoreAsciiCaseAscii( + static_cast(pCurrAct)->GetComment().equalsIgnoreAsciiCase( pCommentString) ) { // requested comment found, done @@ -551,7 +551,7 @@ namespace cppcanvas } if( pCurrAct->GetType() == META_COMMENT_ACTION && - static_cast(pCurrAct)->GetComment().equalsIgnoreAsciiCaseAscii( + static_cast(pCurrAct)->GetComment().equalsIgnoreAsciiCase( pCommentString) ) { // delimiting end comment found, done @@ -1686,7 +1686,7 @@ namespace cppcanvas MetaCommentAction* pAct = static_cast(pCurrAct); // Handle gradients - if (pAct->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_BEGIN"))) + if (pAct->GetComment().equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_BEGIN"))) { MetaGradientExAction* pGradAction = NULL; bool bDone( false ); @@ -1702,7 +1702,7 @@ namespace cppcanvas // skip broken-down rendering, output gradient when sequence is ended case META_COMMENT_ACTION: - if( static_cast(pCurrAct)->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_END")) ) + if( static_cast(pCurrAct)->GetComment().equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_END")) ) { bDone = true; diff --git a/drawinglayer/source/primitive2d/metafileprimitive2d.cxx b/drawinglayer/source/primitive2d/metafileprimitive2d.cxx index 685c4fc00c87..967e1e740757 100644 --- a/drawinglayer/source/primitive2d/metafileprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/metafileprimitive2d.cxx @@ -3107,7 +3107,7 @@ namespace // and makes the code less dependent from those Metafile Add-Ons const MetaCommentAction* pA = (const MetaCommentAction*)pAction; - if (pA->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_BEGIN"))) + if (pA->GetComment().equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_BEGIN"))) { // XGRAD_SEQ_BEGIN, XGRAD_SEQ_END should be supported since the // pure recorded paint of the gradients uses the XOR paint functionality @@ -3127,7 +3127,7 @@ namespace } else if(META_COMMENT_ACTION == pAction->GetType()) { - if (((const MetaCommentAction*)pAction)->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_END"))) + if (((const MetaCommentAction*)pAction)->GetComment().equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_END"))) { bDone = true; } diff --git a/filter/source/flash/swfwriter1.cxx b/filter/source/flash/swfwriter1.cxx index 027e21ac4301..4a4abf9907ee 100644 --- a/filter/source/flash/swfwriter1.cxx +++ b/filter/source/flash/swfwriter1.cxx @@ -1658,7 +1658,7 @@ void Writer::Impl_writeActions( const GDIMetaFile& rMtf ) const sal_uInt8* pData = pA->GetData(); String aSkipComment; - if( pA->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_BEGIN")) ) + if( pA->GetComment().equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_BEGIN")) ) { const MetaGradientExAction* pGradAction = NULL; sal_Bool bDone = sal_False; @@ -1670,7 +1670,7 @@ void Writer::Impl_writeActions( const GDIMetaFile& rMtf ) if( pAction->GetType() == META_GRADIENTEX_ACTION ) pGradAction = (const MetaGradientExAction*) pAction; else if( ( pAction->GetType() == META_COMMENT_ACTION ) && - ( ( (const MetaCommentAction*) pAction )->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_END")) ) ) + ( ( (const MetaCommentAction*) pAction )->GetComment().equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_END")) ) ) { bDone = sal_True; } @@ -1679,7 +1679,7 @@ void Writer::Impl_writeActions( const GDIMetaFile& rMtf ) if( pGradAction ) Impl_writeGradientEx( pGradAction->GetPolyPolygon(), pGradAction->GetGradient()); } - else if( pA->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XPATHFILL_SEQ_BEGIN")) && + else if( pA->GetComment().equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XPATHFILL_SEQ_BEGIN")) && pData ) { @@ -1703,14 +1703,14 @@ void Writer::Impl_writeActions( const GDIMetaFile& rMtf ) pAction = rMtf.GetAction( i ); if( ( pAction->GetType() == META_COMMENT_ACTION ) && - ( ( (const MetaCommentAction*) pAction )->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XPATHFILL_SEQ_END")) ) ) + ( ( (const MetaCommentAction*) pAction )->GetComment().equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XPATHFILL_SEQ_END")) ) ) { bDone = sal_True; } } } } - else if( pA->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XPATHSTROKE_SEQ_BEGIN")) && + else if( pA->GetComment().equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XPATHSTROKE_SEQ_BEGIN")) && pData ) { @@ -1734,7 +1734,7 @@ void Writer::Impl_writeActions( const GDIMetaFile& rMtf ) pAction = rMtf.GetAction( i ); if( ( pAction->GetType() == META_COMMENT_ACTION ) && - ( ( (const MetaCommentAction*) pAction )->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XPATHSTROKE_SEQ_END")) ) ) + ( ( (const MetaCommentAction*) pAction )->GetComment().equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XPATHSTROKE_SEQ_END")) ) ) { bDone = sal_True; } diff --git a/filter/source/graphicfilter/eps/eps.cxx b/filter/source/graphicfilter/eps/eps.cxx index aad48765dc0d..c26f3eb79a96 100644 --- a/filter/source/graphicfilter/eps/eps.cxx +++ b/filter/source/graphicfilter/eps/eps.cxx @@ -1244,7 +1244,7 @@ void PSWriter::ImplWriteActions( const GDIMetaFile& rMtf, VirtualDevice& rVDev ) case META_COMMENT_ACTION: { const MetaCommentAction* pA = (const MetaCommentAction*) pMA; - if ( pA->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_BEGIN")) ) + if ( pA->GetComment().equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_BEGIN")) ) { const MetaGradientExAction* pGradAction = NULL; while( ++nCurAction < nCount ) @@ -1253,7 +1253,7 @@ void PSWriter::ImplWriteActions( const GDIMetaFile& rMtf, VirtualDevice& rVDev ) if( pAction->GetType() == META_GRADIENTEX_ACTION ) pGradAction = (const MetaGradientExAction*) pAction; else if( ( pAction->GetType() == META_COMMENT_ACTION ) && - ( ( (const MetaCommentAction*) pAction )->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_END")) ) ) + ( ( (const MetaCommentAction*) pAction )->GetComment().equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_END")) ) ) { break; } diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx index 1e6d11584170..f69fe6038ff9 100644 --- a/filter/source/svg/svgwriter.cxx +++ b/filter/source/svg/svgwriter.cxx @@ -1627,7 +1627,7 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, const MetaCommentAction* pA = (const MetaCommentAction*) pAction; String aSkipComment; - if( ( pA->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_BEGIN")) ) && + if( ( pA->GetComment().equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_BEGIN")) ) && ( nWriteFlags & SVGWRITER_WRITE_FILL ) ) { const MetaGradientExAction* pGradAction = NULL; @@ -1641,7 +1641,7 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, pGradAction = (const MetaGradientExAction*) pAction; else if( ( pAction->GetType() == META_COMMENT_ACTION ) && ( ( (const MetaCommentAction*) pAction )->GetComment(). - equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_END")) ) ) + equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_END")) ) ) { bDone = sal_True; } @@ -1650,7 +1650,7 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, if( pGradAction ) ImplWriteGradientEx( pGradAction->GetPolyPolygon(), pGradAction->GetGradient(), nWriteFlags ); } - else if( ( pA->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XPATHFILL_SEQ_BEGIN")) ) && + else if( ( pA->GetComment().equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XPATHFILL_SEQ_BEGIN")) ) && ( nWriteFlags & SVGWRITER_WRITE_FILL ) && !( nWriteFlags & SVGWRITER_NO_SHAPE_COMMENTS ) && pA->GetDataSize() ) { @@ -1697,7 +1697,7 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, if( ( pAction->GetType() == META_COMMENT_ACTION ) && ( ( (const MetaCommentAction*) pAction )->GetComment(). - equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XPATHFILL_SEQ_END")) ) ) + equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XPATHFILL_SEQ_END")) ) ) { bSkip = sal_False; } @@ -1725,13 +1725,13 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, if( ( pAction->GetType() == META_COMMENT_ACTION ) && ( ( (const MetaCommentAction*) pAction )->GetComment(). - equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XPATHFILL_SEQ_END")) ) ) + equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XPATHFILL_SEQ_END")) ) ) { bSkip = sal_False; } } } - else if( ( pA->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XPATHSTROKE_SEQ_BEGIN")) ) && + else if( ( pA->GetComment().equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XPATHSTROKE_SEQ_BEGIN")) ) && ( nWriteFlags & SVGWRITER_WRITE_FILL ) && !( nWriteFlags & SVGWRITER_NO_SHAPE_COMMENTS ) && pA->GetDataSize() ) { @@ -1781,7 +1781,7 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, if( ( pAction->GetType() == META_COMMENT_ACTION ) && ( ( (const MetaCommentAction*) pAction )->GetComment(). - equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XPATHSTROKE_SEQ_END")) ) ) + equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XPATHSTROKE_SEQ_END")) ) ) { bSkip = sal_False; } diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx index 23fee9d7674e..ee4101188013 100644 --- a/sal/inc/rtl/string.hxx +++ b/sal/inc/rtl/string.hxx @@ -414,10 +414,9 @@ public: @return sal_True if the strings are equal; sal_False, otherwise. */ - sal_Bool equalsIgnoreAsciiCaseAscii( const sal_Char * asciiStr ) const SAL_THROW(()) + sal_Bool equalsIgnoreAsciiCase( const sal_Char * asciiStr ) const SAL_THROW(()) { - return rtl_str_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, - asciiStr, rtl_str_getLength(asciiStr) ) == 0; + return rtl_str_compareIgnoreAsciiCase( pData->buffer, asciiStr ) == 0; } /** @@ -439,7 +438,7 @@ public: @return sal_True if the strings are equal; sal_False, otherwise. */ - sal_Bool equalsIgnoreAsciiCaseAsciiL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const SAL_THROW(()) + sal_Bool equalsIgnoreAsciiCaseL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const SAL_THROW(()) { if ( pData->length != asciiStrLength ) return sal_False; diff --git a/slideshow/source/engine/shapes/drawshape.cxx b/slideshow/source/engine/shapes/drawshape.cxx index d3b9a2fab89b..153ffb28cd4b 100644 --- a/slideshow/source/engine/shapes/drawshape.cxx +++ b/slideshow/source/engine/shapes/drawshape.cxx @@ -1090,7 +1090,7 @@ namespace slideshow MetaCommentAction * pAct = static_cast(pCurrAct); // skip comment if not a special XTEXT comment - if (pAct->GetComment().equalsIgnoreAsciiCaseAsciiL( + if (pAct->GetComment().equalsIgnoreAsciiCaseL( RTL_CONSTASCII_STRINGPARAM("FIELD_SEQ_BEGIN") ) && // e.g. date field doesn't have data! // currently assuming that only url field, this is @@ -1116,7 +1116,7 @@ namespace slideshow pAct->GetDataSize() / sizeof(sal_Unicode) ) ) ); } - else if (pAct->GetComment().equalsIgnoreAsciiCaseAsciiL( + else if (pAct->GetComment().equalsIgnoreAsciiCaseL( RTL_CONSTASCII_STRINGPARAM("FIELD_SEQ_END")) && // pending end is expected: !maHyperlinkIndices.empty() && diff --git a/slideshow/source/engine/shapes/drawshapesubsetting.cxx b/slideshow/source/engine/shapes/drawshapesubsetting.cxx index b474c05ad8a4..919280b56dae 100644 --- a/slideshow/source/engine/shapes/drawshapesubsetting.cxx +++ b/slideshow/source/engine/shapes/drawshapesubsetting.cxx @@ -91,14 +91,14 @@ namespace slideshow MetaCommentAction* pAct = static_cast(pCurrAct); // skip comment if not a special XTEXT comment - if( pAct->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XTEXT")) ) + if( pAct->GetComment().equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XTEXT")) ) { // fill classification vector with NOOPs, // then insert corresponding classes at // the given index maActionClassVector.resize( nActionIndex+1, CLASS_NOOP ); - if( pAct->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XTEXT_EOC")) ) + if( pAct->GetComment().equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XTEXT_EOC")) ) { // special, because can happen // in-between of portions - set @@ -112,7 +112,7 @@ namespace slideshow maActionClassVector[ nIndex ] = CLASS_CHARACTER_CELL_END; } - else if( pAct->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XTEXT_EOW")) ) + else if( pAct->GetComment().equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XTEXT_EOW")) ) { // special, because can happen // in-between of portions - set @@ -126,7 +126,7 @@ namespace slideshow maActionClassVector[ nIndex ] = CLASS_WORD_END; } - else if( pAct->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM( "XTEXT_EOS" )) ) + else if( pAct->GetComment().equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM( "XTEXT_EOS" )) ) { // special, because can happen // in-between of portions - set @@ -140,19 +140,19 @@ namespace slideshow maActionClassVector[ nIndex ] = CLASS_SENTENCE_END; } - else if( pAct->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XTEXT_EOL")) ) + else if( pAct->GetComment().equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XTEXT_EOL")) ) { maActionClassVector[ nActionIndex ] = CLASS_LINE_END; } - else if( pAct->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XTEXT_EOP")) ) + else if( pAct->GetComment().equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XTEXT_EOP")) ) { maActionClassVector[ nActionIndex ] = CLASS_PARAGRAPH_END; } - else if( pAct->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XTEXT_PAINTSHAPE_END")) ) + else if( pAct->GetComment().equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XTEXT_PAINTSHAPE_END")) ) { maActionClassVector[ nActionIndex ] = CLASS_SHAPE_END; } - else if( pAct->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XTEXT_PAINTSHAPE_BEGIN")) ) + else if( pAct->GetComment().equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XTEXT_PAINTSHAPE_BEGIN")) ) { maActionClassVector[ nActionIndex ] = CLASS_SHAPE_START; } diff --git a/slideshow/source/engine/shapes/gdimtftools.cxx b/slideshow/source/engine/shapes/gdimtftools.cxx index ab85873ceb2c..77d8a0861bb5 100644 --- a/slideshow/source/engine/shapes/gdimtftools.cxx +++ b/slideshow/source/engine/shapes/gdimtftools.cxx @@ -481,10 +481,10 @@ bool getRectanglesFromScrollMtf( ::basegfx::B2DRectangle& o_rScrollRect, MetaCommentAction * pAct = static_cast(pCurrAct); // skip comment if not a special XTEXT comment - if (pAct->GetComment().equalsIgnoreAsciiCaseAsciiL( + if (pAct->GetComment().equalsIgnoreAsciiCaseL( RTL_CONSTASCII_STRINGPARAM("XTEXT") )) { - if (pAct->GetComment().equalsIgnoreAsciiCaseAsciiL( + if (pAct->GetComment().equalsIgnoreAsciiCaseL( RTL_CONSTASCII_STRINGPARAM("XTEXT_SCROLLRECT") )) { o_rScrollRect = ::vcl::unotools::b2DRectangleFromRectangle( @@ -493,7 +493,7 @@ bool getRectanglesFromScrollMtf( ::basegfx::B2DRectangle& o_rScrollRect, bScrollRectSet = true; } - else if (pAct->GetComment().equalsIgnoreAsciiCaseAsciiL( + else if (pAct->GetComment().equalsIgnoreAsciiCaseL( RTL_CONSTASCII_STRINGPARAM("XTEXT_PAINTRECT")) ) { o_rPaintRect = ::vcl::unotools::b2DRectangleFromRectangle( diff --git a/svx/source/svdraw/svdfmtf.cxx b/svx/source/svdraw/svdfmtf.cxx index 9fe3753ef64b..c3a3fa2503c1 100644 --- a/svx/source/svdraw/svdfmtf.cxx +++ b/svx/source/svdraw/svdfmtf.cxx @@ -956,7 +956,7 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaCommentAction& rAct, GDIMetaFile* pM { ByteString aSkipComment; - if (rAct.GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_BEGIN"))) + if (rAct.GetComment().equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_BEGIN"))) { MetaGradientExAction* pAct = (MetaGradientExAction*) pMtf->NextAction(); diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx index 50ae86268e0c..852e7ffac16c 100644 --- a/vcl/source/gdi/pdfwriter_impl2.cxx +++ b/vcl/source/gdi/pdfwriter_impl2.cxx @@ -523,7 +523,7 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa const MetaCommentAction* pA = (const MetaCommentAction*) pAction; String aSkipComment; - if( pA->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_BEGIN"))) + if( pA->GetComment().equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_BEGIN"))) { const MetaGradientExAction* pGradAction = NULL; sal_Bool bDone = sal_False; @@ -535,7 +535,7 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa if( pAction->GetType() == META_GRADIENTEX_ACTION ) pGradAction = (const MetaGradientExAction*) pAction; else if( ( pAction->GetType() == META_COMMENT_ACTION ) && - ( ( (const MetaCommentAction*) pAction )->GetComment().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_END"))) ) + ( ( (const MetaCommentAction*) pAction )->GetComment().equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_END"))) ) { bDone = sal_True; } -- cgit From 9cb9ddbfb7d1baa4a3ac259354079c6e88429e69 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sun, 30 Oct 2011 21:30:31 +0000 Subject: callcatcher: remove unused appendStr --- unusedcode.easy | 1 - vcl/generic/print/psputil.cxx | 8 -------- vcl/generic/print/psputil.hxx | 1 - 3 files changed, 10 deletions(-) diff --git a/unusedcode.easy b/unusedcode.easy index 747291b7714e..b09d11b6ce0b 100644 --- a/unusedcode.easy +++ b/unusedcode.easy @@ -2561,7 +2561,6 @@ psp::PrinterGfx::SetFallbackFont(int) psp::PrinterJob::GetDocumentHeader() psp::PrinterJob::GetDocumentTrailer() psp::PrinterJob::GetErrorCode() -psp::appendStr(char const*, char*, int) pyuno::Runtime::finalize() pyuno::importToGlobal(_object*, _object*, _object*) rptui::OFieldExpressionControl::LinkStubAsynchActivate(void*, void*) diff --git a/vcl/generic/print/psputil.cxx b/vcl/generic/print/psputil.cxx index 2664bac8d022..7f60cdb48726 100644 --- a/vcl/generic/print/psputil.cxx +++ b/vcl/generic/print/psputil.cxx @@ -142,14 +142,6 @@ appendStr (const sal_Char* pSrc, sal_Char* pDst) return nBytes; } -sal_Int32 -appendStr (const sal_Char* pSrc, sal_Char* pDst, sal_Int32 nBytes) -{ - strncpy (pDst, pSrc, nBytes); - pDst [nBytes] = '\0'; - return nBytes; -} - /* * copy strings to file */ diff --git a/vcl/generic/print/psputil.hxx b/vcl/generic/print/psputil.hxx index 2aaffda6519f..718e46d5a5b7 100644 --- a/vcl/generic/print/psputil.hxx +++ b/vcl/generic/print/psputil.hxx @@ -49,7 +49,6 @@ sal_Int32 getHexValueOf (sal_Int32 nValue, sal_Char* pBuffer); sal_Int32 getAlignedHexValueOf (sal_Int32 nValue, sal_Char* pBuffer); sal_Int32 getValueOf (sal_Int32 nValue, sal_Char* pBuffer); sal_Int32 appendStr (const sal_Char* pSrc, sal_Char* pDst); -sal_Int32 appendStr (const sal_Char* pSrc, sal_Char* pDst, sal_Int32 nBytes); sal_Bool WritePS (osl::File* pFile, const sal_Char* pString); sal_Bool WritePS (osl::File* pFile, const sal_Char* pString, sal_uInt64 nInLength); -- cgit From c5e280b4144d3ed642404079f464a42829be3f80 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sun, 30 Oct 2011 21:32:28 +0000 Subject: intermediate String objects are completely unnecessary here --- filter/source/flash/swfdialog.cxx | 4 +--- filter/source/pdf/pdfexport.cxx | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/filter/source/flash/swfdialog.cxx b/filter/source/flash/swfdialog.cxx index 6520341f60e9..d86bfe2fd57f 100644 --- a/filter/source/flash/swfdialog.cxx +++ b/filter/source/flash/swfdialog.cxx @@ -101,9 +101,7 @@ Reference< XInterface > SAL_CALL SWFDialog_createInstance( const Reference< XMul SWFDialog::SWFDialog( const Reference< XMultiServiceFactory > &rxMSF ) : OGenericUnoDialog( rxMSF ) { - ByteString aResMgrName( "flash" ); - - mpResMgr = ResMgr::CreateResMgr( aResMgrName.GetBuffer(), Application::GetSettings().GetUILocale() ); + mpResMgr = ResMgr::CreateResMgr( "flash", Application::GetSettings().GetUILocale() ); } // ----------------------------------------------------------------------------- diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx index 9e1d4efa3487..302909f04c84 100644 --- a/filter/source/pdf/pdfexport.cxx +++ b/filter/source/pdf/pdfexport.cxx @@ -886,8 +886,7 @@ sal_Bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue if ( mxStatusIndicator.is() ) { - ByteString aResMgrName( "pdffilter" ); - ResMgr* pResMgr = ResMgr::CreateResMgr( aResMgrName.GetBuffer(), Application::GetSettings().GetUILocale() ); + ResMgr* pResMgr = ResMgr::CreateResMgr( "pdffilter", Application::GetSettings().GetUILocale() ); if ( pResMgr ) { sal_Int32 nTotalPageCount = aRangeEnum.size(); -- cgit From 4d01a82f370b695b585d59393a461643c1b17001 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sun, 30 Oct 2011 21:33:09 +0000 Subject: intermediate String objects are completely unnecessary here --- filter/source/graphicfilter/eps/eps.cxx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/filter/source/graphicfilter/eps/eps.cxx b/filter/source/graphicfilter/eps/eps.cxx index c26f3eb79a96..a7e03e69edde 100644 --- a/filter/source/graphicfilter/eps/eps.cxx +++ b/filter/source/graphicfilter/eps/eps.cxx @@ -306,10 +306,9 @@ sal_Bool PSWriter::WritePS( const Graphic& rGraphic, SvStream& rTargetStream, Fi // try to get the dialog selection if ( pFilterConfigItem ) { - ByteString aResMgrName( "eps" ); ResMgr* pResMgr; - pResMgr = ResMgr::CreateResMgr( aResMgrName.GetBuffer(), Application::GetSettings().GetUILocale() ); + pResMgr = ResMgr::CreateResMgr( "eps", Application::GetSettings().GetUILocale() ); if( pResMgr ) { @@ -454,9 +453,8 @@ sal_Bool PSWriter::WritePS( const Graphic& rGraphic, SvStream& rTargetStream, Fi if ( mbStatus && mnLevelWarning && pFilterConfigItem ) { - ByteString aResMgrName( "eps" ); ResMgr* pResMgr; - pResMgr = ResMgr::CreateResMgr( aResMgrName.GetBuffer(), Application::GetSettings().GetUILocale() ); + pResMgr = ResMgr::CreateResMgr( "eps", Application::GetSettings().GetUILocale() ); if( pResMgr ) { InfoBox aInfoBox( NULL, String( ResId( KEY_VERSION_CHECK, *pResMgr ) ) ); -- cgit From ace697180bf5eafee062209eef0abab455349160 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sun, 30 Oct 2011 21:43:00 +0000 Subject: ByteString->rtl::OString --- filter/source/graphicfilter/eos2met/eos2met.cxx | 15 +++++++------ filter/source/graphicfilter/eps/eps.cxx | 30 ++++++++++++------------- filter/source/graphicfilter/ieps/ieps.cxx | 2 +- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/filter/source/graphicfilter/eos2met/eos2met.cxx b/filter/source/graphicfilter/eos2met/eos2met.cxx index 8d874303b56f..fffe2ebb4ebe 100644 --- a/filter/source/graphicfilter/eos2met/eos2met.cxx +++ b/filter/source/graphicfilter/eos2met/eos2met.cxx @@ -492,11 +492,12 @@ void METWriter::WriteChrSets() *pMET << (sal_uInt8)0x03 << (sal_uInt8)0x52; *pMET << (sal_uInt8)0x24 << (sal_uInt8)0x02 << (sal_uInt8)0x08 << (sal_uInt8)0x00; - ByteString n(pCS->aName, gsl_getSystemTextEncoding()); + rtl::OString n(rtl::OUStringToOString(pCS->aName, + osl_getThreadTextEncoding())); for (i=0; i<32; i++) { if ( i == 0 || c != 0 ) - c = n.GetChar( i ); + c = n[i]; *pMET << c; } } @@ -1384,14 +1385,14 @@ void METWriter::METPartialArcAtCurPos(Point aCenter, double fMultiplier, void METWriter::METChrStr( Point aPt, String aUniStr ) { - sal_uInt16 nLen,i; - ByteString aStr( aUniStr, gsl_getSystemTextEncoding() ); - nLen = aStr.Len(); + rtl::OString aStr(rtl::OUStringToOString(aUniStr, + osl_getThreadTextEncoding())); + sal_uInt16 nLen = aStr.getLength(); WillWriteOrder( 11 + nLen ); *pMET << (sal_uInt8)0xc3 << (sal_uInt8)( 9 + nLen ); WritePoint(aPt); - for ( i = 0; i < nLen; i++ ) - *pMET << aStr.GetChar( i ); + for (sal_uInt16 i = 0; i < nLen; ++i) + *pMET << aStr[i]; *pMET << (sal_uInt8)0; } diff --git a/filter/source/graphicfilter/eps/eps.cxx b/filter/source/graphicfilter/eps/eps.cxx index a7e03e69edde..369c50fdedaf 100644 --- a/filter/source/graphicfilter/eps/eps.cxx +++ b/filter/source/graphicfilter/eps/eps.cxx @@ -225,7 +225,7 @@ private: void ImplText( const String& rUniString, const Point& rPos, const sal_Int32* pDXArry, sal_Int32 nWidth, VirtualDevice& rVDev ); void ImplSetAttrForText( const Point & rPoint ); void ImplWriteCharacter( sal_Char ); - void ImplWriteString( const ByteString&, VirtualDevice& rVDev, const sal_Int32* pDXArry = NULL, sal_Bool bStretch = sal_False ); + void ImplWriteString( const rtl::OString&, VirtualDevice& rVDev, const sal_Int32* pDXArry = NULL, sal_Bool bStretch = sal_False ); void ImplDefineFont( const char*, const char* ); void ImplClosePathDraw( sal_uLong nMode = PS_RET ); @@ -1274,11 +1274,11 @@ void PSWriter::ImplWriteActions( const GDIMetaFile& rMtf, VirtualDevice& rVDev ) { SvMemoryStream aMemStm( (void*)pData, pA->GetDataSize(), STREAM_READ ); sal_Bool bSkipSequence = sal_False; - ByteString sSeqEnd; + rtl::OString sSeqEnd; if( pA->GetComment().equalsL(RTL_CONSTASCII_STRINGPARAM( "XPATHSTROKE_SEQ_BEGIN" )) ) { - sSeqEnd = ByteString( "XPATHSTROKE_SEQ_END" ); + sSeqEnd = rtl::OString(RTL_CONSTASCII_STRINGPARAM("XPATHSTROKE_SEQ_END")); SvtGraphicStroke aStroke; aMemStm >> aStroke; @@ -1314,7 +1314,7 @@ void PSWriter::ImplWriteActions( const GDIMetaFile& rMtf, VirtualDevice& rVDev ) } else if (pA->GetComment().equalsL(RTL_CONSTASCII_STRINGPARAM("XPATHFILL_SEQ_BEGIN"))) { - sSeqEnd = ByteString( "XPATHFILL_SEQ_END" ); + sSeqEnd = rtl::OString(RTL_CONSTASCII_STRINGPARAM("XPATHFILL_SEQ_END")); SvtGraphicFill aFill; aMemStm >> aFill; switch( aFill.getFillType() ) @@ -1425,8 +1425,8 @@ void PSWriter::ImplWriteActions( const GDIMetaFile& rMtf, VirtualDevice& rVDev ) pMA = rMtf.GetAction( nCurAction ); if ( pMA->GetType() == META_COMMENT_ACTION ) { - ByteString sComment( ((MetaCommentAction*)pMA)->GetComment() ); - if ( sComment.Equals( sSeqEnd ) ) + rtl::OString sComment( ((MetaCommentAction*)pMA)->GetComment() ); + if ( sComment.equals( sSeqEnd ) ) break; } } @@ -2042,32 +2042,31 @@ void PSWriter::ImplWriteCharacter( sal_Char nChar ) //--------------------------------------------------------------------------------- -void PSWriter::ImplWriteString( const ByteString& rString, VirtualDevice& rVDev, const sal_Int32* pDXArry, sal_Bool bStretch ) +void PSWriter::ImplWriteString( const rtl::OString& rString, VirtualDevice& rVDev, const sal_Int32* pDXArry, sal_Bool bStretch ) { - sal_uInt16 nLen = rString.Len(); + sal_Int32 nLen = rString.getLength(); if ( nLen ) { - sal_uInt16 i; if ( pDXArry ) { double nx = 0; - for( i = 0; i < nLen; i++ ) + for (sal_Int32 i = 0; i < nLen; ++i) { if ( i > 0 ) nx = pDXArry[ i - 1 ]; - ImplWriteDouble( ( bStretch ) ? nx : rVDev.GetTextWidth( rString.GetChar( i ) ) ); + ImplWriteDouble( ( bStretch ) ? nx : rVDev.GetTextWidth( rString[i] ) ); ImplWriteDouble( nx ); ImplWriteLine( "(", PS_NONE ); - ImplWriteCharacter( rString.GetChar( i ) ); + ImplWriteCharacter( rString[i] ); ImplWriteLine( ") bs" ); } } else { ImplWriteByte( '(', PS_NONE ); - for ( i = 0; i < nLen; i++ ) - ImplWriteCharacter( rString.GetChar( i ) ); + for (sal_Int32 i = 0; i < nLen; ++i) + ImplWriteCharacter( rString[i] ); ImplWriteLine( ") sw" ); } } @@ -2128,7 +2127,8 @@ void PSWriter::ImplText( const String& rUniString, const Point& rPos, const sal_ if ( mnTextMode == 2 ) // forcing output one complete text packet, by pDXArry = NULL; // ignoring the kerning array ImplSetAttrForText( rPos ); - ByteString aStr( rUniString, maFont.GetCharSet() ); + rtl::OString aStr(rtl::OUStringToOString(rUniString, + maFont.GetCharSet())); ImplWriteString( aStr, rVDev, pDXArry, nWidth != 0 ); if ( maFont.GetOrientation() ) ImplWriteLine( "gr" ); diff --git a/filter/source/graphicfilter/ieps/ieps.cxx b/filter/source/graphicfilter/ieps/ieps.cxx index 4ecb41590997..9a1e6e59fcd7 100644 --- a/filter/source/graphicfilter/ieps/ieps.cxx +++ b/filter/source/graphicfilter/ieps/ieps.cxx @@ -380,7 +380,7 @@ static bool RenderAsPNG(const sal_uInt8* pBuf, sal_uInt32 nBytesRead, Graphic &r void CreateMtfReplacementAction( GDIMetaFile& rMtf, SvStream& rStrm, sal_uInt32 nOrigPos, sal_uInt32 nPSSize, sal_uInt32 nPosWMF, sal_uInt32 nSizeWMF, sal_uInt32 nPosTIFF, sal_uInt32 nSizeTIFF ) { - ByteString aComment( (const sal_Char*)"EPSReplacementGraphic" ); + rtl::OString aComment(RTL_CONSTASCII_STRINGPARAM("EPSReplacementGraphic")); if ( nSizeWMF || nSizeTIFF ) { SvMemoryStream aReplacement( nSizeWMF + nSizeTIFF + 28 ); -- cgit From e547f8ca4cb0c91a65b263b655c23a2f4ae65d8b Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 31 Oct 2011 10:51:52 +0000 Subject: strip out some more unused automation --- automation/source/testtool/objtest.cxx | 6 ------ automation/source/testtool/objtest.hxx | 1 - unusedcode.easy | 1 - 3 files changed, 8 deletions(-) diff --git a/automation/source/testtool/objtest.cxx b/automation/source/testtool/objtest.cxx index dd1ceab1f53c..6659f663da5c 100644 --- a/automation/source/testtool/objtest.cxx +++ b/automation/source/testtool/objtest.cxx @@ -128,12 +128,6 @@ DBG_CTOR(ControlItem,0); pData->aUId = aUIdP; } -ControlItem::ControlItem( ControlData *pDataP ) -{ -DBG_CTOR(ControlItem,0); - pData = pDataP; -} - ControlSon::~ControlSon() { if (pSons) diff --git a/automation/source/testtool/objtest.hxx b/automation/source/testtool/objtest.hxx index f4aa1b0cbb4c..afcb6b963b6d 100644 --- a/automation/source/testtool/objtest.hxx +++ b/automation/source/testtool/objtest.hxx @@ -120,7 +120,6 @@ public: ControlItem( const char *Name, rtl::OString aUIdP ); ControlItem( const String &Name, rtl::OString aUIdP ); - ControlItem( ControlData *pDataP ); virtual ~ControlItem() { DBG_DTOR(ControlItem,0); delete pData; diff --git a/unusedcode.easy b/unusedcode.easy index b09d11b6ce0b..8b5c2e2f8d26 100644 --- a/unusedcode.easy +++ b/unusedcode.easy @@ -84,7 +84,6 @@ CommunicationLinkList::Insert(CommunicationLink const**, unsigned short) CommunicationLinkList::Insert(CommunicationLinkList const*, unsigned short, unsigned short) CommunicationLinkList::Remove(CommunicationLink const*&, unsigned short) Control::GetLineCount() const -ControlItem::ControlItem(ControlData*) CurrencyBox::CurrencyBox(Window*, ResId const&) CurrencyBox::GetValue(unsigned short) const CurrencyBox::GetValuePos(long) const -- cgit From 91220fc0ebffacd6cbcc2fdbede48ea37009e2a0 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 31 Oct 2011 10:58:21 +0000 Subject: callcatcher: unused Drop code --- editeng/inc/editeng/editview.hxx | 4 ---- editeng/source/editeng/editview.cxx | 16 ---------------- unusedcode.easy | 3 --- 3 files changed, 23 deletions(-) diff --git a/editeng/inc/editeng/editview.hxx b/editeng/inc/editeng/editview.hxx index 9346ac7bfbdc..31f08248ff9c 100644 --- a/editeng/inc/editeng/editview.hxx +++ b/editeng/inc/editeng/editview.hxx @@ -148,10 +148,6 @@ public: sal_Bool MouseMove( const MouseEvent& rMouseEvent ); void Command( const CommandEvent& rCEvt ); - sal_Bool Drop( const DropEvent& rEvt ); - sal_Bool QueryDrop( DropEvent& rEvt ); - ESelection GetDropPos(); - void Cut(); void Copy(); void Paste(); diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx index b0df9d0aab35..919e40ffd77b 100644 --- a/editeng/source/editeng/editview.cxx +++ b/editeng/source/editeng/editview.cxx @@ -746,22 +746,6 @@ void EditView::InsertText( ::com::sun::star::uno::Reference< ::com::sun::star::d PIMPEE->FormatAndUpdate( this ); } -sal_Bool EditView::Drop( const DropEvent& ) -{ - return sal_False; -} - -ESelection EditView::GetDropPos() -{ - OSL_FAIL( "GetDropPos - Why?!" ); - return ESelection(); -} - -sal_Bool EditView::QueryDrop( DropEvent& ) -{ - return sal_False; -} - void EditView::SetEditEngineUpdateMode( sal_Bool bUpdate ) { DBG_CHKTHIS( EditView, 0 ); diff --git a/unusedcode.easy b/unusedcode.easy index 8b5c2e2f8d26..cecf1456adf9 100644 --- a/unusedcode.easy +++ b/unusedcode.easy @@ -138,11 +138,8 @@ EditEngine::SetBigTextObjectStart(unsigned short) EditEngine::SetGroupChars(String const&) EditEngine::SetText(unsigned short, EditTextObject const&) EditEngine::StopSelectionMode() -EditView::Drop(DropEvent const&) -EditView::GetDropPos() EditView::GetSelectionMode() const EditView::MatchGroup() -EditView::QueryDrop(DropEvent&) EditView::SetCursor(Cursor const&) EditView::SetParaAttribs(SfxItemSet const&, unsigned short) EditView::SetPointer(Pointer const&) -- cgit From 3c95b2c39ae635f3fb9a4f06d41188d5139ff411 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 31 Oct 2011 15:20:53 +0000 Subject: drop GetImageIds --- unusedcode.easy | 1 - vcl/inc/vcl/image.hxx | 1 - vcl/source/gdi/image.cxx | 17 ----------------- 3 files changed, 19 deletions(-) diff --git a/unusedcode.easy b/unusedcode.easy index cecf1456adf9..fddda51431c2 100644 --- a/unusedcode.easy +++ b/unusedcode.easy @@ -212,7 +212,6 @@ IconChoiceDialog::RemoveResetButton() IconChoiceDialog::RemoveTabPage(unsigned short) ImageButton::ImageButton(unsigned short) ImageList::Clear() -ImageList::GetImageIds(std::__debug::vector >&) const ImageList::RemoveImage(rtl::OUString const&) ImageList::ReplaceImage(rtl::OUString const&, rtl::OUString const&) ImageList::ReplaceImage(unsigned short, Image const&) diff --git a/vcl/inc/vcl/image.hxx b/vcl/inc/vcl/image.hxx index 301af44bead9..3c96eea4d6c7 100644 --- a/vcl/inc/vcl/image.hxx +++ b/vcl/inc/vcl/image.hxx @@ -148,7 +148,6 @@ public: sal_uInt16 GetImagePos( const ::rtl::OUString& rImageName ) const; sal_uInt16 GetImageId( sal_uInt16 nPos ) const; - void GetImageIds( ::std::vector< sal_uInt16 >& rIds ) const; ::rtl::OUString GetImageName( sal_uInt16 nPos ) const; void GetImageNames( ::std::vector< ::rtl::OUString >& rNames ) const; diff --git a/vcl/source/gdi/image.cxx b/vcl/source/gdi/image.cxx index f587bc29d2e9..ad7f84d48eb5 100644 --- a/vcl/source/gdi/image.cxx +++ b/vcl/source/gdi/image.cxx @@ -824,23 +824,6 @@ sal_uInt16 ImageList::GetImageId( sal_uInt16 nPos ) const // ----------------------------------------------------------------------- -void ImageList::GetImageIds( ::std::vector< sal_uInt16 >& rIds ) const -{ - RTL_LOGFILE_CONTEXT( aLog, "vcl: ImageList::GetImageIds" ); - - DBG_CHKTHIS( ImageList, NULL ); - - rIds = ::std::vector< sal_uInt16 >(); - - if( mpImplData ) - { - for( sal_uInt32 i = 0; i < mpImplData->maImages.size(); i++ ) - rIds.push_back( mpImplData->maImages[i]->mnId ); - } -} - -// ----------------------------------------------------------------------- - ::rtl::OUString ImageList::GetImageName( sal_uInt16 nPos ) const { DBG_CHKTHIS( ImageList, NULL ); -- cgit From d01ee468d84a32a83747fb0afdc267e5fd2288c8 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 31 Oct 2011 15:26:27 +0000 Subject: wrong lib name for old-style makefile.mks --- solenv/inc/libs.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solenv/inc/libs.mk b/solenv/inc/libs.mk index 91161f19ecce..17d482501dc6 100644 --- a/solenv/inc/libs.mk +++ b/solenv/inc/libs.mk @@ -308,7 +308,7 @@ PYUNOLIB=-lpyuno LPSOLVELIB=-llpsolve55 SOFFICELIB=-lsofficeapp UNOPKGAPPLIB=-lunopkgapp -TESTLIB=-lunotest +TESTLIB=-ltest UNOTESTLIB=-lunotest XMLREADERLIB=-lxmlreader -- cgit From 8be381cf6662e97579c804ec022da085d370829c Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 31 Oct 2011 22:47:04 +0000 Subject: catch by const ref --- sfx2/source/bastyp/fltfnc.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sfx2/source/bastyp/fltfnc.cxx b/sfx2/source/bastyp/fltfnc.cxx index 63add660c327..2d347781f585 100644 --- a/sfx2/source/bastyp/fltfnc.cxx +++ b/sfx2/source/bastyp/fltfnc.cxx @@ -988,7 +988,7 @@ void SfxFilterContainer::ReadSingleFilter_Impl( { aResult = xTypeCFG->getByName( sType ); } - catch( ::com::sun::star::container::NoSuchElementException& ) + catch (const ::com::sun::star::container::NoSuchElementException&) { aResult = ::com::sun::star::uno::Any(); } @@ -1156,7 +1156,7 @@ void SfxFilterContainer::ReadFilters_Impl( sal_Bool bUpdate ) } } } - catch( ::com::sun::star::uno::Exception& ) + catch(const ::com::sun::star::uno::Exception&) { DBG_ASSERT( sal_False, "SfxFilterContainer::ReadFilter()\nException detected. Possible not all filters could be cached.\n" ); } -- cgit From f1f6f30bac305115fdf58fc4f2ecabaf236a519c Mon Sep 17 00:00:00 2001 From: Tomas Chvatal Date: Tue, 1 Nov 2011 10:59:38 +0100 Subject: When building with gconf check for orbit too. This avoids build error like: Entering /var/tmp/portage/app-office/libreoffice-3.4.3.2-r1/work/libreoffice-bootstrap-3.4.3.2/shell/source/backends/gconfbe Package ORBit-2.0 was not found in the pkg-config search path. Perhaps you should add the directory containing `ORBit-2.0.pc' to the PKG_CONFIG_PATH environment variable No package 'ORBit-2.0' found dmake: Error code 1, while making 'Shell escape' Also update gvfs check to require gconf switch enabled instead of running pkgconfig again. --- configure.in | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/configure.in b/configure.in index 65b81c124b56..b1c9e1870cc9 100644 --- a/configure.in +++ b/configure.in @@ -6956,7 +6956,7 @@ AC_MSG_CHECKING([whether to enable GConf support]) if test "$_os" != "WINNT" -a "$_os" != "Darwin" -a "$enable_gconf" = "yes"; then ENABLE_GCONF="TRUE" AC_MSG_RESULT([yes]) - PKG_CHECK_MODULES( GCONF, gconf-2.0 ) + PKG_CHECK_MODULES( GCONF, gconf-2.0 orbit-2.0 ) else AC_MSG_RESULT([no]) fi @@ -6968,13 +6968,10 @@ dnl =================================================================== ENABLE_GNOMEVFS="" AC_MSG_CHECKING([whether to enable GNOME VFS support]) -if test "$_os" != "WINNT" -a "$_os" != "Darwin" -a "$enable_gnome_vfs" = "yes"; then +if test "$_os" != "WINNT" -a "$_os" != "Darwin" -a "$enable_gnome_vfs" = "yes" -a "$enable_gconf" = "yes"; then ENABLE_GNOMEVFS="TRUE" AC_MSG_RESULT([yes]) PKG_CHECK_MODULES( GNOMEVFS, gnome-vfs-2.0 >= 2.6.0 ) - if test "$ENABLE_GCONF" != "TRUE"; then - PKG_CHECK_MODULES( GCONF, gconf-2.0 ) - fi else AC_MSG_RESULT([no]) fi -- cgit From 055995086474821207313bacabe50bd9b9d7774c Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 1 Nov 2011 11:14:16 +0100 Subject: Made ooinstall more deterministic, fixed Mac OS X Python module dependencies. --- scp2/source/python/module_python.scp | 21 +++++++++++++++++++++ solenv/bin/make_installer.pl | 3 ++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/scp2/source/python/module_python.scp b/scp2/source/python/module_python.scp index d80bc1663a76..32f0dc8def4b 100644 --- a/scp2/source/python/module_python.scp +++ b/scp2/source/python/module_python.scp @@ -34,7 +34,28 @@ Module gid_Module_Optional_Pyuno MOD_NAME_DESC ( MODULE_OPTIONAL_PYTHON ); ParentID = gid_Module_Optional; Sortkey = "750"; + Dirs = (gid_Dir_PythonFramework, + gid_Dir_PythonFramework_Versions, + gid_Dir_PythonFramework_Versions_ver, + gid_Dir_PythonFramework_Versions_ver_bin, + gid_Dir_PythonFramework_Versions_ver_lib, + gid_Dir_PythonFramework_Versions_ver_lib_pythonver, + gid_Dir_PythonFramework_Versions_ver_lib_pythonver_config); Files = (gid_File_Pyuno,gid_File_Lib_Pyuno,gid_File_Lib_Pythonloader,gid_File_Py_Unohelper,gid_File_Py_Officehelper,gid_File_Py_Uno,gid_File_Py_Pythonloader,gid_File_Py_Python_Core,gid_File_Py_Python_Bin,gid_File_Lib_Python_So,gid_Shortcut_Lib_Python_So,gid_File_Scripts_Python,gid_File_Share_Registry_Pyuno_Xcd); + Unixlinks = (gid_Unixlink_Python_Headers, + gid_Unixlink_Python_Resources, + gid_Unixlink_Python_Versions_Current, + gid_Unixlink_Python_Versions_ver_Headers, + gid_Unixlink_Python_OOoPython, + gid_Unixlink_Python_bin_idle, + gid_Unixlink_Python_bin_pydoc, + gid_Unixlink_Python_bin_python_real, + gid_Unixlink_Python_bin_python, + gid_Unixlink_Python_bin_pythonconfig, + gid_Unixlink_Python_bin_pythonw_real, + gid_Unixlink_Python_bin_pythonw, + gid_Unixlink_Python_bin_smtpdpy, + gid_Unixlink_Python_libpython); Minimal = NO; Default = YES; Styles = ( ); diff --git a/solenv/bin/make_installer.pl b/solenv/bin/make_installer.pl index fd1df27ee834..10dac770fd63 100644 --- a/solenv/bin/make_installer.pl +++ b/solenv/bin/make_installer.pl @@ -1309,7 +1309,8 @@ for ( my $n = 0; $n <= $#installer::globals::languageproducts; $n++ ) my $found_epm = 0; # shuffle array to reduce parallel packaging process in pool - installer::worker::shuffle_array($packages); + installer::worker::shuffle_array($packages) + unless $installer::globals::simple; # iterating over all packages for ( my $k = 0; $k <= $#{$packages}; $k++ ) -- cgit From 7cac55174385bb278c4ae979bcf31f106072798e Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 1 Nov 2011 10:37:18 +0000 Subject: case matters --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index b1c9e1870cc9..6052587e70d8 100644 --- a/configure.in +++ b/configure.in @@ -6956,7 +6956,7 @@ AC_MSG_CHECKING([whether to enable GConf support]) if test "$_os" != "WINNT" -a "$_os" != "Darwin" -a "$enable_gconf" = "yes"; then ENABLE_GCONF="TRUE" AC_MSG_RESULT([yes]) - PKG_CHECK_MODULES( GCONF, gconf-2.0 orbit-2.0 ) + PKG_CHECK_MODULES( GCONF, gconf-2.0 ORBit-2.0 ) else AC_MSG_RESULT([no]) fi -- cgit From 75c1a8033a876b711c7b360565c99f831dd9d2e8 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Tue, 1 Nov 2011 09:56:55 +0000 Subject: WaE: various sillies flagged by MSVC++ --- cui/source/dialogs/about.cxx | 8 -------- cui/source/inc/cuitabarea.hxx | 1 + cui/source/options/optinet2.cxx | 28 ++++++++++++++-------------- filter/source/svg/svgreader.cxx | 2 +- sfx2/source/appl/appmisc.cxx | 40 +++------------------------------------- 5 files changed, 19 insertions(+), 60 deletions(-) diff --git a/cui/source/dialogs/about.cxx b/cui/source/dialogs/about.cxx index 0d77033cc2d7..b987b4af08ed 100644 --- a/cui/source/dialogs/about.cxx +++ b/cui/source/dialogs/about.cxx @@ -65,14 +65,6 @@ using namespace ::com::sun::star; #define SPACE_OFFSET 5 #define SCROLL_TIMER 30 -/** loads the application logo as used in the about dialog and impress slideshow pause screen */ -Image SfxApplication::GetApplicationLogo() -{ - BitmapEx aBitmap; - Application::LoadBrandBitmap ("about", aBitmap); - return Image( aBitmap ); -} - /* get good version information */ static String GetBuildId() diff --git a/cui/source/inc/cuitabarea.hxx b/cui/source/inc/cuitabarea.hxx index 1f76ce0ad609..7bb13e2ecbb7 100644 --- a/cui/source/inc/cuitabarea.hxx +++ b/cui/source/inc/cuitabarea.hxx @@ -657,6 +657,7 @@ public: const ResId &aLoad, const ResId &aSave, const ResId &aEmbed, const ResId &aTableName, XPropertyListType t, XOutdevItemPool* mpXPool ); + virtual ~SvxLoadSaveEmbed() {}; XPropertyListRef GetList(); void HideLoadSaveEmbed(); bool GetEmbed(); diff --git a/cui/source/options/optinet2.cxx b/cui/source/options/optinet2.cxx index a8fe225571da..17a55efdd03a 100644 --- a/cui/source/options/optinet2.cxx +++ b/cui/source/options/optinet2.cxx @@ -315,15 +315,15 @@ void SvxProxyTabPage::ReadConfigData_Impl() } } - catch(container::NoSuchElementException &e) { + catch(container::NoSuchElementException &) { OSL_TRACE( "SvxProxyTabPage::ReadConfigData_Impl: NoSuchElementException caught" ); } - catch(com::sun::star::lang::WrappedTargetException &e) { + catch(com::sun::star::lang::WrappedTargetException &) { OSL_TRACE( "SvxProxyTabPage::ReadConfigData_Impl: WrappedTargetException caught" ); } - catch(RuntimeException &e) { + catch(RuntimeException &) { OSL_TRACE( "SvxProxyTabPage::ReadConfigData_Impl: RuntimeException caught" ); } @@ -373,16 +373,16 @@ void SvxProxyTabPage::ReadConfigDefaults_Impl() aNoProxyForED.SetText( aStringValue ); } } - catch(beans::UnknownPropertyException &e) + catch(beans::UnknownPropertyException &) { OSL_TRACE( "SvxProxyTabPage::RestoreConfigDefaults_Impl: UnknownPropertyException caught" ); } - catch(com::sun::star::lang::WrappedTargetException &e) { + catch(com::sun::star::lang::WrappedTargetException &) { OSL_TRACE( "SvxProxyTabPage::RestoreConfigDefaults_Impl: WrappedTargetException caught" ); } - catch(RuntimeException &e) + catch(RuntimeException &) { OSL_TRACE( "SvxProxyTabPage::RestoreConfigDefaults_Impl: RuntimeException caught" ); } @@ -407,16 +407,16 @@ void SvxProxyTabPage::RestoreConfigDefaults_Impl() xChangesBatch->commitChanges(); } - catch(beans::UnknownPropertyException &e) + catch(beans::UnknownPropertyException &) { OSL_TRACE( "SvxProxyTabPage::RestoreConfigDefaults_Impl: UnknownPropertyException caught" ); } - catch(com::sun::star::lang::WrappedTargetException &e) { + catch(com::sun::star::lang::WrappedTargetException &) { OSL_TRACE( "SvxProxyTabPage::RestoreConfigDefaults_Impl: WrappedTargetException caught" ); } - catch(RuntimeException &e) + catch(RuntimeException &) { OSL_TRACE( "SvxProxyTabPage::RestoreConfigDefaults_Impl: RuntimeException caught" ); } @@ -512,23 +512,23 @@ sal_Bool SvxProxyTabPage::FillItemSet(SfxItemSet& ) xChangesBatch->commitChanges(); } - catch(com::sun::star::lang::IllegalArgumentException &e) { + catch(com::sun::star::lang::IllegalArgumentException &) { OSL_TRACE( "SvxProxyTabPage::FillItemSet: IllegalArgumentException caught" ); } - catch(beans::UnknownPropertyException &e) { + catch(beans::UnknownPropertyException &) { OSL_TRACE( "SvxProxyTabPage::FillItemSet: UnknownPropertyException caught" ); } - catch(beans::PropertyVetoException &e) { + catch(beans::PropertyVetoException &) { OSL_TRACE( "SvxProxyTabPage::FillItemSet: PropertyVetoException caught" ); } - catch(com::sun::star::lang::WrappedTargetException &e) { + catch(com::sun::star::lang::WrappedTargetException &) { OSL_TRACE( "SvxProxyTabPage::FillItemSet: WrappedTargetException caught" ); } - catch(RuntimeException &e) { + catch(RuntimeException &) { OSL_TRACE( "SvxProxyTabPage::FillItemSet: RuntimeException caught" ); } diff --git a/filter/source/svg/svgreader.cxx b/filter/source/svg/svgreader.cxx index 6b66c5081509..07f3a16b2bcf 100644 --- a/filter/source/svg/svgreader.cxx +++ b/filter/source/svg/svgreader.cxx @@ -2433,7 +2433,7 @@ struct ShapeRenderingVisitor if( !maCurrState.maFontStyle.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("normal")) ) aFont.SetItalic(ITALIC_NORMAL); // TODO: discriminate - if( !maCurrState.mnFontWeight != 400.0 ) + if( maCurrState.mnFontWeight != 400.0 ) aFont.SetWeight(WEIGHT_BOLD); // TODO: discriminate // extract basic transformations out of CTM diff --git a/sfx2/source/appl/appmisc.cxx b/sfx2/source/appl/appmisc.cxx index fffecd3f348e..ee0b8da9d9c1 100644 --- a/sfx2/source/appl/appmisc.cxx +++ b/sfx2/source/appl/appmisc.cxx @@ -309,43 +309,9 @@ static bool impl_loadBitmap( /** loads the application logo as used in the about dialog and impress slideshow pause screen */ Image SfxApplication::GetApplicationLogo() { - Image aAppLogo; - - rtl::OUString aAbouts; - bool bLoaded = false; - sal_Int32 nIndex = 0; - do - { - bLoaded = impl_loadBitmap( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("$BRAND_BASE_DIR/program")), - aAbouts.getToken( 0, ',', nIndex ), aAppLogo ); - } - while ( !bLoaded && ( nIndex >= 0 ) ); - - // fallback to "about.bmp" - if ( !bLoaded ) - { - bLoaded = impl_loadBitmap( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("$BRAND_BASE_DIR/program/edition")), - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("about.png")), aAppLogo ); - if ( !bLoaded ) - bLoaded = impl_loadBitmap( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("$BRAND_BASE_DIR/program/edition")), - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("about.bmp")), aAppLogo ); - } - - if ( !bLoaded ) - { - bLoaded = impl_loadBitmap( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("$BRAND_BASE_DIR/program")), - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("about.png")), aAppLogo ); - if ( !bLoaded ) - bLoaded = impl_loadBitmap( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("$BRAND_BASE_DIR/program")), - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("about.bmp")), aAppLogo ); - } - - return aAppLogo; + BitmapEx aBitmap; + Application::LoadBrandBitmap ("about", aBitmap); + return Image( aBitmap ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit From cca7126c2908c5b9b6693326a3861bb96fae1be3 Mon Sep 17 00:00:00 2001 From: Bjoern Michaelsen Date: Fri, 28 Oct 2011 02:26:43 +0200 Subject: very,very ugly hack to get the soffice.bin name the previous solution couldnt work: - Packages are toplevel targets, so they need to be in a separate file - However, Packages should not be used here as it interferes with the pattern rules on $(OUTDIR)/bin - replacing those instead with explicit (non-pattern) rules for this exceptional case - depending from the regular target in $(OUTDIR) on the special one - depending from the special target on the $(WORKDIR) one --- desktop/Executable_soffice.bin.mk | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/desktop/Executable_soffice.bin.mk b/desktop/Executable_soffice.bin.mk index 7731aefd6e1e..3953b26508b6 100644 --- a/desktop/Executable_soffice.bin.mk +++ b/desktop/Executable_soffice.bin.mk @@ -69,13 +69,25 @@ $(eval $(call gb_Executable_add_noexception_objects,$(sofficebin),\ desktop/win32/source/extendloaderenvironment \ )) -# the resulting executable is called soffice_bin.exe, copy it to soffice.bin -$(eval $(call gb_Package_Package,$(sofficebin),$(OUTDIR)/bin)) -$(eval $(call gb_Package_add_file,$(sofficebin),bin/soffice.bin,$(sofficebin).exe)) +$(call gb_Executable_get_target,$(sofficebin)) : $(OUTDIR)/bin/soffice.bin +$(call gb_Executable_get_clean_target,$(sofficebin)) : $(WORKDIR)/Clean/OutDir/bin/soffice.bin +$(OUTDIR)/bin/soffice.bin : $(call gb_LinkTarget_get_target,$(call gb_Executable_get_linktargetname,$(sofficebin))) + $(call gb_Deliver_deliver,$<,$@) + +.PHONY : $(WORKDIR)/Clean/OutDir/bin/soffice.bin +$(WORKDIR)/Clean/OutDir/bin/soffice.bin : + rm $(OUTDIR)/bin/soffice.bin ifeq ($(COM),MSC) -# also copy the manifest -$(eval $(call gb_Package_add_file,$(sofficebin),bin/soffice.bin.manifest,$(sofficebin).exe.manifest)) +$(call gb_Executable_get_target,$(sofficebin)) : $(OUTDIR)/bin/soffice.bin.manifest +$(call gb_Executable_get_clean_target,$(sofficebin)) : $(WORKDIR)/Clean/OutDir/bin/soffice.bin.manifest +$(OUTDIR)/bin/soffice.bin.manifest : $(call gb_LinkTarget_get_target,$(call gb_Executable_get_linktargetname,$(sofficebin))).manifest $(call gb_LinkTarget_get_target,$(call gb_Executable_get_linktargetname,$(sofficebin))) + $(call gb_Deliver_deliver,$<,$@) + +.PHONY : $(WORKDIR)/Clean/OutDir/bin/soffice.bin.manifest +$(WORKDIR)/Clean/OutDir/bin/soffice.bin.manifest : + rm $(OUTDIR)/bin/soffice.bin.manifest + endif endif -- cgit From f7303fcac779f99931bfba48e8bfcf9c081af67f Mon Sep 17 00:00:00 2001 From: Daniel Di Marco Date: Sat, 29 Oct 2011 13:24:48 +0200 Subject: eliminate SvUShorts type --- cui/source/dialogs/iconcdlg.cxx | 29 ++++++++------------------- cui/source/inc/cfg.hxx | 3 --- cui/source/inc/selector.hxx | 3 --- editeng/inc/editeng/svxrtf.hxx | 16 +++++++-------- editeng/source/rtf/rtfitem.cxx | 16 +++++++-------- editeng/source/rtf/svxrtf.cxx | 31 ++++++++++++++--------------- fpicker/source/office/iodlgimp.hxx | 1 - sfx2/inc/sfx2/app.hxx | 3 +-- sfx2/inc/sfx2/dispatch.hxx | 3 --- sfx2/inc/sfx2/evntconf.hxx | 2 -- sfx2/inc/sfx2/macrconf.hxx | 4 +--- sfx2/source/appl/appmisc.cxx | 12 ++++++------ sfx2/source/appl/workwin.cxx | 40 +++++++++++++++++++------------------- sfx2/source/control/dispatch.cxx | 6 +++--- sfx2/source/control/macrconf.cxx | 8 ++++---- sfx2/source/dialog/tabdlg.cxx | 36 +++++++++++----------------------- sfx2/source/dialog/templdlg.cxx | 12 ++++++------ sfx2/source/doc/docvor.cxx | 16 ++++++--------- sfx2/source/inc/appdata.hxx | 4 ++-- sfx2/source/inc/templdgi.hxx | 5 +---- sfx2/source/inc/workwin.hxx | 4 +--- svl/inc/svl/svarray.hxx | 1 - svl/inc/svl/svstdarr.hxx | 6 ------ svl/source/memtools/svarray.cxx | 2 -- svtools/inc/svtools/svparser.hxx | 4 ++-- svtools/source/svrtf/svparser.cxx | 12 ++++++++---- sw/inc/node.hxx | 1 - sw/source/core/docnode/ndtbl1.cxx | 12 ++++++------ sw/source/core/fields/expfld.cxx | 10 +++++----- sw/source/core/fields/reffld.cxx | 4 +--- sw/source/core/undo/untbl.cxx | 12 ++++++------ sw/source/filter/html/htmlform.cxx | 15 +++++++------- sw/source/filter/html/htmltab.cxx | 26 ++++++++++++------------- sw/source/filter/html/svxcss1.cxx | 6 +++--- sw/source/filter/html/svxcss1.hxx | 4 ++-- sw/source/filter/html/swhtml.cxx | 24 +++++++++++------------ sw/source/filter/html/swhtml.hxx | 7 ++----- sw/source/filter/rtf/rtffly.cxx | 18 ++++++++--------- sw/source/filter/rtf/swparrtf.cxx | 14 ++++++------- sw/source/filter/ww8/wrtw8esh.cxx | 12 ++++++------ sw/source/filter/ww8/wrtww8.hxx | 2 +- sw/source/ui/uiview/viewsrch.cxx | 23 +++++++++++----------- xmloff/inc/xmloff/xmlexppr.hxx | 5 ++--- xmloff/source/style/xmlexppr.cxx | 21 +++++++++----------- 44 files changed, 214 insertions(+), 281 deletions(-) diff --git a/cui/source/dialogs/iconcdlg.cxx b/cui/source/dialogs/iconcdlg.cxx index 51e9f1d91bbb..99e0c6d7e7ce 100644 --- a/cui/source/dialogs/iconcdlg.cxx +++ b/cui/source/dialogs/iconcdlg.cxx @@ -30,8 +30,6 @@ #include #include -#define _SVSTDARR_USHORTS -#include #include #include "iconcdlg.hxx" @@ -45,11 +43,6 @@ using ::std::vector; -int SAL_CALL IconcDlgCmpUS_Impl( const void* p1, const void* p2 ) -{ - return *(sal_uInt16*)p1 - *(sal_uInt16*)p2; -} - // some stuff for easier changes for SvtViewOptions static const sal_Char* pViewOptDataName = "dialog data"; #define VIEWOPT_DATANAME ::rtl::OUString::createFromAscii( pViewOptDataName ) @@ -962,7 +955,7 @@ const sal_uInt16* IconChoiceDialog::GetInputRanges( const SfxItemPool& rPool ) if ( pRanges ) return pRanges; - SvUShorts aUS( 16, 16 ); + std::vector aUS; size_t nCount = maPageList.size(); for ( size_t i = 0; i < nCount; ++i ) @@ -976,32 +969,26 @@ const sal_uInt16* IconChoiceDialog::GetInputRanges( const SfxItemPool& rPool ) sal_uInt16 nLen; for( nLen = 0; *pIter; ++nLen, ++pIter ) ; - aUS.Insert( pTmpRanges, nLen, aUS.Count() ); + aUS.insert( aUS.end(), pTmpRanges, pTmpRanges + nLen ); } } // remove double Id's { - nCount = aUS.Count(); + nCount = aUS.size(); for ( size_t i = 0; i < nCount; ++i ) aUS[i] = rPool.GetWhich( aUS[i] ); } // sortieren - if ( aUS.Count() > 1 ) + if ( aUS.size() > 1 ) { -#if defined __SUNPRO_CC -#pragma disable_warn -#endif - qsort( (void*)aUS.GetData(), aUS.Count(), sizeof(sal_uInt16), IconcDlgCmpUS_Impl ); -#if defined __SUNPRO_CC -#pragma enable_warn -#endif + std::sort( aUS.begin(), aUS.end() ); } - pRanges = new sal_uInt16[aUS.Count() + 1]; - memcpy(pRanges, aUS.GetData(), sizeof(sal_uInt16) * aUS.Count()); - pRanges[aUS.Count()] = 0; + pRanges = new sal_uInt16[aUS.size() + 1]; + std::copy( aUS.begin(), aUS.end(), pRanges ); + pRanges[aUS.size()] = 0; return pRanges; } diff --git a/cui/source/inc/cfg.hxx b/cui/source/inc/cfg.hxx index dfcbc59da534..9bb95b62eafe 100644 --- a/cui/source/inc/cfg.hxx +++ b/cui/source/inc/cfg.hxx @@ -49,9 +49,6 @@ #include #include -#define _SVSTDARR_USHORTS -#define _SVSTDARR_STRINGSDTOR -#include // SvUShorts #include #include #include diff --git a/cui/source/inc/selector.hxx b/cui/source/inc/selector.hxx index 2959b0e7bfb6..d7c6641f2367 100644 --- a/cui/source/inc/selector.hxx +++ b/cui/source/inc/selector.hxx @@ -39,9 +39,6 @@ #include #include -#define _SVSTDARR_USHORTS -#define _SVSTDARR_STRINGSDTOR -#include // SvUShorts #include #define SVX_CFGGROUP_FUNCTION 1 diff --git a/editeng/inc/editeng/svxrtf.hxx b/editeng/inc/editeng/svxrtf.hxx index f1e932134eac..125ce5535a3f 100644 --- a/editeng/inc/editeng/svxrtf.hxx +++ b/editeng/inc/editeng/svxrtf.hxx @@ -34,8 +34,6 @@ #include #include -#define _SVSTDARR_sal_uInt16S -#include #include #include @@ -231,9 +229,9 @@ class EDITENG_DLLPUBLIC SvxRTFParser : public SvRTFParser SvxRTFItemStack aAttrStack; SvxRTFItemStackList aAttrSetList; - SvUShorts aPlainMap; - SvUShorts aPardMap; - SvUShorts aWhichMap; + std::vector aPlainMap; + std::vector aPardMap; + std::vector aWhichMap; String sBaseURL; SvxPosition* pInsPos; @@ -360,8 +358,8 @@ protected: // Query/Set the mapping IDs for the Pard/Plain attributes //(Set: It is noted in the pointers, which thus does not create a copy) - void AddPardAttr( sal_uInt16 nWhich ) { aPardMap.Insert( nWhich, aPardMap.Count() ); } - void AddPlainAttr( sal_uInt16 nWhich ) { aPlainMap.Insert( nWhich, aPlainMap.Count() ); } + void AddPardAttr( sal_uInt16 nWhich ) { aPardMap.push_back( nWhich ); } + void AddPlainAttr( sal_uInt16 nWhich ) { aPlainMap.push_back( nWhich ); } SvxRTFStyleTbl& GetStyleTbl() { return aStyleTbl; } SvxRTFItemStack& GetAttrStack() { return aAttrStack; } @@ -393,9 +391,9 @@ public: void SetAttrPool( SfxItemPool* pNewPool ) { pAttrPool = pNewPool; } // to set different WhichIds for a different pool. RTFPardAttrMapIds& GetPardMap() - { return (RTFPardAttrMapIds&)*aPardMap.GetData(); } + { return (RTFPardAttrMapIds&)*aPardMap.begin(); } RTFPlainAttrMapIds& GetPlainMap() - { return (RTFPlainAttrMapIds&)*aPlainMap.GetData(); } + { return (RTFPlainAttrMapIds&)*aPlainMap.begin(); } // to be able to assign them from the outside as for example table cells void ReadBorderAttr( int nToken, SfxItemSet& rSet, int bTableDef=sal_False ); void ReadBackgroundAttr( int nToken, SfxItemSet& rSet, int bTableDef=sal_False ); diff --git a/editeng/source/rtf/rtfitem.cxx b/editeng/source/rtf/rtfitem.cxx index d97c05b3d67f..e04113ef6a87 100644 --- a/editeng/source/rtf/rtfitem.cxx +++ b/editeng/source/rtf/rtfitem.cxx @@ -109,14 +109,14 @@ inline const SvxLRSpaceItem& GetLRSpace(const SfxItemSet& rSet,sal_uInt16 nId,sa inline const SvxULSpaceItem& GetULSpace(const SfxItemSet& rSet,sal_uInt16 nId,sal_Bool bInP=sal_True) { return (const SvxULSpaceItem&)rSet.Get( nId,bInP); } -#define PARDID ((RTFPardAttrMapIds*)aPardMap.GetData()) -#define PLAINID ((RTFPlainAttrMapIds*)aPlainMap.GetData()) +#define PARDID ((RTFPardAttrMapIds*)&aPardMap[0]) +#define PLAINID ((RTFPlainAttrMapIds*)&aPlainMap[0]) void SvxRTFParser::SetScriptAttr( RTF_CharTypeDef eType, SfxItemSet& rSet, SfxPoolItem& rItem ) { const sal_uInt16 *pNormal = 0, *pCJK = 0, *pCTL = 0; - const RTFPlainAttrMapIds* pIds = (RTFPlainAttrMapIds*)aPlainMap.GetData(); + const RTFPlainAttrMapIds* pIds = (RTFPlainAttrMapIds*)&aPlainMap[0]; switch( rItem.Which() ) { case SID_ATTR_CHAR_FONT: @@ -1761,13 +1761,13 @@ void SvxRTFParser::RTFPardPlain( int bPard, SfxItemSet** ppSet ) if( bPard ) { pAkt->nStyleNo = 0; - pPtr = aPardMap.GetData(); - nCnt = aPardMap.Count(); + pPtr = &aPardMap[0]; + nCnt = aPardMap.size(); } else { - pPtr = aPlainMap.GetData(); - nCnt = aPlainMap.Count(); + pPtr = &aPlainMap[0]; + nCnt = aPlainMap.size(); } for( sal_uInt16 n = 0; n < nCnt; ++n, ++pPtr ) @@ -1827,7 +1827,7 @@ void SvxRTFParser::SetDefault( int nToken, int nValue ) if( !bNewDoc ) return; - SfxItemSet aTmp( *pAttrPool, aWhichMap.GetData() ); + SfxItemSet aTmp( *pAttrPool, &aWhichMap[0] ); sal_Bool bOldFlag = bIsLeftToRightDef; bIsLeftToRightDef = sal_True; switch( nToken ) diff --git a/editeng/source/rtf/svxrtf.cxx b/editeng/source/rtf/svxrtf.cxx index e24905345aea..beec9c66a21b 100644 --- a/editeng/source/rtf/svxrtf.cxx +++ b/editeng/source/rtf/svxrtf.cxx @@ -94,13 +94,13 @@ SvxRTFParser::SvxRTFParser( SfxItemPool& rPool, SvStream& rIn, { RTFPlainAttrMapIds aTmp( rPool ); - aPlainMap.Insert( (sal_uInt16*)&aTmp, - sizeof( RTFPlainAttrMapIds ) / sizeof(sal_uInt16), 0 ); + aPlainMap.insert( aPlainMap.begin(), (sal_uInt16*)&aTmp, + (sal_uInt16*)&aTmp + (sizeof( RTFPlainAttrMapIds ) / sizeof(sal_uInt16)) ); } { RTFPardAttrMapIds aTmp( rPool ); - aPardMap.Insert( (sal_uInt16*)&aTmp, - sizeof( RTFPardAttrMapIds ) / sizeof(sal_uInt16), 0 ); + aPardMap.insert( aPardMap.begin(), (sal_uInt16*)&aTmp, + (sal_uInt16*)&aTmp + (sizeof( RTFPardAttrMapIds ) / sizeof(sal_uInt16)) ); } pDfltFont = new Font; pDfltColor = new Color; @@ -340,7 +340,7 @@ void SvxRTFParser::ReadStyleTable() int nToken, bSaveChkStyleAttr = bChkStyleAttr; short nStyleNo = 0; int _nOpenBrakets = 1; // the first was already detected earlier!! - SvxRTFStyleType* pStyle = new SvxRTFStyleType( *pAttrPool, aWhichMap.GetData() ); + SvxRTFStyleType* pStyle = new SvxRTFStyleType( *pAttrPool, &aWhichMap[0] ); pStyle->aAttrSet.Put( GetRTFDefaults() ); bIsInReadStyleTab = sal_True; @@ -396,7 +396,7 @@ void SvxRTFParser::ReadStyleTable() } // All data from the font is available, so off to the table aStyleTbl.Insert( nStyleNo, pStyle ); - pStyle = new SvxRTFStyleType( *pAttrPool, aWhichMap.GetData() ); + pStyle = new SvxRTFStyleType( *pAttrPool, &aWhichMap[0] ); pStyle->aAttrSet.Put( GetRTFDefaults() ); nStyleNo = 0; } @@ -841,7 +841,7 @@ const Font& SvxRTFParser::GetFont( sal_uInt16 nId ) { const SvxFontItem& rDfltFont = (const SvxFontItem&) pAttrPool->GetDefaultItem( - ((RTFPlainAttrMapIds*)aPlainMap.GetData())->nFont ); + ((RTFPlainAttrMapIds*)&aPlainMap[0])->nFont ); pDfltFont->SetName( rDfltFont.GetStyleName() ); pDfltFont->SetFamily( rDfltFont.GetFamily() ); pFont = pDfltFont; @@ -856,7 +856,7 @@ SvxRTFItemStackType* SvxRTFParser::_GetAttrSet( int bCopyAttr ) if( pAkt ) pNew = new SvxRTFItemStackType( *pAkt, *pInsPos, bCopyAttr ); else - pNew = new SvxRTFItemStackType( *pAttrPool, aWhichMap.GetData(), + pNew = new SvxRTFItemStackType( *pAttrPool, &aWhichMap[0], *pInsPos ); pNew->SetRTFDefaults( GetRTFDefaults() ); @@ -982,7 +982,7 @@ void SvxRTFParser::AttrGroupEnd() // process the current, delete from Stack pNew->aAttrSet.SetParent( pOld->aAttrSet.GetParent() ); // Delete all paragraph attributes from pNew - for( sal_uInt16 n = 0; n < aPardMap.Count() && + for( sal_uInt16 n = 0; n < aPardMap.size() && pNew->aAttrSet.Count(); ++n ) if( aPardMap[n] ) pNew->aAttrSet.ClearItem( aPardMap[n] ); @@ -1132,24 +1132,23 @@ void SvxRTFParser::SetAttrInDoc( SvxRTFItemStackType & ) void SvxRTFParser::BuildWhichTbl() { - if( aWhichMap.Count() ) - aWhichMap.Remove( 0, aWhichMap.Count() ); - aWhichMap.Insert( (sal_uInt16)0, (sal_uInt16)0 ); + aWhichMap.clear(); + aWhichMap.push_back( 0 ); // Building a Which-Map 'rWhichMap' from an Array of // 'pWhichIds' frm Which-Ids. It has the long 'nWhichIds'. // The Which-Map is not going to be deleted. - SvParser::BuildWhichTbl( aWhichMap, (sal_uInt16*)aPardMap.GetData(), aPardMap.Count() ); - SvParser::BuildWhichTbl( aWhichMap, (sal_uInt16*)aPlainMap.GetData(), aPlainMap.Count() ); + SvParser::BuildWhichTbl( aWhichMap, (sal_uInt16*)&aPardMap[0], aPardMap.size() ); + SvParser::BuildWhichTbl( aWhichMap, (sal_uInt16*)&aPlainMap[0], aPlainMap.size() ); } const SfxItemSet& SvxRTFParser::GetRTFDefaults() { if( !pRTFDefaults ) { - pRTFDefaults = new SfxItemSet( *pAttrPool, aWhichMap.GetData() ); + pRTFDefaults = new SfxItemSet( *pAttrPool, &aWhichMap[0] ); sal_uInt16 nId; - if( 0 != ( nId = ((RTFPardAttrMapIds*)aPardMap.GetData())->nScriptSpace )) + if( 0 != ( nId = ((RTFPardAttrMapIds*)&aPardMap[0])->nScriptSpace )) { SvxScriptSpaceItem aItem( sal_False, nId ); if( bNewDoc ) diff --git a/fpicker/source/office/iodlgimp.hxx b/fpicker/source/office/iodlgimp.hxx index 2cc4f71edcc1..1048bc3092a7 100644 --- a/fpicker/source/office/iodlgimp.hxx +++ b/fpicker/source/office/iodlgimp.hxx @@ -45,7 +45,6 @@ class Accelerator; class CheckBox; class SvtFileDialog; class SvStringsDtor; -class SvUShorts; //***************************************************************************** diff --git a/sfx2/inc/sfx2/app.hxx b/sfx2/inc/sfx2/app.hxx index 87c32f5a3c9d..c255035f8f03 100644 --- a/sfx2/inc/sfx2/app.hxx +++ b/sfx2/inc/sfx2/app.hxx @@ -88,7 +88,6 @@ class SfxViewShellArr_Impl; class StarBASIC; class SfxWorkWindow; class SfxFilterMatcher; -class SvUShorts; class SfxModule; class SfxModuleArr_Impl; class Window; @@ -269,7 +268,7 @@ public: SAL_DLLPRIVATE SfxWorkWindow* GetWorkWindow_Impl(const SfxViewFrame *pFrame=0) const; // TODO/CLEANUP: still needed? - SAL_DLLPRIVATE SvUShorts* GetDisabledSlotList_Impl(); + SAL_DLLPRIVATE std::vector* GetDisabledSlotList_Impl(); SAL_DLLPRIVATE SfxSlotPool& GetAppSlotPool_Impl() const; SAL_DLLPRIVATE SfxModule* GetModule_Impl(); SAL_DLLPRIVATE ResMgr* GetOffResManager_Impl(); diff --git a/sfx2/inc/sfx2/dispatch.hxx b/sfx2/inc/sfx2/dispatch.hxx index 0ce4f2ba16c4..0591d1fb5c9a 100644 --- a/sfx2/inc/sfx2/dispatch.hxx +++ b/sfx2/inc/sfx2/dispatch.hxx @@ -34,9 +34,6 @@ #include -#define _SVSTDARR_USHORTS -#include // SvUShorts - #include #include diff --git a/sfx2/inc/sfx2/evntconf.hxx b/sfx2/inc/sfx2/evntconf.hxx index 89fef8d61687..5bb5f17453e9 100644 --- a/sfx2/inc/sfx2/evntconf.hxx +++ b/sfx2/inc/sfx2/evntconf.hxx @@ -35,8 +35,6 @@ #include #include -#define _SVSTDARR_USHORTS -#include // SvUShorts #include #include diff --git a/sfx2/inc/sfx2/macrconf.hxx b/sfx2/inc/sfx2/macrconf.hxx index 60692b4c49a6..1957b11f5cac 100644 --- a/sfx2/inc/sfx2/macrconf.hxx +++ b/sfx2/inc/sfx2/macrconf.hxx @@ -32,8 +32,6 @@ #include "sfx2/dllapi.h" #include "sal/types.h" #include -#define _SVSTDARR_USHORTS -#include // SvUShorts #include class SfxMacroInfo; @@ -106,7 +104,7 @@ friend class SfxEventConfiguration; SAL_DLLPRIVATE static SfxMacroConfig* pMacroConfig; SfxMacroConfig_Impl* pImp; - SvUShorts aIdArray; + std::vector aIdArray; public: SfxMacroConfig(); diff --git a/sfx2/source/appl/appmisc.cxx b/sfx2/source/appl/appmisc.cxx index ee0b8da9d9c1..119b8a5101ae 100644 --- a/sfx2/source/appl/appmisc.cxx +++ b/sfx2/source/appl/appmisc.cxx @@ -170,10 +170,10 @@ SfxProgress* SfxApplication::GetProgress() const //------------------------------------------------------------------------ -SvUShorts* SfxApplication::GetDisabledSlotList_Impl() +std::vector* SfxApplication::GetDisabledSlotList_Impl() { sal_Bool bError = sal_False; - SvUShorts* pList = pAppData_Impl->pDisabledSlotList; + std::vector* pList = pAppData_Impl->pDisabledSlotList; if ( !pList ) { // Is there a slot file? @@ -200,13 +200,13 @@ SvUShorts* SfxApplication::GetDisabledSlotList_Impl() sal_uInt16 nCount; (*pStream) >> nCount; pList = pAppData_Impl->pDisabledSlotList = - new SvUShorts( nCount < 255 ? (sal_Int8) nCount : 255, 255 ); + new std::vector; sal_uInt16 nSlot; for ( sal_uInt16 n=0; n> nSlot; - pList->Insert( nSlot, n ); + pList->push_back( nSlot ); } pStream->ReadByteString(aTitle); @@ -231,13 +231,13 @@ SvUShorts* SfxApplication::GetDisabledSlotList_Impl() delete pStream; } - else if ( pList == (SvUShorts*) -1L ) + else if ( pList == (std::vector*) -1L ) { return NULL; } if ( !pList ) - pAppData_Impl->pDisabledSlotList = (SvUShorts*) -1L; + pAppData_Impl->pDisabledSlotList = (std::vector*) -1L; if ( bError ) { diff --git a/sfx2/source/appl/workwin.cxx b/sfx2/source/appl/workwin.cxx index bdd2c417a36e..2ea9a9f2d922 100644 --- a/sfx2/source/appl/workwin.cxx +++ b/sfx2/source/appl/workwin.cxx @@ -516,18 +516,18 @@ sal_uInt16 ChildTravelValue( SfxChildAlignment eAlign ) void SfxWorkWindow::Sort_Impl() { - aSortedList.Remove(0, aSortedList.Count()); + aSortedList.clear(); for (sal_uInt16 i=0; iCount(); i++) { SfxChild_Impl *pCli = (*pChilds)[i]; if (pCli) { sal_uInt16 k; - for (k=0; keAlign) > ChildAlignValue(pCli->eAlign)) break; - aSortedList.Insert (i,k); + aSortedList.insert( aSortedList.begin() + k, i ); } } @@ -825,7 +825,7 @@ SvBorder SfxWorkWindow::Arrange_Impl() Size aSize; Rectangle aTmp( aClientArea ); - for ( sal_uInt16 n=0; npWin ) @@ -1786,7 +1786,7 @@ void SfxWorkWindow::ConfigChild_Impl(SfxChildIdentifier eChild, SfxChild_Impl *pChild = 0; sal_uInt16 n; - for ( n=0; neAlign == SFX_ALIGN_NOALIGNMENT) || (IsDockingAllowed() && bInternalDockingAllowed) ) @@ -2553,7 +2553,7 @@ void SfxWorkWindow::MakeChildsVisible_Impl( sal_Bool bVis ) { if ( !bSorted ) Sort_Impl(); - for ( sal_uInt16 n=0; nnVisible &= ~CHILD_ACTIVE; @@ -2761,37 +2761,37 @@ void SfxWorkWindow::SetActiveChild_Impl( Window *pChild ) sal_Bool SfxWorkWindow::ActivateNextChild_Impl( sal_Bool bForward ) { // Sort all children under list - SvUShorts aList; + std::vector aList; for ( sal_uInt16 i=SFX_OBJECTBAR_MAX; iCount(); i++) { SfxChild_Impl *pCli = (*pChilds)[i]; if ( pCli && pCli->bCanGetFocus && pCli->pWin ) { sal_uInt16 k; - for (k=0; keAlign) > ChildTravelValue(pCli->eAlign) ) break; - aList.Insert(i,k); + aList.insert( aList.begin() + k, i ); } } - if ( aList.Count() == 0 ) + if ( aList.empty() ) return sal_False; sal_uInt16 nTopValue = ChildTravelValue( SFX_ALIGN_LOWESTTOP ); - for ( sal_uInt16 i=0; ipWin && ChildTravelValue( pCli->eAlign ) > nTopValue ) break; } - sal_uInt16 n = bForward ? 0 : aList.Count()-1; + sal_uInt16 n = bForward ? 0 : aList.size()-1; SfxChild_Impl *pAct=NULL; if ( pActiveChild ) { // Look for the active window - for ( n=0; npWin && ( pCli->pWin == pActiveChild || !pActiveChild ) ) @@ -2803,8 +2803,8 @@ sal_Bool SfxWorkWindow::ActivateNextChild_Impl( sal_Bool bForward ) } // dummy entries for the container window - aList.Insert( 0xFFFF, 0 ); - aList.Insert( 0xFFFF, aList.Count() ); + aList.insert( aList.begin(), 0xFFFF ); + aList.push_back( 0xFFFF ); n = n + 1; if ( pAct ) { @@ -2827,7 +2827,7 @@ sal_Bool SfxWorkWindow::ActivateNextChild_Impl( sal_Bool bForward ) else n = n-1; - if ( n == 0 || n == aList.Count()-1 ) + if ( n == 0 || n == aList.size()-1 ) return sal_False; } @@ -2865,7 +2865,7 @@ sal_Bool SfxWorkWindow::ActivateNextChild_Impl( sal_Bool bForward ) else n = n-1; - if ( n == 0 || n == aList.Count()-1 ) + if ( n == 0 || n == aList.size()-1 ) break; } diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx index 5aa16e163ff7..8df3b4a00a6a 100644 --- a/sfx2/source/control/dispatch.cxx +++ b/sfx2/source/control/dispatch.cxx @@ -164,7 +164,7 @@ struct SfxDispatcher_Impl sal_uInt16 nFilterCount; // Number of SIDs in pFilterSIDs const sal_uInt16* pFilterSIDs; // sorted Array of SIDs sal_uInt16 nStandardMode; // ExecuteMode from PlugInDispatcher - SvUShorts* pDisableList; + std::vector* pDisableList; sal_uInt32 nDisableFlags; }; @@ -2498,8 +2498,8 @@ sal_Bool SfxDispatcher::IsAllowed } // BinSearch in the disable list - SvUShorts& rList = *pImp->pDisableList; - sal_uInt16 nCount = rList.Count(); + std::vector& rList = *pImp->pDisableList; + sal_uInt16 nCount = rList.size(); sal_uInt16 nLow = 0, nMid = 0, nHigh; sal_Bool bFound = sal_False; nHigh = nCount - 1; diff --git a/sfx2/source/control/macrconf.cxx b/sfx2/source/control/macrconf.cxx index 1464ffe0abed..c02dc8fd45a6 100644 --- a/sfx2/source/control/macrconf.cxx +++ b/sfx2/source/control/macrconf.cxx @@ -447,7 +447,7 @@ sal_uInt16 SfxMacroConfig::GetSlotId(SfxMacroInfoPtr pInfo) if (i == nCount) { // Macro still unknown - nCount = aIdArray.Count(); + nCount = aIdArray.size(); sal_uInt16 n; for (n=0; n SID_MACRO_START + n) @@ -456,7 +456,7 @@ sal_uInt16 SfxMacroConfig::GetSlotId(SfxMacroInfoPtr pInfo) sal_uInt16 nNewSlotId = SID_MACRO_START + n; if ( nNewSlotId > SID_MACRO_END ) return 0; - aIdArray.Insert( SID_MACRO_START + n, n ); + aIdArray.insert( aIdArray.begin() + n, SID_MACRO_START + n ); SfxSlot *pNewSlot = new SfxSlot; pNewSlot->nSlotId = SID_MACRO_START + n; @@ -531,12 +531,12 @@ void SfxMacroConfig::ReleaseSlotId(sal_uInt16 nId) pImp->aArr.Remove(i); // Release SlotId again - sal_uInt16 nIdCount = aIdArray.Count(); + sal_uInt16 nIdCount = aIdArray.size(); for (sal_uInt16 n=0; n #include +#include #include #include -#define _SVSTDARR_sal_uInt16S -#include - #include "appdata.hxx" #include "sfxtypes.hxx" #include @@ -1453,19 +1451,6 @@ IMPL_LINK( SfxTabDialog, DeactivatePageHdl, TabControl *, pTabCtrl ) // ----------------------------------------------------------------------- -extern "C" int SAL_CALL TabDlgCmpUS_Impl( const void* p1, const void* p2 ) - -/* [Description] - - Comparison function for qsort -*/ - -{ - return *(sal_uInt16*)p1 - *(sal_uInt16*)p2; -} - -// ----------------------------------------------------------------------- - void SfxTabDialog::ShowPage( sal_uInt16 nId ) /* [Description] @@ -1509,7 +1494,7 @@ const sal_uInt16* SfxTabDialog::GetInputRanges( const SfxItemPool& rPool ) if ( pRanges ) return pRanges; - SvUShorts aUS( 16, 16 ); + std::vector aUS; sal_uInt16 nCount = pImpl->pData->Count(); sal_uInt16 i; @@ -1525,26 +1510,27 @@ const sal_uInt16* SfxTabDialog::GetInputRanges( const SfxItemPool& rPool ) sal_uInt16 nLen; for( nLen = 0; *pIter; ++nLen, ++pIter ) ; - aUS.Insert( pTmpRanges, nLen, aUS.Count() ); + aUS.insert( aUS.end(), pTmpRanges, pTmpRanges + nLen ); } } //! Remove duplicated Ids? { - nCount = aUS.Count(); + nCount = aUS.size(); for ( i = 0; i < nCount; ++i ) aUS[i] = rPool.GetWhich( aUS[i] ); } // sort - if ( aUS.Count() > 1 ) - qsort( (void*)aUS.GetData(), - aUS.Count(), sizeof(sal_uInt16), TabDlgCmpUS_Impl ); + if ( aUS.size() > 1 ) + { + std::sort( aUS.begin(), aUS.end() ); + } - pRanges = new sal_uInt16[aUS.Count() + 1]; - memcpy(pRanges, aUS.GetData(), sizeof(sal_uInt16) * aUS.Count()); - pRanges[aUS.Count()] = 0; + pRanges = new sal_uInt16[aUS.size() + 1]; + std::copy( aUS.begin(), aUS.end(), pRanges ); + pRanges[aUS.size()] = 0; return pRanges; } diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx index df6f09d76322..c9252483c975 100644 --- a/sfx2/source/dialog/templdlg.cxx +++ b/sfx2/source/dialog/templdlg.cxx @@ -2796,7 +2796,7 @@ void SfxTemplateCatalog_Impl::CheckItem(sal_uInt16 nMesId, sal_Bool /*bCheck*/) if ( nMesId > SFX_STYLE_FAMILY_PSEUDO || nMesId < SFX_STYLE_FAMILY_CHAR ) return; sal_uInt16 i; - for ( i = 0; i < aFamIds.Count() && aFamIds[i] != nMesId; i++ ) ; + for ( i = 0; i < aFamIds.size() && aFamIds[i] != nMesId; i++ ) ; aFamList.SelectEntryPos(i); } @@ -2807,7 +2807,7 @@ sal_Bool SfxTemplateCatalog_Impl::IsCheckedItem(sal_uInt16 nMesId) if ( nMesId > SFX_STYLE_FAMILY_PSEUDO || nMesId < SFX_STYLE_FAMILY_CHAR ) return sal_False; sal_uInt16 i; - for ( i = 0; i < aFamIds.Count() && aFamIds[i] != nMesId; i++ ) + for ( i = 0; i < aFamIds.size() && aFamIds[i] != nMesId; i++ ) ; return aFamList.IsEntrySelected( String::CreateFromInt32(i) ); } @@ -2818,10 +2818,10 @@ sal_Bool SfxTemplateCatalog_Impl::IsCheckedItem(sal_uInt16 nMesId) void SfxTemplateCatalog_Impl::EnableFamilyItem( sal_uInt16 nId, sal_Bool bEnable ) { if ( !bEnable ) - for ( sal_uInt16 nPos = aFamIds.Count(); nPos--; ) + for ( sal_uInt16 nPos = aFamIds.size(); nPos--; ) if ( aFamIds[ nPos ] == nId ) { - aFamIds.Remove( nPos ); + aFamIds.erase( aFamIds.begin() + nPos ); aFamList.RemoveEntry( nPos ); } } @@ -2831,13 +2831,13 @@ void SfxTemplateCatalog_Impl::InsertFamilyItem( sal_uInt16 nId, const SfxStyleFa if ( nId > SFX_STYLE_FAMILY_PSEUDO || nId < SFX_STYLE_FAMILY_CHAR ) return; aFamList.InsertEntry( pItem->GetText(), 0 ); - aFamIds.Insert( nId, 0 ); + aFamIds.insert( aFamIds.begin(), nId ); } void SfxTemplateCatalog_Impl::ClearFamilyList() { aFamList.Clear(); - aFamIds.Remove( 0, aFamIds.Count() ); + aFamIds.clear(); } void SfxTemplateCatalog_Impl::PrepareDeleteAction() diff --git a/sfx2/source/doc/docvor.cxx b/sfx2/source/doc/docvor.cxx index 0f9609f1c420..26b35dd8e16a 100644 --- a/sfx2/source/doc/docvor.cxx +++ b/sfx2/source/doc/docvor.cxx @@ -381,7 +381,7 @@ void ErrorDelete_Impl(Window *pParent, const String &rName, sal_Bool bFolder = s struct ImpPath_Impl { - SvUShorts aUS; + std::vector aUS; sal_uInt16 nRef; ImpPath_Impl(); @@ -390,7 +390,7 @@ struct ImpPath_Impl //------------------------------------------------------------------------- -ImpPath_Impl::ImpPath_Impl() : aUS(5), nRef(1) +ImpPath_Impl::ImpPath_Impl() : nRef(1) { } @@ -398,14 +398,9 @@ ImpPath_Impl::ImpPath_Impl() : aUS(5), nRef(1) ImpPath_Impl::ImpPath_Impl( const ImpPath_Impl& rCopy ) : - aUS ( (sal_uInt8)rCopy.aUS.Count() ), - nRef( 1 ) + aUS(rCopy.aUS), nRef( 1 ) { - const sal_uInt16 nCount = rCopy.aUS.Count(); - - for ( sal_uInt16 i = 0; i < nCount; ++i ) - aUS.Insert( rCopy.aUS[i], i ); } //========================================================================== @@ -442,7 +437,7 @@ public: if(!--pData->nRef) delete pData; } - sal_uInt16 Count() const { return pData->aUS.Count(); } + sal_uInt16 Count() const { return pData->aUS.size(); } sal_uInt16 operator[]( sal_uInt16 i ) const { return i < Count()? pData->aUS[i]: INDEX_IGNORE; @@ -459,7 +454,8 @@ Path::Path(SvLBox *pBox, SvLBoxEntry *pEntry) : return; SvLBoxEntry *pParent = pBox->GetParent(pEntry); do { - pData->aUS.Insert((sal_uInt16)pBox->GetModel()->GetRelPos(pEntry), 0); + pData->aUS.insert(pData->aUS.begin(), + (sal_uInt16)pBox->GetModel()->GetRelPos(pEntry)); if(0 == pParent) break; pEntry = pParent; diff --git a/sfx2/source/inc/appdata.hxx b/sfx2/source/inc/appdata.hxx index b807f5cd21a7..8783675fc40e 100644 --- a/sfx2/source/inc/appdata.hxx +++ b/sfx2/source/inc/appdata.hxx @@ -38,6 +38,7 @@ #include #include "bitset.hxx" +#include class SfxApplication; class SvStrings; @@ -50,7 +51,6 @@ class SfxMacroConfig; class SfxItemPool; class SfxInitLinkList; class SfxFilterMatcher; -class SvUShorts; class ISfxTemplateCommon; class SfxFilterMatcher; class SfxStatusDispatcher; @@ -124,7 +124,7 @@ public: // global pointers SfxItemPool* pPool; - SvUShorts* pDisabledSlotList; + std::vector* pDisabledSlotList; SvStrings* pSecureURLs; SvtSaveOptions* pSaveOptions; SvtUndoOptions* pUndoOptions; diff --git a/sfx2/source/inc/templdgi.hxx b/sfx2/source/inc/templdgi.hxx index 45e00a25a8e8..ea797bed53aa 100644 --- a/sfx2/source/inc/templdgi.hxx +++ b/sfx2/source/inc/templdgi.hxx @@ -37,9 +37,6 @@ class SfxTemplateControllerItem; #include #include -#define _SVSTDARR_USHORTS -#include // SvUShorts - #include #include @@ -344,7 +341,7 @@ private: HelpButton aHelpBtn; SfxTemplateCatalog* pReal; - SvUShorts aFamIds; + std::vector aFamIds; SfxModalDefParentHelper aHelper; protected: diff --git a/sfx2/source/inc/workwin.hxx b/sfx2/source/inc/workwin.hxx index eebc3412d11c..347147d2a835 100644 --- a/sfx2/source/inc/workwin.hxx +++ b/sfx2/source/inc/workwin.hxx @@ -38,8 +38,6 @@ #include #include -#define _SVSTDARR_sal_uInt16S -#include // SvUShorts #include #include @@ -234,7 +232,7 @@ class SfxWorkWindow friend class LayoutManagerListener; protected: - SvUShorts aSortedList; + std::vector aSortedList; SfxStatBar_Impl aStatBar; std::vector< SfxObjectBar_Impl > aObjBarList; Rectangle aClientArea; diff --git a/svl/inc/svl/svarray.hxx b/svl/inc/svl/svarray.hxx index a0db9033d734..4c8d077421ec 100644 --- a/svl/inc/svl/svarray.hxx +++ b/svl/inc/svl/svarray.hxx @@ -81,7 +81,6 @@ * Sortierung mit Hilfe der Object-operatoren "<" und "==" * * JP 09.10.96: vordefinierte Arrays: -* VarArr: SvUShorts * PtrArr: SvStrings, SvStringsDtor * SortArr: SvStringsSort, SvStringsSortDtor, * SvStringsISort, SvStringsISortDtor diff --git a/svl/inc/svl/svstdarr.hxx b/svl/inc/svl/svstdarr.hxx index 9df5b4bb0b54..50349f4b9a3a 100644 --- a/svl/inc/svl/svstdarr.hxx +++ b/svl/inc/svl/svstdarr.hxx @@ -32,7 +32,6 @@ * (die defines setzen sich aus "_SVSTDARR_" und dem Namen des Array * ohne "Sv" zusammen) * -* VarArr: SvUShorts * PtrArr: SvStrings, SvStringsDtor * SortArr: SvStringsSort, SvStringsSortDtor, * SvStringsISort, SvStringsISortDtor, @@ -42,11 +41,6 @@ #include #include -#ifndef _SVSTDARR_USHORTS_DECL -SV_DECL_VARARR_VISIBILITY( SvUShorts, sal_uInt16, 1, 1, SVL_DLLPUBLIC ) -#define _SVSTDARR_USHORTS_DECL -#endif - #include typedef String* StringPtr; diff --git a/svl/source/memtools/svarray.cxx b/svl/source/memtools/svarray.cxx index 7024640fbf2a..95df58a363a4 100644 --- a/svl/source/memtools/svarray.cxx +++ b/svl/source/memtools/svarray.cxx @@ -61,8 +61,6 @@ sal_uInt16 SvPtrarr::GetPos( const VoidPtr& aElement ) const return ( n >= nA ? USHRT_MAX : n ); } -SV_IMPL_VARARR( SvUShorts, sal_uInt16 ) - SV_IMPL_PTRARR( SvStrings, StringPtr ) SV_IMPL_PTRARR( SvStringsDtor, StringPtr ) SV_IMPL_OP_PTRARR_SORT( SvStringsSort, StringPtr ) diff --git a/svtools/inc/svtools/svparser.hxx b/svtools/inc/svtools/svparser.hxx index b82a5a85e36e..eac4a92a8f47 100644 --- a/svtools/inc/svtools/svparser.hxx +++ b/svtools/inc/svtools/svparser.hxx @@ -34,11 +34,11 @@ #include #include #include +#include struct SvParser_Impl; class SvStream; -class SvUShorts; enum SvParserState { @@ -174,7 +174,7 @@ public: // Aufbau einer Which-Map 'rWhichMap' aus einem Array von // 'pWhichIds' von Which-Ids. Es hat die Lange 'nWhichIds'. // Die Which-Map wird nicht geloescht. - static void BuildWhichTbl( SvUShorts &rWhichMap, + static void BuildWhichTbl( std::vector &rWhichMap, sal_uInt16 *pWhichIds, sal_uInt16 nWhichIds ); }; diff --git a/svtools/source/svrtf/svparser.cxx b/svtools/source/svrtf/svparser.cxx index 9cb6ba80f9ae..84ebfa492ce6 100644 --- a/svtools/source/svrtf/svparser.cxx +++ b/svtools/source/svrtf/svparser.cxx @@ -572,7 +572,7 @@ void SvParser::Continue( int ) { } -void SvParser::BuildWhichTbl( SvUShorts &rWhichMap, +void SvParser::BuildWhichTbl( std::vector &rWhichMap, sal_uInt16 *pWhichIds, sal_uInt16 nWhichIds ) { @@ -590,7 +590,7 @@ void SvParser::BuildWhichTbl( SvUShorts &rWhichMap, if( *pWhichIds < rWhichMap[nOfs] - 1 ) { // neuen Range davor - rWhichMap.Insert( aNewRange, 2, nOfs ); + rWhichMap.insert( rWhichMap.begin() + nOfs, aNewRange, aNewRange + 2 ); bIns = sal_False; break; } @@ -607,7 +607,8 @@ void SvParser::BuildWhichTbl( SvUShorts &rWhichMap, { // mit dem naechsten Bereich mergen rWhichMap[nOfs+1] = rWhichMap[nOfs+3]; - rWhichMap.Remove( nOfs+2, 2 ); + rWhichMap.erase( rWhichMap.begin() + nOfs + 2, + rWhichMap.begin() + nOfs + 4 ); } else // diesen Range nach oben erweitern @@ -619,7 +620,10 @@ void SvParser::BuildWhichTbl( SvUShorts &rWhichMap, // einen Range hinten anhaengen if( bIns ) - rWhichMap.Insert( aNewRange, 2, rWhichMap.Count()-1 ); + { + rWhichMap.insert( rWhichMap.begin() + rWhichMap.size() - 1, + aNewRange, aNewRange + 2 ); + } } } diff --git a/sw/inc/node.hxx b/sw/inc/node.hxx index 597f02e626a1..1ad155504eda 100644 --- a/sw/inc/node.hxx +++ b/sw/inc/node.hxx @@ -47,7 +47,6 @@ // forward declarations // --------------------- -class SvUShorts; class SwCntntFrm; class SwCntntNode; class SwDoc; diff --git a/sw/source/core/docnode/ndtbl1.cxx b/sw/source/core/docnode/ndtbl1.cxx index 5f66a3d17fbd..2067dd31e643 100644 --- a/sw/source/core/docnode/ndtbl1.cxx +++ b/sw/source/core/docnode/ndtbl1.cxx @@ -1301,7 +1301,7 @@ sal_uInt16 lcl_CalcCellFit( const SwLayoutFrm *pCell ) *dieser erhalten, kleinere Wuensche werden ueberschrieben. */ -void lcl_CalcSubColValues( SvUShorts &rToFill, const SwTabCols &rCols, +void lcl_CalcSubColValues( std::vector &rToFill, const SwTabCols &rCols, const SwLayoutFrm *pCell, const SwLayoutFrm *pTab, sal_Bool bWishValues ) { @@ -1361,7 +1361,7 @@ void lcl_CalcSubColValues( SvUShorts &rToFill, const SwTabCols &rCols, * schneidet wird der Minimalwert ermittelt. */ -void lcl_CalcColValues( SvUShorts &rToFill, const SwTabCols &rCols, +void lcl_CalcColValues( std::vector &rToFill, const SwTabCols &rCols, const SwLayoutFrm *pStart, const SwLayoutFrm *pEnd, sal_Bool bWishValues ) { @@ -1471,14 +1471,14 @@ void SwDoc::AdjustCellWidth( const SwCursor& rCursor, sal_Bool bBalance ) return; const sal_uInt8 nTmp = (sal_uInt8)Max( sal_uInt16(255), sal_uInt16(aTabCols.Count() + 1) ); - SvUShorts aWish( nTmp, nTmp ), + std::vector aWish( nTmp, nTmp ), aMins( nTmp, nTmp ); sal_uInt16 i; for ( i = 0; i <= aTabCols.Count(); ++i ) { - aWish.Insert( sal_uInt16(0), aWish.Count() ); - aMins.Insert( sal_uInt16(0), aMins.Count() ); + aWish.push_back( 0 ); + aMins.push_back( 0 ); } ::lcl_CalcColValues( aWish, aTabCols, pStart, pEnd, sal_True ); @@ -1511,7 +1511,7 @@ void SwDoc::AdjustCellWidth( const SwCursor& rCursor, sal_Bool bBalance ) } } nWish = nWish / nCnt; - for ( i = 0; i < aWish.Count(); ++i ) + for ( i = 0; i < aWish.size(); ++i ) if ( aWish[i] ) aWish[i] = nWish; } diff --git a/sw/source/core/fields/expfld.cxx b/sw/source/core/fields/expfld.cxx index 76ab5fc5f3e7..5d0305e2a814 100644 --- a/sw/source/core/fields/expfld.cxx +++ b/sw/source/core/fields/expfld.cxx @@ -557,8 +557,8 @@ sal_uInt16 SwSetExpFieldType::SetSeqRefNo( SwSetExpField& rFld ) if( !GetDepends() || !(nsSwGetSetExpType::GSE_SEQ & nType) ) return USHRT_MAX; -extern void InsertSort( SvUShorts& rArr, sal_uInt16 nIdx, sal_uInt16* pInsPos = 0 ); - SvUShorts aArr( 64 ); +extern void InsertSort( std::vector& rArr, sal_uInt16 nIdx, sal_uInt16* pInsPos = 0 ); + std::vector aArr; sal_uInt16 n; @@ -577,18 +577,18 @@ extern void InsertSort( SvUShorts& rArr, sal_uInt16 nIdx, sal_uInt16* pInsPos = sal_uInt16 nNum = rFld.GetSeqNumber(); if( USHRT_MAX != nNum ) { - for( n = 0; n < aArr.Count(); ++n ) + for( n = 0; n < aArr.size(); ++n ) if( aArr[ n ] > nNum ) return nNum; // nicht vorhanden -> also benutzen else if( aArr[ n ] == nNum ) break; // schon vorhanden -> neue erzeugen - if( n == aArr.Count() ) + if( n == aArr.size() ) return nNum; // nicht vorhanden -> also benutzen } // alle Nummern entsprechend geflag, also bestimme die richtige Nummer - for( n = 0; n < aArr.Count(); ++n ) + for( n = 0; n < aArr.size(); ++n ) if( n != aArr[ n ] ) break; diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx index 17f0dd225c42..3b5284965234 100644 --- a/sw/source/core/fields/reffld.cxx +++ b/sw/source/core/fields/reffld.cxx @@ -30,8 +30,6 @@ #include "precompiled_sw.hxx" -#define _SVSTDARR_USHORTS -#include #include #include #include @@ -80,7 +78,7 @@ using namespace ::com::sun::star::text; using namespace ::com::sun::star::lang; using ::rtl::OUString; -extern void InsertSort( SvUShorts& rArr, sal_uInt16 nIdx, sal_uInt16* pInsPos = 0 ); +extern void InsertSort( std::vector& rArr, sal_uInt16 nIdx, sal_uInt16* pInsPos = 0 ); void lcl_GetLayTree( const SwFrm* pFrm, SvPtrarr& rArr ) { diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx index 8f3563f4e694..013566cfed71 100644 --- a/sw/source/core/undo/untbl.cxx +++ b/sw/source/core/undo/untbl.cxx @@ -191,7 +191,7 @@ public: void CreateNew( SwTable& rTbl, SwTableLine& rParent, _SaveTable& rSTbl ); }; -void InsertSort( SvUShorts& rArr, sal_uInt16 nIdx, sal_uInt16* pInsPos = 0 ); +void InsertSort( std::vector& rArr, sal_uInt16 nIdx, sal_uInt16* pInsPos = 0 ); #if OSL_DEBUG_LEVEL > 1 #include "shellio.hxx" @@ -3175,21 +3175,21 @@ void SwUndoMergeTbl::SaveFormula( SwHistory& rHistory ) ////////////////////////////////////////////////////////////////////////// -void InsertSort( SvUShorts& rArr, sal_uInt16 nIdx, sal_uInt16* pInsPos ) +void InsertSort( std::vector& rArr, sal_uInt16 nIdx, sal_uInt16* pInsPos ) { - sal_uInt16 nO = rArr.Count(), nM, nU = 0; + sal_uInt16 nO = rArr.size(), nM, nU = 0; if( nO > 0 ) { nO--; while( nU <= nO ) { nM = nU + ( nO - nU ) / 2; - if( *(rArr.GetData() + nM) == nIdx ) + if ( rArr[nM] == nIdx ) { OSL_FAIL( "Index already exists. This should never happen." ); return; } - if( *(rArr.GetData() + nM) < nIdx ) + if( rArr[nM] < nIdx ) nU = nM + 1; else if( nM == 0 ) break; @@ -3197,7 +3197,7 @@ void InsertSort( SvUShorts& rArr, sal_uInt16 nIdx, sal_uInt16* pInsPos ) nO = nM - 1; } } - rArr.Insert( nIdx, nU ); + rArr.insert( rArr.begin() + nU, nIdx ); if( pInsPos ) *pInsPos = nU; } diff --git a/sw/source/filter/html/htmlform.cxx b/sw/source/filter/html/htmlform.cxx index a6ef89445241..7fc91799d7a5 100644 --- a/sw/source/filter/html/htmlform.cxx +++ b/sw/source/filter/html/htmlform.cxx @@ -208,7 +208,7 @@ class SwHTMLForm_Impl String sText; SvStringsDtor aStringList; SvStringsDtor aValueList; - SvUShorts aSelectedList; + std::vector aSelectedList; public: @@ -269,10 +269,10 @@ public: aValueList.DeleteAndDestroy( 0, aValueList.Count() ); } - SvUShorts& GetSelectedList() { return aSelectedList; } + std::vector& GetSelectedList() { return aSelectedList; } void EraseSelectedList() { - aSelectedList.Remove( 0, aSelectedList.Count() ); + aSelectedList.clear(); } SvKeyValueIterator *GetHeaderAttrs() const { return pHeaderAttrs; } @@ -2544,12 +2544,12 @@ void SwHTMLParser::EndSelect() rPropSet->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("ListSource")), aAny ); - sal_uInt16 nSelCnt = pFormImpl->GetSelectedList().Count(); + size_t nSelCnt = pFormImpl->GetSelectedList().size(); if( !nSelCnt && 1 == nSelectEntryCnt && nEntryCnt ) { // In einer DropDown-Listbox sollte immer ein Eintrag selektiert // sein. - pFormImpl->GetSelectedList().Insert( (sal_uInt16)0, (sal_uInt16)0 ); + pFormImpl->GetSelectedList().insert( pFormImpl->GetSelectedList().begin(), 0 ); nSelCnt = 1; } Sequence aSelList( (sal_Int32)nSelCnt ); @@ -2624,8 +2624,9 @@ void SwHTMLParser::InsertSelectOption() pFormImpl->GetStringList().Insert( new String( aEmptyStr ), nEntryCnt ); pFormImpl->GetValueList().Insert( new String( aValue ), nEntryCnt ); if( bLBEntrySelected ) - pFormImpl->GetSelectedList().Insert( nEntryCnt, - pFormImpl->GetSelectedList().Count() ); + { + pFormImpl->GetSelectedList().push_back( nEntryCnt ); + } } void SwHTMLParser::InsertSelectText() diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx index 17b54983c842..de92f0755bad 100644 --- a/sw/source/filter/html/htmltab.cxx +++ b/sw/source/filter/html/htmltab.cxx @@ -398,7 +398,7 @@ class HTMLTable String aDir; SdrObjects *pResizeDrawObjs;// SDR objects - SvUShorts *pDrawObjPrcWidths; // column of draw object and its rel. width + std::vector *pDrawObjPrcWidths; // column of draw object and its rel. width HTMLTableRows *pRows; // table rows HTMLTableColumns *pColumns; // table columns @@ -2810,10 +2810,10 @@ void HTMLTable::RegisterDrawObject( SdrObject *pObj, sal_uInt8 nPrcWidth ) pResizeDrawObjs->C40_INSERT( SdrObject, pObj, pResizeDrawObjs->Count() ); if( !pDrawObjPrcWidths ) - pDrawObjPrcWidths = new SvUShorts; - pDrawObjPrcWidths->Insert( nCurRow, pDrawObjPrcWidths->Count() ); - pDrawObjPrcWidths->Insert( nCurCol, pDrawObjPrcWidths->Count() ); - pDrawObjPrcWidths->Insert( (sal_uInt16)nPrcWidth, pDrawObjPrcWidths->Count() ); + pDrawObjPrcWidths = new std::vector; + pDrawObjPrcWidths->push_back( nCurRow ); + pDrawObjPrcWidths->push_back( nCurCol ); + pDrawObjPrcWidths->push_back( (sal_uInt16)nPrcWidth ); } void HTMLTable::MakeParentContents() @@ -3081,11 +3081,11 @@ _SectionSaveStruct::_SectionSaveStruct( SwHTMLParser& rParser ) : { // Font-Stacks einfrieren nBaseFontStMinSave = rParser.nBaseFontStMin; - rParser.nBaseFontStMin = rParser.aBaseFontStack.Count(); + rParser.nBaseFontStMin = rParser.aBaseFontStack.size(); nFontStMinSave = rParser.nFontStMin; nFontStHeadStartSave = rParser.nFontStHeadStart; - rParser.nFontStMin = rParser.aFontStack.Count(); + rParser.nFontStMin = rParser.aFontStack.size(); // Kontext-Stack einfrieren nContextStMinSave = rParser.nContextStMin; @@ -3105,16 +3105,16 @@ void _SectionSaveStruct::Restore( SwHTMLParser& rParser ) { // Font-Stacks wieder auftauen sal_uInt16 nMin = rParser.nBaseFontStMin; - if( rParser.aBaseFontStack.Count() > nMin ) - rParser.aBaseFontStack.Remove( nMin, - rParser.aBaseFontStack.Count() - nMin ); + if( rParser.aBaseFontStack.size() > nMin ) + rParser.aBaseFontStack.erase( rParser.aBaseFontStack.begin() + nMin, + rParser.aBaseFontStack.end() ); rParser.nBaseFontStMin = nBaseFontStMinSave; nMin = rParser.nFontStMin; - if( rParser.aFontStack.Count() > nMin ) - rParser.aFontStack.Remove( nMin, - rParser.aFontStack.Count() - nMin ); + if( rParser.aFontStack.size() > nMin ) + rParser.aFontStack.erase( rParser.aFontStack.begin() + nMin, + rParser.aFontStack.end() ); rParser.nFontStMin = nFontStMinSave; rParser.nFontStHeadStart = nFontStHeadStartSave; diff --git a/sw/source/filter/html/svxcss1.cxx b/sw/source/filter/html/svxcss1.cxx index 8ad074212094..93b54e154464 100644 --- a/sw/source/filter/html/svxcss1.cxx +++ b/sw/source/filter/html/svxcss1.cxx @@ -782,15 +782,15 @@ SvxCSS1Parser::SvxCSS1Parser( SfxItemPool& rPool, const String& rBaseURL, sal_uI aItemIds.nLanguageCTL = rPool.GetTrueWhich( SID_ATTR_CHAR_CTL_LANGUAGE, sal_False ); aItemIds.nDirection = rPool.GetTrueWhich( SID_ATTR_FRAMEDIRECTION, sal_False ); - aWhichMap.Insert( (sal_uInt16)0, (sal_uInt16)0 ); + aWhichMap.insert( aWhichMap.begin(), 0 ); SvParser::BuildWhichTbl( aWhichMap, (sal_uInt16 *)&aItemIds, sizeof(aItemIds) / sizeof(sal_uInt16) ); if( pWhichIds && nWhichIds ) SvParser::BuildWhichTbl( aWhichMap, pWhichIds, nWhichIds ); - pSheetItemSet = new SfxItemSet( rPool, aWhichMap.GetData() ); + pSheetItemSet = new SfxItemSet( rPool, &aWhichMap[0] ); pSheetPropInfo = new SvxCSS1PropertyInfo; - pSearchEntry = new SvxCSS1MapEntry( rPool, aWhichMap.GetData() ); + pSearchEntry = new SvxCSS1MapEntry( rPool, &aWhichMap[0] ); } SvxCSS1Parser::~SvxCSS1Parser() diff --git a/sw/source/filter/html/svxcss1.hxx b/sw/source/filter/html/svxcss1.hxx index b90fcdfa91a9..bcd7a283e1f1 100644 --- a/sw/source/filter/html/svxcss1.hxx +++ b/sw/source/filter/html/svxcss1.hxx @@ -245,7 +245,7 @@ class SvxCSS1Parser : public CSS1Parser void ParseProperty( const String& rProperty, const CSS1Expression *pExpr ); - SvUShorts aWhichMap; // Which-Map des Parser + std::vector aWhichMap; // Which-Map des Parser using CSS1Parser::ParseStyleOption; @@ -310,7 +310,7 @@ public: virtual const FontList *GetFontList() const; - const sal_uInt16 *GetWhichMap() const { return aWhichMap.GetData(); } + const sal_uInt16 *GetWhichMap() const { return &aWhichMap[0]; } void InsertMapEntry( const String& rKey, const SfxItemSet& rItemSet, const SvxCSS1PropertyInfo& rProp, CSS1Map& rMap ); diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx index 9a8d77af3a9b..29a4da1f0c32 100644 --- a/sw/source/filter/html/swhtml.cxx +++ b/sw/source/filter/html/swhtml.cxx @@ -3558,7 +3558,7 @@ void SwHTMLParser::NewBasefontAttr() PushContext( pCntxt ); // die Font-Size merken - aBaseFontStack.Insert( nSize, aBaseFontStack.Count() ); + aBaseFontStack.push_back( nSize ); } void SwHTMLParser::EndBasefontAttr() @@ -3566,19 +3566,19 @@ void SwHTMLParser::EndBasefontAttr() EndTag( HTML_BASEFONT_ON ); // Stack-Unterlauf in Tabellen vermeiden - if( aBaseFontStack.Count() > nBaseFontStMin ) - aBaseFontStack.Remove( aBaseFontStack.Count()-1, 1 ); + if( aBaseFontStack.size() > nBaseFontStMin ) + aBaseFontStack.erase( aBaseFontStack.begin() + aBaseFontStack.size() - 1 ); } void SwHTMLParser::NewFontAttr( int nToken ) { sal_uInt16 nBaseSize = - ( aBaseFontStack.Count() > nBaseFontStMin - ? (aBaseFontStack[aBaseFontStack.Count()-1] & FONTSIZE_MASK) + ( aBaseFontStack.size() > nBaseFontStMin + ? (aBaseFontStack[aBaseFontStack.size()-1] & FONTSIZE_MASK) : 3 ); sal_uInt16 nFontSize = - ( aFontStack.Count() > nFontStMin - ? (aFontStack[aFontStack.Count()-1] & FONTSIZE_MASK) + ( aFontStack.size() > nFontStMin + ? (aFontStack[aFontStack.size()-1] & FONTSIZE_MASK) : nBaseSize ); String aFace, aId, aStyle, aClass, aLang, aDir; @@ -3653,7 +3653,7 @@ void SwHTMLParser::NewFontAttr( int nToken ) { // wenn die Schriftgroesse in der Ueberschrift noch // nicht veraendert ist, die aus der Vorlage nehmen - if( nFontStHeadStart==aFontStack.Count() ) + if( nFontStHeadStart==aFontStack.size() ) nFontSize = static_cast< sal_uInt16 >(6 - (nPoolId - RES_POOLCOLL_HEADLINE1)); } else @@ -3786,7 +3786,7 @@ void SwHTMLParser::NewFontAttr( int nToken ) // den Kontext merken PushContext( pCntxt ); - aFontStack.Insert( nSize, aFontStack.Count() ); + aFontStack.push_back( nSize ); } void SwHTMLParser::EndFontAttr( int nToken ) @@ -3794,8 +3794,8 @@ void SwHTMLParser::EndFontAttr( int nToken ) EndTag( nToken ); // Stack-Unterlauf in Tabellen vermeiden - if( aFontStack.Count() > nFontStMin ) - aFontStack.Remove( aFontStack.Count()-1, 1 ); + if( aFontStack.size() > nFontStMin ) + aFontStack.erase( aFontStack.begin() + aFontStack.size() - 1 ); } @@ -4002,7 +4002,7 @@ void SwHTMLParser::NewHeading( int nToken ) // und die Vorlage oder deren Attribute setzen SetTxtCollAttrs( pCntxt ); - nFontStHeadStart = aFontStack.Count(); + nFontStHeadStart = aFontStack.size(); // Laufbalkenanzeige ShowStatline(); diff --git a/sw/source/filter/html/swhtml.hxx b/sw/source/filter/html/swhtml.hxx index 127f9129078e..f218c361328b 100644 --- a/sw/source/filter/html/swhtml.hxx +++ b/sw/source/filter/html/swhtml.hxx @@ -33,9 +33,6 @@ #ifndef _SVSTDARR_XUB_STRLEN_DECL #define _SVSTDARR_XUB_STRLEN #endif -#ifndef _SVSTDARR_USHORTS_DECL -#define _SVSTDARR_USHORTS -#endif #ifndef _SVSTDARR_STRINGSDTOR_DECL #define _SVSTDARR_STRINGSDTOR #endif @@ -394,9 +391,9 @@ class SwHTMLParser : public SfxHTMLParser, public SwClient String aBulletGrfs[MAXLEVEL]; String sJmpMark; - SvUShorts aBaseFontStack; // Stack fuer + std::vector aBaseFontStack; // Stack fuer // Bit 0-2: Fontgroesse (1-7) - SvUShorts aFontStack; // Stack fuer , , + std::vector aFontStack; // Stack fuer , , // Bit 0-2: Fontgroesse (1-7) // Bit 15: Fontfarbe wurde gesetzt diff --git a/sw/source/filter/rtf/rtffly.cxx b/sw/source/filter/rtf/rtffly.cxx index fb5af60f114f..e03467959d9b 100644 --- a/sw/source/filter/rtf/rtffly.cxx +++ b/sw/source/filter/rtf/rtffly.cxx @@ -559,7 +559,7 @@ void SwRTFParser::ReadFly( int nToken, SfxItemSet* pSet ) SvxFrameDirectionItem aFrmDir( FRMDIR_HORI_LEFT_TOP, RES_FRAMEDIR ); sal_uInt16 nCols = USHRT_MAX, nColSpace = USHRT_MAX, nAktCol = 0; - SvUShorts aColumns; + std::vector aColumns; sal_Bool bChkDropCap = 0 == pSet; sal_uInt16 nDropCapLines = 0, nDropCapAnchor = 0; @@ -740,10 +740,10 @@ void SwRTFParser::ReadFly( int nToken, SfxItemSet* pSet ) else SkipToken( -1 ); // wieder zurueck - if( --nAktCol == ( aColumns.Count() / 2 ) ) + if( --nAktCol == ( aColumns.size() / 2 ) ) { - aColumns.Insert( nWidth + nSpace, aColumns.Count() ); - aColumns.Insert( nSpace, aColumns.Count() ); + aColumns.push_back( nWidth + nSpace ); + aColumns.push_back( nSpace ); } } break; @@ -858,10 +858,10 @@ void SwRTFParser::ReadFly( int nToken, SfxItemSet* pSet ) else SkipToken( -1 ); // wieder zurueck - if( --nAktCol == ( aColumns.Count() / 2 ) ) + if( --nAktCol == ( aColumns.size() / 2 ) ) { - aColumns.Insert( nWidth + nSpace, aColumns.Count() ); - aColumns.Insert( nSpace, aColumns.Count() ); + aColumns.push_back( nWidth + nSpace ); + aColumns.push_back( nSpace ); } } break; @@ -961,9 +961,9 @@ void SwRTFParser::ReadFly( int nToken, SfxItemSet* pSet ) sal_uLong nWidth = USHRT_MAX; aCol.Init( nCols, nColSpace, sal_uInt16( nWidth ) ); - if( nCols == ( aColumns.Count() / 2 ) ) + if( nCols == ( aColumns.size() / 2 ) ) { - for( sal_uInt16 n = 0, i = 0; n < aColumns.Count(); n += 2, ++i ) + for( sal_uInt16 n = 0, i = 0; n < aColumns.size(); n += 2, ++i ) { SwColumn* pCol = aCol.GetColumns()[ i ]; sal_uLong nTmp = aColumns[ n ]; diff --git a/sw/source/filter/rtf/swparrtf.cxx b/sw/source/filter/rtf/swparrtf.cxx index 6d7085cdbf1f..38236e6ccee8 100644 --- a/sw/source/filter/rtf/swparrtf.cxx +++ b/sw/source/filter/rtf/swparrtf.cxx @@ -2762,7 +2762,7 @@ void SwRTFParser::MakeStyleTab() } sal_Bool lcl_SetFmtCol( SwFmt& rFmt, sal_uInt16 nCols, sal_uInt16 nColSpace, - const SvUShorts& rColumns ) + const std::vector& rColumns ) { sal_Bool bSet = sal_False; if( nCols && USHRT_MAX != nCols ) @@ -2772,11 +2772,11 @@ sal_Bool lcl_SetFmtCol( SwFmt& rFmt, sal_uInt16 nCols, sal_uInt16 nColSpace, nColSpace = 720; aCol.Init( nCols, nColSpace, USHRT_MAX ); - if( nCols == ( rColumns.Count() / 2 ) ) + if( nCols == ( rColumns.size() / 2 ) ) { aCol._SetOrtho( sal_False ); sal_uInt16 nWishWidth = 0, nHalfPrev = 0; - for( sal_uInt16 n = 0, i = 0; n < rColumns.Count(); n += 2, ++i ) + for( sal_uInt16 n = 0, i = 0; n < rColumns.size(); n += 2, ++i ) { SwColumn* pCol = aCol.GetColumns()[ i ]; pCol->SetLeft( nHalfPrev ); @@ -3262,7 +3262,7 @@ void SwRTFParser::ReadPageDescTbl() SvxFrameDirectionItem aFrmDir(FRMDIR_HORI_LEFT_TOP, RES_FRAMEDIR); sal_uInt16 nCols = USHRT_MAX, nColSpace = USHRT_MAX, nAktCol = 0; - SvUShorts aColumns; + std::vector aColumns; while( nNumOpenBrakets && IsParserWorking() ) { @@ -3422,10 +3422,10 @@ void SwRTFParser::ReadPageDescTbl() else SkipToken( -1 ); // wieder zurueck - if( --nAktCol == ( aColumns.Count() / 2 ) ) + if( --nAktCol == ( aColumns.size() / 2 ) ) { - aColumns.Insert( nWidth, aColumns.Count() ); - aColumns.Insert( nSpace, aColumns.Count() ); + aColumns.push_back( nWidth ); + aColumns.push_back( nSpace ); } } break; diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx index 5c1d220ade60..e7bf299cc5e6 100644 --- a/sw/source/filter/ww8/wrtw8esh.cxx +++ b/sw/source/filter/ww8/wrtw8esh.cxx @@ -874,7 +874,7 @@ void MSWord_SdrAttrIter::NextPara( sal_uInt16 nPar ) // wird, dass am Absatzanfang sowieso die Attribute neu ausgegeben // werden. aChrTxtAtrArr.Remove( 0, aChrTxtAtrArr.Count() ); - aChrSetArr.Remove( 0, aChrSetArr.Count() ); + aChrSetArr.clear(); nAktSwPos = nTmpSwPos = 0; SfxItemSet aSet( pEditObj->GetParaAttribs( nPara )); @@ -892,8 +892,8 @@ void MSWord_SdrAttrIter::NextPara( sal_uInt16 nPar ) rtl_TextEncoding MSWord_SdrAttrIter::GetNextCharSet() const { - if( aChrSetArr.Count() ) - return (rtl_TextEncoding)aChrSetArr[ aChrSetArr.Count() - 1 ]; + if( aChrSetArr.size() ) + return (rtl_TextEncoding)aChrSetArr[ aChrSetArr.size() - 1 ]; return eNdChrSet; } @@ -945,14 +945,14 @@ void MSWord_SdrAttrIter::SetCharSet(const EECharAttrib& rAttr, bool bStart) sal_uInt16 nPos; if( bStart ) { - nPos = aChrSetArr.Count(); - aChrSetArr.Insert( eChrSet, nPos ); + nPos = aChrSetArr.size(); + aChrSetArr.push_back( eChrSet ); aChrTxtAtrArr.Insert( p, nPos ); } else if( USHRT_MAX != ( nPos = aChrTxtAtrArr.GetPos( p )) ) { aChrTxtAtrArr.Remove( nPos ); - aChrSetArr.Remove( nPos ); + aChrSetArr.erase( aChrSetArr.begin() + nPos ); } } } diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx index 761fc2acfd4a..ed7fe30b4d73 100644 --- a/sw/source/filter/ww8/wrtww8.hxx +++ b/sw/source/filter/ww8/wrtww8.hxx @@ -1373,7 +1373,7 @@ private: const SfxItemPool* pEditPool; EECharAttribArray aTxtAtrArr; SvPtrarr aChrTxtAtrArr; - SvUShorts aChrSetArr; + std::vector aChrSetArr; sal_uInt16 nPara; xub_StrLen nAktSwPos; xub_StrLen nTmpSwPos; // for HasItem() diff --git a/sw/source/ui/uiview/viewsrch.cxx b/sw/source/ui/uiview/viewsrch.cxx index ca6a1a4b16ef..bbd490f0640b 100644 --- a/sw/source/ui/uiview/viewsrch.cxx +++ b/sw/source/ui/uiview/viewsrch.cxx @@ -374,21 +374,22 @@ void SwView::ExecSearch(SfxRequest& rReq, sal_Bool bNoMessage) RES_CHRATR_CTL_FONT, RES_CHRATR_CTL_WEIGHT }; - SvUShorts aArr( 0, 16 ); - aArr.Insert( aNormalAttr, - SAL_N_ELEMENTS( aNormalAttr ), - 0 ); + std::vector aArr; + aArr.insert( aArr.begin(), aNormalAttr, + aNormalAttr + SAL_N_ELEMENTS( aNormalAttr )); if( SW_MOD()->GetCTLOptions().IsCTLFontEnabled() ) - aArr.Insert( aCTLAttr, - SAL_N_ELEMENTS( aCTLAttr ), - 14 ); + { + aArr.insert( aArr.begin() + 14, aCTLAttr, + aCTLAttr + SAL_N_ELEMENTS( aCTLAttr )); + } SvtCJKOptions aCJKOpt; if( aCJKOpt.IsAnyEnabled() ) - aArr.Insert( aCJKAttr, - SAL_N_ELEMENTS( aCJKAttr ), - 14 ); + { + aArr.insert( aArr.begin() + 14, aCJKAttr, + aCJKAttr + SAL_N_ELEMENTS( aCJKAttr )); + } - SfxItemSet aSet( pWrtShell->GetAttrPool(), aArr.GetData() ); + SfxItemSet aSet( pWrtShell->GetAttrPool(), &aArr[0] ); sal_uInt16 nWhich = SID_SEARCH_SEARCHSET; if ( FID_SEARCH_REPLACESET == nSlot ) diff --git a/xmloff/inc/xmloff/xmlexppr.hxx b/xmloff/inc/xmloff/xmlexppr.hxx index b7a2c684c81c..fb5851e36e76 100644 --- a/xmloff/inc/xmloff/xmlexppr.hxx +++ b/xmloff/inc/xmloff/xmlexppr.hxx @@ -39,7 +39,6 @@ namespace rtl { class OUString; } class SvXMLUnitConverter; class SvXMLAttributeList; class SvXMLNamespaceMap; -class SvUShorts; class FilterPropertiesInfos_Impl; class SvXMLExport; @@ -85,7 +84,7 @@ protected: const SvXMLUnitConverter& rUnitConverter, const SvXMLNamespaceMap& rNamespaceMap, sal_uInt16 nFlags, - SvUShorts* pIndexArray, + std::vector* pIndexArray, sal_Int32 nPropMapStartIdx, sal_Int32 nPropMapEndIdx ) const; void _exportXML( SvXMLAttributeList& rAttrList, @@ -100,7 +99,7 @@ protected: SvXMLExport& rExport, const ::std::vector< XMLPropertyState >& rProperties, sal_uInt16 nFlags, - const SvUShorts& rIndexArray ) const; + const std::vector& rIndexArray ) const; public: diff --git a/xmloff/source/style/xmlexppr.cxx b/xmloff/source/style/xmlexppr.cxx index 2b83ec2c6b48..47d5777b0158 100644 --- a/xmloff/source/style/xmlexppr.cxx +++ b/xmloff/source/style/xmlexppr.cxx @@ -49,11 +49,6 @@ #include #include -#ifndef _SVSTDARR_USHORTS -#define _SVSTDARR_USHORTS -#include -#endif - using ::rtl::OUString; using ::rtl::OUStringBuffer; @@ -830,7 +825,7 @@ void SvXMLExportPropertyMapper::exportXML( sal_uInt16 nPropType = aPropTokens[i].nType; if( 0==i || (nPropTypeFlags & (1 << nPropType)) != 0 ) { - SvUShorts aIndexArray; + std::vector aIndexArray; _exportXML( nPropType, nPropTypeFlags, rExport.GetAttrList(), rProperties, @@ -841,7 +836,7 @@ void SvXMLExportPropertyMapper::exportXML( if( rExport.GetAttrList().getLength() > 0L || (nFlags & XML_EXPORT_FLAG_EMPTY) != 0 || - aIndexArray.Count() != 0 ) + !aIndexArray.empty() ) { SvXMLElementExport aElem( rExport, XML_NAMESPACE_STYLE, aPropTokens[i].eToken, @@ -898,7 +893,7 @@ void SvXMLExportPropertyMapper::_exportXML( const SvXMLUnitConverter& rUnitConverter, const SvXMLNamespaceMap& rNamespaceMap, sal_uInt16 nFlags, - SvUShorts* pIndexArray, + std::vector* pIndexArray, sal_Int32 nPropMapStartIdx, sal_Int32 nPropMapEndIdx ) const { const sal_uInt32 nCount = rProperties.size(); @@ -928,7 +923,9 @@ void SvXMLExportPropertyMapper::_exportXML( // element items do not add any properties, // we export it later if( pIndexArray ) - pIndexArray->Insert( (sal_uInt16)nIndex, pIndexArray->Count() ); + { + pIndexArray->push_back( (sal_uInt16)nIndex ); + } } else { @@ -1092,15 +1089,15 @@ void SvXMLExportPropertyMapper::exportElementItems( SvXMLExport& rExport, const ::std::vector< XMLPropertyState >& rProperties, sal_uInt16 nFlags, - const SvUShorts& rIndexArray ) const + const std::vector& rIndexArray ) const { - const sal_uInt16 nCount = rIndexArray.Count(); + const sal_uInt16 nCount = rIndexArray.size(); sal_Bool bItemsExported = sal_False; OUString sWS( GetXMLToken(XML_WS) ); for( sal_uInt16 nIndex = 0; nIndex < nCount; nIndex++ ) { - const sal_uInt16 nElement = rIndexArray.GetObject( nIndex ); + const sal_uInt16 nElement = rIndexArray[nIndex]; OSL_ENSURE( 0 != ( maPropMapper->GetEntryFlags( rProperties[nElement].mnIndex ) & MID_FLAG_ELEMENT_ITEM_EXPORT), -- cgit From 9df6f53a88fb5e6d6c9ea430eb1f6d426ea7f755 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 1 Nov 2011 12:31:11 +0000 Subject: impl_loadBitmap is now dangling unused --- sfx2/source/appl/appmisc.cxx | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/sfx2/source/appl/appmisc.cxx b/sfx2/source/appl/appmisc.cxx index 119b8a5101ae..6e76d4428175 100644 --- a/sfx2/source/appl/appmisc.cxx +++ b/sfx2/source/appl/appmisc.cxx @@ -280,32 +280,6 @@ sal_Bool SfxApplication::IsDowning() const { return pAppData_Impl->bDowning; } SfxDispatcher* SfxApplication::GetAppDispatcher_Impl() { return pAppData_Impl->pAppDispat; } SfxSlotPool& SfxApplication::GetAppSlotPool_Impl() const { return *pAppData_Impl->pSlotPool; } -static bool impl_loadBitmap( - const rtl::OUString &rPath, const rtl::OUString &rBmpFileName, - Image &rLogo ) -{ - rtl::OUString uri( rPath ); - rtl::Bootstrap::expandMacros( uri ); - INetURLObject aObj( uri ); - aObj.insertName( rBmpFileName ); - SvFileStream aStrm( aObj.PathToFileName(), STREAM_STD_READ ); - if ( !aStrm.GetError() ) - { - // Use graphic class to also support more graphic formats (bmp,png,...) - Graphic aGraphic; - - GraphicFilter& rGF = GraphicFilter::GetGraphicFilter(); - rGF.ImportGraphic( aGraphic, String(), aStrm, GRFILTER_FORMAT_DONTKNOW ); - - // Default case, we load the intro bitmap from a seperate file - // (e.g. staroffice_intro.bmp or starsuite_intro.bmp) - BitmapEx aBmp = aGraphic.GetBitmapEx(); - rLogo = Image( aBmp ); - return true; - } - return false; -} - /** loads the application logo as used in the about dialog and impress slideshow pause screen */ Image SfxApplication::GetApplicationLogo() { -- cgit From 54c7480a6cdb049a5b0c907fa86af42068dcae16 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Tue, 1 Nov 2011 12:21:49 +0000 Subject: add real alpha to markers --- svx/source/svdraw/svdhdl.cxx | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/svx/source/svdraw/svdhdl.cxx b/svx/source/svdraw/svdhdl.cxx index 62ee66b233de..14f4289d50a5 100644 --- a/svx/source/svdraw/svdhdl.cxx +++ b/svx/source/svdraw/svdhdl.cxx @@ -101,18 +101,10 @@ public: #define INDIVIDUAL_COUNT (4) SdrHdlBitmapSet::SdrHdlBitmapSet(sal_uInt16 nResId) -: maMarkersBitmap(), + : maMarkersBitmap(ResId(nResId, *ImpGetResMgr())), // 14 kinds (BitmapMarkerKind) use index [0..5], 4 extra - maRealMarkers((KIND_COUNT * INDEX_COUNT) + INDIVIDUAL_COUNT) + maRealMarkers((KIND_COUNT * INDEX_COUNT) + INDIVIDUAL_COUNT) { - // #101928# change color used for transparent parts to 0x00ff00ff (ImageList standard) - const Color aColTransparent(0x00ff00ff); - const Bitmap aBitmap(ResId(nResId, *ImpGetResMgr())); - const Bitmap aMask(aBitmap.CreateMask(aColTransparent)); - - // create a real BitmapEx with an AlphaMask - maMarkersBitmap = BitmapEx(aBitmap, aMask); - // maMarkersBitmap = BitmapEx(aBitmap, aColTransparent); } SdrHdlBitmapSet::~SdrHdlBitmapSet() -- cgit From fc1116452095e95616210bde60de0c0d6ed3e953 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Tue, 1 Nov 2011 13:01:33 +0000 Subject: gtk: fix cpu burn when inactive - broken timeout calculation --- vcl/unx/gtk/app/gtkdata.cxx | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/vcl/unx/gtk/app/gtkdata.cxx b/vcl/unx/gtk/app/gtkdata.cxx index 4599ec4ee317..17f179623544 100644 --- a/vcl/unx/gtk/app/gtkdata.cxx +++ b/vcl/unx/gtk/app/gtkdata.cxx @@ -836,13 +836,9 @@ extern "C" { GTimeVal aTimeNow; g_source_get_current_time( pSource, &aTimeNow ); - if( pTSource->aFireTime.tv_sec > aTimeNow.tv_sec ) - return FALSE; - if( pTSource->aFireTime.tv_sec < aTimeNow.tv_sec ) - return TRUE; - if( pTSource->aFireTime.tv_usec < aTimeNow.tv_usec ) - return FALSE; - return TRUE; + return ( pTSource->aFireTime.tv_sec < aTimeNow.tv_sec || + ( pTSource->aFireTime.tv_sec == aTimeNow.tv_sec && + pTSource->aFireTime.tv_usec < aTimeNow.tv_usec ) ); } static gboolean sal_gtk_timeout_dispatch( GSource *pSource, GSourceFunc, gpointer ) @@ -921,7 +917,7 @@ bool GtkSalTimer::Expired() void GtkSalTimer::Start( sal_uLong nMS ) { m_nTimeoutMS = nMS; // for restarting - Stop(); + Stop(); // FIXME: ideally re-use an existing m_pTimeout m_pTimeout = create_sal_gtk_timeout( this ); } -- cgit From 06899e6b77f5ca878ba7fd8b60bb62f5f97e90a2 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Tue, 1 Nov 2011 11:02:45 -0400 Subject: Re-enabling the macros test. It was due to those pesky .~lock* files preventing the test files from being loaded. Maybe this is also what's breaking the mac os build!? --- sc/qa/unit/macros-test.cxx | 2 -- 1 file changed, 2 deletions(-) diff --git a/sc/qa/unit/macros-test.cxx b/sc/qa/unit/macros-test.cxx index aff5bc537e28..22faa26cf915 100644 --- a/sc/qa/unit/macros-test.cxx +++ b/sc/qa/unit/macros-test.cxx @@ -126,7 +126,6 @@ public: void testStarBasic(); void testVba(); CPPUNIT_TEST_SUITE(ScMacrosTest); -#if 0 #ifndef MACOSX //enable this test if you want to play with star basic macros in unit tests //works but does nothing useful yet @@ -134,7 +133,6 @@ public: //enable if you want to hack vba support for unit tests //does not work, still problems during loading CPPUNIT_TEST(testVba); -#endif #endif CPPUNIT_TEST_SUITE_END(); -- cgit From 70c659f4da5ca10bb36a38e6d1494efe57e09260 Mon Sep 17 00:00:00 2001 From: Lior Kaplan Date: Sun, 30 Oct 2011 23:56:36 +0100 Subject: Align dictionary address with DICT_REPO_URL in instsetoo_native/util/openoffice.lst --- cui/source/options/optlingu.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cui/source/options/optlingu.cxx b/cui/source/options/optlingu.cxx index 7269fc821fdd..61ce1b230518 100644 --- a/cui/source/options/optlingu.cxx +++ b/cui/source/options/optlingu.cxx @@ -1137,7 +1137,7 @@ SvxLinguTabPage::SvxLinguTabPage( Window* pParent, != SvtExtendedSecurityOptions::OPEN_NEVER ) { aMoreDictsLink.SetURL( String( - RTL_CONSTASCII_USTRINGPARAM( "http://extensions.libreoffice.org/dictionary/" ) ) ); + RTL_CONSTASCII_USTRINGPARAM( "http://extensions.libreoffice.org/dictionaries/" ) ) ); aMoreDictsLink.SetClickHdl( LINK( this, SvxLinguTabPage, OpenURLHdl_Impl ) ); } else @@ -2017,7 +2017,7 @@ SvxEditModulesDlg::SvxEditModulesDlg(Window* pParent, SvxLinguData_Impl& rData) != SvtExtendedSecurityOptions::OPEN_NEVER ) { aMoreDictsLink.SetURL( String( - RTL_CONSTASCII_USTRINGPARAM( "http://extensions.libreoffice.org/dictionary/" ) ) ); + RTL_CONSTASCII_USTRINGPARAM( "http://extensions.libreoffice.org/dictionaries/" ) ) ); aMoreDictsLink.SetClickHdl( LINK( this, SvxEditModulesDlg, OpenURLHdl_Impl ) ); } else -- cgit From 18a22145c62efc6b75b74803c4a17a5ebd64d037 Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Tue, 1 Nov 2011 16:19:25 +0100 Subject: let's see if better eventloop integr. makes it into Qt4.9, if any https://bugreports.qt.nokia.com//browse/QTBUG-16934 --- vcl/unx/kde4/KDEXLib.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcl/unx/kde4/KDEXLib.cxx b/vcl/unx/kde4/KDEXLib.cxx index a5804b39b5e4..56150cf93105 100644 --- a/vcl/unx/kde4/KDEXLib.cxx +++ b/vcl/unx/kde4/KDEXLib.cxx @@ -57,7 +57,7 @@ #include -#if QT_VERSION >= QT_VERSION_CHECK( 4, 8, 1 ) +#if QT_VERSION >= QT_VERSION_CHECK( 4, 9, 0 ) #define QT_UNIX_EVENT_LOOP_SUPPORT #ifdef KDE_HAVE_GLIB #define GLIB_EVENT_LOOP_SUPPORT -- cgit From 5d02007469d84b248bb623196cca95d431f7ed11 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Tue, 1 Nov 2011 11:49:42 -0400 Subject: fdo#40110: Correctly map external ranges into matrix instances. This is a simple silly mistake; the matrix representation of the external range should've preserved the original range; not the data range which can be smaller than the originally requested range. --- sc/source/ui/docshell/externalrefmgr.cxx | 79 ++++++++++++++++---------------- 1 file changed, 39 insertions(+), 40 deletions(-) diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx index c80653193daf..408feb6d6fb5 100644 --- a/sc/source/ui/docshell/externalrefmgr.cxx +++ b/sc/source/ui/docshell/externalrefmgr.cxx @@ -1412,8 +1412,8 @@ static ScTokenArray* lcl_convertToTokenArray(const ScDocument* pSrcDoc, ScRange& pUsedRange.reset(new ScRange(nDataCol1, nDataRow1, 0, nDataCol2, nDataRow2, 0)); ScMatrixRef xMat = new ScMatrix( - static_cast(nDataCol2-nDataCol1+1), - static_cast(nDataRow2-nDataRow1+1)); + static_cast(nCol2-nCol1+1), + static_cast(nRow2-nRow1+1), ScMatrix::SPARSE_EMPTY); for (SCCOL nCol = nDataCol1; nCol <= nDataCol2; ++nCol) { @@ -1423,53 +1423,52 @@ static ScTokenArray* lcl_convertToTokenArray(const ScDocument* pSrcDoc, ScRange& ScBaseCell* pCell; pSrcDoc->GetCell(nCol, nRow, nTab, pCell); if (!pCell || pCell->HasEmptyData()) - xMat->PutEmpty(nC, nR); - else + // Skip empty cells. Matrix's default values are empty elements. + continue; + + switch (pCell->GetCellType()) { - switch (pCell->GetCellType()) + case CELLTYPE_EDIT: + { + String aStr; + static_cast(pCell)->GetString(aStr); + xMat->PutString(aStr, nC, nR); + } + break; + case CELLTYPE_STRING: + { + String aStr; + static_cast(pCell)->GetString(aStr); + xMat->PutString(aStr, nC, nR); + } + break; + case CELLTYPE_VALUE: + { + double fVal = static_cast(pCell)->GetValue(); + xMat->PutDouble(fVal, nC, nR); + } + break; + case CELLTYPE_FORMULA: { - case CELLTYPE_EDIT: + ScFormulaCell* pFCell = static_cast(pCell); + sal_uInt16 nError = pFCell->GetErrCode(); + if (nError) + xMat->PutDouble( CreateDoubleError( nError), nC, nR); + else if (pFCell->IsValue()) { - String aStr; - static_cast(pCell)->GetString(aStr); - xMat->PutString(aStr, nC, nR); + double fVal = pFCell->GetValue(); + xMat->PutDouble(fVal, nC, nR); } - break; - case CELLTYPE_STRING: + else { String aStr; - static_cast(pCell)->GetString(aStr); + pFCell->GetString(aStr); xMat->PutString(aStr, nC, nR); } - break; - case CELLTYPE_VALUE: - { - double fVal = static_cast(pCell)->GetValue(); - xMat->PutDouble(fVal, nC, nR); - } - break; - case CELLTYPE_FORMULA: - { - ScFormulaCell* pFCell = static_cast(pCell); - sal_uInt16 nError = pFCell->GetErrCode(); - if (nError) - xMat->PutDouble( CreateDoubleError( nError), nC, nR); - else if (pFCell->IsValue()) - { - double fVal = pFCell->GetValue(); - xMat->PutDouble(fVal, nC, nR); - } - else - { - String aStr; - pFCell->GetString(aStr); - xMat->PutString(aStr, nC, nR); - } - } - break; - default: - OSL_FAIL("attempted to convert an unknown cell type."); } + break; + default: + OSL_FAIL("attempted to convert an unknown cell type."); } } } -- cgit From bc0ae5171790dc2656a2102eaced449f9ea54921 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Tue, 1 Nov 2011 14:17:28 +0000 Subject: remove obsolete Sun internal bugzilla numbers --- svx/source/svdraw/svdhdl.cxx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/svx/source/svdraw/svdhdl.cxx b/svx/source/svdraw/svdhdl.cxx index 14f4289d50a5..abf2b1177c21 100644 --- a/svx/source/svdraw/svdhdl.cxx +++ b/svx/source/svdraw/svdhdl.cxx @@ -664,7 +664,7 @@ BitmapEx SdrHdl::ImpGetBitmapEx( BitmapMarkerKind eKindOfMarker, sal_uInt16 nInd eKindOfMarker = GetNextBigger(eKindOfMarker); } - // #97016# II This handle has the focus, visualize it + // This handle has the focus, visualize it if(IsFocusHdl() && pHdlList && pHdlList->GetFocusHdl() == this) { // create animated handle @@ -705,12 +705,12 @@ BitmapEx SdrHdl::ImpGetBitmapEx( BitmapMarkerKind eKindOfMarker, sal_uInt16 nInd if(eKindOfMarker == Anchor || eKindOfMarker == AnchorPressed) { - // #98388# when anchor is used take upper left as reference point inside the handle + // when anchor is used take upper left as reference point inside the handle pRetval = new ::sdr::overlay::OverlayAnimatedBitmapEx(rPos, aBmpEx1, aBmpEx2, nBlinkTime); } else if(eKindOfMarker == AnchorTR || eKindOfMarker == AnchorPressedTR) { - // #101688# AnchorTR for SW, take top right as (0,0) + // AnchorTR for SW, take top right as (0,0) pRetval = new ::sdr::overlay::OverlayAnimatedBitmapEx(rPos, aBmpEx1, aBmpEx2, nBlinkTime, (sal_uInt16)(aBmpEx1.GetSizePixel().Width() - 1), 0, (sal_uInt16)(aBmpEx2.GetSizePixel().Width() - 1), 0); @@ -727,18 +727,17 @@ BitmapEx SdrHdl::ImpGetBitmapEx( BitmapMarkerKind eKindOfMarker, sal_uInt16 nInd } else { - // create normal handle - // #101928# use ImpGetBitmapEx(...) now + // create normal handle: use ImpGetBitmapEx(...) now BitmapEx aBmpEx = ImpGetBitmapEx(eKindOfMarker, (sal_uInt16)eColIndex, bIsFineHdl ); if(eKindOfMarker == Anchor || eKindOfMarker == AnchorPressed) { - // #98388# upper left as reference point inside the handle for AnchorPressed, too + // upper left as reference point inside the handle for AnchorPressed, too pRetval = new ::sdr::overlay::OverlayBitmapEx(rPos, aBmpEx); } else if(eKindOfMarker == AnchorTR || eKindOfMarker == AnchorPressedTR) { - // #101688# AnchorTR for SW, take top right as (0,0) + // AnchorTR for SW, take top right as (0,0) pRetval = new ::sdr::overlay::OverlayBitmapEx(rPos, aBmpEx, (sal_uInt16)(aBmpEx.GetSizePixel().Width() - 1), 0); } -- cgit From 501a1fbc3e34c0f3afc75d523cc6fc72b94682fd Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Tue, 1 Nov 2011 15:24:33 +0000 Subject: WaE: more windows tinderbox warning cleanup --- automation/source/server/XMLParser.cxx | 4 ++-- chart2/source/controller/itemsetwrapper/ItemConverter.cxx | 4 ++++ chart2/source/controller/main/SelectionHelper.cxx | 1 - desktop/source/app/app.cxx | 1 + 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/automation/source/server/XMLParser.cxx b/automation/source/server/XMLParser.cxx index 55214414127b..7768775bba44 100644 --- a/automation/source/server/XMLParser.cxx +++ b/automation/source/server/XMLParser.cxx @@ -277,11 +277,11 @@ sal_Bool SAXParser::Parse( ParseAction aAct ) { xParser->parseStream ( sSource ); } - catch( class SAXParseException & rPEx) + catch( class SAXParseException & ) { // TODO } - catch( class Exception & rEx) + catch( class Exception & ) { // TODO } diff --git a/chart2/source/controller/itemsetwrapper/ItemConverter.cxx b/chart2/source/controller/itemsetwrapper/ItemConverter.cxx index a121a774615c..42f75c330042 100644 --- a/chart2/source/controller/itemsetwrapper/ItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/ItemConverter.cxx @@ -143,6 +143,7 @@ void ItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const catch( beans::UnknownPropertyException &ex ) { delete pItem; + (void)ex; OSL_FAIL( ::rtl::OUStringToOString( ex.Message + @@ -152,6 +153,7 @@ void ItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const } catch( uno::Exception &ex ) { + (void)ex; ASSERT_EXCEPTION( ex ); } } @@ -214,6 +216,7 @@ bool ItemConverter::ApplyItemSet( const SfxItemSet & rItemSet ) } catch( beans::UnknownPropertyException &ex ) { + (void)ex; OSL_FAIL( ::rtl::OUStringToOString( ex.Message + @@ -223,6 +226,7 @@ bool ItemConverter::ApplyItemSet( const SfxItemSet & rItemSet ) } catch( uno::Exception &ex ) { + (void)ex; OSL_FAIL( ::rtl::OUStringToOString( ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr()); } diff --git a/chart2/source/controller/main/SelectionHelper.cxx b/chart2/source/controller/main/SelectionHelper.cxx index 8e54505ab342..328b341ed08c 100644 --- a/chart2/source/controller/main/SelectionHelper.cxx +++ b/chart2/source/controller/main/SelectionHelper.cxx @@ -329,7 +329,6 @@ bool Selection::isResizeableObjectSelected() default: return false; } - return false; } bool Selection::isRotateableObjectSelected( const uno::Reference< frame::XModel >& xChartModel ) diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index b63ee06d8ed6..be33faca1b9e 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -776,6 +776,7 @@ void Desktop::ensureProcessServiceFactory() } catch (const css::uno::Exception& e) { + (void)e; OSL_FAIL(rtl::OUStringToOString(e.Message, osl_getThreadTextEncoding()).getStr()); // let exceptions escape and tear down the process, it is // completely broken anyway -- cgit From f8f02136d8984ebd0a1a79fa3169e61e53521215 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 31 Oct 2011 17:48:39 +0100 Subject: Removed obsolete soltools/testSHL. --- soltools/testSHL/inc/tlog.hxx | 99 ----------------------- soltools/testSHL/inc/tstMgr.hxx | 75 ------------------ soltools/testSHL/inc/tutil.hxx | 52 ------------ soltools/testSHL/makefile.mk | 52 ------------ soltools/testSHL/testshl.cxx | 96 ---------------------- soltools/testSHL/util/makefile.mk | 45 ----------- soltools/testSHL/util/tlog.cxx | 109 ------------------------- soltools/testSHL/util/tstMgr.cxx | 163 -------------------------------------- soltools/testSHL/util/tutil.cxx | 149 ---------------------------------- 9 files changed, 840 deletions(-) delete mode 100644 soltools/testSHL/inc/tlog.hxx delete mode 100644 soltools/testSHL/inc/tstMgr.hxx delete mode 100644 soltools/testSHL/inc/tutil.hxx delete mode 100644 soltools/testSHL/makefile.mk delete mode 100644 soltools/testSHL/testshl.cxx delete mode 100644 soltools/testSHL/util/makefile.mk delete mode 100644 soltools/testSHL/util/tlog.cxx delete mode 100644 soltools/testSHL/util/tstMgr.cxx delete mode 100644 soltools/testSHL/util/tutil.cxx diff --git a/soltools/testSHL/inc/tlog.hxx b/soltools/testSHL/inc/tlog.hxx deleted file mode 100644 index fa38483efd38..000000000000 --- a/soltools/testSHL/inc/tlog.hxx +++ /dev/null @@ -1,99 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _SOLTOOLS_TESTSHL_TLOG_HXX__ -#define _SOLTOOLS_TESTSHL_TLOG_HXX__ - -#include -#include - -#include "tutil.hxx" - -#include - -using namespace std; - -namespace tstutl { - -class tLog { - - // - ::osl::File* m_logfile; // fileobject - ::rtl::OUString m_logname; // name of log - // - - // - void initialize( const ::rtl::OString& name ); - // - -public: - - // - tLog() : m_logfile( 0 ) { - } - - tLog( const sal_Char* name ) { - if( name ) { - initialize( name ); - } - else { - m_logfile = 0; - } - - } - // - - // - virtual ~tLog() { - if ( m_logfile ) { - m_logfile->close(); - delete( m_logfile ); - } - } // - - // - inline ::rtl::OUString& getName() { return m_logname; } - inline ::osl::File* getFile() { return m_logfile; } - - // open logfile for overwrite (default) or append - ::osl::FileBase::RC open( sal_Bool append = sal_False ); - ::osl::FileBase::RC close(); - - ::osl::FileBase::RC writeRes( ::rtl::TestResult& oRes, sal_Bool v = sal_False , - sal_Bool xml = sal_False ); - - // write methods without (default) or with echo on display - ::osl::FileBase::RC write( const sal_Char* buf, sal_Bool v = sal_False ); - // - -}; // - -} // - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/soltools/testSHL/inc/tstMgr.hxx b/soltools/testSHL/inc/tstMgr.hxx deleted file mode 100644 index cbb8474b68af..000000000000 --- a/soltools/testSHL/inc/tstMgr.hxx +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _SOLTOOLS_TESTSHL_TSTMGR_HXX__ -#define _SOLTOOLS_TESTSHL_TSTMGR_HXX__ - -#include - -#include - -using namespace std; - -// -namespace tstutl { - -// -class tstMgr { - - // - struct tstMgr_Impl; - tstMgr_Impl* pImpl; - // - - // - void cleanup(); - // - -public: - tstMgr() : pImpl(0) {} - // - ~tstMgr(){ - cleanup(); - } // - - - // - sal_Bool initialize( sal_Char* moduleName, sal_Bool boom = sal_False ); - sal_Bool test_Entry( sal_Char* entry, sal_Char* logName = 0 ); - sal_Bool test_Entries( vector< sal_Char* > entries, sal_Char* logName = 0 ); - sal_Bool test_EntriesFromFile( sal_Char* fName, sal_Char* logName = 0 ); - // - -}; // - -} // - -#endif - - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/soltools/testSHL/inc/tutil.hxx b/soltools/testSHL/inc/tutil.hxx deleted file mode 100644 index 76c12b314548..000000000000 --- a/soltools/testSHL/inc/tutil.hxx +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _SOLTOOLS_TESTSHL_TUTIL_HXX_ -#define _SOLTOOLS_TESTSHL_TUTIL_HXX__ - -#include - -using namespace std; - -#include - -// -namespace tstutl { - -sal_uInt32 getEntriesFromFile( sal_Char* fName, vector< sal_Char* >& entries ); -::rtl::OUString cnvrtPth( ::rtl::OString sysPth ); - -// string copy, cat, len methods -sal_Char* cpy( sal_Char** dest, const sal_Char* src ); -sal_Char* cat( const sal_Char* str1, const sal_Char* str2 ); -sal_uInt32 ln( const sal_Char* str ); - -} // - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/soltools/testSHL/makefile.mk b/soltools/testSHL/makefile.mk deleted file mode 100644 index 0377137b2274..000000000000 --- a/soltools/testSHL/makefile.mk +++ /dev/null @@ -1,52 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# 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 -# -# for a copy of the LGPLv3 License. -# -#************************************************************************* -PRJ=.. - -PRJNAME=soltools -TARGET=testshl -TARGETTYPE=CUI - -# --- Settings ----------------------------------------------------- - -.INCLUDE : $(PRJ)$/util$/makefile.pmk -.INCLUDE : settings.mk - -UWINAPILIB=$(0) -LIBSALCPPRT=$(0) - -# ------------------------------------------------------------------ - -APP1TARGET= $(TARGET) -APP1OBJS= $(OBJ)$/$(TARGET).obj -APP1STDLIBS=$(SALLIB)\ - $(SALHELPERLIB) -APP1DEPN= $(LB)$/tstutil.lib -APP1LIBS= $(LB)$/tstutil.lib - -# --- Targets ------------------------------------------------------ - -.INCLUDE : target.mk diff --git a/soltools/testSHL/testshl.cxx b/soltools/testSHL/testshl.cxx deleted file mode 100644 index c66a238effa6..000000000000 --- a/soltools/testSHL/testshl.cxx +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_soltools.hxx" - -#include - -#include "inc/tlog.hxx" - -#include "inc/tstMgr.hxx" - -using namespace tstutl; - -void usage(); -void test_shl( vector< sal_Char* > cmdln, sal_Bool boom ); - -#if (defined UNX) -int main( int argc, char* argv[] ) -#else -int _cdecl main( int argc, char* argv[] ) -#endif -{ - if ( argc < 3 ) { - usage(); - } - sal_Bool boom = sal_False; - vector< sal_Char* > cmdln; - - sal_Int32 i; - for ( i = 1; i < argc; i++ ) { - sal_Char* ptr = argv[i]; - if ( ptr[0] == '-' ) { - boom = sal_True; - } - else { - cmdln.push_back( ptr ); - } - } - if ( cmdln.size() < 3 ) { - cmdln.push_back( 0 ); - } - if ( ! cmdln[0] || ! cmdln[1] ) { - usage(); - } - - test_shl( cmdln, boom ); - - return(0); -} - -void test_shl( vector< sal_Char*> cmdln, sal_Bool boom ) { - - tstMgr tst; - - if ( tst.initialize( cmdln[0], boom )) { - tst.test_EntriesFromFile( cmdln[1], cmdln[2] ); - } - else { - sal_Char* msg = "could not find module\n"; - fprintf( stdout, "%s\n", msg ); - } -} - -void usage(){ - fprintf( stdout, - "USAGE: testSHL shlname scename [logname] [-boom]\n" ); - exit(0); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/soltools/testSHL/util/makefile.mk b/soltools/testSHL/util/makefile.mk deleted file mode 100644 index a2582f9c1abd..000000000000 --- a/soltools/testSHL/util/makefile.mk +++ /dev/null @@ -1,45 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# 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 -# -# for a copy of the LGPLv3 License. -# -#************************************************************************* -PRJ=..$/.. - -PRJNAME=soltools -TARGET=tstutil - -# --- Settings ----------------------------------------------------- - -.INCLUDE : settings.mk - -# ------------------------------------------------------------------ - -OBJFILES =\ - $(OBJ)$/tlog.obj \ - $(OBJ)$/tutil.obj \ - $(OBJ)$/tstMgr.obj - -# --- Targets ------------------------------------------------------ - -.INCLUDE : target.mk diff --git a/soltools/testSHL/util/tlog.cxx b/soltools/testSHL/util/tlog.cxx deleted file mode 100644 index 65982ae978ec..000000000000 --- a/soltools/testSHL/util/tlog.cxx +++ /dev/null @@ -1,109 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_soltools.hxx" - -#include "tlog.hxx" - -using namespace std; - -// -namespace tstutl { - -// -void tLog::initialize( const ::rtl::OString& name ) { - m_logname = cnvrtPth( name ); - m_logfile = new ::osl::File( m_logname ); -} // - -// -::osl::FileBase::RC tLog::open( sal_Bool append ) { - - if ( m_logfile ) { - ::osl::FileBase::RC ret; - - if ( ! append ) { - ret = ::osl::File::remove( m_logname ); - } - - if( m_logfile->open( osl_File_OpenFlag_Write ) == ::osl::FileBase::E_NOENT ) { - ret = m_logfile->open( osl_File_OpenFlag_Write | osl_File_OpenFlag_Create ); - } - else { - ret = m_logfile->setPos( osl_Pos_End, 0 ); - } - return ret; - } - return ( ::osl::FileBase::E_INVAL ); -} // - -// -::osl::FileBase::RC tLog::close() { - if ( m_logfile ) { - return m_logfile->close(); - } - return ( ::osl::FileBase::E_INVAL ); -} // - -// -::osl::FileBase::RC tLog::writeRes( ::rtl::TestResult& oRes, sal_Bool v, sal_Bool xml ) { - ::osl::FileBase::RC ret; - - sal_Char* ptr = oRes.getName(); - ptr = cat( ptr, ";" ); - ptr = cat( ptr, oRes.getResult() ); - ret = write( cat( ptr, "\n" ), v ); - delete [] ptr; - - return( ret ); -} // - -// -::osl::FileBase::RC tLog::write( const sal_Char* buf, sal_Bool v ) { - - if ( ! m_logfile ) { - fprintf( stderr, "%s", buf ); - return ( ::osl::FileBase::E_NOENT ); - } - sal_uInt64 uBytes=0; - sal_uInt32 len = ln( buf ); - - if ( v ) { - fprintf( stderr, "%s", buf ); - } - return m_logfile->write( buf, len , uBytes ); -} // - -} // - - - - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/soltools/testSHL/util/tstMgr.cxx b/soltools/testSHL/util/tstMgr.cxx deleted file mode 100644 index 7fa2bd7e40ad..000000000000 --- a/soltools/testSHL/util/tstMgr.cxx +++ /dev/null @@ -1,163 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_soltools.hxx" -#include "tstMgr.hxx" -#include -#include - -#include "tlog.hxx" - -#include "tutil.hxx" - -using namespace rtl; - -// -namespace tstutl { - -typedef void* ( tstFunc )( TestResult* ); -void test_Entry_Impl( ::osl::Module& oMod, TestResult* oRes ); - -// -struct tstMgr::tstMgr_Impl { - ::osl::Module m_tstmodule; - sal_Bool m_boom; -}; -// - -// -sal_Bool tstMgr::initialize( sal_Char* modName, sal_Bool boom ) { - - ::rtl::OUString tstMod( ::rtl::OUString::createFromAscii( modName ) ); - pImpl = new tstMgr_Impl; - pImpl->m_boom = boom; - return ( pImpl->m_tstmodule.load( tstMod ) ); -} // - -// -sal_Bool tstMgr::test_Entries( vector< sal_Char* > entries, - sal_Char* logName ) { - - sal_Bool bOK = sal_False; - if ( ! entries.empty() ) { - - bOK = sal_True; - vector< sal_Char* >::iterator iter = entries.begin(); - - tLog log( logName ); - // open testLog - log.open(); - while ( iter != entries.end() ) { - if ( *iter[0] != '#' ) { - ::rtl::TestResult oRes( *iter, pImpl->m_boom ); - test_Entry_Impl( pImpl->m_tstmodule, &oRes ); - bOK &= oRes.getState(); - log.writeRes( oRes ); - } - ++iter; - } - log.close(); - } - return ( bOK ); -} // - -// -sal_Bool tstMgr::test_Entry( sal_Char* entry, sal_Char* logName ) { - - tLog log( logName ); - // open testLog - log.open(); - ::rtl::TestResult oRes( entry, pImpl->m_boom ); - test_Entry_Impl( pImpl->m_tstmodule, &oRes ); - log.writeRes( oRes, sal_True ); - log.close(); - return ( oRes.getState() ); -} // - -// -sal_Bool tstMgr::test_EntriesFromFile( sal_Char* fName, sal_Char* logName ) { - - sal_Bool bOK = sal_False; - vector< sal_Char* > entries; - - if ( getEntriesFromFile( fName, entries ) ) { - sal_Bool bOK = test_Entries( entries, logName ); - - vector< sal_Char* >::iterator iter = entries.begin(); - while ( iter != entries.end() ) { - if ( *iter ) { - delete [] *iter; - } - ++iter; - } - } - else { - bOK = test_Entry( fName ); - } - return ( bOK ); - -} // - -// -void tstMgr::cleanup() { - if ( pImpl ) { - delete pImpl; - } -} // - - -// -void test_Entry_Impl( ::osl::Module& oMod, ::rtl::TestResult* oRes ) { - - tstFunc* pFunc; // entry pointer - ::rtl::OString entryName( "test_" ); // entryname prefix - - // prefix entryname - entryName += oRes->getName(); - - // get entry pointer - pFunc = (tstFunc*) oMod.getSymbol( - ::rtl::OUString::createFromAscii( entryName.getStr() ) ); - - if ( pFunc ) { - // call entry - pFunc( oRes ); - oRes->end(); - } - else { - oRes->end("symbol not found"); - } - // return - return; - -} // - -} // - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/soltools/testSHL/util/tutil.cxx b/soltools/testSHL/util/tutil.cxx deleted file mode 100644 index 81d068917101..000000000000 --- a/soltools/testSHL/util/tutil.cxx +++ /dev/null @@ -1,149 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_soltools.hxx" -#include "tutil.hxx" - -// -namespace tstutl { - -// getcwd hack is deprecated as soon as normalizePath works as intend -#ifdef WNT -#define _getcwd getcwd -#include // _getcwd -#else -#include // getcwd -#endif - -// -::rtl::OUString cnvrtPth( ::rtl::OString sysPth ) { - - using ::osl::FileBase; - using ::rtl::OUString; - using ::rtl::OString; - - ::rtl::OUString ret; - sysPth = sysPth.replace( '\\','/' ); - OUString pth( OUString::createFromAscii( sysPth.getStr() ) ); - - if ( sysPth.indexOf("..") != -1 ) { - - // for osl_normalizePath() can't handle relatives - char buffer[256]; - OString curPth(getcwd(buffer,256)); - // - OUString nrmCurPth; - FileBase::normalizePath( OUString::createFromAscii( curPth ) , - nrmCurPth ); - FileBase::getAbsolutePath( nrmCurPth, pth, ret ); - } - else { - FileBase::normalizePath( pth, ret ); - } - return ret; - -} // - -// -sal_uInt32 getEntriesFromFile( sal_Char* fName, - vector< sal_Char* >& entries ) { - - ::osl::File inFile( cnvrtPth( fName ) ); - if ( inFile.open( osl_File_OpenFlag_Read ) == ::osl::FileBase::E_None) { - ::rtl::ByteSequence byteSeq; - inFile.readLine( byteSeq ); - while ( byteSeq.getLength() ) { - sal_uInt32 len = byteSeq.getLength(); - sal_uInt32 i; - sal_Char* pEnt = new sal_Char[ len+1 ]; - sal_Char* bsPtr = (sal_Char*)byteSeq.getArray(); - for ( i=0; i - -// -sal_Char* cpy( sal_Char** dest, const sal_Char* src ) { - - *dest = new sal_Char[ ln(src)+1 ]; - // set pointer - sal_Char* pdest = *dest; - const sal_Char* psrc = src; - - // copy string by char - while( *pdest++ = *psrc++ ); - - return ( *dest ); - -} // - -// -sal_Char* cat( const sal_Char* str1, const sal_Char* str2 ) { - - // allocate memory for destination string - sal_Char* dest = new sal_Char[ ln(str1)+ln(str2)+1 ]; - - // set pointers - sal_Char* pdest = dest; - const sal_Char* psrc = str1; - - // copy string1 by char to dest - while( *pdest++ = *psrc++ ); - pdest--; - psrc = str2; - while( *pdest++ = *psrc++ ); - - return ( dest ); - -} // - -// -sal_uInt32 ln( const sal_Char* str ) { - - sal_uInt32 len = 0; - const sal_Char* ptr = str; - - if( ptr ) { - while( *ptr++ ) len++; - } - - return(len); -} // - -} // - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit From 451c945da28818d3791dcaf85716ceae8fa70e61 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 31 Oct 2011 17:50:40 +0100 Subject: Fixed rtl_getGlobalProcessId implementation (moved from C to C++). --- sal/rtl/source/rtl_process.c | 51 ---------------------------------- sal/rtl/source/rtl_process.cxx | 63 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 51 deletions(-) delete mode 100644 sal/rtl/source/rtl_process.c create mode 100644 sal/rtl/source/rtl_process.cxx diff --git a/sal/rtl/source/rtl_process.c b/sal/rtl/source/rtl_process.c deleted file mode 100644 index 0845f46f5723..000000000000 --- a/sal/rtl/source/rtl_process.c +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include -#include -#include - -/* rtl_getCommandArg, rtl_getCommandArgCount see cmdargs.cxx */ - -void SAL_CALL rtl_getGlobalProcessId( sal_uInt8 *pTargetUUID ) -{ - static sal_uInt8 *pUuid = 0; - if( ! pUuid ) - { - osl_acquireMutex( * osl_getGlobalMutex() ); - if( ! pUuid ) - { - static sal_uInt8 aUuid[16]; - rtl_createUuid( aUuid , 0 , sal_False ); - pUuid = aUuid; - } - osl_releaseMutex( * osl_getGlobalMutex() ); - } - memcpy( pTargetUUID , pUuid , 16 ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/rtl_process.cxx b/sal/rtl/source/rtl_process.cxx new file mode 100644 index 000000000000..e20b3338ba88 --- /dev/null +++ b/sal/rtl/source/rtl_process.cxx @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_sal.hxx" +#include "sal/config.h" + +#include + +#include "boost/noncopyable.hpp" +#include "rtl/instance.hxx" +#include "rtl/process.h" +#include "rtl/uuid.h" +#include "sal/types.h" + +namespace { + +class Id: private boost::noncopyable { +public: + Id() { rtl_createUuid(uuid_, 0, false); } + + void copy(sal_uInt8 * target) const + { std::memcpy(target, uuid_, UUID_SIZE); } + +private: + enum { UUID_SIZE = 16 }; + + sal_uInt8 uuid_[UUID_SIZE]; +}; + +struct theId: public rtl::Static< Id, theId > {}; + +} + +void rtl_getGlobalProcessId(sal_uInt8 * pTargetUUID) { + theId::get().copy(pTargetUUID); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit From f67c6fa040346dcf211699d0c31676909fae4b95 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 31 Oct 2011 17:57:35 +0100 Subject: Removed obsolete rtl/tres stuff. --- sal/inc/rtl/tres.h | 109 ------- sal/inc/rtl/tres.hxx | 111 -------- sal/rtl/source/makefile.mk | 2 - sal/rtl/source/tres.c | 688 --------------------------------------------- sal/util/sal.map | 2 - 5 files changed, 912 deletions(-) delete mode 100644 sal/inc/rtl/tres.h delete mode 100644 sal/inc/rtl/tres.hxx delete mode 100644 sal/rtl/source/tres.c diff --git a/sal/inc/rtl/tres.h b/sal/inc/rtl/tres.h deleted file mode 100644 index 102c2ee2319b..000000000000 --- a/sal/inc/rtl/tres.h +++ /dev/null @@ -1,109 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -#ifndef _RTL_TRES_H_ -#define _RTL_TRES_H_ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - - /* comandline flags */ -#define rtl_tres_Flag_BOOM 0x00000001 -#define rtl_tres_Flag_VERBOSE 0x00000002 -#define rtl_tres_Flag_SKIP 0x00000004 -#define rtl_tres_Flag_LOG 0x00000010 -#define rtl_tres_Flag_HIS 0x00000100 -#define rtl_tres_Flag_TIME 0x00000200 -#define rtl_tres_Flag_MSG 0x00000400 -#define rtl_tres_Flag_QUIET 0x00000800 - - /* state flags */ -#define rtl_tres_Flag_SUB 0x01000000 -#define rtl_tres_Flag_PASSED 0x10000000 -#define rtl_tres_Flag_OK 0x20000000 - - - - /* forward declaration and type definition */ -struct _rtl_TestResult; -typedef struct _rtl_TestResult rtl_TestResult; - - -typedef void* rtl_funcstate; -typedef void* rtl_cmpstate; - - /* type definitions of function pointers wich can be overloaded */ -typedef sal_Bool (SAL_CALL *rtl_tres_state_ptr)( - rtl_TestResult*, - sal_Bool, - const sal_Char*, - const sal_Char*, - sal_Bool - ); - -typedef void (SAL_CALL *rtl_tres_end_ptr)( rtl_TestResult*, const sal_Char* ); -typedef sal_Bool (SAL_CALL *rtl_tres_ispassed_ptr)( rtl_TestResult* ); -typedef sal_Bool (SAL_CALL *rtl_tres_isok_ptr)( rtl_TestResult* ); -typedef rtl_funcstate (SAL_CALL *rtl_tres_funcstate_ptr)( rtl_TestResult* ); -typedef sal_Bool (SAL_CALL *rtl_tres_isbit_ptr)( rtl_TestResult*, - sal_uInt32 ); - -typedef rtl_funcstate (SAL_CALL *rtl_tres_getnextfuncstate_ptr) - ( rtl_funcstate ); -typedef rtl_funcstate (SAL_CALL *rtl_tres_getprevfuncstate_ptr) - ( rtl_funcstate ); -typedef sal_uInt32 (SAL_CALL *rtl_tres_getflags_ptr)( rtl_funcstate ); -typedef rtl_String* (SAL_CALL *rtl_tres_getname_ptr)( rtl_funcstate ); -typedef sal_uInt32 (SAL_CALL *rtl_tres_getstart_ptr)( rtl_funcstate ); -typedef sal_uInt32 (SAL_CALL *rtl_tres_getstop_ptr)( rtl_funcstate ); -typedef rtl_cmpstate (SAL_CALL *rtl_tres_getcmpstate_ptr)( rtl_funcstate ); - -typedef sal_Bool (SAL_CALL *rtl_tres_getstat_ptr)( rtl_cmpstate ); -typedef rtl_String* (SAL_CALL *rtl_tres_getmsg_ptr)( rtl_cmpstate ); -typedef rtl_cmpstate (SAL_CALL *rtl_tres_getnextcmpstate_ptr)( rtl_cmpstate ); - - /* type definition of vtable structure for testresult */ -typedef struct _rtl_TestResult_vtable -{ - sal_uInt32 vtablesize; - rtl_tres_state_ptr state_; - rtl_tres_end_ptr end_; - rtl_tres_ispassed_ptr ispassed; - rtl_tres_isok_ptr isok; - rtl_tres_funcstate_ptr funcstate; - rtl_tres_isbit_ptr isbit; - rtl_tres_getnextfuncstate_ptr nextfuncstate; - rtl_tres_getprevfuncstate_ptr prevfuncstate; - rtl_tres_getflags_ptr flags; - rtl_tres_getname_ptr name; - rtl_tres_getstart_ptr start; - rtl_tres_getstop_ptr stop; - rtl_tres_getcmpstate_ptr cmpstate; - rtl_tres_getstat_ptr stat; - rtl_tres_getmsg_ptr msg; - rtl_tres_getnextcmpstate_ptr nextcmpstate; - -} rtl_TestResult_vtable; - - /* type definition of testresult structure */ -struct _rtl_TestResult -{ - rtl_TestResult_vtable * pFuncs; - void * pExternalData; - -}; - - - /* exports */ -rtl_TestResult* SAL_CALL rtl_tres_create( const sal_Char* meth, sal_uInt32 flags ); -void SAL_CALL rtl_tres_destroy( rtl_TestResult* res ); - -#ifdef __cplusplus -} -#endif - -#endif /* _RTL_TRES_H_ */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/inc/rtl/tres.hxx b/sal/inc/rtl/tres.hxx deleted file mode 100644 index 2c0ee9906809..000000000000 --- a/sal/inc/rtl/tres.hxx +++ /dev/null @@ -1,111 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef _RTL_TRES_HXX_ -#define _RTL_TRES_HXX_ - -#include - -// -namespace rtl -{ -/*==========================================================================*/ - -// -class TestResult -{ - // pointer to testresult structure - rtl_TestResult* pData; - - // - TestResult(); - TestResult( const TestResult& oRes ); - // - -public: - - - // - TestResult( const sal_Char* meth, sal_uInt32 flags = 0 ) - { - pData = rtl_tres_create( meth, flags ); - } // - - // - ~TestResult() - { - rtl_tres_destroy( pData ); - } - // - - // - rtl_TestResult* getData() - { - return pData; - } - // - sal_Bool state( - sal_Bool tst_state, - const sal_Char* msg = 0, - const sal_Char* sub = 0, - sal_Bool verbose = sal_False - ) - { - return pData->pFuncs->state_( pData, tst_state, msg, sub, verbose ); - } // - - void end( sal_Char* msg = 0 ) - { - pData->pFuncs->end_( pData, msg ); - } // -}; // - -} // -#endif - - - - - - - - - - - - - - - - - - - - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/makefile.mk b/sal/rtl/source/makefile.mk index 2f1f610a5330..07c36d38ed7e 100644 --- a/sal/rtl/source/makefile.mk +++ b/sal/rtl/source/makefile.mk @@ -87,7 +87,6 @@ SLOFILES= \ $(SLO)$/cmdargs.obj \ $(SLO)$/unload.obj \ $(SLO)$/logfile.obj \ - $(SLO)$/tres.obj \ $(SLO)$/debugprint.obj \ $(SLO)$/math.obj \ $(SLO)$/alloc_global.obj\ @@ -116,7 +115,6 @@ OBJFILES= \ $(OBJ)$/cmdargs.obj \ $(OBJ)$/unload.obj \ $(OBJ)$/logfile.obj \ - $(OBJ)$/tres.obj \ $(OBJ)$/math.obj \ $(OBJ)$/alloc_global.obj\ $(OBJ)$/alloc_cache.obj \ diff --git a/sal/rtl/source/tres.c b/sal/rtl/source/tres.c deleted file mode 100644 index 2cf429c6a49c..000000000000 --- a/sal/rtl/source/tres.c +++ /dev/null @@ -1,688 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include -#include -#include -#include - - /* force an assertion on false state */ -#define TST_BOOM(c, m) OSL_ENSURE(c, m) - - -typedef struct _rtl_CmpState -{ - struct _rtl_CmpState* m_next; - struct _rtl_CmpState* m_prev; - - sal_Bool m_stat; - rtl_String* m_msg; - -} rtl_CmpState; - -typedef struct _rtl_FuncState -{ - struct _rtl_FuncState* m_next; - struct _rtl_FuncState* m_prev; - rtl_String* m_name; - sal_uInt32 m_flags; - sal_uInt32 m_start; - sal_uInt32 m_stop; - struct _rtl_CmpState* m_cmp; - -} rtl_FuncState; - - - -typedef struct _rtl_TestResult_Data -{ - rtl_TestResult_vtable* m_funcs; - void* m_externaldata; - - rtl_FuncState* m_state; - -} rtl_TestResult_Data; - - - /** - * internal helper functions - */ - - /* ...to create, link, unlink and destroy allocated memory */ -rtl_FuncState* SAL_CALL rtl_tres_create_funcstate( const sal_Char* meth ); -rtl_FuncState* SAL_CALL rtl_tres_link_funcstate( rtl_FuncState* ptr, - rtl_FuncState* plink ); -rtl_FuncState* SAL_CALL rtl_tres_unlink_funcstate( rtl_FuncState* plink ); -rtl_CmpState* SAL_CALL rtl_tres_create_cmpstate( - sal_Bool state, - const sal_Char* msg - ); -rtl_CmpState* SAL_CALL rtl_tres_link_cmpstate( rtl_CmpState* ptr, - rtl_CmpState* plink ); -rtl_CmpState* SAL_CALL rtl_tres_unlink_cmpstate( rtl_CmpState* plink ); -sal_uInt32 SAL_CALL rtl_tres_timer(); -void SAL_CALL rtl_tres_destroy_funcstate( rtl_FuncState* pState_ ); -void SAL_CALL rtl_tres_destroy_funcstates( rtl_FuncState* pState_ ); -void SAL_CALL rtl_tres_destroy_cmpstates( rtl_CmpState* pState_ ); -void SAL_CALL rtl_tres_destroy_cmpstate( rtl_CmpState* pState_ ); - - - /* set and clear single bits */ -static void SAL_CALL rtl_tres_setbit( rtl_FuncState* pState_, - sal_uInt32 flag ); -static void SAL_CALL rtl_tres_clearbit( rtl_FuncState* pState_, - sal_uInt32 flag ); - - /** - * forward declarations of concrete function implementations overloadable - * and accessible via vtable - */ -static sal_Bool SAL_CALL rtl_tres_state( - rtl_TestResult* pThis_, - sal_Bool state, - const sal_Char* msg, - const sal_Char* sub, - sal_Bool v - ); - -static void SAL_CALL rtl_tres_end( rtl_TestResult* pThis_, - const sal_Char* msg ); - -static rtl_funcstate SAL_CALL rtl_tres_funcstate( rtl_TestResult* pThis_ ); - -static sal_Bool SAL_CALL rtl_tres_ispassed( rtl_TestResult* pThis_ ); -static sal_Bool SAL_CALL rtl_tres_isok( rtl_TestResult* pThis_ ); - -static sal_Bool SAL_CALL rtl_tres_isbit( rtl_TestResult* pThis_, - sal_uInt32 flag ); - -static rtl_funcstate SAL_CALL rtl_tres_getnextfuncstate( rtl_funcstate ); -static rtl_funcstate SAL_CALL rtl_tres_getprevfuncstate( rtl_funcstate ); -static sal_uInt32 SAL_CALL rtl_tres_getflags( rtl_funcstate ); -sal_uInt32 SAL_CALL rtl_tres_getstarttime( rtl_funcstate ); -sal_uInt32 SAL_CALL rtl_tres_getstoptime( rtl_funcstate ); -static rtl_cmpstate SAL_CALL rtl_tres_getcmpstate( rtl_funcstate ); - -static sal_Bool SAL_CALL rtl_tres_getstat( rtl_cmpstate ); -rtl_String* SAL_CALL rtl_tres_getname( rtl_funcstate ); -rtl_String* SAL_CALL rtl_tres_getmsg( rtl_cmpstate ); -static rtl_cmpstate SAL_CALL rtl_tres_getnextcmpstate( rtl_cmpstate ); - - - /** - * initialize vtable with function pointers - */ -static rtl_TestResult_vtable trVTable = -{ - sizeof(rtl_TestResult_vtable), - rtl_tres_state, - rtl_tres_end, - rtl_tres_ispassed, - rtl_tres_isok, - rtl_tres_funcstate, - rtl_tres_isbit, - rtl_tres_getnextfuncstate, - rtl_tres_getprevfuncstate, - rtl_tres_getflags, - rtl_tres_getname, - rtl_tres_getstarttime, - rtl_tres_getstoptime, - rtl_tres_getcmpstate, - rtl_tres_getstat, - rtl_tres_getmsg, - rtl_tres_getnextcmpstate -}; - - /** - * rtl_tres_create - * create and initialize data struct for TestResult - * - * @param const sal_Char* meth = name of the method (entryname) - * @param sal_uInt32 flags = bitmap of comandline and status flags - * - * @return rtl_TestResult* = pointer to a new allocated testresult struct - */ -rtl_TestResult* rtl_tres_create( const sal_Char* meth, sal_uInt32 flags ) -{ - /* allocate memory for testresult data structure */ - rtl_TestResult_Data* pData = (rtl_TestResult_Data*) malloc( sizeof( - rtl_TestResult_Data ) ); - /* initialize members... */ - pData->m_funcs = &trVTable; /* ...vtableptr to vtbladr */ - pData->m_externaldata = 0; /* ...external data pointer */ - - /* allocate memory for state structure and initialize members */ - pData->m_state = rtl_tres_create_funcstate( meth ); - pData->m_state->m_flags = flags; /* ...option Bitmap */ - - /* set OK flag initial */ - rtl_tres_setbit( pData->m_state, rtl_tres_Flag_OK ); - - return (rtl_TestResult*)pData ; -} - -/** - * rtl_tres_create_funcstate - * allocates and initializes a structure to represent the status of a test - * entry or its substates - * - * @param const sal_Char* meth = the name of the method (entry or sub entry) - * - * @return rtl_FuncState* = pointer to a new allocated funcstate struct - */ -rtl_FuncState* SAL_CALL rtl_tres_create_funcstate( const sal_Char* meth ) -{ - rtl_FuncState* pStat = 0; /* status structure */ - - /* allocate memory for status structure */ - pStat = (rtl_FuncState*) malloc( sizeof( struct _rtl_FuncState ) ); - - if ( pStat ) - { - pStat->m_next = pStat; /* init ptr to next struct */ - pStat->m_prev = pStat; /* init ptr to prev struct */ - - pStat->m_name = 0; /* init name */ - pStat->m_flags = 0; /* init flags */ - pStat->m_start = rtl_tres_timer(); /* init start milliseconds */ - pStat->m_stop = 0; /* init stop milliseconds */ - pStat->m_cmp = 0; /* init ptr to msg struct */ - rtl_string_newFromStr( &pStat->m_name, meth );/* copy meth to name */ - - /* set ok flag initially */ - rtl_tres_setbit(pStat, rtl_tres_Flag_OK); - } - - return ( pStat ); -} - /** - * rtl_tres_link_funcstate - * link initialized funcstate structure to a circular double linked list - * - * @param rtl_FuncState* ptr = pointer to a funcstate where to link in new - * @param rtl_FuncState* plink = pointer to a funcstate to link in list - * - * @return rtl_FuncState* = pointer to structure linked in new - */ -rtl_FuncState* SAL_CALL rtl_tres_link_funcstate( rtl_FuncState* ptr, - rtl_FuncState* plink ) -{ - ptr->m_next->m_prev = plink; - ptr->m_next->m_prev->m_next = ptr->m_next; - ptr->m_next->m_prev->m_prev = ptr; - ptr->m_next = plink; - return ( plink ); -} - - /** - * rtl_tres_unlink_funcstate - * unlink funcstate structure from a circular double linked list - * - * @param rtl_FuncState* plink = pointer to a funcstate to unlink from list - * - * @return rtl_FuncState* = pointer to funcstate struct unlinked from - * list - */ -rtl_FuncState* SAL_CALL rtl_tres_unlink_funcstate( rtl_FuncState* plink ) -{ - plink->m_next->m_prev = plink->m_prev; - plink->m_prev->m_next = plink->m_next; - plink->m_next = plink; - plink->m_prev = plink; - return ( plink ); -} - - /** - * rtl_tres_link_cmpstate - * link initialized cmpstate structure to a circular double linked list - * - * @param rtl_CmpState* ptr = pointer to a cmpstate where to link in new - * @param rtl_CmpState* plink = pointer to a cmpstate to link in list - * - * @return rtl_CmpState* = pointer to cmpstate struct linked in new - */ -rtl_CmpState* SAL_CALL rtl_tres_link_cmpstate( rtl_CmpState* ptr, - rtl_CmpState* plink ) -{ - ptr->m_next->m_prev = plink; - ptr->m_next->m_prev->m_next = ptr->m_next; - ptr->m_next->m_prev->m_prev = ptr; - ptr->m_next = plink; - return ( plink ); -} - /** - * rtl_tres_unlink_cmpstate - * unlink cmpstate structure from a circular double linked list - * - * @param rtl_CmpState* plink = pointer to a cmpstate to unlink from list - * - * @return rtl_CmpState* = pointer to cmpstate struct unlinked from list - */ -rtl_CmpState* SAL_CALL rtl_tres_unlink_cmpstate( rtl_CmpState* plink ) -{ - plink->m_next->m_prev = plink->m_prev; - plink->m_prev->m_next = plink->m_next; - plink->m_next = plink; - plink->m_prev = plink; - return ( plink ); -} - - /** - * rtl_tres_create_cmpstate - * allocates and initializes a structure to represent the status of a test - * comparison - * - * @param sal_Bool state = compare state - * @param sal_Char* msg = message for logging and debug purposes - * - * @return rtl_CmpState* = pointer to the new allocated struct - */ -rtl_CmpState* SAL_CALL rtl_tres_create_cmpstate( - sal_Bool state, - const sal_Char* msg - ) -{ - /* allocate memory for cmpstate struct */ - rtl_CmpState* pStat = (rtl_CmpState*) malloc( sizeof( rtl_CmpState ) ); - - /* initialize if memory could be allocated */ - if ( pStat ) - { - pStat->m_next = pStat; /* init next with this */ - pStat->m_prev = pStat; /* init prev with this */ - pStat->m_msg = 0; - pStat->m_stat = state; /* boolean state */ - rtl_string_newFromStr( &pStat->m_msg, msg ); /* copy message */ - } - return ( pStat ); -} - - /** - * rtl_tres_destroy - * free allocated memory of testresult data struct - * - * @param rtl_TestResult* pThis_ = ponter to a valid testresult struct - */ -void SAL_CALL rtl_tres_destroy( rtl_TestResult* pThis_ ) -{ - /* cast to implementation representation structure */ - rtl_TestResult_Data* pData = (rtl_TestResult_Data*) pThis_; - - /* destroy all funcstates */ - if ( pData->m_state ) - rtl_tres_destroy_funcstates( pData->m_state ); - - /* free allocted memory and reinitialize to zero */ - /* to be able to prevent dangling pointer access*/ - free( pData ); pData = 0; -} - - /** - * rtl_tres_destroy_funcstates - * free allocated memory occupied by the list of funcstate data structs - * (iterates through next pointers) - * - * @param rtl_FuncState* pState_ = pointer to a valid funcstate struct - */ -void SAL_CALL rtl_tres_destroy_funcstates( rtl_FuncState* pState_ ) -{ - rtl_FuncState* plink = pState_->m_next; - while ( plink != plink->m_next ) - { - rtl_tres_destroy_funcstate( rtl_tres_unlink_funcstate( plink ) ); - plink = pState_->m_next; - } - rtl_tres_destroy_funcstate( plink ); -} - - /** - * rtl_tres_destroy_cmpstates - * free allocated memory occupied by the list of cmpstate data structs - * (iterates through next pointers) - * - * @param rtl_CmpState* pState_ = pointer to a valid cmpstate struct - */ -void SAL_CALL rtl_tres_destroy_cmpstates( rtl_CmpState* pState_ ) -{ - rtl_CmpState* plink = pState_->m_next; - while ( plink != plink->m_next ) - { - rtl_tres_destroy_cmpstate( rtl_tres_unlink_cmpstate( plink ) ); - plink = pState_->m_next; - } - rtl_tres_destroy_cmpstate( plink ); -} - - - /** - * rtl_tres_destroy_funcstate - * free allocated memory occupied by one funcstate and it's list - * of cmpstate data structs - * - * @param rtl_FuncState* pState_ = pointer to a valid funcstate struct - */ -void SAL_CALL rtl_tres_destroy_funcstate( rtl_FuncState* pState_ ) -{ - rtl_FuncState* plink = pState_; - - if ( plink->m_cmp ) - rtl_tres_destroy_cmpstates( plink->m_cmp ); - - if ( plink->m_name ) - { - rtl_string_release( plink->m_name ); - plink->m_name = 0; - } - plink->m_flags = 0; - free( plink ); - plink = 0; -} - - /** - * rtl_tres_destroy_cmpstate - * free allocated memory of a cmpstate data struct - * - * @param rtl_CmpState* pState_ = pointer to cmpstate struct to destroy - */ -void SAL_CALL rtl_tres_destroy_cmpstate( rtl_CmpState* pState_ ) -{ - - rtl_CmpState* plink = pState_; - - if ( plink->m_msg ) - { - rtl_string_release( plink->m_msg ); - plink->m_msg = 0; - } - free( plink ); - plink = 0; -} - /** - * central function to call in tests - * - * @param rtl_TestResult* pThis_ = self pointer to TestResult structure - * @param sal_Bool state = boolean result of statement comparison - * @param const sal_Char* msg = message for actual statementcomparison - * @param const sal_Char* sub = name of sub testfunction - * @param sal_Bool v = boolean verbose parameter - * - * @return sal_Bool = determines if statement comparison - * was positive or not - */ -static sal_Bool SAL_CALL rtl_tres_state( - rtl_TestResult* pThis_, - sal_Bool state, - const sal_Char* msg, - const sal_Char* sub, - sal_Bool v - ) -{ - - /* cast pointer to testresult data implementation struct*/ - rtl_TestResult_Data* pData = (rtl_TestResult_Data*)pThis_; - - /* initialize funcstate pointer with masterstate */ - rtl_FuncState* pFunc = pData->m_state; - - /* if substate required */ - if ( sub ) - { - /* link new created function state to last item */ - pFunc = rtl_tres_link_funcstate( pFunc->m_prev, - rtl_tres_create_funcstate( sub ) ); - - /* indicate this state as substate */ - rtl_tres_setbit( pFunc, rtl_tres_Flag_SUB ); - - /* indicate prvious state as passed if no masterstate */ - if ( pFunc->m_prev != pData->m_state ) - rtl_tres_setbit( pFunc->m_prev, rtl_tres_Flag_PASSED ); - } - - - /* test failed */ - if( ! state ) - { - /* determine if assertion should be thrown */ - if ( rtl_tres_isbit( pThis_, rtl_tres_Flag_BOOM ) ) - { - /* if message available */ - if ( msg ) - TST_BOOM( state, msg ); - else - TST_BOOM( state, "no msg available" ); - } - - /* clear this state ok flag and masterstate ok flag */ - rtl_tres_clearbit( pFunc, rtl_tres_Flag_OK ); - rtl_tres_clearbit( pData->m_state, rtl_tres_Flag_OK ); - } - /* message available */ - if( msg ) - { - /* append a new comparison state */ - if (! pFunc->m_cmp ) - pFunc->m_cmp = rtl_tres_create_cmpstate( state, msg ); - else - rtl_tres_link_cmpstate( pFunc->m_cmp, - rtl_tres_create_cmpstate(state, msg ) ); - - /* message to stderr required ? */ - if ( v || ( pFunc->m_next->m_flags & rtl_tres_Flag_VERBOSE ) ) - fprintf( stderr, "%s\n", msg ); - } - - pFunc->m_stop = rtl_tres_timer(); - return ( state ); -} - - /** - * rtl_tres_timer - * function to get actual timevalue - * this has to be replaced by a high resolution timer - */ -sal_uInt32 SAL_CALL rtl_tres_timer() -{ - sal_uInt32 val = 0; - TimeValue* tmv = (TimeValue*)malloc( sizeof( TimeValue ) ); - osl_getSystemTime( tmv ); - val = tmv->Nanosec/1000L; - free( tmv ); - return ( val ); -} - - -static void SAL_CALL rtl_tres_end( rtl_TestResult* pThis_, - const sal_Char* msg ) -{ - rtl_TestResult_Data* pData = (rtl_TestResult_Data*) pThis_; - - if( msg ) - { - if (! pData->m_state->m_cmp ) - pData->m_state->m_cmp = rtl_tres_create_cmpstate( sal_True, msg ); - else - rtl_tres_link_cmpstate( pData->m_state->m_cmp, - rtl_tres_create_cmpstate( sal_True, msg ) ); - } - pData->m_state->m_prev->m_flags |= rtl_tres_Flag_PASSED; - pData->m_state->m_flags |= rtl_tres_Flag_PASSED; - pData->m_state->m_stop = rtl_tres_timer(); -} - - -static sal_Bool SAL_CALL rtl_tres_ispassed( rtl_TestResult* pThis_ ) -{ - return rtl_tres_isbit( pThis_, rtl_tres_Flag_PASSED ); -} - -static sal_Bool SAL_CALL rtl_tres_isok( rtl_TestResult* pThis_ ) -{ - return rtl_tres_isbit( pThis_, rtl_tres_Flag_OK ); -} - /** - * return pointer to funcstate structure - */ -static rtl_funcstate SAL_CALL rtl_tres_funcstate( rtl_TestResult* pThis_ ) -{ - - rtl_TestResult_Data* pThis = (rtl_TestResult_Data*) pThis_; - return (rtl_funcstate)pThis->m_state; -} - - /** - * determine if a flag is set or not - */ -static sal_Bool SAL_CALL rtl_tres_isbit( rtl_TestResult* pThis_, - sal_uInt32 flag ) -{ - return (sal_Bool) - ((((rtl_TestResult_Data *) pThis_)->m_state->m_flags & flag) == flag); -} - /** - * set one single bit - */ -static void SAL_CALL rtl_tres_setbit( rtl_FuncState* pState_, - sal_uInt32 flag ) -{ - pState_->m_flags |= flag; -} - /** - * clear one single bit - */ -static void SAL_CALL rtl_tres_clearbit( rtl_FuncState* pState_, - sal_uInt32 flag ) -{ - pState_->m_flags = pState_->m_flags & ( ~flag ); -} - - /** - * returns next pointer of passed funcstate structure - */ -rtl_funcstate SAL_CALL rtl_tres_getnextfuncstate( rtl_funcstate fstate ) -{ - rtl_FuncState* fs = (rtl_FuncState*)fstate; - return( (rtl_funcstate)fs->m_next ); - -} - /** - * returns previous pointer of passed funcstate structure - */ -rtl_funcstate SAL_CALL rtl_tres_getprevfuncstate( rtl_funcstate fstate ) -{ - rtl_FuncState* fs = (rtl_FuncState*)fstate; - return( (rtl_funcstate)fs->m_prev ); - -} - /** - * returns flag value of passed funcstate structure - */ -sal_uInt32 SAL_CALL rtl_tres_getflags( rtl_funcstate fstate ) -{ - rtl_FuncState* fs = (rtl_FuncState*)fstate; - return( fs->m_flags ); -} - /** - * returns name of passed funcstate structure - */ -rtl_String* SAL_CALL rtl_tres_getname( rtl_funcstate fstate ) -{ - rtl_FuncState* fs = (rtl_FuncState*)fstate; - return( fs->m_name ); -} - /** - * returns starttime of passed funcstate structure - */ -sal_uInt32 SAL_CALL rtl_tres_getstarttime( rtl_funcstate fstate ) -{ - rtl_FuncState* fs = (rtl_FuncState*)fstate; - return( fs->m_start ); -} - - /** - * returns stoptime of passed funcstate structure - */ -sal_uInt32 SAL_CALL rtl_tres_getstoptime( rtl_funcstate fstate ) -{ - rtl_FuncState* fs = (rtl_FuncState*)fstate; - return( fs->m_stop ); -} - - /** - * returns pointer to cmpstate of passed funcstate structure - */ -rtl_cmpstate SAL_CALL rtl_tres_getcmpstate( rtl_funcstate fstate) -{ - rtl_FuncState* fs = (rtl_FuncState*)fstate; - return( (rtl_cmpstate)fs->m_cmp ); - -} - /** - * returns boolean state of passed cmpstate structure - */ -sal_Bool SAL_CALL rtl_tres_getstat( rtl_cmpstate cstate) -{ - rtl_CmpState* cs = (rtl_CmpState*)cstate; - return( cs->m_stat ); -} - /** - * returns message of passed cmpstate structure - */ -rtl_String* SAL_CALL rtl_tres_getmsg( rtl_cmpstate cstate) -{ - rtl_CmpState* cs = (rtl_CmpState*)cstate; - return( cs->m_msg ); -} - /** - * returns next pointer of passed cmpstate structure - */ -rtl_cmpstate SAL_CALL rtl_tres_getnextcmpstate( rtl_cmpstate cstate) -{ - rtl_CmpState* cs = (rtl_CmpState*)cstate; - return( (rtl_cmpstate)cs->m_next ); -} - -/* -// -//inline void logPrintf ( const sal_Bool bTestCaseState, -// const char *pFormatStr, ... -// ) -//{ -// if( m_pFunctions && m_pFunctions->pLogPrintf ) -// { -// va_list vArgumentList; -// va_start ( vArgumentList, pFormatStr ); - -// m_pFunctions->pLogPrintf( this, bTestCaseState, pFormatStr, vArgumentList ); - -// va_end ( vArgumentList ); -// } -//} // - */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/util/sal.map b/sal/util/sal.map index b1b8892a0bd1..b67e313427b5 100755 --- a/sal/util/sal.map +++ b/sal/util/sal.map @@ -482,8 +482,6 @@ UDK_3_0_0 { rtl_removeUnloadingListener; rtl_logfile_trace; - rtl_tres_create; - rtl_tres_destroy; osl_getProcessLocale; osl_setProcessLocale; local: -- cgit From 76af7256e04ac5a24205f76663fc20aa810a9c3d Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 31 Oct 2011 18:57:30 +0100 Subject: Moved various sal/rtl/source files from C to C++, for easier maintenance. --- sal/inc/internal/rtl_locale_init.h | 49 + sal/osl/w32/dllentry.c | 3 +- sal/rtl/source/alloc_fini.cxx | 19 +- sal/rtl/source/byteseq.c | 257 ----- sal/rtl/source/byteseq.cxx | 266 +++++ sal/rtl/source/cipher.c | 1365 ----------------------- sal/rtl/source/cipher.cxx | 1364 +++++++++++++++++++++++ sal/rtl/source/cmdargs.cxx | 2 +- sal/rtl/source/crc.c | 166 --- sal/rtl/source/crc.cxx | 166 +++ sal/rtl/source/digest.c | 2121 ----------------------------------- sal/rtl/source/digest.cxx | 2143 ++++++++++++++++++++++++++++++++++++ sal/rtl/source/locale.c | 352 ------ sal/rtl/source/locale.cxx | 349 ++++++ sal/rtl/source/memory.c | 64 -- sal/rtl/source/memory.cxx | 64 ++ sal/rtl/source/random.c | 340 ------ sal/rtl/source/random.cxx | 340 ++++++ sal/rtl/source/uuid.cxx | 4 +- 19 files changed, 4756 insertions(+), 4678 deletions(-) create mode 100644 sal/inc/internal/rtl_locale_init.h delete mode 100644 sal/rtl/source/byteseq.c create mode 100644 sal/rtl/source/byteseq.cxx delete mode 100644 sal/rtl/source/cipher.c create mode 100644 sal/rtl/source/cipher.cxx delete mode 100644 sal/rtl/source/crc.c create mode 100644 sal/rtl/source/crc.cxx delete mode 100644 sal/rtl/source/digest.c create mode 100644 sal/rtl/source/digest.cxx delete mode 100644 sal/rtl/source/locale.c create mode 100644 sal/rtl/source/locale.cxx delete mode 100644 sal/rtl/source/memory.c create mode 100644 sal/rtl/source/memory.cxx delete mode 100644 sal/rtl/source/random.c create mode 100644 sal/rtl/source/random.cxx diff --git a/sal/inc/internal/rtl_locale_init.h b/sal/inc/internal/rtl_locale_init.h new file mode 100644 index 000000000000..816ba56f042a --- /dev/null +++ b/sal/inc/internal/rtl_locale_init.h @@ -0,0 +1,49 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License or as specified alternatively below. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * Major Contributor(s): + * [ Copyright (C) 2011 Stephan Bergmann, Red Hat (initial + * developer) ] + * + * All Rights Reserved. + * + * For minor contributions see the git repository. + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 3 or later (the "GPLv3+"), or + * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), + * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable + * instead of those above. + */ + +#ifndef INCLUDED_SAL_INTERNAL_RTL_LOCALE_INIT_H +#define INCLUDED_SAL_INTERNAL_RTL_LOCALE_INIT_H + +#if defined __cplusplus +extern "C" { +#endif + +void rtl_locale_init(); + +void rtl_locale_fini(); + +void ensureLocaleSingleton(); + +#if defined __cplusplus +} +#endif + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/dllentry.c b/sal/osl/w32/dllentry.c index 4d894260446a..f4e63dc9e0c6 100644 --- a/sal/osl/w32/dllentry.c +++ b/sal/osl/w32/dllentry.c @@ -44,6 +44,8 @@ #include #include +#include "internal/rtl_locale_init.h" + //------------------------------------------------------------------------------ // externals //------------------------------------------------------------------------------ @@ -54,7 +56,6 @@ extern CRITICAL_SECTION g_ThreadKeyListCS; extern oslMutex g_Mutex; extern oslMutex g_CurrentDirectoryMutex; -extern void rtl_locale_fini (void); extern void rtl_memory_fini (void); extern void rtl_cache_fini (void); extern void rtl_arena_fini (void); diff --git a/sal/rtl/source/alloc_fini.cxx b/sal/rtl/source/alloc_fini.cxx index 1c1d30af43d1..c19e8dcb47ef 100644 --- a/sal/rtl/source/alloc_fini.cxx +++ b/sal/rtl/source/alloc_fini.cxx @@ -28,8 +28,10 @@ #include -extern "C" void rtl_memory_fini (void); -extern "C" void rtl_memory_init (void); +#include "internal/rtl_locale_init.h" + +extern "C" void rtl_memory_fini(); +extern "C" void rtl_memory_init(); namespace { struct rtlMemorySingleton @@ -51,8 +53,8 @@ extern "C" void ensureMemorySingleton() theMemorySingleton::get(); } -extern "C" void rtl_cache_fini (void); -extern "C" void rtl_cache_init (void); +extern "C" void rtl_cache_fini(); +extern "C" void rtl_cache_init(); namespace { struct rtlCacheSingleton @@ -74,8 +76,8 @@ extern "C" void ensureCacheSingleton() theCacheSingleton::get(); } -extern "C" void rtl_arena_fini (void); -extern "C" void rtl_arena_init (void); +extern "C" void rtl_arena_fini(); +extern "C" void rtl_arena_init(); namespace { struct rtlArenaSingleton @@ -97,8 +99,6 @@ extern "C" void ensureArenaSingleton() theArenaSingleton::get(); } -extern "C" void rtl_locale_fini (void); -extern "C" void rtl_locale_init (void); namespace { struct rtlLocaleSingleton @@ -115,7 +115,8 @@ namespace class theLocaleSingleton : public rtl::Static{}; } -extern "C" void ensureLocaleSingleton() + +void ensureLocaleSingleton() { theLocaleSingleton::get(); } diff --git a/sal/rtl/source/byteseq.c b/sal/rtl/source/byteseq.c deleted file mode 100644 index 52c81d8df375..000000000000 --- a/sal/rtl/source/byteseq.c +++ /dev/null @@ -1,257 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include -#include - -#include -#include -#include - -/* static data to be referenced by all empty strings - * the refCount is predefined to 1 and must never become 0 ! - */ -static sal_Sequence aEmpty_rtl_ByteSeq = -{ - 1, /* sal_Int32 refCount; */ - 0, /* sal_Int32 length; */ - { 0 } /* sal_Unicode buffer[1]; */ -}; - -//================================================================================================== -void SAL_CALL rtl_byte_sequence_reference2One( - sal_Sequence ** ppSequence ) -{ - sal_Sequence * pSequence, * pNew; - sal_Int32 nElements; - - OSL_ENSURE( ppSequence, "### null ptr!" ); - pSequence = *ppSequence; - - if (pSequence->nRefCount > 1) - { - nElements = pSequence->nElements; - if (nElements) - { - pNew = (sal_Sequence *)rtl_allocateMemory( SAL_SEQUENCE_HEADER_SIZE + nElements ); - - if ( pNew != 0 ) - rtl_copyMemory( pNew->elements, pSequence->elements, nElements ); - - if (! osl_decrementInterlockedCount( &pSequence->nRefCount )) - rtl_freeMemory( pSequence ); - } - else - { - pNew = (sal_Sequence *)rtl_allocateMemory( SAL_SEQUENCE_HEADER_SIZE ); - } - - if ( pNew != 0 ) - { - pNew->nRefCount = 1; - pNew->nElements = nElements; - } - - *ppSequence = pNew; - } -} - -//================================================================================================== -void SAL_CALL rtl_byte_sequence_realloc( - sal_Sequence ** ppSequence, sal_Int32 nSize ) -{ - sal_Sequence * pSequence, * pNew; - sal_Int32 nElements; - - OSL_ENSURE( ppSequence, "### null ptr!" ); - pSequence = *ppSequence; - nElements = pSequence->nElements; - - if (nElements == nSize) - return; - - if (pSequence->nRefCount > 1) // split - { - pNew = (sal_Sequence *)rtl_allocateMemory( SAL_SEQUENCE_HEADER_SIZE + nSize ); - - if ( pNew != 0 ) - { - if (nSize > nElements) - { - rtl_copyMemory( pNew->elements, pSequence->elements, nElements ); - rtl_zeroMemory( pNew->elements + nElements, nSize - nElements ); - } - else - { - rtl_copyMemory( pNew->elements, pSequence->elements, nSize ); - } - } - - if (! osl_decrementInterlockedCount( &pSequence->nRefCount )) - rtl_freeMemory( pSequence ); - pSequence = pNew; - } - else - { - pSequence = (sal_Sequence *)rtl_reallocateMemory( - pSequence, SAL_SEQUENCE_HEADER_SIZE + nSize ); - } - - if ( pSequence != 0 ) - { - pSequence->nRefCount = 1; - pSequence->nElements = nSize; - } - - *ppSequence = pSequence; -} - -//================================================================================================== -void SAL_CALL rtl_byte_sequence_acquire( sal_Sequence *pSequence ) -{ - OSL_ASSERT( pSequence ); - osl_incrementInterlockedCount( &(pSequence->nRefCount) ); -} - -//================================================================================================== -void SAL_CALL rtl_byte_sequence_release( sal_Sequence *pSequence ) -{ - if ( pSequence != 0 ) - { - if (! osl_decrementInterlockedCount( &(pSequence->nRefCount )) ) - { - rtl_freeMemory( pSequence ); - } - } -} - -//================================================================================================== -void SAL_CALL rtl_byte_sequence_construct( sal_Sequence **ppSequence , sal_Int32 nLength ) -{ - OSL_ASSERT( ppSequence ); - if( *ppSequence ) - { - rtl_byte_sequence_release( *ppSequence ); - *ppSequence = 0; - } - - if( nLength ) - { - *ppSequence = (sal_Sequence *) rtl_allocateZeroMemory( SAL_SEQUENCE_HEADER_SIZE + nLength ); - - if ( *ppSequence != 0 ) - { - (*ppSequence)->nRefCount = 1; - (*ppSequence)->nElements = nLength; - } - } - else - { - *ppSequence = &aEmpty_rtl_ByteSeq; - rtl_byte_sequence_acquire( *ppSequence ); - } -} - -//================================================================================================== -void SAL_CALL rtl_byte_sequence_constructNoDefault( sal_Sequence **ppSequence , sal_Int32 nLength ) -{ - OSL_ASSERT( ppSequence ); - if( *ppSequence ) - { - rtl_byte_sequence_release( *ppSequence ); - *ppSequence = 0; - } - - *ppSequence = (sal_Sequence *) rtl_allocateMemory( SAL_SEQUENCE_HEADER_SIZE + nLength ); - - if ( *ppSequence != 0 ) - { - (*ppSequence)->nRefCount = 1; - (*ppSequence)->nElements = nLength; - } -} - -//================================================================================================== -void SAL_CALL rtl_byte_sequence_constructFromArray( - sal_Sequence **ppSequence, const sal_Int8 *pData , sal_Int32 nLength ) -{ - rtl_byte_sequence_constructNoDefault( ppSequence , nLength ); - if ( *ppSequence != 0 ) - rtl_copyMemory( (*ppSequence)->elements, pData, nLength ); -} - -//================================================================================================== -void SAL_CALL rtl_byte_sequence_assign( sal_Sequence **ppSequence , sal_Sequence *pSequence ) -{ - if ( *ppSequence != pSequence) - { - if( *ppSequence ) - { - rtl_byte_sequence_release( *ppSequence ); - } - *ppSequence = pSequence; - rtl_byte_sequence_acquire( *ppSequence ); - } -// else -// nothing to do - -} - -//================================================================================================== -sal_Bool SAL_CALL rtl_byte_sequence_equals( sal_Sequence *pSequence1 , sal_Sequence *pSequence2 ) -{ - OSL_ASSERT( pSequence1 ); - OSL_ASSERT( pSequence2 ); - if (pSequence1 == pSequence2) - { - return sal_True; - } - if (pSequence1->nElements != pSequence2->nElements) - { - return sal_False; - } - return (sal_Bool) - (rtl_compareMemory( - pSequence1->elements, pSequence2->elements, pSequence1->nElements ) - == 0); -} - - -//================================================================================================== -const sal_Int8 *SAL_CALL rtl_byte_sequence_getConstArray( sal_Sequence *pSequence ) -{ - return ((const sal_Int8*)(pSequence->elements)); -} - -//================================================================================================== -sal_Int32 SAL_CALL rtl_byte_sequence_getLength( sal_Sequence *pSequence ) -{ - return pSequence->nElements; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/byteseq.cxx b/sal/rtl/source/byteseq.cxx new file mode 100644 index 000000000000..76423f78f1f9 --- /dev/null +++ b/sal/rtl/source/byteseq.cxx @@ -0,0 +1,266 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include +#include + +#include +#include +#include + +/* static data to be referenced by all empty strings + * the refCount is predefined to 1 and must never become 0 ! + */ +static sal_Sequence aEmpty_rtl_ByteSeq = +{ + 1, /* sal_Int32 refCount; */ + 0, /* sal_Int32 length; */ + { 0 } /* sal_Unicode buffer[1]; */ +}; + +//================================================================================================== +void SAL_CALL rtl_byte_sequence_reference2One( + sal_Sequence ** ppSequence ) SAL_THROW_EXTERN_C() +{ + sal_Sequence * pSequence, * pNew; + sal_Int32 nElements; + + OSL_ENSURE( ppSequence, "### null ptr!" ); + pSequence = *ppSequence; + + if (pSequence->nRefCount > 1) + { + nElements = pSequence->nElements; + if (nElements) + { + pNew = (sal_Sequence *)rtl_allocateMemory( SAL_SEQUENCE_HEADER_SIZE + nElements ); + + if ( pNew != 0 ) + rtl_copyMemory( pNew->elements, pSequence->elements, nElements ); + + if (! osl_decrementInterlockedCount( &pSequence->nRefCount )) + rtl_freeMemory( pSequence ); + } + else + { + pNew = (sal_Sequence *)rtl_allocateMemory( SAL_SEQUENCE_HEADER_SIZE ); + } + + if ( pNew != 0 ) + { + pNew->nRefCount = 1; + pNew->nElements = nElements; + } + + *ppSequence = pNew; + } +} + +//================================================================================================== +void SAL_CALL rtl_byte_sequence_realloc( + sal_Sequence ** ppSequence, sal_Int32 nSize ) SAL_THROW_EXTERN_C() +{ + sal_Sequence * pSequence, * pNew; + sal_Int32 nElements; + + OSL_ENSURE( ppSequence, "### null ptr!" ); + pSequence = *ppSequence; + nElements = pSequence->nElements; + + if (nElements == nSize) + return; + + if (pSequence->nRefCount > 1) // split + { + pNew = (sal_Sequence *)rtl_allocateMemory( SAL_SEQUENCE_HEADER_SIZE + nSize ); + + if ( pNew != 0 ) + { + if (nSize > nElements) + { + rtl_copyMemory( pNew->elements, pSequence->elements, nElements ); + rtl_zeroMemory( pNew->elements + nElements, nSize - nElements ); + } + else + { + rtl_copyMemory( pNew->elements, pSequence->elements, nSize ); + } + } + + if (! osl_decrementInterlockedCount( &pSequence->nRefCount )) + rtl_freeMemory( pSequence ); + pSequence = pNew; + } + else + { + pSequence = (sal_Sequence *)rtl_reallocateMemory( + pSequence, SAL_SEQUENCE_HEADER_SIZE + nSize ); + } + + if ( pSequence != 0 ) + { + pSequence->nRefCount = 1; + pSequence->nElements = nSize; + } + + *ppSequence = pSequence; +} + +//================================================================================================== +void SAL_CALL rtl_byte_sequence_acquire( sal_Sequence *pSequence ) + SAL_THROW_EXTERN_C() +{ + OSL_ASSERT( pSequence ); + osl_incrementInterlockedCount( &(pSequence->nRefCount) ); +} + +//================================================================================================== +void SAL_CALL rtl_byte_sequence_release( sal_Sequence *pSequence ) + SAL_THROW_EXTERN_C() +{ + if ( pSequence != 0 ) + { + if (! osl_decrementInterlockedCount( &(pSequence->nRefCount )) ) + { + rtl_freeMemory( pSequence ); + } + } +} + +//================================================================================================== +void SAL_CALL rtl_byte_sequence_construct( sal_Sequence **ppSequence , sal_Int32 nLength ) + SAL_THROW_EXTERN_C() +{ + OSL_ASSERT( ppSequence ); + if( *ppSequence ) + { + rtl_byte_sequence_release( *ppSequence ); + *ppSequence = 0; + } + + if( nLength ) + { + *ppSequence = (sal_Sequence *) rtl_allocateZeroMemory( SAL_SEQUENCE_HEADER_SIZE + nLength ); + + if ( *ppSequence != 0 ) + { + (*ppSequence)->nRefCount = 1; + (*ppSequence)->nElements = nLength; + } + } + else + { + *ppSequence = &aEmpty_rtl_ByteSeq; + rtl_byte_sequence_acquire( *ppSequence ); + } +} + +//================================================================================================== +void SAL_CALL rtl_byte_sequence_constructNoDefault( sal_Sequence **ppSequence , sal_Int32 nLength ) + SAL_THROW_EXTERN_C() +{ + OSL_ASSERT( ppSequence ); + if( *ppSequence ) + { + rtl_byte_sequence_release( *ppSequence ); + *ppSequence = 0; + } + + *ppSequence = (sal_Sequence *) rtl_allocateMemory( SAL_SEQUENCE_HEADER_SIZE + nLength ); + + if ( *ppSequence != 0 ) + { + (*ppSequence)->nRefCount = 1; + (*ppSequence)->nElements = nLength; + } +} + +//================================================================================================== +void SAL_CALL rtl_byte_sequence_constructFromArray( + sal_Sequence **ppSequence, const sal_Int8 *pData , sal_Int32 nLength ) + SAL_THROW_EXTERN_C() +{ + rtl_byte_sequence_constructNoDefault( ppSequence , nLength ); + if ( *ppSequence != 0 ) + rtl_copyMemory( (*ppSequence)->elements, pData, nLength ); +} + +//================================================================================================== +void SAL_CALL rtl_byte_sequence_assign( sal_Sequence **ppSequence , sal_Sequence *pSequence ) + SAL_THROW_EXTERN_C() +{ + if ( *ppSequence != pSequence) + { + if( *ppSequence ) + { + rtl_byte_sequence_release( *ppSequence ); + } + *ppSequence = pSequence; + rtl_byte_sequence_acquire( *ppSequence ); + } +// else +// nothing to do + +} + +//================================================================================================== +sal_Bool SAL_CALL rtl_byte_sequence_equals( sal_Sequence *pSequence1 , sal_Sequence *pSequence2 ) + SAL_THROW_EXTERN_C() +{ + OSL_ASSERT( pSequence1 ); + OSL_ASSERT( pSequence2 ); + if (pSequence1 == pSequence2) + { + return sal_True; + } + if (pSequence1->nElements != pSequence2->nElements) + { + return sal_False; + } + return (sal_Bool) + (rtl_compareMemory( + pSequence1->elements, pSequence2->elements, pSequence1->nElements ) + == 0); +} + + +//================================================================================================== +const sal_Int8 *SAL_CALL rtl_byte_sequence_getConstArray( sal_Sequence *pSequence ) + SAL_THROW_EXTERN_C() +{ + return ((const sal_Int8*)(pSequence->elements)); +} + +//================================================================================================== +sal_Int32 SAL_CALL rtl_byte_sequence_getLength( sal_Sequence *pSequence ) + SAL_THROW_EXTERN_C() +{ + return pSequence->nElements; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/cipher.c b/sal/rtl/source/cipher.c deleted file mode 100644 index e6ede4274af6..000000000000 --- a/sal/rtl/source/cipher.c +++ /dev/null @@ -1,1365 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#define _RTL_CIPHER_C_ - -#include -#include -#include -#include - -/*======================================================================== - * - * rtlCipher internals. - * - *======================================================================*/ -#define RTL_CIPHER_NTOHL(c, l) \ - ((l) = ((sal_uInt32)(*((c)++))) << 24L, \ - (l) |= ((sal_uInt32)(*((c)++))) << 16L, \ - (l) |= ((sal_uInt32)(*((c)++))) << 8L, \ - (l) |= ((sal_uInt32)(*((c)++)))) - -#define RTL_CIPHER_HTONL(l, c) \ - (*((c)++) = (sal_uInt8)(((l) >> 24L) & 0xff), \ - *((c)++) = (sal_uInt8)(((l) >> 16L) & 0xff), \ - *((c)++) = (sal_uInt8)(((l) >> 8L) & 0xff), \ - *((c)++) = (sal_uInt8)(((l) ) & 0xff)) - -#define RTL_CIPHER_NTOHL64(c, xl, xr, n) \ -{ \ - (xl) = (xr) = 0; \ - (c) += (n); \ - switch ((n)) \ - { \ - case 8: (xr) = ((sal_uInt32)(*(--(c)))); \ - case 7: (xr) |= ((sal_uInt32)(*(--(c)))) << 8L; \ - case 6: (xr) |= ((sal_uInt32)(*(--(c)))) << 16L; \ - case 5: (xr) |= ((sal_uInt32)(*(--(c)))) << 24L; \ - case 4: (xl) = ((sal_uInt32)(*(--(c)))); \ - case 3: (xl) |= ((sal_uInt32)(*(--(c)))) << 8L; \ - case 2: (xl) |= ((sal_uInt32)(*(--(c)))) << 16L; \ - case 1: (xl) |= ((sal_uInt32)(*(--(c)))) << 24L; \ - } \ -} - -#define RTL_CIPHER_HTONL64(xl, xr, c, n) \ -{ \ - (c) += (n); \ - switch ((n)) \ - { \ - case 8: *(--(c)) = (sal_uInt8)(((xr) ) & 0xff); \ - case 7: *(--(c)) = (sal_uInt8)(((xr) >> 8L) & 0xff); \ - case 6: *(--(c)) = (sal_uInt8)(((xr) >> 16L) & 0xff); \ - case 5: *(--(c)) = (sal_uInt8)(((xr) >> 24L) & 0xff); \ - case 4: *(--(c)) = (sal_uInt8)(((xl) ) & 0xff); \ - case 3: *(--(c)) = (sal_uInt8)(((xl) >> 8L) & 0xff); \ - case 2: *(--(c)) = (sal_uInt8)(((xl) >> 16L) & 0xff); \ - case 1: *(--(c)) = (sal_uInt8)(((xl) >> 24L) & 0xff); \ - } \ -} - -typedef rtlCipherError (SAL_CALL cipher_init_t) ( - rtlCipher Cipher, - rtlCipherDirection Direction, - const sal_uInt8 *pKeyData, sal_Size nKeyLen, - const sal_uInt8 *pArgData, sal_Size nArgLen); - -typedef rtlCipherError (SAL_CALL cipher_update_t) ( - rtlCipher Cipher, - const void *pData, sal_Size nDatLen, - sal_uInt8 *pBuffer, sal_Size nBufLen); - -typedef void (SAL_CALL cipher_delete_t) (rtlCipher Cipher); - -/** Cipher_Impl. - */ -typedef struct cipher_impl_st -{ - rtlCipherAlgorithm m_algorithm; - rtlCipherDirection m_direction; - rtlCipherMode m_mode; - - cipher_init_t *m_init; - cipher_update_t *m_encode; - cipher_update_t *m_decode; - cipher_delete_t *m_delete; -} Cipher_Impl; - -/*======================================================================== - * - * rtlCipher implementation. - * - *======================================================================*/ -/* - * rtl_cipher_create. - */ -rtlCipher SAL_CALL rtl_cipher_create ( - rtlCipherAlgorithm Algorithm, - rtlCipherMode Mode) -{ - rtlCipher Cipher = (rtlCipher)NULL; - switch (Algorithm) - { - case rtl_Cipher_AlgorithmBF: - Cipher = rtl_cipher_createBF (Mode); - break; - - case rtl_Cipher_AlgorithmARCFOUR: - Cipher = rtl_cipher_createARCFOUR (Mode); - break; - - default: /* rtl_Cipher_AlgorithmInvalid */ - break; - } - return Cipher; -} - -/* - * rtl_cipher_init. - */ -rtlCipherError SAL_CALL rtl_cipher_init ( - rtlCipher Cipher, - rtlCipherDirection Direction, - const sal_uInt8 *pKeyData, sal_Size nKeyLen, - const sal_uInt8 *pArgData, sal_Size nArgLen) -{ - Cipher_Impl *pImpl = (Cipher_Impl*)Cipher; - if (pImpl == NULL) - return rtl_Cipher_E_Argument; - if (pImpl->m_init == NULL) - return rtl_Cipher_E_Unknown; - - return (pImpl->m_init)( - Cipher, Direction, pKeyData, nKeyLen, pArgData, nArgLen); -} - -/* - * rtl_cipher_encode. - */ -rtlCipherError SAL_CALL rtl_cipher_encode ( - rtlCipher Cipher, - const void *pData, sal_Size nDatLen, - sal_uInt8 *pBuffer, sal_Size nBufLen) -{ - Cipher_Impl *pImpl = (Cipher_Impl*)Cipher; - if (pImpl == NULL) - return rtl_Cipher_E_Argument; - if (pImpl->m_encode == NULL) - return rtl_Cipher_E_Unknown; - - return (pImpl->m_encode)(Cipher, pData, nDatLen, pBuffer, nBufLen); -} - -/* - * rtl_cipher_decode. - */ -rtlCipherError SAL_CALL rtl_cipher_decode ( - rtlCipher Cipher, - const void *pData, sal_Size nDatLen, - sal_uInt8 *pBuffer, sal_Size nBufLen) -{ - Cipher_Impl *pImpl = (Cipher_Impl*)Cipher; - if (pImpl == NULL) - return rtl_Cipher_E_Argument; - if (pImpl->m_decode == NULL) - return rtl_Cipher_E_Unknown; - - return (pImpl->m_decode)(Cipher, pData, nDatLen, pBuffer, nBufLen); -} - -/* - * rtl_cipher_destroy. - */ -void SAL_CALL rtl_cipher_destroy (rtlCipher Cipher) -{ - Cipher_Impl *pImpl = (Cipher_Impl*)Cipher; - if (pImpl && pImpl->m_delete) - pImpl->m_delete (Cipher); -} - -/*======================================================================== - * - * rtl_cipherBF (Blowfish) internals. - * - *======================================================================*/ -#define CIPHER_ROUNDS_BF 16 - -typedef struct cipherBF_key_st -{ - sal_uInt32 m_S[4][256]; - sal_uInt32 m_P[CIPHER_ROUNDS_BF + 2]; -} CipherKeyBF; - -typedef struct cipherBF_context_st -{ - CipherKeyBF m_key; - union - { - sal_uInt32 m_long[2]; - sal_uInt8 m_byte[8]; - } m_iv; - sal_uInt32 m_offset; -} CipherContextBF; - -typedef struct cipherBF_impl_st -{ - Cipher_Impl m_cipher; - CipherContextBF m_context; -} CipherBF_Impl; - -/** __rtl_cipherBF_init. - */ -static rtlCipherError __rtl_cipherBF_init ( - CipherContextBF *ctx, - rtlCipherMode eMode, - const sal_uInt8 *pKeyData, sal_Size nKeyLen, - const sal_uInt8 *pArgData, sal_Size nArgLen); - -/** __rtl_cipherBF_update. - */ -static rtlCipherError __rtl_cipherBF_update ( - CipherContextBF *ctx, - rtlCipherMode eMode, - rtlCipherDirection eDirection, - const sal_uInt8 *pData, sal_Size nDatLen, - sal_uInt8 *pBuffer, sal_Size nBufLen); - -/** __rtl_cipherBF_updateECB. - */ -static void __rtl_cipherBF_updateECB ( - CipherContextBF *ctx, - rtlCipherDirection direction, - const sal_uInt8 *pData, - sal_uInt8 *pBuffer, - sal_Size nLength); - -/** __rtl_cipherBF_updateCBC. - */ -static void __rtl_cipherBF_updateCBC ( - CipherContextBF *ctx, - rtlCipherDirection direction, - const sal_uInt8 *pData, - sal_uInt8 *pBuffer, - sal_Size nLength); - -/** __rtl_cipherBF_updateCFB. - */ -static void __rtl_cipherBF_updateCFB ( - CipherContextBF *ctx, - rtlCipherDirection direction, - const sal_uInt8 *pData, - sal_uInt8 *pBuffer); - -/** __rtl_cipher_encode. - */ -static void __rtl_cipherBF_encode ( - CipherKeyBF *key, sal_uInt32 *xl, sal_uInt32 *xr); - -/** __rtl_cipherBF_decode. - */ -static void __rtl_cipherBF_decode ( - CipherKeyBF *key, sal_uInt32 *xl, sal_uInt32 *xr); - -/** __rtl_cipherBF. - */ -static sal_uInt32 __rtl_cipherBF ( - CipherKeyBF *key, sal_uInt32 x); - -/** __rtl_cipherBF_key. - */ -static const CipherKeyBF __rtl_cipherBF_key = -{ - /* S */ - { - /* S[0] */ - { - /* 0 */ - 0xD1310BA6L, 0x98DFB5ACL, 0x2FFD72DBL, 0xD01ADFB7L, - 0xB8E1AFEDL, 0x6A267E96L, 0xBA7C9045L, 0xF12C7F99L, - 0x24A19947L, 0xB3916CF7L, 0x0801F2E2L, 0x858EFC16L, - 0x636920D8L, 0x71574E69L, 0xA458FEA3L, 0xF4933D7EL, - - /* 1 */ - 0x0D95748FL, 0x728EB658L, 0x718BCD58L, 0x82154AEEL, - 0x7B54A41DL, 0xC25A59B5L, 0x9C30D539L, 0x2AF26013L, - 0xC5D1B023L, 0x286085F0L, 0xCA417918L, 0xB8DB38EFL, - 0x8E79DCB0L, 0x603A180EL, 0x6C9E0E8BL, 0xB01E8A3EL, - - /* 2 */ - 0xD71577C1L, 0xBD314B27L, 0x78AF2FDAL, 0x55605C60L, - 0xE65525F3L, 0xAA55AB94L, 0x57489862L, 0x63E81440L, - 0x55CA396AL, 0x2AAB10B6L, 0xB4CC5C34L, 0x1141E8CEL, - 0xA15486AFL, 0x7C72E993L, 0xB3EE1411L, 0x636FBC2AL, - - /* 3 */ - 0x2BA9C55DL, 0x741831F6L, 0xCE5C3E16L, 0x9B87931EL, - 0xAFD6BA33L, 0x6C24CF5CL, 0x7A325381L, 0x28958677L, - 0x3B8F4898L, 0x6B4BB9AFL, 0xC4BFE81BL, 0x66282193L, - 0x61D809CCL, 0xFB21A991L, 0x487CAC60L, 0x5DEC8032L, - - /* 4 */ - 0xEF845D5DL, 0xE98575B1L, 0xDC262302L, 0xEB651B88L, - 0x23893E81L, 0xD396ACC5L, 0x0F6D6FF3L, 0x83F44239L, - 0x2E0B4482L, 0xA4842004L, 0x69C8F04AL, 0x9E1F9B5EL, - 0x21C66842L, 0xF6E96C9AL, 0x670C9C61L, 0xABD388F0L, - - /* 5 */ - 0x6A51A0D2L, 0xD8542F68L, 0x960FA728L, 0xAB5133A3L, - 0x6EEF0B6CL, 0x137A3BE4L, 0xBA3BF050L, 0x7EFB2A98L, - 0xA1F1651DL, 0x39AF0176L, 0x66CA593EL, 0x82430E88L, - 0x8CEE8619L, 0x456F9FB4L, 0x7D84A5C3L, 0x3B8B5EBEL, - - /* 6 */ - 0xE06F75D8L, 0x85C12073L, 0x401A449FL, 0x56C16AA6L, - 0x4ED3AA62L, 0x363F7706L, 0x1BFEDF72L, 0x429B023DL, - 0x37D0D724L, 0xD00A1248L, 0xDB0FEAD3L, 0x49F1C09BL, - 0x075372C9L, 0x80991B7BL, 0x25D479D8L, 0xF6E8DEF7L, - - /* 7 */ - 0xE3FE501AL, 0xB6794C3BL, 0x976CE0BDL, 0x04C006BAL, - 0xC1A94FB6L, 0x409F60C4L, 0x5E5C9EC2L, 0x196A2463L, - 0x68FB6FAFL, 0x3E6C53B5L, 0x1339B2EBL, 0x3B52EC6FL, - 0x6DFC511FL, 0x9B30952CL, 0xCC814544L, 0xAF5EBD09L, - - /* 8 */ - 0xBEE3D004L, 0xDE334AFDL, 0x660F2807L, 0x192E4BB3L, - 0xC0CBA857L, 0x45C8740FL, 0xD20B5F39L, 0xB9D3FBDBL, - 0x5579C0BDL, 0x1A60320AL, 0xD6A100C6L, 0x402C7279L, - 0x679F25FEL, 0xFB1FA3CCL, 0x8EA5E9F8L, 0xDB3222F8L, - - /* 9 */ - 0x3C7516DFL, 0xFD616B15L, 0x2F501EC8L, 0xAD0552ABL, - 0x323DB5FAL, 0xFD238760L, 0x53317B48L, 0x3E00DF82L, - 0x9E5C57BBL, 0xCA6F8CA0L, 0x1A87562EL, 0xDF1769DBL, - 0xD542A8F6L, 0x287EFFC3L, 0xAC6732C6L, 0x8C4F5573L, - - /* A */ - 0x695B27B0L, 0xBBCA58C8L, 0xE1FFA35DL, 0xB8F011A0L, - 0x10FA3D98L, 0xFD2183B8L, 0x4AFCB56CL, 0x2DD1D35BL, - 0x9A53E479L, 0xB6F84565L, 0xD28E49BCL, 0x4BFB9790L, - 0xE1DDF2DAL, 0xA4CB7E33L, 0x62FB1341L, 0xCEE4C6E8L, - - /* B */ - 0xEF20CADAL, 0x36774C01L, 0xD07E9EFEL, 0x2BF11FB4L, - 0x95DBDA4DL, 0xAE909198L, 0xEAAD8E71L, 0x6B93D5A0L, - 0xD08ED1D0L, 0xAFC725E0L, 0x8E3C5B2FL, 0x8E7594B7L, - 0x8FF6E2FBL, 0xF2122B64L, 0x8888B812L, 0x900DF01CL, - - /* C */ - 0x4FAD5EA0L, 0x688FC31CL, 0xD1CFF191L, 0xB3A8C1ADL, - 0x2F2F2218L, 0xBE0E1777L, 0xEA752DFEL, 0x8B021FA1L, - 0xE5A0CC0FL, 0xB56F74E8L, 0x18ACF3D6L, 0xCE89E299L, - 0xB4A84FE0L, 0xFD13E0B7L, 0x7CC43B81L, 0xD2ADA8D9L, - - /* D */ - 0x165FA266L, 0x80957705L, 0x93CC7314L, 0x211A1477L, - 0xE6AD2065L, 0x77B5FA86L, 0xC75442F5L, 0xFB9D35CFL, - 0xEBCDAF0CL, 0x7B3E89A0L, 0xD6411BD3L, 0xAE1E7E49L, - 0x00250E2DL, 0x2071B35EL, 0x226800BBL, 0x57B8E0AFL, - - /* E */ - 0x2464369BL, 0xF009B91EL, 0x5563911DL, 0x59DFA6AAL, - 0x78C14389L, 0xD95A537FL, 0x207D5BA2L, 0x02E5B9C5L, - 0x83260376L, 0x6295CFA9L, 0x11C81968L, 0x4E734A41L, - 0xB3472DCAL, 0x7B14A94AL, 0x1B510052L, 0x9A532915L, - - /* F */ - 0xD60F573FL, 0xBC9BC6E4L, 0x2B60A476L, 0x81E67400L, - 0x08BA6FB5L, 0x571BE91FL, 0xF296EC6BL, 0x2A0DD915L, - 0xB6636521L, 0xE7B9F9B6L, 0xFF34052EL, 0xC5855664L, - 0x53B02D5DL, 0xA99F8FA1L, 0x08BA4799L, 0x6E85076AL - }, - - /* S[1] */ - { - 0x4B7A70E9L, 0xB5B32944L, 0xDB75092EL, 0xC4192623L, - 0xAD6EA6B0L, 0x49A7DF7DL, 0x9CEE60B8L, 0x8FEDB266L, - 0xECAA8C71L, 0x699A17FFL, 0x5664526CL, 0xC2B19EE1L, - 0x193602A5L, 0x75094C29L, 0xA0591340L, 0xE4183A3EL, - - 0x3F54989AL, 0x5B429D65L, 0x6B8FE4D6L, 0x99F73FD6L, - 0xA1D29C07L, 0xEFE830F5L, 0x4D2D38E6L, 0xF0255DC1L, - 0x4CDD2086L, 0x8470EB26L, 0x6382E9C6L, 0x021ECC5EL, - 0x09686B3FL, 0x3EBAEFC9L, 0x3C971814L, 0x6B6A70A1L, - - 0x687F3584L, 0x52A0E286L, 0xB79C5305L, 0xAA500737L, - 0x3E07841CL, 0x7FDEAE5CL, 0x8E7D44ECL, 0x5716F2B8L, - 0xB03ADA37L, 0xF0500C0DL, 0xF01C1F04L, 0x0200B3FFL, - 0xAE0CF51AL, 0x3CB574B2L, 0x25837A58L, 0xDC0921BDL, - - 0xD19113F9L, 0x7CA92FF6L, 0x94324773L, 0x22F54701L, - 0x3AE5E581L, 0x37C2DADCL, 0xC8B57634L, 0x9AF3DDA7L, - 0xA9446146L, 0x0FD0030EL, 0xECC8C73EL, 0xA4751E41L, - 0xE238CD99L, 0x3BEA0E2FL, 0x3280BBA1L, 0x183EB331L, - - 0x4E548B38L, 0x4F6DB908L, 0x6F420D03L, 0xF60A04BFL, - 0x2CB81290L, 0x24977C79L, 0x5679B072L, 0xBCAF89AFL, - 0xDE9A771FL, 0xD9930810L, 0xB38BAE12L, 0xDCCF3F2EL, - 0x5512721FL, 0x2E6B7124L, 0x501ADDE6L, 0x9F84CD87L, - - 0x7A584718L, 0x7408DA17L, 0xBC9F9ABCL, 0xE94B7D8CL, - 0xEC7AEC3AL, 0xDB851DFAL, 0x63094366L, 0xC464C3D2L, - 0xEF1C1847L, 0x3215D908L, 0xDD433B37L, 0x24C2BA16L, - 0x12A14D43L, 0x2A65C451L, 0x50940002L, 0x133AE4DDL, - - 0x71DFF89EL, 0x10314E55L, 0x81AC77D6L, 0x5F11199BL, - 0x043556F1L, 0xD7A3C76BL, 0x3C11183BL, 0x5924A509L, - 0xF28FE6EDL, 0x97F1FBFAL, 0x9EBABF2CL, 0x1E153C6EL, - 0x86E34570L, 0xEAE96FB1L, 0x860E5E0AL, 0x5A3E2AB3L, - - 0x771FE71CL, 0x4E3D06FAL, 0x2965DCB9L, 0x99E71D0FL, - 0x803E89D6L, 0x5266C825L, 0x2E4CC978L, 0x9C10B36AL, - 0xC6150EBAL, 0x94E2EA78L, 0xA5FC3C53L, 0x1E0A2DF4L, - 0xF2F74EA7L, 0x361D2B3DL, 0x1939260FL, 0x19C27960L, - - 0x5223A708L, 0xF71312B6L, 0xEBADFE6EL, 0xEAC31F66L, - 0xE3BC4595L, 0xA67BC883L, 0xB17F37D1L, 0x018CFF28L, - 0xC332DDEFL, 0xBE6C5AA5L, 0x65582185L, 0x68AB9802L, - 0xEECEA50FL, 0xDB2F953BL, 0x2AEF7DADL, 0x5B6E2F84L, - - 0x1521B628L, 0x29076170L, 0xECDD4775L, 0x619F1510L, - 0x13CCA830L, 0xEB61BD96L, 0x0334FE1EL, 0xAA0363CFL, - 0xB5735C90L, 0x4C70A239L, 0xD59E9E0BL, 0xCBAADE14L, - 0xEECC86BCL, 0x60622CA7L, 0x9CAB5CABL, 0xB2F3846EL, - - 0x648B1EAFL, 0x19BDF0CAL, 0xA02369B9L, 0x655ABB50L, - 0x40685A32L, 0x3C2AB4B3L, 0x319EE9D5L, 0xC021B8F7L, - 0x9B540B19L, 0x875FA099L, 0x95F7997EL, 0x623D7DA8L, - 0xF837889AL, 0x97E32D77L, 0x11ED935FL, 0x16681281L, - - 0x0E358829L, 0xC7E61FD6L, 0x96DEDFA1L, 0x7858BA99L, - 0x57F584A5L, 0x1B227263L, 0x9B83C3FFL, 0x1AC24696L, - 0xCDB30AEBL, 0x532E3054L, 0x8FD948E4L, 0x6DBC3128L, - 0x58EBF2EFL, 0x34C6FFEAL, 0xFE28ED61L, 0xEE7C3C73L, - - 0x5D4A14D9L, 0xE864B7E3L, 0x42105D14L, 0x203E13E0L, - 0x45EEE2B6L, 0xA3AAABEAL, 0xDB6C4F15L, 0xFACB4FD0L, - 0xC742F442L, 0xEF6ABBB5L, 0x654F3B1DL, 0x41CD2105L, - 0xD81E799EL, 0x86854DC7L, 0xE44B476AL, 0x3D816250L, - - 0xCF62A1F2L, 0x5B8D2646L, 0xFC8883A0L, 0xC1C7B6A3L, - 0x7F1524C3L, 0x69CB7492L, 0x47848A0BL, 0x5692B285L, - 0x095BBF00L, 0xAD19489DL, 0x1462B174L, 0x23820E00L, - 0x58428D2AL, 0x0C55F5EAL, 0x1DADF43EL, 0x233F7061L, - - 0x3372F092L, 0x8D937E41L, 0xD65FECF1L, 0x6C223BDBL, - 0x7CDE3759L, 0xCBEE7460L, 0x4085F2A7L, 0xCE77326EL, - 0xA6078084L, 0x19F8509EL, 0xE8EFD855L, 0x61D99735L, - 0xA969A7AAL, 0xC50C06C2L, 0x5A04ABFCL, 0x800BCADCL, - - 0x9E447A2EL, 0xC3453484L, 0xFDD56705L, 0x0E1E9EC9L, - 0xDB73DBD3L, 0x105588CDL, 0x675FDA79L, 0xE3674340L, - 0xC5C43465L, 0x713E38D8L, 0x3D28F89EL, 0xF16DFF20L, - 0x153E21E7L, 0x8FB03D4AL, 0xE6E39F2BL, 0xDB83ADF7L - }, - - /* S[2] */ - { - 0xE93D5A68L, 0x948140F7L, 0xF64C261CL, 0x94692934L, - 0x411520F7L, 0x7602D4F7L, 0xBCF46B2EL, 0xD4A20068L, - 0xD4082471L, 0x3320F46AL, 0x43B7D4B7L, 0x500061AFL, - 0x1E39F62EL, 0x97244546L, 0x14214F74L, 0xBF8B8840L, - - 0x4D95FC1DL, 0x96B591AFL, 0x70F4DDD3L, 0x66A02F45L, - 0xBFBC09ECL, 0x03BD9785L, 0x7FAC6DD0L, 0x31CB8504L, - 0x96EB27B3L, 0x55FD3941L, 0xDA2547E6L, 0xABCA0A9AL, - 0x28507825L, 0x530429F4L, 0x0A2C86DAL, 0xE9B66DFBL, - - 0x68DC1462L, 0xD7486900L, 0x680EC0A4L, 0x27A18DEEL, - 0x4F3FFEA2L, 0xE887AD8CL, 0xB58CE006L, 0x7AF4D6B6L, - 0xAACE1E7CL, 0xD3375FECL, 0xCE78A399L, 0x406B2A42L, - 0x20FE9E35L, 0xD9F385B9L, 0xEE39D7ABL, 0x3B124E8BL, - - 0x1DC9FAF7L, 0x4B6D1856L, 0x26A36631L, 0xEAE397B2L, - 0x3A6EFA74L, 0xDD5B4332L, 0x6841E7F7L, 0xCA7820FBL, - 0xFB0AF54EL, 0xD8FEB397L, 0x454056ACL, 0xBA489527L, - 0x55533A3AL, 0x20838D87L, 0xFE6BA9B7L, 0xD096954BL, - - 0x55A867BCL, 0xA1159A58L, 0xCCA92963L, 0x99E1DB33L, - 0xA62A4A56L, 0x3F3125F9L, 0x5EF47E1CL, 0x9029317CL, - 0xFDF8E802L, 0x04272F70L, 0x80BB155CL, 0x05282CE3L, - 0x95C11548L, 0xE4C66D22L, 0x48C1133FL, 0xC70F86DCL, - - 0x07F9C9EEL, 0x41041F0FL, 0x404779A4L, 0x5D886E17L, - 0x325F51EBL, 0xD59BC0D1L, 0xF2BCC18FL, 0x41113564L, - 0x257B7834L, 0x602A9C60L, 0xDFF8E8A3L, 0x1F636C1BL, - 0x0E12B4C2L, 0x02E1329EL, 0xAF664FD1L, 0xCAD18115L, - - 0x6B2395E0L, 0x333E92E1L, 0x3B240B62L, 0xEEBEB922L, - 0x85B2A20EL, 0xE6BA0D99L, 0xDE720C8CL, 0x2DA2F728L, - 0xD0127845L, 0x95B794FDL, 0x647D0862L, 0xE7CCF5F0L, - 0x5449A36FL, 0x877D48FAL, 0xC39DFD27L, 0xF33E8D1EL, - - 0x0A476341L, 0x992EFF74L, 0x3A6F6EABL, 0xF4F8FD37L, - 0xA812DC60L, 0xA1EBDDF8L, 0x991BE14CL, 0xDB6E6B0DL, - 0xC67B5510L, 0x6D672C37L, 0x2765D43BL, 0xDCD0E804L, - 0xF1290DC7L, 0xCC00FFA3L, 0xB5390F92L, 0x690FED0BL, - - 0x667B9FFBL, 0xCEDB7D9CL, 0xA091CF0BL, 0xD9155EA3L, - 0xBB132F88L, 0x515BAD24L, 0x7B9479BFL, 0x763BD6EBL, - 0x37392EB3L, 0xCC115979L, 0x8026E297L, 0xF42E312DL, - 0x6842ADA7L, 0xC66A2B3BL, 0x12754CCCL, 0x782EF11CL, - - 0x6A124237L, 0xB79251E7L, 0x06A1BBE6L, 0x4BFB6350L, - 0x1A6B1018L, 0x11CAEDFAL, 0x3D25BDD8L, 0xE2E1C3C9L, - 0x44421659L, 0x0A121386L, 0xD90CEC6EL, 0xD5ABEA2AL, - 0x64AF674EL, 0xDA86A85FL, 0xBEBFE988L, 0x64E4C3FEL, - - 0x9DBC8057L, 0xF0F7C086L, 0x60787BF8L, 0x6003604DL, - 0xD1FD8346L, 0xF6381FB0L, 0x7745AE04L, 0xD736FCCCL, - 0x83426B33L, 0xF01EAB71L, 0xB0804187L, 0x3C005E5FL, - 0x77A057BEL, 0xBDE8AE24L, 0x55464299L, 0xBF582E61L, - - 0x4E58F48FL, 0xF2DDFDA2L, 0xF474EF38L, 0x8789BDC2L, - 0x5366F9C3L, 0xC8B38E74L, 0xB475F255L, 0x46FCD9B9L, - 0x7AEB2661L, 0x8B1DDF84L, 0x846A0E79L, 0x915F95E2L, - 0x466E598EL, 0x20B45770L, 0x8CD55591L, 0xC902DE4CL, - - 0xB90BACE1L, 0xBB8205D0L, 0x11A86248L, 0x7574A99EL, - 0xB77F19B6L, 0xE0A9DC09L, 0x662D09A1L, 0xC4324633L, - 0xE85A1F02L, 0x09F0BE8CL, 0x4A99A025L, 0x1D6EFE10L, - 0x1AB93D1DL, 0x0BA5A4DFL, 0xA186F20FL, 0x2868F169L, - - 0xDCB7DA83L, 0x573906FEL, 0xA1E2CE9BL, 0x4FCD7F52L, - 0x50115E01L, 0xA70683FAL, 0xA002B5C4L, 0x0DE6D027L, - 0x9AF88C27L, 0x773F8641L, 0xC3604C06L, 0x61A806B5L, - 0xF0177A28L, 0xC0F586E0L, 0x006058AAL, 0x30DC7D62L, - - 0x11E69ED7L, 0x2338EA63L, 0x53C2DD94L, 0xC2C21634L, - 0xBBCBEE56L, 0x90BCB6DEL, 0xEBFC7DA1L, 0xCE591D76L, - 0x6F05E409L, 0x4B7C0188L, 0x39720A3DL, 0x7C927C24L, - 0x86E3725FL, 0x724D9DB9L, 0x1AC15BB4L, 0xD39EB8FCL, - - 0xED545578L, 0x08FCA5B5L, 0xD83D7CD3L, 0x4DAD0FC4L, - 0x1E50EF5EL, 0xB161E6F8L, 0xA28514D9L, 0x6C51133CL, - 0x6FD5C7E7L, 0x56E14EC4L, 0x362ABFCEL, 0xDDC6C837L, - 0xD79A3234L, 0x92638212L, 0x670EFA8EL, 0x406000E0L - }, - - /* S[3] */ - { - 0x3A39CE37L, 0xD3FAF5CFL, 0xABC27737L, 0x5AC52D1BL, - 0x5CB0679EL, 0x4FA33742L, 0xD3822740L, 0x99BC9BBEL, - 0xD5118E9DL, 0xBF0F7315L, 0xD62D1C7EL, 0xC700C47BL, - 0xB78C1B6BL, 0x21A19045L, 0xB26EB1BEL, 0x6A366EB4L, - - 0x5748AB2FL, 0xBC946E79L, 0xC6A376D2L, 0x6549C2C8L, - 0x530FF8EEL, 0x468DDE7DL, 0xD5730A1DL, 0x4CD04DC6L, - 0x2939BBDBL, 0xA9BA4650L, 0xAC9526E8L, 0xBE5EE304L, - 0xA1FAD5F0L, 0x6A2D519AL, 0x63EF8CE2L, 0x9A86EE22L, - - 0xC089C2B8L, 0x43242EF6L, 0xA51E03AAL, 0x9CF2D0A4L, - 0x83C061BAL, 0x9BE96A4DL, 0x8FE51550L, 0xBA645BD6L, - 0x2826A2F9L, 0xA73A3AE1L, 0x4BA99586L, 0xEF5562E9L, - 0xC72FEFD3L, 0xF752F7DAL, 0x3F046F69L, 0x77FA0A59L, - - 0x80E4A915L, 0x87B08601L, 0x9B09E6ADL, 0x3B3EE593L, - 0xE990FD5AL, 0x9E34D797L, 0x2CF0B7D9L, 0x022B8B51L, - 0x96D5AC3AL, 0x017DA67DL, 0xD1CF3ED6L, 0x7C7D2D28L, - 0x1F9F25CFL, 0xADF2B89BL, 0x5AD6B472L, 0x5A88F54CL, - - 0xE029AC71L, 0xE019A5E6L, 0x47B0ACFDL, 0xED93FA9BL, - 0xE8D3C48DL, 0x283B57CCL, 0xF8D56629L, 0x79132E28L, - 0x785F0191L, 0xED756055L, 0xF7960E44L, 0xE3D35E8CL, - 0x15056DD4L, 0x88F46DBAL, 0x03A16125L, 0x0564F0BDL, - - 0xC3EB9E15L, 0x3C9057A2L, 0x97271AECL, 0xA93A072AL, - 0x1B3F6D9BL, 0x1E6321F5L, 0xF59C66FBL, 0x26DCF319L, - 0x7533D928L, 0xB155FDF5L, 0x03563482L, 0x8ABA3CBBL, - 0x28517711L, 0xC20AD9F8L, 0xABCC5167L, 0xCCAD925FL, - - 0x4DE81751L, 0x3830DC8EL, 0x379D5862L, 0x9320F991L, - 0xEA7A90C2L, 0xFB3E7BCEL, 0x5121CE64L, 0x774FBE32L, - 0xA8B6E37EL, 0xC3293D46L, 0x48DE5369L, 0x6413E680L, - 0xA2AE0810L, 0xDD6DB224L, 0x69852DFDL, 0x09072166L, - - 0xB39A460AL, 0x6445C0DDL, 0x586CDECFL, 0x1C20C8AEL, - 0x5BBEF7DDL, 0x1B588D40L, 0xCCD2017FL, 0x6BB4E3BBL, - 0xDDA26A7EL, 0x3A59FF45L, 0x3E350A44L, 0xBCB4CDD5L, - 0x72EACEA8L, 0xFA6484BBL, 0x8D6612AEL, 0xBF3C6F47L, - - 0xD29BE463L, 0x542F5D9EL, 0xAEC2771BL, 0xF64E6370L, - 0x740E0D8DL, 0xE75B1357L, 0xF8721671L, 0xAF537D5DL, - 0x4040CB08L, 0x4EB4E2CCL, 0x34D2466AL, 0x0115AF84L, - 0xE1B00428L, 0x95983A1DL, 0x06B89FB4L, 0xCE6EA048L, - - 0x6F3F3B82L, 0x3520AB82L, 0x011A1D4BL, 0x277227F8L, - 0x611560B1L, 0xE7933FDCL, 0xBB3A792BL, 0x344525BDL, - 0xA08839E1L, 0x51CE794BL, 0x2F32C9B7L, 0xA01FBAC9L, - 0xE01CC87EL, 0xBCC7D1F6L, 0xCF0111C3L, 0xA1E8AAC7L, - - 0x1A908749L, 0xD44FBD9AL, 0xD0DADECBL, 0xD50ADA38L, - 0x0339C32AL, 0xC6913667L, 0x8DF9317CL, 0xE0B12B4FL, - 0xF79E59B7L, 0x43F5BB3AL, 0xF2D519FFL, 0x27D9459CL, - 0xBF97222CL, 0x15E6FC2AL, 0x0F91FC71L, 0x9B941525L, - - 0xFAE59361L, 0xCEB69CEBL, 0xC2A86459L, 0x12BAA8D1L, - 0xB6C1075EL, 0xE3056A0CL, 0x10D25065L, 0xCB03A442L, - 0xE0EC6E0EL, 0x1698DB3BL, 0x4C98A0BEL, 0x3278E964L, - 0x9F1F9532L, 0xE0D392DFL, 0xD3A0342BL, 0x8971F21EL, - - 0x1B0A7441L, 0x4BA3348CL, 0xC5BE7120L, 0xC37632D8L, - 0xDF359F8DL, 0x9B992F2EL, 0xE60B6F47L, 0x0FE3F11DL, - 0xE54CDA54L, 0x1EDAD891L, 0xCE6279CFL, 0xCD3E7E6FL, - 0x1618B166L, 0xFD2C1D05L, 0x848FD2C5L, 0xF6FB2299L, - - 0xF523F357L, 0xA6327623L, 0x93A83531L, 0x56CCCD02L, - 0xACF08162L, 0x5A75EBB5L, 0x6E163697L, 0x88D273CCL, - 0xDE966292L, 0x81B949D0L, 0x4C50901BL, 0x71C65614L, - 0xE6C6C7BDL, 0x327A140AL, 0x45E1D006L, 0xC3F27B9AL, - - 0xC9AA53FDL, 0x62A80F00L, 0xBB25BFE2L, 0x35BDD2F6L, - 0x71126905L, 0xB2040222L, 0xB6CBCF7CL, 0xCD769C2BL, - 0x53113EC0L, 0x1640E3D3L, 0x38ABBD60L, 0x2547ADF0L, - 0xBA38209CL, 0xF746CE76L, 0x77AFA1C5L, 0x20756060L, - - 0x85CBFE4EL, 0x8AE88DD8L, 0x7AAAF9B0L, 0x4CF9AA7EL, - 0x1948C25CL, 0x02FB8A8CL, 0x01C36AE4L, 0xD6EBE1F9L, - 0x90D4F869L, 0xA65CDEA0L, 0x3F09252DL, 0xC208E69FL, - 0xB74E6132L, 0xCE77E25BL, 0x578FDFE3L, 0x3AC372E6L - } - }, - - /* P */ - { - 0x243F6A88L, 0x85A308D3L, 0x13198A2EL, 0x03707344L, - 0xA4093822L, 0x299F31D0L, 0x082EFA98L, 0xEC4E6C89L, - 0x452821E6L, 0x38D01377L, 0xBE5466CFL, 0x34E90C6CL, - 0xC0AC29B7L, 0xC97C50DDL, 0x3F84D5B5L, 0xB5470917L, - 0x9216D5D9L, 0x8979FB1BL - } -}; - -/* - * __rtl_cipherBF_init. - */ -static rtlCipherError __rtl_cipherBF_init ( - CipherContextBF *ctx, - rtlCipherMode eMode, - const sal_uInt8 *pKeyData, sal_Size nKeyLen, - const sal_uInt8 *pArgData, sal_Size nArgLen) -{ - CipherKeyBF *key; - sal_uInt32 D, DL, DR; - sal_uInt16 i, j, k; - - key = &(ctx->m_key); - - rtl_copyMemory (key, &__rtl_cipherBF_key, sizeof (CipherKeyBF)); - rtl_zeroMemory (&(ctx->m_iv), sizeof(ctx->m_iv)); - ctx->m_offset = 0; - - for (i = 0, k = 0; i < CIPHER_ROUNDS_BF + 2; ++i) - { - D = 0; - for (j = 0; j < 4; ++j) - { - D = ((D << 8) | pKeyData[k]); - k++; - if (k >= nKeyLen) - k = 0; - } - key->m_P[i] ^= D; - } - - DL = 0; - DR = 0; - - for (i = 0; i < CIPHER_ROUNDS_BF + 2; i += 2) - { - __rtl_cipherBF_encode (key, &DL, &DR); - key->m_P[i ] = DL; - key->m_P[i + 1] = DR; - } - - for (i = 0; i < 4; ++i) - { - for (k = 0; k < 256; k += 2) - { - __rtl_cipherBF_encode (key, &DL, &DR); - key->m_S[i][k ] = DL; - key->m_S[i][k + 1] = DR; - } - } - - if (pArgData && nArgLen) - { - nArgLen = ((nArgLen < 8) ? nArgLen : 8); - if (eMode == rtl_Cipher_ModeStream) - { - rtl_copyMemory (ctx->m_iv.m_byte, pArgData, nArgLen); - } - else - { - RTL_CIPHER_NTOHL64 (pArgData, DL, DR, nArgLen); - ctx->m_iv.m_long[0] = DL; - ctx->m_iv.m_long[1] = DR; - } - } - - D = DL = DR = 0; - return rtl_Cipher_E_None; -} - -/* - * __rtl_cipherBF_update. - */ -static rtlCipherError __rtl_cipherBF_update ( - CipherContextBF *ctx, - rtlCipherMode eMode, - rtlCipherDirection eDirection, - const sal_uInt8 *pData, sal_Size nDatLen, - sal_uInt8 *pBuffer, sal_Size nBufLen) -{ - /* Check arguments. */ - if ((pData == NULL) || (pBuffer == NULL)) - return rtl_Cipher_E_Argument; - - if (!((0 < nDatLen) && (nDatLen <= nBufLen))) - return rtl_Cipher_E_BufferSize; - - /* Update. */ - if (eMode == rtl_Cipher_ModeECB) - { - /* Block mode. */ - while (nDatLen > 8) - { - __rtl_cipherBF_updateECB (ctx, eDirection, pData, pBuffer, 8); - nDatLen -= 8; - pData += 8; - pBuffer += 8; - } - __rtl_cipherBF_updateECB (ctx, eDirection, pData, pBuffer, nDatLen); - } - else if (eMode == rtl_Cipher_ModeCBC) - { - /* Block mode. */ - while (nDatLen > 8) - { - __rtl_cipherBF_updateCBC (ctx, eDirection, pData, pBuffer, 8); - nDatLen -= 8; - pData += 8; - pBuffer += 8; - } - __rtl_cipherBF_updateCBC (ctx, eDirection, pData, pBuffer, nDatLen); - } - else - { - /* Stream mode. */ - while (nDatLen > 0) - { - __rtl_cipherBF_updateCFB (ctx, eDirection, pData, pBuffer); - nDatLen -= 1; - pData += 1; - pBuffer += 1; - } - } - return rtl_Cipher_E_None; -} - -/* - * __rtl_cipherBF_updateECB. - */ -static void __rtl_cipherBF_updateECB ( - CipherContextBF *ctx, - rtlCipherDirection direction, - const sal_uInt8 *pData, - sal_uInt8 *pBuffer, - sal_Size nLength) -{ - CipherKeyBF *key; - sal_uInt32 DL, DR; - - key = &(ctx->m_key); - if (direction == rtl_Cipher_DirectionEncode) - { - RTL_CIPHER_NTOHL64(pData, DL, DR, nLength); - - __rtl_cipherBF_encode (key, &DL, &DR); - - RTL_CIPHER_HTONL(DL, pBuffer); - RTL_CIPHER_HTONL(DR, pBuffer); - } - else - { - RTL_CIPHER_NTOHL(pData, DL); - RTL_CIPHER_NTOHL(pData, DR); - - __rtl_cipherBF_decode (key, &DL, &DR); - - RTL_CIPHER_HTONL64(DL, DR, pBuffer, nLength); - } - DL = DR = 0; -} - -/* - * __rtl_cipherBF_updateCBC. - */ -static void __rtl_cipherBF_updateCBC ( - CipherContextBF *ctx, - rtlCipherDirection direction, - const sal_uInt8 *pData, - sal_uInt8 *pBuffer, - sal_Size nLength) -{ - CipherKeyBF *key; - sal_uInt32 DL, DR; - - key = &(ctx->m_key); - if (direction == rtl_Cipher_DirectionEncode) - { - RTL_CIPHER_NTOHL64(pData, DL, DR, nLength); - - DL ^= ctx->m_iv.m_long[0]; - DR ^= ctx->m_iv.m_long[1]; - - __rtl_cipherBF_encode (key, &DL, &DR); - - ctx->m_iv.m_long[0] = DL; - ctx->m_iv.m_long[1] = DR; - - RTL_CIPHER_HTONL(DL, pBuffer); - RTL_CIPHER_HTONL(DR, pBuffer); - } - else - { - sal_uInt32 IVL, IVR; - - RTL_CIPHER_NTOHL(pData, DL); - RTL_CIPHER_NTOHL(pData, DR); - - IVL = DL; - IVR = DR; - - __rtl_cipherBF_decode (key, &DL, &DR); - - DL ^= ctx->m_iv.m_long[0]; - DR ^= ctx->m_iv.m_long[1]; - - ctx->m_iv.m_long[0] = IVL; - ctx->m_iv.m_long[1] = IVR; - - RTL_CIPHER_HTONL64(DL, DR, pBuffer, nLength); - IVL = IVR = 0; - } - DL = DR = 0; -} - -/* - * __rtl_cipherBF_updateCFB. - */ -static void __rtl_cipherBF_updateCFB ( - CipherContextBF *ctx, - rtlCipherDirection direction, - const sal_uInt8 *pData, - sal_uInt8 *pBuffer) -{ - sal_uInt8 *iv; - sal_uInt32 k; - - iv = ctx->m_iv.m_byte; - k = ctx->m_offset; - - if (k == 0) - { - sal_uInt32 IVL, IVR; - - RTL_CIPHER_NTOHL64(iv, IVL, IVR, 8); - __rtl_cipherBF_encode (&(ctx->m_key), &IVL, &IVR); - RTL_CIPHER_HTONL64(IVL, IVR, iv, 8); - - IVL = IVR = 0; - } - - if (direction == rtl_Cipher_DirectionEncode) - { - iv[k] ^= *pData; - *pBuffer = iv[k]; - } - else - { - sal_uInt8 c = iv[k]; - iv[k] = *pData; - *pBuffer = *pData ^ c; - } - - ctx->m_offset = ((k + 1) & 0x07); - iv = NULL; -} - -/* - * __rtl_cipherBF_encode. - */ -static void __rtl_cipherBF_encode ( - CipherKeyBF *key, sal_uInt32 *xl, sal_uInt32 *xr) -{ - sal_uInt32 t, XL, XR; - sal_uInt16 i; - - XL = *xl; - XR = *xr; - - for (i = 0; i < CIPHER_ROUNDS_BF; ++i) - { - XL ^= key->m_P[i]; - XR ^= __rtl_cipherBF (key, XL); - - t = XL; - XL = XR; - XR = t; - } - - t = XL; - XL = XR; - XR = t; - - XR ^= key->m_P[CIPHER_ROUNDS_BF ]; - XL ^= key->m_P[CIPHER_ROUNDS_BF + 1]; - - *xl = XL; - *xr = XR; - - t = XL = XR = 0; -} - -/* - * __rtl_cipherBF_decode. - */ -static void __rtl_cipherBF_decode ( - CipherKeyBF *key, sal_uInt32 *xl, sal_uInt32 *xr) -{ - sal_uInt32 t, XL, XR; - sal_uInt16 i; - - XL = *xl; - XR = *xr; - - for (i = CIPHER_ROUNDS_BF + 1; i > 1; --i) - { - XL ^= key->m_P[i]; - XR ^= __rtl_cipherBF (key, XL); - - t = XL; - XL = XR; - XR = t; - } - - t = XL; - XL = XR; - XR = t; - - XR ^= key->m_P[1]; - XL ^= key->m_P[0]; - - *xl = XL; - *xr = XR; - - t = XL = XR = 0; -} - -/* - * __rtl_cipherBF. - */ -static sal_uInt32 __rtl_cipherBF (CipherKeyBF *key, sal_uInt32 x) -{ - sal_uInt16 a, b, c, d; - sal_uInt32 y; - - d = (sal_uInt16)(x & 0x00ff); - x >>= 8; - c = (sal_uInt16)(x & 0x00ff); - x >>= 8; - b = (sal_uInt16)(x & 0x00ff); - x >>= 8; - a = (sal_uInt16)(x & 0x00ff); - - y = key->m_S[0][a]; - y += key->m_S[1][b]; - y ^= key->m_S[2][c]; - y += key->m_S[3][d]; - - return y; -} - -/*======================================================================== - * - * rtl_cipherBF (Blowfish) implementation. - * - * Reference: - * Bruce Schneier: Applied Cryptography, 2nd edition, ch. 14.3 - * - *======================================================================*/ -/* - * rtl_cipher_createBF. - */ -rtlCipher SAL_CALL rtl_cipher_createBF (rtlCipherMode Mode) -{ - CipherBF_Impl *pImpl = (CipherBF_Impl*)NULL; - - if (Mode == rtl_Cipher_ModeInvalid) - return ((rtlCipher)NULL); - - pImpl = ((CipherBF_Impl*)rtl_allocateZeroMemory (sizeof (CipherBF_Impl))); - if (pImpl) - { - pImpl->m_cipher.m_algorithm = rtl_Cipher_AlgorithmBF; - pImpl->m_cipher.m_direction = rtl_Cipher_DirectionInvalid; - pImpl->m_cipher.m_mode = Mode; - - pImpl->m_cipher.m_init = rtl_cipher_initBF; - pImpl->m_cipher.m_encode = rtl_cipher_encodeBF; - pImpl->m_cipher.m_decode = rtl_cipher_decodeBF; - pImpl->m_cipher.m_delete = rtl_cipher_destroyBF; - } - return ((rtlCipher)pImpl); -} - -/* - * rtl_cipher_initBF. - */ -rtlCipherError SAL_CALL rtl_cipher_initBF ( - rtlCipher Cipher, - rtlCipherDirection Direction, - const sal_uInt8 *pKeyData, sal_Size nKeyLen, - const sal_uInt8 *pArgData, sal_Size nArgLen) -{ - CipherBF_Impl *pImpl = (CipherBF_Impl*)Cipher; - - if ((pImpl == NULL) || (pKeyData == NULL)) - return rtl_Cipher_E_Argument; - - if (!(pImpl->m_cipher.m_algorithm == rtl_Cipher_AlgorithmBF)) - return rtl_Cipher_E_Algorithm; - - if (!(Direction == rtl_Cipher_DirectionInvalid)) - pImpl->m_cipher.m_direction = Direction; - else - return rtl_Cipher_E_Direction; - - return __rtl_cipherBF_init ( - &(pImpl->m_context), pImpl->m_cipher.m_mode, - pKeyData, nKeyLen, pArgData, nArgLen); -} - -/* - * rtl_cipher_encodeBF. - */ -rtlCipherError SAL_CALL rtl_cipher_encodeBF ( - rtlCipher Cipher, - const void *pData, sal_Size nDatLen, - sal_uInt8 *pBuffer, sal_Size nBufLen) -{ - CipherBF_Impl *pImpl = (CipherBF_Impl*)Cipher; - if (pImpl == NULL) - return rtl_Cipher_E_Argument; - - if (!(pImpl->m_cipher.m_algorithm == rtl_Cipher_AlgorithmBF)) - return rtl_Cipher_E_Algorithm; - - if (pImpl->m_cipher.m_direction == rtl_Cipher_DirectionInvalid) - return rtl_Cipher_E_Direction; - if (pImpl->m_cipher.m_direction == rtl_Cipher_DirectionDecode) - return rtl_Cipher_E_Direction; - - return __rtl_cipherBF_update ( - &(pImpl->m_context), pImpl->m_cipher.m_mode, - rtl_Cipher_DirectionEncode, - (const sal_uInt8*)pData, nDatLen, pBuffer, nBufLen); -} - -/* - * rtl_cipher_decodeBF. - */ -rtlCipherError SAL_CALL rtl_cipher_decodeBF ( - rtlCipher Cipher, - const void *pData, sal_Size nDatLen, - sal_uInt8 *pBuffer, sal_Size nBufLen) -{ - CipherBF_Impl *pImpl = (CipherBF_Impl*)Cipher; - if (pImpl == NULL) - return rtl_Cipher_E_Argument; - - if (!(pImpl->m_cipher.m_algorithm == rtl_Cipher_AlgorithmBF)) - return rtl_Cipher_E_Algorithm; - - if (pImpl->m_cipher.m_direction == rtl_Cipher_DirectionInvalid) - return rtl_Cipher_E_Direction; - if (pImpl->m_cipher.m_direction == rtl_Cipher_DirectionEncode) - return rtl_Cipher_E_Direction; - - return __rtl_cipherBF_update ( - &(pImpl->m_context), pImpl->m_cipher.m_mode, - rtl_Cipher_DirectionDecode, - (const sal_uInt8*)pData, nDatLen, pBuffer, nBufLen); -} - -/* - * rtl_cipher_destroyBF. - */ -void SAL_CALL rtl_cipher_destroyBF (rtlCipher Cipher) -{ - CipherBF_Impl *pImpl = (CipherBF_Impl*)Cipher; - if (pImpl) - { - if (pImpl->m_cipher.m_algorithm == rtl_Cipher_AlgorithmBF) - rtl_freeZeroMemory (pImpl, sizeof (CipherBF_Impl)); - else - rtl_freeMemory (pImpl); - } -} - -/*======================================================================== - * - * rtl_cipher_ARCFOUR (RC4) internals. - * - *======================================================================*/ -#define CIPHER_CBLOCK_ARCFOUR 256 - -typedef struct cipherARCFOUR_context_st -{ - unsigned int m_S[CIPHER_CBLOCK_ARCFOUR]; - unsigned int m_X, m_Y; -} ContextARCFOUR_Impl; - -typedef struct cipherARCFOUR_impl_st -{ - Cipher_Impl m_cipher; - ContextARCFOUR_Impl m_context; -} CipherARCFOUR_Impl; - -/** rtl_cipherARCFOUR_update_Impl. - */ -static rtlCipherError rtl_cipherARCFOUR_update_Impl ( - ContextARCFOUR_Impl *ctx, - const sal_uInt8 *pData, sal_Size nDatLen, - sal_uInt8 *pBuffer, sal_Size nBufLen); - -/* - * rtl_cipherARCFOUR_init_Impl. - */ -static rtlCipherError rtl_cipherARCFOUR_init_Impl ( - ContextARCFOUR_Impl *ctx, - const sal_uInt8 *pKeyData, sal_Size nKeyLen) -{ - unsigned int K[CIPHER_CBLOCK_ARCFOUR]; - unsigned int *L, *S; - unsigned int x, y, t; - sal_Size n, k; - - S = &(ctx->m_S[0]); - - /* Initialize S linearly. */ - for (x = 0; x < CIPHER_CBLOCK_ARCFOUR; x++) - S[x] = x; - - /* Initialize K with key, repeat key as necessary. */ - for (L = K, n = CIPHER_CBLOCK_ARCFOUR; n > nKeyLen; n -= nKeyLen) - { - for (k = 0; k < nKeyLen; k++) L[k] = pKeyData[k]; - L += nKeyLen; - } - for (k = 0; k < n; k++) L[k] = pKeyData[k]; - - /* Initialize S with K. */ - for (x = 0, y = 0; x < CIPHER_CBLOCK_ARCFOUR; x++) - { - y = (y + S[x] + K[x]) % CIPHER_CBLOCK_ARCFOUR; - t = S[x], S[x] = S[y], S[y] = t; /* swap S[x] and S[y] */ - } - - /* Initialize counters X and Y. */ - ctx->m_X = 0; - ctx->m_Y = 0; - - return rtl_Cipher_E_None; -} - -/* - * rtl_cipherARCFOUR_update_Impl. - */ -static rtlCipherError rtl_cipherARCFOUR_update_Impl ( - ContextARCFOUR_Impl *ctx, - const sal_uInt8 *pData, sal_Size nDatLen, - sal_uInt8 *pBuffer, sal_Size nBufLen) -{ - register unsigned int *S; - register unsigned int x, y, t; - sal_Size k; - - /* Check arguments. */ - if ((pData == NULL) || (pBuffer == NULL)) - return rtl_Cipher_E_Argument; - - if (!((0 < nDatLen) && (nDatLen <= nBufLen))) - return rtl_Cipher_E_BufferSize; - - /* Update. */ - S = &(ctx->m_S[0]); - for (k = 0; k < nDatLen; k++) - { - /* Update counters X and Y. */ - x = ctx->m_X; - y = ctx->m_Y; - x = (x + 1 ) % CIPHER_CBLOCK_ARCFOUR; - y = (y + S[x]) % CIPHER_CBLOCK_ARCFOUR; - ctx->m_X = x; - ctx->m_Y = y; - - /* Swap S[x] and S[y]. */ - t = S[x], S[x] = S[y], S[y] = t; - - /* Evaluate next key byte S[t]. */ - t = (S[x] + S[y]) % CIPHER_CBLOCK_ARCFOUR; - pBuffer[k] = pData[k] ^ ((sal_uInt8)(S[t] & 0xff)); - } - - return rtl_Cipher_E_None; -} - -/*======================================================================== - * - * rtl_cipher_ARCFOUR (RC4) implementation. - * - * Reference: - * Bruce Schneier: Applied Cryptography, 2nd edition, ch. 17.1 - * - *======================================================================*/ -/* - * rtl_cipher_createARCFOUR. - */ -rtlCipher SAL_CALL rtl_cipher_createARCFOUR (rtlCipherMode Mode) -{ - CipherARCFOUR_Impl *pImpl = (CipherARCFOUR_Impl*)NULL; - - if (!(Mode == rtl_Cipher_ModeStream)) - return ((rtlCipher)NULL); - - pImpl = ((CipherARCFOUR_Impl*)rtl_allocateZeroMemory (sizeof (CipherARCFOUR_Impl))); - if (pImpl) - { - pImpl->m_cipher.m_algorithm = rtl_Cipher_AlgorithmARCFOUR; - pImpl->m_cipher.m_direction = rtl_Cipher_DirectionInvalid; - pImpl->m_cipher.m_mode = rtl_Cipher_ModeStream; - - pImpl->m_cipher.m_init = rtl_cipher_initARCFOUR; - pImpl->m_cipher.m_encode = rtl_cipher_encodeARCFOUR; - pImpl->m_cipher.m_decode = rtl_cipher_decodeARCFOUR; - pImpl->m_cipher.m_delete = rtl_cipher_destroyARCFOUR; - } - return ((rtlCipher)pImpl); -} - -/* - * rtl_cipher_initARCFOUR. - */ -rtlCipherError SAL_CALL rtl_cipher_initARCFOUR ( - rtlCipher Cipher, - rtlCipherDirection Direction, - const sal_uInt8 *pKeyData, sal_Size nKeyLen, - const sal_uInt8 *pArgData, sal_Size nArgLen) -{ - CipherARCFOUR_Impl *pImpl = (CipherARCFOUR_Impl*)Cipher; - (void) pArgData; // avoid warning - (void) nArgLen; // avoid warning - - if ((pImpl == NULL) || (pKeyData == NULL)) - return rtl_Cipher_E_Argument; - - if (!(pImpl->m_cipher.m_algorithm == rtl_Cipher_AlgorithmARCFOUR)) - return rtl_Cipher_E_Algorithm; - - if (!(Direction == rtl_Cipher_DirectionInvalid)) - pImpl->m_cipher.m_direction = Direction; - else - return rtl_Cipher_E_Direction; - - return rtl_cipherARCFOUR_init_Impl (&(pImpl->m_context), pKeyData, nKeyLen); -} - -/* - * rtl_cipher_encodeARCFOUR. - */ -rtlCipherError SAL_CALL rtl_cipher_encodeARCFOUR ( - rtlCipher Cipher, - const void *pData, sal_Size nDatLen, - sal_uInt8 *pBuffer, sal_Size nBufLen) -{ - CipherARCFOUR_Impl *pImpl = (CipherARCFOUR_Impl*)Cipher; - if (pImpl == NULL) - return rtl_Cipher_E_Argument; - - if (!(pImpl->m_cipher.m_algorithm == rtl_Cipher_AlgorithmARCFOUR)) - return rtl_Cipher_E_Algorithm; - - if (pImpl->m_cipher.m_direction == rtl_Cipher_DirectionInvalid) - return rtl_Cipher_E_Direction; - - return rtl_cipherARCFOUR_update_Impl ( - &(pImpl->m_context), - (const sal_uInt8*)pData, nDatLen, pBuffer, nBufLen); -} - -/* - * rtl_cipher_decodeARCFOUR. - */ -rtlCipherError SAL_CALL rtl_cipher_decodeARCFOUR ( - rtlCipher Cipher, - const void *pData, sal_Size nDatLen, - sal_uInt8 *pBuffer, sal_Size nBufLen) -{ - CipherARCFOUR_Impl *pImpl = (CipherARCFOUR_Impl*)Cipher; - if (pImpl == NULL) - return rtl_Cipher_E_Argument; - - if (!(pImpl->m_cipher.m_algorithm == rtl_Cipher_AlgorithmARCFOUR)) - return rtl_Cipher_E_Algorithm; - - if (pImpl->m_cipher.m_direction == rtl_Cipher_DirectionInvalid) - return rtl_Cipher_E_Direction; - - return rtl_cipherARCFOUR_update_Impl ( - &(pImpl->m_context), - (const sal_uInt8*)pData, nDatLen, pBuffer, nBufLen); -} - -/* - * rtl_cipher_destroyARCFOUR. - */ -void SAL_CALL rtl_cipher_destroyARCFOUR (rtlCipher Cipher) -{ - CipherARCFOUR_Impl *pImpl = (CipherARCFOUR_Impl*)Cipher; - if (pImpl) - { - if (pImpl->m_cipher.m_algorithm == rtl_Cipher_AlgorithmARCFOUR) - rtl_freeZeroMemory (pImpl, sizeof (CipherARCFOUR_Impl)); - else - rtl_freeMemory (pImpl); - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/cipher.cxx b/sal/rtl/source/cipher.cxx new file mode 100644 index 000000000000..19647ab3186d --- /dev/null +++ b/sal/rtl/source/cipher.cxx @@ -0,0 +1,1364 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#define _RTL_CIPHER_C_ + +#include +#include +#include +#include + +/*======================================================================== + * + * rtlCipher internals. + * + *======================================================================*/ +#define RTL_CIPHER_NTOHL(c, l) \ + ((l) = ((sal_uInt32)(*((c)++))) << 24L, \ + (l) |= ((sal_uInt32)(*((c)++))) << 16L, \ + (l) |= ((sal_uInt32)(*((c)++))) << 8L, \ + (l) |= ((sal_uInt32)(*((c)++)))) + +#define RTL_CIPHER_HTONL(l, c) \ + (*((c)++) = (sal_uInt8)(((l) >> 24L) & 0xff), \ + *((c)++) = (sal_uInt8)(((l) >> 16L) & 0xff), \ + *((c)++) = (sal_uInt8)(((l) >> 8L) & 0xff), \ + *((c)++) = (sal_uInt8)(((l) ) & 0xff)) + +#define RTL_CIPHER_NTOHL64(c, xl, xr, n) \ +{ \ + (xl) = (xr) = 0; \ + (c) += (n); \ + switch ((n)) \ + { \ + case 8: (xr) = ((sal_uInt32)(*(--(c)))); \ + case 7: (xr) |= ((sal_uInt32)(*(--(c)))) << 8L; \ + case 6: (xr) |= ((sal_uInt32)(*(--(c)))) << 16L; \ + case 5: (xr) |= ((sal_uInt32)(*(--(c)))) << 24L; \ + case 4: (xl) = ((sal_uInt32)(*(--(c)))); \ + case 3: (xl) |= ((sal_uInt32)(*(--(c)))) << 8L; \ + case 2: (xl) |= ((sal_uInt32)(*(--(c)))) << 16L; \ + case 1: (xl) |= ((sal_uInt32)(*(--(c)))) << 24L; \ + } \ +} + +#define RTL_CIPHER_HTONL64(xl, xr, c, n) \ +{ \ + (c) += (n); \ + switch ((n)) \ + { \ + case 8: *(--(c)) = (sal_uInt8)(((xr) ) & 0xff); \ + case 7: *(--(c)) = (sal_uInt8)(((xr) >> 8L) & 0xff); \ + case 6: *(--(c)) = (sal_uInt8)(((xr) >> 16L) & 0xff); \ + case 5: *(--(c)) = (sal_uInt8)(((xr) >> 24L) & 0xff); \ + case 4: *(--(c)) = (sal_uInt8)(((xl) ) & 0xff); \ + case 3: *(--(c)) = (sal_uInt8)(((xl) >> 8L) & 0xff); \ + case 2: *(--(c)) = (sal_uInt8)(((xl) >> 16L) & 0xff); \ + case 1: *(--(c)) = (sal_uInt8)(((xl) >> 24L) & 0xff); \ + } \ +} + +typedef rtlCipherError (SAL_CALL cipher_init_t) ( + rtlCipher Cipher, + rtlCipherDirection Direction, + const sal_uInt8 *pKeyData, sal_Size nKeyLen, + const sal_uInt8 *pArgData, sal_Size nArgLen); + +typedef rtlCipherError (SAL_CALL cipher_update_t) ( + rtlCipher Cipher, + const void *pData, sal_Size nDatLen, + sal_uInt8 *pBuffer, sal_Size nBufLen); + +typedef void (SAL_CALL cipher_delete_t) (rtlCipher Cipher); + +/** Cipher_Impl. + */ +struct Cipher_Impl +{ + rtlCipherAlgorithm m_algorithm; + rtlCipherDirection m_direction; + rtlCipherMode m_mode; + + cipher_init_t *m_init; + cipher_update_t *m_encode; + cipher_update_t *m_decode; + cipher_delete_t *m_delete; +}; + +/*======================================================================== + * + * rtlCipher implementation. + * + *======================================================================*/ +/* + * rtl_cipher_create. + */ +rtlCipher SAL_CALL rtl_cipher_create ( + rtlCipherAlgorithm Algorithm, + rtlCipherMode Mode) SAL_THROW_EXTERN_C() +{ + rtlCipher Cipher = (rtlCipher)NULL; + switch (Algorithm) + { + case rtl_Cipher_AlgorithmBF: + Cipher = rtl_cipher_createBF (Mode); + break; + + case rtl_Cipher_AlgorithmARCFOUR: + Cipher = rtl_cipher_createARCFOUR (Mode); + break; + + default: /* rtl_Cipher_AlgorithmInvalid */ + break; + } + return Cipher; +} + +/* + * rtl_cipher_init. + */ +rtlCipherError SAL_CALL rtl_cipher_init ( + rtlCipher Cipher, + rtlCipherDirection Direction, + const sal_uInt8 *pKeyData, sal_Size nKeyLen, + const sal_uInt8 *pArgData, sal_Size nArgLen) SAL_THROW_EXTERN_C() +{ + Cipher_Impl *pImpl = (Cipher_Impl*)Cipher; + if (pImpl == NULL) + return rtl_Cipher_E_Argument; + if (pImpl->m_init == NULL) + return rtl_Cipher_E_Unknown; + + return (pImpl->m_init)( + Cipher, Direction, pKeyData, nKeyLen, pArgData, nArgLen); +} + +/* + * rtl_cipher_encode. + */ +rtlCipherError SAL_CALL rtl_cipher_encode ( + rtlCipher Cipher, + const void *pData, sal_Size nDatLen, + sal_uInt8 *pBuffer, sal_Size nBufLen) SAL_THROW_EXTERN_C() +{ + Cipher_Impl *pImpl = (Cipher_Impl*)Cipher; + if (pImpl == NULL) + return rtl_Cipher_E_Argument; + if (pImpl->m_encode == NULL) + return rtl_Cipher_E_Unknown; + + return (pImpl->m_encode)(Cipher, pData, nDatLen, pBuffer, nBufLen); +} + +/* + * rtl_cipher_decode. + */ +rtlCipherError SAL_CALL rtl_cipher_decode ( + rtlCipher Cipher, + const void *pData, sal_Size nDatLen, + sal_uInt8 *pBuffer, sal_Size nBufLen) SAL_THROW_EXTERN_C() +{ + Cipher_Impl *pImpl = (Cipher_Impl*)Cipher; + if (pImpl == NULL) + return rtl_Cipher_E_Argument; + if (pImpl->m_decode == NULL) + return rtl_Cipher_E_Unknown; + + return (pImpl->m_decode)(Cipher, pData, nDatLen, pBuffer, nBufLen); +} + +/* + * rtl_cipher_destroy. + */ +void SAL_CALL rtl_cipher_destroy (rtlCipher Cipher) SAL_THROW_EXTERN_C() +{ + Cipher_Impl *pImpl = (Cipher_Impl*)Cipher; + if (pImpl && pImpl->m_delete) + pImpl->m_delete (Cipher); +} + +/*======================================================================== + * + * rtl_cipherBF (Blowfish) internals. + * + *======================================================================*/ +#define CIPHER_ROUNDS_BF 16 + +struct CipherKeyBF +{ + sal_uInt32 m_S[4][256]; + sal_uInt32 m_P[CIPHER_ROUNDS_BF + 2]; +}; + +struct CipherContextBF +{ + CipherKeyBF m_key; + union + { + sal_uInt32 m_long[2]; + sal_uInt8 m_byte[8]; + } m_iv; + sal_uInt32 m_offset; +}; + +struct CipherBF_Impl +{ + Cipher_Impl m_cipher; + CipherContextBF m_context; +}; + +/** __rtl_cipherBF_init. + */ +static rtlCipherError __rtl_cipherBF_init ( + CipherContextBF *ctx, + rtlCipherMode eMode, + const sal_uInt8 *pKeyData, sal_Size nKeyLen, + const sal_uInt8 *pArgData, sal_Size nArgLen); + +/** __rtl_cipherBF_update. + */ +static rtlCipherError __rtl_cipherBF_update ( + CipherContextBF *ctx, + rtlCipherMode eMode, + rtlCipherDirection eDirection, + const sal_uInt8 *pData, sal_Size nDatLen, + sal_uInt8 *pBuffer, sal_Size nBufLen); + +/** __rtl_cipherBF_updateECB. + */ +static void __rtl_cipherBF_updateECB ( + CipherContextBF *ctx, + rtlCipherDirection direction, + const sal_uInt8 *pData, + sal_uInt8 *pBuffer, + sal_Size nLength); + +/** __rtl_cipherBF_updateCBC. + */ +static void __rtl_cipherBF_updateCBC ( + CipherContextBF *ctx, + rtlCipherDirection direction, + const sal_uInt8 *pData, + sal_uInt8 *pBuffer, + sal_Size nLength); + +/** __rtl_cipherBF_updateCFB. + */ +static void __rtl_cipherBF_updateCFB ( + CipherContextBF *ctx, + rtlCipherDirection direction, + const sal_uInt8 *pData, + sal_uInt8 *pBuffer); + +/** __rtl_cipher_encode. + */ +static void __rtl_cipherBF_encode ( + CipherKeyBF *key, sal_uInt32 *xl, sal_uInt32 *xr); + +/** __rtl_cipherBF_decode. + */ +static void __rtl_cipherBF_decode ( + CipherKeyBF *key, sal_uInt32 *xl, sal_uInt32 *xr); + +/** __rtl_cipherBF. + */ +static sal_uInt32 __rtl_cipherBF ( + CipherKeyBF *key, sal_uInt32 x); + +/** __rtl_cipherBF_key. + */ +static const CipherKeyBF __rtl_cipherBF_key = +{ + /* S */ + { + /* S[0] */ + { + /* 0 */ + 0xD1310BA6L, 0x98DFB5ACL, 0x2FFD72DBL, 0xD01ADFB7L, + 0xB8E1AFEDL, 0x6A267E96L, 0xBA7C9045L, 0xF12C7F99L, + 0x24A19947L, 0xB3916CF7L, 0x0801F2E2L, 0x858EFC16L, + 0x636920D8L, 0x71574E69L, 0xA458FEA3L, 0xF4933D7EL, + + /* 1 */ + 0x0D95748FL, 0x728EB658L, 0x718BCD58L, 0x82154AEEL, + 0x7B54A41DL, 0xC25A59B5L, 0x9C30D539L, 0x2AF26013L, + 0xC5D1B023L, 0x286085F0L, 0xCA417918L, 0xB8DB38EFL, + 0x8E79DCB0L, 0x603A180EL, 0x6C9E0E8BL, 0xB01E8A3EL, + + /* 2 */ + 0xD71577C1L, 0xBD314B27L, 0x78AF2FDAL, 0x55605C60L, + 0xE65525F3L, 0xAA55AB94L, 0x57489862L, 0x63E81440L, + 0x55CA396AL, 0x2AAB10B6L, 0xB4CC5C34L, 0x1141E8CEL, + 0xA15486AFL, 0x7C72E993L, 0xB3EE1411L, 0x636FBC2AL, + + /* 3 */ + 0x2BA9C55DL, 0x741831F6L, 0xCE5C3E16L, 0x9B87931EL, + 0xAFD6BA33L, 0x6C24CF5CL, 0x7A325381L, 0x28958677L, + 0x3B8F4898L, 0x6B4BB9AFL, 0xC4BFE81BL, 0x66282193L, + 0x61D809CCL, 0xFB21A991L, 0x487CAC60L, 0x5DEC8032L, + + /* 4 */ + 0xEF845D5DL, 0xE98575B1L, 0xDC262302L, 0xEB651B88L, + 0x23893E81L, 0xD396ACC5L, 0x0F6D6FF3L, 0x83F44239L, + 0x2E0B4482L, 0xA4842004L, 0x69C8F04AL, 0x9E1F9B5EL, + 0x21C66842L, 0xF6E96C9AL, 0x670C9C61L, 0xABD388F0L, + + /* 5 */ + 0x6A51A0D2L, 0xD8542F68L, 0x960FA728L, 0xAB5133A3L, + 0x6EEF0B6CL, 0x137A3BE4L, 0xBA3BF050L, 0x7EFB2A98L, + 0xA1F1651DL, 0x39AF0176L, 0x66CA593EL, 0x82430E88L, + 0x8CEE8619L, 0x456F9FB4L, 0x7D84A5C3L, 0x3B8B5EBEL, + + /* 6 */ + 0xE06F75D8L, 0x85C12073L, 0x401A449FL, 0x56C16AA6L, + 0x4ED3AA62L, 0x363F7706L, 0x1BFEDF72L, 0x429B023DL, + 0x37D0D724L, 0xD00A1248L, 0xDB0FEAD3L, 0x49F1C09BL, + 0x075372C9L, 0x80991B7BL, 0x25D479D8L, 0xF6E8DEF7L, + + /* 7 */ + 0xE3FE501AL, 0xB6794C3BL, 0x976CE0BDL, 0x04C006BAL, + 0xC1A94FB6L, 0x409F60C4L, 0x5E5C9EC2L, 0x196A2463L, + 0x68FB6FAFL, 0x3E6C53B5L, 0x1339B2EBL, 0x3B52EC6FL, + 0x6DFC511FL, 0x9B30952CL, 0xCC814544L, 0xAF5EBD09L, + + /* 8 */ + 0xBEE3D004L, 0xDE334AFDL, 0x660F2807L, 0x192E4BB3L, + 0xC0CBA857L, 0x45C8740FL, 0xD20B5F39L, 0xB9D3FBDBL, + 0x5579C0BDL, 0x1A60320AL, 0xD6A100C6L, 0x402C7279L, + 0x679F25FEL, 0xFB1FA3CCL, 0x8EA5E9F8L, 0xDB3222F8L, + + /* 9 */ + 0x3C7516DFL, 0xFD616B15L, 0x2F501EC8L, 0xAD0552ABL, + 0x323DB5FAL, 0xFD238760L, 0x53317B48L, 0x3E00DF82L, + 0x9E5C57BBL, 0xCA6F8CA0L, 0x1A87562EL, 0xDF1769DBL, + 0xD542A8F6L, 0x287EFFC3L, 0xAC6732C6L, 0x8C4F5573L, + + /* A */ + 0x695B27B0L, 0xBBCA58C8L, 0xE1FFA35DL, 0xB8F011A0L, + 0x10FA3D98L, 0xFD2183B8L, 0x4AFCB56CL, 0x2DD1D35BL, + 0x9A53E479L, 0xB6F84565L, 0xD28E49BCL, 0x4BFB9790L, + 0xE1DDF2DAL, 0xA4CB7E33L, 0x62FB1341L, 0xCEE4C6E8L, + + /* B */ + 0xEF20CADAL, 0x36774C01L, 0xD07E9EFEL, 0x2BF11FB4L, + 0x95DBDA4DL, 0xAE909198L, 0xEAAD8E71L, 0x6B93D5A0L, + 0xD08ED1D0L, 0xAFC725E0L, 0x8E3C5B2FL, 0x8E7594B7L, + 0x8FF6E2FBL, 0xF2122B64L, 0x8888B812L, 0x900DF01CL, + + /* C */ + 0x4FAD5EA0L, 0x688FC31CL, 0xD1CFF191L, 0xB3A8C1ADL, + 0x2F2F2218L, 0xBE0E1777L, 0xEA752DFEL, 0x8B021FA1L, + 0xE5A0CC0FL, 0xB56F74E8L, 0x18ACF3D6L, 0xCE89E299L, + 0xB4A84FE0L, 0xFD13E0B7L, 0x7CC43B81L, 0xD2ADA8D9L, + + /* D */ + 0x165FA266L, 0x80957705L, 0x93CC7314L, 0x211A1477L, + 0xE6AD2065L, 0x77B5FA86L, 0xC75442F5L, 0xFB9D35CFL, + 0xEBCDAF0CL, 0x7B3E89A0L, 0xD6411BD3L, 0xAE1E7E49L, + 0x00250E2DL, 0x2071B35EL, 0x226800BBL, 0x57B8E0AFL, + + /* E */ + 0x2464369BL, 0xF009B91EL, 0x5563911DL, 0x59DFA6AAL, + 0x78C14389L, 0xD95A537FL, 0x207D5BA2L, 0x02E5B9C5L, + 0x83260376L, 0x6295CFA9L, 0x11C81968L, 0x4E734A41L, + 0xB3472DCAL, 0x7B14A94AL, 0x1B510052L, 0x9A532915L, + + /* F */ + 0xD60F573FL, 0xBC9BC6E4L, 0x2B60A476L, 0x81E67400L, + 0x08BA6FB5L, 0x571BE91FL, 0xF296EC6BL, 0x2A0DD915L, + 0xB6636521L, 0xE7B9F9B6L, 0xFF34052EL, 0xC5855664L, + 0x53B02D5DL, 0xA99F8FA1L, 0x08BA4799L, 0x6E85076AL + }, + + /* S[1] */ + { + 0x4B7A70E9L, 0xB5B32944L, 0xDB75092EL, 0xC4192623L, + 0xAD6EA6B0L, 0x49A7DF7DL, 0x9CEE60B8L, 0x8FEDB266L, + 0xECAA8C71L, 0x699A17FFL, 0x5664526CL, 0xC2B19EE1L, + 0x193602A5L, 0x75094C29L, 0xA0591340L, 0xE4183A3EL, + + 0x3F54989AL, 0x5B429D65L, 0x6B8FE4D6L, 0x99F73FD6L, + 0xA1D29C07L, 0xEFE830F5L, 0x4D2D38E6L, 0xF0255DC1L, + 0x4CDD2086L, 0x8470EB26L, 0x6382E9C6L, 0x021ECC5EL, + 0x09686B3FL, 0x3EBAEFC9L, 0x3C971814L, 0x6B6A70A1L, + + 0x687F3584L, 0x52A0E286L, 0xB79C5305L, 0xAA500737L, + 0x3E07841CL, 0x7FDEAE5CL, 0x8E7D44ECL, 0x5716F2B8L, + 0xB03ADA37L, 0xF0500C0DL, 0xF01C1F04L, 0x0200B3FFL, + 0xAE0CF51AL, 0x3CB574B2L, 0x25837A58L, 0xDC0921BDL, + + 0xD19113F9L, 0x7CA92FF6L, 0x94324773L, 0x22F54701L, + 0x3AE5E581L, 0x37C2DADCL, 0xC8B57634L, 0x9AF3DDA7L, + 0xA9446146L, 0x0FD0030EL, 0xECC8C73EL, 0xA4751E41L, + 0xE238CD99L, 0x3BEA0E2FL, 0x3280BBA1L, 0x183EB331L, + + 0x4E548B38L, 0x4F6DB908L, 0x6F420D03L, 0xF60A04BFL, + 0x2CB81290L, 0x24977C79L, 0x5679B072L, 0xBCAF89AFL, + 0xDE9A771FL, 0xD9930810L, 0xB38BAE12L, 0xDCCF3F2EL, + 0x5512721FL, 0x2E6B7124L, 0x501ADDE6L, 0x9F84CD87L, + + 0x7A584718L, 0x7408DA17L, 0xBC9F9ABCL, 0xE94B7D8CL, + 0xEC7AEC3AL, 0xDB851DFAL, 0x63094366L, 0xC464C3D2L, + 0xEF1C1847L, 0x3215D908L, 0xDD433B37L, 0x24C2BA16L, + 0x12A14D43L, 0x2A65C451L, 0x50940002L, 0x133AE4DDL, + + 0x71DFF89EL, 0x10314E55L, 0x81AC77D6L, 0x5F11199BL, + 0x043556F1L, 0xD7A3C76BL, 0x3C11183BL, 0x5924A509L, + 0xF28FE6EDL, 0x97F1FBFAL, 0x9EBABF2CL, 0x1E153C6EL, + 0x86E34570L, 0xEAE96FB1L, 0x860E5E0AL, 0x5A3E2AB3L, + + 0x771FE71CL, 0x4E3D06FAL, 0x2965DCB9L, 0x99E71D0FL, + 0x803E89D6L, 0x5266C825L, 0x2E4CC978L, 0x9C10B36AL, + 0xC6150EBAL, 0x94E2EA78L, 0xA5FC3C53L, 0x1E0A2DF4L, + 0xF2F74EA7L, 0x361D2B3DL, 0x1939260FL, 0x19C27960L, + + 0x5223A708L, 0xF71312B6L, 0xEBADFE6EL, 0xEAC31F66L, + 0xE3BC4595L, 0xA67BC883L, 0xB17F37D1L, 0x018CFF28L, + 0xC332DDEFL, 0xBE6C5AA5L, 0x65582185L, 0x68AB9802L, + 0xEECEA50FL, 0xDB2F953BL, 0x2AEF7DADL, 0x5B6E2F84L, + + 0x1521B628L, 0x29076170L, 0xECDD4775L, 0x619F1510L, + 0x13CCA830L, 0xEB61BD96L, 0x0334FE1EL, 0xAA0363CFL, + 0xB5735C90L, 0x4C70A239L, 0xD59E9E0BL, 0xCBAADE14L, + 0xEECC86BCL, 0x60622CA7L, 0x9CAB5CABL, 0xB2F3846EL, + + 0x648B1EAFL, 0x19BDF0CAL, 0xA02369B9L, 0x655ABB50L, + 0x40685A32L, 0x3C2AB4B3L, 0x319EE9D5L, 0xC021B8F7L, + 0x9B540B19L, 0x875FA099L, 0x95F7997EL, 0x623D7DA8L, + 0xF837889AL, 0x97E32D77L, 0x11ED935FL, 0x16681281L, + + 0x0E358829L, 0xC7E61FD6L, 0x96DEDFA1L, 0x7858BA99L, + 0x57F584A5L, 0x1B227263L, 0x9B83C3FFL, 0x1AC24696L, + 0xCDB30AEBL, 0x532E3054L, 0x8FD948E4L, 0x6DBC3128L, + 0x58EBF2EFL, 0x34C6FFEAL, 0xFE28ED61L, 0xEE7C3C73L, + + 0x5D4A14D9L, 0xE864B7E3L, 0x42105D14L, 0x203E13E0L, + 0x45EEE2B6L, 0xA3AAABEAL, 0xDB6C4F15L, 0xFACB4FD0L, + 0xC742F442L, 0xEF6ABBB5L, 0x654F3B1DL, 0x41CD2105L, + 0xD81E799EL, 0x86854DC7L, 0xE44B476AL, 0x3D816250L, + + 0xCF62A1F2L, 0x5B8D2646L, 0xFC8883A0L, 0xC1C7B6A3L, + 0x7F1524C3L, 0x69CB7492L, 0x47848A0BL, 0x5692B285L, + 0x095BBF00L, 0xAD19489DL, 0x1462B174L, 0x23820E00L, + 0x58428D2AL, 0x0C55F5EAL, 0x1DADF43EL, 0x233F7061L, + + 0x3372F092L, 0x8D937E41L, 0xD65FECF1L, 0x6C223BDBL, + 0x7CDE3759L, 0xCBEE7460L, 0x4085F2A7L, 0xCE77326EL, + 0xA6078084L, 0x19F8509EL, 0xE8EFD855L, 0x61D99735L, + 0xA969A7AAL, 0xC50C06C2L, 0x5A04ABFCL, 0x800BCADCL, + + 0x9E447A2EL, 0xC3453484L, 0xFDD56705L, 0x0E1E9EC9L, + 0xDB73DBD3L, 0x105588CDL, 0x675FDA79L, 0xE3674340L, + 0xC5C43465L, 0x713E38D8L, 0x3D28F89EL, 0xF16DFF20L, + 0x153E21E7L, 0x8FB03D4AL, 0xE6E39F2BL, 0xDB83ADF7L + }, + + /* S[2] */ + { + 0xE93D5A68L, 0x948140F7L, 0xF64C261CL, 0x94692934L, + 0x411520F7L, 0x7602D4F7L, 0xBCF46B2EL, 0xD4A20068L, + 0xD4082471L, 0x3320F46AL, 0x43B7D4B7L, 0x500061AFL, + 0x1E39F62EL, 0x97244546L, 0x14214F74L, 0xBF8B8840L, + + 0x4D95FC1DL, 0x96B591AFL, 0x70F4DDD3L, 0x66A02F45L, + 0xBFBC09ECL, 0x03BD9785L, 0x7FAC6DD0L, 0x31CB8504L, + 0x96EB27B3L, 0x55FD3941L, 0xDA2547E6L, 0xABCA0A9AL, + 0x28507825L, 0x530429F4L, 0x0A2C86DAL, 0xE9B66DFBL, + + 0x68DC1462L, 0xD7486900L, 0x680EC0A4L, 0x27A18DEEL, + 0x4F3FFEA2L, 0xE887AD8CL, 0xB58CE006L, 0x7AF4D6B6L, + 0xAACE1E7CL, 0xD3375FECL, 0xCE78A399L, 0x406B2A42L, + 0x20FE9E35L, 0xD9F385B9L, 0xEE39D7ABL, 0x3B124E8BL, + + 0x1DC9FAF7L, 0x4B6D1856L, 0x26A36631L, 0xEAE397B2L, + 0x3A6EFA74L, 0xDD5B4332L, 0x6841E7F7L, 0xCA7820FBL, + 0xFB0AF54EL, 0xD8FEB397L, 0x454056ACL, 0xBA489527L, + 0x55533A3AL, 0x20838D87L, 0xFE6BA9B7L, 0xD096954BL, + + 0x55A867BCL, 0xA1159A58L, 0xCCA92963L, 0x99E1DB33L, + 0xA62A4A56L, 0x3F3125F9L, 0x5EF47E1CL, 0x9029317CL, + 0xFDF8E802L, 0x04272F70L, 0x80BB155CL, 0x05282CE3L, + 0x95C11548L, 0xE4C66D22L, 0x48C1133FL, 0xC70F86DCL, + + 0x07F9C9EEL, 0x41041F0FL, 0x404779A4L, 0x5D886E17L, + 0x325F51EBL, 0xD59BC0D1L, 0xF2BCC18FL, 0x41113564L, + 0x257B7834L, 0x602A9C60L, 0xDFF8E8A3L, 0x1F636C1BL, + 0x0E12B4C2L, 0x02E1329EL, 0xAF664FD1L, 0xCAD18115L, + + 0x6B2395E0L, 0x333E92E1L, 0x3B240B62L, 0xEEBEB922L, + 0x85B2A20EL, 0xE6BA0D99L, 0xDE720C8CL, 0x2DA2F728L, + 0xD0127845L, 0x95B794FDL, 0x647D0862L, 0xE7CCF5F0L, + 0x5449A36FL, 0x877D48FAL, 0xC39DFD27L, 0xF33E8D1EL, + + 0x0A476341L, 0x992EFF74L, 0x3A6F6EABL, 0xF4F8FD37L, + 0xA812DC60L, 0xA1EBDDF8L, 0x991BE14CL, 0xDB6E6B0DL, + 0xC67B5510L, 0x6D672C37L, 0x2765D43BL, 0xDCD0E804L, + 0xF1290DC7L, 0xCC00FFA3L, 0xB5390F92L, 0x690FED0BL, + + 0x667B9FFBL, 0xCEDB7D9CL, 0xA091CF0BL, 0xD9155EA3L, + 0xBB132F88L, 0x515BAD24L, 0x7B9479BFL, 0x763BD6EBL, + 0x37392EB3L, 0xCC115979L, 0x8026E297L, 0xF42E312DL, + 0x6842ADA7L, 0xC66A2B3BL, 0x12754CCCL, 0x782EF11CL, + + 0x6A124237L, 0xB79251E7L, 0x06A1BBE6L, 0x4BFB6350L, + 0x1A6B1018L, 0x11CAEDFAL, 0x3D25BDD8L, 0xE2E1C3C9L, + 0x44421659L, 0x0A121386L, 0xD90CEC6EL, 0xD5ABEA2AL, + 0x64AF674EL, 0xDA86A85FL, 0xBEBFE988L, 0x64E4C3FEL, + + 0x9DBC8057L, 0xF0F7C086L, 0x60787BF8L, 0x6003604DL, + 0xD1FD8346L, 0xF6381FB0L, 0x7745AE04L, 0xD736FCCCL, + 0x83426B33L, 0xF01EAB71L, 0xB0804187L, 0x3C005E5FL, + 0x77A057BEL, 0xBDE8AE24L, 0x55464299L, 0xBF582E61L, + + 0x4E58F48FL, 0xF2DDFDA2L, 0xF474EF38L, 0x8789BDC2L, + 0x5366F9C3L, 0xC8B38E74L, 0xB475F255L, 0x46FCD9B9L, + 0x7AEB2661L, 0x8B1DDF84L, 0x846A0E79L, 0x915F95E2L, + 0x466E598EL, 0x20B45770L, 0x8CD55591L, 0xC902DE4CL, + + 0xB90BACE1L, 0xBB8205D0L, 0x11A86248L, 0x7574A99EL, + 0xB77F19B6L, 0xE0A9DC09L, 0x662D09A1L, 0xC4324633L, + 0xE85A1F02L, 0x09F0BE8CL, 0x4A99A025L, 0x1D6EFE10L, + 0x1AB93D1DL, 0x0BA5A4DFL, 0xA186F20FL, 0x2868F169L, + + 0xDCB7DA83L, 0x573906FEL, 0xA1E2CE9BL, 0x4FCD7F52L, + 0x50115E01L, 0xA70683FAL, 0xA002B5C4L, 0x0DE6D027L, + 0x9AF88C27L, 0x773F8641L, 0xC3604C06L, 0x61A806B5L, + 0xF0177A28L, 0xC0F586E0L, 0x006058AAL, 0x30DC7D62L, + + 0x11E69ED7L, 0x2338EA63L, 0x53C2DD94L, 0xC2C21634L, + 0xBBCBEE56L, 0x90BCB6DEL, 0xEBFC7DA1L, 0xCE591D76L, + 0x6F05E409L, 0x4B7C0188L, 0x39720A3DL, 0x7C927C24L, + 0x86E3725FL, 0x724D9DB9L, 0x1AC15BB4L, 0xD39EB8FCL, + + 0xED545578L, 0x08FCA5B5L, 0xD83D7CD3L, 0x4DAD0FC4L, + 0x1E50EF5EL, 0xB161E6F8L, 0xA28514D9L, 0x6C51133CL, + 0x6FD5C7E7L, 0x56E14EC4L, 0x362ABFCEL, 0xDDC6C837L, + 0xD79A3234L, 0x92638212L, 0x670EFA8EL, 0x406000E0L + }, + + /* S[3] */ + { + 0x3A39CE37L, 0xD3FAF5CFL, 0xABC27737L, 0x5AC52D1BL, + 0x5CB0679EL, 0x4FA33742L, 0xD3822740L, 0x99BC9BBEL, + 0xD5118E9DL, 0xBF0F7315L, 0xD62D1C7EL, 0xC700C47BL, + 0xB78C1B6BL, 0x21A19045L, 0xB26EB1BEL, 0x6A366EB4L, + + 0x5748AB2FL, 0xBC946E79L, 0xC6A376D2L, 0x6549C2C8L, + 0x530FF8EEL, 0x468DDE7DL, 0xD5730A1DL, 0x4CD04DC6L, + 0x2939BBDBL, 0xA9BA4650L, 0xAC9526E8L, 0xBE5EE304L, + 0xA1FAD5F0L, 0x6A2D519AL, 0x63EF8CE2L, 0x9A86EE22L, + + 0xC089C2B8L, 0x43242EF6L, 0xA51E03AAL, 0x9CF2D0A4L, + 0x83C061BAL, 0x9BE96A4DL, 0x8FE51550L, 0xBA645BD6L, + 0x2826A2F9L, 0xA73A3AE1L, 0x4BA99586L, 0xEF5562E9L, + 0xC72FEFD3L, 0xF752F7DAL, 0x3F046F69L, 0x77FA0A59L, + + 0x80E4A915L, 0x87B08601L, 0x9B09E6ADL, 0x3B3EE593L, + 0xE990FD5AL, 0x9E34D797L, 0x2CF0B7D9L, 0x022B8B51L, + 0x96D5AC3AL, 0x017DA67DL, 0xD1CF3ED6L, 0x7C7D2D28L, + 0x1F9F25CFL, 0xADF2B89BL, 0x5AD6B472L, 0x5A88F54CL, + + 0xE029AC71L, 0xE019A5E6L, 0x47B0ACFDL, 0xED93FA9BL, + 0xE8D3C48DL, 0x283B57CCL, 0xF8D56629L, 0x79132E28L, + 0x785F0191L, 0xED756055L, 0xF7960E44L, 0xE3D35E8CL, + 0x15056DD4L, 0x88F46DBAL, 0x03A16125L, 0x0564F0BDL, + + 0xC3EB9E15L, 0x3C9057A2L, 0x97271AECL, 0xA93A072AL, + 0x1B3F6D9BL, 0x1E6321F5L, 0xF59C66FBL, 0x26DCF319L, + 0x7533D928L, 0xB155FDF5L, 0x03563482L, 0x8ABA3CBBL, + 0x28517711L, 0xC20AD9F8L, 0xABCC5167L, 0xCCAD925FL, + + 0x4DE81751L, 0x3830DC8EL, 0x379D5862L, 0x9320F991L, + 0xEA7A90C2L, 0xFB3E7BCEL, 0x5121CE64L, 0x774FBE32L, + 0xA8B6E37EL, 0xC3293D46L, 0x48DE5369L, 0x6413E680L, + 0xA2AE0810L, 0xDD6DB224L, 0x69852DFDL, 0x09072166L, + + 0xB39A460AL, 0x6445C0DDL, 0x586CDECFL, 0x1C20C8AEL, + 0x5BBEF7DDL, 0x1B588D40L, 0xCCD2017FL, 0x6BB4E3BBL, + 0xDDA26A7EL, 0x3A59FF45L, 0x3E350A44L, 0xBCB4CDD5L, + 0x72EACEA8L, 0xFA6484BBL, 0x8D6612AEL, 0xBF3C6F47L, + + 0xD29BE463L, 0x542F5D9EL, 0xAEC2771BL, 0xF64E6370L, + 0x740E0D8DL, 0xE75B1357L, 0xF8721671L, 0xAF537D5DL, + 0x4040CB08L, 0x4EB4E2CCL, 0x34D2466AL, 0x0115AF84L, + 0xE1B00428L, 0x95983A1DL, 0x06B89FB4L, 0xCE6EA048L, + + 0x6F3F3B82L, 0x3520AB82L, 0x011A1D4BL, 0x277227F8L, + 0x611560B1L, 0xE7933FDCL, 0xBB3A792BL, 0x344525BDL, + 0xA08839E1L, 0x51CE794BL, 0x2F32C9B7L, 0xA01FBAC9L, + 0xE01CC87EL, 0xBCC7D1F6L, 0xCF0111C3L, 0xA1E8AAC7L, + + 0x1A908749L, 0xD44FBD9AL, 0xD0DADECBL, 0xD50ADA38L, + 0x0339C32AL, 0xC6913667L, 0x8DF9317CL, 0xE0B12B4FL, + 0xF79E59B7L, 0x43F5BB3AL, 0xF2D519FFL, 0x27D9459CL, + 0xBF97222CL, 0x15E6FC2AL, 0x0F91FC71L, 0x9B941525L, + + 0xFAE59361L, 0xCEB69CEBL, 0xC2A86459L, 0x12BAA8D1L, + 0xB6C1075EL, 0xE3056A0CL, 0x10D25065L, 0xCB03A442L, + 0xE0EC6E0EL, 0x1698DB3BL, 0x4C98A0BEL, 0x3278E964L, + 0x9F1F9532L, 0xE0D392DFL, 0xD3A0342BL, 0x8971F21EL, + + 0x1B0A7441L, 0x4BA3348CL, 0xC5BE7120L, 0xC37632D8L, + 0xDF359F8DL, 0x9B992F2EL, 0xE60B6F47L, 0x0FE3F11DL, + 0xE54CDA54L, 0x1EDAD891L, 0xCE6279CFL, 0xCD3E7E6FL, + 0x1618B166L, 0xFD2C1D05L, 0x848FD2C5L, 0xF6FB2299L, + + 0xF523F357L, 0xA6327623L, 0x93A83531L, 0x56CCCD02L, + 0xACF08162L, 0x5A75EBB5L, 0x6E163697L, 0x88D273CCL, + 0xDE966292L, 0x81B949D0L, 0x4C50901BL, 0x71C65614L, + 0xE6C6C7BDL, 0x327A140AL, 0x45E1D006L, 0xC3F27B9AL, + + 0xC9AA53FDL, 0x62A80F00L, 0xBB25BFE2L, 0x35BDD2F6L, + 0x71126905L, 0xB2040222L, 0xB6CBCF7CL, 0xCD769C2BL, + 0x53113EC0L, 0x1640E3D3L, 0x38ABBD60L, 0x2547ADF0L, + 0xBA38209CL, 0xF746CE76L, 0x77AFA1C5L, 0x20756060L, + + 0x85CBFE4EL, 0x8AE88DD8L, 0x7AAAF9B0L, 0x4CF9AA7EL, + 0x1948C25CL, 0x02FB8A8CL, 0x01C36AE4L, 0xD6EBE1F9L, + 0x90D4F869L, 0xA65CDEA0L, 0x3F09252DL, 0xC208E69FL, + 0xB74E6132L, 0xCE77E25BL, 0x578FDFE3L, 0x3AC372E6L + } + }, + + /* P */ + { + 0x243F6A88L, 0x85A308D3L, 0x13198A2EL, 0x03707344L, + 0xA4093822L, 0x299F31D0L, 0x082EFA98L, 0xEC4E6C89L, + 0x452821E6L, 0x38D01377L, 0xBE5466CFL, 0x34E90C6CL, + 0xC0AC29B7L, 0xC97C50DDL, 0x3F84D5B5L, 0xB5470917L, + 0x9216D5D9L, 0x8979FB1BL + } +}; + +/* + * __rtl_cipherBF_init. + */ +static rtlCipherError __rtl_cipherBF_init ( + CipherContextBF *ctx, + rtlCipherMode eMode, + const sal_uInt8 *pKeyData, sal_Size nKeyLen, + const sal_uInt8 *pArgData, sal_Size nArgLen) +{ + CipherKeyBF *key; + sal_uInt32 D, DL, DR; + sal_uInt16 i, j, k; + + key = &(ctx->m_key); + + rtl_copyMemory (key, &__rtl_cipherBF_key, sizeof (CipherKeyBF)); + rtl_zeroMemory (&(ctx->m_iv), sizeof(ctx->m_iv)); + ctx->m_offset = 0; + + for (i = 0, k = 0; i < CIPHER_ROUNDS_BF + 2; ++i) + { + D = 0; + for (j = 0; j < 4; ++j) + { + D = ((D << 8) | pKeyData[k]); + k++; + if (k >= nKeyLen) + k = 0; + } + key->m_P[i] ^= D; + } + + DL = 0; + DR = 0; + + for (i = 0; i < CIPHER_ROUNDS_BF + 2; i += 2) + { + __rtl_cipherBF_encode (key, &DL, &DR); + key->m_P[i ] = DL; + key->m_P[i + 1] = DR; + } + + for (i = 0; i < 4; ++i) + { + for (k = 0; k < 256; k += 2) + { + __rtl_cipherBF_encode (key, &DL, &DR); + key->m_S[i][k ] = DL; + key->m_S[i][k + 1] = DR; + } + } + + if (pArgData && nArgLen) + { + nArgLen = ((nArgLen < 8) ? nArgLen : 8); + if (eMode == rtl_Cipher_ModeStream) + { + rtl_copyMemory (ctx->m_iv.m_byte, pArgData, nArgLen); + } + else + { + RTL_CIPHER_NTOHL64 (pArgData, DL, DR, nArgLen); + ctx->m_iv.m_long[0] = DL; + ctx->m_iv.m_long[1] = DR; + } + } + + D = DL = DR = 0; + return rtl_Cipher_E_None; +} + +/* + * __rtl_cipherBF_update. + */ +static rtlCipherError __rtl_cipherBF_update ( + CipherContextBF *ctx, + rtlCipherMode eMode, + rtlCipherDirection eDirection, + const sal_uInt8 *pData, sal_Size nDatLen, + sal_uInt8 *pBuffer, sal_Size nBufLen) +{ + /* Check arguments. */ + if ((pData == NULL) || (pBuffer == NULL)) + return rtl_Cipher_E_Argument; + + if (!((0 < nDatLen) && (nDatLen <= nBufLen))) + return rtl_Cipher_E_BufferSize; + + /* Update. */ + if (eMode == rtl_Cipher_ModeECB) + { + /* Block mode. */ + while (nDatLen > 8) + { + __rtl_cipherBF_updateECB (ctx, eDirection, pData, pBuffer, 8); + nDatLen -= 8; + pData += 8; + pBuffer += 8; + } + __rtl_cipherBF_updateECB (ctx, eDirection, pData, pBuffer, nDatLen); + } + else if (eMode == rtl_Cipher_ModeCBC) + { + /* Block mode. */ + while (nDatLen > 8) + { + __rtl_cipherBF_updateCBC (ctx, eDirection, pData, pBuffer, 8); + nDatLen -= 8; + pData += 8; + pBuffer += 8; + } + __rtl_cipherBF_updateCBC (ctx, eDirection, pData, pBuffer, nDatLen); + } + else + { + /* Stream mode. */ + while (nDatLen > 0) + { + __rtl_cipherBF_updateCFB (ctx, eDirection, pData, pBuffer); + nDatLen -= 1; + pData += 1; + pBuffer += 1; + } + } + return rtl_Cipher_E_None; +} + +/* + * __rtl_cipherBF_updateECB. + */ +static void __rtl_cipherBF_updateECB ( + CipherContextBF *ctx, + rtlCipherDirection direction, + const sal_uInt8 *pData, + sal_uInt8 *pBuffer, + sal_Size nLength) +{ + CipherKeyBF *key; + sal_uInt32 DL, DR; + + key = &(ctx->m_key); + if (direction == rtl_Cipher_DirectionEncode) + { + RTL_CIPHER_NTOHL64(pData, DL, DR, nLength); + + __rtl_cipherBF_encode (key, &DL, &DR); + + RTL_CIPHER_HTONL(DL, pBuffer); + RTL_CIPHER_HTONL(DR, pBuffer); + } + else + { + RTL_CIPHER_NTOHL(pData, DL); + RTL_CIPHER_NTOHL(pData, DR); + + __rtl_cipherBF_decode (key, &DL, &DR); + + RTL_CIPHER_HTONL64(DL, DR, pBuffer, nLength); + } + DL = DR = 0; +} + +/* + * __rtl_cipherBF_updateCBC. + */ +static void __rtl_cipherBF_updateCBC ( + CipherContextBF *ctx, + rtlCipherDirection direction, + const sal_uInt8 *pData, + sal_uInt8 *pBuffer, + sal_Size nLength) +{ + CipherKeyBF *key; + sal_uInt32 DL, DR; + + key = &(ctx->m_key); + if (direction == rtl_Cipher_DirectionEncode) + { + RTL_CIPHER_NTOHL64(pData, DL, DR, nLength); + + DL ^= ctx->m_iv.m_long[0]; + DR ^= ctx->m_iv.m_long[1]; + + __rtl_cipherBF_encode (key, &DL, &DR); + + ctx->m_iv.m_long[0] = DL; + ctx->m_iv.m_long[1] = DR; + + RTL_CIPHER_HTONL(DL, pBuffer); + RTL_CIPHER_HTONL(DR, pBuffer); + } + else + { + sal_uInt32 IVL, IVR; + + RTL_CIPHER_NTOHL(pData, DL); + RTL_CIPHER_NTOHL(pData, DR); + + IVL = DL; + IVR = DR; + + __rtl_cipherBF_decode (key, &DL, &DR); + + DL ^= ctx->m_iv.m_long[0]; + DR ^= ctx->m_iv.m_long[1]; + + ctx->m_iv.m_long[0] = IVL; + ctx->m_iv.m_long[1] = IVR; + + RTL_CIPHER_HTONL64(DL, DR, pBuffer, nLength); + IVL = IVR = 0; + } + DL = DR = 0; +} + +/* + * __rtl_cipherBF_updateCFB. + */ +static void __rtl_cipherBF_updateCFB ( + CipherContextBF *ctx, + rtlCipherDirection direction, + const sal_uInt8 *pData, + sal_uInt8 *pBuffer) +{ + sal_uInt8 *iv; + sal_uInt32 k; + + iv = ctx->m_iv.m_byte; + k = ctx->m_offset; + + if (k == 0) + { + sal_uInt32 IVL, IVR; + + RTL_CIPHER_NTOHL64(iv, IVL, IVR, 8); + __rtl_cipherBF_encode (&(ctx->m_key), &IVL, &IVR); + RTL_CIPHER_HTONL64(IVL, IVR, iv, 8); + + IVL = IVR = 0; + } + + if (direction == rtl_Cipher_DirectionEncode) + { + iv[k] ^= *pData; + *pBuffer = iv[k]; + } + else + { + sal_uInt8 c = iv[k]; + iv[k] = *pData; + *pBuffer = *pData ^ c; + } + + ctx->m_offset = ((k + 1) & 0x07); + iv = NULL; +} + +/* + * __rtl_cipherBF_encode. + */ +static void __rtl_cipherBF_encode ( + CipherKeyBF *key, sal_uInt32 *xl, sal_uInt32 *xr) +{ + sal_uInt32 t, XL, XR; + sal_uInt16 i; + + XL = *xl; + XR = *xr; + + for (i = 0; i < CIPHER_ROUNDS_BF; ++i) + { + XL ^= key->m_P[i]; + XR ^= __rtl_cipherBF (key, XL); + + t = XL; + XL = XR; + XR = t; + } + + t = XL; + XL = XR; + XR = t; + + XR ^= key->m_P[CIPHER_ROUNDS_BF ]; + XL ^= key->m_P[CIPHER_ROUNDS_BF + 1]; + + *xl = XL; + *xr = XR; + + t = XL = XR = 0; +} + +/* + * __rtl_cipherBF_decode. + */ +static void __rtl_cipherBF_decode ( + CipherKeyBF *key, sal_uInt32 *xl, sal_uInt32 *xr) +{ + sal_uInt32 t, XL, XR; + sal_uInt16 i; + + XL = *xl; + XR = *xr; + + for (i = CIPHER_ROUNDS_BF + 1; i > 1; --i) + { + XL ^= key->m_P[i]; + XR ^= __rtl_cipherBF (key, XL); + + t = XL; + XL = XR; + XR = t; + } + + t = XL; + XL = XR; + XR = t; + + XR ^= key->m_P[1]; + XL ^= key->m_P[0]; + + *xl = XL; + *xr = XR; + + t = XL = XR = 0; +} + +/* + * __rtl_cipherBF. + */ +static sal_uInt32 __rtl_cipherBF (CipherKeyBF *key, sal_uInt32 x) +{ + sal_uInt16 a, b, c, d; + sal_uInt32 y; + + d = (sal_uInt16)(x & 0x00ff); + x >>= 8; + c = (sal_uInt16)(x & 0x00ff); + x >>= 8; + b = (sal_uInt16)(x & 0x00ff); + x >>= 8; + a = (sal_uInt16)(x & 0x00ff); + + y = key->m_S[0][a]; + y += key->m_S[1][b]; + y ^= key->m_S[2][c]; + y += key->m_S[3][d]; + + return y; +} + +/*======================================================================== + * + * rtl_cipherBF (Blowfish) implementation. + * + * Reference: + * Bruce Schneier: Applied Cryptography, 2nd edition, ch. 14.3 + * + *======================================================================*/ +/* + * rtl_cipher_createBF. + */ +rtlCipher SAL_CALL rtl_cipher_createBF (rtlCipherMode Mode) SAL_THROW_EXTERN_C() +{ + CipherBF_Impl *pImpl = (CipherBF_Impl*)NULL; + + if (Mode == rtl_Cipher_ModeInvalid) + return ((rtlCipher)NULL); + + pImpl = ((CipherBF_Impl*)rtl_allocateZeroMemory (sizeof (CipherBF_Impl))); + if (pImpl) + { + pImpl->m_cipher.m_algorithm = rtl_Cipher_AlgorithmBF; + pImpl->m_cipher.m_direction = rtl_Cipher_DirectionInvalid; + pImpl->m_cipher.m_mode = Mode; + + pImpl->m_cipher.m_init = rtl_cipher_initBF; + pImpl->m_cipher.m_encode = rtl_cipher_encodeBF; + pImpl->m_cipher.m_decode = rtl_cipher_decodeBF; + pImpl->m_cipher.m_delete = rtl_cipher_destroyBF; + } + return ((rtlCipher)pImpl); +} + +/* + * rtl_cipher_initBF. + */ +rtlCipherError SAL_CALL rtl_cipher_initBF ( + rtlCipher Cipher, + rtlCipherDirection Direction, + const sal_uInt8 *pKeyData, sal_Size nKeyLen, + const sal_uInt8 *pArgData, sal_Size nArgLen) SAL_THROW_EXTERN_C() +{ + CipherBF_Impl *pImpl = (CipherBF_Impl*)Cipher; + + if ((pImpl == NULL) || (pKeyData == NULL)) + return rtl_Cipher_E_Argument; + + if (!(pImpl->m_cipher.m_algorithm == rtl_Cipher_AlgorithmBF)) + return rtl_Cipher_E_Algorithm; + + if (!(Direction == rtl_Cipher_DirectionInvalid)) + pImpl->m_cipher.m_direction = Direction; + else + return rtl_Cipher_E_Direction; + + return __rtl_cipherBF_init ( + &(pImpl->m_context), pImpl->m_cipher.m_mode, + pKeyData, nKeyLen, pArgData, nArgLen); +} + +/* + * rtl_cipher_encodeBF. + */ +rtlCipherError SAL_CALL rtl_cipher_encodeBF ( + rtlCipher Cipher, + const void *pData, sal_Size nDatLen, + sal_uInt8 *pBuffer, sal_Size nBufLen) SAL_THROW_EXTERN_C() +{ + CipherBF_Impl *pImpl = (CipherBF_Impl*)Cipher; + if (pImpl == NULL) + return rtl_Cipher_E_Argument; + + if (!(pImpl->m_cipher.m_algorithm == rtl_Cipher_AlgorithmBF)) + return rtl_Cipher_E_Algorithm; + + if (pImpl->m_cipher.m_direction == rtl_Cipher_DirectionInvalid) + return rtl_Cipher_E_Direction; + if (pImpl->m_cipher.m_direction == rtl_Cipher_DirectionDecode) + return rtl_Cipher_E_Direction; + + return __rtl_cipherBF_update ( + &(pImpl->m_context), pImpl->m_cipher.m_mode, + rtl_Cipher_DirectionEncode, + (const sal_uInt8*)pData, nDatLen, pBuffer, nBufLen); +} + +/* + * rtl_cipher_decodeBF. + */ +rtlCipherError SAL_CALL rtl_cipher_decodeBF ( + rtlCipher Cipher, + const void *pData, sal_Size nDatLen, + sal_uInt8 *pBuffer, sal_Size nBufLen) SAL_THROW_EXTERN_C() +{ + CipherBF_Impl *pImpl = (CipherBF_Impl*)Cipher; + if (pImpl == NULL) + return rtl_Cipher_E_Argument; + + if (!(pImpl->m_cipher.m_algorithm == rtl_Cipher_AlgorithmBF)) + return rtl_Cipher_E_Algorithm; + + if (pImpl->m_cipher.m_direction == rtl_Cipher_DirectionInvalid) + return rtl_Cipher_E_Direction; + if (pImpl->m_cipher.m_direction == rtl_Cipher_DirectionEncode) + return rtl_Cipher_E_Direction; + + return __rtl_cipherBF_update ( + &(pImpl->m_context), pImpl->m_cipher.m_mode, + rtl_Cipher_DirectionDecode, + (const sal_uInt8*)pData, nDatLen, pBuffer, nBufLen); +} + +/* + * rtl_cipher_destroyBF. + */ +void SAL_CALL rtl_cipher_destroyBF (rtlCipher Cipher) SAL_THROW_EXTERN_C() +{ + CipherBF_Impl *pImpl = (CipherBF_Impl*)Cipher; + if (pImpl) + { + if (pImpl->m_cipher.m_algorithm == rtl_Cipher_AlgorithmBF) + rtl_freeZeroMemory (pImpl, sizeof (CipherBF_Impl)); + else + rtl_freeMemory (pImpl); + } +} + +/*======================================================================== + * + * rtl_cipher_ARCFOUR (RC4) internals. + * + *======================================================================*/ +#define CIPHER_CBLOCK_ARCFOUR 256 + +struct ContextARCFOUR_Impl +{ + unsigned int m_S[CIPHER_CBLOCK_ARCFOUR]; + unsigned int m_X, m_Y; +}; + +struct CipherARCFOUR_Impl +{ + Cipher_Impl m_cipher; + ContextARCFOUR_Impl m_context; +}; + +/** rtl_cipherARCFOUR_update_Impl. + */ +static rtlCipherError rtl_cipherARCFOUR_update_Impl ( + ContextARCFOUR_Impl *ctx, + const sal_uInt8 *pData, sal_Size nDatLen, + sal_uInt8 *pBuffer, sal_Size nBufLen); + +/* + * rtl_cipherARCFOUR_init_Impl. + */ +static rtlCipherError rtl_cipherARCFOUR_init_Impl ( + ContextARCFOUR_Impl *ctx, + const sal_uInt8 *pKeyData, sal_Size nKeyLen) +{ + unsigned int K[CIPHER_CBLOCK_ARCFOUR]; + unsigned int *L, *S; + unsigned int x, y, t; + sal_Size n, k; + + S = &(ctx->m_S[0]); + + /* Initialize S linearly. */ + for (x = 0; x < CIPHER_CBLOCK_ARCFOUR; x++) + S[x] = x; + + /* Initialize K with key, repeat key as necessary. */ + for (L = K, n = CIPHER_CBLOCK_ARCFOUR; n > nKeyLen; n -= nKeyLen) + { + for (k = 0; k < nKeyLen; k++) L[k] = pKeyData[k]; + L += nKeyLen; + } + for (k = 0; k < n; k++) L[k] = pKeyData[k]; + + /* Initialize S with K. */ + for (x = 0, y = 0; x < CIPHER_CBLOCK_ARCFOUR; x++) + { + y = (y + S[x] + K[x]) % CIPHER_CBLOCK_ARCFOUR; + t = S[x], S[x] = S[y], S[y] = t; /* swap S[x] and S[y] */ + } + + /* Initialize counters X and Y. */ + ctx->m_X = 0; + ctx->m_Y = 0; + + return rtl_Cipher_E_None; +} + +/* + * rtl_cipherARCFOUR_update_Impl. + */ +static rtlCipherError rtl_cipherARCFOUR_update_Impl ( + ContextARCFOUR_Impl *ctx, + const sal_uInt8 *pData, sal_Size nDatLen, + sal_uInt8 *pBuffer, sal_Size nBufLen) +{ + register unsigned int *S; + register unsigned int x, y, t; + sal_Size k; + + /* Check arguments. */ + if ((pData == NULL) || (pBuffer == NULL)) + return rtl_Cipher_E_Argument; + + if (!((0 < nDatLen) && (nDatLen <= nBufLen))) + return rtl_Cipher_E_BufferSize; + + /* Update. */ + S = &(ctx->m_S[0]); + for (k = 0; k < nDatLen; k++) + { + /* Update counters X and Y. */ + x = ctx->m_X; + y = ctx->m_Y; + x = (x + 1 ) % CIPHER_CBLOCK_ARCFOUR; + y = (y + S[x]) % CIPHER_CBLOCK_ARCFOUR; + ctx->m_X = x; + ctx->m_Y = y; + + /* Swap S[x] and S[y]. */ + t = S[x], S[x] = S[y], S[y] = t; + + /* Evaluate next key byte S[t]. */ + t = (S[x] + S[y]) % CIPHER_CBLOCK_ARCFOUR; + pBuffer[k] = pData[k] ^ ((sal_uInt8)(S[t] & 0xff)); + } + + return rtl_Cipher_E_None; +} + +/*======================================================================== + * + * rtl_cipher_ARCFOUR (RC4) implementation. + * + * Reference: + * Bruce Schneier: Applied Cryptography, 2nd edition, ch. 17.1 + * + *======================================================================*/ +/* + * rtl_cipher_createARCFOUR. + */ +rtlCipher SAL_CALL rtl_cipher_createARCFOUR (rtlCipherMode Mode) + SAL_THROW_EXTERN_C() +{ + CipherARCFOUR_Impl *pImpl = (CipherARCFOUR_Impl*)NULL; + + if (!(Mode == rtl_Cipher_ModeStream)) + return ((rtlCipher)NULL); + + pImpl = ((CipherARCFOUR_Impl*)rtl_allocateZeroMemory (sizeof (CipherARCFOUR_Impl))); + if (pImpl) + { + pImpl->m_cipher.m_algorithm = rtl_Cipher_AlgorithmARCFOUR; + pImpl->m_cipher.m_direction = rtl_Cipher_DirectionInvalid; + pImpl->m_cipher.m_mode = rtl_Cipher_ModeStream; + + pImpl->m_cipher.m_init = rtl_cipher_initARCFOUR; + pImpl->m_cipher.m_encode = rtl_cipher_encodeARCFOUR; + pImpl->m_cipher.m_decode = rtl_cipher_decodeARCFOUR; + pImpl->m_cipher.m_delete = rtl_cipher_destroyARCFOUR; + } + return ((rtlCipher)pImpl); +} + +/* + * rtl_cipher_initARCFOUR. + */ +rtlCipherError SAL_CALL rtl_cipher_initARCFOUR ( + rtlCipher Cipher, + rtlCipherDirection Direction, + const sal_uInt8 *pKeyData, sal_Size nKeyLen, + const sal_uInt8 *, sal_Size) SAL_THROW_EXTERN_C() +{ + CipherARCFOUR_Impl *pImpl = (CipherARCFOUR_Impl*)Cipher; + + if ((pImpl == NULL) || (pKeyData == NULL)) + return rtl_Cipher_E_Argument; + + if (!(pImpl->m_cipher.m_algorithm == rtl_Cipher_AlgorithmARCFOUR)) + return rtl_Cipher_E_Algorithm; + + if (!(Direction == rtl_Cipher_DirectionInvalid)) + pImpl->m_cipher.m_direction = Direction; + else + return rtl_Cipher_E_Direction; + + return rtl_cipherARCFOUR_init_Impl (&(pImpl->m_context), pKeyData, nKeyLen); +} + +/* + * rtl_cipher_encodeARCFOUR. + */ +rtlCipherError SAL_CALL rtl_cipher_encodeARCFOUR ( + rtlCipher Cipher, + const void *pData, sal_Size nDatLen, + sal_uInt8 *pBuffer, sal_Size nBufLen) SAL_THROW_EXTERN_C() +{ + CipherARCFOUR_Impl *pImpl = (CipherARCFOUR_Impl*)Cipher; + if (pImpl == NULL) + return rtl_Cipher_E_Argument; + + if (!(pImpl->m_cipher.m_algorithm == rtl_Cipher_AlgorithmARCFOUR)) + return rtl_Cipher_E_Algorithm; + + if (pImpl->m_cipher.m_direction == rtl_Cipher_DirectionInvalid) + return rtl_Cipher_E_Direction; + + return rtl_cipherARCFOUR_update_Impl ( + &(pImpl->m_context), + (const sal_uInt8*)pData, nDatLen, pBuffer, nBufLen); +} + +/* + * rtl_cipher_decodeARCFOUR. + */ +rtlCipherError SAL_CALL rtl_cipher_decodeARCFOUR ( + rtlCipher Cipher, + const void *pData, sal_Size nDatLen, + sal_uInt8 *pBuffer, sal_Size nBufLen) SAL_THROW_EXTERN_C() +{ + CipherARCFOUR_Impl *pImpl = (CipherARCFOUR_Impl*)Cipher; + if (pImpl == NULL) + return rtl_Cipher_E_Argument; + + if (!(pImpl->m_cipher.m_algorithm == rtl_Cipher_AlgorithmARCFOUR)) + return rtl_Cipher_E_Algorithm; + + if (pImpl->m_cipher.m_direction == rtl_Cipher_DirectionInvalid) + return rtl_Cipher_E_Direction; + + return rtl_cipherARCFOUR_update_Impl ( + &(pImpl->m_context), + (const sal_uInt8*)pData, nDatLen, pBuffer, nBufLen); +} + +/* + * rtl_cipher_destroyARCFOUR. + */ +void SAL_CALL rtl_cipher_destroyARCFOUR (rtlCipher Cipher) SAL_THROW_EXTERN_C() +{ + CipherARCFOUR_Impl *pImpl = (CipherARCFOUR_Impl*)Cipher; + if (pImpl) + { + if (pImpl->m_cipher.m_algorithm == rtl_Cipher_AlgorithmARCFOUR) + rtl_freeZeroMemory (pImpl, sizeof (CipherARCFOUR_Impl)); + else + rtl_freeMemory (pImpl); + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/cmdargs.cxx b/sal/rtl/source/cmdargs.cxx index ed44843b11cc..475e5fb76236 100644 --- a/sal/rtl/source/cmdargs.cxx +++ b/sal/rtl/source/cmdargs.cxx @@ -103,7 +103,7 @@ oslProcessError SAL_CALL rtl_getAppCommandArg ( return (result); } -sal_uInt32 SAL_CALL rtl_getAppCommandArgCount (void) +sal_uInt32 SAL_CALL rtl_getAppCommandArgCount() { init(); return g_nCommandArgCount; diff --git a/sal/rtl/source/crc.c b/sal/rtl/source/crc.c deleted file mode 100644 index fa372aaf4339..000000000000 --- a/sal/rtl/source/crc.c +++ /dev/null @@ -1,166 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#define _RTL_CRC_C_ - -#include -#include - -/*======================================================================== - * - * rtl_crc32Table (CRC polynomial 0xEDB88320). - * - *======================================================================*/ -static const sal_uInt32 rtl_crc32Table[256] = -{ - /* 0 */ - 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, - 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, - 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, - 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, - - /* 1 */ - 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, - 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, - 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, - 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, - - /* 2 */ - 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, - 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, - 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, - 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, - - /* 3 */ - 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, - 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, - 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, - 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, - - /* 4 */ - 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, - 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, - 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, - 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, - - /* 5 */ - 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, - 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, - 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, - 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, - - /* 6 */ - 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, - 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, - 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, - 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, - - /* 7 */ - 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, - 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, - 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, - 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, - - /* 8 */ - 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, - 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, - 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, - 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, - - /* 9 */ - 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, - 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, - 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, - 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, - - /* A */ - 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, - 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, - 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, - 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, - - /* B */ - 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, - 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, - 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, - 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, - - /* C */ - 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, - 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, - 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, - 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, - - /* D */ - 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, - 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, - 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, - 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, - - /* E */ - 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, - 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, - 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, - 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, - - /* F */ - 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, - 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, - 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, - 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D -}; - -/*======================================================================== - * - * rtl_crc32 implementation. - * - *======================================================================*/ -#define UPDCRC32(crc, octet) \ - (rtl_crc32Table[((crc) ^ (octet)) & 0xff] ^ ((crc) >> 8)) - -/* - * rtl_crc32. - */ -sal_uInt32 SAL_CALL rtl_crc32 ( - sal_uInt32 Crc, - const void *Data, sal_uInt32 DatLen) -{ - if (Data) - { - register const sal_uInt8 *p = (const sal_uInt8 *)Data; - register const sal_uInt8 *q = p + DatLen; - - Crc = ~Crc; - while (p < q) - Crc = UPDCRC32(Crc, *(p++)); - Crc = ~Crc; - } - return Crc; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/crc.cxx b/sal/rtl/source/crc.cxx new file mode 100644 index 000000000000..bd61347edc24 --- /dev/null +++ b/sal/rtl/source/crc.cxx @@ -0,0 +1,166 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#define _RTL_CRC_C_ + +#include +#include + +/*======================================================================== + * + * rtl_crc32Table (CRC polynomial 0xEDB88320). + * + *======================================================================*/ +static const sal_uInt32 rtl_crc32Table[256] = +{ + /* 0 */ + 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, + 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, + 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, + 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, + + /* 1 */ + 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, + 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, + 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, + 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, + + /* 2 */ + 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, + 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, + 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, + 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, + + /* 3 */ + 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, + 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, + 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, + 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, + + /* 4 */ + 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, + 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, + 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, + 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, + + /* 5 */ + 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, + 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, + 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, + 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, + + /* 6 */ + 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, + 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, + 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, + 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, + + /* 7 */ + 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, + 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, + 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, + 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, + + /* 8 */ + 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, + 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, + 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, + 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, + + /* 9 */ + 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, + 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, + 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, + 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, + + /* A */ + 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, + 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, + 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, + 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, + + /* B */ + 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, + 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, + 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, + 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, + + /* C */ + 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, + 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, + 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, + 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, + + /* D */ + 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, + 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, + 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, + 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, + + /* E */ + 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, + 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, + 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, + 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, + + /* F */ + 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, + 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, + 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, + 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D +}; + +/*======================================================================== + * + * rtl_crc32 implementation. + * + *======================================================================*/ +#define UPDCRC32(crc, octet) \ + (rtl_crc32Table[((crc) ^ (octet)) & 0xff] ^ ((crc) >> 8)) + +/* + * rtl_crc32. + */ +sal_uInt32 SAL_CALL rtl_crc32 ( + sal_uInt32 Crc, + const void *Data, sal_uInt32 DatLen) SAL_THROW_EXTERN_C() +{ + if (Data) + { + register const sal_uInt8 *p = (const sal_uInt8 *)Data; + register const sal_uInt8 *q = p + DatLen; + + Crc = ~Crc; + while (p < q) + Crc = UPDCRC32(Crc, *(p++)); + Crc = ~Crc; + } + return Crc; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/digest.c b/sal/rtl/source/digest.c deleted file mode 100644 index 92736cf4dd95..000000000000 --- a/sal/rtl/source/digest.c +++ /dev/null @@ -1,2121 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#define _RTL_DIGEST_C_ - -#include -#include -#include -#include -#include -#include - -/*======================================================================== - * - * rtlDigest internals. - * - *======================================================================*/ -#define RTL_DIGEST_CREATE(T) ((T*)(rtl_allocateZeroMemory(sizeof(T)))) - -#define RTL_DIGEST_ROTL(a,n) (((a) << (n)) | ((a) >> (32 - (n)))) - -#define RTL_DIGEST_HTONL(l,c) \ - (*((c)++) = (sal_uInt8)(((l) >> 24L) & 0xff), \ - *((c)++) = (sal_uInt8)(((l) >> 16L) & 0xff), \ - *((c)++) = (sal_uInt8)(((l) >> 8L) & 0xff), \ - *((c)++) = (sal_uInt8)(((l) ) & 0xff)) - -#define RTL_DIGEST_LTOC(l,c) \ - (*((c)++) = (sal_uInt8)(((l) ) & 0xff), \ - *((c)++) = (sal_uInt8)(((l) >> 8L) & 0xff), \ - *((c)++) = (sal_uInt8)(((l) >> 16L) & 0xff), \ - *((c)++) = (sal_uInt8)(((l) >> 24L) & 0xff)) - -typedef rtlDigestError (SAL_CALL Digest_init_t) ( - void *ctx, const sal_uInt8 *Data, sal_uInt32 DatLen); - -typedef void (SAL_CALL Digest_delete_t) (void *ctx); - -typedef rtlDigestError (SAL_CALL Digest_update_t) ( - void *ctx, const void *Data, sal_uInt32 DatLen); - -typedef rtlDigestError (SAL_CALL Digest_get_t) ( - void *ctx, sal_uInt8 *Buffer, sal_uInt32 BufLen); - -typedef struct digest_impl_st -{ - rtlDigestAlgorithm m_algorithm; - sal_uInt32 m_length; - - Digest_init_t *m_init; - Digest_delete_t *m_delete; - Digest_update_t *m_update; - Digest_get_t *m_get; -} Digest_Impl; - -/* - * __rtl_digest_swapLong. - */ -static void __rtl_digest_swapLong (sal_uInt32 *pData, sal_uInt32 nDatLen) -{ - register sal_uInt32 *X; - register int i, n; - - X = pData; - n = nDatLen; - - for (i = 0; i < n; i++) - X[i] = OSL_SWAPDWORD(X[i]); -} - -/*======================================================================== - * - * rtlDigest implementation. - * - *======================================================================*/ -/* - * rtl_digest_create. - */ -rtlDigest SAL_CALL rtl_digest_create (rtlDigestAlgorithm Algorithm) -{ - rtlDigest Digest = (rtlDigest)NULL; - switch (Algorithm) - { - case rtl_Digest_AlgorithmMD2: - Digest = rtl_digest_createMD2(); - break; - - case rtl_Digest_AlgorithmMD5: - Digest = rtl_digest_createMD5(); - break; - - case rtl_Digest_AlgorithmSHA: - Digest = rtl_digest_createSHA(); - break; - - case rtl_Digest_AlgorithmSHA1: - Digest = rtl_digest_createSHA1(); - break; - - case rtl_Digest_AlgorithmHMAC_MD5: - Digest = rtl_digest_createHMAC_MD5(); - break; - - case rtl_Digest_AlgorithmHMAC_SHA1: - Digest = rtl_digest_createHMAC_SHA1(); - break; - - default: /* rtl_Digest_AlgorithmInvalid */ - break; - } - return Digest; -} - -/* - * rtl_digest_queryAlgorithm. - */ -rtlDigestAlgorithm SAL_CALL rtl_digest_queryAlgorithm (rtlDigest Digest) -{ - Digest_Impl *pImpl = (Digest_Impl *)Digest; - if (pImpl) - return pImpl->m_algorithm; - else - return rtl_Digest_AlgorithmInvalid; -} - -/* - * rtl_digest_queryLength. - */ -sal_uInt32 SAL_CALL rtl_digest_queryLength (rtlDigest Digest) -{ - Digest_Impl *pImpl = (Digest_Impl *)Digest; - if (pImpl) - return pImpl->m_length; - else - return 0; -} - -/* - * rtl_digest_init. - */ -rtlDigestError SAL_CALL rtl_digest_init ( - rtlDigest Digest, const sal_uInt8 *pData, sal_uInt32 nDatLen) -{ - Digest_Impl *pImpl = (Digest_Impl *)Digest; - if (pImpl) - { - if (pImpl->m_init) - return pImpl->m_init (Digest, pData, nDatLen); - else - return rtl_Digest_E_None; - } - return rtl_Digest_E_Argument; -} - -/* - * rtl_digest_update. - */ -rtlDigestError SAL_CALL rtl_digest_update ( - rtlDigest Digest, const void *pData, sal_uInt32 nDatLen) -{ - Digest_Impl *pImpl = (Digest_Impl *)Digest; - if (pImpl && pImpl->m_update) - return pImpl->m_update (Digest, pData, nDatLen); - else - return rtl_Digest_E_Argument; -} - -/* - * rtl_digest_get. - */ -rtlDigestError SAL_CALL rtl_digest_get ( - rtlDigest Digest, sal_uInt8 *pBuffer, sal_uInt32 nBufLen) -{ - Digest_Impl *pImpl = (Digest_Impl *)Digest; - if (pImpl && pImpl->m_get) - return pImpl->m_get (Digest, pBuffer, nBufLen); - else - return rtl_Digest_E_Argument; -} - -/* - * rtl_digest_destroy. - */ -void SAL_CALL rtl_digest_destroy (rtlDigest Digest) -{ - Digest_Impl *pImpl = (Digest_Impl *)Digest; - if (pImpl && pImpl->m_delete) - pImpl->m_delete (Digest); -} - -/*======================================================================== - * - * rtl_digest_MD2 internals. - * - *======================================================================*/ -#define DIGEST_CBLOCK_MD2 16 -#define DIGEST_LBLOCK_MD2 16 - -typedef struct digestMD2_context_st -{ - sal_uInt32 m_nDatLen; - sal_uInt8 m_pData[DIGEST_CBLOCK_MD2]; - sal_uInt32 m_state[DIGEST_LBLOCK_MD2]; - sal_uInt32 m_chksum[DIGEST_LBLOCK_MD2]; -} DigestContextMD2; - -typedef struct digestMD2_impl_st -{ - Digest_Impl m_digest; - DigestContextMD2 m_context; -} DigestMD2_Impl; - -static void __rtl_digest_initMD2 (DigestContextMD2 *ctx); -static void __rtl_digest_updateMD2 (DigestContextMD2 *ctx); -static void __rtl_digest_endMD2 (DigestContextMD2 *ctx); - -static const sal_uInt32 S[256] = -{ - 0x29, 0x2E, 0x43, 0xC9, 0xA2, 0xD8, 0x7C, 0x01, - 0x3D, 0x36, 0x54, 0xA1, 0xEC, 0xF0, 0x06, 0x13, - 0x62, 0xA7, 0x05, 0xF3, 0xC0, 0xC7, 0x73, 0x8C, - 0x98, 0x93, 0x2B, 0xD9, 0xBC, 0x4C, 0x82, 0xCA, - 0x1E, 0x9B, 0x57, 0x3C, 0xFD, 0xD4, 0xE0, 0x16, - 0x67, 0x42, 0x6F, 0x18, 0x8A, 0x17, 0xE5, 0x12, - 0xBE, 0x4E, 0xC4, 0xD6, 0xDA, 0x9E, 0xDE, 0x49, - 0xA0, 0xFB, 0xF5, 0x8E, 0xBB, 0x2F, 0xEE, 0x7A, - 0xA9, 0x68, 0x79, 0x91, 0x15, 0xB2, 0x07, 0x3F, - 0x94, 0xC2, 0x10, 0x89, 0x0B, 0x22, 0x5F, 0x21, - 0x80, 0x7F, 0x5D, 0x9A, 0x5A, 0x90, 0x32, 0x27, - 0x35, 0x3E, 0xCC, 0xE7, 0xBF, 0xF7, 0x97, 0x03, - 0xFF, 0x19, 0x30, 0xB3, 0x48, 0xA5, 0xB5, 0xD1, - 0xD7, 0x5E, 0x92, 0x2A, 0xAC, 0x56, 0xAA, 0xC6, - 0x4F, 0xB8, 0x38, 0xD2, 0x96, 0xA4, 0x7D, 0xB6, - 0x76, 0xFC, 0x6B, 0xE2, 0x9C, 0x74, 0x04, 0xF1, - 0x45, 0x9D, 0x70, 0x59, 0x64, 0x71, 0x87, 0x20, - 0x86, 0x5B, 0xCF, 0x65, 0xE6, 0x2D, 0xA8, 0x02, - 0x1B, 0x60, 0x25, 0xAD, 0xAE, 0xB0, 0xB9, 0xF6, - 0x1C, 0x46, 0x61, 0x69, 0x34, 0x40, 0x7E, 0x0F, - 0x55, 0x47, 0xA3, 0x23, 0xDD, 0x51, 0xAF, 0x3A, - 0xC3, 0x5C, 0xF9, 0xCE, 0xBA, 0xC5, 0xEA, 0x26, - 0x2C, 0x53, 0x0D, 0x6E, 0x85, 0x28, 0x84, 0x09, - 0xD3, 0xDF, 0xCD, 0xF4, 0x41, 0x81, 0x4D, 0x52, - 0x6A, 0xDC, 0x37, 0xC8, 0x6C, 0xC1, 0xAB, 0xFA, - 0x24, 0xE1, 0x7B, 0x08, 0x0C, 0xBD, 0xB1, 0x4A, - 0x78, 0x88, 0x95, 0x8B, 0xE3, 0x63, 0xE8, 0x6D, - 0xE9, 0xCB, 0xD5, 0xFE, 0x3B, 0x00, 0x1D, 0x39, - 0xF2, 0xEF, 0xB7, 0x0E, 0x66, 0x58, 0xD0, 0xE4, - 0xA6, 0x77, 0x72, 0xF8, 0xEB, 0x75, 0x4B, 0x0A, - 0x31, 0x44, 0x50, 0xB4, 0x8F, 0xED, 0x1F, 0x1A, - 0xDB, 0x99, 0x8D, 0x33, 0x9F, 0x11, 0x83, 0x14, -}; - -/* - * __rtl_digest_MD2. - */ -static const Digest_Impl __rtl_digest_MD2 = -{ - rtl_Digest_AlgorithmMD2, - RTL_DIGEST_LENGTH_MD2, - - NULL, - rtl_digest_destroyMD2, - rtl_digest_updateMD2, - rtl_digest_getMD2 -}; - -/* - * __rtl_digest_initMD2. - */ -static void __rtl_digest_initMD2 (DigestContextMD2 *ctx) -{ - rtl_zeroMemory (ctx, sizeof (DigestContextMD2)); -} - -/* - * __rtl_digest_updateMD2. - */ -static void __rtl_digest_updateMD2 (DigestContextMD2 *ctx) -{ - register sal_uInt8 *X; - register sal_uInt32 *sp1, *sp2; - register sal_uInt32 i, k, t; - - sal_uInt32 state[48]; - - X = ctx->m_pData; - sp1 = ctx->m_state; - sp2 = ctx->m_chksum; - - k = sp2[DIGEST_LBLOCK_MD2 - 1]; - for (i = 0; i < 16; i++) - { - state[i + 0] = sp1[i]; - state[i + 16] = t = X[i]; - state[i + 32] = t ^ sp1[i]; - k = sp2[i] ^= S[t^k]; - } - - t = 0; - for (i = 0; i < 18; i++) - { - for (k = 0; k < 48; k += 8) - { - t = state[k + 0] ^= S[t]; - t = state[k + 1] ^= S[t]; - t = state[k + 2] ^= S[t]; - t = state[k + 3] ^= S[t]; - t = state[k + 4] ^= S[t]; - t = state[k + 5] ^= S[t]; - t = state[k + 6] ^= S[t]; - t = state[k + 7] ^= S[t]; - } - t = ((t + i) & 0xff); - } - - rtl_copyMemory (sp1, state, 16 * sizeof(sal_uInt32)); - rtl_zeroMemory (state, 48 * sizeof(sal_uInt32)); -} - -/* - * __rtl_digest_endMD2. - */ -static void __rtl_digest_endMD2 (DigestContextMD2 *ctx) -{ - register sal_uInt8 *X; - register sal_uInt32 *C; - sal_uInt32 i, n; - - X = ctx->m_pData; - C = ctx->m_chksum; - n = DIGEST_CBLOCK_MD2 - ctx->m_nDatLen; - - for (i = ctx->m_nDatLen; i < DIGEST_CBLOCK_MD2; i++) - X[i] = (sal_uInt8)(n & 0xff); - __rtl_digest_updateMD2 (ctx); - - for (i = 0; i < DIGEST_CBLOCK_MD2; i++) - X[i] = (sal_uInt8)(C[i] & 0xff); - __rtl_digest_updateMD2 (ctx); -} - -/*======================================================================== - * - * rtl_digest_MD2 implementation. - * - *======================================================================*/ -/* - * rtl_digest_MD2. - */ -rtlDigestError SAL_CALL rtl_digest_MD2 ( - const void *pData, sal_uInt32 nDatLen, - sal_uInt8 *pBuffer, sal_uInt32 nBufLen) -{ - DigestMD2_Impl digest; - rtlDigestError result; - - digest.m_digest = __rtl_digest_MD2; - __rtl_digest_initMD2 (&(digest.m_context)); - - result = rtl_digest_updateMD2 (&digest, pData, nDatLen); - if (result == rtl_Digest_E_None) - result = rtl_digest_getMD2 (&digest, pBuffer, nBufLen); - - rtl_zeroMemory (&digest, sizeof (digest)); - return (result); -} - -/* - * rtl_digest_createMD2. - */ -rtlDigest SAL_CALL rtl_digest_createMD2 (void) -{ - DigestMD2_Impl *pImpl = (DigestMD2_Impl*)NULL; - pImpl = RTL_DIGEST_CREATE(DigestMD2_Impl); - if (pImpl) - { - pImpl->m_digest = __rtl_digest_MD2; - __rtl_digest_initMD2 (&(pImpl->m_context)); - } - return ((rtlDigest)pImpl); -} - -/* - * rtl_digest_updateMD2. - */ -rtlDigestError SAL_CALL rtl_digest_updateMD2 ( - rtlDigest Digest, const void *pData, sal_uInt32 nDatLen) -{ - DigestMD2_Impl *pImpl = (DigestMD2_Impl *)Digest; - const sal_uInt8 *d = (const sal_uInt8 *)pData; - - DigestContextMD2 *ctx; - - if ((pImpl == NULL) || (pData == NULL)) - return rtl_Digest_E_Argument; - - if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmMD2)) - return rtl_Digest_E_Algorithm; - - if (nDatLen == 0) - return rtl_Digest_E_None; - - ctx = &(pImpl->m_context); - - if (ctx->m_nDatLen) - { - sal_uInt8 *p = ctx->m_pData + ctx->m_nDatLen; - sal_uInt32 n = DIGEST_CBLOCK_MD2 - ctx->m_nDatLen; - - if (nDatLen < n) - { - rtl_copyMemory (p, d, nDatLen); - ctx->m_nDatLen += nDatLen; - - return rtl_Digest_E_None; - } - - rtl_copyMemory (p, d, n); - d += n; - nDatLen -= n; - - __rtl_digest_updateMD2 (ctx); - ctx->m_nDatLen = 0; - } - - while (nDatLen >= DIGEST_CBLOCK_MD2) - { - rtl_copyMemory (ctx->m_pData, d, DIGEST_CBLOCK_MD2); - d += DIGEST_CBLOCK_MD2; - nDatLen -= DIGEST_CBLOCK_MD2; - - __rtl_digest_updateMD2 (ctx); - } - - rtl_copyMemory (ctx->m_pData, d, nDatLen); - ctx->m_nDatLen = nDatLen; - - return rtl_Digest_E_None; -} - -/* - * rtl_digest_getMD2. - */ -rtlDigestError SAL_CALL rtl_digest_getMD2 ( - rtlDigest Digest, sal_uInt8 *pBuffer, sal_uInt32 nBufLen) -{ - DigestMD2_Impl *pImpl = (DigestMD2_Impl *)Digest; - sal_uInt32 i; - - DigestContextMD2 *ctx; - - if ((pImpl == NULL) || (pBuffer == NULL)) - return rtl_Digest_E_Argument; - - if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmMD2)) - return rtl_Digest_E_Algorithm; - - if (!(pImpl->m_digest.m_length <= nBufLen)) - return rtl_Digest_E_BufferSize; - - ctx = &(pImpl->m_context); - - __rtl_digest_endMD2 (ctx); - for (i = 0; i < DIGEST_CBLOCK_MD2; i++) - pBuffer[i] = (sal_uInt8)(ctx->m_state[i] & 0xff); - __rtl_digest_initMD2 (ctx); - - return rtl_Digest_E_None; -} - -/* - * rtl_digest_destroyMD2. - */ -void SAL_CALL rtl_digest_destroyMD2 (rtlDigest Digest) -{ - DigestMD2_Impl *pImpl = (DigestMD2_Impl *)Digest; - if (pImpl) - { - if (pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmMD2) - rtl_freeZeroMemory (pImpl, sizeof (DigestMD2_Impl)); - else - rtl_freeMemory (pImpl); - } -} - -/*======================================================================== - * - * rtl_digest_MD5 internals. - * - *======================================================================*/ -#define DIGEST_CBLOCK_MD5 64 -#define DIGEST_LBLOCK_MD5 16 - -typedef struct digestMD5_context_st -{ - sal_uInt32 m_nDatLen; - sal_uInt32 m_pData[DIGEST_LBLOCK_MD5]; - sal_uInt32 m_nA, m_nB, m_nC, m_nD; - sal_uInt32 m_nL, m_nH; -} DigestContextMD5; - -typedef struct digestMD5_impl_st -{ - Digest_Impl m_digest; - DigestContextMD5 m_context; -} DigestMD5_Impl; - -static void __rtl_digest_initMD5 (DigestContextMD5 *ctx); -static void __rtl_digest_updateMD5 (DigestContextMD5 *ctx); -static void __rtl_digest_endMD5 (DigestContextMD5 *ctx); - -#define F(x,y,z) ((((y) ^ (z)) & (x)) ^ (z)) -#define G(x,y,z) ((((x) ^ (y)) & (z)) ^ (y)) -#define H(x,y,z) ((x) ^ (y) ^ (z)) -#define I(x,y,z) (((x) | (~(z))) ^ (y)) - -#define R0(a,b,c,d,k,s,t) { \ - a += ((k) + (t) + F((b), (c), (d))); \ - a = RTL_DIGEST_ROTL(a, s); \ - a += b; } - -#define R1(a,b,c,d,k,s,t) { \ - a += ((k) + (t) + G((b), (c), (d))); \ - a = RTL_DIGEST_ROTL(a, s); \ - a += b; } - -#define R2(a,b,c,d,k,s,t) { \ - a += ((k) + (t) + H((b), (c), (d))); \ - a = RTL_DIGEST_ROTL(a, s); \ - a += b; } - -#define R3(a,b,c,d,k,s,t) { \ - a += ((k) + (t) + I((b), (c), (d))); \ - a = RTL_DIGEST_ROTL(a, s); \ - a += b; } - -/* - * __rtl_digest_MD5. - */ -static const Digest_Impl __rtl_digest_MD5 = -{ - rtl_Digest_AlgorithmMD5, - RTL_DIGEST_LENGTH_MD5, - - NULL, - rtl_digest_destroyMD5, - rtl_digest_updateMD5, - rtl_digest_getMD5 -}; - -/* - * __rtl_digest_initMD5. - */ -static void __rtl_digest_initMD5 (DigestContextMD5 *ctx) -{ - rtl_zeroMemory (ctx, sizeof (DigestContextMD5)); - - ctx->m_nA = (sal_uInt32)0x67452301L; - ctx->m_nB = (sal_uInt32)0xefcdab89L; - ctx->m_nC = (sal_uInt32)0x98badcfeL; - ctx->m_nD = (sal_uInt32)0x10325476L; -} - -/* - * __rtl_digest_updateMD5. - */ -static void __rtl_digest_updateMD5 (DigestContextMD5 *ctx) -{ - register sal_uInt32 A, B, C, D; - register sal_uInt32 *X; - - A = ctx->m_nA; - B = ctx->m_nB; - C = ctx->m_nC; - D = ctx->m_nD; - X = ctx->m_pData; - - R0 (A, B, C, D, X[ 0], 7, 0xd76aa478L); - R0 (D, A, B, C, X[ 1], 12, 0xe8c7b756L); - R0 (C, D, A, B, X[ 2], 17, 0x242070dbL); - R0 (B, C, D, A, X[ 3], 22, 0xc1bdceeeL); - R0 (A, B, C, D, X[ 4], 7, 0xf57c0fafL); - R0 (D, A, B, C, X[ 5], 12, 0x4787c62aL); - R0 (C, D, A, B, X[ 6], 17, 0xa8304613L); - R0 (B, C, D, A, X[ 7], 22, 0xfd469501L); - R0 (A, B, C, D, X[ 8], 7, 0x698098d8L); - R0 (D, A, B, C, X[ 9], 12, 0x8b44f7afL); - R0 (C, D, A, B, X[10], 17, 0xffff5bb1L); - R0 (B, C, D, A, X[11], 22, 0x895cd7beL); - R0 (A, B, C, D, X[12], 7, 0x6b901122L); - R0 (D, A, B, C, X[13], 12, 0xfd987193L); - R0 (C, D, A, B, X[14], 17, 0xa679438eL); - R0 (B, C, D, A, X[15], 22, 0x49b40821L); - - R1 (A, B, C, D, X[ 1], 5, 0xf61e2562L); - R1 (D, A, B, C, X[ 6], 9, 0xc040b340L); - R1 (C, D, A, B, X[11], 14, 0x265e5a51L); - R1 (B, C, D, A, X[ 0], 20, 0xe9b6c7aaL); - R1 (A, B, C, D, X[ 5], 5, 0xd62f105dL); - R1 (D, A, B, C, X[10], 9, 0x02441453L); - R1 (C, D, A, B, X[15], 14, 0xd8a1e681L); - R1 (B, C, D, A, X[ 4], 20, 0xe7d3fbc8L); - R1 (A, B, C, D, X[ 9], 5, 0x21e1cde6L); - R1 (D, A, B, C, X[14], 9, 0xc33707d6L); - R1 (C, D, A, B, X[ 3], 14, 0xf4d50d87L); - R1 (B, C, D, A, X[ 8], 20, 0x455a14edL); - R1 (A, B, C, D, X[13], 5, 0xa9e3e905L); - R1 (D, A, B, C, X[ 2], 9, 0xfcefa3f8L); - R1 (C, D, A, B, X[ 7], 14, 0x676f02d9L); - R1 (B, C, D, A, X[12], 20, 0x8d2a4c8aL); - - R2 (A, B, C, D, X[ 5], 4, 0xfffa3942L); - R2 (D, A, B, C, X[ 8], 11, 0x8771f681L); - R2 (C, D, A, B, X[11], 16, 0x6d9d6122L); - R2 (B, C, D, A, X[14], 23, 0xfde5380cL); - R2 (A, B, C, D, X[ 1], 4, 0xa4beea44L); - R2 (D, A, B, C, X[ 4], 11, 0x4bdecfa9L); - R2 (C, D, A, B, X[ 7], 16, 0xf6bb4b60L); - R2 (B, C, D, A, X[10], 23, 0xbebfbc70L); - R2 (A, B, C, D, X[13], 4, 0x289b7ec6L); - R2 (D, A, B, C, X[ 0], 11, 0xeaa127faL); - R2 (C, D, A, B, X[ 3], 16, 0xd4ef3085L); - R2 (B, C, D, A, X[ 6], 23, 0x04881d05L); - R2 (A, B, C, D, X[ 9], 4, 0xd9d4d039L); - R2 (D, A, B, C, X[12], 11, 0xe6db99e5L); - R2 (C, D, A, B, X[15], 16, 0x1fa27cf8L); - R2 (B, C, D, A, X[ 2], 23, 0xc4ac5665L); - - R3 (A, B, C, D, X[ 0], 6, 0xf4292244L); - R3 (D, A, B, C, X[ 7], 10, 0x432aff97L); - R3 (C, D, A, B, X[14], 15, 0xab9423a7L); - R3 (B, C, D, A, X[ 5], 21, 0xfc93a039L); - R3 (A, B, C, D, X[12], 6, 0x655b59c3L); - R3 (D, A, B, C, X[ 3], 10, 0x8f0ccc92L); - R3 (C, D, A, B, X[10], 15, 0xffeff47dL); - R3 (B, C, D, A, X[ 1], 21, 0x85845dd1L); - R3 (A, B, C, D, X[ 8], 6, 0x6fa87e4fL); - R3 (D, A, B, C, X[15], 10, 0xfe2ce6e0L); - R3 (C, D, A, B, X[ 6], 15, 0xa3014314L); - R3 (B, C, D, A, X[13], 21, 0x4e0811a1L); - R3 (A, B, C, D, X[ 4], 6, 0xf7537e82L); - R3 (D, A, B, C, X[11], 10, 0xbd3af235L); - R3 (C, D, A, B, X[ 2], 15, 0x2ad7d2bbL); - R3 (B, C, D, A, X[ 9], 21, 0xeb86d391L); - - ctx->m_nA += A; - ctx->m_nB += B; - ctx->m_nC += C; - ctx->m_nD += D; -} - -/* - * __rtl_digest_endMD5. - */ -static void __rtl_digest_endMD5 (DigestContextMD5 *ctx) -{ - static const sal_uInt8 end[4] = - { - 0x80, 0x00, 0x00, 0x00 - }; - register const sal_uInt8 *p = end; - - register sal_uInt32 *X; - register int i; - - X = ctx->m_pData; - i = (ctx->m_nDatLen >> 2); - -#ifdef OSL_BIGENDIAN - __rtl_digest_swapLong (X, i + 1); -#endif /* OSL_BIGENDIAN */ - - switch (ctx->m_nDatLen & 0x03) - { - case 1: X[i] &= 0x000000ff; break; - case 2: X[i] &= 0x0000ffff; break; - case 3: X[i] &= 0x00ffffff; break; - } - - switch (ctx->m_nDatLen & 0x03) - { - case 0: X[i] = ((sal_uInt32)(*(p++))) << 0L; - case 1: X[i] |= ((sal_uInt32)(*(p++))) << 8L; - case 2: X[i] |= ((sal_uInt32)(*(p++))) << 16L; - case 3: X[i] |= ((sal_uInt32)(*p)) << 24L; - } - - i += 1; - - if (i >= (DIGEST_LBLOCK_MD5 - 2)) - { - for (; i < DIGEST_LBLOCK_MD5; i++) - X[i] = 0; - __rtl_digest_updateMD5 (ctx); - i = 0; - } - - for (; i < (DIGEST_LBLOCK_MD5 - 2); i++) - X[i] = 0; - - X[DIGEST_LBLOCK_MD5 - 2] = ctx->m_nL; - X[DIGEST_LBLOCK_MD5 - 1] = ctx->m_nH; - - __rtl_digest_updateMD5 (ctx); -} - -/*======================================================================== - * - * rtl_digest_MD5 implementation. - * - *======================================================================*/ -/* - * rtl_digest_MD5. - */ -rtlDigestError SAL_CALL rtl_digest_MD5 ( - const void *pData, sal_uInt32 nDatLen, - sal_uInt8 *pBuffer, sal_uInt32 nBufLen) -{ - DigestMD5_Impl digest; - rtlDigestError result; - - digest.m_digest = __rtl_digest_MD5; - __rtl_digest_initMD5 (&(digest.m_context)); - - result = rtl_digest_update (&digest, pData, nDatLen); - if (result == rtl_Digest_E_None) - result = rtl_digest_getMD5 (&digest, pBuffer, nBufLen); - - rtl_zeroMemory (&digest, sizeof (digest)); - return (result); -} - -/* - * rtl_digest_createMD5. - */ -rtlDigest SAL_CALL rtl_digest_createMD5 (void) -{ - DigestMD5_Impl *pImpl = (DigestMD5_Impl*)NULL; - pImpl = RTL_DIGEST_CREATE(DigestMD5_Impl); - if (pImpl) - { - pImpl->m_digest = __rtl_digest_MD5; - __rtl_digest_initMD5 (&(pImpl->m_context)); - } - return ((rtlDigest)pImpl); -} - -/* - * rtl_digest_updateMD5. - */ -rtlDigestError SAL_CALL rtl_digest_updateMD5 ( - rtlDigest Digest, const void *pData, sal_uInt32 nDatLen) -{ - DigestMD5_Impl *pImpl = (DigestMD5_Impl *)Digest; - const sal_uInt8 *d = (const sal_uInt8 *)pData; - - DigestContextMD5 *ctx; - sal_uInt32 len; - - if ((pImpl == NULL) || (pData == NULL)) - return rtl_Digest_E_Argument; - - if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmMD5)) - return rtl_Digest_E_Algorithm; - - if (nDatLen == 0) - return rtl_Digest_E_None; - - ctx = &(pImpl->m_context); - - len = ctx->m_nL + (nDatLen << 3); - if (len < ctx->m_nL) ctx->m_nH += 1; - ctx->m_nH += (nDatLen >> 29); - ctx->m_nL = len; - - if (ctx->m_nDatLen) - { - sal_uInt8 *p = (sal_uInt8 *)(ctx->m_pData) + ctx->m_nDatLen; - sal_uInt32 n = DIGEST_CBLOCK_MD5 - ctx->m_nDatLen; - - if (nDatLen < n) - { - rtl_copyMemory (p, d, nDatLen); - ctx->m_nDatLen += nDatLen; - - return rtl_Digest_E_None; - } - - rtl_copyMemory (p, d, n); - d += n; - nDatLen -= n; - -#ifdef OSL_BIGENDIAN - __rtl_digest_swapLong (ctx->m_pData, DIGEST_LBLOCK_MD5); -#endif /* OSL_BIGENDIAN */ - - __rtl_digest_updateMD5 (ctx); - ctx->m_nDatLen = 0; - } - - while (nDatLen >= DIGEST_CBLOCK_MD5) - { - rtl_copyMemory (ctx->m_pData, d, DIGEST_CBLOCK_MD5); - d += DIGEST_CBLOCK_MD5; - nDatLen -= DIGEST_CBLOCK_MD5; - -#ifdef OSL_BIGENDIAN - __rtl_digest_swapLong (ctx->m_pData, DIGEST_LBLOCK_MD5); -#endif /* OSL_BIGENDIAN */ - - __rtl_digest_updateMD5 (ctx); - } - - rtl_copyMemory (ctx->m_pData, d, nDatLen); - ctx->m_nDatLen = nDatLen; - - return rtl_Digest_E_None; -} - -/* - * rtl_digest_getMD5. - */ -rtlDigestError SAL_CALL rtl_digest_getMD5 ( - rtlDigest Digest, sal_uInt8 *pBuffer, sal_uInt32 nBufLen) -{ - DigestMD5_Impl *pImpl = (DigestMD5_Impl *)Digest; - sal_uInt8 *p = pBuffer; - - DigestContextMD5 *ctx; - - if ((pImpl == NULL) || (pBuffer == NULL)) - return rtl_Digest_E_Argument; - - if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmMD5)) - return rtl_Digest_E_Algorithm; - - if (!(pImpl->m_digest.m_length <= nBufLen)) - return rtl_Digest_E_BufferSize; - - ctx = &(pImpl->m_context); - - __rtl_digest_endMD5 (ctx); - RTL_DIGEST_LTOC (ctx->m_nA, p); - RTL_DIGEST_LTOC (ctx->m_nB, p); - RTL_DIGEST_LTOC (ctx->m_nC, p); - RTL_DIGEST_LTOC (ctx->m_nD, p); - __rtl_digest_initMD5 (ctx); - - return rtl_Digest_E_None; -} - -/* - * rtl_digest_rawMD5. - */ -rtlDigestError SAL_CALL rtl_digest_rawMD5 ( - rtlDigest Digest, sal_uInt8 *pBuffer, sal_uInt32 nBufLen) -{ - DigestMD5_Impl *pImpl = (DigestMD5_Impl *)Digest; - sal_uInt8 *p = pBuffer; - - DigestContextMD5 *ctx; - - if ((pImpl == NULL) || (pBuffer == NULL)) - return rtl_Digest_E_Argument; - - if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmMD5)) - return rtl_Digest_E_Algorithm; - - if (!(pImpl->m_digest.m_length <= nBufLen)) - return rtl_Digest_E_BufferSize; - - ctx = &(pImpl->m_context); - - /* __rtl_digest_endMD5 (ctx); *//* not finalized */ - RTL_DIGEST_LTOC (ctx->m_nA, p); - RTL_DIGEST_LTOC (ctx->m_nB, p); - RTL_DIGEST_LTOC (ctx->m_nC, p); - RTL_DIGEST_LTOC (ctx->m_nD, p); - __rtl_digest_initMD5 (ctx); - - return rtl_Digest_E_None; -} - -/* - * rtl_digest_destroyMD5. - */ -void SAL_CALL rtl_digest_destroyMD5 (rtlDigest Digest) -{ - DigestMD5_Impl *pImpl = (DigestMD5_Impl *)Digest; - if (pImpl) - { - if (pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmMD5) - rtl_freeZeroMemory (pImpl, sizeof (DigestMD5_Impl)); - else - rtl_freeMemory (pImpl); - } -} - -/*======================================================================== - * - * rtl_digest_(SHA|SHA1) common internals. - * - *======================================================================*/ -#define DIGEST_CBLOCK_SHA 64 -#define DIGEST_LBLOCK_SHA 16 - -typedef sal_uInt32 DigestSHA_update_t (sal_uInt32 x); - -static sal_uInt32 __rtl_digest_updateSHA_0 (sal_uInt32 x); -static sal_uInt32 __rtl_digest_updateSHA_1 (sal_uInt32 x); - -typedef struct digestSHA_context_st -{ - DigestSHA_update_t *m_update; - sal_uInt32 m_nDatLen; - sal_uInt32 m_pData[DIGEST_LBLOCK_SHA]; - sal_uInt32 m_nA, m_nB, m_nC, m_nD, m_nE; - sal_uInt32 m_nL, m_nH; -} DigestContextSHA; - -typedef struct digestSHA_impl_st -{ - Digest_Impl m_digest; - DigestContextSHA m_context; -} DigestSHA_Impl; - -static void __rtl_digest_initSHA ( - DigestContextSHA *ctx, DigestSHA_update_t *fct); - -static void __rtl_digest_updateSHA (DigestContextSHA *ctx); -static void __rtl_digest_endSHA (DigestContextSHA *ctx); - -#define K_00_19 (sal_uInt32)0x5a827999L -#define K_20_39 (sal_uInt32)0x6ed9eba1L -#define K_40_59 (sal_uInt32)0x8f1bbcdcL -#define K_60_79 (sal_uInt32)0xca62c1d6L - -#define F_00_19(b,c,d) ((((c) ^ (d)) & (b)) ^ (d)) -#define F_20_39(b,c,d) ((b) ^ (c) ^ (d)) -#define F_40_59(b,c,d) (((b) & (c)) | ((b) & (d)) | ((c) & (d))) -#define F_60_79(b,c,d) F_20_39(b,c,d) - -#define BODY_X(i) \ - (X[(i)&0x0f] ^ X[((i)+2)&0x0f] ^ X[((i)+8)&0x0f] ^ X[((i)+13)&0x0f]) - -#define BODY_00_15(u,i,a,b,c,d,e,f) \ - (f) = X[i]; \ - (f) += (e) + K_00_19 + RTL_DIGEST_ROTL((a), 5) + F_00_19((b), (c), (d)); \ - (b) = RTL_DIGEST_ROTL((b), 30); - -#define BODY_16_19(u,i,a,b,c,d,e,f) \ - (f) = BODY_X((i)); \ - (f) = X[(i)&0x0f] = (u)((f)); \ - (f) += (e) + K_00_19 + RTL_DIGEST_ROTL((a), 5) + F_00_19((b), (c), (d)); \ - (b) = RTL_DIGEST_ROTL((b), 30); - -#define BODY_20_39(u,i,a,b,c,d,e,f) \ - (f) = BODY_X((i)); \ - (f) = X[(i)&0x0f] = (u)((f)); \ - (f) += (e) + K_20_39 + RTL_DIGEST_ROTL((a), 5) + F_20_39((b), (c), (d)); \ - (b) = RTL_DIGEST_ROTL((b), 30); - -#define BODY_40_59(u,i,a,b,c,d,e,f) \ - (f) = BODY_X((i)); \ - (f) = X[(i)&0x0f] = (u)((f)); \ - (f) += (e) + K_40_59 + RTL_DIGEST_ROTL((a), 5) + F_40_59((b), (c), (d)); \ - (b) = RTL_DIGEST_ROTL((b), 30); - -#define BODY_60_79(u,i,a,b,c,d,e,f) \ - (f) = BODY_X((i)); \ - (f) = X[(i)&0x0f] = (u)((f)); \ - (f) += (e) + K_60_79 + RTL_DIGEST_ROTL((a), 5) + F_60_79((b), (c), (d)); \ - (b) = RTL_DIGEST_ROTL((b), 30); - -/* - * __rtl_digest_initSHA. - */ -static void __rtl_digest_initSHA ( - DigestContextSHA *ctx, DigestSHA_update_t *fct) -{ - rtl_zeroMemory (ctx, sizeof (DigestContextSHA)); - ctx->m_update = fct; - - ctx->m_nA = (sal_uInt32)0x67452301L; - ctx->m_nB = (sal_uInt32)0xefcdab89L; - ctx->m_nC = (sal_uInt32)0x98badcfeL; - ctx->m_nD = (sal_uInt32)0x10325476L; - ctx->m_nE = (sal_uInt32)0xc3d2e1f0L; -} - -/* - * __rtl_digest_updateSHA. - */ -static void __rtl_digest_updateSHA (DigestContextSHA *ctx) -{ - register sal_uInt32 A, B, C, D, E, T; - register sal_uInt32 *X; - - register DigestSHA_update_t *U; - U = ctx->m_update; - - A = ctx->m_nA; - B = ctx->m_nB; - C = ctx->m_nC; - D = ctx->m_nD; - E = ctx->m_nE; - X = ctx->m_pData; - - BODY_00_15 (U, 0, A, B, C, D, E, T); - BODY_00_15 (U, 1, T, A, B, C, D, E); - BODY_00_15 (U, 2, E, T, A, B, C, D); - BODY_00_15 (U, 3, D, E, T, A, B, C); - BODY_00_15 (U, 4, C, D, E, T, A, B); - BODY_00_15 (U, 5, B, C, D, E, T, A); - BODY_00_15 (U, 6, A, B, C, D, E, T); - BODY_00_15 (U, 7, T, A, B, C, D, E); - BODY_00_15 (U, 8, E, T, A, B, C, D); - BODY_00_15 (U, 9, D, E, T, A, B, C); - BODY_00_15 (U, 10, C, D, E, T, A, B); - BODY_00_15 (U, 11, B, C, D, E, T, A); - BODY_00_15 (U, 12, A, B, C, D, E, T); - BODY_00_15 (U, 13, T, A, B, C, D, E); - BODY_00_15 (U, 14, E, T, A, B, C, D); - BODY_00_15 (U, 15, D, E, T, A, B, C); - BODY_16_19 (U, 16, C, D, E, T, A, B); - BODY_16_19 (U, 17, B, C, D, E, T, A); - BODY_16_19 (U, 18, A, B, C, D, E, T); - BODY_16_19 (U, 19, T, A, B, C, D, E); - - BODY_20_39 (U, 20, E, T, A, B, C, D); - BODY_20_39 (U, 21, D, E, T, A, B, C); - BODY_20_39 (U, 22, C, D, E, T, A, B); - BODY_20_39 (U, 23, B, C, D, E, T, A); - BODY_20_39 (U, 24, A, B, C, D, E, T); - BODY_20_39 (U, 25, T, A, B, C, D, E); - BODY_20_39 (U, 26, E, T, A, B, C, D); - BODY_20_39 (U, 27, D, E, T, A, B, C); - BODY_20_39 (U, 28, C, D, E, T, A, B); - BODY_20_39 (U, 29, B, C, D, E, T, A); - BODY_20_39 (U, 30, A, B, C, D, E, T); - BODY_20_39 (U, 31, T, A, B, C, D, E); - BODY_20_39 (U, 32, E, T, A, B, C, D); - BODY_20_39 (U, 33, D, E, T, A, B, C); - BODY_20_39 (U, 34, C, D, E, T, A, B); - BODY_20_39 (U, 35, B, C, D, E, T, A); - BODY_20_39 (U, 36, A, B, C, D, E, T); - BODY_20_39 (U, 37, T, A, B, C, D, E); - BODY_20_39 (U, 38, E, T, A, B, C, D); - BODY_20_39 (U, 39, D, E, T, A, B, C); - - BODY_40_59 (U, 40, C, D, E, T, A, B); - BODY_40_59 (U, 41, B, C, D, E, T, A); - BODY_40_59 (U, 42, A, B, C, D, E, T); - BODY_40_59 (U, 43, T, A, B, C, D, E); - BODY_40_59 (U, 44, E, T, A, B, C, D); - BODY_40_59 (U, 45, D, E, T, A, B, C); - BODY_40_59 (U, 46, C, D, E, T, A, B); - BODY_40_59 (U, 47, B, C, D, E, T, A); - BODY_40_59 (U, 48, A, B, C, D, E, T); - BODY_40_59 (U, 49, T, A, B, C, D, E); - BODY_40_59 (U, 50, E, T, A, B, C, D); - BODY_40_59 (U, 51, D, E, T, A, B, C); - BODY_40_59 (U, 52, C, D, E, T, A, B); - BODY_40_59 (U, 53, B, C, D, E, T, A); - BODY_40_59 (U, 54, A, B, C, D, E, T); - BODY_40_59 (U, 55, T, A, B, C, D, E); - BODY_40_59 (U, 56, E, T, A, B, C, D); - BODY_40_59 (U, 57, D, E, T, A, B, C); - BODY_40_59 (U, 58, C, D, E, T, A, B); - BODY_40_59 (U, 59, B, C, D, E, T, A); - - BODY_60_79 (U, 60, A, B, C, D, E, T); - BODY_60_79 (U, 61, T, A, B, C, D, E); - BODY_60_79 (U, 62, E, T, A, B, C, D); - BODY_60_79 (U, 63, D, E, T, A, B, C); - BODY_60_79 (U, 64, C, D, E, T, A, B); - BODY_60_79 (U, 65, B, C, D, E, T, A); - BODY_60_79 (U, 66, A, B, C, D, E, T); - BODY_60_79 (U, 67, T, A, B, C, D, E); - BODY_60_79 (U, 68, E, T, A, B, C, D); - BODY_60_79 (U, 69, D, E, T, A, B, C); - BODY_60_79 (U, 70, C, D, E, T, A, B); - BODY_60_79 (U, 71, B, C, D, E, T, A); - BODY_60_79 (U, 72, A, B, C, D, E, T); - BODY_60_79 (U, 73, T, A, B, C, D, E); - BODY_60_79 (U, 74, E, T, A, B, C, D); - BODY_60_79 (U, 75, D, E, T, A, B, C); - BODY_60_79 (U, 76, C, D, E, T, A, B); - BODY_60_79 (U, 77, B, C, D, E, T, A); - BODY_60_79 (U, 78, A, B, C, D, E, T); - BODY_60_79 (U, 79, T, A, B, C, D, E); - - ctx->m_nA += E; - ctx->m_nB += T; - ctx->m_nC += A; - ctx->m_nD += B; - ctx->m_nE += C; -} - -/* - * __rtl_digest_endSHA. - */ -static void __rtl_digest_endSHA (DigestContextSHA *ctx) -{ - static const sal_uInt8 end[4] = - { - 0x80, 0x00, 0x00, 0x00 - }; - register const sal_uInt8 *p = end; - - register sal_uInt32 *X; - register int i; - - X = ctx->m_pData; - i = (ctx->m_nDatLen >> 2); - -#ifdef OSL_BIGENDIAN - __rtl_digest_swapLong (X, i + 1); -#endif /* OSL_BIGENDIAN */ - - switch (ctx->m_nDatLen & 0x03) - { - case 1: X[i] &= 0x000000ff; break; - case 2: X[i] &= 0x0000ffff; break; - case 3: X[i] &= 0x00ffffff; break; - } - - switch (ctx->m_nDatLen & 0x03) - { - case 0: X[i] = ((sal_uInt32)(*(p++))) << 0L; - case 1: X[i] |= ((sal_uInt32)(*(p++))) << 8L; - case 2: X[i] |= ((sal_uInt32)(*(p++))) << 16L; - case 3: X[i] |= ((sal_uInt32)(*(p++))) << 24L; - } - - __rtl_digest_swapLong (X, i + 1); - - i += 1; - - if (i >= (DIGEST_LBLOCK_SHA - 2)) - { - for (; i < DIGEST_LBLOCK_SHA; i++) - X[i] = 0; - __rtl_digest_updateSHA (ctx); - i = 0; - } - - for (; i < (DIGEST_LBLOCK_SHA - 2); i++) - X[i] = 0; - - X[DIGEST_LBLOCK_SHA - 2] = ctx->m_nH; - X[DIGEST_LBLOCK_SHA - 1] = ctx->m_nL; - - __rtl_digest_updateSHA (ctx); -} - -/*======================================================================== - * - * rtl_digest_SHA internals. - * - *======================================================================*/ -/* - * __rtl_digest_SHA_0. - */ -static const Digest_Impl __rtl_digest_SHA_0 = -{ - rtl_Digest_AlgorithmSHA, - RTL_DIGEST_LENGTH_SHA, - - NULL, - rtl_digest_destroySHA, - rtl_digest_updateSHA, - rtl_digest_getSHA -}; - -/* - * __rtl_digest_updateSHA_0. - */ -static sal_uInt32 __rtl_digest_updateSHA_0 (sal_uInt32 x) -{ - return x; -} - -/*======================================================================== - * - * rtl_digest_SHA implementation. - * - *======================================================================*/ -/* - * rtl_digest_SHA. - */ -rtlDigestError SAL_CALL rtl_digest_SHA ( - const void *pData, sal_uInt32 nDatLen, - sal_uInt8 *pBuffer, sal_uInt32 nBufLen) -{ - DigestSHA_Impl digest; - rtlDigestError result; - - digest.m_digest = __rtl_digest_SHA_0; - __rtl_digest_initSHA (&(digest.m_context), __rtl_digest_updateSHA_0); - - result = rtl_digest_updateSHA (&digest, pData, nDatLen); - if (result == rtl_Digest_E_None) - result = rtl_digest_getSHA (&digest, pBuffer, nBufLen); - - rtl_zeroMemory (&digest, sizeof (digest)); - return (result); -} - -/* - * rtl_digest_createSHA. - */ -rtlDigest SAL_CALL rtl_digest_createSHA (void) -{ - DigestSHA_Impl *pImpl = (DigestSHA_Impl*)NULL; - pImpl = RTL_DIGEST_CREATE(DigestSHA_Impl); - if (pImpl) - { - pImpl->m_digest = __rtl_digest_SHA_0; - __rtl_digest_initSHA (&(pImpl->m_context), __rtl_digest_updateSHA_0); - } - return ((rtlDigest)pImpl); -} - -/* - * rtl_digest_updateSHA. - */ -rtlDigestError SAL_CALL rtl_digest_updateSHA ( - rtlDigest Digest, const void *pData, sal_uInt32 nDatLen) -{ - DigestSHA_Impl *pImpl = (DigestSHA_Impl *)Digest; - const sal_uInt8 *d = (const sal_uInt8 *)pData; - - DigestContextSHA *ctx; - sal_uInt32 len; - - if ((pImpl == NULL) || (pData == NULL)) - return rtl_Digest_E_Argument; - - if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmSHA)) - return rtl_Digest_E_Algorithm; - - if (nDatLen == 0) - return rtl_Digest_E_None; - - ctx = &(pImpl->m_context); - - len = ctx->m_nL + (nDatLen << 3); - if (len < ctx->m_nL) ctx->m_nH += 1; - ctx->m_nH += (nDatLen >> 29); - ctx->m_nL = len; - - if (ctx->m_nDatLen) - { - sal_uInt8 *p = (sal_uInt8 *)(ctx->m_pData) + ctx->m_nDatLen; - sal_uInt32 n = DIGEST_CBLOCK_SHA - ctx->m_nDatLen; - - if (nDatLen < n) - { - rtl_copyMemory (p, d, nDatLen); - ctx->m_nDatLen += nDatLen; - - return rtl_Digest_E_None; - } - - rtl_copyMemory (p, d, n); - d += n; - nDatLen -= n; - -#ifndef OSL_BIGENDIAN - __rtl_digest_swapLong (ctx->m_pData, DIGEST_LBLOCK_SHA); -#endif /* OSL_BIGENDIAN */ - - __rtl_digest_updateSHA (ctx); - ctx->m_nDatLen = 0; - } - - while (nDatLen >= DIGEST_CBLOCK_SHA) - { - rtl_copyMemory (ctx->m_pData, d, DIGEST_CBLOCK_SHA); - d += DIGEST_CBLOCK_SHA; - nDatLen -= DIGEST_CBLOCK_SHA; - -#ifndef OSL_BIGENDIAN - __rtl_digest_swapLong (ctx->m_pData, DIGEST_LBLOCK_SHA); -#endif /* OSL_BIGENDIAN */ - - __rtl_digest_updateSHA (ctx); - } - - rtl_copyMemory (ctx->m_pData, d, nDatLen); - ctx->m_nDatLen = nDatLen; - - return rtl_Digest_E_None; -} - -/* - * rtl_digest_getSHA. - */ -rtlDigestError SAL_CALL rtl_digest_getSHA ( - rtlDigest Digest, sal_uInt8 *pBuffer, sal_uInt32 nBufLen) -{ - DigestSHA_Impl *pImpl = (DigestSHA_Impl *)Digest; - sal_uInt8 *p = pBuffer; - - DigestContextSHA *ctx; - - if ((pImpl == NULL) || (pBuffer == NULL)) - return rtl_Digest_E_Argument; - - if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmSHA)) - return rtl_Digest_E_Algorithm; - - if (!(pImpl->m_digest.m_length <= nBufLen)) - return rtl_Digest_E_BufferSize; - - ctx = &(pImpl->m_context); - - __rtl_digest_endSHA (ctx); - RTL_DIGEST_HTONL (ctx->m_nA, p); - RTL_DIGEST_HTONL (ctx->m_nB, p); - RTL_DIGEST_HTONL (ctx->m_nC, p); - RTL_DIGEST_HTONL (ctx->m_nD, p); - RTL_DIGEST_HTONL (ctx->m_nE, p); - __rtl_digest_initSHA (ctx, __rtl_digest_updateSHA_0); - - return rtl_Digest_E_None; -} - -/* - * rtl_digest_destroySHA. - */ -void SAL_CALL rtl_digest_destroySHA (rtlDigest Digest) -{ - DigestSHA_Impl *pImpl = (DigestSHA_Impl *)Digest; - if (pImpl) - { - if (pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmSHA) - rtl_freeZeroMemory (pImpl, sizeof (DigestSHA_Impl)); - else - rtl_freeMemory (pImpl); - } -} - -/*======================================================================== - * - * rtl_digest_SHA1 internals. - * - *======================================================================*/ -/* - * __rtl_digest_SHA_1. - */ -static const Digest_Impl __rtl_digest_SHA_1 = -{ - rtl_Digest_AlgorithmSHA1, - RTL_DIGEST_LENGTH_SHA1, - - NULL, - rtl_digest_destroySHA1, - rtl_digest_updateSHA1, - rtl_digest_getSHA1 -}; - -/* - * __rtl_digest_updateSHA_1. - */ -static sal_uInt32 __rtl_digest_updateSHA_1 (sal_uInt32 x) -{ - return RTL_DIGEST_ROTL (x, 1); -} - -/*======================================================================== - * - * rtl_digest_SHA1 implementation. - * - *======================================================================*/ -/* - * rtl_digest_SHA1. - */ -rtlDigestError SAL_CALL rtl_digest_SHA1 ( - const void *pData, sal_uInt32 nDatLen, - sal_uInt8 *pBuffer, sal_uInt32 nBufLen) -{ - DigestSHA_Impl digest; - rtlDigestError result; - - digest.m_digest = __rtl_digest_SHA_1; - __rtl_digest_initSHA (&(digest.m_context), __rtl_digest_updateSHA_1); - - result = rtl_digest_updateSHA1 (&digest, pData, nDatLen); - if (result == rtl_Digest_E_None) - result = rtl_digest_getSHA1 (&digest, pBuffer, nBufLen); - - rtl_zeroMemory (&digest, sizeof (digest)); - return (result); -} - -/* - * rtl_digest_createSHA1. - */ -rtlDigest SAL_CALL rtl_digest_createSHA1 (void) -{ - DigestSHA_Impl *pImpl = (DigestSHA_Impl*)NULL; - pImpl = RTL_DIGEST_CREATE(DigestSHA_Impl); - if (pImpl) - { - pImpl->m_digest = __rtl_digest_SHA_1; - __rtl_digest_initSHA (&(pImpl->m_context), __rtl_digest_updateSHA_1); - } - return ((rtlDigest)pImpl); -} - -/* - * rtl_digest_updateSHA1. - */ -rtlDigestError SAL_CALL rtl_digest_updateSHA1 ( - rtlDigest Digest, const void *pData, sal_uInt32 nDatLen) -{ - DigestSHA_Impl *pImpl = (DigestSHA_Impl *)Digest; - const sal_uInt8 *d = (const sal_uInt8 *)pData; - - DigestContextSHA *ctx; - sal_uInt32 len; - - if ((pImpl == NULL) || (pData == NULL)) - return rtl_Digest_E_Argument; - - if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmSHA1)) - return rtl_Digest_E_Algorithm; - - if (nDatLen == 0) - return rtl_Digest_E_None; - - ctx = &(pImpl->m_context); - - len = ctx->m_nL + (nDatLen << 3); - if (len < ctx->m_nL) ctx->m_nH += 1; - ctx->m_nH += (nDatLen >> 29); - ctx->m_nL = len; - - if (ctx->m_nDatLen) - { - sal_uInt8 *p = (sal_uInt8 *)(ctx->m_pData) + ctx->m_nDatLen; - sal_uInt32 n = DIGEST_CBLOCK_SHA - ctx->m_nDatLen; - - if (nDatLen < n) - { - rtl_copyMemory (p, d, nDatLen); - ctx->m_nDatLen += nDatLen; - - return rtl_Digest_E_None; - } - - rtl_copyMemory (p, d, n); - d += n; - nDatLen -= n; - -#ifndef OSL_BIGENDIAN - __rtl_digest_swapLong (ctx->m_pData, DIGEST_LBLOCK_SHA); -#endif /* OSL_BIGENDIAN */ - - __rtl_digest_updateSHA (ctx); - ctx->m_nDatLen = 0; - } - - while (nDatLen >= DIGEST_CBLOCK_SHA) - { - rtl_copyMemory (ctx->m_pData, d, DIGEST_CBLOCK_SHA); - d += DIGEST_CBLOCK_SHA; - nDatLen -= DIGEST_CBLOCK_SHA; - -#ifndef OSL_BIGENDIAN - __rtl_digest_swapLong (ctx->m_pData, DIGEST_LBLOCK_SHA); -#endif /* OSL_BIGENDIAN */ - - __rtl_digest_updateSHA (ctx); - } - - rtl_copyMemory (ctx->m_pData, d, nDatLen); - ctx->m_nDatLen = nDatLen; - - return rtl_Digest_E_None; -} - -/* - * rtl_digest_getSHA1. - */ -rtlDigestError SAL_CALL rtl_digest_getSHA1 ( - rtlDigest Digest, sal_uInt8 *pBuffer, sal_uInt32 nBufLen) -{ - DigestSHA_Impl *pImpl = (DigestSHA_Impl *)Digest; - sal_uInt8 *p = pBuffer; - - DigestContextSHA *ctx; - - if ((pImpl == NULL) || (pBuffer == NULL)) - return rtl_Digest_E_Argument; - - if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmSHA1)) - return rtl_Digest_E_Algorithm; - - if (!(pImpl->m_digest.m_length <= nBufLen)) - return rtl_Digest_E_BufferSize; - - ctx = &(pImpl->m_context); - - __rtl_digest_endSHA (ctx); - RTL_DIGEST_HTONL (ctx->m_nA, p); - RTL_DIGEST_HTONL (ctx->m_nB, p); - RTL_DIGEST_HTONL (ctx->m_nC, p); - RTL_DIGEST_HTONL (ctx->m_nD, p); - RTL_DIGEST_HTONL (ctx->m_nE, p); - __rtl_digest_initSHA (ctx, __rtl_digest_updateSHA_1); - - return rtl_Digest_E_None; -} - -/* - * rtl_digest_destroySHA1. - */ -void SAL_CALL rtl_digest_destroySHA1 (rtlDigest Digest) -{ - DigestSHA_Impl *pImpl = (DigestSHA_Impl *)Digest; - if (pImpl) - { - if (pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmSHA1) - rtl_freeZeroMemory (pImpl, sizeof (DigestSHA_Impl)); - else - rtl_freeMemory (pImpl); - } -} - -/*======================================================================== - * - * rtl_digest_HMAC_MD5 internals. - * - *======================================================================*/ -#define DIGEST_CBLOCK_HMAC_MD5 64 - -typedef struct _contextHMAC_MD5_st -{ - DigestMD5_Impl m_hash; - sal_uInt8 m_opad[DIGEST_CBLOCK_HMAC_MD5]; -} ContextHMAC_MD5; - -typedef struct _digestHMAC_MD5_impl_st -{ - Digest_Impl m_digest; - ContextHMAC_MD5 m_context; -} DigestHMAC_MD5_Impl; - -static void __rtl_digest_initHMAC_MD5 (ContextHMAC_MD5 * ctx); -static void __rtl_digest_ipadHMAC_MD5 (ContextHMAC_MD5 * ctx); -static void __rtl_digest_opadHMAC_MD5 (ContextHMAC_MD5 * ctx); - -/* - * __rtl_digest_HMAC_MD5. - */ -static const Digest_Impl __rtl_digest_HMAC_MD5 = -{ - rtl_Digest_AlgorithmHMAC_MD5, - RTL_DIGEST_LENGTH_MD5, - - rtl_digest_initHMAC_MD5, - rtl_digest_destroyHMAC_MD5, - rtl_digest_updateHMAC_MD5, - rtl_digest_getHMAC_MD5 -}; - -/* - * __rtl_digest_initHMAC_MD5. - */ -static void __rtl_digest_initHMAC_MD5 (ContextHMAC_MD5 * ctx) -{ - DigestMD5_Impl *pImpl = &(ctx->m_hash); - - pImpl->m_digest = __rtl_digest_MD5; - __rtl_digest_initMD5 (&(pImpl->m_context)); - - rtl_zeroMemory (ctx->m_opad, DIGEST_CBLOCK_HMAC_MD5); -} - -/* - * __rtl_digest_ipadHMAC_MD5. - */ -static void __rtl_digest_ipadHMAC_MD5 (ContextHMAC_MD5 * ctx) -{ - register sal_uInt32 i; - - for (i = 0; i < DIGEST_CBLOCK_HMAC_MD5; i++) - ctx->m_opad[i] ^= 0x36; - rtl_digest_updateMD5 ( - &(ctx->m_hash), ctx->m_opad, DIGEST_CBLOCK_HMAC_MD5); - for (i = 0; i < DIGEST_CBLOCK_HMAC_MD5; i++) - ctx->m_opad[i] ^= 0x36; -} - -/* - * __rtl_digest_opadHMAC_MD5. - */ -static void __rtl_digest_opadHMAC_MD5 (ContextHMAC_MD5 * ctx) -{ - register sal_uInt32 i; - - for (i = 0; i < DIGEST_CBLOCK_HMAC_MD5; i++) - ctx->m_opad[i] ^= 0x5c; -} - -/*======================================================================== - * - * rtl_digest_HMAC_MD5 implementation. - * - *======================================================================*/ -/* - * rtl_digest_HMAC_MD5. - */ -rtlDigestError SAL_CALL rtl_digest_HMAC_MD5 ( - const sal_uInt8 *pKeyData, sal_uInt32 nKeyLen, - const void *pData, sal_uInt32 nDatLen, - sal_uInt8 *pBuffer, sal_uInt32 nBufLen) -{ - DigestHMAC_MD5_Impl digest; - rtlDigestError result; - - digest.m_digest = __rtl_digest_HMAC_MD5; - - result = rtl_digest_initHMAC_MD5 (&digest, pKeyData, nKeyLen); - if (result == rtl_Digest_E_None) - { - result = rtl_digest_updateHMAC_MD5 (&digest, pData, nDatLen); - if (result == rtl_Digest_E_None) - result = rtl_digest_getHMAC_MD5 (&digest, pBuffer, nBufLen); - } - - rtl_zeroMemory (&digest, sizeof (digest)); - return (result); -} - -/* - * rtl_digest_createHMAC_MD5. - */ -rtlDigest SAL_CALL rtl_digest_createHMAC_MD5 (void) -{ - DigestHMAC_MD5_Impl *pImpl = (DigestHMAC_MD5_Impl*)NULL; - pImpl = RTL_DIGEST_CREATE(DigestHMAC_MD5_Impl); - if (pImpl) - { - pImpl->m_digest = __rtl_digest_HMAC_MD5; - __rtl_digest_initHMAC_MD5 (&(pImpl->m_context)); - } - return ((rtlDigest)pImpl); -} - -/* - * rtl_digest_initHMAC_MD5. - */ -rtlDigestError SAL_CALL rtl_digest_initHMAC_MD5 ( - rtlDigest Digest, const sal_uInt8 *pKeyData, sal_uInt32 nKeyLen) -{ - DigestHMAC_MD5_Impl *pImpl = (DigestHMAC_MD5_Impl*)Digest; - ContextHMAC_MD5 *ctx; - - if ((pImpl == NULL) || (pKeyData == NULL)) - return rtl_Digest_E_Argument; - - if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmHMAC_MD5)) - return rtl_Digest_E_Algorithm; - - ctx = &(pImpl->m_context); - __rtl_digest_initHMAC_MD5 (ctx); - - if (nKeyLen > DIGEST_CBLOCK_HMAC_MD5) - { - /* Initialize 'opad' with hashed 'KeyData' */ - rtl_digest_updateMD5 ( - &(ctx->m_hash), pKeyData, nKeyLen); - rtl_digest_getMD5 ( - &(ctx->m_hash), ctx->m_opad, RTL_DIGEST_LENGTH_MD5); - } - else - { - /* Initialize 'opad' with plain 'KeyData' */ - rtl_copyMemory (ctx->m_opad, pKeyData, nKeyLen); - } - - __rtl_digest_ipadHMAC_MD5 (ctx); - __rtl_digest_opadHMAC_MD5 (ctx); - - return rtl_Digest_E_None; -} - -/* - * rtl_digest_updateHMAC_MD5. - */ -rtlDigestError SAL_CALL rtl_digest_updateHMAC_MD5 ( - rtlDigest Digest, const void *pData, sal_uInt32 nDatLen) -{ - DigestHMAC_MD5_Impl *pImpl = (DigestHMAC_MD5_Impl*)Digest; - ContextHMAC_MD5 *ctx; - - if ((pImpl == NULL) || (pData == NULL)) - return rtl_Digest_E_Argument; - - if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmHMAC_MD5)) - return rtl_Digest_E_Algorithm; - - ctx = &(pImpl->m_context); - rtl_digest_updateMD5 (&(ctx->m_hash), pData, nDatLen); - - return rtl_Digest_E_None; -} - -/* - * rtl_digest_getHMAC_MD5. - */ -rtlDigestError SAL_CALL rtl_digest_getHMAC_MD5 ( - rtlDigest Digest, sal_uInt8 *pBuffer, sal_uInt32 nBufLen) -{ - DigestHMAC_MD5_Impl *pImpl = (DigestHMAC_MD5_Impl*)Digest; - ContextHMAC_MD5 *ctx; - - if ((pImpl == NULL) || (pBuffer == NULL)) - return rtl_Digest_E_Argument; - - if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmHMAC_MD5)) - return rtl_Digest_E_Algorithm; - - if (!(pImpl->m_digest.m_length <= nBufLen)) - return rtl_Digest_E_BufferSize; - - nBufLen = pImpl->m_digest.m_length; - - ctx = &(pImpl->m_context); - rtl_digest_getMD5 (&(ctx->m_hash), pBuffer, nBufLen); - - rtl_digest_updateMD5 (&(ctx->m_hash), ctx->m_opad, 64); - rtl_digest_updateMD5 (&(ctx->m_hash), pBuffer, nBufLen); - rtl_digest_getMD5 (&(ctx->m_hash), pBuffer, nBufLen); - - __rtl_digest_opadHMAC_MD5 (ctx); - __rtl_digest_ipadHMAC_MD5 (ctx); - __rtl_digest_opadHMAC_MD5 (ctx); - - return rtl_Digest_E_None; -} - -/* - * rtl_digest_destroyHMAC_MD5. - */ -void SAL_CALL rtl_digest_destroyHMAC_MD5 (rtlDigest Digest) -{ - DigestHMAC_MD5_Impl *pImpl = (DigestHMAC_MD5_Impl*)Digest; - if (pImpl) - { - if (pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmHMAC_MD5) - rtl_freeZeroMemory (pImpl, sizeof (DigestHMAC_MD5_Impl)); - else - rtl_freeMemory (pImpl); - } -} - -/*======================================================================== - * - * rtl_digest_HMAC_SHA1 internals. - * - *======================================================================*/ -#define DIGEST_CBLOCK_HMAC_SHA1 64 - -typedef struct _contextHMAC_SHA1_st -{ - DigestSHA_Impl m_hash; - sal_uInt8 m_opad[DIGEST_CBLOCK_HMAC_SHA1]; -} ContextHMAC_SHA1; - -typedef struct _digestHMAC_SHA1_impl_st -{ - Digest_Impl m_digest; - ContextHMAC_SHA1 m_context; -} DigestHMAC_SHA1_Impl; - -static void __rtl_digest_initHMAC_SHA1 (ContextHMAC_SHA1 * ctx); -static void __rtl_digest_ipadHMAC_SHA1 (ContextHMAC_SHA1 * ctx); -static void __rtl_digest_opadHMAC_SHA1 (ContextHMAC_SHA1 * ctx); - -/* - * __rtl_digest_HMAC_SHA1. - */ -static const Digest_Impl __rtl_digest_HMAC_SHA1 = -{ - rtl_Digest_AlgorithmHMAC_SHA1, - RTL_DIGEST_LENGTH_SHA1, - - rtl_digest_initHMAC_SHA1, - rtl_digest_destroyHMAC_SHA1, - rtl_digest_updateHMAC_SHA1, - rtl_digest_getHMAC_SHA1 -}; - -/* - * __rtl_digest_initHMAC_SHA1. - */ -static void __rtl_digest_initHMAC_SHA1 (ContextHMAC_SHA1 * ctx) -{ - DigestSHA_Impl *pImpl = &(ctx->m_hash); - - pImpl->m_digest = __rtl_digest_SHA_1; - __rtl_digest_initSHA (&(pImpl->m_context), __rtl_digest_updateSHA_1); - - rtl_zeroMemory (ctx->m_opad, DIGEST_CBLOCK_HMAC_SHA1); -} - -/* - * __rtl_digest_ipadHMAC_SHA1. - */ -static void __rtl_digest_ipadHMAC_SHA1 (ContextHMAC_SHA1 * ctx) -{ - register sal_uInt32 i; - - for (i = 0; i < DIGEST_CBLOCK_HMAC_SHA1; i++) - ctx->m_opad[i] ^= 0x36; - rtl_digest_updateSHA1 ( - &(ctx->m_hash), ctx->m_opad, DIGEST_CBLOCK_HMAC_SHA1); - for (i = 0; i < DIGEST_CBLOCK_HMAC_SHA1; i++) - ctx->m_opad[i] ^= 0x36; -} - -/* - * __rtl_digest_opadHMAC_SHA1. - */ -static void __rtl_digest_opadHMAC_SHA1 (ContextHMAC_SHA1 * ctx) -{ - register sal_uInt32 i; - - for (i = 0; i < DIGEST_CBLOCK_HMAC_SHA1; i++) - ctx->m_opad[i] ^= 0x5c; -} - -/*======================================================================== - * - * rtl_digest_HMAC_SHA1 implementation. - * - *======================================================================*/ -/* - * rtl_digest_HMAC_SHA1. - */ -rtlDigestError SAL_CALL rtl_digest_HMAC_SHA1 ( - const sal_uInt8 *pKeyData, sal_uInt32 nKeyLen, - const void *pData, sal_uInt32 nDatLen, - sal_uInt8 *pBuffer, sal_uInt32 nBufLen) -{ - DigestHMAC_SHA1_Impl digest; - rtlDigestError result; - - digest.m_digest = __rtl_digest_HMAC_SHA1; - - result = rtl_digest_initHMAC_SHA1 (&digest, pKeyData, nKeyLen); - if (result == rtl_Digest_E_None) - { - result = rtl_digest_updateHMAC_SHA1 (&digest, pData, nDatLen); - if (result == rtl_Digest_E_None) - result = rtl_digest_getHMAC_SHA1 (&digest, pBuffer, nBufLen); - } - - rtl_zeroMemory (&digest, sizeof (digest)); - return (result); -} - -/* - * rtl_digest_createHMAC_SHA1. - */ -rtlDigest SAL_CALL rtl_digest_createHMAC_SHA1 (void) -{ - DigestHMAC_SHA1_Impl *pImpl = (DigestHMAC_SHA1_Impl*)NULL; - pImpl = RTL_DIGEST_CREATE(DigestHMAC_SHA1_Impl); - if (pImpl) - { - pImpl->m_digest = __rtl_digest_HMAC_SHA1; - __rtl_digest_initHMAC_SHA1 (&(pImpl->m_context)); - } - return ((rtlDigest)pImpl); -} - -/* - * rtl_digest_initHMAC_SHA1. - */ -rtlDigestError SAL_CALL rtl_digest_initHMAC_SHA1 ( - rtlDigest Digest, const sal_uInt8 *pKeyData, sal_uInt32 nKeyLen) -{ - DigestHMAC_SHA1_Impl *pImpl = (DigestHMAC_SHA1_Impl*)Digest; - ContextHMAC_SHA1 *ctx; - - if ((pImpl == NULL) || (pKeyData == NULL)) - return rtl_Digest_E_Argument; - - if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmHMAC_SHA1)) - return rtl_Digest_E_Algorithm; - - ctx = &(pImpl->m_context); - __rtl_digest_initHMAC_SHA1 (ctx); - - if (nKeyLen > DIGEST_CBLOCK_HMAC_SHA1) - { - /* Initialize 'opad' with hashed 'KeyData' */ - rtl_digest_updateSHA1 ( - &(ctx->m_hash), pKeyData, nKeyLen); - rtl_digest_getSHA1 ( - &(ctx->m_hash), ctx->m_opad, RTL_DIGEST_LENGTH_SHA1); - } - else - { - /* Initialize 'opad' with plain 'KeyData' */ - rtl_copyMemory (ctx->m_opad, pKeyData, nKeyLen); - } - - __rtl_digest_ipadHMAC_SHA1 (ctx); - __rtl_digest_opadHMAC_SHA1 (ctx); - - return rtl_Digest_E_None; -} - -/* - * rtl_digest_updateHMAC_SHA1. - */ -rtlDigestError SAL_CALL rtl_digest_updateHMAC_SHA1 ( - rtlDigest Digest, const void *pData, sal_uInt32 nDatLen) -{ - DigestHMAC_SHA1_Impl *pImpl = (DigestHMAC_SHA1_Impl*)Digest; - ContextHMAC_SHA1 *ctx; - - if ((pImpl == NULL) || (pData == NULL)) - return rtl_Digest_E_Argument; - - if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmHMAC_SHA1)) - return rtl_Digest_E_Algorithm; - - ctx = &(pImpl->m_context); - rtl_digest_updateSHA1 (&(ctx->m_hash), pData, nDatLen); - - return rtl_Digest_E_None; -} - -/* - * rtl_digest_getHMAC_SHA1. - */ -rtlDigestError SAL_CALL rtl_digest_getHMAC_SHA1 ( - rtlDigest Digest, sal_uInt8 *pBuffer, sal_uInt32 nBufLen) -{ - DigestHMAC_SHA1_Impl *pImpl = (DigestHMAC_SHA1_Impl*)Digest; - ContextHMAC_SHA1 *ctx; - - if ((pImpl == NULL) || (pBuffer == NULL)) - return rtl_Digest_E_Argument; - - if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmHMAC_SHA1)) - return rtl_Digest_E_Algorithm; - - if (!(pImpl->m_digest.m_length <= nBufLen)) - return rtl_Digest_E_BufferSize; - - nBufLen = pImpl->m_digest.m_length; - - ctx = &(pImpl->m_context); - rtl_digest_getSHA1 (&(ctx->m_hash), pBuffer, nBufLen); - - rtl_digest_updateSHA1 (&(ctx->m_hash), ctx->m_opad, sizeof(ctx->m_opad)); - rtl_digest_updateSHA1 (&(ctx->m_hash), pBuffer, nBufLen); - rtl_digest_getSHA1 (&(ctx->m_hash), pBuffer, nBufLen); - - __rtl_digest_opadHMAC_SHA1 (ctx); - __rtl_digest_ipadHMAC_SHA1 (ctx); - __rtl_digest_opadHMAC_SHA1 (ctx); - - return rtl_Digest_E_None; -} - -/* - * rtl_digest_destroyHMAC_SHA1. - */ -void SAL_CALL rtl_digest_destroyHMAC_SHA1 (rtlDigest Digest) -{ - DigestHMAC_SHA1_Impl *pImpl = (DigestHMAC_SHA1_Impl*)Digest; - if (pImpl) - { - if (pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmHMAC_SHA1) - rtl_freeZeroMemory (pImpl, sizeof (DigestHMAC_SHA1_Impl)); - else - rtl_freeMemory (pImpl); - } -} - -/*======================================================================== - * - * rtl_digest_PBKDF2 internals. - * - *======================================================================*/ -#define DIGEST_CBLOCK_PBKDF2 RTL_DIGEST_LENGTH_HMAC_SHA1 - -/* - * __rtl_digest_updatePBKDF2. - */ -static void __rtl_digest_updatePBKDF2 ( - rtlDigest hDigest, - sal_uInt8 T[DIGEST_CBLOCK_PBKDF2], - const sal_uInt8 *pSaltData, sal_uInt32 nSaltLen, - sal_uInt32 nCount, sal_uInt32 nIndex) -{ - /* T_i = F (P, S, c, i) */ - sal_uInt8 U[DIGEST_CBLOCK_PBKDF2]; - register sal_uInt32 i, k; - - /* U_(1) = PRF (P, S || INDEX) */ - rtl_digest_updateHMAC_SHA1 (hDigest, pSaltData, nSaltLen); - rtl_digest_updateHMAC_SHA1 (hDigest, &nIndex, sizeof(nIndex)); - rtl_digest_getHMAC_SHA1 (hDigest, U, DIGEST_CBLOCK_PBKDF2); - - /* T = U_(1) */ - for (k = 0; k < DIGEST_CBLOCK_PBKDF2; k++) T[k] = U[k]; - - /* T ^= U_(2) ^ ... ^ U_(c) */ - for (i = 1; i < nCount; i++) - { - /* U_(i) = PRF (P, U_(i-1)) */ - rtl_digest_updateHMAC_SHA1 (hDigest, U, DIGEST_CBLOCK_PBKDF2); - rtl_digest_getHMAC_SHA1 (hDigest, U, DIGEST_CBLOCK_PBKDF2); - - /* T ^= U_(i) */ - for (k = 0; k < DIGEST_CBLOCK_PBKDF2; k++) T[k] ^= U[k]; - } - - rtl_zeroMemory (U, DIGEST_CBLOCK_PBKDF2); -} - -/*======================================================================== - * - * rtl_digest_PBKDF2 implementation. - * - *======================================================================*/ -/* - * rtl_digest_PBKDF2. - */ -rtlDigestError SAL_CALL rtl_digest_PBKDF2 ( - sal_uInt8 *pKeyData , sal_uInt32 nKeyLen, - const sal_uInt8 *pPassData, sal_uInt32 nPassLen, - const sal_uInt8 *pSaltData, sal_uInt32 nSaltLen, - sal_uInt32 nCount) -{ - DigestHMAC_SHA1_Impl digest; - sal_uInt32 i = 1; - - if ((pKeyData == NULL) || (pPassData == NULL) || (pSaltData == NULL)) - return rtl_Digest_E_Argument; - - digest.m_digest = __rtl_digest_HMAC_SHA1; - rtl_digest_initHMAC_SHA1 (&digest, pPassData, nPassLen); - - /* DK = T_(1) || T_(2) || ... || T_(l) */ - while (nKeyLen >= DIGEST_CBLOCK_PBKDF2) - { - /* T_(i) = F (P, S, c, i); DK ||= T_(i) */ - __rtl_digest_updatePBKDF2 ( - &digest, pKeyData, - pSaltData, nSaltLen, - nCount, OSL_NETDWORD(i)); - - /* Next 'KeyData' block */ - pKeyData += DIGEST_CBLOCK_PBKDF2; - nKeyLen -= DIGEST_CBLOCK_PBKDF2; - i += 1; - } - if (nKeyLen > 0) - { - /* Last 'KeyData' block */ - sal_uInt8 T[DIGEST_CBLOCK_PBKDF2]; - - /* T_i = F (P, S, c, i) */ - __rtl_digest_updatePBKDF2 ( - &digest, T, - pSaltData, nSaltLen, - nCount, OSL_NETDWORD(i)); - - /* DK ||= T_(i) */ - rtl_copyMemory (pKeyData, T, nKeyLen); - rtl_zeroMemory (T, DIGEST_CBLOCK_PBKDF2); - } - - rtl_zeroMemory (&digest, sizeof (digest)); - return rtl_Digest_E_None; -} - -/*======================================================================== - * - * The End. - * - *======================================================================*/ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/digest.cxx b/sal/rtl/source/digest.cxx new file mode 100644 index 000000000000..28655858d425 --- /dev/null +++ b/sal/rtl/source/digest.cxx @@ -0,0 +1,2143 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#define _RTL_DIGEST_C_ + +#include +#include +#include +#include +#include +#include + +/*======================================================================== + * + * rtlDigest internals. + * + *======================================================================*/ +#define RTL_DIGEST_CREATE(T) ((T*)(rtl_allocateZeroMemory(sizeof(T)))) + +#define RTL_DIGEST_ROTL(a,n) (((a) << (n)) | ((a) >> (32 - (n)))) + +#define RTL_DIGEST_HTONL(l,c) \ + (*((c)++) = (sal_uInt8)(((l) >> 24L) & 0xff), \ + *((c)++) = (sal_uInt8)(((l) >> 16L) & 0xff), \ + *((c)++) = (sal_uInt8)(((l) >> 8L) & 0xff), \ + *((c)++) = (sal_uInt8)(((l) ) & 0xff)) + +#define RTL_DIGEST_LTOC(l,c) \ + (*((c)++) = (sal_uInt8)(((l) ) & 0xff), \ + *((c)++) = (sal_uInt8)(((l) >> 8L) & 0xff), \ + *((c)++) = (sal_uInt8)(((l) >> 16L) & 0xff), \ + *((c)++) = (sal_uInt8)(((l) >> 24L) & 0xff)) + +typedef rtlDigestError (SAL_CALL Digest_init_t) ( + void *ctx, const sal_uInt8 *Data, sal_uInt32 DatLen); + +typedef void (SAL_CALL Digest_delete_t) (void *ctx); + +typedef rtlDigestError (SAL_CALL Digest_update_t) ( + void *ctx, const void *Data, sal_uInt32 DatLen); + +typedef rtlDigestError (SAL_CALL Digest_get_t) ( + void *ctx, sal_uInt8 *Buffer, sal_uInt32 BufLen); + +struct Digest_Impl +{ + rtlDigestAlgorithm m_algorithm; + sal_uInt32 m_length; + + Digest_init_t *m_init; + Digest_delete_t *m_delete; + Digest_update_t *m_update; + Digest_get_t *m_get; +}; + +/* + * __rtl_digest_swapLong. + */ +static void __rtl_digest_swapLong (sal_uInt32 *pData, sal_uInt32 nDatLen) +{ + register sal_uInt32 *X; + register int i, n; + + X = pData; + n = nDatLen; + + for (i = 0; i < n; i++) + X[i] = OSL_SWAPDWORD(X[i]); +} + +/*======================================================================== + * + * rtlDigest implementation. + * + *======================================================================*/ +/* + * rtl_digest_create. + */ +rtlDigest SAL_CALL rtl_digest_create (rtlDigestAlgorithm Algorithm) + SAL_THROW_EXTERN_C() +{ + rtlDigest Digest = (rtlDigest)NULL; + switch (Algorithm) + { + case rtl_Digest_AlgorithmMD2: + Digest = rtl_digest_createMD2(); + break; + + case rtl_Digest_AlgorithmMD5: + Digest = rtl_digest_createMD5(); + break; + + case rtl_Digest_AlgorithmSHA: + Digest = rtl_digest_createSHA(); + break; + + case rtl_Digest_AlgorithmSHA1: + Digest = rtl_digest_createSHA1(); + break; + + case rtl_Digest_AlgorithmHMAC_MD5: + Digest = rtl_digest_createHMAC_MD5(); + break; + + case rtl_Digest_AlgorithmHMAC_SHA1: + Digest = rtl_digest_createHMAC_SHA1(); + break; + + default: /* rtl_Digest_AlgorithmInvalid */ + break; + } + return Digest; +} + +/* + * rtl_digest_queryAlgorithm. + */ +rtlDigestAlgorithm SAL_CALL rtl_digest_queryAlgorithm (rtlDigest Digest) + SAL_THROW_EXTERN_C() +{ + Digest_Impl *pImpl = (Digest_Impl *)Digest; + if (pImpl) + return pImpl->m_algorithm; + else + return rtl_Digest_AlgorithmInvalid; +} + +/* + * rtl_digest_queryLength. + */ +sal_uInt32 SAL_CALL rtl_digest_queryLength (rtlDigest Digest) + SAL_THROW_EXTERN_C() +{ + Digest_Impl *pImpl = (Digest_Impl *)Digest; + if (pImpl) + return pImpl->m_length; + else + return 0; +} + +/* + * rtl_digest_init. + */ +rtlDigestError SAL_CALL rtl_digest_init ( + rtlDigest Digest, const sal_uInt8 *pData, sal_uInt32 nDatLen) + SAL_THROW_EXTERN_C() +{ + Digest_Impl *pImpl = (Digest_Impl *)Digest; + if (pImpl) + { + if (pImpl->m_init) + return pImpl->m_init (Digest, pData, nDatLen); + else + return rtl_Digest_E_None; + } + return rtl_Digest_E_Argument; +} + +/* + * rtl_digest_update. + */ +rtlDigestError SAL_CALL rtl_digest_update ( + rtlDigest Digest, const void *pData, sal_uInt32 nDatLen) + SAL_THROW_EXTERN_C() +{ + Digest_Impl *pImpl = (Digest_Impl *)Digest; + if (pImpl && pImpl->m_update) + return pImpl->m_update (Digest, pData, nDatLen); + else + return rtl_Digest_E_Argument; +} + +/* + * rtl_digest_get. + */ +rtlDigestError SAL_CALL rtl_digest_get ( + rtlDigest Digest, sal_uInt8 *pBuffer, sal_uInt32 nBufLen) + SAL_THROW_EXTERN_C() +{ + Digest_Impl *pImpl = (Digest_Impl *)Digest; + if (pImpl && pImpl->m_get) + return pImpl->m_get (Digest, pBuffer, nBufLen); + else + return rtl_Digest_E_Argument; +} + +/* + * rtl_digest_destroy. + */ +void SAL_CALL rtl_digest_destroy (rtlDigest Digest) SAL_THROW_EXTERN_C() +{ + Digest_Impl *pImpl = (Digest_Impl *)Digest; + if (pImpl && pImpl->m_delete) + pImpl->m_delete (Digest); +} + +/*======================================================================== + * + * rtl_digest_MD2 internals. + * + *======================================================================*/ +#define DIGEST_CBLOCK_MD2 16 +#define DIGEST_LBLOCK_MD2 16 + +struct DigestContextMD2 +{ + sal_uInt32 m_nDatLen; + sal_uInt8 m_pData[DIGEST_CBLOCK_MD2]; + sal_uInt32 m_state[DIGEST_LBLOCK_MD2]; + sal_uInt32 m_chksum[DIGEST_LBLOCK_MD2]; +}; + +struct DigestMD2_Impl +{ + Digest_Impl m_digest; + DigestContextMD2 m_context; +}; + +static void __rtl_digest_initMD2 (DigestContextMD2 *ctx); +static void __rtl_digest_updateMD2 (DigestContextMD2 *ctx); +static void __rtl_digest_endMD2 (DigestContextMD2 *ctx); + +static const sal_uInt32 S[256] = +{ + 0x29, 0x2E, 0x43, 0xC9, 0xA2, 0xD8, 0x7C, 0x01, + 0x3D, 0x36, 0x54, 0xA1, 0xEC, 0xF0, 0x06, 0x13, + 0x62, 0xA7, 0x05, 0xF3, 0xC0, 0xC7, 0x73, 0x8C, + 0x98, 0x93, 0x2B, 0xD9, 0xBC, 0x4C, 0x82, 0xCA, + 0x1E, 0x9B, 0x57, 0x3C, 0xFD, 0xD4, 0xE0, 0x16, + 0x67, 0x42, 0x6F, 0x18, 0x8A, 0x17, 0xE5, 0x12, + 0xBE, 0x4E, 0xC4, 0xD6, 0xDA, 0x9E, 0xDE, 0x49, + 0xA0, 0xFB, 0xF5, 0x8E, 0xBB, 0x2F, 0xEE, 0x7A, + 0xA9, 0x68, 0x79, 0x91, 0x15, 0xB2, 0x07, 0x3F, + 0x94, 0xC2, 0x10, 0x89, 0x0B, 0x22, 0x5F, 0x21, + 0x80, 0x7F, 0x5D, 0x9A, 0x5A, 0x90, 0x32, 0x27, + 0x35, 0x3E, 0xCC, 0xE7, 0xBF, 0xF7, 0x97, 0x03, + 0xFF, 0x19, 0x30, 0xB3, 0x48, 0xA5, 0xB5, 0xD1, + 0xD7, 0x5E, 0x92, 0x2A, 0xAC, 0x56, 0xAA, 0xC6, + 0x4F, 0xB8, 0x38, 0xD2, 0x96, 0xA4, 0x7D, 0xB6, + 0x76, 0xFC, 0x6B, 0xE2, 0x9C, 0x74, 0x04, 0xF1, + 0x45, 0x9D, 0x70, 0x59, 0x64, 0x71, 0x87, 0x20, + 0x86, 0x5B, 0xCF, 0x65, 0xE6, 0x2D, 0xA8, 0x02, + 0x1B, 0x60, 0x25, 0xAD, 0xAE, 0xB0, 0xB9, 0xF6, + 0x1C, 0x46, 0x61, 0x69, 0x34, 0x40, 0x7E, 0x0F, + 0x55, 0x47, 0xA3, 0x23, 0xDD, 0x51, 0xAF, 0x3A, + 0xC3, 0x5C, 0xF9, 0xCE, 0xBA, 0xC5, 0xEA, 0x26, + 0x2C, 0x53, 0x0D, 0x6E, 0x85, 0x28, 0x84, 0x09, + 0xD3, 0xDF, 0xCD, 0xF4, 0x41, 0x81, 0x4D, 0x52, + 0x6A, 0xDC, 0x37, 0xC8, 0x6C, 0xC1, 0xAB, 0xFA, + 0x24, 0xE1, 0x7B, 0x08, 0x0C, 0xBD, 0xB1, 0x4A, + 0x78, 0x88, 0x95, 0x8B, 0xE3, 0x63, 0xE8, 0x6D, + 0xE9, 0xCB, 0xD5, 0xFE, 0x3B, 0x00, 0x1D, 0x39, + 0xF2, 0xEF, 0xB7, 0x0E, 0x66, 0x58, 0xD0, 0xE4, + 0xA6, 0x77, 0x72, 0xF8, 0xEB, 0x75, 0x4B, 0x0A, + 0x31, 0x44, 0x50, 0xB4, 0x8F, 0xED, 0x1F, 0x1A, + 0xDB, 0x99, 0x8D, 0x33, 0x9F, 0x11, 0x83, 0x14, +}; + +/* + * __rtl_digest_MD2. + */ +static const Digest_Impl __rtl_digest_MD2 = +{ + rtl_Digest_AlgorithmMD2, + RTL_DIGEST_LENGTH_MD2, + + NULL, + rtl_digest_destroyMD2, + rtl_digest_updateMD2, + rtl_digest_getMD2 +}; + +/* + * __rtl_digest_initMD2. + */ +static void __rtl_digest_initMD2 (DigestContextMD2 *ctx) +{ + rtl_zeroMemory (ctx, sizeof (DigestContextMD2)); +} + +/* + * __rtl_digest_updateMD2. + */ +static void __rtl_digest_updateMD2 (DigestContextMD2 *ctx) +{ + register sal_uInt8 *X; + register sal_uInt32 *sp1, *sp2; + register sal_uInt32 i, k, t; + + sal_uInt32 state[48]; + + X = ctx->m_pData; + sp1 = ctx->m_state; + sp2 = ctx->m_chksum; + + k = sp2[DIGEST_LBLOCK_MD2 - 1]; + for (i = 0; i < 16; i++) + { + state[i + 0] = sp1[i]; + state[i + 16] = t = X[i]; + state[i + 32] = t ^ sp1[i]; + k = sp2[i] ^= S[t^k]; + } + + t = 0; + for (i = 0; i < 18; i++) + { + for (k = 0; k < 48; k += 8) + { + t = state[k + 0] ^= S[t]; + t = state[k + 1] ^= S[t]; + t = state[k + 2] ^= S[t]; + t = state[k + 3] ^= S[t]; + t = state[k + 4] ^= S[t]; + t = state[k + 5] ^= S[t]; + t = state[k + 6] ^= S[t]; + t = state[k + 7] ^= S[t]; + } + t = ((t + i) & 0xff); + } + + rtl_copyMemory (sp1, state, 16 * sizeof(sal_uInt32)); + rtl_zeroMemory (state, 48 * sizeof(sal_uInt32)); +} + +/* + * __rtl_digest_endMD2. + */ +static void __rtl_digest_endMD2 (DigestContextMD2 *ctx) +{ + register sal_uInt8 *X; + register sal_uInt32 *C; + sal_uInt32 i, n; + + X = ctx->m_pData; + C = ctx->m_chksum; + n = DIGEST_CBLOCK_MD2 - ctx->m_nDatLen; + + for (i = ctx->m_nDatLen; i < DIGEST_CBLOCK_MD2; i++) + X[i] = (sal_uInt8)(n & 0xff); + __rtl_digest_updateMD2 (ctx); + + for (i = 0; i < DIGEST_CBLOCK_MD2; i++) + X[i] = (sal_uInt8)(C[i] & 0xff); + __rtl_digest_updateMD2 (ctx); +} + +/*======================================================================== + * + * rtl_digest_MD2 implementation. + * + *======================================================================*/ +/* + * rtl_digest_MD2. + */ +rtlDigestError SAL_CALL rtl_digest_MD2 ( + const void *pData, sal_uInt32 nDatLen, + sal_uInt8 *pBuffer, sal_uInt32 nBufLen) SAL_THROW_EXTERN_C() +{ + DigestMD2_Impl digest; + rtlDigestError result; + + digest.m_digest = __rtl_digest_MD2; + __rtl_digest_initMD2 (&(digest.m_context)); + + result = rtl_digest_updateMD2 (&digest, pData, nDatLen); + if (result == rtl_Digest_E_None) + result = rtl_digest_getMD2 (&digest, pBuffer, nBufLen); + + rtl_zeroMemory (&digest, sizeof (digest)); + return (result); +} + +/* + * rtl_digest_createMD2. + */ +rtlDigest SAL_CALL rtl_digest_createMD2() SAL_THROW_EXTERN_C() +{ + DigestMD2_Impl *pImpl = (DigestMD2_Impl*)NULL; + pImpl = RTL_DIGEST_CREATE(DigestMD2_Impl); + if (pImpl) + { + pImpl->m_digest = __rtl_digest_MD2; + __rtl_digest_initMD2 (&(pImpl->m_context)); + } + return ((rtlDigest)pImpl); +} + +/* + * rtl_digest_updateMD2. + */ +rtlDigestError SAL_CALL rtl_digest_updateMD2 ( + rtlDigest Digest, const void *pData, sal_uInt32 nDatLen) + SAL_THROW_EXTERN_C() +{ + DigestMD2_Impl *pImpl = (DigestMD2_Impl *)Digest; + const sal_uInt8 *d = (const sal_uInt8 *)pData; + + DigestContextMD2 *ctx; + + if ((pImpl == NULL) || (pData == NULL)) + return rtl_Digest_E_Argument; + + if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmMD2)) + return rtl_Digest_E_Algorithm; + + if (nDatLen == 0) + return rtl_Digest_E_None; + + ctx = &(pImpl->m_context); + + if (ctx->m_nDatLen) + { + sal_uInt8 *p = ctx->m_pData + ctx->m_nDatLen; + sal_uInt32 n = DIGEST_CBLOCK_MD2 - ctx->m_nDatLen; + + if (nDatLen < n) + { + rtl_copyMemory (p, d, nDatLen); + ctx->m_nDatLen += nDatLen; + + return rtl_Digest_E_None; + } + + rtl_copyMemory (p, d, n); + d += n; + nDatLen -= n; + + __rtl_digest_updateMD2 (ctx); + ctx->m_nDatLen = 0; + } + + while (nDatLen >= DIGEST_CBLOCK_MD2) + { + rtl_copyMemory (ctx->m_pData, d, DIGEST_CBLOCK_MD2); + d += DIGEST_CBLOCK_MD2; + nDatLen -= DIGEST_CBLOCK_MD2; + + __rtl_digest_updateMD2 (ctx); + } + + rtl_copyMemory (ctx->m_pData, d, nDatLen); + ctx->m_nDatLen = nDatLen; + + return rtl_Digest_E_None; +} + +/* + * rtl_digest_getMD2. + */ +rtlDigestError SAL_CALL rtl_digest_getMD2 ( + rtlDigest Digest, sal_uInt8 *pBuffer, sal_uInt32 nBufLen) + SAL_THROW_EXTERN_C() +{ + DigestMD2_Impl *pImpl = (DigestMD2_Impl *)Digest; + sal_uInt32 i; + + DigestContextMD2 *ctx; + + if ((pImpl == NULL) || (pBuffer == NULL)) + return rtl_Digest_E_Argument; + + if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmMD2)) + return rtl_Digest_E_Algorithm; + + if (!(pImpl->m_digest.m_length <= nBufLen)) + return rtl_Digest_E_BufferSize; + + ctx = &(pImpl->m_context); + + __rtl_digest_endMD2 (ctx); + for (i = 0; i < DIGEST_CBLOCK_MD2; i++) + pBuffer[i] = (sal_uInt8)(ctx->m_state[i] & 0xff); + __rtl_digest_initMD2 (ctx); + + return rtl_Digest_E_None; +} + +/* + * rtl_digest_destroyMD2. + */ +void SAL_CALL rtl_digest_destroyMD2 (rtlDigest Digest) SAL_THROW_EXTERN_C() +{ + DigestMD2_Impl *pImpl = (DigestMD2_Impl *)Digest; + if (pImpl) + { + if (pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmMD2) + rtl_freeZeroMemory (pImpl, sizeof (DigestMD2_Impl)); + else + rtl_freeMemory (pImpl); + } +} + +/*======================================================================== + * + * rtl_digest_MD5 internals. + * + *======================================================================*/ +#define DIGEST_CBLOCK_MD5 64 +#define DIGEST_LBLOCK_MD5 16 + +struct DigestContextMD5 +{ + sal_uInt32 m_nDatLen; + sal_uInt32 m_pData[DIGEST_LBLOCK_MD5]; + sal_uInt32 m_nA, m_nB, m_nC, m_nD; + sal_uInt32 m_nL, m_nH; +}; + +struct DigestMD5_Impl +{ + Digest_Impl m_digest; + DigestContextMD5 m_context; +}; + +static void __rtl_digest_initMD5 (DigestContextMD5 *ctx); +static void __rtl_digest_updateMD5 (DigestContextMD5 *ctx); +static void __rtl_digest_endMD5 (DigestContextMD5 *ctx); + +#define F(x,y,z) ((((y) ^ (z)) & (x)) ^ (z)) +#define G(x,y,z) ((((x) ^ (y)) & (z)) ^ (y)) +#define H(x,y,z) ((x) ^ (y) ^ (z)) +#define I(x,y,z) (((x) | (~(z))) ^ (y)) + +#define R0(a,b,c,d,k,s,t) { \ + a += ((k) + (t) + F((b), (c), (d))); \ + a = RTL_DIGEST_ROTL(a, s); \ + a += b; } + +#define R1(a,b,c,d,k,s,t) { \ + a += ((k) + (t) + G((b), (c), (d))); \ + a = RTL_DIGEST_ROTL(a, s); \ + a += b; } + +#define R2(a,b,c,d,k,s,t) { \ + a += ((k) + (t) + H((b), (c), (d))); \ + a = RTL_DIGEST_ROTL(a, s); \ + a += b; } + +#define R3(a,b,c,d,k,s,t) { \ + a += ((k) + (t) + I((b), (c), (d))); \ + a = RTL_DIGEST_ROTL(a, s); \ + a += b; } + +/* + * __rtl_digest_MD5. + */ +static const Digest_Impl __rtl_digest_MD5 = +{ + rtl_Digest_AlgorithmMD5, + RTL_DIGEST_LENGTH_MD5, + + NULL, + rtl_digest_destroyMD5, + rtl_digest_updateMD5, + rtl_digest_getMD5 +}; + +/* + * __rtl_digest_initMD5. + */ +static void __rtl_digest_initMD5 (DigestContextMD5 *ctx) +{ + rtl_zeroMemory (ctx, sizeof (DigestContextMD5)); + + ctx->m_nA = (sal_uInt32)0x67452301L; + ctx->m_nB = (sal_uInt32)0xefcdab89L; + ctx->m_nC = (sal_uInt32)0x98badcfeL; + ctx->m_nD = (sal_uInt32)0x10325476L; +} + +/* + * __rtl_digest_updateMD5. + */ +static void __rtl_digest_updateMD5 (DigestContextMD5 *ctx) +{ + register sal_uInt32 A, B, C, D; + register sal_uInt32 *X; + + A = ctx->m_nA; + B = ctx->m_nB; + C = ctx->m_nC; + D = ctx->m_nD; + X = ctx->m_pData; + + R0 (A, B, C, D, X[ 0], 7, 0xd76aa478L); + R0 (D, A, B, C, X[ 1], 12, 0xe8c7b756L); + R0 (C, D, A, B, X[ 2], 17, 0x242070dbL); + R0 (B, C, D, A, X[ 3], 22, 0xc1bdceeeL); + R0 (A, B, C, D, X[ 4], 7, 0xf57c0fafL); + R0 (D, A, B, C, X[ 5], 12, 0x4787c62aL); + R0 (C, D, A, B, X[ 6], 17, 0xa8304613L); + R0 (B, C, D, A, X[ 7], 22, 0xfd469501L); + R0 (A, B, C, D, X[ 8], 7, 0x698098d8L); + R0 (D, A, B, C, X[ 9], 12, 0x8b44f7afL); + R0 (C, D, A, B, X[10], 17, 0xffff5bb1L); + R0 (B, C, D, A, X[11], 22, 0x895cd7beL); + R0 (A, B, C, D, X[12], 7, 0x6b901122L); + R0 (D, A, B, C, X[13], 12, 0xfd987193L); + R0 (C, D, A, B, X[14], 17, 0xa679438eL); + R0 (B, C, D, A, X[15], 22, 0x49b40821L); + + R1 (A, B, C, D, X[ 1], 5, 0xf61e2562L); + R1 (D, A, B, C, X[ 6], 9, 0xc040b340L); + R1 (C, D, A, B, X[11], 14, 0x265e5a51L); + R1 (B, C, D, A, X[ 0], 20, 0xe9b6c7aaL); + R1 (A, B, C, D, X[ 5], 5, 0xd62f105dL); + R1 (D, A, B, C, X[10], 9, 0x02441453L); + R1 (C, D, A, B, X[15], 14, 0xd8a1e681L); + R1 (B, C, D, A, X[ 4], 20, 0xe7d3fbc8L); + R1 (A, B, C, D, X[ 9], 5, 0x21e1cde6L); + R1 (D, A, B, C, X[14], 9, 0xc33707d6L); + R1 (C, D, A, B, X[ 3], 14, 0xf4d50d87L); + R1 (B, C, D, A, X[ 8], 20, 0x455a14edL); + R1 (A, B, C, D, X[13], 5, 0xa9e3e905L); + R1 (D, A, B, C, X[ 2], 9, 0xfcefa3f8L); + R1 (C, D, A, B, X[ 7], 14, 0x676f02d9L); + R1 (B, C, D, A, X[12], 20, 0x8d2a4c8aL); + + R2 (A, B, C, D, X[ 5], 4, 0xfffa3942L); + R2 (D, A, B, C, X[ 8], 11, 0x8771f681L); + R2 (C, D, A, B, X[11], 16, 0x6d9d6122L); + R2 (B, C, D, A, X[14], 23, 0xfde5380cL); + R2 (A, B, C, D, X[ 1], 4, 0xa4beea44L); + R2 (D, A, B, C, X[ 4], 11, 0x4bdecfa9L); + R2 (C, D, A, B, X[ 7], 16, 0xf6bb4b60L); + R2 (B, C, D, A, X[10], 23, 0xbebfbc70L); + R2 (A, B, C, D, X[13], 4, 0x289b7ec6L); + R2 (D, A, B, C, X[ 0], 11, 0xeaa127faL); + R2 (C, D, A, B, X[ 3], 16, 0xd4ef3085L); + R2 (B, C, D, A, X[ 6], 23, 0x04881d05L); + R2 (A, B, C, D, X[ 9], 4, 0xd9d4d039L); + R2 (D, A, B, C, X[12], 11, 0xe6db99e5L); + R2 (C, D, A, B, X[15], 16, 0x1fa27cf8L); + R2 (B, C, D, A, X[ 2], 23, 0xc4ac5665L); + + R3 (A, B, C, D, X[ 0], 6, 0xf4292244L); + R3 (D, A, B, C, X[ 7], 10, 0x432aff97L); + R3 (C, D, A, B, X[14], 15, 0xab9423a7L); + R3 (B, C, D, A, X[ 5], 21, 0xfc93a039L); + R3 (A, B, C, D, X[12], 6, 0x655b59c3L); + R3 (D, A, B, C, X[ 3], 10, 0x8f0ccc92L); + R3 (C, D, A, B, X[10], 15, 0xffeff47dL); + R3 (B, C, D, A, X[ 1], 21, 0x85845dd1L); + R3 (A, B, C, D, X[ 8], 6, 0x6fa87e4fL); + R3 (D, A, B, C, X[15], 10, 0xfe2ce6e0L); + R3 (C, D, A, B, X[ 6], 15, 0xa3014314L); + R3 (B, C, D, A, X[13], 21, 0x4e0811a1L); + R3 (A, B, C, D, X[ 4], 6, 0xf7537e82L); + R3 (D, A, B, C, X[11], 10, 0xbd3af235L); + R3 (C, D, A, B, X[ 2], 15, 0x2ad7d2bbL); + R3 (B, C, D, A, X[ 9], 21, 0xeb86d391L); + + ctx->m_nA += A; + ctx->m_nB += B; + ctx->m_nC += C; + ctx->m_nD += D; +} + +/* + * __rtl_digest_endMD5. + */ +static void __rtl_digest_endMD5 (DigestContextMD5 *ctx) +{ + static const sal_uInt8 end[4] = + { + 0x80, 0x00, 0x00, 0x00 + }; + register const sal_uInt8 *p = end; + + register sal_uInt32 *X; + register int i; + + X = ctx->m_pData; + i = (ctx->m_nDatLen >> 2); + +#ifdef OSL_BIGENDIAN + __rtl_digest_swapLong (X, i + 1); +#endif /* OSL_BIGENDIAN */ + + switch (ctx->m_nDatLen & 0x03) + { + case 1: X[i] &= 0x000000ff; break; + case 2: X[i] &= 0x0000ffff; break; + case 3: X[i] &= 0x00ffffff; break; + } + + switch (ctx->m_nDatLen & 0x03) + { + case 0: X[i] = ((sal_uInt32)(*(p++))) << 0L; + case 1: X[i] |= ((sal_uInt32)(*(p++))) << 8L; + case 2: X[i] |= ((sal_uInt32)(*(p++))) << 16L; + case 3: X[i] |= ((sal_uInt32)(*p)) << 24L; + } + + i += 1; + + if (i >= (DIGEST_LBLOCK_MD5 - 2)) + { + for (; i < DIGEST_LBLOCK_MD5; i++) + X[i] = 0; + __rtl_digest_updateMD5 (ctx); + i = 0; + } + + for (; i < (DIGEST_LBLOCK_MD5 - 2); i++) + X[i] = 0; + + X[DIGEST_LBLOCK_MD5 - 2] = ctx->m_nL; + X[DIGEST_LBLOCK_MD5 - 1] = ctx->m_nH; + + __rtl_digest_updateMD5 (ctx); +} + +/*======================================================================== + * + * rtl_digest_MD5 implementation. + * + *======================================================================*/ +/* + * rtl_digest_MD5. + */ +rtlDigestError SAL_CALL rtl_digest_MD5 ( + const void *pData, sal_uInt32 nDatLen, + sal_uInt8 *pBuffer, sal_uInt32 nBufLen) SAL_THROW_EXTERN_C() +{ + DigestMD5_Impl digest; + rtlDigestError result; + + digest.m_digest = __rtl_digest_MD5; + __rtl_digest_initMD5 (&(digest.m_context)); + + result = rtl_digest_update (&digest, pData, nDatLen); + if (result == rtl_Digest_E_None) + result = rtl_digest_getMD5 (&digest, pBuffer, nBufLen); + + rtl_zeroMemory (&digest, sizeof (digest)); + return (result); +} + +/* + * rtl_digest_createMD5. + */ +rtlDigest SAL_CALL rtl_digest_createMD5() SAL_THROW_EXTERN_C() +{ + DigestMD5_Impl *pImpl = (DigestMD5_Impl*)NULL; + pImpl = RTL_DIGEST_CREATE(DigestMD5_Impl); + if (pImpl) + { + pImpl->m_digest = __rtl_digest_MD5; + __rtl_digest_initMD5 (&(pImpl->m_context)); + } + return ((rtlDigest)pImpl); +} + +/* + * rtl_digest_updateMD5. + */ +rtlDigestError SAL_CALL rtl_digest_updateMD5 ( + rtlDigest Digest, const void *pData, sal_uInt32 nDatLen) + SAL_THROW_EXTERN_C() +{ + DigestMD5_Impl *pImpl = (DigestMD5_Impl *)Digest; + const sal_uInt8 *d = (const sal_uInt8 *)pData; + + DigestContextMD5 *ctx; + sal_uInt32 len; + + if ((pImpl == NULL) || (pData == NULL)) + return rtl_Digest_E_Argument; + + if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmMD5)) + return rtl_Digest_E_Algorithm; + + if (nDatLen == 0) + return rtl_Digest_E_None; + + ctx = &(pImpl->m_context); + + len = ctx->m_nL + (nDatLen << 3); + if (len < ctx->m_nL) ctx->m_nH += 1; + ctx->m_nH += (nDatLen >> 29); + ctx->m_nL = len; + + if (ctx->m_nDatLen) + { + sal_uInt8 *p = (sal_uInt8 *)(ctx->m_pData) + ctx->m_nDatLen; + sal_uInt32 n = DIGEST_CBLOCK_MD5 - ctx->m_nDatLen; + + if (nDatLen < n) + { + rtl_copyMemory (p, d, nDatLen); + ctx->m_nDatLen += nDatLen; + + return rtl_Digest_E_None; + } + + rtl_copyMemory (p, d, n); + d += n; + nDatLen -= n; + +#ifdef OSL_BIGENDIAN + __rtl_digest_swapLong (ctx->m_pData, DIGEST_LBLOCK_MD5); +#endif /* OSL_BIGENDIAN */ + + __rtl_digest_updateMD5 (ctx); + ctx->m_nDatLen = 0; + } + + while (nDatLen >= DIGEST_CBLOCK_MD5) + { + rtl_copyMemory (ctx->m_pData, d, DIGEST_CBLOCK_MD5); + d += DIGEST_CBLOCK_MD5; + nDatLen -= DIGEST_CBLOCK_MD5; + +#ifdef OSL_BIGENDIAN + __rtl_digest_swapLong (ctx->m_pData, DIGEST_LBLOCK_MD5); +#endif /* OSL_BIGENDIAN */ + + __rtl_digest_updateMD5 (ctx); + } + + rtl_copyMemory (ctx->m_pData, d, nDatLen); + ctx->m_nDatLen = nDatLen; + + return rtl_Digest_E_None; +} + +/* + * rtl_digest_getMD5. + */ +rtlDigestError SAL_CALL rtl_digest_getMD5 ( + rtlDigest Digest, sal_uInt8 *pBuffer, sal_uInt32 nBufLen) + SAL_THROW_EXTERN_C() +{ + DigestMD5_Impl *pImpl = (DigestMD5_Impl *)Digest; + sal_uInt8 *p = pBuffer; + + DigestContextMD5 *ctx; + + if ((pImpl == NULL) || (pBuffer == NULL)) + return rtl_Digest_E_Argument; + + if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmMD5)) + return rtl_Digest_E_Algorithm; + + if (!(pImpl->m_digest.m_length <= nBufLen)) + return rtl_Digest_E_BufferSize; + + ctx = &(pImpl->m_context); + + __rtl_digest_endMD5 (ctx); + RTL_DIGEST_LTOC (ctx->m_nA, p); + RTL_DIGEST_LTOC (ctx->m_nB, p); + RTL_DIGEST_LTOC (ctx->m_nC, p); + RTL_DIGEST_LTOC (ctx->m_nD, p); + __rtl_digest_initMD5 (ctx); + + return rtl_Digest_E_None; +} + +/* + * rtl_digest_rawMD5. + */ +rtlDigestError SAL_CALL rtl_digest_rawMD5 ( + rtlDigest Digest, sal_uInt8 *pBuffer, sal_uInt32 nBufLen) + SAL_THROW_EXTERN_C() +{ + DigestMD5_Impl *pImpl = (DigestMD5_Impl *)Digest; + sal_uInt8 *p = pBuffer; + + DigestContextMD5 *ctx; + + if ((pImpl == NULL) || (pBuffer == NULL)) + return rtl_Digest_E_Argument; + + if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmMD5)) + return rtl_Digest_E_Algorithm; + + if (!(pImpl->m_digest.m_length <= nBufLen)) + return rtl_Digest_E_BufferSize; + + ctx = &(pImpl->m_context); + + /* __rtl_digest_endMD5 (ctx); *//* not finalized */ + RTL_DIGEST_LTOC (ctx->m_nA, p); + RTL_DIGEST_LTOC (ctx->m_nB, p); + RTL_DIGEST_LTOC (ctx->m_nC, p); + RTL_DIGEST_LTOC (ctx->m_nD, p); + __rtl_digest_initMD5 (ctx); + + return rtl_Digest_E_None; +} + +/* + * rtl_digest_destroyMD5. + */ +void SAL_CALL rtl_digest_destroyMD5 (rtlDigest Digest) SAL_THROW_EXTERN_C() +{ + DigestMD5_Impl *pImpl = (DigestMD5_Impl *)Digest; + if (pImpl) + { + if (pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmMD5) + rtl_freeZeroMemory (pImpl, sizeof (DigestMD5_Impl)); + else + rtl_freeMemory (pImpl); + } +} + +/*======================================================================== + * + * rtl_digest_(SHA|SHA1) common internals. + * + *======================================================================*/ +#define DIGEST_CBLOCK_SHA 64 +#define DIGEST_LBLOCK_SHA 16 + +typedef sal_uInt32 DigestSHA_update_t (sal_uInt32 x); + +static sal_uInt32 __rtl_digest_updateSHA_0 (sal_uInt32 x); +static sal_uInt32 __rtl_digest_updateSHA_1 (sal_uInt32 x); + +struct DigestContextSHA +{ + DigestSHA_update_t *m_update; + sal_uInt32 m_nDatLen; + sal_uInt32 m_pData[DIGEST_LBLOCK_SHA]; + sal_uInt32 m_nA, m_nB, m_nC, m_nD, m_nE; + sal_uInt32 m_nL, m_nH; +}; + +struct DigestSHA_Impl +{ + Digest_Impl m_digest; + DigestContextSHA m_context; +}; + +static void __rtl_digest_initSHA ( + DigestContextSHA *ctx, DigestSHA_update_t *fct); + +static void __rtl_digest_updateSHA (DigestContextSHA *ctx); +static void __rtl_digest_endSHA (DigestContextSHA *ctx); + +#define K_00_19 (sal_uInt32)0x5a827999L +#define K_20_39 (sal_uInt32)0x6ed9eba1L +#define K_40_59 (sal_uInt32)0x8f1bbcdcL +#define K_60_79 (sal_uInt32)0xca62c1d6L + +#define F_00_19(b,c,d) ((((c) ^ (d)) & (b)) ^ (d)) +#define F_20_39(b,c,d) ((b) ^ (c) ^ (d)) +#define F_40_59(b,c,d) (((b) & (c)) | ((b) & (d)) | ((c) & (d))) +#define F_60_79(b,c,d) F_20_39(b,c,d) + +#define BODY_X(i) \ + (X[(i)&0x0f] ^ X[((i)+2)&0x0f] ^ X[((i)+8)&0x0f] ^ X[((i)+13)&0x0f]) + +#define BODY_00_15(u,i,a,b,c,d,e,f) \ + (f) = X[i]; \ + (f) += (e) + K_00_19 + RTL_DIGEST_ROTL((a), 5) + F_00_19((b), (c), (d)); \ + (b) = RTL_DIGEST_ROTL((b), 30); + +#define BODY_16_19(u,i,a,b,c,d,e,f) \ + (f) = BODY_X((i)); \ + (f) = X[(i)&0x0f] = (u)((f)); \ + (f) += (e) + K_00_19 + RTL_DIGEST_ROTL((a), 5) + F_00_19((b), (c), (d)); \ + (b) = RTL_DIGEST_ROTL((b), 30); + +#define BODY_20_39(u,i,a,b,c,d,e,f) \ + (f) = BODY_X((i)); \ + (f) = X[(i)&0x0f] = (u)((f)); \ + (f) += (e) + K_20_39 + RTL_DIGEST_ROTL((a), 5) + F_20_39((b), (c), (d)); \ + (b) = RTL_DIGEST_ROTL((b), 30); + +#define BODY_40_59(u,i,a,b,c,d,e,f) \ + (f) = BODY_X((i)); \ + (f) = X[(i)&0x0f] = (u)((f)); \ + (f) += (e) + K_40_59 + RTL_DIGEST_ROTL((a), 5) + F_40_59((b), (c), (d)); \ + (b) = RTL_DIGEST_ROTL((b), 30); + +#define BODY_60_79(u,i,a,b,c,d,e,f) \ + (f) = BODY_X((i)); \ + (f) = X[(i)&0x0f] = (u)((f)); \ + (f) += (e) + K_60_79 + RTL_DIGEST_ROTL((a), 5) + F_60_79((b), (c), (d)); \ + (b) = RTL_DIGEST_ROTL((b), 30); + +/* + * __rtl_digest_initSHA. + */ +static void __rtl_digest_initSHA ( + DigestContextSHA *ctx, DigestSHA_update_t *fct) +{ + rtl_zeroMemory (ctx, sizeof (DigestContextSHA)); + ctx->m_update = fct; + + ctx->m_nA = (sal_uInt32)0x67452301L; + ctx->m_nB = (sal_uInt32)0xefcdab89L; + ctx->m_nC = (sal_uInt32)0x98badcfeL; + ctx->m_nD = (sal_uInt32)0x10325476L; + ctx->m_nE = (sal_uInt32)0xc3d2e1f0L; +} + +/* + * __rtl_digest_updateSHA. + */ +static void __rtl_digest_updateSHA (DigestContextSHA *ctx) +{ + register sal_uInt32 A, B, C, D, E, T; + register sal_uInt32 *X; + + register DigestSHA_update_t *U; + U = ctx->m_update; + + A = ctx->m_nA; + B = ctx->m_nB; + C = ctx->m_nC; + D = ctx->m_nD; + E = ctx->m_nE; + X = ctx->m_pData; + + BODY_00_15 (U, 0, A, B, C, D, E, T); + BODY_00_15 (U, 1, T, A, B, C, D, E); + BODY_00_15 (U, 2, E, T, A, B, C, D); + BODY_00_15 (U, 3, D, E, T, A, B, C); + BODY_00_15 (U, 4, C, D, E, T, A, B); + BODY_00_15 (U, 5, B, C, D, E, T, A); + BODY_00_15 (U, 6, A, B, C, D, E, T); + BODY_00_15 (U, 7, T, A, B, C, D, E); + BODY_00_15 (U, 8, E, T, A, B, C, D); + BODY_00_15 (U, 9, D, E, T, A, B, C); + BODY_00_15 (U, 10, C, D, E, T, A, B); + BODY_00_15 (U, 11, B, C, D, E, T, A); + BODY_00_15 (U, 12, A, B, C, D, E, T); + BODY_00_15 (U, 13, T, A, B, C, D, E); + BODY_00_15 (U, 14, E, T, A, B, C, D); + BODY_00_15 (U, 15, D, E, T, A, B, C); + BODY_16_19 (U, 16, C, D, E, T, A, B); + BODY_16_19 (U, 17, B, C, D, E, T, A); + BODY_16_19 (U, 18, A, B, C, D, E, T); + BODY_16_19 (U, 19, T, A, B, C, D, E); + + BODY_20_39 (U, 20, E, T, A, B, C, D); + BODY_20_39 (U, 21, D, E, T, A, B, C); + BODY_20_39 (U, 22, C, D, E, T, A, B); + BODY_20_39 (U, 23, B, C, D, E, T, A); + BODY_20_39 (U, 24, A, B, C, D, E, T); + BODY_20_39 (U, 25, T, A, B, C, D, E); + BODY_20_39 (U, 26, E, T, A, B, C, D); + BODY_20_39 (U, 27, D, E, T, A, B, C); + BODY_20_39 (U, 28, C, D, E, T, A, B); + BODY_20_39 (U, 29, B, C, D, E, T, A); + BODY_20_39 (U, 30, A, B, C, D, E, T); + BODY_20_39 (U, 31, T, A, B, C, D, E); + BODY_20_39 (U, 32, E, T, A, B, C, D); + BODY_20_39 (U, 33, D, E, T, A, B, C); + BODY_20_39 (U, 34, C, D, E, T, A, B); + BODY_20_39 (U, 35, B, C, D, E, T, A); + BODY_20_39 (U, 36, A, B, C, D, E, T); + BODY_20_39 (U, 37, T, A, B, C, D, E); + BODY_20_39 (U, 38, E, T, A, B, C, D); + BODY_20_39 (U, 39, D, E, T, A, B, C); + + BODY_40_59 (U, 40, C, D, E, T, A, B); + BODY_40_59 (U, 41, B, C, D, E, T, A); + BODY_40_59 (U, 42, A, B, C, D, E, T); + BODY_40_59 (U, 43, T, A, B, C, D, E); + BODY_40_59 (U, 44, E, T, A, B, C, D); + BODY_40_59 (U, 45, D, E, T, A, B, C); + BODY_40_59 (U, 46, C, D, E, T, A, B); + BODY_40_59 (U, 47, B, C, D, E, T, A); + BODY_40_59 (U, 48, A, B, C, D, E, T); + BODY_40_59 (U, 49, T, A, B, C, D, E); + BODY_40_59 (U, 50, E, T, A, B, C, D); + BODY_40_59 (U, 51, D, E, T, A, B, C); + BODY_40_59 (U, 52, C, D, E, T, A, B); + BODY_40_59 (U, 53, B, C, D, E, T, A); + BODY_40_59 (U, 54, A, B, C, D, E, T); + BODY_40_59 (U, 55, T, A, B, C, D, E); + BODY_40_59 (U, 56, E, T, A, B, C, D); + BODY_40_59 (U, 57, D, E, T, A, B, C); + BODY_40_59 (U, 58, C, D, E, T, A, B); + BODY_40_59 (U, 59, B, C, D, E, T, A); + + BODY_60_79 (U, 60, A, B, C, D, E, T); + BODY_60_79 (U, 61, T, A, B, C, D, E); + BODY_60_79 (U, 62, E, T, A, B, C, D); + BODY_60_79 (U, 63, D, E, T, A, B, C); + BODY_60_79 (U, 64, C, D, E, T, A, B); + BODY_60_79 (U, 65, B, C, D, E, T, A); + BODY_60_79 (U, 66, A, B, C, D, E, T); + BODY_60_79 (U, 67, T, A, B, C, D, E); + BODY_60_79 (U, 68, E, T, A, B, C, D); + BODY_60_79 (U, 69, D, E, T, A, B, C); + BODY_60_79 (U, 70, C, D, E, T, A, B); + BODY_60_79 (U, 71, B, C, D, E, T, A); + BODY_60_79 (U, 72, A, B, C, D, E, T); + BODY_60_79 (U, 73, T, A, B, C, D, E); + BODY_60_79 (U, 74, E, T, A, B, C, D); + BODY_60_79 (U, 75, D, E, T, A, B, C); + BODY_60_79 (U, 76, C, D, E, T, A, B); + BODY_60_79 (U, 77, B, C, D, E, T, A); + BODY_60_79 (U, 78, A, B, C, D, E, T); + BODY_60_79 (U, 79, T, A, B, C, D, E); + + ctx->m_nA += E; + ctx->m_nB += T; + ctx->m_nC += A; + ctx->m_nD += B; + ctx->m_nE += C; +} + +/* + * __rtl_digest_endSHA. + */ +static void __rtl_digest_endSHA (DigestContextSHA *ctx) +{ + static const sal_uInt8 end[4] = + { + 0x80, 0x00, 0x00, 0x00 + }; + register const sal_uInt8 *p = end; + + register sal_uInt32 *X; + register int i; + + X = ctx->m_pData; + i = (ctx->m_nDatLen >> 2); + +#ifdef OSL_BIGENDIAN + __rtl_digest_swapLong (X, i + 1); +#endif /* OSL_BIGENDIAN */ + + switch (ctx->m_nDatLen & 0x03) + { + case 1: X[i] &= 0x000000ff; break; + case 2: X[i] &= 0x0000ffff; break; + case 3: X[i] &= 0x00ffffff; break; + } + + switch (ctx->m_nDatLen & 0x03) + { + case 0: X[i] = ((sal_uInt32)(*(p++))) << 0L; + case 1: X[i] |= ((sal_uInt32)(*(p++))) << 8L; + case 2: X[i] |= ((sal_uInt32)(*(p++))) << 16L; + case 3: X[i] |= ((sal_uInt32)(*(p++))) << 24L; + } + + __rtl_digest_swapLong (X, i + 1); + + i += 1; + + if (i >= (DIGEST_LBLOCK_SHA - 2)) + { + for (; i < DIGEST_LBLOCK_SHA; i++) + X[i] = 0; + __rtl_digest_updateSHA (ctx); + i = 0; + } + + for (; i < (DIGEST_LBLOCK_SHA - 2); i++) + X[i] = 0; + + X[DIGEST_LBLOCK_SHA - 2] = ctx->m_nH; + X[DIGEST_LBLOCK_SHA - 1] = ctx->m_nL; + + __rtl_digest_updateSHA (ctx); +} + +/*======================================================================== + * + * rtl_digest_SHA internals. + * + *======================================================================*/ +/* + * __rtl_digest_SHA_0. + */ +static const Digest_Impl __rtl_digest_SHA_0 = +{ + rtl_Digest_AlgorithmSHA, + RTL_DIGEST_LENGTH_SHA, + + NULL, + rtl_digest_destroySHA, + rtl_digest_updateSHA, + rtl_digest_getSHA +}; + +/* + * __rtl_digest_updateSHA_0. + */ +static sal_uInt32 __rtl_digest_updateSHA_0 (sal_uInt32 x) +{ + return x; +} + +/*======================================================================== + * + * rtl_digest_SHA implementation. + * + *======================================================================*/ +/* + * rtl_digest_SHA. + */ +rtlDigestError SAL_CALL rtl_digest_SHA ( + const void *pData, sal_uInt32 nDatLen, + sal_uInt8 *pBuffer, sal_uInt32 nBufLen) SAL_THROW_EXTERN_C() +{ + DigestSHA_Impl digest; + rtlDigestError result; + + digest.m_digest = __rtl_digest_SHA_0; + __rtl_digest_initSHA (&(digest.m_context), __rtl_digest_updateSHA_0); + + result = rtl_digest_updateSHA (&digest, pData, nDatLen); + if (result == rtl_Digest_E_None) + result = rtl_digest_getSHA (&digest, pBuffer, nBufLen); + + rtl_zeroMemory (&digest, sizeof (digest)); + return (result); +} + +/* + * rtl_digest_createSHA. + */ +rtlDigest SAL_CALL rtl_digest_createSHA() SAL_THROW_EXTERN_C() +{ + DigestSHA_Impl *pImpl = (DigestSHA_Impl*)NULL; + pImpl = RTL_DIGEST_CREATE(DigestSHA_Impl); + if (pImpl) + { + pImpl->m_digest = __rtl_digest_SHA_0; + __rtl_digest_initSHA (&(pImpl->m_context), __rtl_digest_updateSHA_0); + } + return ((rtlDigest)pImpl); +} + +/* + * rtl_digest_updateSHA. + */ +rtlDigestError SAL_CALL rtl_digest_updateSHA ( + rtlDigest Digest, const void *pData, sal_uInt32 nDatLen) + SAL_THROW_EXTERN_C() +{ + DigestSHA_Impl *pImpl = (DigestSHA_Impl *)Digest; + const sal_uInt8 *d = (const sal_uInt8 *)pData; + + DigestContextSHA *ctx; + sal_uInt32 len; + + if ((pImpl == NULL) || (pData == NULL)) + return rtl_Digest_E_Argument; + + if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmSHA)) + return rtl_Digest_E_Algorithm; + + if (nDatLen == 0) + return rtl_Digest_E_None; + + ctx = &(pImpl->m_context); + + len = ctx->m_nL + (nDatLen << 3); + if (len < ctx->m_nL) ctx->m_nH += 1; + ctx->m_nH += (nDatLen >> 29); + ctx->m_nL = len; + + if (ctx->m_nDatLen) + { + sal_uInt8 *p = (sal_uInt8 *)(ctx->m_pData) + ctx->m_nDatLen; + sal_uInt32 n = DIGEST_CBLOCK_SHA - ctx->m_nDatLen; + + if (nDatLen < n) + { + rtl_copyMemory (p, d, nDatLen); + ctx->m_nDatLen += nDatLen; + + return rtl_Digest_E_None; + } + + rtl_copyMemory (p, d, n); + d += n; + nDatLen -= n; + +#ifndef OSL_BIGENDIAN + __rtl_digest_swapLong (ctx->m_pData, DIGEST_LBLOCK_SHA); +#endif /* OSL_BIGENDIAN */ + + __rtl_digest_updateSHA (ctx); + ctx->m_nDatLen = 0; + } + + while (nDatLen >= DIGEST_CBLOCK_SHA) + { + rtl_copyMemory (ctx->m_pData, d, DIGEST_CBLOCK_SHA); + d += DIGEST_CBLOCK_SHA; + nDatLen -= DIGEST_CBLOCK_SHA; + +#ifndef OSL_BIGENDIAN + __rtl_digest_swapLong (ctx->m_pData, DIGEST_LBLOCK_SHA); +#endif /* OSL_BIGENDIAN */ + + __rtl_digest_updateSHA (ctx); + } + + rtl_copyMemory (ctx->m_pData, d, nDatLen); + ctx->m_nDatLen = nDatLen; + + return rtl_Digest_E_None; +} + +/* + * rtl_digest_getSHA. + */ +rtlDigestError SAL_CALL rtl_digest_getSHA ( + rtlDigest Digest, sal_uInt8 *pBuffer, sal_uInt32 nBufLen) + SAL_THROW_EXTERN_C() +{ + DigestSHA_Impl *pImpl = (DigestSHA_Impl *)Digest; + sal_uInt8 *p = pBuffer; + + DigestContextSHA *ctx; + + if ((pImpl == NULL) || (pBuffer == NULL)) + return rtl_Digest_E_Argument; + + if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmSHA)) + return rtl_Digest_E_Algorithm; + + if (!(pImpl->m_digest.m_length <= nBufLen)) + return rtl_Digest_E_BufferSize; + + ctx = &(pImpl->m_context); + + __rtl_digest_endSHA (ctx); + RTL_DIGEST_HTONL (ctx->m_nA, p); + RTL_DIGEST_HTONL (ctx->m_nB, p); + RTL_DIGEST_HTONL (ctx->m_nC, p); + RTL_DIGEST_HTONL (ctx->m_nD, p); + RTL_DIGEST_HTONL (ctx->m_nE, p); + __rtl_digest_initSHA (ctx, __rtl_digest_updateSHA_0); + + return rtl_Digest_E_None; +} + +/* + * rtl_digest_destroySHA. + */ +void SAL_CALL rtl_digest_destroySHA (rtlDigest Digest) SAL_THROW_EXTERN_C() +{ + DigestSHA_Impl *pImpl = (DigestSHA_Impl *)Digest; + if (pImpl) + { + if (pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmSHA) + rtl_freeZeroMemory (pImpl, sizeof (DigestSHA_Impl)); + else + rtl_freeMemory (pImpl); + } +} + +/*======================================================================== + * + * rtl_digest_SHA1 internals. + * + *======================================================================*/ +/* + * __rtl_digest_SHA_1. + */ +static const Digest_Impl __rtl_digest_SHA_1 = +{ + rtl_Digest_AlgorithmSHA1, + RTL_DIGEST_LENGTH_SHA1, + + NULL, + rtl_digest_destroySHA1, + rtl_digest_updateSHA1, + rtl_digest_getSHA1 +}; + +/* + * __rtl_digest_updateSHA_1. + */ +static sal_uInt32 __rtl_digest_updateSHA_1 (sal_uInt32 x) +{ + return RTL_DIGEST_ROTL (x, 1); +} + +/*======================================================================== + * + * rtl_digest_SHA1 implementation. + * + *======================================================================*/ +/* + * rtl_digest_SHA1. + */ +rtlDigestError SAL_CALL rtl_digest_SHA1 ( + const void *pData, sal_uInt32 nDatLen, + sal_uInt8 *pBuffer, sal_uInt32 nBufLen) SAL_THROW_EXTERN_C() +{ + DigestSHA_Impl digest; + rtlDigestError result; + + digest.m_digest = __rtl_digest_SHA_1; + __rtl_digest_initSHA (&(digest.m_context), __rtl_digest_updateSHA_1); + + result = rtl_digest_updateSHA1 (&digest, pData, nDatLen); + if (result == rtl_Digest_E_None) + result = rtl_digest_getSHA1 (&digest, pBuffer, nBufLen); + + rtl_zeroMemory (&digest, sizeof (digest)); + return (result); +} + +/* + * rtl_digest_createSHA1. + */ +rtlDigest SAL_CALL rtl_digest_createSHA1() SAL_THROW_EXTERN_C() +{ + DigestSHA_Impl *pImpl = (DigestSHA_Impl*)NULL; + pImpl = RTL_DIGEST_CREATE(DigestSHA_Impl); + if (pImpl) + { + pImpl->m_digest = __rtl_digest_SHA_1; + __rtl_digest_initSHA (&(pImpl->m_context), __rtl_digest_updateSHA_1); + } + return ((rtlDigest)pImpl); +} + +/* + * rtl_digest_updateSHA1. + */ +rtlDigestError SAL_CALL rtl_digest_updateSHA1 ( + rtlDigest Digest, const void *pData, sal_uInt32 nDatLen) + SAL_THROW_EXTERN_C() +{ + DigestSHA_Impl *pImpl = (DigestSHA_Impl *)Digest; + const sal_uInt8 *d = (const sal_uInt8 *)pData; + + DigestContextSHA *ctx; + sal_uInt32 len; + + if ((pImpl == NULL) || (pData == NULL)) + return rtl_Digest_E_Argument; + + if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmSHA1)) + return rtl_Digest_E_Algorithm; + + if (nDatLen == 0) + return rtl_Digest_E_None; + + ctx = &(pImpl->m_context); + + len = ctx->m_nL + (nDatLen << 3); + if (len < ctx->m_nL) ctx->m_nH += 1; + ctx->m_nH += (nDatLen >> 29); + ctx->m_nL = len; + + if (ctx->m_nDatLen) + { + sal_uInt8 *p = (sal_uInt8 *)(ctx->m_pData) + ctx->m_nDatLen; + sal_uInt32 n = DIGEST_CBLOCK_SHA - ctx->m_nDatLen; + + if (nDatLen < n) + { + rtl_copyMemory (p, d, nDatLen); + ctx->m_nDatLen += nDatLen; + + return rtl_Digest_E_None; + } + + rtl_copyMemory (p, d, n); + d += n; + nDatLen -= n; + +#ifndef OSL_BIGENDIAN + __rtl_digest_swapLong (ctx->m_pData, DIGEST_LBLOCK_SHA); +#endif /* OSL_BIGENDIAN */ + + __rtl_digest_updateSHA (ctx); + ctx->m_nDatLen = 0; + } + + while (nDatLen >= DIGEST_CBLOCK_SHA) + { + rtl_copyMemory (ctx->m_pData, d, DIGEST_CBLOCK_SHA); + d += DIGEST_CBLOCK_SHA; + nDatLen -= DIGEST_CBLOCK_SHA; + +#ifndef OSL_BIGENDIAN + __rtl_digest_swapLong (ctx->m_pData, DIGEST_LBLOCK_SHA); +#endif /* OSL_BIGENDIAN */ + + __rtl_digest_updateSHA (ctx); + } + + rtl_copyMemory (ctx->m_pData, d, nDatLen); + ctx->m_nDatLen = nDatLen; + + return rtl_Digest_E_None; +} + +/* + * rtl_digest_getSHA1. + */ +rtlDigestError SAL_CALL rtl_digest_getSHA1 ( + rtlDigest Digest, sal_uInt8 *pBuffer, sal_uInt32 nBufLen) + SAL_THROW_EXTERN_C() +{ + DigestSHA_Impl *pImpl = (DigestSHA_Impl *)Digest; + sal_uInt8 *p = pBuffer; + + DigestContextSHA *ctx; + + if ((pImpl == NULL) || (pBuffer == NULL)) + return rtl_Digest_E_Argument; + + if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmSHA1)) + return rtl_Digest_E_Algorithm; + + if (!(pImpl->m_digest.m_length <= nBufLen)) + return rtl_Digest_E_BufferSize; + + ctx = &(pImpl->m_context); + + __rtl_digest_endSHA (ctx); + RTL_DIGEST_HTONL (ctx->m_nA, p); + RTL_DIGEST_HTONL (ctx->m_nB, p); + RTL_DIGEST_HTONL (ctx->m_nC, p); + RTL_DIGEST_HTONL (ctx->m_nD, p); + RTL_DIGEST_HTONL (ctx->m_nE, p); + __rtl_digest_initSHA (ctx, __rtl_digest_updateSHA_1); + + return rtl_Digest_E_None; +} + +/* + * rtl_digest_destroySHA1. + */ +void SAL_CALL rtl_digest_destroySHA1 (rtlDigest Digest) SAL_THROW_EXTERN_C() +{ + DigestSHA_Impl *pImpl = (DigestSHA_Impl *)Digest; + if (pImpl) + { + if (pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmSHA1) + rtl_freeZeroMemory (pImpl, sizeof (DigestSHA_Impl)); + else + rtl_freeMemory (pImpl); + } +} + +/*======================================================================== + * + * rtl_digest_HMAC_MD5 internals. + * + *======================================================================*/ +#define DIGEST_CBLOCK_HMAC_MD5 64 + +struct ContextHMAC_MD5 +{ + DigestMD5_Impl m_hash; + sal_uInt8 m_opad[DIGEST_CBLOCK_HMAC_MD5]; +}; + +struct DigestHMAC_MD5_Impl +{ + Digest_Impl m_digest; + ContextHMAC_MD5 m_context; +}; + +static void __rtl_digest_initHMAC_MD5 (ContextHMAC_MD5 * ctx); +static void __rtl_digest_ipadHMAC_MD5 (ContextHMAC_MD5 * ctx); +static void __rtl_digest_opadHMAC_MD5 (ContextHMAC_MD5 * ctx); + +/* + * __rtl_digest_HMAC_MD5. + */ +static const Digest_Impl __rtl_digest_HMAC_MD5 = +{ + rtl_Digest_AlgorithmHMAC_MD5, + RTL_DIGEST_LENGTH_MD5, + + rtl_digest_initHMAC_MD5, + rtl_digest_destroyHMAC_MD5, + rtl_digest_updateHMAC_MD5, + rtl_digest_getHMAC_MD5 +}; + +/* + * __rtl_digest_initHMAC_MD5. + */ +static void __rtl_digest_initHMAC_MD5 (ContextHMAC_MD5 * ctx) +{ + DigestMD5_Impl *pImpl = &(ctx->m_hash); + + pImpl->m_digest = __rtl_digest_MD5; + __rtl_digest_initMD5 (&(pImpl->m_context)); + + rtl_zeroMemory (ctx->m_opad, DIGEST_CBLOCK_HMAC_MD5); +} + +/* + * __rtl_digest_ipadHMAC_MD5. + */ +static void __rtl_digest_ipadHMAC_MD5 (ContextHMAC_MD5 * ctx) +{ + register sal_uInt32 i; + + for (i = 0; i < DIGEST_CBLOCK_HMAC_MD5; i++) + ctx->m_opad[i] ^= 0x36; + rtl_digest_updateMD5 ( + &(ctx->m_hash), ctx->m_opad, DIGEST_CBLOCK_HMAC_MD5); + for (i = 0; i < DIGEST_CBLOCK_HMAC_MD5; i++) + ctx->m_opad[i] ^= 0x36; +} + +/* + * __rtl_digest_opadHMAC_MD5. + */ +static void __rtl_digest_opadHMAC_MD5 (ContextHMAC_MD5 * ctx) +{ + register sal_uInt32 i; + + for (i = 0; i < DIGEST_CBLOCK_HMAC_MD5; i++) + ctx->m_opad[i] ^= 0x5c; +} + +/*======================================================================== + * + * rtl_digest_HMAC_MD5 implementation. + * + *======================================================================*/ +/* + * rtl_digest_HMAC_MD5. + */ +rtlDigestError SAL_CALL rtl_digest_HMAC_MD5 ( + const sal_uInt8 *pKeyData, sal_uInt32 nKeyLen, + const void *pData, sal_uInt32 nDatLen, + sal_uInt8 *pBuffer, sal_uInt32 nBufLen) SAL_THROW_EXTERN_C() +{ + DigestHMAC_MD5_Impl digest; + rtlDigestError result; + + digest.m_digest = __rtl_digest_HMAC_MD5; + + result = rtl_digest_initHMAC_MD5 (&digest, pKeyData, nKeyLen); + if (result == rtl_Digest_E_None) + { + result = rtl_digest_updateHMAC_MD5 (&digest, pData, nDatLen); + if (result == rtl_Digest_E_None) + result = rtl_digest_getHMAC_MD5 (&digest, pBuffer, nBufLen); + } + + rtl_zeroMemory (&digest, sizeof (digest)); + return (result); +} + +/* + * rtl_digest_createHMAC_MD5. + */ +rtlDigest SAL_CALL rtl_digest_createHMAC_MD5() SAL_THROW_EXTERN_C() +{ + DigestHMAC_MD5_Impl *pImpl = (DigestHMAC_MD5_Impl*)NULL; + pImpl = RTL_DIGEST_CREATE(DigestHMAC_MD5_Impl); + if (pImpl) + { + pImpl->m_digest = __rtl_digest_HMAC_MD5; + __rtl_digest_initHMAC_MD5 (&(pImpl->m_context)); + } + return ((rtlDigest)pImpl); +} + +/* + * rtl_digest_initHMAC_MD5. + */ +rtlDigestError SAL_CALL rtl_digest_initHMAC_MD5 ( + rtlDigest Digest, const sal_uInt8 *pKeyData, sal_uInt32 nKeyLen) + SAL_THROW_EXTERN_C() +{ + DigestHMAC_MD5_Impl *pImpl = (DigestHMAC_MD5_Impl*)Digest; + ContextHMAC_MD5 *ctx; + + if ((pImpl == NULL) || (pKeyData == NULL)) + return rtl_Digest_E_Argument; + + if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmHMAC_MD5)) + return rtl_Digest_E_Algorithm; + + ctx = &(pImpl->m_context); + __rtl_digest_initHMAC_MD5 (ctx); + + if (nKeyLen > DIGEST_CBLOCK_HMAC_MD5) + { + /* Initialize 'opad' with hashed 'KeyData' */ + rtl_digest_updateMD5 ( + &(ctx->m_hash), pKeyData, nKeyLen); + rtl_digest_getMD5 ( + &(ctx->m_hash), ctx->m_opad, RTL_DIGEST_LENGTH_MD5); + } + else + { + /* Initialize 'opad' with plain 'KeyData' */ + rtl_copyMemory (ctx->m_opad, pKeyData, nKeyLen); + } + + __rtl_digest_ipadHMAC_MD5 (ctx); + __rtl_digest_opadHMAC_MD5 (ctx); + + return rtl_Digest_E_None; +} + +/* + * rtl_digest_updateHMAC_MD5. + */ +rtlDigestError SAL_CALL rtl_digest_updateHMAC_MD5 ( + rtlDigest Digest, const void *pData, sal_uInt32 nDatLen) + SAL_THROW_EXTERN_C() +{ + DigestHMAC_MD5_Impl *pImpl = (DigestHMAC_MD5_Impl*)Digest; + ContextHMAC_MD5 *ctx; + + if ((pImpl == NULL) || (pData == NULL)) + return rtl_Digest_E_Argument; + + if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmHMAC_MD5)) + return rtl_Digest_E_Algorithm; + + ctx = &(pImpl->m_context); + rtl_digest_updateMD5 (&(ctx->m_hash), pData, nDatLen); + + return rtl_Digest_E_None; +} + +/* + * rtl_digest_getHMAC_MD5. + */ +rtlDigestError SAL_CALL rtl_digest_getHMAC_MD5 ( + rtlDigest Digest, sal_uInt8 *pBuffer, sal_uInt32 nBufLen) + SAL_THROW_EXTERN_C() +{ + DigestHMAC_MD5_Impl *pImpl = (DigestHMAC_MD5_Impl*)Digest; + ContextHMAC_MD5 *ctx; + + if ((pImpl == NULL) || (pBuffer == NULL)) + return rtl_Digest_E_Argument; + + if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmHMAC_MD5)) + return rtl_Digest_E_Algorithm; + + if (!(pImpl->m_digest.m_length <= nBufLen)) + return rtl_Digest_E_BufferSize; + + nBufLen = pImpl->m_digest.m_length; + + ctx = &(pImpl->m_context); + rtl_digest_getMD5 (&(ctx->m_hash), pBuffer, nBufLen); + + rtl_digest_updateMD5 (&(ctx->m_hash), ctx->m_opad, 64); + rtl_digest_updateMD5 (&(ctx->m_hash), pBuffer, nBufLen); + rtl_digest_getMD5 (&(ctx->m_hash), pBuffer, nBufLen); + + __rtl_digest_opadHMAC_MD5 (ctx); + __rtl_digest_ipadHMAC_MD5 (ctx); + __rtl_digest_opadHMAC_MD5 (ctx); + + return rtl_Digest_E_None; +} + +/* + * rtl_digest_destroyHMAC_MD5. + */ +void SAL_CALL rtl_digest_destroyHMAC_MD5 (rtlDigest Digest) SAL_THROW_EXTERN_C() +{ + DigestHMAC_MD5_Impl *pImpl = (DigestHMAC_MD5_Impl*)Digest; + if (pImpl) + { + if (pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmHMAC_MD5) + rtl_freeZeroMemory (pImpl, sizeof (DigestHMAC_MD5_Impl)); + else + rtl_freeMemory (pImpl); + } +} + +/*======================================================================== + * + * rtl_digest_HMAC_SHA1 internals. + * + *======================================================================*/ +#define DIGEST_CBLOCK_HMAC_SHA1 64 + +struct ContextHMAC_SHA1 +{ + DigestSHA_Impl m_hash; + sal_uInt8 m_opad[DIGEST_CBLOCK_HMAC_SHA1]; +}; + +struct DigestHMAC_SHA1_Impl +{ + Digest_Impl m_digest; + ContextHMAC_SHA1 m_context; +}; + +static void __rtl_digest_initHMAC_SHA1 (ContextHMAC_SHA1 * ctx); +static void __rtl_digest_ipadHMAC_SHA1 (ContextHMAC_SHA1 * ctx); +static void __rtl_digest_opadHMAC_SHA1 (ContextHMAC_SHA1 * ctx); + +/* + * __rtl_digest_HMAC_SHA1. + */ +static const Digest_Impl __rtl_digest_HMAC_SHA1 = +{ + rtl_Digest_AlgorithmHMAC_SHA1, + RTL_DIGEST_LENGTH_SHA1, + + rtl_digest_initHMAC_SHA1, + rtl_digest_destroyHMAC_SHA1, + rtl_digest_updateHMAC_SHA1, + rtl_digest_getHMAC_SHA1 +}; + +/* + * __rtl_digest_initHMAC_SHA1. + */ +static void __rtl_digest_initHMAC_SHA1 (ContextHMAC_SHA1 * ctx) +{ + DigestSHA_Impl *pImpl = &(ctx->m_hash); + + pImpl->m_digest = __rtl_digest_SHA_1; + __rtl_digest_initSHA (&(pImpl->m_context), __rtl_digest_updateSHA_1); + + rtl_zeroMemory (ctx->m_opad, DIGEST_CBLOCK_HMAC_SHA1); +} + +/* + * __rtl_digest_ipadHMAC_SHA1. + */ +static void __rtl_digest_ipadHMAC_SHA1 (ContextHMAC_SHA1 * ctx) +{ + register sal_uInt32 i; + + for (i = 0; i < DIGEST_CBLOCK_HMAC_SHA1; i++) + ctx->m_opad[i] ^= 0x36; + rtl_digest_updateSHA1 ( + &(ctx->m_hash), ctx->m_opad, DIGEST_CBLOCK_HMAC_SHA1); + for (i = 0; i < DIGEST_CBLOCK_HMAC_SHA1; i++) + ctx->m_opad[i] ^= 0x36; +} + +/* + * __rtl_digest_opadHMAC_SHA1. + */ +static void __rtl_digest_opadHMAC_SHA1 (ContextHMAC_SHA1 * ctx) +{ + register sal_uInt32 i; + + for (i = 0; i < DIGEST_CBLOCK_HMAC_SHA1; i++) + ctx->m_opad[i] ^= 0x5c; +} + +/*======================================================================== + * + * rtl_digest_HMAC_SHA1 implementation. + * + *======================================================================*/ +/* + * rtl_digest_HMAC_SHA1. + */ +rtlDigestError SAL_CALL rtl_digest_HMAC_SHA1 ( + const sal_uInt8 *pKeyData, sal_uInt32 nKeyLen, + const void *pData, sal_uInt32 nDatLen, + sal_uInt8 *pBuffer, sal_uInt32 nBufLen) SAL_THROW_EXTERN_C() +{ + DigestHMAC_SHA1_Impl digest; + rtlDigestError result; + + digest.m_digest = __rtl_digest_HMAC_SHA1; + + result = rtl_digest_initHMAC_SHA1 (&digest, pKeyData, nKeyLen); + if (result == rtl_Digest_E_None) + { + result = rtl_digest_updateHMAC_SHA1 (&digest, pData, nDatLen); + if (result == rtl_Digest_E_None) + result = rtl_digest_getHMAC_SHA1 (&digest, pBuffer, nBufLen); + } + + rtl_zeroMemory (&digest, sizeof (digest)); + return (result); +} + +/* + * rtl_digest_createHMAC_SHA1. + */ +rtlDigest SAL_CALL rtl_digest_createHMAC_SHA1() SAL_THROW_EXTERN_C() +{ + DigestHMAC_SHA1_Impl *pImpl = (DigestHMAC_SHA1_Impl*)NULL; + pImpl = RTL_DIGEST_CREATE(DigestHMAC_SHA1_Impl); + if (pImpl) + { + pImpl->m_digest = __rtl_digest_HMAC_SHA1; + __rtl_digest_initHMAC_SHA1 (&(pImpl->m_context)); + } + return ((rtlDigest)pImpl); +} + +/* + * rtl_digest_initHMAC_SHA1. + */ +rtlDigestError SAL_CALL rtl_digest_initHMAC_SHA1 ( + rtlDigest Digest, const sal_uInt8 *pKeyData, sal_uInt32 nKeyLen) + SAL_THROW_EXTERN_C() +{ + DigestHMAC_SHA1_Impl *pImpl = (DigestHMAC_SHA1_Impl*)Digest; + ContextHMAC_SHA1 *ctx; + + if ((pImpl == NULL) || (pKeyData == NULL)) + return rtl_Digest_E_Argument; + + if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmHMAC_SHA1)) + return rtl_Digest_E_Algorithm; + + ctx = &(pImpl->m_context); + __rtl_digest_initHMAC_SHA1 (ctx); + + if (nKeyLen > DIGEST_CBLOCK_HMAC_SHA1) + { + /* Initialize 'opad' with hashed 'KeyData' */ + rtl_digest_updateSHA1 ( + &(ctx->m_hash), pKeyData, nKeyLen); + rtl_digest_getSHA1 ( + &(ctx->m_hash), ctx->m_opad, RTL_DIGEST_LENGTH_SHA1); + } + else + { + /* Initialize 'opad' with plain 'KeyData' */ + rtl_copyMemory (ctx->m_opad, pKeyData, nKeyLen); + } + + __rtl_digest_ipadHMAC_SHA1 (ctx); + __rtl_digest_opadHMAC_SHA1 (ctx); + + return rtl_Digest_E_None; +} + +/* + * rtl_digest_updateHMAC_SHA1. + */ +rtlDigestError SAL_CALL rtl_digest_updateHMAC_SHA1 ( + rtlDigest Digest, const void *pData, sal_uInt32 nDatLen) + SAL_THROW_EXTERN_C() +{ + DigestHMAC_SHA1_Impl *pImpl = (DigestHMAC_SHA1_Impl*)Digest; + ContextHMAC_SHA1 *ctx; + + if ((pImpl == NULL) || (pData == NULL)) + return rtl_Digest_E_Argument; + + if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmHMAC_SHA1)) + return rtl_Digest_E_Algorithm; + + ctx = &(pImpl->m_context); + rtl_digest_updateSHA1 (&(ctx->m_hash), pData, nDatLen); + + return rtl_Digest_E_None; +} + +/* + * rtl_digest_getHMAC_SHA1. + */ +rtlDigestError SAL_CALL rtl_digest_getHMAC_SHA1 ( + rtlDigest Digest, sal_uInt8 *pBuffer, sal_uInt32 nBufLen) + SAL_THROW_EXTERN_C() +{ + DigestHMAC_SHA1_Impl *pImpl = (DigestHMAC_SHA1_Impl*)Digest; + ContextHMAC_SHA1 *ctx; + + if ((pImpl == NULL) || (pBuffer == NULL)) + return rtl_Digest_E_Argument; + + if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmHMAC_SHA1)) + return rtl_Digest_E_Algorithm; + + if (!(pImpl->m_digest.m_length <= nBufLen)) + return rtl_Digest_E_BufferSize; + + nBufLen = pImpl->m_digest.m_length; + + ctx = &(pImpl->m_context); + rtl_digest_getSHA1 (&(ctx->m_hash), pBuffer, nBufLen); + + rtl_digest_updateSHA1 (&(ctx->m_hash), ctx->m_opad, sizeof(ctx->m_opad)); + rtl_digest_updateSHA1 (&(ctx->m_hash), pBuffer, nBufLen); + rtl_digest_getSHA1 (&(ctx->m_hash), pBuffer, nBufLen); + + __rtl_digest_opadHMAC_SHA1 (ctx); + __rtl_digest_ipadHMAC_SHA1 (ctx); + __rtl_digest_opadHMAC_SHA1 (ctx); + + return rtl_Digest_E_None; +} + +/* + * rtl_digest_destroyHMAC_SHA1. + */ +void SAL_CALL rtl_digest_destroyHMAC_SHA1 (rtlDigest Digest) + SAL_THROW_EXTERN_C() +{ + DigestHMAC_SHA1_Impl *pImpl = (DigestHMAC_SHA1_Impl*)Digest; + if (pImpl) + { + if (pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmHMAC_SHA1) + rtl_freeZeroMemory (pImpl, sizeof (DigestHMAC_SHA1_Impl)); + else + rtl_freeMemory (pImpl); + } +} + +/*======================================================================== + * + * rtl_digest_PBKDF2 internals. + * + *======================================================================*/ +#define DIGEST_CBLOCK_PBKDF2 RTL_DIGEST_LENGTH_HMAC_SHA1 + +/* + * __rtl_digest_updatePBKDF2. + */ +static void __rtl_digest_updatePBKDF2 ( + rtlDigest hDigest, + sal_uInt8 T[DIGEST_CBLOCK_PBKDF2], + const sal_uInt8 *pSaltData, sal_uInt32 nSaltLen, + sal_uInt32 nCount, sal_uInt32 nIndex) +{ + /* T_i = F (P, S, c, i) */ + sal_uInt8 U[DIGEST_CBLOCK_PBKDF2]; + register sal_uInt32 i, k; + + /* U_(1) = PRF (P, S || INDEX) */ + rtl_digest_updateHMAC_SHA1 (hDigest, pSaltData, nSaltLen); + rtl_digest_updateHMAC_SHA1 (hDigest, &nIndex, sizeof(nIndex)); + rtl_digest_getHMAC_SHA1 (hDigest, U, DIGEST_CBLOCK_PBKDF2); + + /* T = U_(1) */ + for (k = 0; k < DIGEST_CBLOCK_PBKDF2; k++) T[k] = U[k]; + + /* T ^= U_(2) ^ ... ^ U_(c) */ + for (i = 1; i < nCount; i++) + { + /* U_(i) = PRF (P, U_(i-1)) */ + rtl_digest_updateHMAC_SHA1 (hDigest, U, DIGEST_CBLOCK_PBKDF2); + rtl_digest_getHMAC_SHA1 (hDigest, U, DIGEST_CBLOCK_PBKDF2); + + /* T ^= U_(i) */ + for (k = 0; k < DIGEST_CBLOCK_PBKDF2; k++) T[k] ^= U[k]; + } + + rtl_zeroMemory (U, DIGEST_CBLOCK_PBKDF2); +} + +/*======================================================================== + * + * rtl_digest_PBKDF2 implementation. + * + *======================================================================*/ +/* + * rtl_digest_PBKDF2. + */ +rtlDigestError SAL_CALL rtl_digest_PBKDF2 ( + sal_uInt8 *pKeyData , sal_uInt32 nKeyLen, + const sal_uInt8 *pPassData, sal_uInt32 nPassLen, + const sal_uInt8 *pSaltData, sal_uInt32 nSaltLen, + sal_uInt32 nCount) SAL_THROW_EXTERN_C() +{ + DigestHMAC_SHA1_Impl digest; + sal_uInt32 i = 1; + + if ((pKeyData == NULL) || (pPassData == NULL) || (pSaltData == NULL)) + return rtl_Digest_E_Argument; + + digest.m_digest = __rtl_digest_HMAC_SHA1; + rtl_digest_initHMAC_SHA1 (&digest, pPassData, nPassLen); + + /* DK = T_(1) || T_(2) || ... || T_(l) */ + while (nKeyLen >= DIGEST_CBLOCK_PBKDF2) + { + /* T_(i) = F (P, S, c, i); DK ||= T_(i) */ + __rtl_digest_updatePBKDF2 ( + &digest, pKeyData, + pSaltData, nSaltLen, + nCount, OSL_NETDWORD(i)); + + /* Next 'KeyData' block */ + pKeyData += DIGEST_CBLOCK_PBKDF2; + nKeyLen -= DIGEST_CBLOCK_PBKDF2; + i += 1; + } + if (nKeyLen > 0) + { + /* Last 'KeyData' block */ + sal_uInt8 T[DIGEST_CBLOCK_PBKDF2]; + + /* T_i = F (P, S, c, i) */ + __rtl_digest_updatePBKDF2 ( + &digest, T, + pSaltData, nSaltLen, + nCount, OSL_NETDWORD(i)); + + /* DK ||= T_(i) */ + rtl_copyMemory (pKeyData, T, nKeyLen); + rtl_zeroMemory (T, DIGEST_CBLOCK_PBKDF2); + } + + rtl_zeroMemory (&digest, sizeof (digest)); + return rtl_Digest_E_None; +} + +/*======================================================================== + * + * The End. + * + *======================================================================*/ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/locale.c b/sal/rtl/source/locale.c deleted file mode 100644 index 2885b4cc4b68..000000000000 --- a/sal/rtl/source/locale.c +++ /dev/null @@ -1,352 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "rtl/locale.h" - -#include "osl/diagnose.h" -#include "rtl/alloc.h" - -#include "internal/once.h" - -static sal_Int32 RTL_HASHTABLE_SIZE[] = -{ - 7, 31, 127, 251, 509, 1021, 2039, 4093 -}; - -typedef struct rtl_hashentry RTL_HASHENTRY; - -struct rtl_hashentry -{ - rtl_Locale* Entry; - RTL_HASHENTRY* Next; -}; - -typedef struct rtl_hashtable -{ - sal_Int8 iSize; - sal_Int32 Size; - sal_Int32 Elements; - RTL_HASHENTRY** Table; -} RTL_HASHTABLE; - -static RTL_HASHTABLE* g_pLocaleTable = NULL; - -static rtl_Locale* g_pDefaultLocale = NULL; - -/************************************************************************* - */ -void rtl_hashentry_destroy(RTL_HASHENTRY* entry) -{ - rtl_uString_release(entry->Entry->Language); - rtl_uString_release(entry->Entry->Country); - rtl_uString_release(entry->Entry->Variant); - if (entry->Next) - rtl_hashentry_destroy(entry->Next); - - rtl_freeMemory(entry->Entry); - rtl_freeMemory(entry); -} - -void rtl_hashtable_destroy(RTL_HASHTABLE* table) -{ - sal_Int32 size = 0; - - if (!table) - return; - - size = table->Size; - - while (size) - { - if (table->Table[size - 1]) - rtl_hashentry_destroy(table->Table[size - 1]); - size--; - } - - rtl_freeMemory(table->Table); - rtl_freeMemory(table); -} - -void rtl_hashtable_init(RTL_HASHTABLE** table, sal_Int8 sizeIndex) -{ - sal_Int32 nSize = RTL_HASHTABLE_SIZE[sizeIndex]; - - if (*table) - rtl_hashtable_destroy(*table); - - *table = (RTL_HASHTABLE*)rtl_allocateMemory( sizeof(RTL_HASHTABLE) ); - - (*table)->iSize = sizeIndex; - (*table)->Size = nSize; - (*table)->Elements = 0; - (*table)->Table = (RTL_HASHENTRY**)rtl_allocateMemory( (*table)->Size * sizeof(RTL_HASHENTRY*) ); - - while (nSize) - { - (*table)->Table[nSize - 1] = NULL; - nSize--; - } -} - -sal_Int32 rtl_hashfunc(RTL_HASHTABLE* table, sal_Int32 key) -{ - return ( (sal_uInt32) key % table->Size); -} - -sal_Bool rtl_hashtable_grow(RTL_HASHTABLE** table); - -rtl_Locale* rtl_hashtable_add(RTL_HASHTABLE** table, rtl_Locale* value) -{ - sal_Int32 key = 0; - - if (!(*table)) - return NULL; - - if ((*table)->Elements > ((*table)->Size / 2)) - rtl_hashtable_grow(table); - - key = rtl_hashfunc(*table, value->HashCode); - - if (!(*table)->Table[key]) - { - RTL_HASHENTRY *newEntry = (RTL_HASHENTRY*)rtl_allocateMemory( sizeof(RTL_HASHENTRY) ); - newEntry->Entry = value; - newEntry->Next = NULL; - (*table)->Table[key] = newEntry; - (*table)->Elements++; - return NULL; - } else - { - RTL_HASHENTRY *pEntry = (*table)->Table[key]; - RTL_HASHENTRY *newEntry = NULL; - - while (pEntry) - { - if (value->HashCode == pEntry->Entry->HashCode) - return pEntry->Entry; - - if (!pEntry->Next) - break; - - pEntry = pEntry->Next; - } - - newEntry = (RTL_HASHENTRY*)rtl_allocateMemory( sizeof(RTL_HASHENTRY) ); - newEntry->Entry = value; - newEntry->Next = NULL; - pEntry->Next = newEntry; - (*table)->Elements++; - return NULL; - } -} - -sal_Bool rtl_hashtable_grow(RTL_HASHTABLE** table) -{ - RTL_HASHTABLE* pNewTable = NULL; - sal_Int32 i = 0; - - rtl_hashtable_init(&pNewTable, (sal_Int8)((*table)->iSize + 1)); - - while (i < (*table)->Size) - { - if ((*table)->Table[i]) - { - RTL_HASHENTRY *pNext; - RTL_HASHENTRY *pEntry = (*table)->Table[i]; - - rtl_hashtable_add(&pNewTable, pEntry->Entry); - - while (pEntry->Next) - { - rtl_hashtable_add(&pNewTable, pEntry->Next->Entry); - pNext = pEntry->Next; - rtl_freeMemory(pEntry); - pEntry = pNext; - } - - rtl_freeMemory(pEntry); - } - i++; - } - - rtl_freeMemory((*table)->Table); - rtl_freeMemory((*table)); - (*table) = pNewTable; - - return sal_True; -} - -sal_Bool rtl_hashtable_find(RTL_HASHTABLE * table, sal_Int32 key, sal_Int32 hashCode, rtl_Locale** pValue) -{ - if (!table) - return sal_False; - - if (table->Table[key]) - { - RTL_HASHENTRY *pEntry = table->Table[key]; - - while (pEntry && hashCode != pEntry->Entry->HashCode) - pEntry = pEntry->Next; - - if (pEntry) - *pValue = pEntry->Entry; - else - return sal_False; - } else - return sal_False; - - return sal_True; -} - -/************************************************************************* - * rtl_locale_init - */ -void rtl_locale_init (void) -{ - OSL_ASSERT(g_pLocaleTable == 0); - rtl_hashtable_init(&g_pLocaleTable, 1); -} - -/************************************************************************* - * rtl_locale_fini - */ -void rtl_locale_fini (void) -{ - if (g_pLocaleTable != 0) - { - rtl_hashtable_destroy (g_pLocaleTable); - g_pLocaleTable = 0; - } -} - -extern void ensureLocaleSingleton(); - -/************************************************************************* - * rtl_locale_register - */ -rtl_Locale * SAL_CALL rtl_locale_register( const sal_Unicode * language, const sal_Unicode * country, const sal_Unicode * variant ) -{ - sal_Unicode c = 0; - rtl_uString* sLanguage = NULL; - rtl_uString* sCountry = NULL; - rtl_uString* sVariant = NULL; - rtl_Locale *newLocale = NULL; - sal_Int32 hashCode = -1; - sal_Int32 key = 0; - - if ( !country ) - country = &c; - if ( !variant ) - variant = &c; - - ensureLocaleSingleton(); - if (!g_pLocaleTable) - return NULL; - - hashCode = rtl_ustr_hashCode(language) ^ rtl_ustr_hashCode(country) ^ rtl_ustr_hashCode(variant); - key = rtl_hashfunc(g_pLocaleTable, hashCode); - - if (rtl_hashtable_find(g_pLocaleTable, key, hashCode, &newLocale)) - return newLocale; - - rtl_uString_newFromStr(&sLanguage, language); - rtl_uString_newFromStr(&sCountry, country); - rtl_uString_newFromStr(&sVariant, variant); - - newLocale = (rtl_Locale*)rtl_allocateMemory( sizeof(rtl_Locale) ); - - newLocale->Language = sLanguage; - newLocale->Country = sCountry; - newLocale->Variant = sVariant; - newLocale->HashCode = hashCode; - - rtl_hashtable_add(&g_pLocaleTable, newLocale); - - return newLocale; -} - -/************************************************************************* - * rtl_locale_getDefault - */ -rtl_Locale * SAL_CALL rtl_locale_getDefault() -{ - return g_pDefaultLocale; -} - -/************************************************************************* - * rtl_locale_setDefault - */ -void SAL_CALL rtl_locale_setDefault( const sal_Unicode * language, const sal_Unicode * country, const sal_Unicode * variant ) -{ - g_pDefaultLocale = rtl_locale_register(language, country, variant); -} - -/************************************************************************* - * rtl_locale_getLanguage - */ -rtl_uString * SAL_CALL rtl_locale_getLanguage( rtl_Locale * This ) -{ - rtl_uString_acquire(This->Language); - return This->Language; -} - -/************************************************************************* - * rtl_locale_getCountry - */ -rtl_uString * SAL_CALL rtl_locale_getCountry( rtl_Locale * This ) -{ - rtl_uString_acquire(This->Country); - return This->Country; -} - -/************************************************************************* - * rtl_locale_getVariant - */ -rtl_uString * SAL_CALL rtl_locale_getVariant( rtl_Locale * This ) -{ - rtl_uString_acquire(This->Variant); - return This->Variant; -} - -/************************************************************************* - * rtl_locale_hashCode - */ -sal_Int32 SAL_CALL rtl_locale_hashCode( rtl_Locale * This ) -{ - return This->HashCode; -} - -/************************************************************************* - * rtl_locale_equals - */ -sal_Int32 SAL_CALL rtl_locale_equals( rtl_Locale * This, rtl_Locale * obj ) -{ - return This == obj; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/locale.cxx b/sal/rtl/source/locale.cxx new file mode 100644 index 000000000000..3e58c4cbb791 --- /dev/null +++ b/sal/rtl/source/locale.cxx @@ -0,0 +1,349 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "rtl/locale.h" + +#include "osl/diagnose.h" +#include "rtl/alloc.h" + +#include "internal/once.h" +#include "internal/rtl_locale_init.h" + +static sal_Int32 RTL_HASHTABLE_SIZE[] = +{ + 7, 31, 127, 251, 509, 1021, 2039, 4093 +}; + +struct RTL_HASHENTRY +{ + rtl_Locale* Entry; + RTL_HASHENTRY* Next; +}; + +struct RTL_HASHTABLE +{ + sal_Int8 iSize; + sal_Int32 Size; + sal_Int32 Elements; + RTL_HASHENTRY** Table; +}; + +static RTL_HASHTABLE* g_pLocaleTable = NULL; + +static rtl_Locale* g_pDefaultLocale = NULL; + +/************************************************************************* + */ +extern "C" void rtl_hashentry_destroy(RTL_HASHENTRY* entry) +{ + rtl_uString_release(entry->Entry->Language); + rtl_uString_release(entry->Entry->Country); + rtl_uString_release(entry->Entry->Variant); + if (entry->Next) + rtl_hashentry_destroy(entry->Next); + + rtl_freeMemory(entry->Entry); + rtl_freeMemory(entry); +} + +extern "C" void rtl_hashtable_destroy(RTL_HASHTABLE* table) +{ + sal_Int32 size = 0; + + if (!table) + return; + + size = table->Size; + + while (size) + { + if (table->Table[size - 1]) + rtl_hashentry_destroy(table->Table[size - 1]); + size--; + } + + rtl_freeMemory(table->Table); + rtl_freeMemory(table); +} + +extern "C" void rtl_hashtable_init(RTL_HASHTABLE** table, sal_Int8 sizeIndex) +{ + sal_Int32 nSize = RTL_HASHTABLE_SIZE[sizeIndex]; + + if (*table) + rtl_hashtable_destroy(*table); + + *table = (RTL_HASHTABLE*)rtl_allocateMemory( sizeof(RTL_HASHTABLE) ); + + (*table)->iSize = sizeIndex; + (*table)->Size = nSize; + (*table)->Elements = 0; + (*table)->Table = (RTL_HASHENTRY**)rtl_allocateMemory( (*table)->Size * sizeof(RTL_HASHENTRY*) ); + + while (nSize) + { + (*table)->Table[nSize - 1] = NULL; + nSize--; + } +} + +extern "C" sal_Int32 rtl_hashfunc(RTL_HASHTABLE* table, sal_Int32 key) +{ + return ( (sal_uInt32) key % table->Size); +} + +extern "C" sal_Bool rtl_hashtable_grow(RTL_HASHTABLE** table); + +extern "C" rtl_Locale* rtl_hashtable_add(RTL_HASHTABLE** table, rtl_Locale* value) +{ + sal_Int32 key = 0; + + if (!(*table)) + return NULL; + + if ((*table)->Elements > ((*table)->Size / 2)) + rtl_hashtable_grow(table); + + key = rtl_hashfunc(*table, value->HashCode); + + if (!(*table)->Table[key]) + { + RTL_HASHENTRY *newEntry = (RTL_HASHENTRY*)rtl_allocateMemory( sizeof(RTL_HASHENTRY) ); + newEntry->Entry = value; + newEntry->Next = NULL; + (*table)->Table[key] = newEntry; + (*table)->Elements++; + return NULL; + } else + { + RTL_HASHENTRY *pEntry = (*table)->Table[key]; + RTL_HASHENTRY *newEntry = NULL; + + while (pEntry) + { + if (value->HashCode == pEntry->Entry->HashCode) + return pEntry->Entry; + + if (!pEntry->Next) + break; + + pEntry = pEntry->Next; + } + + newEntry = (RTL_HASHENTRY*)rtl_allocateMemory( sizeof(RTL_HASHENTRY) ); + newEntry->Entry = value; + newEntry->Next = NULL; + pEntry->Next = newEntry; + (*table)->Elements++; + return NULL; + } +} + +sal_Bool rtl_hashtable_grow(RTL_HASHTABLE** table) +{ + RTL_HASHTABLE* pNewTable = NULL; + sal_Int32 i = 0; + + rtl_hashtable_init(&pNewTable, (sal_Int8)((*table)->iSize + 1)); + + while (i < (*table)->Size) + { + if ((*table)->Table[i]) + { + RTL_HASHENTRY *pNext; + RTL_HASHENTRY *pEntry = (*table)->Table[i]; + + rtl_hashtable_add(&pNewTable, pEntry->Entry); + + while (pEntry->Next) + { + rtl_hashtable_add(&pNewTable, pEntry->Next->Entry); + pNext = pEntry->Next; + rtl_freeMemory(pEntry); + pEntry = pNext; + } + + rtl_freeMemory(pEntry); + } + i++; + } + + rtl_freeMemory((*table)->Table); + rtl_freeMemory((*table)); + (*table) = pNewTable; + + return sal_True; +} + +extern "C" sal_Bool rtl_hashtable_find(RTL_HASHTABLE * table, sal_Int32 key, sal_Int32 hashCode, rtl_Locale** pValue) +{ + if (!table) + return sal_False; + + if (table->Table[key]) + { + RTL_HASHENTRY *pEntry = table->Table[key]; + + while (pEntry && hashCode != pEntry->Entry->HashCode) + pEntry = pEntry->Next; + + if (pEntry) + *pValue = pEntry->Entry; + else + return sal_False; + } else + return sal_False; + + return sal_True; +} + +/************************************************************************* + * rtl_locale_init + */ +void rtl_locale_init() +{ + OSL_ASSERT(g_pLocaleTable == 0); + rtl_hashtable_init(&g_pLocaleTable, 1); +} + +/************************************************************************* + * rtl_locale_fini + */ +void rtl_locale_fini() +{ + if (g_pLocaleTable != 0) + { + rtl_hashtable_destroy (g_pLocaleTable); + g_pLocaleTable = 0; + } +} + +/************************************************************************* + * rtl_locale_register + */ +rtl_Locale * SAL_CALL rtl_locale_register( const sal_Unicode * language, const sal_Unicode * country, const sal_Unicode * variant ) +{ + sal_Unicode c = 0; + rtl_uString* sLanguage = NULL; + rtl_uString* sCountry = NULL; + rtl_uString* sVariant = NULL; + rtl_Locale *newLocale = NULL; + sal_Int32 hashCode = -1; + sal_Int32 key = 0; + + if ( !country ) + country = &c; + if ( !variant ) + variant = &c; + + ensureLocaleSingleton(); + if (!g_pLocaleTable) + return NULL; + + hashCode = rtl_ustr_hashCode(language) ^ rtl_ustr_hashCode(country) ^ rtl_ustr_hashCode(variant); + key = rtl_hashfunc(g_pLocaleTable, hashCode); + + if (rtl_hashtable_find(g_pLocaleTable, key, hashCode, &newLocale)) + return newLocale; + + rtl_uString_newFromStr(&sLanguage, language); + rtl_uString_newFromStr(&sCountry, country); + rtl_uString_newFromStr(&sVariant, variant); + + newLocale = (rtl_Locale*)rtl_allocateMemory( sizeof(rtl_Locale) ); + + newLocale->Language = sLanguage; + newLocale->Country = sCountry; + newLocale->Variant = sVariant; + newLocale->HashCode = hashCode; + + rtl_hashtable_add(&g_pLocaleTable, newLocale); + + return newLocale; +} + +/************************************************************************* + * rtl_locale_getDefault + */ +rtl_Locale * SAL_CALL rtl_locale_getDefault() +{ + return g_pDefaultLocale; +} + +/************************************************************************* + * rtl_locale_setDefault + */ +void SAL_CALL rtl_locale_setDefault( const sal_Unicode * language, const sal_Unicode * country, const sal_Unicode * variant ) +{ + g_pDefaultLocale = rtl_locale_register(language, country, variant); +} + +/************************************************************************* + * rtl_locale_getLanguage + */ +rtl_uString * SAL_CALL rtl_locale_getLanguage( rtl_Locale * This ) +{ + rtl_uString_acquire(This->Language); + return This->Language; +} + +/************************************************************************* + * rtl_locale_getCountry + */ +rtl_uString * SAL_CALL rtl_locale_getCountry( rtl_Locale * This ) +{ + rtl_uString_acquire(This->Country); + return This->Country; +} + +/************************************************************************* + * rtl_locale_getVariant + */ +rtl_uString * SAL_CALL rtl_locale_getVariant( rtl_Locale * This ) +{ + rtl_uString_acquire(This->Variant); + return This->Variant; +} + +/************************************************************************* + * rtl_locale_hashCode + */ +sal_Int32 SAL_CALL rtl_locale_hashCode( rtl_Locale * This ) +{ + return This->HashCode; +} + +/************************************************************************* + * rtl_locale_equals + */ +sal_Int32 SAL_CALL rtl_locale_equals( rtl_Locale * This, rtl_Locale * obj ) +{ + return This == obj; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/memory.c b/sal/rtl/source/memory.c deleted file mode 100644 index 070b7898d413..000000000000 --- a/sal/rtl/source/memory.c +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -#include -#include - -void SAL_CALL rtl_zeroMemory(void *Ptr, sal_Size Bytes) -{ - memset(Ptr, 0, Bytes); -} - -void SAL_CALL rtl_fillMemory(void *Ptr, sal_Size Bytes, sal_uInt8 Fill) -{ - memset(Ptr, Fill, Bytes); -} - -void SAL_CALL rtl_copyMemory(void *Dst, const void *Src, sal_Size Bytes) -{ - memcpy(Dst, Src, Bytes); -} - -void SAL_CALL rtl_moveMemory(void *Dst, const void *Src, sal_Size Bytes) -{ - memmove(Dst, Src, Bytes); -} - -sal_Int32 SAL_CALL rtl_compareMemory(const void *MemA, const void *MemB, sal_Size Bytes) -{ - return memcmp(MemA, MemB, Bytes); -} - -void* SAL_CALL rtl_findInMemory(const void *MemA, sal_uInt8 ch, sal_Size Bytes) -{ - return memchr(MemA, ch, Bytes); -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/memory.cxx b/sal/rtl/source/memory.cxx new file mode 100644 index 000000000000..857710dcc708 --- /dev/null +++ b/sal/rtl/source/memory.cxx @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#include +#include + +void SAL_CALL rtl_zeroMemory(void *Ptr, sal_Size Bytes) +{ + memset(Ptr, 0, Bytes); +} + +void SAL_CALL rtl_fillMemory(void *Ptr, sal_Size Bytes, sal_uInt8 Fill) +{ + memset(Ptr, Fill, Bytes); +} + +void SAL_CALL rtl_copyMemory(void *Dst, const void *Src, sal_Size Bytes) +{ + memcpy(Dst, Src, Bytes); +} + +void SAL_CALL rtl_moveMemory(void *Dst, const void *Src, sal_Size Bytes) +{ + memmove(Dst, Src, Bytes); +} + +sal_Int32 SAL_CALL rtl_compareMemory(const void *MemA, const void *MemB, sal_Size Bytes) +{ + return memcmp(MemA, MemB, Bytes); +} + +void* SAL_CALL rtl_findInMemory(const void *MemA, sal_uInt8 ch, sal_Size Bytes) +{ + return const_cast< void * >(memchr(MemA, ch, Bytes)); +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/random.c b/sal/rtl/source/random.c deleted file mode 100644 index 101c7dffdbec..000000000000 --- a/sal/rtl/source/random.c +++ /dev/null @@ -1,340 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#define _RTL_RANDOM_C_ - -#include -#include -#include -#include -#include -#include -#include - -/*======================================================================== - * - * rtlRandom internals. - * - *======================================================================*/ -#define RTL_RANDOM_RNG_1(a) ((a) * 16807L) -#define RTL_RANDOM_RNG_2(a) ((a) * 65539L) - -#define RTL_RANDOM_RNG(x, y, z) \ -{ \ - (x) = 170 * ((x) % 178) - 63 * ((x) / 178); \ - if ((x) < 0) (x) += 30328L; \ - \ - (y) = 171 * ((y) % 177) - 2 * ((y) / 177); \ - if ((y) < 0) (y) += 30269L; \ - \ - (z) = 172 * ((z) % 176) - 35 * ((z) / 176); \ - if ((z) < 0) (z) += 30307L; \ -} - -/** RandomData_Impl. - */ -typedef struct random_data_impl_st -{ - sal_Int16 m_nX; - sal_Int16 m_nY; - sal_Int16 m_nZ; -} RandomData_Impl; - -/** __rtl_random_data. - */ -static double __rtl_random_data (RandomData_Impl *pImpl); - -/** RandomPool_Impl. - */ -#define RTL_RANDOM_DIGEST rtl_Digest_AlgorithmMD5 -#define RTL_RANDOM_SIZE_DIGEST RTL_DIGEST_LENGTH_MD5 -#define RTL_RANDOM_SIZE_POOL 1023 - -typedef struct random_pool_impl_st -{ - rtlDigest m_hDigest; - sal_uInt8 m_pDigest[RTL_RANDOM_SIZE_DIGEST]; - sal_uInt8 m_pData[RTL_RANDOM_SIZE_POOL + 1]; - sal_uInt32 m_nData; - sal_uInt32 m_nIndex; - sal_uInt32 m_nCount; -} RandomPool_Impl; - -/** __rtl_random_initPool. - */ -static sal_Bool __rtl_random_initPool ( - RandomPool_Impl *pImpl); - -/** __rtl_random_seedPool. - */ -static void __rtl_random_seedPool ( - RandomPool_Impl *pImpl, const sal_uInt8 *pBuffer, sal_Size nBufLen); - -/** __rtl_random_readPool. - */ -static void __rtl_random_readPool ( - RandomPool_Impl *pImpl, sal_uInt8 *pBuffer, sal_Size nBufLen); - -/* - * __rtl_random_data. - */ -static double __rtl_random_data (RandomData_Impl *pImpl) -{ - register double random; - - RTL_RANDOM_RNG (pImpl->m_nX, pImpl->m_nY, pImpl->m_nZ); - random = (((double)(pImpl->m_nX) / 30328.0) + - ((double)(pImpl->m_nY) / 30269.0) + - ((double)(pImpl->m_nZ) / 30307.0) ); - - random -= ((double)((sal_uInt32)(random))); - return (random); -} - -/* - * __rtl_random_initPool. - */ -static sal_Bool __rtl_random_initPool (RandomPool_Impl *pImpl) -{ - pImpl->m_hDigest = rtl_digest_create (RTL_RANDOM_DIGEST); - if (pImpl->m_hDigest) - { - oslThreadIdentifier id; - TimeValue tv; - RandomData_Impl rd; - double seed; - - /* The use of uninitialized stack variables as a way to - * enhance the entropy of the random pool triggers - * memory checkers like purify and valgrind. - */ - - /* - __rtl_random_seedPool (pImpl, (sal_uInt8*)&id, sizeof(id)); - __rtl_random_seedPool (pImpl, (sal_uInt8*)&tv, sizeof(tv)); - __rtl_random_seedPool (pImpl, (sal_uInt8*)&rd, sizeof(rd)); - */ - - id = osl_getThreadIdentifier (NULL); - id = RTL_RANDOM_RNG_2(RTL_RANDOM_RNG_1(id)); - __rtl_random_seedPool (pImpl, (sal_uInt8*)&id, sizeof(id)); - - osl_getSystemTime (&tv); - tv.Seconds = RTL_RANDOM_RNG_2(tv.Seconds); - tv.Nanosec = RTL_RANDOM_RNG_2(tv.Nanosec); - __rtl_random_seedPool (pImpl, (sal_uInt8*)&tv, sizeof(tv)); - - rd.m_nX = (sal_Int16)(((id >> 1) << 1) + 1); - rd.m_nY = (sal_Int16)(((tv.Seconds >> 1) << 1) + 1); - rd.m_nZ = (sal_Int16)(((tv.Nanosec >> 1) << 1) + 1); - __rtl_random_seedPool (pImpl, (sal_uInt8*)&rd, sizeof(rd)); - - while (pImpl->m_nData < RTL_RANDOM_SIZE_POOL) - { - seed = __rtl_random_data (&rd); - __rtl_random_seedPool (pImpl, (sal_uInt8*)&seed, sizeof(seed)); - } - return sal_True; - } - return sal_False; -} - -/* - * __rtl_random_seedPool. - */ -static void __rtl_random_seedPool ( - RandomPool_Impl *pImpl, const sal_uInt8 *pBuffer, sal_Size nBufLen) -{ - sal_Size i; - sal_sSize j, k; - - for (i = 0; i < nBufLen; i += RTL_RANDOM_SIZE_DIGEST) - { - j = nBufLen - i; - if (j > RTL_RANDOM_SIZE_DIGEST) - j = RTL_RANDOM_SIZE_DIGEST; - - rtl_digest_update ( - pImpl->m_hDigest, pImpl->m_pDigest, RTL_RANDOM_SIZE_DIGEST); - - k = (pImpl->m_nIndex + j) - RTL_RANDOM_SIZE_POOL; - if (k > 0) - { - rtl_digest_update ( - pImpl->m_hDigest, &(pImpl->m_pData[pImpl->m_nIndex]), j - k); - rtl_digest_update ( - pImpl->m_hDigest, &(pImpl->m_pData[0]), k); - } - else - { - rtl_digest_update ( - pImpl->m_hDigest, &(pImpl->m_pData[pImpl->m_nIndex]), j); - } - - rtl_digest_update (pImpl->m_hDigest, pBuffer, j); - pBuffer += j; - - rtl_digest_get ( - pImpl->m_hDigest, pImpl->m_pDigest, RTL_RANDOM_SIZE_DIGEST); - for (k = 0; k < j; k++) - { - pImpl->m_pData[pImpl->m_nIndex++] ^= pImpl->m_pDigest[k]; - if (pImpl->m_nIndex >= RTL_RANDOM_SIZE_POOL) - { - pImpl->m_nData = RTL_RANDOM_SIZE_POOL; - pImpl->m_nIndex = 0; - } - } - } - - if (pImpl->m_nIndex > pImpl->m_nData) - pImpl->m_nData = pImpl->m_nIndex; -} - -/* - * __rtl_random_readPool. - */ -static void __rtl_random_readPool ( - RandomPool_Impl *pImpl, sal_uInt8 *pBuffer, sal_Size nBufLen) -{ - sal_Int32 j, k; - - while (nBufLen > 0) - { - j = nBufLen; - if (j > RTL_RANDOM_SIZE_DIGEST/2) - j = RTL_RANDOM_SIZE_DIGEST/2; - nBufLen -= j; - - rtl_digest_update ( - pImpl->m_hDigest, - &(pImpl->m_pDigest[RTL_RANDOM_SIZE_DIGEST/2]), - RTL_RANDOM_SIZE_DIGEST/2); - - k = (pImpl->m_nIndex + j) - pImpl->m_nData; - if (k > 0) - { - rtl_digest_update ( - pImpl->m_hDigest, &(pImpl->m_pData[pImpl->m_nIndex]), j - k); - rtl_digest_update ( - pImpl->m_hDigest, &(pImpl->m_pData[0]), k); - } - else - { - rtl_digest_update ( - pImpl->m_hDigest, &(pImpl->m_pData[pImpl->m_nIndex]), j); - } - - rtl_digest_get ( - pImpl->m_hDigest, pImpl->m_pDigest, RTL_RANDOM_SIZE_DIGEST); - for (k = 0; k < j; k++) - { - if (pImpl->m_nIndex >= pImpl->m_nData) pImpl->m_nIndex = 0; - pImpl->m_pData[pImpl->m_nIndex++] ^= pImpl->m_pDigest[k]; - *pBuffer++ = pImpl->m_pDigest[k + RTL_RANDOM_SIZE_DIGEST/2]; - } - } - - pImpl->m_nCount++; - rtl_digest_update ( - pImpl->m_hDigest, &(pImpl->m_nCount), sizeof(pImpl->m_nCount)); - rtl_digest_update ( - pImpl->m_hDigest, pImpl->m_pDigest, RTL_RANDOM_SIZE_DIGEST); - rtl_digest_get ( - pImpl->m_hDigest, pImpl->m_pDigest, RTL_RANDOM_SIZE_DIGEST); -} - -/*======================================================================== - * - * rtlRandom implementation. - * - *======================================================================*/ -/* - * rtl_random_createPool. - */ -rtlRandomPool SAL_CALL rtl_random_createPool (void) -{ - RandomPool_Impl *pImpl = (RandomPool_Impl*)NULL; - pImpl = (RandomPool_Impl*)rtl_allocateZeroMemory (sizeof(RandomPool_Impl)); - if (pImpl) - { - if (!__rtl_random_initPool (pImpl)) - { - rtl_freeZeroMemory (pImpl, sizeof(RandomPool_Impl)); - pImpl = (RandomPool_Impl*)NULL; - } - } - return ((rtlRandomPool)pImpl); -} - -/* - * rtl_random_destroyPool. - */ -void SAL_CALL rtl_random_destroyPool (rtlRandomPool Pool) -{ - RandomPool_Impl *pImpl = (RandomPool_Impl *)Pool; - if (pImpl) - { - rtl_digest_destroy (pImpl->m_hDigest); - rtl_freeZeroMemory (pImpl, sizeof (RandomPool_Impl)); - } -} - -/* - * rtl_random_addBytes. - */ -rtlRandomError SAL_CALL rtl_random_addBytes ( - rtlRandomPool Pool, const void *Buffer, sal_Size Bytes) -{ - RandomPool_Impl *pImpl = (RandomPool_Impl *)Pool; - const sal_uInt8 *pBuffer = (const sal_uInt8 *)Buffer; - - if ((pImpl == NULL) || (pBuffer == NULL)) - return rtl_Random_E_Argument; - - __rtl_random_seedPool (pImpl, pBuffer, Bytes); - return rtl_Random_E_None; -} - -/* - * rtl_random_getBytes. - */ -rtlRandomError SAL_CALL rtl_random_getBytes ( - rtlRandomPool Pool, void *Buffer, sal_Size Bytes) -{ - RandomPool_Impl *pImpl = (RandomPool_Impl *)Pool; - sal_uInt8 *pBuffer = (sal_uInt8 *)Buffer; - - if ((pImpl == NULL) || (pBuffer == NULL)) - return rtl_Random_E_Argument; - - __rtl_random_readPool (pImpl, pBuffer, Bytes); - return rtl_Random_E_None; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/random.cxx b/sal/rtl/source/random.cxx new file mode 100644 index 000000000000..a8b452ac439b --- /dev/null +++ b/sal/rtl/source/random.cxx @@ -0,0 +1,340 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#define _RTL_RANDOM_C_ + +#include +#include +#include +#include +#include +#include +#include + +/*======================================================================== + * + * rtlRandom internals. + * + *======================================================================*/ +#define RTL_RANDOM_RNG_1(a) ((a) * 16807L) +#define RTL_RANDOM_RNG_2(a) ((a) * 65539L) + +#define RTL_RANDOM_RNG(x, y, z) \ +{ \ + (x) = 170 * ((x) % 178) - 63 * ((x) / 178); \ + if ((x) < 0) (x) += 30328L; \ + \ + (y) = 171 * ((y) % 177) - 2 * ((y) / 177); \ + if ((y) < 0) (y) += 30269L; \ + \ + (z) = 172 * ((z) % 176) - 35 * ((z) / 176); \ + if ((z) < 0) (z) += 30307L; \ +} + +/** RandomData_Impl. + */ +struct RandomData_Impl +{ + sal_Int16 m_nX; + sal_Int16 m_nY; + sal_Int16 m_nZ; +}; + +/** __rtl_random_data. + */ +static double __rtl_random_data (RandomData_Impl *pImpl); + +/** RandomPool_Impl. + */ +#define RTL_RANDOM_DIGEST rtl_Digest_AlgorithmMD5 +#define RTL_RANDOM_SIZE_DIGEST RTL_DIGEST_LENGTH_MD5 +#define RTL_RANDOM_SIZE_POOL 1023 + +struct RandomPool_Impl +{ + rtlDigest m_hDigest; + sal_uInt8 m_pDigest[RTL_RANDOM_SIZE_DIGEST]; + sal_uInt8 m_pData[RTL_RANDOM_SIZE_POOL + 1]; + sal_uInt32 m_nData; + sal_uInt32 m_nIndex; + sal_uInt32 m_nCount; +}; + +/** __rtl_random_initPool. + */ +static sal_Bool __rtl_random_initPool ( + RandomPool_Impl *pImpl); + +/** __rtl_random_seedPool. + */ +static void __rtl_random_seedPool ( + RandomPool_Impl *pImpl, const sal_uInt8 *pBuffer, sal_Size nBufLen); + +/** __rtl_random_readPool. + */ +static void __rtl_random_readPool ( + RandomPool_Impl *pImpl, sal_uInt8 *pBuffer, sal_Size nBufLen); + +/* + * __rtl_random_data. + */ +static double __rtl_random_data (RandomData_Impl *pImpl) +{ + register double random; + + RTL_RANDOM_RNG (pImpl->m_nX, pImpl->m_nY, pImpl->m_nZ); + random = (((double)(pImpl->m_nX) / 30328.0) + + ((double)(pImpl->m_nY) / 30269.0) + + ((double)(pImpl->m_nZ) / 30307.0) ); + + random -= ((double)((sal_uInt32)(random))); + return (random); +} + +/* + * __rtl_random_initPool. + */ +static sal_Bool __rtl_random_initPool (RandomPool_Impl *pImpl) +{ + pImpl->m_hDigest = rtl_digest_create (RTL_RANDOM_DIGEST); + if (pImpl->m_hDigest) + { + oslThreadIdentifier id; + TimeValue tv; + RandomData_Impl rd; + double seed; + + /* The use of uninitialized stack variables as a way to + * enhance the entropy of the random pool triggers + * memory checkers like purify and valgrind. + */ + + /* + __rtl_random_seedPool (pImpl, (sal_uInt8*)&id, sizeof(id)); + __rtl_random_seedPool (pImpl, (sal_uInt8*)&tv, sizeof(tv)); + __rtl_random_seedPool (pImpl, (sal_uInt8*)&rd, sizeof(rd)); + */ + + id = osl_getThreadIdentifier (NULL); + id = RTL_RANDOM_RNG_2(RTL_RANDOM_RNG_1(id)); + __rtl_random_seedPool (pImpl, (sal_uInt8*)&id, sizeof(id)); + + osl_getSystemTime (&tv); + tv.Seconds = RTL_RANDOM_RNG_2(tv.Seconds); + tv.Nanosec = RTL_RANDOM_RNG_2(tv.Nanosec); + __rtl_random_seedPool (pImpl, (sal_uInt8*)&tv, sizeof(tv)); + + rd.m_nX = (sal_Int16)(((id >> 1) << 1) + 1); + rd.m_nY = (sal_Int16)(((tv.Seconds >> 1) << 1) + 1); + rd.m_nZ = (sal_Int16)(((tv.Nanosec >> 1) << 1) + 1); + __rtl_random_seedPool (pImpl, (sal_uInt8*)&rd, sizeof(rd)); + + while (pImpl->m_nData < RTL_RANDOM_SIZE_POOL) + { + seed = __rtl_random_data (&rd); + __rtl_random_seedPool (pImpl, (sal_uInt8*)&seed, sizeof(seed)); + } + return sal_True; + } + return sal_False; +} + +/* + * __rtl_random_seedPool. + */ +static void __rtl_random_seedPool ( + RandomPool_Impl *pImpl, const sal_uInt8 *pBuffer, sal_Size nBufLen) +{ + sal_Size i; + sal_sSize j, k; + + for (i = 0; i < nBufLen; i += RTL_RANDOM_SIZE_DIGEST) + { + j = nBufLen - i; + if (j > RTL_RANDOM_SIZE_DIGEST) + j = RTL_RANDOM_SIZE_DIGEST; + + rtl_digest_update ( + pImpl->m_hDigest, pImpl->m_pDigest, RTL_RANDOM_SIZE_DIGEST); + + k = (pImpl->m_nIndex + j) - RTL_RANDOM_SIZE_POOL; + if (k > 0) + { + rtl_digest_update ( + pImpl->m_hDigest, &(pImpl->m_pData[pImpl->m_nIndex]), j - k); + rtl_digest_update ( + pImpl->m_hDigest, &(pImpl->m_pData[0]), k); + } + else + { + rtl_digest_update ( + pImpl->m_hDigest, &(pImpl->m_pData[pImpl->m_nIndex]), j); + } + + rtl_digest_update (pImpl->m_hDigest, pBuffer, j); + pBuffer += j; + + rtl_digest_get ( + pImpl->m_hDigest, pImpl->m_pDigest, RTL_RANDOM_SIZE_DIGEST); + for (k = 0; k < j; k++) + { + pImpl->m_pData[pImpl->m_nIndex++] ^= pImpl->m_pDigest[k]; + if (pImpl->m_nIndex >= RTL_RANDOM_SIZE_POOL) + { + pImpl->m_nData = RTL_RANDOM_SIZE_POOL; + pImpl->m_nIndex = 0; + } + } + } + + if (pImpl->m_nIndex > pImpl->m_nData) + pImpl->m_nData = pImpl->m_nIndex; +} + +/* + * __rtl_random_readPool. + */ +static void __rtl_random_readPool ( + RandomPool_Impl *pImpl, sal_uInt8 *pBuffer, sal_Size nBufLen) +{ + sal_Int32 j, k; + + while (nBufLen > 0) + { + j = nBufLen; + if (j > RTL_RANDOM_SIZE_DIGEST/2) + j = RTL_RANDOM_SIZE_DIGEST/2; + nBufLen -= j; + + rtl_digest_update ( + pImpl->m_hDigest, + &(pImpl->m_pDigest[RTL_RANDOM_SIZE_DIGEST/2]), + RTL_RANDOM_SIZE_DIGEST/2); + + k = (pImpl->m_nIndex + j) - pImpl->m_nData; + if (k > 0) + { + rtl_digest_update ( + pImpl->m_hDigest, &(pImpl->m_pData[pImpl->m_nIndex]), j - k); + rtl_digest_update ( + pImpl->m_hDigest, &(pImpl->m_pData[0]), k); + } + else + { + rtl_digest_update ( + pImpl->m_hDigest, &(pImpl->m_pData[pImpl->m_nIndex]), j); + } + + rtl_digest_get ( + pImpl->m_hDigest, pImpl->m_pDigest, RTL_RANDOM_SIZE_DIGEST); + for (k = 0; k < j; k++) + { + if (pImpl->m_nIndex >= pImpl->m_nData) pImpl->m_nIndex = 0; + pImpl->m_pData[pImpl->m_nIndex++] ^= pImpl->m_pDigest[k]; + *pBuffer++ = pImpl->m_pDigest[k + RTL_RANDOM_SIZE_DIGEST/2]; + } + } + + pImpl->m_nCount++; + rtl_digest_update ( + pImpl->m_hDigest, &(pImpl->m_nCount), sizeof(pImpl->m_nCount)); + rtl_digest_update ( + pImpl->m_hDigest, pImpl->m_pDigest, RTL_RANDOM_SIZE_DIGEST); + rtl_digest_get ( + pImpl->m_hDigest, pImpl->m_pDigest, RTL_RANDOM_SIZE_DIGEST); +} + +/*======================================================================== + * + * rtlRandom implementation. + * + *======================================================================*/ +/* + * rtl_random_createPool. + */ +rtlRandomPool SAL_CALL rtl_random_createPool() SAL_THROW_EXTERN_C() +{ + RandomPool_Impl *pImpl = (RandomPool_Impl*)NULL; + pImpl = (RandomPool_Impl*)rtl_allocateZeroMemory (sizeof(RandomPool_Impl)); + if (pImpl) + { + if (!__rtl_random_initPool (pImpl)) + { + rtl_freeZeroMemory (pImpl, sizeof(RandomPool_Impl)); + pImpl = (RandomPool_Impl*)NULL; + } + } + return ((rtlRandomPool)pImpl); +} + +/* + * rtl_random_destroyPool. + */ +void SAL_CALL rtl_random_destroyPool (rtlRandomPool Pool) SAL_THROW_EXTERN_C() +{ + RandomPool_Impl *pImpl = (RandomPool_Impl *)Pool; + if (pImpl) + { + rtl_digest_destroy (pImpl->m_hDigest); + rtl_freeZeroMemory (pImpl, sizeof (RandomPool_Impl)); + } +} + +/* + * rtl_random_addBytes. + */ +rtlRandomError SAL_CALL rtl_random_addBytes ( + rtlRandomPool Pool, const void *Buffer, sal_Size Bytes) SAL_THROW_EXTERN_C() +{ + RandomPool_Impl *pImpl = (RandomPool_Impl *)Pool; + const sal_uInt8 *pBuffer = (const sal_uInt8 *)Buffer; + + if ((pImpl == NULL) || (pBuffer == NULL)) + return rtl_Random_E_Argument; + + __rtl_random_seedPool (pImpl, pBuffer, Bytes); + return rtl_Random_E_None; +} + +/* + * rtl_random_getBytes. + */ +rtlRandomError SAL_CALL rtl_random_getBytes ( + rtlRandomPool Pool, void *Buffer, sal_Size Bytes) SAL_THROW_EXTERN_C() +{ + RandomPool_Impl *pImpl = (RandomPool_Impl *)Pool; + sal_uInt8 *pBuffer = (sal_uInt8 *)Buffer; + + if ((pImpl == NULL) || (pBuffer == NULL)) + return rtl_Random_E_Argument; + + __rtl_random_readPool (pImpl, pBuffer, Bytes); + return rtl_Random_E_None; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/uuid.cxx b/sal/rtl/source/uuid.cxx index 7be3847e6902..8b650cd6aa43 100644 --- a/sal/rtl/source/uuid.cxx +++ b/sal/rtl/source/uuid.cxx @@ -67,7 +67,7 @@ ( ( (sal_uInt32)p[3]) & 0xff);\ } -typedef struct _UUID +struct UUID { sal_uInt32 time_low; sal_uInt16 time_mid; @@ -75,7 +75,7 @@ typedef struct _UUID sal_uInt8 clock_seq_hi_and_reserved; sal_uInt8 clock_seq_low; sal_uInt8 node[6]; -} UUID; +}; static void write_v3( sal_uInt8 *pUuid ) { -- cgit From 2a6aeea94de022b364fa5943793cdc1922df84f1 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 31 Oct 2011 19:02:52 +0100 Subject: Removed some obsolete register annotations. --- sal/rtl/source/alloc_impl.h | 4 ++-- sal/rtl/source/cipher.cxx | 4 ++-- sal/rtl/source/crc.cxx | 4 ++-- sal/rtl/source/digest.cxx | 46 ++++++++++++++++++++++----------------------- sal/rtl/source/random.cxx | 2 +- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/sal/rtl/source/alloc_impl.h b/sal/rtl/source/alloc_impl.h index 8ea038496dfa..3b63f07fe1f8 100644 --- a/sal/rtl/source/alloc_impl.h +++ b/sal/rtl/source/alloc_impl.h @@ -98,7 +98,7 @@ extern "C" { static RTL_MEMORY_INLINE int highbit(sal_Size n) { - register int k = 1; + int k = 1; if (n == 0) return (0); @@ -131,7 +131,7 @@ highbit(sal_Size n) static RTL_MEMORY_INLINE int lowbit(sal_Size n) { - register int k = 1; + int k = 1; if (n == 0) return (0); diff --git a/sal/rtl/source/cipher.cxx b/sal/rtl/source/cipher.cxx index 19647ab3186d..31c141771724 100644 --- a/sal/rtl/source/cipher.cxx +++ b/sal/rtl/source/cipher.cxx @@ -1207,8 +1207,8 @@ static rtlCipherError rtl_cipherARCFOUR_update_Impl ( const sal_uInt8 *pData, sal_Size nDatLen, sal_uInt8 *pBuffer, sal_Size nBufLen) { - register unsigned int *S; - register unsigned int x, y, t; + unsigned int *S; + unsigned int x, y, t; sal_Size k; /* Check arguments. */ diff --git a/sal/rtl/source/crc.cxx b/sal/rtl/source/crc.cxx index bd61347edc24..942bff7026c6 100644 --- a/sal/rtl/source/crc.cxx +++ b/sal/rtl/source/crc.cxx @@ -152,8 +152,8 @@ sal_uInt32 SAL_CALL rtl_crc32 ( { if (Data) { - register const sal_uInt8 *p = (const sal_uInt8 *)Data; - register const sal_uInt8 *q = p + DatLen; + const sal_uInt8 *p = (const sal_uInt8 *)Data; + const sal_uInt8 *q = p + DatLen; Crc = ~Crc; while (p < q) diff --git a/sal/rtl/source/digest.cxx b/sal/rtl/source/digest.cxx index 28655858d425..1bcc1509867c 100644 --- a/sal/rtl/source/digest.cxx +++ b/sal/rtl/source/digest.cxx @@ -83,8 +83,8 @@ struct Digest_Impl */ static void __rtl_digest_swapLong (sal_uInt32 *pData, sal_uInt32 nDatLen) { - register sal_uInt32 *X; - register int i, n; + sal_uInt32 *X; + int i, n; X = pData; n = nDatLen; @@ -308,9 +308,9 @@ static void __rtl_digest_initMD2 (DigestContextMD2 *ctx) */ static void __rtl_digest_updateMD2 (DigestContextMD2 *ctx) { - register sal_uInt8 *X; - register sal_uInt32 *sp1, *sp2; - register sal_uInt32 i, k, t; + sal_uInt8 *X; + sal_uInt32 *sp1, *sp2; + sal_uInt32 i, k, t; sal_uInt32 state[48]; @@ -353,8 +353,8 @@ static void __rtl_digest_updateMD2 (DigestContextMD2 *ctx) */ static void __rtl_digest_endMD2 (DigestContextMD2 *ctx) { - register sal_uInt8 *X; - register sal_uInt32 *C; + sal_uInt8 *X; + sal_uInt32 *C; sal_uInt32 i, n; X = ctx->m_pData; @@ -599,8 +599,8 @@ static void __rtl_digest_initMD5 (DigestContextMD5 *ctx) */ static void __rtl_digest_updateMD5 (DigestContextMD5 *ctx) { - register sal_uInt32 A, B, C, D; - register sal_uInt32 *X; + sal_uInt32 A, B, C, D; + sal_uInt32 *X; A = ctx->m_nA; B = ctx->m_nB; @@ -691,10 +691,10 @@ static void __rtl_digest_endMD5 (DigestContextMD5 *ctx) { 0x80, 0x00, 0x00, 0x00 }; - register const sal_uInt8 *p = end; + const sal_uInt8 *p = end; - register sal_uInt32 *X; - register int i; + sal_uInt32 *X; + int i; X = ctx->m_pData; i = (ctx->m_nDatLen >> 2); @@ -1029,10 +1029,10 @@ static void __rtl_digest_initSHA ( */ static void __rtl_digest_updateSHA (DigestContextSHA *ctx) { - register sal_uInt32 A, B, C, D, E, T; - register sal_uInt32 *X; + sal_uInt32 A, B, C, D, E, T; + sal_uInt32 *X; - register DigestSHA_update_t *U; + DigestSHA_update_t *U; U = ctx->m_update; A = ctx->m_nA; @@ -1142,10 +1142,10 @@ static void __rtl_digest_endSHA (DigestContextSHA *ctx) { 0x80, 0x00, 0x00, 0x00 }; - register const sal_uInt8 *p = end; + const sal_uInt8 *p = end; - register sal_uInt32 *X; - register int i; + sal_uInt32 *X; + int i; X = ctx->m_pData; i = (ctx->m_nDatLen >> 2); @@ -1625,7 +1625,7 @@ static void __rtl_digest_initHMAC_MD5 (ContextHMAC_MD5 * ctx) */ static void __rtl_digest_ipadHMAC_MD5 (ContextHMAC_MD5 * ctx) { - register sal_uInt32 i; + sal_uInt32 i; for (i = 0; i < DIGEST_CBLOCK_HMAC_MD5; i++) ctx->m_opad[i] ^= 0x36; @@ -1640,7 +1640,7 @@ static void __rtl_digest_ipadHMAC_MD5 (ContextHMAC_MD5 * ctx) */ static void __rtl_digest_opadHMAC_MD5 (ContextHMAC_MD5 * ctx) { - register sal_uInt32 i; + sal_uInt32 i; for (i = 0; i < DIGEST_CBLOCK_HMAC_MD5; i++) ctx->m_opad[i] ^= 0x5c; @@ -1857,7 +1857,7 @@ static void __rtl_digest_initHMAC_SHA1 (ContextHMAC_SHA1 * ctx) */ static void __rtl_digest_ipadHMAC_SHA1 (ContextHMAC_SHA1 * ctx) { - register sal_uInt32 i; + sal_uInt32 i; for (i = 0; i < DIGEST_CBLOCK_HMAC_SHA1; i++) ctx->m_opad[i] ^= 0x36; @@ -1872,7 +1872,7 @@ static void __rtl_digest_ipadHMAC_SHA1 (ContextHMAC_SHA1 * ctx) */ static void __rtl_digest_opadHMAC_SHA1 (ContextHMAC_SHA1 * ctx) { - register sal_uInt32 i; + sal_uInt32 i; for (i = 0; i < DIGEST_CBLOCK_HMAC_SHA1; i++) ctx->m_opad[i] ^= 0x5c; @@ -2053,7 +2053,7 @@ static void __rtl_digest_updatePBKDF2 ( { /* T_i = F (P, S, c, i) */ sal_uInt8 U[DIGEST_CBLOCK_PBKDF2]; - register sal_uInt32 i, k; + sal_uInt32 i, k; /* U_(1) = PRF (P, S || INDEX) */ rtl_digest_updateHMAC_SHA1 (hDigest, pSaltData, nSaltLen); diff --git a/sal/rtl/source/random.cxx b/sal/rtl/source/random.cxx index a8b452ac439b..774e8eb72510 100644 --- a/sal/rtl/source/random.cxx +++ b/sal/rtl/source/random.cxx @@ -105,7 +105,7 @@ static void __rtl_random_readPool ( */ static double __rtl_random_data (RandomData_Impl *pImpl) { - register double random; + double random; RTL_RANDOM_RNG (pImpl->m_nX, pImpl->m_nY, pImpl->m_nZ); random = (((double)(pImpl->m_nX) / 30328.0) + -- cgit From e2c60649102a9840eff36b35813906d7cbb95d4b Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 31 Oct 2011 20:09:24 +0100 Subject: Moved sal/rtl/source/alloc_* files from C to C++, for easier maintenance. --- sal/inc/internal/rtl_locale_init.h | 49 - sal/inc/internal/rtllifecycle.h | 67 ++ sal/osl/w32/dllentry.c | 6 +- sal/rtl/source/alloc_arena.c | 1362 --------------------------- sal/rtl/source/alloc_arena.cxx | 1360 +++++++++++++++++++++++++++ sal/rtl/source/alloc_arena.h | 140 --- sal/rtl/source/alloc_arena.hxx | 129 +++ sal/rtl/source/alloc_cache.c | 1767 ------------------------------------ sal/rtl/source/alloc_cache.cxx | 1759 +++++++++++++++++++++++++++++++++++ sal/rtl/source/alloc_cache.h | 185 ---- sal/rtl/source/alloc_cache.hxx | 171 ++++ sal/rtl/source/alloc_fini.cxx | 17 +- sal/rtl/source/alloc_global.c | 386 -------- sal/rtl/source/alloc_global.cxx | 386 ++++++++ sal/rtl/source/alloc_impl.h | 284 ------ sal/rtl/source/alloc_impl.hxx | 275 ++++++ sal/rtl/source/locale.cxx | 2 +- 17 files changed, 4156 insertions(+), 4189 deletions(-) delete mode 100644 sal/inc/internal/rtl_locale_init.h create mode 100644 sal/inc/internal/rtllifecycle.h delete mode 100644 sal/rtl/source/alloc_arena.c create mode 100644 sal/rtl/source/alloc_arena.cxx delete mode 100644 sal/rtl/source/alloc_arena.h create mode 100644 sal/rtl/source/alloc_arena.hxx delete mode 100644 sal/rtl/source/alloc_cache.c create mode 100644 sal/rtl/source/alloc_cache.cxx delete mode 100644 sal/rtl/source/alloc_cache.h create mode 100644 sal/rtl/source/alloc_cache.hxx delete mode 100644 sal/rtl/source/alloc_global.c create mode 100644 sal/rtl/source/alloc_global.cxx delete mode 100644 sal/rtl/source/alloc_impl.h create mode 100644 sal/rtl/source/alloc_impl.hxx diff --git a/sal/inc/internal/rtl_locale_init.h b/sal/inc/internal/rtl_locale_init.h deleted file mode 100644 index 816ba56f042a..000000000000 --- a/sal/inc/internal/rtl_locale_init.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * Version: MPL 1.1 / GPLv3+ / LGPLv3+ - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License or as specified alternatively below. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * Major Contributor(s): - * [ Copyright (C) 2011 Stephan Bergmann, Red Hat (initial - * developer) ] - * - * All Rights Reserved. - * - * For minor contributions see the git repository. - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 3 or later (the "GPLv3+"), or - * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), - * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable - * instead of those above. - */ - -#ifndef INCLUDED_SAL_INTERNAL_RTL_LOCALE_INIT_H -#define INCLUDED_SAL_INTERNAL_RTL_LOCALE_INIT_H - -#if defined __cplusplus -extern "C" { -#endif - -void rtl_locale_init(); - -void rtl_locale_fini(); - -void ensureLocaleSingleton(); - -#if defined __cplusplus -} -#endif - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/inc/internal/rtllifecycle.h b/sal/inc/internal/rtllifecycle.h new file mode 100644 index 000000000000..6e5ea81f97fd --- /dev/null +++ b/sal/inc/internal/rtllifecycle.h @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License or as specified alternatively below. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * Major Contributor(s): + * [ Copyright (C) 2011 Stephan Bergmann, Red Hat (initial + * developer) ] + * + * All Rights Reserved. + * + * For minor contributions see the git repository. + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 3 or later (the "GPLv3+"), or + * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), + * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable + * instead of those above. + */ + +#ifndef INCLUDED_SAL_INTERNAL_RTLLIFECYCLE_H +#define INCLUDED_SAL_INTERNAL_RTLLIFECYCLE_H + +#if defined __cplusplus +extern "C" { +#endif + +void rtl_arena_init(); + +void rtl_arena_fini(); + +void ensureArenaSingleton(); + +void rtl_cache_init(); + +void rtl_cache_fini(); + +void ensureCacheSingleton(); + +void rtl_memory_init(); + +void rtl_memory_fini(); + +void ensureMemorySingleton(); + +void rtl_locale_init(); + +void rtl_locale_fini(); + +void ensureLocaleSingleton(); + +#if defined __cplusplus +} +#endif + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/dllentry.c b/sal/osl/w32/dllentry.c index f4e63dc9e0c6..0267216f0966 100644 --- a/sal/osl/w32/dllentry.c +++ b/sal/osl/w32/dllentry.c @@ -44,7 +44,7 @@ #include #include -#include "internal/rtl_locale_init.h" +#include "internal/rtllifecycle.h" //------------------------------------------------------------------------------ // externals @@ -56,10 +56,6 @@ extern CRITICAL_SECTION g_ThreadKeyListCS; extern oslMutex g_Mutex; extern oslMutex g_CurrentDirectoryMutex; -extern void rtl_memory_fini (void); -extern void rtl_cache_fini (void); -extern void rtl_arena_fini (void); - #ifdef __MINGW32__ typedef void (*func_ptr) (void); diff --git a/sal/rtl/source/alloc_arena.c b/sal/rtl/source/alloc_arena.c deleted file mode 100644 index 1585273ccffc..000000000000 --- a/sal/rtl/source/alloc_arena.c +++ /dev/null @@ -1,1362 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#define _BSD_SOURCE /* sys/mman.h: MAP_ANON */ -#include "alloc_arena.h" - -#include "alloc_impl.h" -#include "internal/once.h" -#include "sal/macros.h" -#include "osl/diagnose.h" - -#include -#include - -extern AllocMode alloc_mode; - -/* ================================================================= * - * - * arena internals. - * - * ================================================================= */ - -/** g_arena_list - * @internal - */ -struct rtl_arena_list_st -{ - rtl_memory_lock_type m_lock; - rtl_arena_type m_arena_head; -}; - -static struct rtl_arena_list_st g_arena_list; - - -/** gp_arena_arena - * provided for arena_type allocations, and hash_table resizing. - * - * @internal - */ -static rtl_arena_type * gp_arena_arena = 0; - - -/** gp_machdep_arena - * - * Low level virtual memory (pseudo) arena - * (platform dependent implementation) - * - * @internal - */ -static rtl_arena_type * gp_machdep_arena = 0; - - -static void * -SAL_CALL rtl_machdep_alloc ( - rtl_arena_type * pArena, - sal_Size * pSize -); - -static void -SAL_CALL rtl_machdep_free ( - rtl_arena_type * pArena, - void * pAddr, - sal_Size nSize -); - -static sal_Size -rtl_machdep_pagesize (void); - - -/** gp_default_arena - */ -rtl_arena_type * gp_default_arena = 0; - - -/* ================================================================= */ - -/** rtl_arena_segment_constructor() - */ -static int -rtl_arena_segment_constructor (void * obj) -{ - rtl_arena_segment_type * segment = (rtl_arena_segment_type*)(obj); - - QUEUE_START_NAMED(segment, s); - QUEUE_START_NAMED(segment, f); - - return (1); -} - - -/** rtl_arena_segment_destructor() - */ -static void -rtl_arena_segment_destructor (void * obj) -{ -#if OSL_DEBUG_LEVEL == 0 - (void) obj; /* unused */ -#else /* OSL_DEBUG_LEVEL */ - rtl_arena_segment_type * segment = (rtl_arena_segment_type*)(obj); - - OSL_ASSERT(QUEUE_STARTED_NAMED(segment, s)); - OSL_ASSERT(QUEUE_STARTED_NAMED(segment, f)); -#endif /* OSL_DEBUG_LEVEL */ -} - -/* ================================================================= */ - -/** rtl_arena_segment_populate() - * - * @precond arena->m_lock acquired. - */ -static int -rtl_arena_segment_populate ( - rtl_arena_type * arena -) -{ - rtl_arena_segment_type *span; - sal_Size size = rtl_machdep_pagesize(); - - span = rtl_machdep_alloc(gp_machdep_arena, &size); - if (span != 0) - { - rtl_arena_segment_type *first, *last, *head; - sal_Size count = size / sizeof(rtl_arena_segment_type); - - /* insert onto reserve span list */ - QUEUE_INSERT_TAIL_NAMED(&(arena->m_segment_reserve_span_head), span, s); - QUEUE_START_NAMED(span, f); - span->m_addr = (sal_uIntPtr)(span); - span->m_size = size; - span->m_type = RTL_ARENA_SEGMENT_TYPE_SPAN; - - /* insert onto reserve list */ - head = &(arena->m_segment_reserve_head); - for (first = span + 1, last = span + count; first < last; ++first) - { - QUEUE_INSERT_TAIL_NAMED(head, first, s); - QUEUE_START_NAMED(first, f); - first->m_addr = 0; - first->m_size = 0; - first->m_type = 0; - } - } - return (span != 0); -} - - -/** rtl_arena_segment_get() - * - * @precond arena->m_lock acquired. - * @precond (*ppSegment == 0) - */ -static RTL_MEMORY_INLINE void -rtl_arena_segment_get ( - rtl_arena_type * arena, - rtl_arena_segment_type ** ppSegment -) -{ - rtl_arena_segment_type * head; - - OSL_ASSERT(*ppSegment == 0); - - head = &(arena->m_segment_reserve_head); - if ((head->m_snext != head) || rtl_arena_segment_populate (arena)) - { - (*ppSegment) = head->m_snext; - QUEUE_REMOVE_NAMED((*ppSegment), s); - } -} - -#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) -#pragma inline(rtl_arena_segment_get) -#endif - - -/** rtl_arena_segment_put() - * - * @precond arena->m_lock acquired. - * @postcond (*ppSegment == 0) - */ -static RTL_MEMORY_INLINE void -rtl_arena_segment_put ( - rtl_arena_type * arena, - rtl_arena_segment_type ** ppSegment -) -{ - rtl_arena_segment_type * head; - - OSL_ASSERT(QUEUE_STARTED_NAMED((*ppSegment), s)); - OSL_ASSERT(QUEUE_STARTED_NAMED((*ppSegment), f)); - - (*ppSegment)->m_addr = 0; - (*ppSegment)->m_size = 0; - - OSL_ASSERT((*ppSegment)->m_type != RTL_ARENA_SEGMENT_TYPE_HEAD); - (*ppSegment)->m_type = 0; - - /* keep as reserve */ - head = &(arena->m_segment_reserve_head); - QUEUE_INSERT_HEAD_NAMED(head, (*ppSegment), s); - - /* clear */ - (*ppSegment) = 0; -} - -#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) -#pragma inline(rtl_arena_segment_put) -#endif - -/* ================================================================= */ - -/** rtl_arena_freelist_insert() - * - * @precond arena->m_lock acquired. - */ -static RTL_MEMORY_INLINE void -rtl_arena_freelist_insert ( - rtl_arena_type * arena, - rtl_arena_segment_type * segment -) -{ - rtl_arena_segment_type * head; - - head = &(arena->m_freelist_head[highbit(segment->m_size) - 1]); - QUEUE_INSERT_TAIL_NAMED(head, segment, f); - - arena->m_freelist_bitmap |= head->m_size; -} - -#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) -#pragma inline(rtl_arena_freelist_insert) -#endif /* __SUNPRO_C */ - - -/** rtl_arena_freelist_remove() - * - * @precond arena->m_lock acquired. - */ -static RTL_MEMORY_INLINE void -rtl_arena_freelist_remove ( - rtl_arena_type * arena, - rtl_arena_segment_type * segment -) -{ - if ((segment->m_fnext->m_type == RTL_ARENA_SEGMENT_TYPE_HEAD) && - (segment->m_fprev->m_type == RTL_ARENA_SEGMENT_TYPE_HEAD) ) - { - rtl_arena_segment_type * head; - - head = segment->m_fprev; - OSL_ASSERT(arena->m_freelist_bitmap & head->m_size); - arena->m_freelist_bitmap ^= head->m_size; - } - QUEUE_REMOVE_NAMED(segment, f); -} - -#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) -#pragma inline(rtl_arena_freelist_remove) -#endif /* __SUNPRO_C */ - - -/* ================================================================= */ - -/** RTL_ARENA_HASH_INDEX() - */ -#define RTL_ARENA_HASH_INDEX_IMPL(a, s, q, m) \ - ((((a) + ((a) >> (s)) + ((a) >> ((s) << 1))) >> (q)) & (m)) - -#define RTL_ARENA_HASH_INDEX(arena, addr) \ - RTL_ARENA_HASH_INDEX_IMPL((addr), (arena)->m_hash_shift, (arena)->m_quantum_shift, ((arena)->m_hash_size - 1)) - -/** rtl_arena_hash_rescale() - * - * @precond arena->m_lock released. - */ -static void -rtl_arena_hash_rescale ( - rtl_arena_type * arena, - sal_Size new_size -) -{ - rtl_arena_segment_type ** new_table; - sal_Size new_bytes; - - new_bytes = new_size * sizeof(rtl_arena_segment_type*); - new_table = (rtl_arena_segment_type **)rtl_arena_alloc (gp_arena_arena, &new_bytes); - - if (new_table != 0) - { - rtl_arena_segment_type ** old_table; - sal_Size old_size, i; - - memset (new_table, 0, new_bytes); - - RTL_MEMORY_LOCK_ACQUIRE(&(arena->m_lock)); - - old_table = arena->m_hash_table; - old_size = arena->m_hash_size; - - OSL_TRACE( - "rtl_arena_hash_rescale(\"%s\"): " - "nseg: %"PRIu64" (ave: %"PRIu64"), frees: %"PRIu64" " - "[old_size: %lu, new_size: %lu]", - arena->m_name, - arena->m_stats.m_alloc - arena->m_stats.m_free, - (arena->m_stats.m_alloc - arena->m_stats.m_free) >> arena->m_hash_shift, - arena->m_stats.m_free, - old_size, new_size - ); - - arena->m_hash_table = new_table; - arena->m_hash_size = new_size; - arena->m_hash_shift = highbit(arena->m_hash_size) - 1; - - for (i = 0; i < old_size; i++) - { - rtl_arena_segment_type * curr = old_table[i]; - while (curr != 0) - { - rtl_arena_segment_type * next = curr->m_fnext; - rtl_arena_segment_type ** head; - - head = &(arena->m_hash_table[RTL_ARENA_HASH_INDEX(arena, curr->m_addr)]); - curr->m_fnext = (*head); - (*head) = curr; - - curr = next; - } - old_table[i] = 0; - } - - RTL_MEMORY_LOCK_RELEASE(&(arena->m_lock)); - - if (old_table != arena->m_hash_table_0) - { - sal_Size old_bytes = old_size * sizeof(rtl_arena_segment_type*); - rtl_arena_free (gp_arena_arena, old_table, old_bytes); - } - } -} - - -/** rtl_arena_hash_insert() - * ...and update stats. - */ -static RTL_MEMORY_INLINE void -rtl_arena_hash_insert ( - rtl_arena_type * arena, - rtl_arena_segment_type * segment -) -{ - rtl_arena_segment_type ** ppSegment; - - ppSegment = &(arena->m_hash_table[RTL_ARENA_HASH_INDEX(arena, segment->m_addr)]); - - segment->m_fnext = (*ppSegment); - (*ppSegment) = segment; - - arena->m_stats.m_alloc += 1; - arena->m_stats.m_mem_alloc += segment->m_size; -} - -#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) -#pragma inline(rtl_arena_hash_insert) -#endif /* __SUNPRO_C */ - - -/** rtl_arena_hash_remove() - * ...and update stats. - */ -static rtl_arena_segment_type * -rtl_arena_hash_remove ( - rtl_arena_type * arena, - sal_uIntPtr addr, - sal_Size size -) -{ - rtl_arena_segment_type *segment, **segpp; - sal_Size lookups = 0; - -#if OSL_DEBUG_LEVEL == 0 - (void) size; /* unused */ -#endif /* OSL_DEBUG_LEVEL */ - - segpp = &(arena->m_hash_table[RTL_ARENA_HASH_INDEX(arena, addr)]); - while ((segment = *segpp) != 0) - { - if (segment->m_addr == addr) - { - *segpp = segment->m_fnext, segment->m_fnext = segment->m_fprev = segment; - break; - } - - /* update lookup miss stats */ - lookups += 1; - segpp = &(segment->m_fnext); - } - - OSL_POSTCOND(segment != 0, "rtl_arena_hash_remove(): bad free."); - if (segment != 0) - { - OSL_POSTCOND(segment->m_size == size, "rtl_arena_hash_remove(): wrong size."); - - arena->m_stats.m_free += 1; - arena->m_stats.m_mem_alloc -= segment->m_size; - - if (lookups > 1) - { - sal_Size nseg = (sal_Size)(arena->m_stats.m_alloc - arena->m_stats.m_free); - if (nseg > 4 * arena->m_hash_size) - { - if (!(arena->m_flags & RTL_ARENA_FLAG_RESCALE)) - { - sal_Size ave = nseg >> arena->m_hash_shift; - sal_Size new_size = arena->m_hash_size << (highbit(ave) - 1); - - arena->m_flags |= RTL_ARENA_FLAG_RESCALE; - RTL_MEMORY_LOCK_RELEASE(&(arena->m_lock)); - rtl_arena_hash_rescale (arena, new_size); - RTL_MEMORY_LOCK_ACQUIRE(&(arena->m_lock)); - arena->m_flags &= ~RTL_ARENA_FLAG_RESCALE; - } - } - } - } - - return (segment); -} - -/* ================================================================= */ - -/** rtl_arena_segment_alloc() - * allocate (and remove) segment from freelist - * - * @precond arena->m_lock acquired - * @precond (*ppSegment == 0) - */ -static int -rtl_arena_segment_alloc ( - rtl_arena_type * arena, - sal_Size size, - rtl_arena_segment_type ** ppSegment -) -{ - int index = 0; - - OSL_ASSERT(*ppSegment == 0); - if (!RTL_MEMORY_ISP2(size)) - { - int msb = highbit(size); - if (RTL_ARENA_FREELIST_SIZE == SAL_INT_CAST(size_t, msb)) - { - /* highest possible freelist: fall back to first fit */ - rtl_arena_segment_type *head, *segment; - - head = &(arena->m_freelist_head[msb - 1]); - for (segment = head->m_fnext; segment != head; segment = segment->m_fnext) - { - if (segment->m_size >= size) - { - /* allocate first fit segment */ - (*ppSegment) = segment; - break; - } - } - goto dequeue_and_leave; - } - - /* roundup to next power of 2 */ - size = (1UL << msb); - } - - index = lowbit(RTL_MEMORY_P2ALIGN(arena->m_freelist_bitmap, size)); - if (index > 0) - { - /* instant fit: allocate first free segment */ - rtl_arena_segment_type *head; - - head = &(arena->m_freelist_head[index - 1]); - (*ppSegment) = head->m_fnext; - OSL_ASSERT((*ppSegment) != head); - } - -dequeue_and_leave: - if (*ppSegment != 0) - { - /* remove from freelist */ - rtl_arena_freelist_remove (arena, (*ppSegment)); - } - return (*ppSegment != 0); -} - - -/** rtl_arena_segment_create() - * import new (span) segment from source arena - * - * @precond arena->m_lock acquired - * @precond (*ppSegment == 0) - */ -static int -rtl_arena_segment_create ( - rtl_arena_type * arena, - sal_Size size, - rtl_arena_segment_type ** ppSegment -) -{ - OSL_ASSERT((*ppSegment) == 0); - if (arena->m_source_alloc != 0) - { - rtl_arena_segment_get (arena, ppSegment); - if (*ppSegment != 0) - { - rtl_arena_segment_type * span = 0; - rtl_arena_segment_get (arena, &span); - if (span != 0) - { - /* import new span from source arena */ - RTL_MEMORY_LOCK_RELEASE(&(arena->m_lock)); - - span->m_size = size; - span->m_addr = (sal_uIntPtr)(arena->m_source_alloc)( - arena->m_source_arena, &(span->m_size)); - - RTL_MEMORY_LOCK_ACQUIRE(&(arena->m_lock)); - if (span->m_addr != 0) - { - /* insert onto segment list, update stats */ - span->m_type = RTL_ARENA_SEGMENT_TYPE_SPAN; - QUEUE_INSERT_HEAD_NAMED(&(arena->m_segment_head), span, s); - arena->m_stats.m_mem_total += span->m_size; - - (*ppSegment)->m_addr = span->m_addr; - (*ppSegment)->m_size = span->m_size; - (*ppSegment)->m_type = RTL_ARENA_SEGMENT_TYPE_FREE; - QUEUE_INSERT_HEAD_NAMED(span, (*ppSegment), s); - - /* report success */ - return (1); - } - rtl_arena_segment_put (arena, &span); - } - rtl_arena_segment_put (arena, ppSegment); - } - } - return (0); -} - - -/** rtl_arena_segment_coalesce() - * mark as free and join with adjacent free segment(s) - * - * @precond arena->m_lock acquired - * @precond segment marked 'used' - */ -static void -rtl_arena_segment_coalesce ( - rtl_arena_type * arena, - rtl_arena_segment_type * segment -) -{ - rtl_arena_segment_type *next, *prev; - - /* mark segment free */ - OSL_ASSERT(segment->m_type == RTL_ARENA_SEGMENT_TYPE_USED); - segment->m_type = RTL_ARENA_SEGMENT_TYPE_FREE; - - /* try to merge w/ next segment */ - next = segment->m_snext; - if (next->m_type == RTL_ARENA_SEGMENT_TYPE_FREE) - { - OSL_ASSERT(segment->m_addr + segment->m_size == next->m_addr); - segment->m_size += next->m_size; - - /* remove from freelist */ - rtl_arena_freelist_remove (arena, next); - - /* remove from segment list */ - QUEUE_REMOVE_NAMED(next, s); - - /* release segment descriptor */ - rtl_arena_segment_put (arena, &next); - } - - /* try to merge w/ prev segment */ - prev = segment->m_sprev; - if (prev->m_type == RTL_ARENA_SEGMENT_TYPE_FREE) - { - OSL_ASSERT(prev->m_addr + prev->m_size == segment->m_addr); - segment->m_addr = prev->m_addr; - segment->m_size += prev->m_size; - - /* remove from freelist */ - rtl_arena_freelist_remove (arena, prev); - - /* remove from segment list */ - QUEUE_REMOVE_NAMED(prev, s); - - /* release segment descriptor */ - rtl_arena_segment_put (arena, &prev); - } -} - -/* ================================================================= */ - -/** rtl_arena_constructor() - */ -static void -rtl_arena_constructor (void * obj) -{ - rtl_arena_type * arena = (rtl_arena_type*)(obj); - rtl_arena_segment_type * head; - size_t i; - - memset (arena, 0, sizeof(rtl_arena_type)); - - QUEUE_START_NAMED(arena, arena_); - - (void) RTL_MEMORY_LOCK_INIT(&(arena->m_lock)); - - head = &(arena->m_segment_reserve_span_head); - rtl_arena_segment_constructor (head); - head->m_type = RTL_ARENA_SEGMENT_TYPE_HEAD; - - head = &(arena->m_segment_reserve_head); - rtl_arena_segment_constructor (head); - head->m_type = RTL_ARENA_SEGMENT_TYPE_HEAD; - - head = &(arena->m_segment_head); - rtl_arena_segment_constructor (head); - head->m_type = RTL_ARENA_SEGMENT_TYPE_HEAD; - - for (i = 0; i < RTL_ARENA_FREELIST_SIZE; i++) - { - head = &(arena->m_freelist_head[i]); - rtl_arena_segment_constructor (head); - - head->m_size = (1UL << i); - head->m_type = RTL_ARENA_SEGMENT_TYPE_HEAD; - } - - arena->m_hash_table = arena->m_hash_table_0; - arena->m_hash_size = RTL_ARENA_HASH_SIZE; - arena->m_hash_shift = highbit(arena->m_hash_size) - 1; -} - - -/** rtl_arena_destructor() - */ -static void -rtl_arena_destructor (void * obj) -{ - rtl_arena_type * arena = (rtl_arena_type*)(obj); - rtl_arena_segment_type * head; - size_t i; - - OSL_ASSERT(QUEUE_STARTED_NAMED(arena, arena_)); - - RTL_MEMORY_LOCK_DESTROY(&(arena->m_lock)); - - head = &(arena->m_segment_reserve_span_head); - OSL_ASSERT(head->m_type == RTL_ARENA_SEGMENT_TYPE_HEAD); - rtl_arena_segment_destructor (head); - - head = &(arena->m_segment_reserve_head); - OSL_ASSERT(head->m_type == RTL_ARENA_SEGMENT_TYPE_HEAD); - rtl_arena_segment_destructor (head); - - head = &(arena->m_segment_head); - OSL_ASSERT(head->m_type == RTL_ARENA_SEGMENT_TYPE_HEAD); - rtl_arena_segment_destructor (head); - - for (i = 0; i < RTL_ARENA_FREELIST_SIZE; i++) - { - head = &(arena->m_freelist_head[i]); - - OSL_ASSERT(head->m_size == (1UL << i)); - OSL_ASSERT(head->m_type == RTL_ARENA_SEGMENT_TYPE_HEAD); - - rtl_arena_segment_destructor (head); - } - - OSL_ASSERT(arena->m_hash_table == arena->m_hash_table_0); - OSL_ASSERT(arena->m_hash_size == RTL_ARENA_HASH_SIZE); - OSL_ASSERT( - arena->m_hash_shift == - SAL_INT_CAST(unsigned, highbit(arena->m_hash_size) - 1)); -} - -/* ================================================================= */ - -/** rtl_arena_activate() - */ -static rtl_arena_type * -rtl_arena_activate ( - rtl_arena_type * arena, - const char * name, - sal_Size quantum, - sal_Size quantum_cache_max, - rtl_arena_type * source_arena, - void * (SAL_CALL * source_alloc)(rtl_arena_type *, sal_Size *), - void (SAL_CALL * source_free) (rtl_arena_type *, void *, sal_Size) -) -{ - OSL_ASSERT(arena != 0); - if (arena != 0) - { - (void) snprintf (arena->m_name, sizeof(arena->m_name), "%s", name); - - if (!RTL_MEMORY_ISP2(quantum)) - { - /* roundup to next power of 2 */ - quantum = (1UL << highbit(quantum)); - } - quantum_cache_max = RTL_MEMORY_P2ROUNDUP(quantum_cache_max, quantum); - - arena->m_quantum = quantum; - arena->m_quantum_shift = highbit(arena->m_quantum) - 1; - arena->m_qcache_max = quantum_cache_max; - - arena->m_source_arena = source_arena; - arena->m_source_alloc = source_alloc; - arena->m_source_free = source_free; - - if (arena->m_qcache_max > 0) - { - char name[RTL_ARENA_NAME_LENGTH + 1]; - int i, n = (arena->m_qcache_max >> arena->m_quantum_shift); - - sal_Size size = n * sizeof(rtl_cache_type*); - arena->m_qcache_ptr = (rtl_cache_type**)rtl_arena_alloc (gp_arena_arena, &size); - if (!(arena->m_qcache_ptr)) - { - /* out of memory */ - return (0); - } - for (i = 1; i <= n; i++) - { - size = i * arena->m_quantum; - (void) snprintf (name, sizeof(name), "%s_%lu", arena->m_name, size); - arena->m_qcache_ptr[i - 1] = rtl_cache_create(name, size, 0, NULL, NULL, NULL, NULL, arena, RTL_CACHE_FLAG_QUANTUMCACHE); - } - } - - /* insert into arena list */ - RTL_MEMORY_LOCK_ACQUIRE(&(g_arena_list.m_lock)); - QUEUE_INSERT_TAIL_NAMED(&(g_arena_list.m_arena_head), arena, arena_); - RTL_MEMORY_LOCK_RELEASE(&(g_arena_list.m_lock)); - } - return (arena); -} - -/** rtl_arena_deactivate() - */ -static void -rtl_arena_deactivate ( - rtl_arena_type * arena -) -{ - rtl_arena_segment_type * head, * segment; - - /* remove from arena list */ - RTL_MEMORY_LOCK_ACQUIRE(&(g_arena_list.m_lock)); - QUEUE_REMOVE_NAMED(arena, arena_); - RTL_MEMORY_LOCK_RELEASE(&(g_arena_list.m_lock)); - - /* cleanup quantum cache(s) */ - if ((arena->m_qcache_max > 0) && (arena->m_qcache_ptr != 0)) - { - int i, n = (arena->m_qcache_max >> arena->m_quantum_shift); - for (i = 1; i <= n; i++) - { - if (arena->m_qcache_ptr[i - 1] != 0) - { - rtl_cache_destroy (arena->m_qcache_ptr[i - 1]); - arena->m_qcache_ptr[i - 1] = 0; - } - } - rtl_arena_free ( - gp_arena_arena, - arena->m_qcache_ptr, - n * sizeof(rtl_cache_type*)); - - arena->m_qcache_ptr = 0; - } - - /* check for leaked segments */ - OSL_TRACE( - "rtl_arena_deactivate(\"%s\"): " - "allocs: %"PRIu64", frees: %"PRIu64"; total: %lu, used: %lu", - arena->m_name, - arena->m_stats.m_alloc, arena->m_stats.m_free, - arena->m_stats.m_mem_total, arena->m_stats.m_mem_alloc - ); - if (arena->m_stats.m_alloc > arena->m_stats.m_free) - { - sal_Size i, n; - - OSL_TRACE( - "rtl_arena_deactivate(\"%s\"): " - "cleaning up %"PRIu64" leaked segment(s) [%lu bytes]", - arena->m_name, - arena->m_stats.m_alloc - arena->m_stats.m_free, - arena->m_stats.m_mem_alloc - ); - - /* cleanup still used segment(s) */ - for (i = 0, n = arena->m_hash_size; i < n; i++) - { - while ((segment = arena->m_hash_table[i]) != 0) - { - /* pop from hash table */ - arena->m_hash_table[i] = segment->m_fnext, segment->m_fnext = segment->m_fprev = segment; - - /* coalesce w/ adjacent free segment(s) */ - rtl_arena_segment_coalesce (arena, segment); - - /* insert onto freelist */ - rtl_arena_freelist_insert (arena, segment); - } - } - } - - /* cleanup hash table */ - if (arena->m_hash_table != arena->m_hash_table_0) - { - rtl_arena_free ( - gp_arena_arena, - arena->m_hash_table, - arena->m_hash_size * sizeof(rtl_arena_segment_type*)); - - arena->m_hash_table = arena->m_hash_table_0; - arena->m_hash_size = RTL_ARENA_HASH_SIZE; - arena->m_hash_shift = highbit(arena->m_hash_size) - 1; - } - - /* cleanup segment list */ - head = &(arena->m_segment_head); - for (segment = head->m_snext; segment != head; segment = head->m_snext) - { - if (segment->m_type == RTL_ARENA_SEGMENT_TYPE_FREE) - { - /* remove from freelist */ - rtl_arena_freelist_remove (arena, segment); - } - else - { - /* can have only free and span segments here */ - OSL_ASSERT(segment->m_type == RTL_ARENA_SEGMENT_TYPE_SPAN); - } - - /* remove from segment list */ - QUEUE_REMOVE_NAMED(segment, s); - - /* release segment descriptor */ - rtl_arena_segment_put (arena, &segment); - } - - /* cleanup segment reserve list */ - head = &(arena->m_segment_reserve_head); - for (segment = head->m_snext; segment != head; segment = head->m_snext) - { - /* remove from segment list */ - QUEUE_REMOVE_NAMED(segment, s); - } - - /* cleanup segment reserve span(s) */ - head = &(arena->m_segment_reserve_span_head); - for (segment = head->m_snext; segment != head; segment = head->m_snext) - { - /* can have only span segments here */ - OSL_ASSERT(segment->m_type == RTL_ARENA_SEGMENT_TYPE_SPAN); - - /* remove from segment list */ - QUEUE_REMOVE_NAMED(segment, s); - - /* return span to g_machdep_arena */ - rtl_machdep_free (gp_machdep_arena, (void*)(segment->m_addr), segment->m_size); - } -} - -/* ================================================================= * - * - * arena implementation. - * - * ================================================================= */ - -extern void ensureArenaSingleton(); - -/** rtl_arena_create() - */ -rtl_arena_type * -SAL_CALL rtl_arena_create ( - const char * name, - sal_Size quantum, - sal_Size quantum_cache_max, - rtl_arena_type * source_arena, - void * (SAL_CALL * source_alloc)(rtl_arena_type *, sal_Size *), - void (SAL_CALL * source_free) (rtl_arena_type *, void *, sal_Size), - int flags -) SAL_THROW_EXTERN_C() -{ - rtl_arena_type * result = 0; - sal_Size size = sizeof(rtl_arena_type); - - (void) flags; /* unused */ - -try_alloc: - result = (rtl_arena_type*)rtl_arena_alloc (gp_arena_arena, &size); - if (result != 0) - { - rtl_arena_type * arena = result; - VALGRIND_CREATE_MEMPOOL(arena, 0, 0); - rtl_arena_constructor (arena); - - if (!source_arena) - { - OSL_ASSERT(gp_default_arena != 0); - source_arena = gp_default_arena; - } - - result = rtl_arena_activate ( - arena, - name, - quantum, - quantum_cache_max, - source_arena, - source_alloc, - source_free - ); - - if (result == 0) - { - rtl_arena_deactivate (arena); - rtl_arena_destructor (arena); - VALGRIND_DESTROY_MEMPOOL(arena); - rtl_arena_free (gp_arena_arena, arena, size); - } - } - else if (gp_arena_arena == 0) - { - ensureArenaSingleton(); - if (gp_arena_arena) - { - /* try again */ - goto try_alloc; - } - } - return (result); -} - -/** rtl_arena_destroy() - */ -void -SAL_CALL rtl_arena_destroy ( - rtl_arena_type * arena -) -{ - if (arena != 0) - { - rtl_arena_deactivate (arena); - rtl_arena_destructor (arena); - VALGRIND_DESTROY_MEMPOOL(arena); - rtl_arena_free (gp_arena_arena, arena, sizeof(rtl_arena_type)); - } -} - -/** rtl_arena_alloc() - */ -void * -SAL_CALL rtl_arena_alloc ( - rtl_arena_type * arena, - sal_Size * pSize -) SAL_THROW_EXTERN_C() -{ - void * addr = 0; - - if ((arena != 0) && (pSize != 0)) - { - sal_Size size; - - if (alloc_mode == AMode_SYSTEM) - return rtl_allocateMemory(*pSize); - - size = RTL_MEMORY_ALIGN((*pSize), arena->m_quantum); - if (size > arena->m_qcache_max) - { - /* allocate from segment list */ - rtl_arena_segment_type *segment = 0; - - RTL_MEMORY_LOCK_ACQUIRE(&(arena->m_lock)); - if (rtl_arena_segment_alloc (arena, size, &segment) || - rtl_arena_segment_create(arena, size, &segment) ) - { - /* shrink to fit */ - sal_Size oversize; - - /* mark segment used */ - OSL_ASSERT(segment->m_type == RTL_ARENA_SEGMENT_TYPE_FREE); - segment->m_type = RTL_ARENA_SEGMENT_TYPE_USED; - - /* resize */ - OSL_ASSERT(segment->m_size >= size); - oversize = segment->m_size - size; - if (oversize >= SAL_MAX(arena->m_quantum, arena->m_qcache_max)) - { - rtl_arena_segment_type * remainder = 0; - rtl_arena_segment_get (arena, &remainder); - if (remainder != 0) - { - segment->m_size = size; - - remainder->m_addr = segment->m_addr + segment->m_size; - remainder->m_size = oversize; - remainder->m_type = RTL_ARENA_SEGMENT_TYPE_FREE; - QUEUE_INSERT_HEAD_NAMED(segment, remainder, s); - - rtl_arena_freelist_insert (arena, remainder); - } - } - - rtl_arena_hash_insert (arena, segment); - - /* DEBUG ONLY: mark allocated, undefined */ - OSL_DEBUG_ONLY(memset((void*)(segment->m_addr), 0x77777777, segment->m_size)); - VALGRIND_MEMPOOL_ALLOC(arena, segment->m_addr, segment->m_size); - - (*pSize) = segment->m_size; - addr = (void*)(segment->m_addr); - } - RTL_MEMORY_LOCK_RELEASE(&(arena->m_lock)); - } - else if (size > 0) - { - /* allocate from quantum cache(s) */ - int index = (size >> arena->m_quantum_shift) - 1; - OSL_ASSERT (arena->m_qcache_ptr[index] != 0); - - addr = rtl_cache_alloc (arena->m_qcache_ptr[index]); - if (addr != 0) - (*pSize) = size; - } - } - return (addr); -} - -/** rtl_arena_free() - */ -void -SAL_CALL rtl_arena_free ( - rtl_arena_type * arena, - void * addr, - sal_Size size -) SAL_THROW_EXTERN_C() -{ - if (arena != 0) - { - if (alloc_mode == AMode_SYSTEM) - { - rtl_freeMemory(addr); - return; - } - - size = RTL_MEMORY_ALIGN(size, arena->m_quantum); - if (size > arena->m_qcache_max) - { - /* free to segment list */ - rtl_arena_segment_type * segment; - - RTL_MEMORY_LOCK_ACQUIRE(&(arena->m_lock)); - - segment = rtl_arena_hash_remove (arena, (sal_uIntPtr)(addr), size); - if (segment != 0) - { - rtl_arena_segment_type *next, *prev; - - /* DEBUG ONLY: mark unallocated, undefined */ - VALGRIND_MEMPOOL_FREE(arena, segment->m_addr); - /* OSL_DEBUG_ONLY() */ RTL_VALGRIND_IGNORE_VAL VALGRIND_MAKE_MEM_UNDEFINED(segment->m_addr, segment->m_size); - OSL_DEBUG_ONLY(memset((void*)(segment->m_addr), 0x33333333, segment->m_size)); - - /* coalesce w/ adjacent free segment(s) */ - rtl_arena_segment_coalesce (arena, segment); - - /* determine (new) next and prev segment */ - next = segment->m_snext, prev = segment->m_sprev; - - /* entire span free when prev is a span, and next is either a span or a list head */ - if (((prev->m_type == RTL_ARENA_SEGMENT_TYPE_SPAN)) && - ((next->m_type == RTL_ARENA_SEGMENT_TYPE_SPAN) || - (next->m_type == RTL_ARENA_SEGMENT_TYPE_HEAD)) ) - { - OSL_ASSERT((prev->m_addr == segment->m_addr) && - (prev->m_size == segment->m_size) ); - - if (arena->m_source_free) - { - addr = (void*)(prev->m_addr); - size = prev->m_size; - - /* remove from segment list */ - QUEUE_REMOVE_NAMED(segment, s); - - /* release segment descriptor */ - rtl_arena_segment_put (arena, &segment); - - /* remove from segment list */ - QUEUE_REMOVE_NAMED(prev, s); - - /* release (span) segment descriptor */ - rtl_arena_segment_put (arena, &prev); - - /* update stats, return span to source arena */ - arena->m_stats.m_mem_total -= size; - RTL_MEMORY_LOCK_RELEASE(&(arena->m_lock)); - - (arena->m_source_free)(arena->m_source_arena, addr, size); - return; - } - } - - /* insert onto freelist */ - rtl_arena_freelist_insert (arena, segment); - } - - RTL_MEMORY_LOCK_RELEASE(&(arena->m_lock)); - } - else if (size > 0) - { - /* free to quantum cache(s) */ - int index = (size >> arena->m_quantum_shift) - 1; - OSL_ASSERT (arena->m_qcache_ptr[index] != 0); - - rtl_cache_free (arena->m_qcache_ptr[index], addr); - } - } -} - -/* ================================================================= * - * - * machdep internals. - * - * ================================================================= */ - -#if defined(SAL_UNX) -#include -#elif defined(SAL_W32) -#define MAP_FAILED 0 -#endif /* SAL_UNX || SAL_W32 */ - -/** rtl_machdep_alloc() - */ -static void * -SAL_CALL rtl_machdep_alloc ( - rtl_arena_type * pArena, - sal_Size * pSize -) -{ - void * addr; - sal_Size size = (*pSize); - - OSL_PRECOND(pArena == gp_machdep_arena, "rtl_machdep_alloc(): invalid argument"); - -#if defined(SOLARIS) && defined(SPARC) - /* see @ mmap(2) man pages */ - size += (pArena->m_quantum + pArena->m_quantum); /* "red-zone" pages */ - if (size > (4 << 20)) - size = RTL_MEMORY_P2ROUNDUP(size, (4 << 20)); - else if (size > (512 << 10)) - size = RTL_MEMORY_P2ROUNDUP(size, (512 << 10)); - else - size = RTL_MEMORY_P2ROUNDUP(size, (64 << 10)); - size -= (pArena->m_quantum + pArena->m_quantum); /* "red-zone" pages */ -#else - /* default allocation granularity */ - size = RTL_MEMORY_P2ROUNDUP(size, SAL_MAX(pArena->m_quantum, 64 << 10)); -#endif - -#if defined(SAL_UNX) - addr = mmap (NULL, (size_t)(size), PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); -#elif defined(SAL_W32) - addr = VirtualAlloc (NULL, (SIZE_T)(size), MEM_COMMIT, PAGE_READWRITE); -#endif /* (SAL_UNX || SAL_W32) */ - - if (addr != MAP_FAILED) - { - pArena->m_stats.m_alloc += 1; - pArena->m_stats.m_mem_total += size; - pArena->m_stats.m_mem_alloc += size; - - (*pSize) = size; - return (addr); - } - return (NULL); -} - -/** rtl_machdep_free() - */ -static void -SAL_CALL rtl_machdep_free ( - rtl_arena_type * pArena, - void * pAddr, - sal_Size nSize -) -{ - OSL_PRECOND(pArena == gp_machdep_arena, "rtl_machdep_free(): invalid argument"); - - pArena->m_stats.m_free += 1; - pArena->m_stats.m_mem_total -= nSize; - pArena->m_stats.m_mem_alloc -= nSize; - -#if defined(SAL_UNX) - (void) munmap(pAddr, nSize); -#elif defined(SAL_W32) - (void) VirtualFree ((LPVOID)(pAddr), (SIZE_T)(0), MEM_RELEASE); -#endif /* (SAL_UNX || SAL_W32) */ -} - -/** rtl_machdep_pagesize() - */ -static sal_Size -rtl_machdep_pagesize (void) -{ -#if defined(SAL_UNX) -#if defined(FREEBSD) || defined(NETBSD) || defined(DRAGONFLY) - return ((sal_Size)getpagesize()); -#else /* POSIX */ - return ((sal_Size)sysconf(_SC_PAGESIZE)); -#endif /* xBSD || POSIX */ -#elif defined(SAL_W32) - SYSTEM_INFO info; - GetSystemInfo (&info); - return ((sal_Size)(info.dwPageSize)); -#endif /* (SAL_UNX || SAL_W32) */ -} - -/* ================================================================= * - * - * arena initialization. - * - * ================================================================= */ - -void -rtl_arena_init (void) -{ - { - /* list of arenas */ - RTL_MEMORY_LOCK_INIT(&(g_arena_list.m_lock)); - rtl_arena_constructor (&(g_arena_list.m_arena_head)); - } - { - /* machdep (pseudo) arena */ - static rtl_arena_type g_machdep_arena; - - OSL_ASSERT(gp_machdep_arena == 0); - VALGRIND_CREATE_MEMPOOL(&g_machdep_arena, 0, 0); - rtl_arena_constructor (&g_machdep_arena); - - gp_machdep_arena = rtl_arena_activate ( - &g_machdep_arena, - "rtl_machdep_arena", - rtl_machdep_pagesize(), - 0, /* no quantum caching */ - 0, 0, 0 /* no source */ - ); - OSL_ASSERT(gp_machdep_arena != 0); - } - { - /* default arena */ - static rtl_arena_type g_default_arena; - - OSL_ASSERT(gp_default_arena == 0); - VALGRIND_CREATE_MEMPOOL(&g_default_arena, 0, 0); - rtl_arena_constructor (&g_default_arena); - - gp_default_arena = rtl_arena_activate ( - &g_default_arena, - "rtl_default_arena", - rtl_machdep_pagesize(), - 0, /* no quantum caching */ - gp_machdep_arena, /* source */ - rtl_machdep_alloc, - rtl_machdep_free - ); - OSL_ASSERT(gp_default_arena != 0); - } - { - /* arena internal arena */ - static rtl_arena_type g_arena_arena; - - OSL_ASSERT(gp_arena_arena == 0); - VALGRIND_CREATE_MEMPOOL(&g_arena_arena, 0, 0); - rtl_arena_constructor (&g_arena_arena); - - gp_arena_arena = rtl_arena_activate ( - &g_arena_arena, - "rtl_arena_internal_arena", - 64, /* quantum */ - 0, /* no quantum caching */ - gp_default_arena, /* source */ - rtl_arena_alloc, - rtl_arena_free - ); - OSL_ASSERT(gp_arena_arena != 0); - } - OSL_TRACE("rtl_arena_init completed"); -} - -/* ================================================================= */ - -void -rtl_arena_fini (void) -{ - if (gp_arena_arena != 0) - { - rtl_arena_type * arena, * head; - - RTL_MEMORY_LOCK_ACQUIRE(&(g_arena_list.m_lock)); - head = &(g_arena_list.m_arena_head); - - for (arena = head->m_arena_next; arena != head; arena = arena->m_arena_next) - { - OSL_TRACE( - "rtl_arena_fini(\"%s\"): " - "allocs: %"PRIu64", frees: %"PRIu64"; total: %lu, used: %lu", - arena->m_name, - arena->m_stats.m_alloc, arena->m_stats.m_free, - arena->m_stats.m_mem_total, arena->m_stats.m_mem_alloc - ); - } - RTL_MEMORY_LOCK_RELEASE(&(g_arena_list.m_lock)); - } - OSL_TRACE("rtl_arena_fini completed"); -} - -/* ================================================================= */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/alloc_arena.cxx b/sal/rtl/source/alloc_arena.cxx new file mode 100644 index 000000000000..20ee962d55c5 --- /dev/null +++ b/sal/rtl/source/alloc_arena.cxx @@ -0,0 +1,1360 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#define _BSD_SOURCE /* sys/mman.h: MAP_ANON */ +#include "alloc_arena.hxx" + +#include "alloc_impl.hxx" +#include "internal/once.h" +#include "internal/rtllifecycle.h" +#include "sal/macros.h" +#include "osl/diagnose.h" + +#include +#include + +extern AllocMode alloc_mode; + +/* ================================================================= * + * + * arena internals. + * + * ================================================================= */ + +/** g_arena_list + * @internal + */ +struct rtl_arena_list_st +{ + rtl_memory_lock_type m_lock; + rtl_arena_type m_arena_head; +}; + +static rtl_arena_list_st g_arena_list; + + +/** gp_arena_arena + * provided for arena_type allocations, and hash_table resizing. + * + * @internal + */ +static rtl_arena_type * gp_arena_arena = 0; + + +/** gp_machdep_arena + * + * Low level virtual memory (pseudo) arena + * (platform dependent implementation) + * + * @internal + */ +static rtl_arena_type * gp_machdep_arena = 0; + + +static void * +SAL_CALL rtl_machdep_alloc ( + rtl_arena_type * pArena, + sal_Size * pSize +); + +static void +SAL_CALL rtl_machdep_free ( + rtl_arena_type * pArena, + void * pAddr, + sal_Size nSize +); + +static sal_Size +rtl_machdep_pagesize(); + + +/** gp_default_arena + */ +rtl_arena_type * gp_default_arena = 0; + + +/* ================================================================= */ + +/** rtl_arena_segment_constructor() + */ +static int +rtl_arena_segment_constructor (void * obj) +{ + rtl_arena_segment_type * segment = (rtl_arena_segment_type*)(obj); + + QUEUE_START_NAMED(segment, s); + QUEUE_START_NAMED(segment, f); + + return (1); +} + + +/** rtl_arena_segment_destructor() + */ +static void +rtl_arena_segment_destructor (void * obj) +{ +#if OSL_DEBUG_LEVEL == 0 + (void) obj; /* unused */ +#else /* OSL_DEBUG_LEVEL */ + rtl_arena_segment_type * segment = (rtl_arena_segment_type*)(obj); + + OSL_ASSERT(QUEUE_STARTED_NAMED(segment, s)); + OSL_ASSERT(QUEUE_STARTED_NAMED(segment, f)); +#endif /* OSL_DEBUG_LEVEL */ +} + +/* ================================================================= */ + +/** rtl_arena_segment_populate() + * + * @precond arena->m_lock acquired. + */ +static int +rtl_arena_segment_populate ( + rtl_arena_type * arena +) +{ + rtl_arena_segment_type *span; + sal_Size size = rtl_machdep_pagesize(); + + span = static_cast< rtl_arena_segment_type * >( + rtl_machdep_alloc(gp_machdep_arena, &size)); + if (span != 0) + { + rtl_arena_segment_type *first, *last, *head; + sal_Size count = size / sizeof(rtl_arena_segment_type); + + /* insert onto reserve span list */ + QUEUE_INSERT_TAIL_NAMED(&(arena->m_segment_reserve_span_head), span, s); + QUEUE_START_NAMED(span, f); + span->m_addr = (sal_uIntPtr)(span); + span->m_size = size; + span->m_type = RTL_ARENA_SEGMENT_TYPE_SPAN; + + /* insert onto reserve list */ + head = &(arena->m_segment_reserve_head); + for (first = span + 1, last = span + count; first < last; ++first) + { + QUEUE_INSERT_TAIL_NAMED(head, first, s); + QUEUE_START_NAMED(first, f); + first->m_addr = 0; + first->m_size = 0; + first->m_type = 0; + } + } + return (span != 0); +} + + +/** rtl_arena_segment_get() + * + * @precond arena->m_lock acquired. + * @precond (*ppSegment == 0) + */ +static RTL_MEMORY_INLINE void +rtl_arena_segment_get ( + rtl_arena_type * arena, + rtl_arena_segment_type ** ppSegment +) +{ + rtl_arena_segment_type * head; + + OSL_ASSERT(*ppSegment == 0); + + head = &(arena->m_segment_reserve_head); + if ((head->m_snext != head) || rtl_arena_segment_populate (arena)) + { + (*ppSegment) = head->m_snext; + QUEUE_REMOVE_NAMED((*ppSegment), s); + } +} + +#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) +#pragma inline(rtl_arena_segment_get) +#endif + + +/** rtl_arena_segment_put() + * + * @precond arena->m_lock acquired. + * @postcond (*ppSegment == 0) + */ +static RTL_MEMORY_INLINE void +rtl_arena_segment_put ( + rtl_arena_type * arena, + rtl_arena_segment_type ** ppSegment +) +{ + rtl_arena_segment_type * head; + + OSL_ASSERT(QUEUE_STARTED_NAMED((*ppSegment), s)); + OSL_ASSERT(QUEUE_STARTED_NAMED((*ppSegment), f)); + + (*ppSegment)->m_addr = 0; + (*ppSegment)->m_size = 0; + + OSL_ASSERT((*ppSegment)->m_type != RTL_ARENA_SEGMENT_TYPE_HEAD); + (*ppSegment)->m_type = 0; + + /* keep as reserve */ + head = &(arena->m_segment_reserve_head); + QUEUE_INSERT_HEAD_NAMED(head, (*ppSegment), s); + + /* clear */ + (*ppSegment) = 0; +} + +#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) +#pragma inline(rtl_arena_segment_put) +#endif + +/* ================================================================= */ + +/** rtl_arena_freelist_insert() + * + * @precond arena->m_lock acquired. + */ +static RTL_MEMORY_INLINE void +rtl_arena_freelist_insert ( + rtl_arena_type * arena, + rtl_arena_segment_type * segment +) +{ + rtl_arena_segment_type * head; + + head = &(arena->m_freelist_head[highbit(segment->m_size) - 1]); + QUEUE_INSERT_TAIL_NAMED(head, segment, f); + + arena->m_freelist_bitmap |= head->m_size; +} + +#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) +#pragma inline(rtl_arena_freelist_insert) +#endif /* __SUNPRO_C */ + + +/** rtl_arena_freelist_remove() + * + * @precond arena->m_lock acquired. + */ +static RTL_MEMORY_INLINE void +rtl_arena_freelist_remove ( + rtl_arena_type * arena, + rtl_arena_segment_type * segment +) +{ + if ((segment->m_fnext->m_type == RTL_ARENA_SEGMENT_TYPE_HEAD) && + (segment->m_fprev->m_type == RTL_ARENA_SEGMENT_TYPE_HEAD) ) + { + rtl_arena_segment_type * head; + + head = segment->m_fprev; + OSL_ASSERT(arena->m_freelist_bitmap & head->m_size); + arena->m_freelist_bitmap ^= head->m_size; + } + QUEUE_REMOVE_NAMED(segment, f); +} + +#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) +#pragma inline(rtl_arena_freelist_remove) +#endif /* __SUNPRO_C */ + + +/* ================================================================= */ + +/** RTL_ARENA_HASH_INDEX() + */ +#define RTL_ARENA_HASH_INDEX_IMPL(a, s, q, m) \ + ((((a) + ((a) >> (s)) + ((a) >> ((s) << 1))) >> (q)) & (m)) + +#define RTL_ARENA_HASH_INDEX(arena, addr) \ + RTL_ARENA_HASH_INDEX_IMPL((addr), (arena)->m_hash_shift, (arena)->m_quantum_shift, ((arena)->m_hash_size - 1)) + +/** rtl_arena_hash_rescale() + * + * @precond arena->m_lock released. + */ +static void +rtl_arena_hash_rescale ( + rtl_arena_type * arena, + sal_Size new_size +) +{ + rtl_arena_segment_type ** new_table; + sal_Size new_bytes; + + new_bytes = new_size * sizeof(rtl_arena_segment_type*); + new_table = (rtl_arena_segment_type **)rtl_arena_alloc (gp_arena_arena, &new_bytes); + + if (new_table != 0) + { + rtl_arena_segment_type ** old_table; + sal_Size old_size, i; + + memset (new_table, 0, new_bytes); + + RTL_MEMORY_LOCK_ACQUIRE(&(arena->m_lock)); + + old_table = arena->m_hash_table; + old_size = arena->m_hash_size; + + OSL_TRACE( + "rtl_arena_hash_rescale(\"%s\"): " + "nseg: %"PRIu64" (ave: %"PRIu64"), frees: %"PRIu64" " + "[old_size: %lu, new_size: %lu]", + arena->m_name, + arena->m_stats.m_alloc - arena->m_stats.m_free, + (arena->m_stats.m_alloc - arena->m_stats.m_free) >> arena->m_hash_shift, + arena->m_stats.m_free, + old_size, new_size + ); + + arena->m_hash_table = new_table; + arena->m_hash_size = new_size; + arena->m_hash_shift = highbit(arena->m_hash_size) - 1; + + for (i = 0; i < old_size; i++) + { + rtl_arena_segment_type * curr = old_table[i]; + while (curr != 0) + { + rtl_arena_segment_type * next = curr->m_fnext; + rtl_arena_segment_type ** head; + + head = &(arena->m_hash_table[RTL_ARENA_HASH_INDEX(arena, curr->m_addr)]); + curr->m_fnext = (*head); + (*head) = curr; + + curr = next; + } + old_table[i] = 0; + } + + RTL_MEMORY_LOCK_RELEASE(&(arena->m_lock)); + + if (old_table != arena->m_hash_table_0) + { + sal_Size old_bytes = old_size * sizeof(rtl_arena_segment_type*); + rtl_arena_free (gp_arena_arena, old_table, old_bytes); + } + } +} + + +/** rtl_arena_hash_insert() + * ...and update stats. + */ +static RTL_MEMORY_INLINE void +rtl_arena_hash_insert ( + rtl_arena_type * arena, + rtl_arena_segment_type * segment +) +{ + rtl_arena_segment_type ** ppSegment; + + ppSegment = &(arena->m_hash_table[RTL_ARENA_HASH_INDEX(arena, segment->m_addr)]); + + segment->m_fnext = (*ppSegment); + (*ppSegment) = segment; + + arena->m_stats.m_alloc += 1; + arena->m_stats.m_mem_alloc += segment->m_size; +} + +#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) +#pragma inline(rtl_arena_hash_insert) +#endif /* __SUNPRO_C */ + + +/** rtl_arena_hash_remove() + * ...and update stats. + */ +static rtl_arena_segment_type * +rtl_arena_hash_remove ( + rtl_arena_type * arena, + sal_uIntPtr addr, + sal_Size size +) +{ + rtl_arena_segment_type *segment, **segpp; + sal_Size lookups = 0; + +#if OSL_DEBUG_LEVEL == 0 + (void) size; /* unused */ +#endif /* OSL_DEBUG_LEVEL */ + + segpp = &(arena->m_hash_table[RTL_ARENA_HASH_INDEX(arena, addr)]); + while ((segment = *segpp) != 0) + { + if (segment->m_addr == addr) + { + *segpp = segment->m_fnext, segment->m_fnext = segment->m_fprev = segment; + break; + } + + /* update lookup miss stats */ + lookups += 1; + segpp = &(segment->m_fnext); + } + + OSL_POSTCOND(segment != 0, "rtl_arena_hash_remove(): bad free."); + if (segment != 0) + { + OSL_POSTCOND(segment->m_size == size, "rtl_arena_hash_remove(): wrong size."); + + arena->m_stats.m_free += 1; + arena->m_stats.m_mem_alloc -= segment->m_size; + + if (lookups > 1) + { + sal_Size nseg = (sal_Size)(arena->m_stats.m_alloc - arena->m_stats.m_free); + if (nseg > 4 * arena->m_hash_size) + { + if (!(arena->m_flags & RTL_ARENA_FLAG_RESCALE)) + { + sal_Size ave = nseg >> arena->m_hash_shift; + sal_Size new_size = arena->m_hash_size << (highbit(ave) - 1); + + arena->m_flags |= RTL_ARENA_FLAG_RESCALE; + RTL_MEMORY_LOCK_RELEASE(&(arena->m_lock)); + rtl_arena_hash_rescale (arena, new_size); + RTL_MEMORY_LOCK_ACQUIRE(&(arena->m_lock)); + arena->m_flags &= ~RTL_ARENA_FLAG_RESCALE; + } + } + } + } + + return (segment); +} + +/* ================================================================= */ + +/** rtl_arena_segment_alloc() + * allocate (and remove) segment from freelist + * + * @precond arena->m_lock acquired + * @precond (*ppSegment == 0) + */ +static int +rtl_arena_segment_alloc ( + rtl_arena_type * arena, + sal_Size size, + rtl_arena_segment_type ** ppSegment +) +{ + int index = 0; + + OSL_ASSERT(*ppSegment == 0); + if (!RTL_MEMORY_ISP2(size)) + { + int msb = highbit(size); + if (RTL_ARENA_FREELIST_SIZE == sal::static_int_cast< size_t >(msb)) + { + /* highest possible freelist: fall back to first fit */ + rtl_arena_segment_type *head, *segment; + + head = &(arena->m_freelist_head[msb - 1]); + for (segment = head->m_fnext; segment != head; segment = segment->m_fnext) + { + if (segment->m_size >= size) + { + /* allocate first fit segment */ + (*ppSegment) = segment; + break; + } + } + goto dequeue_and_leave; + } + + /* roundup to next power of 2 */ + size = (1UL << msb); + } + + index = lowbit(RTL_MEMORY_P2ALIGN(arena->m_freelist_bitmap, size)); + if (index > 0) + { + /* instant fit: allocate first free segment */ + rtl_arena_segment_type *head; + + head = &(arena->m_freelist_head[index - 1]); + (*ppSegment) = head->m_fnext; + OSL_ASSERT((*ppSegment) != head); + } + +dequeue_and_leave: + if (*ppSegment != 0) + { + /* remove from freelist */ + rtl_arena_freelist_remove (arena, (*ppSegment)); + } + return (*ppSegment != 0); +} + + +/** rtl_arena_segment_create() + * import new (span) segment from source arena + * + * @precond arena->m_lock acquired + * @precond (*ppSegment == 0) + */ +static int +rtl_arena_segment_create ( + rtl_arena_type * arena, + sal_Size size, + rtl_arena_segment_type ** ppSegment +) +{ + OSL_ASSERT((*ppSegment) == 0); + if (arena->m_source_alloc != 0) + { + rtl_arena_segment_get (arena, ppSegment); + if (*ppSegment != 0) + { + rtl_arena_segment_type * span = 0; + rtl_arena_segment_get (arena, &span); + if (span != 0) + { + /* import new span from source arena */ + RTL_MEMORY_LOCK_RELEASE(&(arena->m_lock)); + + span->m_size = size; + span->m_addr = (sal_uIntPtr)(arena->m_source_alloc)( + arena->m_source_arena, &(span->m_size)); + + RTL_MEMORY_LOCK_ACQUIRE(&(arena->m_lock)); + if (span->m_addr != 0) + { + /* insert onto segment list, update stats */ + span->m_type = RTL_ARENA_SEGMENT_TYPE_SPAN; + QUEUE_INSERT_HEAD_NAMED(&(arena->m_segment_head), span, s); + arena->m_stats.m_mem_total += span->m_size; + + (*ppSegment)->m_addr = span->m_addr; + (*ppSegment)->m_size = span->m_size; + (*ppSegment)->m_type = RTL_ARENA_SEGMENT_TYPE_FREE; + QUEUE_INSERT_HEAD_NAMED(span, (*ppSegment), s); + + /* report success */ + return (1); + } + rtl_arena_segment_put (arena, &span); + } + rtl_arena_segment_put (arena, ppSegment); + } + } + return (0); +} + + +/** rtl_arena_segment_coalesce() + * mark as free and join with adjacent free segment(s) + * + * @precond arena->m_lock acquired + * @precond segment marked 'used' + */ +static void +rtl_arena_segment_coalesce ( + rtl_arena_type * arena, + rtl_arena_segment_type * segment +) +{ + rtl_arena_segment_type *next, *prev; + + /* mark segment free */ + OSL_ASSERT(segment->m_type == RTL_ARENA_SEGMENT_TYPE_USED); + segment->m_type = RTL_ARENA_SEGMENT_TYPE_FREE; + + /* try to merge w/ next segment */ + next = segment->m_snext; + if (next->m_type == RTL_ARENA_SEGMENT_TYPE_FREE) + { + OSL_ASSERT(segment->m_addr + segment->m_size == next->m_addr); + segment->m_size += next->m_size; + + /* remove from freelist */ + rtl_arena_freelist_remove (arena, next); + + /* remove from segment list */ + QUEUE_REMOVE_NAMED(next, s); + + /* release segment descriptor */ + rtl_arena_segment_put (arena, &next); + } + + /* try to merge w/ prev segment */ + prev = segment->m_sprev; + if (prev->m_type == RTL_ARENA_SEGMENT_TYPE_FREE) + { + OSL_ASSERT(prev->m_addr + prev->m_size == segment->m_addr); + segment->m_addr = prev->m_addr; + segment->m_size += prev->m_size; + + /* remove from freelist */ + rtl_arena_freelist_remove (arena, prev); + + /* remove from segment list */ + QUEUE_REMOVE_NAMED(prev, s); + + /* release segment descriptor */ + rtl_arena_segment_put (arena, &prev); + } +} + +/* ================================================================= */ + +/** rtl_arena_constructor() + */ +static void +rtl_arena_constructor (void * obj) +{ + rtl_arena_type * arena = (rtl_arena_type*)(obj); + rtl_arena_segment_type * head; + size_t i; + + memset (arena, 0, sizeof(rtl_arena_type)); + + QUEUE_START_NAMED(arena, arena_); + + (void) RTL_MEMORY_LOCK_INIT(&(arena->m_lock)); + + head = &(arena->m_segment_reserve_span_head); + rtl_arena_segment_constructor (head); + head->m_type = RTL_ARENA_SEGMENT_TYPE_HEAD; + + head = &(arena->m_segment_reserve_head); + rtl_arena_segment_constructor (head); + head->m_type = RTL_ARENA_SEGMENT_TYPE_HEAD; + + head = &(arena->m_segment_head); + rtl_arena_segment_constructor (head); + head->m_type = RTL_ARENA_SEGMENT_TYPE_HEAD; + + for (i = 0; i < RTL_ARENA_FREELIST_SIZE; i++) + { + head = &(arena->m_freelist_head[i]); + rtl_arena_segment_constructor (head); + + head->m_size = (1UL << i); + head->m_type = RTL_ARENA_SEGMENT_TYPE_HEAD; + } + + arena->m_hash_table = arena->m_hash_table_0; + arena->m_hash_size = RTL_ARENA_HASH_SIZE; + arena->m_hash_shift = highbit(arena->m_hash_size) - 1; +} + + +/** rtl_arena_destructor() + */ +static void +rtl_arena_destructor (void * obj) +{ + rtl_arena_type * arena = (rtl_arena_type*)(obj); + rtl_arena_segment_type * head; + size_t i; + + OSL_ASSERT(QUEUE_STARTED_NAMED(arena, arena_)); + + RTL_MEMORY_LOCK_DESTROY(&(arena->m_lock)); + + head = &(arena->m_segment_reserve_span_head); + OSL_ASSERT(head->m_type == RTL_ARENA_SEGMENT_TYPE_HEAD); + rtl_arena_segment_destructor (head); + + head = &(arena->m_segment_reserve_head); + OSL_ASSERT(head->m_type == RTL_ARENA_SEGMENT_TYPE_HEAD); + rtl_arena_segment_destructor (head); + + head = &(arena->m_segment_head); + OSL_ASSERT(head->m_type == RTL_ARENA_SEGMENT_TYPE_HEAD); + rtl_arena_segment_destructor (head); + + for (i = 0; i < RTL_ARENA_FREELIST_SIZE; i++) + { + head = &(arena->m_freelist_head[i]); + + OSL_ASSERT(head->m_size == (1UL << i)); + OSL_ASSERT(head->m_type == RTL_ARENA_SEGMENT_TYPE_HEAD); + + rtl_arena_segment_destructor (head); + } + + OSL_ASSERT(arena->m_hash_table == arena->m_hash_table_0); + OSL_ASSERT(arena->m_hash_size == RTL_ARENA_HASH_SIZE); + OSL_ASSERT( + arena->m_hash_shift == + sal::static_int_cast< unsigned >(highbit(arena->m_hash_size) - 1)); +} + +/* ================================================================= */ + +/** rtl_arena_activate() + */ +static rtl_arena_type * +rtl_arena_activate ( + rtl_arena_type * arena, + const char * name, + sal_Size quantum, + sal_Size quantum_cache_max, + rtl_arena_type * source_arena, + void * (SAL_CALL * source_alloc)(rtl_arena_type *, sal_Size *), + void (SAL_CALL * source_free) (rtl_arena_type *, void *, sal_Size) +) +{ + OSL_ASSERT(arena != 0); + if (arena != 0) + { + (void) snprintf (arena->m_name, sizeof(arena->m_name), "%s", name); + + if (!RTL_MEMORY_ISP2(quantum)) + { + /* roundup to next power of 2 */ + quantum = (1UL << highbit(quantum)); + } + quantum_cache_max = RTL_MEMORY_P2ROUNDUP(quantum_cache_max, quantum); + + arena->m_quantum = quantum; + arena->m_quantum_shift = highbit(arena->m_quantum) - 1; + arena->m_qcache_max = quantum_cache_max; + + arena->m_source_arena = source_arena; + arena->m_source_alloc = source_alloc; + arena->m_source_free = source_free; + + if (arena->m_qcache_max > 0) + { + char namebuf[RTL_ARENA_NAME_LENGTH + 1]; + int i, n = (arena->m_qcache_max >> arena->m_quantum_shift); + + sal_Size size = n * sizeof(rtl_cache_type*); + arena->m_qcache_ptr = (rtl_cache_type**)rtl_arena_alloc (gp_arena_arena, &size); + if (!(arena->m_qcache_ptr)) + { + /* out of memory */ + return (0); + } + for (i = 1; i <= n; i++) + { + size = i * arena->m_quantum; + (void) snprintf (namebuf, sizeof(namebuf), "%s_%lu", arena->m_name, size); + arena->m_qcache_ptr[i - 1] = rtl_cache_create(namebuf, size, 0, NULL, NULL, NULL, NULL, arena, RTL_CACHE_FLAG_QUANTUMCACHE); + } + } + + /* insert into arena list */ + RTL_MEMORY_LOCK_ACQUIRE(&(g_arena_list.m_lock)); + QUEUE_INSERT_TAIL_NAMED(&(g_arena_list.m_arena_head), arena, arena_); + RTL_MEMORY_LOCK_RELEASE(&(g_arena_list.m_lock)); + } + return (arena); +} + +/** rtl_arena_deactivate() + */ +static void +rtl_arena_deactivate ( + rtl_arena_type * arena +) +{ + rtl_arena_segment_type * head, * segment; + + /* remove from arena list */ + RTL_MEMORY_LOCK_ACQUIRE(&(g_arena_list.m_lock)); + QUEUE_REMOVE_NAMED(arena, arena_); + RTL_MEMORY_LOCK_RELEASE(&(g_arena_list.m_lock)); + + /* cleanup quantum cache(s) */ + if ((arena->m_qcache_max > 0) && (arena->m_qcache_ptr != 0)) + { + int i, n = (arena->m_qcache_max >> arena->m_quantum_shift); + for (i = 1; i <= n; i++) + { + if (arena->m_qcache_ptr[i - 1] != 0) + { + rtl_cache_destroy (arena->m_qcache_ptr[i - 1]); + arena->m_qcache_ptr[i - 1] = 0; + } + } + rtl_arena_free ( + gp_arena_arena, + arena->m_qcache_ptr, + n * sizeof(rtl_cache_type*)); + + arena->m_qcache_ptr = 0; + } + + /* check for leaked segments */ + OSL_TRACE( + "rtl_arena_deactivate(\"%s\"): " + "allocs: %"PRIu64", frees: %"PRIu64"; total: %lu, used: %lu", + arena->m_name, + arena->m_stats.m_alloc, arena->m_stats.m_free, + arena->m_stats.m_mem_total, arena->m_stats.m_mem_alloc + ); + if (arena->m_stats.m_alloc > arena->m_stats.m_free) + { + sal_Size i, n; + + OSL_TRACE( + "rtl_arena_deactivate(\"%s\"): " + "cleaning up %"PRIu64" leaked segment(s) [%lu bytes]", + arena->m_name, + arena->m_stats.m_alloc - arena->m_stats.m_free, + arena->m_stats.m_mem_alloc + ); + + /* cleanup still used segment(s) */ + for (i = 0, n = arena->m_hash_size; i < n; i++) + { + while ((segment = arena->m_hash_table[i]) != 0) + { + /* pop from hash table */ + arena->m_hash_table[i] = segment->m_fnext, segment->m_fnext = segment->m_fprev = segment; + + /* coalesce w/ adjacent free segment(s) */ + rtl_arena_segment_coalesce (arena, segment); + + /* insert onto freelist */ + rtl_arena_freelist_insert (arena, segment); + } + } + } + + /* cleanup hash table */ + if (arena->m_hash_table != arena->m_hash_table_0) + { + rtl_arena_free ( + gp_arena_arena, + arena->m_hash_table, + arena->m_hash_size * sizeof(rtl_arena_segment_type*)); + + arena->m_hash_table = arena->m_hash_table_0; + arena->m_hash_size = RTL_ARENA_HASH_SIZE; + arena->m_hash_shift = highbit(arena->m_hash_size) - 1; + } + + /* cleanup segment list */ + head = &(arena->m_segment_head); + for (segment = head->m_snext; segment != head; segment = head->m_snext) + { + if (segment->m_type == RTL_ARENA_SEGMENT_TYPE_FREE) + { + /* remove from freelist */ + rtl_arena_freelist_remove (arena, segment); + } + else + { + /* can have only free and span segments here */ + OSL_ASSERT(segment->m_type == RTL_ARENA_SEGMENT_TYPE_SPAN); + } + + /* remove from segment list */ + QUEUE_REMOVE_NAMED(segment, s); + + /* release segment descriptor */ + rtl_arena_segment_put (arena, &segment); + } + + /* cleanup segment reserve list */ + head = &(arena->m_segment_reserve_head); + for (segment = head->m_snext; segment != head; segment = head->m_snext) + { + /* remove from segment list */ + QUEUE_REMOVE_NAMED(segment, s); + } + + /* cleanup segment reserve span(s) */ + head = &(arena->m_segment_reserve_span_head); + for (segment = head->m_snext; segment != head; segment = head->m_snext) + { + /* can have only span segments here */ + OSL_ASSERT(segment->m_type == RTL_ARENA_SEGMENT_TYPE_SPAN); + + /* remove from segment list */ + QUEUE_REMOVE_NAMED(segment, s); + + /* return span to g_machdep_arena */ + rtl_machdep_free (gp_machdep_arena, (void*)(segment->m_addr), segment->m_size); + } +} + +/* ================================================================= * + * + * arena implementation. + * + * ================================================================= */ + +/** rtl_arena_create() + */ +rtl_arena_type * +SAL_CALL rtl_arena_create ( + const char * name, + sal_Size quantum, + sal_Size quantum_cache_max, + rtl_arena_type * source_arena, + void * (SAL_CALL * source_alloc)(rtl_arena_type *, sal_Size *), + void (SAL_CALL * source_free) (rtl_arena_type *, void *, sal_Size), + int +) SAL_THROW_EXTERN_C() +{ + rtl_arena_type * result = 0; + sal_Size size = sizeof(rtl_arena_type); + +try_alloc: + result = (rtl_arena_type*)rtl_arena_alloc (gp_arena_arena, &size); + if (result != 0) + { + rtl_arena_type * arena = result; + VALGRIND_CREATE_MEMPOOL(arena, 0, 0); + rtl_arena_constructor (arena); + + if (!source_arena) + { + OSL_ASSERT(gp_default_arena != 0); + source_arena = gp_default_arena; + } + + result = rtl_arena_activate ( + arena, + name, + quantum, + quantum_cache_max, + source_arena, + source_alloc, + source_free + ); + + if (result == 0) + { + rtl_arena_deactivate (arena); + rtl_arena_destructor (arena); + VALGRIND_DESTROY_MEMPOOL(arena); + rtl_arena_free (gp_arena_arena, arena, size); + } + } + else if (gp_arena_arena == 0) + { + ensureArenaSingleton(); + if (gp_arena_arena) + { + /* try again */ + goto try_alloc; + } + } + return (result); +} + +/** rtl_arena_destroy() + */ +void +SAL_CALL rtl_arena_destroy ( + rtl_arena_type * arena +) SAL_THROW_EXTERN_C() +{ + if (arena != 0) + { + rtl_arena_deactivate (arena); + rtl_arena_destructor (arena); + VALGRIND_DESTROY_MEMPOOL(arena); + rtl_arena_free (gp_arena_arena, arena, sizeof(rtl_arena_type)); + } +} + +/** rtl_arena_alloc() + */ +void * +SAL_CALL rtl_arena_alloc ( + rtl_arena_type * arena, + sal_Size * pSize +) SAL_THROW_EXTERN_C() +{ + void * addr = 0; + + if ((arena != 0) && (pSize != 0)) + { + sal_Size size; + + if (alloc_mode == AMode_SYSTEM) + return rtl_allocateMemory(*pSize); + + size = RTL_MEMORY_ALIGN((*pSize), arena->m_quantum); + if (size > arena->m_qcache_max) + { + /* allocate from segment list */ + rtl_arena_segment_type *segment = 0; + + RTL_MEMORY_LOCK_ACQUIRE(&(arena->m_lock)); + if (rtl_arena_segment_alloc (arena, size, &segment) || + rtl_arena_segment_create(arena, size, &segment) ) + { + /* shrink to fit */ + sal_Size oversize; + + /* mark segment used */ + OSL_ASSERT(segment->m_type == RTL_ARENA_SEGMENT_TYPE_FREE); + segment->m_type = RTL_ARENA_SEGMENT_TYPE_USED; + + /* resize */ + OSL_ASSERT(segment->m_size >= size); + oversize = segment->m_size - size; + if (oversize >= SAL_MAX(arena->m_quantum, arena->m_qcache_max)) + { + rtl_arena_segment_type * remainder = 0; + rtl_arena_segment_get (arena, &remainder); + if (remainder != 0) + { + segment->m_size = size; + + remainder->m_addr = segment->m_addr + segment->m_size; + remainder->m_size = oversize; + remainder->m_type = RTL_ARENA_SEGMENT_TYPE_FREE; + QUEUE_INSERT_HEAD_NAMED(segment, remainder, s); + + rtl_arena_freelist_insert (arena, remainder); + } + } + + rtl_arena_hash_insert (arena, segment); + + /* DEBUG ONLY: mark allocated, undefined */ + OSL_DEBUG_ONLY(memset((void*)(segment->m_addr), 0x77777777, segment->m_size)); + VALGRIND_MEMPOOL_ALLOC(arena, segment->m_addr, segment->m_size); + + (*pSize) = segment->m_size; + addr = (void*)(segment->m_addr); + } + RTL_MEMORY_LOCK_RELEASE(&(arena->m_lock)); + } + else if (size > 0) + { + /* allocate from quantum cache(s) */ + int index = (size >> arena->m_quantum_shift) - 1; + OSL_ASSERT (arena->m_qcache_ptr[index] != 0); + + addr = rtl_cache_alloc (arena->m_qcache_ptr[index]); + if (addr != 0) + (*pSize) = size; + } + } + return (addr); +} + +/** rtl_arena_free() + */ +void +SAL_CALL rtl_arena_free ( + rtl_arena_type * arena, + void * addr, + sal_Size size +) SAL_THROW_EXTERN_C() +{ + if (arena != 0) + { + if (alloc_mode == AMode_SYSTEM) + { + rtl_freeMemory(addr); + return; + } + + size = RTL_MEMORY_ALIGN(size, arena->m_quantum); + if (size > arena->m_qcache_max) + { + /* free to segment list */ + rtl_arena_segment_type * segment; + + RTL_MEMORY_LOCK_ACQUIRE(&(arena->m_lock)); + + segment = rtl_arena_hash_remove (arena, (sal_uIntPtr)(addr), size); + if (segment != 0) + { + rtl_arena_segment_type *next, *prev; + + /* DEBUG ONLY: mark unallocated, undefined */ + VALGRIND_MEMPOOL_FREE(arena, segment->m_addr); + /* OSL_DEBUG_ONLY() */ RTL_VALGRIND_IGNORE_VAL VALGRIND_MAKE_MEM_UNDEFINED(segment->m_addr, segment->m_size); + OSL_DEBUG_ONLY(memset((void*)(segment->m_addr), 0x33333333, segment->m_size)); + + /* coalesce w/ adjacent free segment(s) */ + rtl_arena_segment_coalesce (arena, segment); + + /* determine (new) next and prev segment */ + next = segment->m_snext, prev = segment->m_sprev; + + /* entire span free when prev is a span, and next is either a span or a list head */ + if (((prev->m_type == RTL_ARENA_SEGMENT_TYPE_SPAN)) && + ((next->m_type == RTL_ARENA_SEGMENT_TYPE_SPAN) || + (next->m_type == RTL_ARENA_SEGMENT_TYPE_HEAD)) ) + { + OSL_ASSERT((prev->m_addr == segment->m_addr) && + (prev->m_size == segment->m_size) ); + + if (arena->m_source_free) + { + addr = (void*)(prev->m_addr); + size = prev->m_size; + + /* remove from segment list */ + QUEUE_REMOVE_NAMED(segment, s); + + /* release segment descriptor */ + rtl_arena_segment_put (arena, &segment); + + /* remove from segment list */ + QUEUE_REMOVE_NAMED(prev, s); + + /* release (span) segment descriptor */ + rtl_arena_segment_put (arena, &prev); + + /* update stats, return span to source arena */ + arena->m_stats.m_mem_total -= size; + RTL_MEMORY_LOCK_RELEASE(&(arena->m_lock)); + + (arena->m_source_free)(arena->m_source_arena, addr, size); + return; + } + } + + /* insert onto freelist */ + rtl_arena_freelist_insert (arena, segment); + } + + RTL_MEMORY_LOCK_RELEASE(&(arena->m_lock)); + } + else if (size > 0) + { + /* free to quantum cache(s) */ + int index = (size >> arena->m_quantum_shift) - 1; + OSL_ASSERT (arena->m_qcache_ptr[index] != 0); + + rtl_cache_free (arena->m_qcache_ptr[index], addr); + } + } +} + +/* ================================================================= * + * + * machdep internals. + * + * ================================================================= */ + +#if defined(SAL_UNX) +#include +#elif defined(SAL_W32) +#define MAP_FAILED 0 +#endif /* SAL_UNX || SAL_W32 */ + +/** rtl_machdep_alloc() + */ +static void * +SAL_CALL rtl_machdep_alloc ( + rtl_arena_type * pArena, + sal_Size * pSize +) +{ + void * addr; + sal_Size size = (*pSize); + + OSL_PRECOND(pArena == gp_machdep_arena, "rtl_machdep_alloc(): invalid argument"); + +#if defined(SOLARIS) && defined(SPARC) + /* see @ mmap(2) man pages */ + size += (pArena->m_quantum + pArena->m_quantum); /* "red-zone" pages */ + if (size > (4 << 20)) + size = RTL_MEMORY_P2ROUNDUP(size, (4 << 20)); + else if (size > (512 << 10)) + size = RTL_MEMORY_P2ROUNDUP(size, (512 << 10)); + else + size = RTL_MEMORY_P2ROUNDUP(size, (64 << 10)); + size -= (pArena->m_quantum + pArena->m_quantum); /* "red-zone" pages */ +#else + /* default allocation granularity */ + size = RTL_MEMORY_P2ROUNDUP(size, SAL_MAX(pArena->m_quantum, 64 << 10)); +#endif + +#if defined(SAL_UNX) + addr = mmap (NULL, (size_t)(size), PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); +#elif defined(SAL_W32) + addr = VirtualAlloc (NULL, (SIZE_T)(size), MEM_COMMIT, PAGE_READWRITE); +#endif /* (SAL_UNX || SAL_W32) */ + + if (addr != MAP_FAILED) + { + pArena->m_stats.m_alloc += 1; + pArena->m_stats.m_mem_total += size; + pArena->m_stats.m_mem_alloc += size; + + (*pSize) = size; + return (addr); + } + return (NULL); +} + +/** rtl_machdep_free() + */ +static void +SAL_CALL rtl_machdep_free ( + rtl_arena_type * pArena, + void * pAddr, + sal_Size nSize +) +{ + OSL_PRECOND(pArena == gp_machdep_arena, "rtl_machdep_free(): invalid argument"); + + pArena->m_stats.m_free += 1; + pArena->m_stats.m_mem_total -= nSize; + pArena->m_stats.m_mem_alloc -= nSize; + +#if defined(SAL_UNX) + (void) munmap(pAddr, nSize); +#elif defined(SAL_W32) + (void) VirtualFree ((LPVOID)(pAddr), (SIZE_T)(0), MEM_RELEASE); +#endif /* (SAL_UNX || SAL_W32) */ +} + +/** rtl_machdep_pagesize() + */ +static sal_Size +rtl_machdep_pagesize() +{ +#if defined(SAL_UNX) +#if defined(FREEBSD) || defined(NETBSD) || defined(DRAGONFLY) + return ((sal_Size)getpagesize()); +#else /* POSIX */ + return ((sal_Size)sysconf(_SC_PAGESIZE)); +#endif /* xBSD || POSIX */ +#elif defined(SAL_W32) + SYSTEM_INFO info; + GetSystemInfo (&info); + return ((sal_Size)(info.dwPageSize)); +#endif /* (SAL_UNX || SAL_W32) */ +} + +/* ================================================================= * + * + * arena initialization. + * + * ================================================================= */ + +void +rtl_arena_init() +{ + { + /* list of arenas */ + RTL_MEMORY_LOCK_INIT(&(g_arena_list.m_lock)); + rtl_arena_constructor (&(g_arena_list.m_arena_head)); + } + { + /* machdep (pseudo) arena */ + static rtl_arena_type g_machdep_arena; + + OSL_ASSERT(gp_machdep_arena == 0); + VALGRIND_CREATE_MEMPOOL(&g_machdep_arena, 0, 0); + rtl_arena_constructor (&g_machdep_arena); + + gp_machdep_arena = rtl_arena_activate ( + &g_machdep_arena, + "rtl_machdep_arena", + rtl_machdep_pagesize(), + 0, /* no quantum caching */ + 0, 0, 0 /* no source */ + ); + OSL_ASSERT(gp_machdep_arena != 0); + } + { + /* default arena */ + static rtl_arena_type g_default_arena; + + OSL_ASSERT(gp_default_arena == 0); + VALGRIND_CREATE_MEMPOOL(&g_default_arena, 0, 0); + rtl_arena_constructor (&g_default_arena); + + gp_default_arena = rtl_arena_activate ( + &g_default_arena, + "rtl_default_arena", + rtl_machdep_pagesize(), + 0, /* no quantum caching */ + gp_machdep_arena, /* source */ + rtl_machdep_alloc, + rtl_machdep_free + ); + OSL_ASSERT(gp_default_arena != 0); + } + { + /* arena internal arena */ + static rtl_arena_type g_arena_arena; + + OSL_ASSERT(gp_arena_arena == 0); + VALGRIND_CREATE_MEMPOOL(&g_arena_arena, 0, 0); + rtl_arena_constructor (&g_arena_arena); + + gp_arena_arena = rtl_arena_activate ( + &g_arena_arena, + "rtl_arena_internal_arena", + 64, /* quantum */ + 0, /* no quantum caching */ + gp_default_arena, /* source */ + rtl_arena_alloc, + rtl_arena_free + ); + OSL_ASSERT(gp_arena_arena != 0); + } + OSL_TRACE("rtl_arena_init completed"); +} + +/* ================================================================= */ + +void +rtl_arena_fini() +{ + if (gp_arena_arena != 0) + { + rtl_arena_type * arena, * head; + + RTL_MEMORY_LOCK_ACQUIRE(&(g_arena_list.m_lock)); + head = &(g_arena_list.m_arena_head); + + for (arena = head->m_arena_next; arena != head; arena = arena->m_arena_next) + { + OSL_TRACE( + "rtl_arena_fini(\"%s\"): " + "allocs: %"PRIu64", frees: %"PRIu64"; total: %lu, used: %lu", + arena->m_name, + arena->m_stats.m_alloc, arena->m_stats.m_free, + arena->m_stats.m_mem_total, arena->m_stats.m_mem_alloc + ); + } + RTL_MEMORY_LOCK_RELEASE(&(g_arena_list.m_lock)); + } + OSL_TRACE("rtl_arena_fini completed"); +} + +/* ================================================================= */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/alloc_arena.h b/sal/rtl/source/alloc_arena.h deleted file mode 100644 index 8c0f08c0fd4f..000000000000 --- a/sal/rtl/source/alloc_arena.h +++ /dev/null @@ -1,140 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef INCLUDED_RTL_ALLOC_ARENA_H -#define INCLUDED_RTL_ALLOC_ARENA_H - -#include "sal/types.h" -#include "rtl/alloc.h" -#include "alloc_impl.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** rtl_arena_stat_type - * @internal - */ -typedef struct rtl_arena_stat_st rtl_arena_stat_type; -struct rtl_arena_stat_st -{ - sal_uInt64 m_alloc; - sal_uInt64 m_free; - - sal_Size m_mem_total; - sal_Size m_mem_alloc; -}; - - -/** rtl_arena_segment_type - * @internal - */ -#define RTL_ARENA_SEGMENT_TYPE_HEAD ((sal_Size)(0x01)) -#define RTL_ARENA_SEGMENT_TYPE_SPAN ((sal_Size)(0x02)) -#define RTL_ARENA_SEGMENT_TYPE_FREE ((sal_Size)(0x04)) -#define RTL_ARENA_SEGMENT_TYPE_USED ((sal_Size)(0x08)) - -typedef struct rtl_arena_segment_st rtl_arena_segment_type; -struct rtl_arena_segment_st -{ - /* segment list linkage */ - rtl_arena_segment_type * m_snext; - rtl_arena_segment_type * m_sprev; - - /* free/used list linkage */ - rtl_arena_segment_type * m_fnext; - rtl_arena_segment_type * m_fprev; - - /* segment description */ - sal_uIntPtr m_addr; - sal_Size m_size; - sal_Size m_type; -}; - - -/** rtl_arena_type - * @internal - */ -#define RTL_ARENA_FREELIST_SIZE (sizeof(void*) * 8) -#define RTL_ARENA_HASH_SIZE 64 - -#define RTL_ARENA_FLAG_RESCALE 1 /* within hash rescale operation */ - -struct rtl_arena_st -{ - /* linkage */ - rtl_arena_type * m_arena_next; - rtl_arena_type * m_arena_prev; - - /* properties */ - char m_name[RTL_ARENA_NAME_LENGTH + 1]; - long m_flags; - - rtl_memory_lock_type m_lock; - rtl_arena_stat_type m_stats; - - rtl_arena_type * m_source_arena; - void * (SAL_CALL * m_source_alloc)(rtl_arena_type *, sal_Size *); - void (SAL_CALL * m_source_free) (rtl_arena_type *, void *, sal_Size); - - sal_Size m_quantum; - sal_Size m_quantum_shift; /* log2(m_quantum) */ - - rtl_arena_segment_type m_segment_reserve_span_head; - rtl_arena_segment_type m_segment_reserve_head; - - rtl_arena_segment_type m_segment_head; - - rtl_arena_segment_type m_freelist_head[RTL_ARENA_FREELIST_SIZE]; - sal_Size m_freelist_bitmap; - - rtl_arena_segment_type ** m_hash_table; - rtl_arena_segment_type * m_hash_table_0[RTL_ARENA_HASH_SIZE]; - sal_Size m_hash_size; /* m_hash_mask + 1 */ - sal_Size m_hash_shift; /* log2(m_hash_size) */ - - sal_Size m_qcache_max; - rtl_cache_type ** m_qcache_ptr; -}; - - -/** gp_default_arena - * default arena with pagesize quantum - * - * @internal - */ -extern rtl_arena_type * gp_default_arena; - - -#ifdef __cplusplus -} -#endif - -#endif /* INCLUDED_RTL_ALLOC_ARENA_H */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/alloc_arena.hxx b/sal/rtl/source/alloc_arena.hxx new file mode 100644 index 000000000000..6a933a9ed5f9 --- /dev/null +++ b/sal/rtl/source/alloc_arena.hxx @@ -0,0 +1,129 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_RTL_ALLOC_ARENA_HXX +#define INCLUDED_RTL_ALLOC_ARENA_HXX + +#include "sal/types.h" +#include "rtl/alloc.h" +#include "alloc_impl.hxx" + +/** rtl_arena_stat_type + * @internal + */ +struct rtl_arena_stat_type +{ + sal_uInt64 m_alloc; + sal_uInt64 m_free; + + sal_Size m_mem_total; + sal_Size m_mem_alloc; +}; + + +/** rtl_arena_segment_type + * @internal + */ +#define RTL_ARENA_SEGMENT_TYPE_HEAD ((sal_Size)(0x01)) +#define RTL_ARENA_SEGMENT_TYPE_SPAN ((sal_Size)(0x02)) +#define RTL_ARENA_SEGMENT_TYPE_FREE ((sal_Size)(0x04)) +#define RTL_ARENA_SEGMENT_TYPE_USED ((sal_Size)(0x08)) + +struct rtl_arena_segment_type +{ + /* segment list linkage */ + rtl_arena_segment_type * m_snext; + rtl_arena_segment_type * m_sprev; + + /* free/used list linkage */ + rtl_arena_segment_type * m_fnext; + rtl_arena_segment_type * m_fprev; + + /* segment description */ + sal_uIntPtr m_addr; + sal_Size m_size; + sal_Size m_type; +}; + + +/** rtl_arena_type + * @internal + */ +#define RTL_ARENA_FREELIST_SIZE (sizeof(void*) * 8) +#define RTL_ARENA_HASH_SIZE 64 + +#define RTL_ARENA_FLAG_RESCALE 1 /* within hash rescale operation */ + +struct rtl_arena_st +{ + /* linkage */ + rtl_arena_type * m_arena_next; + rtl_arena_type * m_arena_prev; + + /* properties */ + char m_name[RTL_ARENA_NAME_LENGTH + 1]; + long m_flags; + + rtl_memory_lock_type m_lock; + rtl_arena_stat_type m_stats; + + rtl_arena_type * m_source_arena; + void * (SAL_CALL * m_source_alloc)(rtl_arena_type *, sal_Size *); + void (SAL_CALL * m_source_free) (rtl_arena_type *, void *, sal_Size); + + sal_Size m_quantum; + sal_Size m_quantum_shift; /* log2(m_quantum) */ + + rtl_arena_segment_type m_segment_reserve_span_head; + rtl_arena_segment_type m_segment_reserve_head; + + rtl_arena_segment_type m_segment_head; + + rtl_arena_segment_type m_freelist_head[RTL_ARENA_FREELIST_SIZE]; + sal_Size m_freelist_bitmap; + + rtl_arena_segment_type ** m_hash_table; + rtl_arena_segment_type * m_hash_table_0[RTL_ARENA_HASH_SIZE]; + sal_Size m_hash_size; /* m_hash_mask + 1 */ + sal_Size m_hash_shift; /* log2(m_hash_size) */ + + sal_Size m_qcache_max; + rtl_cache_type ** m_qcache_ptr; +}; + + +/** gp_default_arena + * default arena with pagesize quantum + * + * @internal + */ +extern rtl_arena_type * gp_default_arena; + +#endif /* INCLUDED_RTL_ALLOC_ARENA_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/alloc_cache.c b/sal/rtl/source/alloc_cache.c deleted file mode 100644 index 1a4c87e09395..000000000000 --- a/sal/rtl/source/alloc_cache.c +++ /dev/null @@ -1,1767 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "alloc_cache.h" -#include "alloc_impl.h" -#include "alloc_arena.h" -#include "internal/once.h" -#include "sal/macros.h" -#include "osl/diagnose.h" - -#ifndef INCLUDED_STRING_H -#include -#endif - -#ifndef INCLUDED_STDIO_H -#include -#endif - -extern AllocMode alloc_mode; - -/* ================================================================= * - * - * cache internals. - * - * ================================================================= */ - -/** g_cache_list - * @internal - */ -struct rtl_cache_list_st -{ - rtl_memory_lock_type m_lock; - rtl_cache_type m_cache_head; - -#if defined(SAL_UNX) - pthread_t m_update_thread; - pthread_cond_t m_update_cond; -#elif defined(SAL_W32) - HANDLE m_update_thread; - HANDLE m_update_cond; -#endif /* SAL_UNX || SAL_W32 */ - int m_update_done; -}; - -static struct rtl_cache_list_st g_cache_list; - - -/** gp_cache_arena - * provided for cache_type allocations, and hash_table resizing. - * - * @internal - */ -static rtl_arena_type * gp_cache_arena = 0; - - -/** gp_cache_magazine_cache - * @internal - */ -static rtl_cache_type * gp_cache_magazine_cache = 0; - - -/** gp_cache_slab_cache - * @internal - */ -static rtl_cache_type * gp_cache_slab_cache = 0; - - -/** gp_cache_bufctl_cache - * @internal - */ -static rtl_cache_type * gp_cache_bufctl_cache = 0; - - -/* ================================================================= */ - -/** RTL_CACHE_HASH_INDEX() - */ -#define RTL_CACHE_HASH_INDEX_IMPL(a, s, q, m) \ - ((((a) + ((a) >> (s)) + ((a) >> ((s) << 1))) >> (q)) & (m)) - -#define RTL_CACHE_HASH_INDEX(cache, addr) \ - RTL_CACHE_HASH_INDEX_IMPL((addr), (cache)->m_hash_shift, (cache)->m_type_shift, ((cache)->m_hash_size - 1)) - - -/** rtl_cache_hash_rescale() - */ -static void -rtl_cache_hash_rescale ( - rtl_cache_type * cache, - sal_Size new_size -) -{ - rtl_cache_bufctl_type ** new_table; - sal_Size new_bytes; - - new_bytes = new_size * sizeof(rtl_cache_bufctl_type*); - new_table = (rtl_cache_bufctl_type**)rtl_arena_alloc(gp_cache_arena, &new_bytes); - - if (new_table != 0) - { - rtl_cache_bufctl_type ** old_table; - sal_Size old_size, i; - - memset (new_table, 0, new_bytes); - - RTL_MEMORY_LOCK_ACQUIRE(&(cache->m_slab_lock)); - - old_table = cache->m_hash_table; - old_size = cache->m_hash_size; - - OSL_TRACE( - "rtl_cache_hash_rescale(\"%s\"): " - "nbuf: % " PRIu64 " (ave: %" PRIu64 "), frees: %" PRIu64 " " - "[old_size: %lu, new_size: %lu]", - cache->m_name, - cache->m_slab_stats.m_alloc - cache->m_slab_stats.m_free, - (cache->m_slab_stats.m_alloc - cache->m_slab_stats.m_free) >> cache->m_hash_shift, - cache->m_slab_stats.m_free, - old_size, new_size); - - cache->m_hash_table = new_table; - cache->m_hash_size = new_size; - cache->m_hash_shift = highbit(cache->m_hash_size) - 1; - - for (i = 0; i < old_size; i++) - { - rtl_cache_bufctl_type * curr = old_table[i]; - while (curr != 0) - { - rtl_cache_bufctl_type * next = curr->m_next; - rtl_cache_bufctl_type ** head; - - head = &(cache->m_hash_table[RTL_CACHE_HASH_INDEX(cache, curr->m_addr)]); - curr->m_next = (*head); - (*head) = curr; - - curr = next; - } - old_table[i] = 0; - } - - RTL_MEMORY_LOCK_RELEASE(&(cache->m_slab_lock)); - - if (old_table != cache->m_hash_table_0) - { - sal_Size old_bytes = old_size * sizeof(rtl_cache_bufctl_type*); - rtl_arena_free (gp_cache_arena, old_table, old_bytes); - } - } -} - -/** rtl_cache_hash_insert() - */ -static RTL_MEMORY_INLINE sal_uIntPtr -rtl_cache_hash_insert ( - rtl_cache_type * cache, - rtl_cache_bufctl_type * bufctl -) -{ - rtl_cache_bufctl_type ** ppHead; - - ppHead = &(cache->m_hash_table[RTL_CACHE_HASH_INDEX(cache, bufctl->m_addr)]); - - bufctl->m_next = (*ppHead); - (*ppHead) = bufctl; - - return (bufctl->m_addr); -} - -#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) -#pragma inline(rtl_cache_hash_insert) -#endif /* __SUNPRO_C */ - - -/** rtl_cache_hash_remove() - */ -static rtl_cache_bufctl_type * -rtl_cache_hash_remove ( - rtl_cache_type * cache, - sal_uIntPtr addr -) -{ - rtl_cache_bufctl_type ** ppHead; - rtl_cache_bufctl_type * bufctl; - sal_Size lookups = 0; - - ppHead = &(cache->m_hash_table[RTL_CACHE_HASH_INDEX(cache, addr)]); - while ((bufctl = *ppHead) != 0) - { - if (bufctl->m_addr == addr) - { - *ppHead = bufctl->m_next, bufctl->m_next = 0; - break; - } - - lookups += 1; - ppHead = &(bufctl->m_next); - } - - OSL_ASSERT (bufctl != 0); /* bad free */ - - if (lookups > 1) - { - sal_Size nbuf = (sal_Size)(cache->m_slab_stats.m_alloc - cache->m_slab_stats.m_free); - if (nbuf > 4 * cache->m_hash_size) - { - if (!(cache->m_features & RTL_CACHE_FEATURE_RESCALE)) - { - sal_Size ave = nbuf >> cache->m_hash_shift; - sal_Size new_size = cache->m_hash_size << (highbit(ave) - 1); - - cache->m_features |= RTL_CACHE_FEATURE_RESCALE; - RTL_MEMORY_LOCK_RELEASE(&(cache->m_slab_lock)); - rtl_cache_hash_rescale (cache, new_size); - RTL_MEMORY_LOCK_ACQUIRE(&(cache->m_slab_lock)); - cache->m_features &= ~RTL_CACHE_FEATURE_RESCALE; - } - } - } - - return (bufctl); -} - -/* ================================================================= */ - -/** RTL_CACHE_SLAB() - */ -#define RTL_CACHE_SLAB(addr, size) \ - (((rtl_cache_slab_type*)(RTL_MEMORY_P2END((sal_uIntPtr)(addr), (size)))) - 1) - - -/** rtl_cache_slab_constructor() - */ -static int -rtl_cache_slab_constructor (void * obj, void * arg) -{ - rtl_cache_slab_type * slab = (rtl_cache_slab_type*)(obj); - - (void) arg; /* unused */ - - QUEUE_START_NAMED(slab, slab_); - slab->m_ntypes = 0; - - return (1); -} - - -/** rtl_cache_slab_destructor() - */ -static void -rtl_cache_slab_destructor (void * obj, void * arg) -{ -#if OSL_DEBUG_LEVEL == 0 - (void) obj; /* unused */ -#else /* OSL_DEBUG_LEVEL */ - rtl_cache_slab_type * slab = (rtl_cache_slab_type*)(obj); - - /* assure removed from queue(s) */ - OSL_ASSERT(QUEUE_STARTED_NAMED(slab, slab_)); - - /* assure no longer referenced */ - OSL_ASSERT(slab->m_ntypes == 0); -#endif /* OSL_DEBUG_LEVEL */ - - (void) arg; /* unused */ -} - - -/** rtl_cache_slab_create() - * - * @precond cache->m_slab_lock released. - */ -static rtl_cache_slab_type * -rtl_cache_slab_create ( - rtl_cache_type * cache -) -{ - rtl_cache_slab_type * slab = 0; - void * addr; - sal_Size size; - - size = cache->m_slab_size; - addr = rtl_arena_alloc (cache->m_source, &size); - if (addr != 0) - { - OSL_ASSERT(size >= cache->m_slab_size); - - if (cache->m_features & RTL_CACHE_FEATURE_HASH) - { - /* allocate slab struct from slab cache */ - OSL_ASSERT (cache != gp_cache_slab_cache); - slab = (rtl_cache_slab_type*)rtl_cache_alloc (gp_cache_slab_cache); - } - else - { - /* construct embedded slab struct */ - slab = RTL_CACHE_SLAB(addr, cache->m_slab_size); - (void) rtl_cache_slab_constructor (slab, 0); - } - if (slab != 0) - { - slab->m_data = (sal_uIntPtr)(addr); - - /* dynamic freelist initialization */ - slab->m_bp = slab->m_data; - slab->m_sp = 0; - } - else - { - rtl_arena_free (cache->m_source, addr, size); - } - } - return (slab); -} - - -/** rtl_cache_slab_destroy() - * - * @precond cache->m_slab_lock released. - */ -static void -rtl_cache_slab_destroy ( - rtl_cache_type * cache, - rtl_cache_slab_type * slab -) -{ - void * addr = (void*)(slab->m_data); - sal_Size refcnt = slab->m_ntypes; slab->m_ntypes = 0; - - if (cache->m_features & RTL_CACHE_FEATURE_HASH) - { - /* cleanup bufctl(s) for free buffer(s) */ - sal_Size ntypes = (slab->m_bp - slab->m_data) / cache->m_type_size; - for (ntypes -= refcnt; slab->m_sp != 0; ntypes--) - { - rtl_cache_bufctl_type * bufctl = slab->m_sp; - - /* pop from freelist */ - slab->m_sp = bufctl->m_next, bufctl->m_next = 0; - - /* return bufctl struct to bufctl cache */ - rtl_cache_free (gp_cache_bufctl_cache, bufctl); - } - OSL_ASSERT(ntypes == 0); - - /* return slab struct to slab cache */ - rtl_cache_free (gp_cache_slab_cache, slab); - } - else - { - /* destruct embedded slab struct */ - rtl_cache_slab_destructor (slab, 0); - } - - if ((refcnt == 0) || (cache->m_features & RTL_CACHE_FEATURE_BULKDESTROY)) - { - /* free memory */ - rtl_arena_free (cache->m_source, addr, cache->m_slab_size); - } -} - - -/** rtl_cache_slab_populate() - * - * @precond cache->m_slab_lock acquired. - */ -static int -rtl_cache_slab_populate ( - rtl_cache_type * cache -) -{ - rtl_cache_slab_type * slab; - - RTL_MEMORY_LOCK_RELEASE(&(cache->m_slab_lock)); - slab = rtl_cache_slab_create (cache); - RTL_MEMORY_LOCK_ACQUIRE(&(cache->m_slab_lock)); - if (slab != 0) - { - /* update buffer start addr w/ current color */ - slab->m_bp += cache->m_ncolor; - - /* update color for next slab */ - cache->m_ncolor += cache->m_type_align; - if (cache->m_ncolor > cache->m_ncolor_max) - cache->m_ncolor = 0; - - /* update stats */ - cache->m_slab_stats.m_mem_total += cache->m_slab_size; - - /* insert onto 'free' queue */ - QUEUE_INSERT_HEAD_NAMED(&(cache->m_free_head), slab, slab_); - } - return (slab != 0); -} - -/* ================================================================= */ - -/** rtl_cache_slab_alloc() - * - * Allocate a buffer from slab layer; used by magazine layer. - */ -static void * -rtl_cache_slab_alloc ( - rtl_cache_type * cache -) -{ - void * addr = 0; - rtl_cache_slab_type * head; - - RTL_MEMORY_LOCK_ACQUIRE(&(cache->m_slab_lock)); - - head = &(cache->m_free_head); - if ((head->m_slab_next != head) || rtl_cache_slab_populate (cache)) - { - rtl_cache_slab_type * slab; - rtl_cache_bufctl_type * bufctl; - - slab = head->m_slab_next; - OSL_ASSERT(slab->m_ntypes < cache->m_ntypes); - - if (slab->m_sp == 0) - { - /* initialize bufctl w/ current 'slab->m_bp' */ - OSL_ASSERT (slab->m_bp < slab->m_data + cache->m_ntypes * cache->m_type_size + cache->m_ncolor_max); - if (cache->m_features & RTL_CACHE_FEATURE_HASH) - { - /* allocate bufctl */ - OSL_ASSERT (cache != gp_cache_bufctl_cache); - bufctl = (rtl_cache_bufctl_type*)rtl_cache_alloc (gp_cache_bufctl_cache); - if (bufctl == 0) - { - /* out of memory */ - RTL_MEMORY_LOCK_RELEASE(&(cache->m_slab_lock)); - return (0); - } - - bufctl->m_addr = slab->m_bp; - bufctl->m_slab = (sal_uIntPtr)(slab); - } - else - { - /* embedded bufctl */ - bufctl = (rtl_cache_bufctl_type*)(slab->m_bp); - } - bufctl->m_next = 0; - - /* update 'slab->m_bp' to next free buffer */ - slab->m_bp += cache->m_type_size; - - /* assign bufctl to freelist */ - slab->m_sp = bufctl; - } - - /* pop front */ - bufctl = slab->m_sp; - slab->m_sp = bufctl->m_next; - - /* increment usage, check for full slab */ - if ((slab->m_ntypes += 1) == cache->m_ntypes) - { - /* remove from 'free' queue */ - QUEUE_REMOVE_NAMED(slab, slab_); - - /* insert onto 'used' queue (tail) */ - QUEUE_INSERT_TAIL_NAMED(&(cache->m_used_head), slab, slab_); - } - - /* update stats */ - cache->m_slab_stats.m_alloc += 1; - cache->m_slab_stats.m_mem_alloc += cache->m_type_size; - - if (cache->m_features & RTL_CACHE_FEATURE_HASH) - addr = (void*)rtl_cache_hash_insert (cache, bufctl); - else - addr = bufctl; - - /* DEBUG ONLY: mark allocated, undefined */ - /* OSL_DEBUG_ONLY() */ RTL_VALGRIND_IGNORE_VAL VALGRIND_MAKE_MEM_UNDEFINED(addr, cache->m_type_size); - OSL_DEBUG_ONLY(memset(addr, 0x77777777, cache->m_type_size)); - VALGRIND_MEMPOOL_ALLOC(cache, addr, cache->m_type_size); - } - - RTL_MEMORY_LOCK_RELEASE(&(cache->m_slab_lock)); - return (addr); -} - - -/** rtl_cache_slab_free() - * - * Return a buffer to slab layer; used by magazine layer. - */ -static void -rtl_cache_slab_free ( - rtl_cache_type * cache, - void * addr -) -{ - rtl_cache_bufctl_type * bufctl; - rtl_cache_slab_type * slab; - - RTL_MEMORY_LOCK_ACQUIRE(&(cache->m_slab_lock)); - - /* DEBUG ONLY: mark unallocated, undefined */ - VALGRIND_MEMPOOL_FREE(cache, addr); - /* OSL_DEBUG_ONLY() */ RTL_VALGRIND_IGNORE_VAL VALGRIND_MAKE_MEM_UNDEFINED(addr, cache->m_type_size); - OSL_DEBUG_ONLY(memset(addr, 0x33333333, cache->m_type_size)); - - /* determine slab from addr */ - if (cache->m_features & RTL_CACHE_FEATURE_HASH) - { - bufctl = rtl_cache_hash_remove (cache, (sal_uIntPtr)(addr)); - slab = (bufctl != 0) ? (rtl_cache_slab_type*)(bufctl->m_slab) : 0; - } - else - { - /* embedded slab struct */ - bufctl = (rtl_cache_bufctl_type*)(addr); - slab = RTL_CACHE_SLAB(addr, cache->m_slab_size); - } - - if (slab != 0) - { - /* check for full slab */ - if (slab->m_ntypes == cache->m_ntypes) - { - /* remove from 'used' queue */ - QUEUE_REMOVE_NAMED(slab, slab_); - - /* insert onto 'free' queue (head) */ - QUEUE_INSERT_HEAD_NAMED(&(cache->m_free_head), slab, slab_); - } - - /* push front */ - bufctl->m_next = slab->m_sp; - slab->m_sp = bufctl; - - /* update stats */ - cache->m_slab_stats.m_free += 1; - cache->m_slab_stats.m_mem_alloc -= cache->m_type_size; - - /* decrement usage, check for empty slab */ - if ((slab->m_ntypes -= 1) == 0) - { - /* remove from 'free' queue */ - QUEUE_REMOVE_NAMED(slab, slab_); - - /* update stats */ - cache->m_slab_stats.m_mem_total -= cache->m_slab_size; - - /* free 'empty' slab */ - RTL_MEMORY_LOCK_RELEASE(&(cache->m_slab_lock)); - rtl_cache_slab_destroy (cache, slab); - return; - } - } - - RTL_MEMORY_LOCK_RELEASE(&(cache->m_slab_lock)); -} - -/* ================================================================= */ - -/** rtl_cache_magazine_constructor() - */ -static int -rtl_cache_magazine_constructor (void * obj, void * arg) -{ - rtl_cache_magazine_type * mag = (rtl_cache_magazine_type*)(obj); - /* @@@ sal_Size size = (sal_Size)(arg); @@@ */ - - (void) arg; /* unused */ - - mag->m_mag_next = 0; - mag->m_mag_size = RTL_CACHE_MAGAZINE_SIZE; - mag->m_mag_used = 0; - - return (1); -} - - -/** rtl_cache_magazine_destructor() - */ -static void -rtl_cache_magazine_destructor (void * obj, void * arg) -{ -#if OSL_DEBUG_LEVEL == 0 - (void) obj; /* unused */ -#else /* OSL_DEBUG_LEVEL */ - rtl_cache_magazine_type * mag = (rtl_cache_magazine_type*)(obj); - - /* assure removed from queue(s) */ - OSL_ASSERT(mag->m_mag_next == 0); - - /* assure no longer referenced */ - OSL_ASSERT(mag->m_mag_used == 0); -#endif /* OSL_DEBUG_LEVEL */ - - (void) arg; /* unused */ -} - - -/** rtl_cache_magazine_clear() - */ -static void -rtl_cache_magazine_clear ( - rtl_cache_type * cache, - rtl_cache_magazine_type * mag -) -{ - for (; mag->m_mag_used > 0; --mag->m_mag_used) - { - void * obj = mag->m_objects[mag->m_mag_used - 1]; - mag->m_objects[mag->m_mag_used - 1] = 0; - - /* DEBUG ONLY: mark cached object allocated, undefined */ - VALGRIND_MEMPOOL_ALLOC(cache, obj, cache->m_type_size); - if (cache->m_destructor != 0) - { - /* DEBUG ONLY: keep constructed object defined */ - RTL_VALGRIND_IGNORE_VAL VALGRIND_MAKE_MEM_DEFINED(obj, cache->m_type_size); - - /* destruct object */ - (cache->m_destructor)(obj, cache->m_userarg); - } - - /* return buffer to slab layer */ - rtl_cache_slab_free (cache, obj); - } -} - -/* ================================================================= */ - -/** rtl_cache_depot_enqueue() - * - * @precond cache->m_depot_lock acquired. - */ -static RTL_MEMORY_INLINE void -rtl_cache_depot_enqueue ( - rtl_cache_depot_type * depot, - rtl_cache_magazine_type * mag -) -{ - /* enqueue empty magazine */ - mag->m_mag_next = depot->m_mag_next; - depot->m_mag_next = mag; - - /* update depot stats */ - depot->m_mag_count++; -} - -#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) -#pragma inline(rtl_cache_depot_enqueue) -#endif /* __SUNPRO_C */ - - -/** rtl_cache_depot_dequeue() - * - * @precond cache->m_depot_lock acquired. - */ -static RTL_MEMORY_INLINE rtl_cache_magazine_type * -rtl_cache_depot_dequeue ( - rtl_cache_depot_type * depot -) -{ - rtl_cache_magazine_type * mag = 0; - if (depot->m_mag_count > 0) - { - /* dequeue magazine */ - OSL_ASSERT(depot->m_mag_next != 0); - - mag = depot->m_mag_next; - depot->m_mag_next = mag->m_mag_next; - mag->m_mag_next = 0; - - /* update depot stats */ - depot->m_mag_count--; - depot->m_curr_min = SAL_MIN(depot->m_curr_min, depot->m_mag_count); - } - return (mag); -} - -#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) -#pragma inline(rtl_cache_depot_dequeue) -#endif /* __SUNPRO_C */ - - -/** rtl_cache_depot_exchange_alloc() - * - * @precond cache->m_depot_lock acquired. - */ -static RTL_MEMORY_INLINE rtl_cache_magazine_type * -rtl_cache_depot_exchange_alloc ( - rtl_cache_type * cache, - rtl_cache_magazine_type * empty -) -{ - rtl_cache_magazine_type * full; - - OSL_ASSERT((empty == 0) || (empty->m_mag_used == 0)); - - /* dequeue full magazine */ - full = rtl_cache_depot_dequeue (&(cache->m_depot_full)); - if ((full != 0) && (empty != 0)) - { - /* enqueue empty magazine */ - rtl_cache_depot_enqueue (&(cache->m_depot_empty), empty); - } - - OSL_ASSERT((full == 0) || (full->m_mag_used > 0)); - - return (full); -} - -#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) -#pragma inline(rtl_cache_depot_exchange_alloc) -#endif /* __SUNPRO_C */ - - -/** rtl_cache_depot_exchange_free() - * - * @precond cache->m_depot_lock acquired. - */ -static RTL_MEMORY_INLINE rtl_cache_magazine_type * -rtl_cache_depot_exchange_free ( - rtl_cache_type * cache, - rtl_cache_magazine_type * full -) -{ - rtl_cache_magazine_type * empty; - - OSL_ASSERT((full == 0) || (full->m_mag_used > 0)); - - /* dequeue empty magazine */ - empty = rtl_cache_depot_dequeue (&(cache->m_depot_empty)); - if ((empty != 0) && (full != 0)) - { - /* enqueue full magazine */ - rtl_cache_depot_enqueue (&(cache->m_depot_full), full); - } - - OSL_ASSERT((empty == 0) || (empty->m_mag_used == 0)); - - return (empty); -} - -#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) -#pragma inline(rtl_cache_depot_exchange_free) -#endif /* __SUNPRO_C */ - - -/** rtl_cache_depot_populate() - * - * @precond cache->m_depot_lock acquired. - */ -static int -rtl_cache_depot_populate ( - rtl_cache_type * cache -) -{ - rtl_cache_magazine_type * empty = 0; - - if (cache->m_magazine_cache != 0) - { - /* allocate new empty magazine */ - RTL_MEMORY_LOCK_RELEASE(&(cache->m_depot_lock)); - empty = (rtl_cache_magazine_type*)rtl_cache_alloc (cache->m_magazine_cache); - RTL_MEMORY_LOCK_ACQUIRE(&(cache->m_depot_lock)); - if (empty != 0) - { - /* enqueue (new) empty magazine */ - rtl_cache_depot_enqueue (&(cache->m_depot_empty), empty); - } - } - return (empty != 0); -} - -/* ================================================================= */ - -/** rtl_cache_constructor() - */ -static int -rtl_cache_constructor (void * obj) -{ - rtl_cache_type * cache = (rtl_cache_type*)(obj); - - memset (cache, 0, sizeof(rtl_cache_type)); - - /* linkage */ - QUEUE_START_NAMED(cache, cache_); - - /* slab layer */ - (void)RTL_MEMORY_LOCK_INIT(&(cache->m_slab_lock)); - - QUEUE_START_NAMED(&(cache->m_free_head), slab_); - QUEUE_START_NAMED(&(cache->m_used_head), slab_); - - cache->m_hash_table = cache->m_hash_table_0; - cache->m_hash_size = RTL_CACHE_HASH_SIZE; - cache->m_hash_shift = highbit(cache->m_hash_size) - 1; - - /* depot layer */ - (void)RTL_MEMORY_LOCK_INIT(&(cache->m_depot_lock)); - - return (1); -} - -/** rtl_cache_destructor() - */ -static void -rtl_cache_destructor (void * obj) -{ - rtl_cache_type * cache = (rtl_cache_type*)(obj); - - /* linkage */ - OSL_ASSERT(QUEUE_STARTED_NAMED(cache, cache_)); - - /* slab layer */ - (void)RTL_MEMORY_LOCK_DESTROY(&(cache->m_slab_lock)); - - OSL_ASSERT(QUEUE_STARTED_NAMED(&(cache->m_free_head), slab_)); - OSL_ASSERT(QUEUE_STARTED_NAMED(&(cache->m_used_head), slab_)); - - OSL_ASSERT(cache->m_hash_table == cache->m_hash_table_0); - OSL_ASSERT(cache->m_hash_size == RTL_CACHE_HASH_SIZE); - OSL_ASSERT(cache->m_hash_shift == (sal_Size)(highbit(cache->m_hash_size) - 1)); - - /* depot layer */ - (void)RTL_MEMORY_LOCK_DESTROY(&(cache->m_depot_lock)); -} - -/* ================================================================= */ - -/** rtl_cache_activate() - */ -static rtl_cache_type * -rtl_cache_activate ( - rtl_cache_type * cache, - const char * name, - size_t objsize, - size_t objalign, - int (SAL_CALL * constructor)(void * obj, void * userarg), - void (SAL_CALL * destructor) (void * obj, void * userarg), - void (SAL_CALL * reclaim) (void * userarg), - void * userarg, - rtl_arena_type * source, - int flags -) -{ - OSL_ASSERT(cache != 0); - if (cache != 0) - { - sal_Size slabsize; - - snprintf (cache->m_name, sizeof(cache->m_name), "%s", name); - - /* ensure minimum size (embedded bufctl linkage) */ - objsize = SAL_MAX(objsize, sizeof(rtl_cache_bufctl_type*)); - - if (objalign == 0) - { - /* determine default alignment */ - if (objsize >= RTL_MEMORY_ALIGNMENT_8) - objalign = RTL_MEMORY_ALIGNMENT_8; - else - objalign = RTL_MEMORY_ALIGNMENT_4; - } - else - { - /* ensure minimum alignment */ - objalign = SAL_MAX(objalign, RTL_MEMORY_ALIGNMENT_4); - } - OSL_ASSERT(RTL_MEMORY_ISP2(objalign)); - - cache->m_type_size = objsize = RTL_MEMORY_P2ROUNDUP(objsize, objalign); - cache->m_type_align = objalign; - cache->m_type_shift = highbit(cache->m_type_size) - 1; - - cache->m_constructor = constructor; - cache->m_destructor = destructor; - cache->m_reclaim = reclaim; - cache->m_userarg = userarg; - - /* slab layer */ - cache->m_source = source; - - slabsize = source->m_quantum; /* minimum slab size */ - if (flags & RTL_CACHE_FLAG_QUANTUMCACHE) - { - /* next power of 2 above 3 * qcache_max */ - slabsize = SAL_MAX(slabsize, (1UL << highbit(3 * source->m_qcache_max))); - } - else - { - /* waste at most 1/8 of slab */ - slabsize = SAL_MAX(slabsize, cache->m_type_size * 8); - } - - slabsize = RTL_MEMORY_P2ROUNDUP(slabsize, source->m_quantum); - if (!RTL_MEMORY_ISP2(slabsize)) - slabsize = 1UL << highbit(slabsize); - cache->m_slab_size = slabsize; - - if (cache->m_slab_size > source->m_quantum) - { - OSL_ASSERT(gp_cache_slab_cache != 0); - OSL_ASSERT(gp_cache_bufctl_cache != 0); - - cache->m_features |= RTL_CACHE_FEATURE_HASH; - cache->m_ntypes = cache->m_slab_size / cache->m_type_size; - cache->m_ncolor_max = cache->m_slab_size % cache->m_type_size; - } - else - { - /* embedded slab struct */ - cache->m_ntypes = (cache->m_slab_size - sizeof(rtl_cache_slab_type)) / cache->m_type_size; - cache->m_ncolor_max = (cache->m_slab_size - sizeof(rtl_cache_slab_type)) % cache->m_type_size; - } - - OSL_ASSERT(cache->m_ntypes > 0); - cache->m_ncolor = 0; - - if (flags & RTL_CACHE_FLAG_BULKDESTROY) - { - /* allow bulk slab delete upon cache deactivation */ - cache->m_features |= RTL_CACHE_FEATURE_BULKDESTROY; - } - - /* magazine layer */ - if (!(flags & RTL_CACHE_FLAG_NOMAGAZINE)) - { - OSL_ASSERT(gp_cache_magazine_cache != 0); - cache->m_magazine_cache = gp_cache_magazine_cache; - } - - /* insert into cache list */ - RTL_MEMORY_LOCK_ACQUIRE(&(g_cache_list.m_lock)); - QUEUE_INSERT_TAIL_NAMED(&(g_cache_list.m_cache_head), cache, cache_); - RTL_MEMORY_LOCK_RELEASE(&(g_cache_list.m_lock)); - } - return (cache); -} - -/** rtl_cache_deactivate() - */ -static void -rtl_cache_deactivate ( - rtl_cache_type * cache -) -{ - int active = 1; - - /* remove from cache list */ - RTL_MEMORY_LOCK_ACQUIRE(&(g_cache_list.m_lock)); - active = QUEUE_STARTED_NAMED(cache, cache_) == 0; - QUEUE_REMOVE_NAMED(cache, cache_); - RTL_MEMORY_LOCK_RELEASE(&(g_cache_list.m_lock)); - - OSL_PRECOND(active, "rtl_cache_deactivate(): orphaned cache."); - (void)active; - - /* cleanup magazine layer */ - if (cache->m_magazine_cache != 0) - { - rtl_cache_type * mag_cache; - rtl_cache_magazine_type * mag; - - /* prevent recursion */ - mag_cache = cache->m_magazine_cache, cache->m_magazine_cache = 0; - - /* cleanup cpu layer */ - if ((mag = cache->m_cpu_curr) != 0) - { - cache->m_cpu_curr = 0; - rtl_cache_magazine_clear (cache, mag); - rtl_cache_free (mag_cache, mag); - } - if ((mag = cache->m_cpu_prev) != 0) - { - cache->m_cpu_prev = 0; - rtl_cache_magazine_clear (cache, mag); - rtl_cache_free (mag_cache, mag); - } - - /* cleanup depot layer */ - while ((mag = rtl_cache_depot_dequeue(&(cache->m_depot_full))) != 0) - { - rtl_cache_magazine_clear (cache, mag); - rtl_cache_free (mag_cache, mag); - } - while ((mag = rtl_cache_depot_dequeue(&(cache->m_depot_empty))) != 0) - { - rtl_cache_magazine_clear (cache, mag); - rtl_cache_free (mag_cache, mag); - } - } - - OSL_TRACE( - "rtl_cache_deactivate(\"%s\"): " - "[slab]: allocs: %"PRIu64", frees: %"PRIu64"; total: %lu, used: %lu; " - "[cpu]: allocs: %"PRIu64", frees: %"PRIu64"; " - "[total]: allocs: %"PRIu64", frees: %"PRIu64"", - cache->m_name, - cache->m_slab_stats.m_alloc, cache->m_slab_stats.m_free, - cache->m_slab_stats.m_mem_total, cache->m_slab_stats.m_mem_alloc, - cache->m_cpu_stats.m_alloc, cache->m_cpu_stats.m_free, - cache->m_slab_stats.m_alloc + cache->m_cpu_stats.m_alloc, - cache->m_slab_stats.m_free + cache->m_cpu_stats.m_free - ); - - /* cleanup slab layer */ - if (cache->m_slab_stats.m_alloc > cache->m_slab_stats.m_free) - { - OSL_TRACE( - "rtl_cache_deactivate(\"%s\"): " - "cleaning up %"PRIu64" leaked buffer(s) [%lu bytes] [%lu total]", - cache->m_name, - cache->m_slab_stats.m_alloc - cache->m_slab_stats.m_free, - cache->m_slab_stats.m_mem_alloc, cache->m_slab_stats.m_mem_total - ); - - if (cache->m_features & RTL_CACHE_FEATURE_HASH) - { - /* cleanup bufctl(s) for leaking buffer(s) */ - sal_Size i, n = cache->m_hash_size; - for (i = 0; i < n; i++) - { - rtl_cache_bufctl_type * bufctl; - while ((bufctl = cache->m_hash_table[i]) != 0) - { - /* pop from hash table */ - cache->m_hash_table[i] = bufctl->m_next, bufctl->m_next = 0; - - /* return to bufctl cache */ - rtl_cache_free (gp_cache_bufctl_cache, bufctl); - } - } - } - { - /* force cleanup of remaining slabs */ - rtl_cache_slab_type *head, *slab; - - head = &(cache->m_used_head); - for (slab = head->m_slab_next; slab != head; slab = head->m_slab_next) - { - /* remove from 'used' queue */ - QUEUE_REMOVE_NAMED(slab, slab_); - - /* update stats */ - cache->m_slab_stats.m_mem_total -= cache->m_slab_size; - - /* free slab */ - rtl_cache_slab_destroy (cache, slab); - } - - head = &(cache->m_free_head); - for (slab = head->m_slab_next; slab != head; slab = head->m_slab_next) - { - /* remove from 'free' queue */ - QUEUE_REMOVE_NAMED(slab, slab_); - - /* update stats */ - cache->m_slab_stats.m_mem_total -= cache->m_slab_size; - - /* free slab */ - rtl_cache_slab_destroy (cache, slab); - } - } - } - - if (cache->m_hash_table != cache->m_hash_table_0) - { - rtl_arena_free ( - gp_cache_arena, - cache->m_hash_table, - cache->m_hash_size * sizeof(rtl_cache_bufctl_type*)); - - cache->m_hash_table = cache->m_hash_table_0; - cache->m_hash_size = RTL_CACHE_HASH_SIZE; - cache->m_hash_shift = highbit(cache->m_hash_size) - 1; - } -} - -/* ================================================================= * - * - * cache implementation. - * - * ================================================================= */ - -extern void ensureCacheSingleton(); - -/** rtl_cache_create() - */ -rtl_cache_type * -SAL_CALL rtl_cache_create ( - const char * name, - sal_Size objsize, - sal_Size objalign, - int (SAL_CALL * constructor)(void * obj, void * userarg), - void (SAL_CALL * destructor) (void * obj, void * userarg), - void (SAL_CALL * reclaim) (void * userarg), - void * userarg, - rtl_arena_type * source, - int flags -) SAL_THROW_EXTERN_C() -{ - rtl_cache_type * result = 0; - sal_Size size = sizeof(rtl_cache_type); - -try_alloc: - result = (rtl_cache_type*)rtl_arena_alloc (gp_cache_arena, &size); - if (result != 0) - { - rtl_cache_type * cache = result; - VALGRIND_CREATE_MEMPOOL(cache, 0, 0); - (void) rtl_cache_constructor (cache); - - if (!source) - { - /* use default arena */ - OSL_ASSERT(gp_default_arena != 0); - source = gp_default_arena; - } - - result = rtl_cache_activate ( - cache, - name, - objsize, - objalign, - constructor, - destructor, - reclaim, - userarg, - source, - flags - ); - - if (result == 0) - { - /* activation failed */ - rtl_cache_deactivate (cache); - rtl_cache_destructor (cache); - VALGRIND_DESTROY_MEMPOOL(cache); - rtl_arena_free (gp_cache_arena, cache, size); - } - } - else if (gp_cache_arena == 0) - { - ensureCacheSingleton(); - if (gp_cache_arena) - { - /* try again */ - goto try_alloc; - } - } - return (result); -} - -/** rtl_cache_destroy() - */ -void SAL_CALL rtl_cache_destroy ( - rtl_cache_type * cache -) SAL_THROW_EXTERN_C() -{ - if (cache != 0) - { - rtl_cache_deactivate (cache); - rtl_cache_destructor (cache); - VALGRIND_DESTROY_MEMPOOL(cache); - rtl_arena_free (gp_cache_arena, cache, sizeof(rtl_cache_type)); - } -} - -/** rtl_cache_alloc() - */ -void * -SAL_CALL rtl_cache_alloc ( - rtl_cache_type * cache -) SAL_THROW_EXTERN_C() -{ - void * obj = 0; - - if (cache == 0) - return (0); - - if (alloc_mode == AMode_SYSTEM) - { - obj = rtl_allocateMemory(cache->m_type_size); - if ((obj != 0) && (cache->m_constructor != 0)) - { - if (!((cache->m_constructor)(obj, cache->m_userarg))) - { - /* construction failure */ - rtl_freeMemory(obj), obj = 0; - } - } - return obj; - } - - RTL_MEMORY_LOCK_ACQUIRE(&(cache->m_depot_lock)); - if (cache->m_cpu_curr != 0) - { - for (;;) - { - /* take object from magazine layer */ - rtl_cache_magazine_type *curr, *prev, *temp; - - curr = cache->m_cpu_curr; - if ((curr != 0) && (curr->m_mag_used > 0)) - { - obj = curr->m_objects[--curr->m_mag_used]; -#if defined(HAVE_VALGRIND_MEMCHECK_H) - VALGRIND_MEMPOOL_ALLOC(cache, obj, cache->m_type_size); - if (cache->m_constructor != 0) - { - /* keep constructed object defined */ - RTL_VALGRIND_IGNORE_VAL VALGRIND_MAKE_MEM_DEFINED(obj, cache->m_type_size); - } -#endif /* HAVE_VALGRIND_MEMCHECK_H */ - cache->m_cpu_stats.m_alloc += 1; - RTL_MEMORY_LOCK_RELEASE(&(cache->m_depot_lock)); - - return (obj); - } - - prev = cache->m_cpu_prev; - if ((prev != 0) && (prev->m_mag_used > 0)) - { - temp = cache->m_cpu_curr; - cache->m_cpu_curr = cache->m_cpu_prev; - cache->m_cpu_prev = temp; - - continue; - } - - temp = rtl_cache_depot_exchange_alloc (cache, prev); - if (temp != 0) - { - cache->m_cpu_prev = cache->m_cpu_curr; - cache->m_cpu_curr = temp; - - continue; - } - - /* no full magazine: fall through to slab layer */ - break; - } - } - RTL_MEMORY_LOCK_RELEASE(&(cache->m_depot_lock)); - - /* alloc buffer from slab layer */ - obj = rtl_cache_slab_alloc (cache); - if ((obj != 0) && (cache->m_constructor != 0)) - { - /* construct object */ - if (!((cache->m_constructor)(obj, cache->m_userarg))) - { - /* construction failure */ - rtl_cache_slab_free (cache, obj), obj = 0; - } - } - return (obj); -} - -/** rtl_cache_free() - */ -void -SAL_CALL rtl_cache_free ( - rtl_cache_type * cache, - void * obj -) SAL_THROW_EXTERN_C() -{ - if ((obj != 0) && (cache != 0)) - { - if (alloc_mode == AMode_SYSTEM) - { - if (cache->m_destructor != 0) - { - /* destruct object */ - (cache->m_destructor)(obj, cache->m_userarg); - } - rtl_freeMemory(obj); - return; - } - - RTL_MEMORY_LOCK_ACQUIRE(&(cache->m_depot_lock)); - - for (;;) - { - /* return object to magazine layer */ - rtl_cache_magazine_type *curr, *prev, *temp; - - curr = cache->m_cpu_curr; - if ((curr != 0) && (curr->m_mag_used < curr->m_mag_size)) - { - curr->m_objects[curr->m_mag_used++] = obj; -#if defined(HAVE_VALGRIND_MEMCHECK_H) - VALGRIND_MEMPOOL_FREE(cache, obj); -#endif /* HAVE_VALGRIND_MEMCHECK_H */ - cache->m_cpu_stats.m_free += 1; - RTL_MEMORY_LOCK_RELEASE(&(cache->m_depot_lock)); - - return; - } - - prev = cache->m_cpu_prev; - if ((prev != 0) && (prev->m_mag_used == 0)) - { - temp = cache->m_cpu_curr; - cache->m_cpu_curr = cache->m_cpu_prev; - cache->m_cpu_prev = temp; - - continue; - } - - temp = rtl_cache_depot_exchange_free (cache, prev); - if (temp != 0) - { - cache->m_cpu_prev = cache->m_cpu_curr; - cache->m_cpu_curr = temp; - - continue; - } - - if (rtl_cache_depot_populate(cache) != 0) - { - continue; - } - - /* no empty magazine: fall through to slab layer */ - break; - } - - RTL_MEMORY_LOCK_RELEASE(&(cache->m_depot_lock)); - - /* no space for constructed object in magazine layer */ - if (cache->m_destructor != 0) - { - /* destruct object */ - (cache->m_destructor)(obj, cache->m_userarg); - } - - /* return buffer to slab layer */ - rtl_cache_slab_free (cache, obj); - } -} - -/* ================================================================= * - * - * cache wsupdate (machdep) internals. - * - * ================================================================= */ - -/** rtl_cache_wsupdate_init() - * - * @precond g_cache_list.m_lock initialized - */ -static void -rtl_cache_wsupdate_init (void); - - -/** rtl_cache_wsupdate_wait() - * - * @precond g_cache_list.m_lock acquired - */ -static void -rtl_cache_wsupdate_wait ( - unsigned int seconds -); - -/** rtl_cache_wsupdate_fini() - * - */ -static void -rtl_cache_wsupdate_fini (void); - -/* ================================================================= */ - -#if defined(SAL_UNX) - -#include - -static void * -rtl_cache_wsupdate_all (void * arg); - -static void -rtl_cache_wsupdate_init (void) -{ - RTL_MEMORY_LOCK_ACQUIRE(&(g_cache_list.m_lock)); - g_cache_list.m_update_done = 0; - (void) pthread_cond_init (&(g_cache_list.m_update_cond), NULL); - if (pthread_create ( - &(g_cache_list.m_update_thread), NULL, rtl_cache_wsupdate_all, (void*)(10)) != 0) - { - /* failure */ - g_cache_list.m_update_thread = (pthread_t)(0); - } - RTL_MEMORY_LOCK_RELEASE(&(g_cache_list.m_lock)); -} - -static void -rtl_cache_wsupdate_wait (unsigned int seconds) -{ - if (seconds > 0) - { - struct timeval now; - struct timespec wakeup; - - gettimeofday(&now, 0); - wakeup.tv_sec = now.tv_sec + (seconds); - wakeup.tv_nsec = now.tv_usec * 1000; - - (void) pthread_cond_timedwait ( - &(g_cache_list.m_update_cond), - &(g_cache_list.m_lock), - &wakeup); - } -} - -static void -rtl_cache_wsupdate_fini (void) -{ - RTL_MEMORY_LOCK_ACQUIRE(&(g_cache_list.m_lock)); - g_cache_list.m_update_done = 1; - pthread_cond_signal (&(g_cache_list.m_update_cond)); - RTL_MEMORY_LOCK_RELEASE(&(g_cache_list.m_lock)); - - if (g_cache_list.m_update_thread != (pthread_t)(0)) - pthread_join (g_cache_list.m_update_thread, NULL); -} - -/* ================================================================= */ - -#elif defined(SAL_W32) - -static DWORD WINAPI -rtl_cache_wsupdate_all (void * arg); - -static void -rtl_cache_wsupdate_init (void) -{ - DWORD dwThreadId; - - RTL_MEMORY_LOCK_ACQUIRE(&(g_cache_list.m_lock)); - g_cache_list.m_update_done = 0; - g_cache_list.m_update_cond = CreateEvent (0, TRUE, FALSE, 0); - - g_cache_list.m_update_thread = - CreateThread (NULL, 0, rtl_cache_wsupdate_all, (LPVOID)(10), 0, &dwThreadId); - RTL_MEMORY_LOCK_RELEASE(&(g_cache_list.m_lock)); -} - -static void -rtl_cache_wsupdate_wait (unsigned int seconds) -{ - if (seconds > 0) - { - RTL_MEMORY_LOCK_RELEASE(&(g_cache_list.m_lock)); - WaitForSingleObject (g_cache_list.m_update_cond, (DWORD)(seconds * 1000)); - RTL_MEMORY_LOCK_ACQUIRE(&(g_cache_list.m_lock)); - } -} - -static void -rtl_cache_wsupdate_fini (void) -{ - RTL_MEMORY_LOCK_ACQUIRE(&(g_cache_list.m_lock)); - g_cache_list.m_update_done = 1; - SetEvent (g_cache_list.m_update_cond); - RTL_MEMORY_LOCK_RELEASE(&(g_cache_list.m_lock)); - - WaitForSingleObject (g_cache_list.m_update_thread, INFINITE); -} - -#endif /* SAL_UNX || SAL_W32 */ - -/* ================================================================= */ - -/** rtl_cache_depot_wsupdate() - * update depot stats and purge excess magazines. - * - * @precond cache->m_depot_lock acquired - */ -static void -rtl_cache_depot_wsupdate ( - rtl_cache_type * cache, - rtl_cache_depot_type * depot -) -{ - sal_Size npurge; - - depot->m_prev_min = depot->m_curr_min; - depot->m_curr_min = depot->m_mag_count; - - npurge = SAL_MIN(depot->m_curr_min, depot->m_prev_min); - for (; npurge > 0; npurge--) - { - rtl_cache_magazine_type * mag = rtl_cache_depot_dequeue (depot); - if (mag != 0) - { - RTL_MEMORY_LOCK_RELEASE(&(cache->m_depot_lock)); - rtl_cache_magazine_clear (cache, mag); - rtl_cache_free (cache->m_magazine_cache, mag); - RTL_MEMORY_LOCK_ACQUIRE(&(cache->m_depot_lock)); - } - } -} - -/** rtl_cache_wsupdate() - * - * @precond cache->m_depot_lock released - */ -static void -rtl_cache_wsupdate ( - rtl_cache_type * cache -) -{ - if (cache->m_magazine_cache != 0) - { - RTL_MEMORY_LOCK_ACQUIRE(&(cache->m_depot_lock)); - - OSL_TRACE( - "rtl_cache_wsupdate(\"%s\") " - "[depot: count, curr_min, prev_min] " - "full: %lu, %lu, %lu; empty: %lu, %lu, %lu", - cache->m_name, - cache->m_depot_full.m_mag_count, - cache->m_depot_full.m_curr_min, - cache->m_depot_full.m_prev_min, - cache->m_depot_empty.m_mag_count, - cache->m_depot_empty.m_curr_min, - cache->m_depot_empty.m_prev_min - ); - - rtl_cache_depot_wsupdate (cache, &(cache->m_depot_full)); - rtl_cache_depot_wsupdate (cache, &(cache->m_depot_empty)); - - RTL_MEMORY_LOCK_RELEASE(&(cache->m_depot_lock)); - } -} - -/** rtl_cache_wsupdate_all() - * - */ -#if defined(SAL_UNX) -static void * -#elif defined(SAL_W32) -static DWORD WINAPI -#endif /* SAL_UNX || SAL_W32 */ -rtl_cache_wsupdate_all (void * arg) -{ - unsigned int seconds = (unsigned int)SAL_INT_CAST(sal_uIntPtr, arg); - - RTL_MEMORY_LOCK_ACQUIRE(&(g_cache_list.m_lock)); - while (!g_cache_list.m_update_done) - { - rtl_cache_wsupdate_wait (seconds); - if (!g_cache_list.m_update_done) - { - rtl_cache_type * head, * cache; - - head = &(g_cache_list.m_cache_head); - for (cache = head->m_cache_next; - cache != head; - cache = cache->m_cache_next) - { - rtl_cache_wsupdate (cache); - } - } - } - RTL_MEMORY_LOCK_RELEASE(&(g_cache_list.m_lock)); - - return (0); -} - -/* ================================================================= * - * - * cache initialization. - * - * ================================================================= */ - -void -rtl_cache_init (void) -{ - { - /* list of caches */ - RTL_MEMORY_LOCK_INIT(&(g_cache_list.m_lock)); - (void) rtl_cache_constructor (&(g_cache_list.m_cache_head)); - } - { - /* cache: internal arena */ - OSL_ASSERT(gp_cache_arena == 0); - - gp_cache_arena = rtl_arena_create ( - "rtl_cache_internal_arena", - 64, /* quantum */ - 0, /* no quantum caching */ - NULL, /* default source */ - rtl_arena_alloc, - rtl_arena_free, - 0 /* flags */ - ); - OSL_ASSERT(gp_cache_arena != 0); - - /* check 'gp_default_arena' initialization */ - OSL_ASSERT(gp_default_arena != 0); - } - { - /* cache: magazine cache */ - static rtl_cache_type g_cache_magazine_cache; - - OSL_ASSERT(gp_cache_magazine_cache == 0); - VALGRIND_CREATE_MEMPOOL(&g_cache_magazine_cache, 0, 0); - (void) rtl_cache_constructor (&g_cache_magazine_cache); - - gp_cache_magazine_cache = rtl_cache_activate ( - &g_cache_magazine_cache, - "rtl_cache_magazine_cache", - sizeof(rtl_cache_magazine_type), /* objsize */ - 0, /* objalign */ - rtl_cache_magazine_constructor, - rtl_cache_magazine_destructor, - 0, /* reclaim */ - 0, /* userarg: NYI */ - gp_default_arena, /* source */ - RTL_CACHE_FLAG_NOMAGAZINE /* during bootstrap; activated below */ - ); - OSL_ASSERT(gp_cache_magazine_cache != 0); - - /* activate magazine layer */ - g_cache_magazine_cache.m_magazine_cache = gp_cache_magazine_cache; - } - { - /* cache: slab (struct) cache */ - static rtl_cache_type g_cache_slab_cache; - - OSL_ASSERT(gp_cache_slab_cache == 0); - VALGRIND_CREATE_MEMPOOL(&g_cache_slab_cache, 0, 0); - (void) rtl_cache_constructor (&g_cache_slab_cache); - - gp_cache_slab_cache = rtl_cache_activate ( - &g_cache_slab_cache, - "rtl_cache_slab_cache", - sizeof(rtl_cache_slab_type), /* objsize */ - 0, /* objalign */ - rtl_cache_slab_constructor, - rtl_cache_slab_destructor, - 0, /* reclaim */ - 0, /* userarg: none */ - gp_default_arena, /* source */ - 0 /* flags: none */ - ); - OSL_ASSERT(gp_cache_slab_cache != 0); - } - { - /* cache: bufctl cache */ - static rtl_cache_type g_cache_bufctl_cache; - - OSL_ASSERT(gp_cache_bufctl_cache == 0); - VALGRIND_CREATE_MEMPOOL(&g_cache_bufctl_cache, 0, 0); - (void) rtl_cache_constructor (&g_cache_bufctl_cache); - - gp_cache_bufctl_cache = rtl_cache_activate ( - &g_cache_bufctl_cache, - "rtl_cache_bufctl_cache", - sizeof(rtl_cache_bufctl_type), /* objsize */ - 0, /* objalign */ - 0, /* constructor */ - 0, /* destructor */ - 0, /* reclaim */ - 0, /* userarg */ - gp_default_arena, /* source */ - 0 /* flags: none */ - ); - OSL_ASSERT(gp_cache_bufctl_cache != 0); - } - - rtl_cache_wsupdate_init(); - OSL_TRACE("rtl_cache_init completed"); -} - -/* ================================================================= */ - -void -rtl_cache_fini (void) -{ - if (gp_cache_arena != 0) - { - rtl_cache_type * cache, * head; - - rtl_cache_wsupdate_fini(); - - if (gp_cache_bufctl_cache != 0) - { - cache = gp_cache_bufctl_cache, gp_cache_bufctl_cache = 0; - rtl_cache_deactivate (cache); - rtl_cache_destructor (cache); - VALGRIND_DESTROY_MEMPOOL(cache); - } - if (gp_cache_slab_cache != 0) - { - cache = gp_cache_slab_cache, gp_cache_slab_cache = 0; - rtl_cache_deactivate (cache); - rtl_cache_destructor (cache); - VALGRIND_DESTROY_MEMPOOL(cache); - } - if (gp_cache_magazine_cache != 0) - { - cache = gp_cache_magazine_cache, gp_cache_magazine_cache = 0; - rtl_cache_deactivate (cache); - rtl_cache_destructor (cache); - VALGRIND_DESTROY_MEMPOOL(cache); - } - if (gp_cache_arena != 0) - { - rtl_arena_destroy (gp_cache_arena); - gp_cache_arena = 0; - } - - RTL_MEMORY_LOCK_ACQUIRE(&(g_cache_list.m_lock)); - head = &(g_cache_list.m_cache_head); - for (cache = head->m_cache_next; cache != head; cache = cache->m_cache_next) - { - OSL_TRACE( - "rtl_cache_fini(\"%s\") " - "[slab]: allocs: %"PRIu64", frees: %"PRIu64"; total: %lu, used: %lu; " - "[cpu]: allocs: %"PRIu64", frees: %"PRIu64"; " - "[total]: allocs: %"PRIu64", frees: %"PRIu64"", - cache->m_name, - cache->m_slab_stats.m_alloc, cache->m_slab_stats.m_free, - cache->m_slab_stats.m_mem_total, cache->m_slab_stats.m_mem_alloc, - cache->m_cpu_stats.m_alloc, cache->m_cpu_stats.m_free, - cache->m_slab_stats.m_alloc + cache->m_cpu_stats.m_alloc, - cache->m_slab_stats.m_free + cache->m_cpu_stats.m_free - ); - } - RTL_MEMORY_LOCK_RELEASE(&(g_cache_list.m_lock)); - } - OSL_TRACE("rtl_cache_fini completed"); -} - -/* ================================================================= */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/alloc_cache.cxx b/sal/rtl/source/alloc_cache.cxx new file mode 100644 index 000000000000..a1d8d5490961 --- /dev/null +++ b/sal/rtl/source/alloc_cache.cxx @@ -0,0 +1,1759 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "alloc_cache.hxx" +#include "alloc_impl.hxx" +#include "alloc_arena.hxx" +#include "internal/once.h" +#include "internal/rtllifecycle.h" +#include "sal/macros.h" +#include "osl/diagnose.h" + +#ifndef INCLUDED_STRING_H +#include +#endif + +#ifndef INCLUDED_STDIO_H +#include +#endif + +extern AllocMode alloc_mode; + +/* ================================================================= * + * + * cache internals. + * + * ================================================================= */ + +/** g_cache_list + * @internal + */ +struct rtl_cache_list_st +{ + rtl_memory_lock_type m_lock; + rtl_cache_type m_cache_head; + +#if defined(SAL_UNX) + pthread_t m_update_thread; + pthread_cond_t m_update_cond; +#elif defined(SAL_W32) + HANDLE m_update_thread; + HANDLE m_update_cond; +#endif /* SAL_UNX || SAL_W32 */ + int m_update_done; +}; + +static rtl_cache_list_st g_cache_list; + + +/** gp_cache_arena + * provided for cache_type allocations, and hash_table resizing. + * + * @internal + */ +static rtl_arena_type * gp_cache_arena = 0; + + +/** gp_cache_magazine_cache + * @internal + */ +static rtl_cache_type * gp_cache_magazine_cache = 0; + + +/** gp_cache_slab_cache + * @internal + */ +static rtl_cache_type * gp_cache_slab_cache = 0; + + +/** gp_cache_bufctl_cache + * @internal + */ +static rtl_cache_type * gp_cache_bufctl_cache = 0; + + +/* ================================================================= */ + +/** RTL_CACHE_HASH_INDEX() + */ +#define RTL_CACHE_HASH_INDEX_IMPL(a, s, q, m) \ + ((((a) + ((a) >> (s)) + ((a) >> ((s) << 1))) >> (q)) & (m)) + +#define RTL_CACHE_HASH_INDEX(cache, addr) \ + RTL_CACHE_HASH_INDEX_IMPL((addr), (cache)->m_hash_shift, (cache)->m_type_shift, ((cache)->m_hash_size - 1)) + + +/** rtl_cache_hash_rescale() + */ +static void +rtl_cache_hash_rescale ( + rtl_cache_type * cache, + sal_Size new_size +) +{ + rtl_cache_bufctl_type ** new_table; + sal_Size new_bytes; + + new_bytes = new_size * sizeof(rtl_cache_bufctl_type*); + new_table = (rtl_cache_bufctl_type**)rtl_arena_alloc(gp_cache_arena, &new_bytes); + + if (new_table != 0) + { + rtl_cache_bufctl_type ** old_table; + sal_Size old_size, i; + + memset (new_table, 0, new_bytes); + + RTL_MEMORY_LOCK_ACQUIRE(&(cache->m_slab_lock)); + + old_table = cache->m_hash_table; + old_size = cache->m_hash_size; + + OSL_TRACE( + "rtl_cache_hash_rescale(\"%s\"): " + "nbuf: % " PRIu64 " (ave: %" PRIu64 "), frees: %" PRIu64 " " + "[old_size: %lu, new_size: %lu]", + cache->m_name, + cache->m_slab_stats.m_alloc - cache->m_slab_stats.m_free, + (cache->m_slab_stats.m_alloc - cache->m_slab_stats.m_free) >> cache->m_hash_shift, + cache->m_slab_stats.m_free, + old_size, new_size); + + cache->m_hash_table = new_table; + cache->m_hash_size = new_size; + cache->m_hash_shift = highbit(cache->m_hash_size) - 1; + + for (i = 0; i < old_size; i++) + { + rtl_cache_bufctl_type * curr = old_table[i]; + while (curr != 0) + { + rtl_cache_bufctl_type * next = curr->m_next; + rtl_cache_bufctl_type ** head; + + head = &(cache->m_hash_table[RTL_CACHE_HASH_INDEX(cache, curr->m_addr)]); + curr->m_next = (*head); + (*head) = curr; + + curr = next; + } + old_table[i] = 0; + } + + RTL_MEMORY_LOCK_RELEASE(&(cache->m_slab_lock)); + + if (old_table != cache->m_hash_table_0) + { + sal_Size old_bytes = old_size * sizeof(rtl_cache_bufctl_type*); + rtl_arena_free (gp_cache_arena, old_table, old_bytes); + } + } +} + +/** rtl_cache_hash_insert() + */ +static RTL_MEMORY_INLINE sal_uIntPtr +rtl_cache_hash_insert ( + rtl_cache_type * cache, + rtl_cache_bufctl_type * bufctl +) +{ + rtl_cache_bufctl_type ** ppHead; + + ppHead = &(cache->m_hash_table[RTL_CACHE_HASH_INDEX(cache, bufctl->m_addr)]); + + bufctl->m_next = (*ppHead); + (*ppHead) = bufctl; + + return (bufctl->m_addr); +} + +#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) +#pragma inline(rtl_cache_hash_insert) +#endif /* __SUNPRO_C */ + + +/** rtl_cache_hash_remove() + */ +static rtl_cache_bufctl_type * +rtl_cache_hash_remove ( + rtl_cache_type * cache, + sal_uIntPtr addr +) +{ + rtl_cache_bufctl_type ** ppHead; + rtl_cache_bufctl_type * bufctl; + sal_Size lookups = 0; + + ppHead = &(cache->m_hash_table[RTL_CACHE_HASH_INDEX(cache, addr)]); + while ((bufctl = *ppHead) != 0) + { + if (bufctl->m_addr == addr) + { + *ppHead = bufctl->m_next, bufctl->m_next = 0; + break; + } + + lookups += 1; + ppHead = &(bufctl->m_next); + } + + OSL_ASSERT (bufctl != 0); /* bad free */ + + if (lookups > 1) + { + sal_Size nbuf = (sal_Size)(cache->m_slab_stats.m_alloc - cache->m_slab_stats.m_free); + if (nbuf > 4 * cache->m_hash_size) + { + if (!(cache->m_features & RTL_CACHE_FEATURE_RESCALE)) + { + sal_Size ave = nbuf >> cache->m_hash_shift; + sal_Size new_size = cache->m_hash_size << (highbit(ave) - 1); + + cache->m_features |= RTL_CACHE_FEATURE_RESCALE; + RTL_MEMORY_LOCK_RELEASE(&(cache->m_slab_lock)); + rtl_cache_hash_rescale (cache, new_size); + RTL_MEMORY_LOCK_ACQUIRE(&(cache->m_slab_lock)); + cache->m_features &= ~RTL_CACHE_FEATURE_RESCALE; + } + } + } + + return (bufctl); +} + +/* ================================================================= */ + +/** RTL_CACHE_SLAB() + */ +#define RTL_CACHE_SLAB(addr, size) \ + (((rtl_cache_slab_type*)(RTL_MEMORY_P2END((sal_uIntPtr)(addr), (size)))) - 1) + + +/** rtl_cache_slab_constructor() + */ +static int +rtl_cache_slab_constructor (void * obj, void *) +{ + rtl_cache_slab_type * slab = (rtl_cache_slab_type*)(obj); + + QUEUE_START_NAMED(slab, slab_); + slab->m_ntypes = 0; + + return (1); +} + + +/** rtl_cache_slab_destructor() + */ +static void +rtl_cache_slab_destructor (void * obj, void *) +{ +#if OSL_DEBUG_LEVEL == 0 + (void) obj; /* unused */ +#else /* OSL_DEBUG_LEVEL */ + rtl_cache_slab_type * slab = (rtl_cache_slab_type*)(obj); + + /* assure removed from queue(s) */ + OSL_ASSERT(QUEUE_STARTED_NAMED(slab, slab_)); + + /* assure no longer referenced */ + OSL_ASSERT(slab->m_ntypes == 0); +#endif /* OSL_DEBUG_LEVEL */ +} + + +/** rtl_cache_slab_create() + * + * @precond cache->m_slab_lock released. + */ +static rtl_cache_slab_type * +rtl_cache_slab_create ( + rtl_cache_type * cache +) +{ + rtl_cache_slab_type * slab = 0; + void * addr; + sal_Size size; + + size = cache->m_slab_size; + addr = rtl_arena_alloc (cache->m_source, &size); + if (addr != 0) + { + OSL_ASSERT(size >= cache->m_slab_size); + + if (cache->m_features & RTL_CACHE_FEATURE_HASH) + { + /* allocate slab struct from slab cache */ + OSL_ASSERT (cache != gp_cache_slab_cache); + slab = (rtl_cache_slab_type*)rtl_cache_alloc (gp_cache_slab_cache); + } + else + { + /* construct embedded slab struct */ + slab = RTL_CACHE_SLAB(addr, cache->m_slab_size); + (void) rtl_cache_slab_constructor (slab, 0); + } + if (slab != 0) + { + slab->m_data = (sal_uIntPtr)(addr); + + /* dynamic freelist initialization */ + slab->m_bp = slab->m_data; + slab->m_sp = 0; + } + else + { + rtl_arena_free (cache->m_source, addr, size); + } + } + return (slab); +} + + +/** rtl_cache_slab_destroy() + * + * @precond cache->m_slab_lock released. + */ +static void +rtl_cache_slab_destroy ( + rtl_cache_type * cache, + rtl_cache_slab_type * slab +) +{ + void * addr = (void*)(slab->m_data); + sal_Size refcnt = slab->m_ntypes; slab->m_ntypes = 0; + + if (cache->m_features & RTL_CACHE_FEATURE_HASH) + { + /* cleanup bufctl(s) for free buffer(s) */ + sal_Size ntypes = (slab->m_bp - slab->m_data) / cache->m_type_size; + for (ntypes -= refcnt; slab->m_sp != 0; ntypes--) + { + rtl_cache_bufctl_type * bufctl = slab->m_sp; + + /* pop from freelist */ + slab->m_sp = bufctl->m_next, bufctl->m_next = 0; + + /* return bufctl struct to bufctl cache */ + rtl_cache_free (gp_cache_bufctl_cache, bufctl); + } + OSL_ASSERT(ntypes == 0); + + /* return slab struct to slab cache */ + rtl_cache_free (gp_cache_slab_cache, slab); + } + else + { + /* destruct embedded slab struct */ + rtl_cache_slab_destructor (slab, 0); + } + + if ((refcnt == 0) || (cache->m_features & RTL_CACHE_FEATURE_BULKDESTROY)) + { + /* free memory */ + rtl_arena_free (cache->m_source, addr, cache->m_slab_size); + } +} + + +/** rtl_cache_slab_populate() + * + * @precond cache->m_slab_lock acquired. + */ +static int +rtl_cache_slab_populate ( + rtl_cache_type * cache +) +{ + rtl_cache_slab_type * slab; + + RTL_MEMORY_LOCK_RELEASE(&(cache->m_slab_lock)); + slab = rtl_cache_slab_create (cache); + RTL_MEMORY_LOCK_ACQUIRE(&(cache->m_slab_lock)); + if (slab != 0) + { + /* update buffer start addr w/ current color */ + slab->m_bp += cache->m_ncolor; + + /* update color for next slab */ + cache->m_ncolor += cache->m_type_align; + if (cache->m_ncolor > cache->m_ncolor_max) + cache->m_ncolor = 0; + + /* update stats */ + cache->m_slab_stats.m_mem_total += cache->m_slab_size; + + /* insert onto 'free' queue */ + QUEUE_INSERT_HEAD_NAMED(&(cache->m_free_head), slab, slab_); + } + return (slab != 0); +} + +/* ================================================================= */ + +/** rtl_cache_slab_alloc() + * + * Allocate a buffer from slab layer; used by magazine layer. + */ +static void * +rtl_cache_slab_alloc ( + rtl_cache_type * cache +) +{ + void * addr = 0; + rtl_cache_slab_type * head; + + RTL_MEMORY_LOCK_ACQUIRE(&(cache->m_slab_lock)); + + head = &(cache->m_free_head); + if ((head->m_slab_next != head) || rtl_cache_slab_populate (cache)) + { + rtl_cache_slab_type * slab; + rtl_cache_bufctl_type * bufctl; + + slab = head->m_slab_next; + OSL_ASSERT(slab->m_ntypes < cache->m_ntypes); + + if (slab->m_sp == 0) + { + /* initialize bufctl w/ current 'slab->m_bp' */ + OSL_ASSERT (slab->m_bp < slab->m_data + cache->m_ntypes * cache->m_type_size + cache->m_ncolor_max); + if (cache->m_features & RTL_CACHE_FEATURE_HASH) + { + /* allocate bufctl */ + OSL_ASSERT (cache != gp_cache_bufctl_cache); + bufctl = (rtl_cache_bufctl_type*)rtl_cache_alloc (gp_cache_bufctl_cache); + if (bufctl == 0) + { + /* out of memory */ + RTL_MEMORY_LOCK_RELEASE(&(cache->m_slab_lock)); + return (0); + } + + bufctl->m_addr = slab->m_bp; + bufctl->m_slab = (sal_uIntPtr)(slab); + } + else + { + /* embedded bufctl */ + bufctl = (rtl_cache_bufctl_type*)(slab->m_bp); + } + bufctl->m_next = 0; + + /* update 'slab->m_bp' to next free buffer */ + slab->m_bp += cache->m_type_size; + + /* assign bufctl to freelist */ + slab->m_sp = bufctl; + } + + /* pop front */ + bufctl = slab->m_sp; + slab->m_sp = bufctl->m_next; + + /* increment usage, check for full slab */ + if ((slab->m_ntypes += 1) == cache->m_ntypes) + { + /* remove from 'free' queue */ + QUEUE_REMOVE_NAMED(slab, slab_); + + /* insert onto 'used' queue (tail) */ + QUEUE_INSERT_TAIL_NAMED(&(cache->m_used_head), slab, slab_); + } + + /* update stats */ + cache->m_slab_stats.m_alloc += 1; + cache->m_slab_stats.m_mem_alloc += cache->m_type_size; + + if (cache->m_features & RTL_CACHE_FEATURE_HASH) + addr = (void*)rtl_cache_hash_insert (cache, bufctl); + else + addr = bufctl; + + /* DEBUG ONLY: mark allocated, undefined */ + /* OSL_DEBUG_ONLY() */ RTL_VALGRIND_IGNORE_VAL VALGRIND_MAKE_MEM_UNDEFINED(addr, cache->m_type_size); + OSL_DEBUG_ONLY(memset(addr, 0x77777777, cache->m_type_size)); + VALGRIND_MEMPOOL_ALLOC(cache, addr, cache->m_type_size); + } + + RTL_MEMORY_LOCK_RELEASE(&(cache->m_slab_lock)); + return (addr); +} + + +/** rtl_cache_slab_free() + * + * Return a buffer to slab layer; used by magazine layer. + */ +static void +rtl_cache_slab_free ( + rtl_cache_type * cache, + void * addr +) +{ + rtl_cache_bufctl_type * bufctl; + rtl_cache_slab_type * slab; + + RTL_MEMORY_LOCK_ACQUIRE(&(cache->m_slab_lock)); + + /* DEBUG ONLY: mark unallocated, undefined */ + VALGRIND_MEMPOOL_FREE(cache, addr); + /* OSL_DEBUG_ONLY() */ RTL_VALGRIND_IGNORE_VAL VALGRIND_MAKE_MEM_UNDEFINED(addr, cache->m_type_size); + OSL_DEBUG_ONLY(memset(addr, 0x33333333, cache->m_type_size)); + + /* determine slab from addr */ + if (cache->m_features & RTL_CACHE_FEATURE_HASH) + { + bufctl = rtl_cache_hash_remove (cache, (sal_uIntPtr)(addr)); + slab = (bufctl != 0) ? (rtl_cache_slab_type*)(bufctl->m_slab) : 0; + } + else + { + /* embedded slab struct */ + bufctl = (rtl_cache_bufctl_type*)(addr); + slab = RTL_CACHE_SLAB(addr, cache->m_slab_size); + } + + if (slab != 0) + { + /* check for full slab */ + if (slab->m_ntypes == cache->m_ntypes) + { + /* remove from 'used' queue */ + QUEUE_REMOVE_NAMED(slab, slab_); + + /* insert onto 'free' queue (head) */ + QUEUE_INSERT_HEAD_NAMED(&(cache->m_free_head), slab, slab_); + } + + /* push front */ + bufctl->m_next = slab->m_sp; + slab->m_sp = bufctl; + + /* update stats */ + cache->m_slab_stats.m_free += 1; + cache->m_slab_stats.m_mem_alloc -= cache->m_type_size; + + /* decrement usage, check for empty slab */ + if ((slab->m_ntypes -= 1) == 0) + { + /* remove from 'free' queue */ + QUEUE_REMOVE_NAMED(slab, slab_); + + /* update stats */ + cache->m_slab_stats.m_mem_total -= cache->m_slab_size; + + /* free 'empty' slab */ + RTL_MEMORY_LOCK_RELEASE(&(cache->m_slab_lock)); + rtl_cache_slab_destroy (cache, slab); + return; + } + } + + RTL_MEMORY_LOCK_RELEASE(&(cache->m_slab_lock)); +} + +/* ================================================================= */ + +/** rtl_cache_magazine_constructor() + */ +static int +rtl_cache_magazine_constructor (void * obj, void *) +{ + rtl_cache_magazine_type * mag = (rtl_cache_magazine_type*)(obj); + /* @@@ sal_Size size = (sal_Size)(arg); @@@ */ + + mag->m_mag_next = 0; + mag->m_mag_size = RTL_CACHE_MAGAZINE_SIZE; + mag->m_mag_used = 0; + + return (1); +} + + +/** rtl_cache_magazine_destructor() + */ +static void +rtl_cache_magazine_destructor (void * obj, void *) +{ +#if OSL_DEBUG_LEVEL == 0 + (void) obj; /* unused */ +#else /* OSL_DEBUG_LEVEL */ + rtl_cache_magazine_type * mag = (rtl_cache_magazine_type*)(obj); + + /* assure removed from queue(s) */ + OSL_ASSERT(mag->m_mag_next == 0); + + /* assure no longer referenced */ + OSL_ASSERT(mag->m_mag_used == 0); +#endif /* OSL_DEBUG_LEVEL */ +} + + +/** rtl_cache_magazine_clear() + */ +static void +rtl_cache_magazine_clear ( + rtl_cache_type * cache, + rtl_cache_magazine_type * mag +) +{ + for (; mag->m_mag_used > 0; --mag->m_mag_used) + { + void * obj = mag->m_objects[mag->m_mag_used - 1]; + mag->m_objects[mag->m_mag_used - 1] = 0; + + /* DEBUG ONLY: mark cached object allocated, undefined */ + VALGRIND_MEMPOOL_ALLOC(cache, obj, cache->m_type_size); + if (cache->m_destructor != 0) + { + /* DEBUG ONLY: keep constructed object defined */ + RTL_VALGRIND_IGNORE_VAL VALGRIND_MAKE_MEM_DEFINED(obj, cache->m_type_size); + + /* destruct object */ + (cache->m_destructor)(obj, cache->m_userarg); + } + + /* return buffer to slab layer */ + rtl_cache_slab_free (cache, obj); + } +} + +/* ================================================================= */ + +/** rtl_cache_depot_enqueue() + * + * @precond cache->m_depot_lock acquired. + */ +static RTL_MEMORY_INLINE void +rtl_cache_depot_enqueue ( + rtl_cache_depot_type * depot, + rtl_cache_magazine_type * mag +) +{ + /* enqueue empty magazine */ + mag->m_mag_next = depot->m_mag_next; + depot->m_mag_next = mag; + + /* update depot stats */ + depot->m_mag_count++; +} + +#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) +#pragma inline(rtl_cache_depot_enqueue) +#endif /* __SUNPRO_C */ + + +/** rtl_cache_depot_dequeue() + * + * @precond cache->m_depot_lock acquired. + */ +static RTL_MEMORY_INLINE rtl_cache_magazine_type * +rtl_cache_depot_dequeue ( + rtl_cache_depot_type * depot +) +{ + rtl_cache_magazine_type * mag = 0; + if (depot->m_mag_count > 0) + { + /* dequeue magazine */ + OSL_ASSERT(depot->m_mag_next != 0); + + mag = depot->m_mag_next; + depot->m_mag_next = mag->m_mag_next; + mag->m_mag_next = 0; + + /* update depot stats */ + depot->m_mag_count--; + depot->m_curr_min = SAL_MIN(depot->m_curr_min, depot->m_mag_count); + } + return (mag); +} + +#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) +#pragma inline(rtl_cache_depot_dequeue) +#endif /* __SUNPRO_C */ + + +/** rtl_cache_depot_exchange_alloc() + * + * @precond cache->m_depot_lock acquired. + */ +static RTL_MEMORY_INLINE rtl_cache_magazine_type * +rtl_cache_depot_exchange_alloc ( + rtl_cache_type * cache, + rtl_cache_magazine_type * empty +) +{ + rtl_cache_magazine_type * full; + + OSL_ASSERT((empty == 0) || (empty->m_mag_used == 0)); + + /* dequeue full magazine */ + full = rtl_cache_depot_dequeue (&(cache->m_depot_full)); + if ((full != 0) && (empty != 0)) + { + /* enqueue empty magazine */ + rtl_cache_depot_enqueue (&(cache->m_depot_empty), empty); + } + + OSL_ASSERT((full == 0) || (full->m_mag_used > 0)); + + return (full); +} + +#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) +#pragma inline(rtl_cache_depot_exchange_alloc) +#endif /* __SUNPRO_C */ + + +/** rtl_cache_depot_exchange_free() + * + * @precond cache->m_depot_lock acquired. + */ +static RTL_MEMORY_INLINE rtl_cache_magazine_type * +rtl_cache_depot_exchange_free ( + rtl_cache_type * cache, + rtl_cache_magazine_type * full +) +{ + rtl_cache_magazine_type * empty; + + OSL_ASSERT((full == 0) || (full->m_mag_used > 0)); + + /* dequeue empty magazine */ + empty = rtl_cache_depot_dequeue (&(cache->m_depot_empty)); + if ((empty != 0) && (full != 0)) + { + /* enqueue full magazine */ + rtl_cache_depot_enqueue (&(cache->m_depot_full), full); + } + + OSL_ASSERT((empty == 0) || (empty->m_mag_used == 0)); + + return (empty); +} + +#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) +#pragma inline(rtl_cache_depot_exchange_free) +#endif /* __SUNPRO_C */ + + +/** rtl_cache_depot_populate() + * + * @precond cache->m_depot_lock acquired. + */ +static int +rtl_cache_depot_populate ( + rtl_cache_type * cache +) +{ + rtl_cache_magazine_type * empty = 0; + + if (cache->m_magazine_cache != 0) + { + /* allocate new empty magazine */ + RTL_MEMORY_LOCK_RELEASE(&(cache->m_depot_lock)); + empty = (rtl_cache_magazine_type*)rtl_cache_alloc (cache->m_magazine_cache); + RTL_MEMORY_LOCK_ACQUIRE(&(cache->m_depot_lock)); + if (empty != 0) + { + /* enqueue (new) empty magazine */ + rtl_cache_depot_enqueue (&(cache->m_depot_empty), empty); + } + } + return (empty != 0); +} + +/* ================================================================= */ + +/** rtl_cache_constructor() + */ +static int +rtl_cache_constructor (void * obj) +{ + rtl_cache_type * cache = (rtl_cache_type*)(obj); + + memset (cache, 0, sizeof(rtl_cache_type)); + + /* linkage */ + QUEUE_START_NAMED(cache, cache_); + + /* slab layer */ + (void)RTL_MEMORY_LOCK_INIT(&(cache->m_slab_lock)); + + QUEUE_START_NAMED(&(cache->m_free_head), slab_); + QUEUE_START_NAMED(&(cache->m_used_head), slab_); + + cache->m_hash_table = cache->m_hash_table_0; + cache->m_hash_size = RTL_CACHE_HASH_SIZE; + cache->m_hash_shift = highbit(cache->m_hash_size) - 1; + + /* depot layer */ + (void)RTL_MEMORY_LOCK_INIT(&(cache->m_depot_lock)); + + return (1); +} + +/** rtl_cache_destructor() + */ +static void +rtl_cache_destructor (void * obj) +{ + rtl_cache_type * cache = (rtl_cache_type*)(obj); + + /* linkage */ + OSL_ASSERT(QUEUE_STARTED_NAMED(cache, cache_)); + + /* slab layer */ + (void)RTL_MEMORY_LOCK_DESTROY(&(cache->m_slab_lock)); + + OSL_ASSERT(QUEUE_STARTED_NAMED(&(cache->m_free_head), slab_)); + OSL_ASSERT(QUEUE_STARTED_NAMED(&(cache->m_used_head), slab_)); + + OSL_ASSERT(cache->m_hash_table == cache->m_hash_table_0); + OSL_ASSERT(cache->m_hash_size == RTL_CACHE_HASH_SIZE); + OSL_ASSERT(cache->m_hash_shift == (sal_Size)(highbit(cache->m_hash_size) - 1)); + + /* depot layer */ + (void)RTL_MEMORY_LOCK_DESTROY(&(cache->m_depot_lock)); +} + +/* ================================================================= */ + +/** rtl_cache_activate() + */ +static rtl_cache_type * +rtl_cache_activate ( + rtl_cache_type * cache, + const char * name, + size_t objsize, + size_t objalign, + int (SAL_CALL * constructor)(void * obj, void * userarg), + void (SAL_CALL * destructor) (void * obj, void * userarg), + void (SAL_CALL * reclaim) (void * userarg), + void * userarg, + rtl_arena_type * source, + int flags +) +{ + OSL_ASSERT(cache != 0); + if (cache != 0) + { + sal_Size slabsize; + + snprintf (cache->m_name, sizeof(cache->m_name), "%s", name); + + /* ensure minimum size (embedded bufctl linkage) */ + objsize = SAL_MAX(objsize, sizeof(rtl_cache_bufctl_type*)); + + if (objalign == 0) + { + /* determine default alignment */ + if (objsize >= RTL_MEMORY_ALIGNMENT_8) + objalign = RTL_MEMORY_ALIGNMENT_8; + else + objalign = RTL_MEMORY_ALIGNMENT_4; + } + else + { + /* ensure minimum alignment */ + objalign = SAL_MAX(objalign, RTL_MEMORY_ALIGNMENT_4); + } + OSL_ASSERT(RTL_MEMORY_ISP2(objalign)); + + cache->m_type_size = objsize = RTL_MEMORY_P2ROUNDUP(objsize, objalign); + cache->m_type_align = objalign; + cache->m_type_shift = highbit(cache->m_type_size) - 1; + + cache->m_constructor = constructor; + cache->m_destructor = destructor; + cache->m_reclaim = reclaim; + cache->m_userarg = userarg; + + /* slab layer */ + cache->m_source = source; + + slabsize = source->m_quantum; /* minimum slab size */ + if (flags & RTL_CACHE_FLAG_QUANTUMCACHE) + { + /* next power of 2 above 3 * qcache_max */ + slabsize = SAL_MAX(slabsize, (1UL << highbit(3 * source->m_qcache_max))); + } + else + { + /* waste at most 1/8 of slab */ + slabsize = SAL_MAX(slabsize, cache->m_type_size * 8); + } + + slabsize = RTL_MEMORY_P2ROUNDUP(slabsize, source->m_quantum); + if (!RTL_MEMORY_ISP2(slabsize)) + slabsize = 1UL << highbit(slabsize); + cache->m_slab_size = slabsize; + + if (cache->m_slab_size > source->m_quantum) + { + OSL_ASSERT(gp_cache_slab_cache != 0); + OSL_ASSERT(gp_cache_bufctl_cache != 0); + + cache->m_features |= RTL_CACHE_FEATURE_HASH; + cache->m_ntypes = cache->m_slab_size / cache->m_type_size; + cache->m_ncolor_max = cache->m_slab_size % cache->m_type_size; + } + else + { + /* embedded slab struct */ + cache->m_ntypes = (cache->m_slab_size - sizeof(rtl_cache_slab_type)) / cache->m_type_size; + cache->m_ncolor_max = (cache->m_slab_size - sizeof(rtl_cache_slab_type)) % cache->m_type_size; + } + + OSL_ASSERT(cache->m_ntypes > 0); + cache->m_ncolor = 0; + + if (flags & RTL_CACHE_FLAG_BULKDESTROY) + { + /* allow bulk slab delete upon cache deactivation */ + cache->m_features |= RTL_CACHE_FEATURE_BULKDESTROY; + } + + /* magazine layer */ + if (!(flags & RTL_CACHE_FLAG_NOMAGAZINE)) + { + OSL_ASSERT(gp_cache_magazine_cache != 0); + cache->m_magazine_cache = gp_cache_magazine_cache; + } + + /* insert into cache list */ + RTL_MEMORY_LOCK_ACQUIRE(&(g_cache_list.m_lock)); + QUEUE_INSERT_TAIL_NAMED(&(g_cache_list.m_cache_head), cache, cache_); + RTL_MEMORY_LOCK_RELEASE(&(g_cache_list.m_lock)); + } + return (cache); +} + +/** rtl_cache_deactivate() + */ +static void +rtl_cache_deactivate ( + rtl_cache_type * cache +) +{ + int active = 1; + + /* remove from cache list */ + RTL_MEMORY_LOCK_ACQUIRE(&(g_cache_list.m_lock)); + active = QUEUE_STARTED_NAMED(cache, cache_) == 0; + QUEUE_REMOVE_NAMED(cache, cache_); + RTL_MEMORY_LOCK_RELEASE(&(g_cache_list.m_lock)); + + OSL_PRECOND(active, "rtl_cache_deactivate(): orphaned cache."); + (void)active; + + /* cleanup magazine layer */ + if (cache->m_magazine_cache != 0) + { + rtl_cache_type * mag_cache; + rtl_cache_magazine_type * mag; + + /* prevent recursion */ + mag_cache = cache->m_magazine_cache, cache->m_magazine_cache = 0; + + /* cleanup cpu layer */ + if ((mag = cache->m_cpu_curr) != 0) + { + cache->m_cpu_curr = 0; + rtl_cache_magazine_clear (cache, mag); + rtl_cache_free (mag_cache, mag); + } + if ((mag = cache->m_cpu_prev) != 0) + { + cache->m_cpu_prev = 0; + rtl_cache_magazine_clear (cache, mag); + rtl_cache_free (mag_cache, mag); + } + + /* cleanup depot layer */ + while ((mag = rtl_cache_depot_dequeue(&(cache->m_depot_full))) != 0) + { + rtl_cache_magazine_clear (cache, mag); + rtl_cache_free (mag_cache, mag); + } + while ((mag = rtl_cache_depot_dequeue(&(cache->m_depot_empty))) != 0) + { + rtl_cache_magazine_clear (cache, mag); + rtl_cache_free (mag_cache, mag); + } + } + + OSL_TRACE( + "rtl_cache_deactivate(\"%s\"): " + "[slab]: allocs: %"PRIu64", frees: %"PRIu64"; total: %lu, used: %lu; " + "[cpu]: allocs: %"PRIu64", frees: %"PRIu64"; " + "[total]: allocs: %"PRIu64", frees: %"PRIu64"", + cache->m_name, + cache->m_slab_stats.m_alloc, cache->m_slab_stats.m_free, + cache->m_slab_stats.m_mem_total, cache->m_slab_stats.m_mem_alloc, + cache->m_cpu_stats.m_alloc, cache->m_cpu_stats.m_free, + cache->m_slab_stats.m_alloc + cache->m_cpu_stats.m_alloc, + cache->m_slab_stats.m_free + cache->m_cpu_stats.m_free + ); + + /* cleanup slab layer */ + if (cache->m_slab_stats.m_alloc > cache->m_slab_stats.m_free) + { + OSL_TRACE( + "rtl_cache_deactivate(\"%s\"): " + "cleaning up %"PRIu64" leaked buffer(s) [%lu bytes] [%lu total]", + cache->m_name, + cache->m_slab_stats.m_alloc - cache->m_slab_stats.m_free, + cache->m_slab_stats.m_mem_alloc, cache->m_slab_stats.m_mem_total + ); + + if (cache->m_features & RTL_CACHE_FEATURE_HASH) + { + /* cleanup bufctl(s) for leaking buffer(s) */ + sal_Size i, n = cache->m_hash_size; + for (i = 0; i < n; i++) + { + rtl_cache_bufctl_type * bufctl; + while ((bufctl = cache->m_hash_table[i]) != 0) + { + /* pop from hash table */ + cache->m_hash_table[i] = bufctl->m_next, bufctl->m_next = 0; + + /* return to bufctl cache */ + rtl_cache_free (gp_cache_bufctl_cache, bufctl); + } + } + } + { + /* force cleanup of remaining slabs */ + rtl_cache_slab_type *head, *slab; + + head = &(cache->m_used_head); + for (slab = head->m_slab_next; slab != head; slab = head->m_slab_next) + { + /* remove from 'used' queue */ + QUEUE_REMOVE_NAMED(slab, slab_); + + /* update stats */ + cache->m_slab_stats.m_mem_total -= cache->m_slab_size; + + /* free slab */ + rtl_cache_slab_destroy (cache, slab); + } + + head = &(cache->m_free_head); + for (slab = head->m_slab_next; slab != head; slab = head->m_slab_next) + { + /* remove from 'free' queue */ + QUEUE_REMOVE_NAMED(slab, slab_); + + /* update stats */ + cache->m_slab_stats.m_mem_total -= cache->m_slab_size; + + /* free slab */ + rtl_cache_slab_destroy (cache, slab); + } + } + } + + if (cache->m_hash_table != cache->m_hash_table_0) + { + rtl_arena_free ( + gp_cache_arena, + cache->m_hash_table, + cache->m_hash_size * sizeof(rtl_cache_bufctl_type*)); + + cache->m_hash_table = cache->m_hash_table_0; + cache->m_hash_size = RTL_CACHE_HASH_SIZE; + cache->m_hash_shift = highbit(cache->m_hash_size) - 1; + } +} + +/* ================================================================= * + * + * cache implementation. + * + * ================================================================= */ + +/** rtl_cache_create() + */ +rtl_cache_type * +SAL_CALL rtl_cache_create ( + const char * name, + sal_Size objsize, + sal_Size objalign, + int (SAL_CALL * constructor)(void * obj, void * userarg), + void (SAL_CALL * destructor) (void * obj, void * userarg), + void (SAL_CALL * reclaim) (void * userarg), + void * userarg, + rtl_arena_type * source, + int flags +) SAL_THROW_EXTERN_C() +{ + rtl_cache_type * result = 0; + sal_Size size = sizeof(rtl_cache_type); + +try_alloc: + result = (rtl_cache_type*)rtl_arena_alloc (gp_cache_arena, &size); + if (result != 0) + { + rtl_cache_type * cache = result; + VALGRIND_CREATE_MEMPOOL(cache, 0, 0); + (void) rtl_cache_constructor (cache); + + if (!source) + { + /* use default arena */ + OSL_ASSERT(gp_default_arena != 0); + source = gp_default_arena; + } + + result = rtl_cache_activate ( + cache, + name, + objsize, + objalign, + constructor, + destructor, + reclaim, + userarg, + source, + flags + ); + + if (result == 0) + { + /* activation failed */ + rtl_cache_deactivate (cache); + rtl_cache_destructor (cache); + VALGRIND_DESTROY_MEMPOOL(cache); + rtl_arena_free (gp_cache_arena, cache, size); + } + } + else if (gp_cache_arena == 0) + { + ensureCacheSingleton(); + if (gp_cache_arena) + { + /* try again */ + goto try_alloc; + } + } + return (result); +} + +/** rtl_cache_destroy() + */ +void SAL_CALL rtl_cache_destroy ( + rtl_cache_type * cache +) SAL_THROW_EXTERN_C() +{ + if (cache != 0) + { + rtl_cache_deactivate (cache); + rtl_cache_destructor (cache); + VALGRIND_DESTROY_MEMPOOL(cache); + rtl_arena_free (gp_cache_arena, cache, sizeof(rtl_cache_type)); + } +} + +/** rtl_cache_alloc() + */ +void * +SAL_CALL rtl_cache_alloc ( + rtl_cache_type * cache +) SAL_THROW_EXTERN_C() +{ + void * obj = 0; + + if (cache == 0) + return (0); + + if (alloc_mode == AMode_SYSTEM) + { + obj = rtl_allocateMemory(cache->m_type_size); + if ((obj != 0) && (cache->m_constructor != 0)) + { + if (!((cache->m_constructor)(obj, cache->m_userarg))) + { + /* construction failure */ + rtl_freeMemory(obj), obj = 0; + } + } + return obj; + } + + RTL_MEMORY_LOCK_ACQUIRE(&(cache->m_depot_lock)); + if (cache->m_cpu_curr != 0) + { + for (;;) + { + /* take object from magazine layer */ + rtl_cache_magazine_type *curr, *prev, *temp; + + curr = cache->m_cpu_curr; + if ((curr != 0) && (curr->m_mag_used > 0)) + { + obj = curr->m_objects[--curr->m_mag_used]; +#if defined(HAVE_VALGRIND_MEMCHECK_H) + VALGRIND_MEMPOOL_ALLOC(cache, obj, cache->m_type_size); + if (cache->m_constructor != 0) + { + /* keep constructed object defined */ + RTL_VALGRIND_IGNORE_VAL VALGRIND_MAKE_MEM_DEFINED(obj, cache->m_type_size); + } +#endif /* HAVE_VALGRIND_MEMCHECK_H */ + cache->m_cpu_stats.m_alloc += 1; + RTL_MEMORY_LOCK_RELEASE(&(cache->m_depot_lock)); + + return (obj); + } + + prev = cache->m_cpu_prev; + if ((prev != 0) && (prev->m_mag_used > 0)) + { + temp = cache->m_cpu_curr; + cache->m_cpu_curr = cache->m_cpu_prev; + cache->m_cpu_prev = temp; + + continue; + } + + temp = rtl_cache_depot_exchange_alloc (cache, prev); + if (temp != 0) + { + cache->m_cpu_prev = cache->m_cpu_curr; + cache->m_cpu_curr = temp; + + continue; + } + + /* no full magazine: fall through to slab layer */ + break; + } + } + RTL_MEMORY_LOCK_RELEASE(&(cache->m_depot_lock)); + + /* alloc buffer from slab layer */ + obj = rtl_cache_slab_alloc (cache); + if ((obj != 0) && (cache->m_constructor != 0)) + { + /* construct object */ + if (!((cache->m_constructor)(obj, cache->m_userarg))) + { + /* construction failure */ + rtl_cache_slab_free (cache, obj), obj = 0; + } + } + return (obj); +} + +/** rtl_cache_free() + */ +void +SAL_CALL rtl_cache_free ( + rtl_cache_type * cache, + void * obj +) SAL_THROW_EXTERN_C() +{ + if ((obj != 0) && (cache != 0)) + { + if (alloc_mode == AMode_SYSTEM) + { + if (cache->m_destructor != 0) + { + /* destruct object */ + (cache->m_destructor)(obj, cache->m_userarg); + } + rtl_freeMemory(obj); + return; + } + + RTL_MEMORY_LOCK_ACQUIRE(&(cache->m_depot_lock)); + + for (;;) + { + /* return object to magazine layer */ + rtl_cache_magazine_type *curr, *prev, *temp; + + curr = cache->m_cpu_curr; + if ((curr != 0) && (curr->m_mag_used < curr->m_mag_size)) + { + curr->m_objects[curr->m_mag_used++] = obj; +#if defined(HAVE_VALGRIND_MEMCHECK_H) + VALGRIND_MEMPOOL_FREE(cache, obj); +#endif /* HAVE_VALGRIND_MEMCHECK_H */ + cache->m_cpu_stats.m_free += 1; + RTL_MEMORY_LOCK_RELEASE(&(cache->m_depot_lock)); + + return; + } + + prev = cache->m_cpu_prev; + if ((prev != 0) && (prev->m_mag_used == 0)) + { + temp = cache->m_cpu_curr; + cache->m_cpu_curr = cache->m_cpu_prev; + cache->m_cpu_prev = temp; + + continue; + } + + temp = rtl_cache_depot_exchange_free (cache, prev); + if (temp != 0) + { + cache->m_cpu_prev = cache->m_cpu_curr; + cache->m_cpu_curr = temp; + + continue; + } + + if (rtl_cache_depot_populate(cache) != 0) + { + continue; + } + + /* no empty magazine: fall through to slab layer */ + break; + } + + RTL_MEMORY_LOCK_RELEASE(&(cache->m_depot_lock)); + + /* no space for constructed object in magazine layer */ + if (cache->m_destructor != 0) + { + /* destruct object */ + (cache->m_destructor)(obj, cache->m_userarg); + } + + /* return buffer to slab layer */ + rtl_cache_slab_free (cache, obj); + } +} + +/* ================================================================= * + * + * cache wsupdate (machdep) internals. + * + * ================================================================= */ + +/** rtl_cache_wsupdate_init() + * + * @precond g_cache_list.m_lock initialized + */ +static void +rtl_cache_wsupdate_init(); + + +/** rtl_cache_wsupdate_wait() + * + * @precond g_cache_list.m_lock acquired + */ +static void +rtl_cache_wsupdate_wait ( + unsigned int seconds +); + +/** rtl_cache_wsupdate_fini() + * + */ +static void +rtl_cache_wsupdate_fini(); + +/* ================================================================= */ + +#if defined(SAL_UNX) + +#include + +static void * +rtl_cache_wsupdate_all (void * arg); + +static void +rtl_cache_wsupdate_init() +{ + RTL_MEMORY_LOCK_ACQUIRE(&(g_cache_list.m_lock)); + g_cache_list.m_update_done = 0; + (void) pthread_cond_init (&(g_cache_list.m_update_cond), NULL); + if (pthread_create ( + &(g_cache_list.m_update_thread), NULL, rtl_cache_wsupdate_all, (void*)(10)) != 0) + { + /* failure */ + g_cache_list.m_update_thread = (pthread_t)(0); + } + RTL_MEMORY_LOCK_RELEASE(&(g_cache_list.m_lock)); +} + +static void +rtl_cache_wsupdate_wait (unsigned int seconds) +{ + if (seconds > 0) + { + timeval now; + timespec wakeup; + + gettimeofday(&now, 0); + wakeup.tv_sec = now.tv_sec + (seconds); + wakeup.tv_nsec = now.tv_usec * 1000; + + (void) pthread_cond_timedwait ( + &(g_cache_list.m_update_cond), + &(g_cache_list.m_lock), + &wakeup); + } +} + +static void +rtl_cache_wsupdate_fini() +{ + RTL_MEMORY_LOCK_ACQUIRE(&(g_cache_list.m_lock)); + g_cache_list.m_update_done = 1; + pthread_cond_signal (&(g_cache_list.m_update_cond)); + RTL_MEMORY_LOCK_RELEASE(&(g_cache_list.m_lock)); + + if (g_cache_list.m_update_thread != (pthread_t)(0)) + pthread_join (g_cache_list.m_update_thread, NULL); +} + +/* ================================================================= */ + +#elif defined(SAL_W32) + +static DWORD WINAPI +rtl_cache_wsupdate_all (void * arg); + +static void +rtl_cache_wsupdate_init() +{ + DWORD dwThreadId; + + RTL_MEMORY_LOCK_ACQUIRE(&(g_cache_list.m_lock)); + g_cache_list.m_update_done = 0; + g_cache_list.m_update_cond = CreateEvent (0, TRUE, FALSE, 0); + + g_cache_list.m_update_thread = + CreateThread (NULL, 0, rtl_cache_wsupdate_all, (LPVOID)(10), 0, &dwThreadId); + RTL_MEMORY_LOCK_RELEASE(&(g_cache_list.m_lock)); +} + +static void +rtl_cache_wsupdate_wait (unsigned int seconds) +{ + if (seconds > 0) + { + RTL_MEMORY_LOCK_RELEASE(&(g_cache_list.m_lock)); + WaitForSingleObject (g_cache_list.m_update_cond, (DWORD)(seconds * 1000)); + RTL_MEMORY_LOCK_ACQUIRE(&(g_cache_list.m_lock)); + } +} + +static void +rtl_cache_wsupdate_fini() +{ + RTL_MEMORY_LOCK_ACQUIRE(&(g_cache_list.m_lock)); + g_cache_list.m_update_done = 1; + SetEvent (g_cache_list.m_update_cond); + RTL_MEMORY_LOCK_RELEASE(&(g_cache_list.m_lock)); + + WaitForSingleObject (g_cache_list.m_update_thread, INFINITE); +} + +#endif /* SAL_UNX || SAL_W32 */ + +/* ================================================================= */ + +/** rtl_cache_depot_wsupdate() + * update depot stats and purge excess magazines. + * + * @precond cache->m_depot_lock acquired + */ +static void +rtl_cache_depot_wsupdate ( + rtl_cache_type * cache, + rtl_cache_depot_type * depot +) +{ + sal_Size npurge; + + depot->m_prev_min = depot->m_curr_min; + depot->m_curr_min = depot->m_mag_count; + + npurge = SAL_MIN(depot->m_curr_min, depot->m_prev_min); + for (; npurge > 0; npurge--) + { + rtl_cache_magazine_type * mag = rtl_cache_depot_dequeue (depot); + if (mag != 0) + { + RTL_MEMORY_LOCK_RELEASE(&(cache->m_depot_lock)); + rtl_cache_magazine_clear (cache, mag); + rtl_cache_free (cache->m_magazine_cache, mag); + RTL_MEMORY_LOCK_ACQUIRE(&(cache->m_depot_lock)); + } + } +} + +/** rtl_cache_wsupdate() + * + * @precond cache->m_depot_lock released + */ +static void +rtl_cache_wsupdate ( + rtl_cache_type * cache +) +{ + if (cache->m_magazine_cache != 0) + { + RTL_MEMORY_LOCK_ACQUIRE(&(cache->m_depot_lock)); + + OSL_TRACE( + "rtl_cache_wsupdate(\"%s\") " + "[depot: count, curr_min, prev_min] " + "full: %lu, %lu, %lu; empty: %lu, %lu, %lu", + cache->m_name, + cache->m_depot_full.m_mag_count, + cache->m_depot_full.m_curr_min, + cache->m_depot_full.m_prev_min, + cache->m_depot_empty.m_mag_count, + cache->m_depot_empty.m_curr_min, + cache->m_depot_empty.m_prev_min + ); + + rtl_cache_depot_wsupdate (cache, &(cache->m_depot_full)); + rtl_cache_depot_wsupdate (cache, &(cache->m_depot_empty)); + + RTL_MEMORY_LOCK_RELEASE(&(cache->m_depot_lock)); + } +} + +/** rtl_cache_wsupdate_all() + * + */ +#if defined(SAL_UNX) +static void * +#elif defined(SAL_W32) +static DWORD WINAPI +#endif /* SAL_UNX || SAL_W32 */ +rtl_cache_wsupdate_all (void * arg) +{ + unsigned int seconds = sal::static_int_cast< unsigned int >( + reinterpret_cast< sal_uIntPtr >(arg)); + + RTL_MEMORY_LOCK_ACQUIRE(&(g_cache_list.m_lock)); + while (!g_cache_list.m_update_done) + { + rtl_cache_wsupdate_wait (seconds); + if (!g_cache_list.m_update_done) + { + rtl_cache_type * head, * cache; + + head = &(g_cache_list.m_cache_head); + for (cache = head->m_cache_next; + cache != head; + cache = cache->m_cache_next) + { + rtl_cache_wsupdate (cache); + } + } + } + RTL_MEMORY_LOCK_RELEASE(&(g_cache_list.m_lock)); + + return (0); +} + +/* ================================================================= * + * + * cache initialization. + * + * ================================================================= */ + +void +rtl_cache_init() +{ + { + /* list of caches */ + RTL_MEMORY_LOCK_INIT(&(g_cache_list.m_lock)); + (void) rtl_cache_constructor (&(g_cache_list.m_cache_head)); + } + { + /* cache: internal arena */ + OSL_ASSERT(gp_cache_arena == 0); + + gp_cache_arena = rtl_arena_create ( + "rtl_cache_internal_arena", + 64, /* quantum */ + 0, /* no quantum caching */ + NULL, /* default source */ + rtl_arena_alloc, + rtl_arena_free, + 0 /* flags */ + ); + OSL_ASSERT(gp_cache_arena != 0); + + /* check 'gp_default_arena' initialization */ + OSL_ASSERT(gp_default_arena != 0); + } + { + /* cache: magazine cache */ + static rtl_cache_type g_cache_magazine_cache; + + OSL_ASSERT(gp_cache_magazine_cache == 0); + VALGRIND_CREATE_MEMPOOL(&g_cache_magazine_cache, 0, 0); + (void) rtl_cache_constructor (&g_cache_magazine_cache); + + gp_cache_magazine_cache = rtl_cache_activate ( + &g_cache_magazine_cache, + "rtl_cache_magazine_cache", + sizeof(rtl_cache_magazine_type), /* objsize */ + 0, /* objalign */ + rtl_cache_magazine_constructor, + rtl_cache_magazine_destructor, + 0, /* reclaim */ + 0, /* userarg: NYI */ + gp_default_arena, /* source */ + RTL_CACHE_FLAG_NOMAGAZINE /* during bootstrap; activated below */ + ); + OSL_ASSERT(gp_cache_magazine_cache != 0); + + /* activate magazine layer */ + g_cache_magazine_cache.m_magazine_cache = gp_cache_magazine_cache; + } + { + /* cache: slab (struct) cache */ + static rtl_cache_type g_cache_slab_cache; + + OSL_ASSERT(gp_cache_slab_cache == 0); + VALGRIND_CREATE_MEMPOOL(&g_cache_slab_cache, 0, 0); + (void) rtl_cache_constructor (&g_cache_slab_cache); + + gp_cache_slab_cache = rtl_cache_activate ( + &g_cache_slab_cache, + "rtl_cache_slab_cache", + sizeof(rtl_cache_slab_type), /* objsize */ + 0, /* objalign */ + rtl_cache_slab_constructor, + rtl_cache_slab_destructor, + 0, /* reclaim */ + 0, /* userarg: none */ + gp_default_arena, /* source */ + 0 /* flags: none */ + ); + OSL_ASSERT(gp_cache_slab_cache != 0); + } + { + /* cache: bufctl cache */ + static rtl_cache_type g_cache_bufctl_cache; + + OSL_ASSERT(gp_cache_bufctl_cache == 0); + VALGRIND_CREATE_MEMPOOL(&g_cache_bufctl_cache, 0, 0); + (void) rtl_cache_constructor (&g_cache_bufctl_cache); + + gp_cache_bufctl_cache = rtl_cache_activate ( + &g_cache_bufctl_cache, + "rtl_cache_bufctl_cache", + sizeof(rtl_cache_bufctl_type), /* objsize */ + 0, /* objalign */ + 0, /* constructor */ + 0, /* destructor */ + 0, /* reclaim */ + 0, /* userarg */ + gp_default_arena, /* source */ + 0 /* flags: none */ + ); + OSL_ASSERT(gp_cache_bufctl_cache != 0); + } + + rtl_cache_wsupdate_init(); + OSL_TRACE("rtl_cache_init completed"); +} + +/* ================================================================= */ + +void +rtl_cache_fini() +{ + if (gp_cache_arena != 0) + { + rtl_cache_type * cache, * head; + + rtl_cache_wsupdate_fini(); + + if (gp_cache_bufctl_cache != 0) + { + cache = gp_cache_bufctl_cache, gp_cache_bufctl_cache = 0; + rtl_cache_deactivate (cache); + rtl_cache_destructor (cache); + VALGRIND_DESTROY_MEMPOOL(cache); + } + if (gp_cache_slab_cache != 0) + { + cache = gp_cache_slab_cache, gp_cache_slab_cache = 0; + rtl_cache_deactivate (cache); + rtl_cache_destructor (cache); + VALGRIND_DESTROY_MEMPOOL(cache); + } + if (gp_cache_magazine_cache != 0) + { + cache = gp_cache_magazine_cache, gp_cache_magazine_cache = 0; + rtl_cache_deactivate (cache); + rtl_cache_destructor (cache); + VALGRIND_DESTROY_MEMPOOL(cache); + } + if (gp_cache_arena != 0) + { + rtl_arena_destroy (gp_cache_arena); + gp_cache_arena = 0; + } + + RTL_MEMORY_LOCK_ACQUIRE(&(g_cache_list.m_lock)); + head = &(g_cache_list.m_cache_head); + for (cache = head->m_cache_next; cache != head; cache = cache->m_cache_next) + { + OSL_TRACE( + "rtl_cache_fini(\"%s\") " + "[slab]: allocs: %"PRIu64", frees: %"PRIu64"; total: %lu, used: %lu; " + "[cpu]: allocs: %"PRIu64", frees: %"PRIu64"; " + "[total]: allocs: %"PRIu64", frees: %"PRIu64"", + cache->m_name, + cache->m_slab_stats.m_alloc, cache->m_slab_stats.m_free, + cache->m_slab_stats.m_mem_total, cache->m_slab_stats.m_mem_alloc, + cache->m_cpu_stats.m_alloc, cache->m_cpu_stats.m_free, + cache->m_slab_stats.m_alloc + cache->m_cpu_stats.m_alloc, + cache->m_slab_stats.m_free + cache->m_cpu_stats.m_free + ); + } + RTL_MEMORY_LOCK_RELEASE(&(g_cache_list.m_lock)); + } + OSL_TRACE("rtl_cache_fini completed"); +} + +/* ================================================================= */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/alloc_cache.h b/sal/rtl/source/alloc_cache.h deleted file mode 100644 index 05efceb980c8..000000000000 --- a/sal/rtl/source/alloc_cache.h +++ /dev/null @@ -1,185 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef INCLUDED_RTL_ALLOC_CACHE_H -#define INCLUDED_RTL_ALLOC_CACHE_H - -#include "sal/types.h" -#include "rtl/alloc.h" -#include "alloc_impl.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** rtl_cache_stat_type - * @internal - */ -typedef struct rtl_cache_stat_st rtl_cache_stat_type; -struct rtl_cache_stat_st -{ - sal_uInt64 m_alloc; - sal_uInt64 m_free; - - sal_Size m_mem_total; - sal_Size m_mem_alloc; -}; - - -/** rtl_cache_bufctl_type - * @internal - */ -typedef struct rtl_cache_bufctl_st rtl_cache_bufctl_type; -struct rtl_cache_bufctl_st -{ - rtl_cache_bufctl_type * m_next; /* linkage */ - - sal_uIntPtr m_addr; /* buffer address */ - sal_uIntPtr m_slab; /* parent slab address */ -}; - - -/** rtl_cache_slab_type - * @internal - */ -typedef struct rtl_cache_slab_st rtl_cache_slab_type; -struct rtl_cache_slab_st -{ - rtl_cache_slab_type * m_slab_next; /* slab linkage */ - rtl_cache_slab_type * m_slab_prev; /* slab linkage */ - - sal_Size m_ntypes; /* number of buffers used */ - sal_uIntPtr m_data; /* buffer start addr */ - - sal_uIntPtr m_bp; /* free buffer linkage 'base pointer' */ - rtl_cache_bufctl_type * m_sp; /* free buffer linkage 'stack pointer' */ -}; - - -/** rtl_cache_magazine_type - * @internal - */ -#define RTL_CACHE_MAGAZINE_SIZE 61 - -typedef struct rtl_cache_magazine_st rtl_cache_magazine_type; -struct rtl_cache_magazine_st -{ - rtl_cache_magazine_type * m_mag_next; /* depot linkage */ - - sal_Size m_mag_size; - sal_Size m_mag_used; - - void * m_objects[RTL_CACHE_MAGAZINE_SIZE]; -}; - - -/** rtl_cache_depot_type - * @internal - */ -typedef struct rtl_cache_depot_st rtl_cache_depot_type; -struct rtl_cache_depot_st -{ - /* magazine list */ - rtl_cache_magazine_type * m_mag_next; /* linkage */ - sal_Size m_mag_count; /* count */ - - /* working set parameters */ - sal_Size m_curr_min; - sal_Size m_prev_min; -}; - - -/** rtl_cache_type - * @internal - */ -#define RTL_CACHE_HASH_SIZE 8 - -#define RTL_CACHE_FEATURE_HASH 1 -#define RTL_CACHE_FEATURE_BULKDESTROY 2 -#define RTL_CACHE_FEATURE_RESCALE 4 /* within hash rescale operation */ - -struct rtl_cache_st -{ - /* linkage */ - rtl_cache_type * m_cache_next; - rtl_cache_type * m_cache_prev; - - /* properties */ - char m_name[RTL_CACHE_NAME_LENGTH + 1]; - long m_features; - - sal_Size m_type_size; /* const */ - sal_Size m_type_align; /* const */ - sal_Size m_type_shift; /* log2(m_type_size); const */ - - int (SAL_CALL * m_constructor)(void * obj, void * userarg); /* const */ - void (SAL_CALL * m_destructor) (void * obj, void * userarg); /* const */ - void (SAL_CALL * m_reclaim) (void * userarg); /* const */ - void * m_userarg; - - /* slab layer */ - rtl_memory_lock_type m_slab_lock; - rtl_cache_stat_type m_slab_stats; - - rtl_arena_type * m_source; /* slab supplier; const */ - sal_Size m_slab_size; /* const */ - sal_Size m_ntypes; /* number of buffers per slab; const */ - sal_Size m_ncolor; /* next slab color */ - sal_Size m_ncolor_max; /* max. slab color */ - - rtl_cache_slab_type m_free_head; - rtl_cache_slab_type m_used_head; - - rtl_cache_bufctl_type ** m_hash_table; - rtl_cache_bufctl_type * m_hash_table_0[RTL_CACHE_HASH_SIZE]; - sal_Size m_hash_size; /* m_hash_mask + 1 */ - sal_Size m_hash_shift; /* log2(m_hash_size) */ - - /* depot layer */ - rtl_memory_lock_type m_depot_lock; - - rtl_cache_depot_type m_depot_empty; - rtl_cache_depot_type m_depot_full; - - rtl_cache_type * m_magazine_cache; /* magazine supplier; const */ - - /* cpu layer */ - rtl_cache_magazine_type * m_cpu_curr; - rtl_cache_magazine_type * m_cpu_prev; - - rtl_cache_stat_type m_cpu_stats; -}; - - -#ifdef __cplusplus -} -#endif - -#endif /* INCLUDED_RTL_ALLOC_CACHE_H */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/alloc_cache.hxx b/sal/rtl/source/alloc_cache.hxx new file mode 100644 index 000000000000..1238981fc022 --- /dev/null +++ b/sal/rtl/source/alloc_cache.hxx @@ -0,0 +1,171 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_RTL_ALLOC_CACHE_HXX +#define INCLUDED_RTL_ALLOC_CACHE_HXX + +#include "sal/types.h" +#include "rtl/alloc.h" +#include "alloc_impl.hxx" + +/** rtl_cache_stat_type + * @internal + */ +struct rtl_cache_stat_type +{ + sal_uInt64 m_alloc; + sal_uInt64 m_free; + + sal_Size m_mem_total; + sal_Size m_mem_alloc; +}; + + +/** rtl_cache_bufctl_type + * @internal + */ +struct rtl_cache_bufctl_type +{ + rtl_cache_bufctl_type * m_next; /* linkage */ + + sal_uIntPtr m_addr; /* buffer address */ + sal_uIntPtr m_slab; /* parent slab address */ +}; + + +/** rtl_cache_slab_type + * @internal + */ +struct rtl_cache_slab_type +{ + rtl_cache_slab_type * m_slab_next; /* slab linkage */ + rtl_cache_slab_type * m_slab_prev; /* slab linkage */ + + sal_Size m_ntypes; /* number of buffers used */ + sal_uIntPtr m_data; /* buffer start addr */ + + sal_uIntPtr m_bp; /* free buffer linkage 'base pointer' */ + rtl_cache_bufctl_type * m_sp; /* free buffer linkage 'stack pointer' */ +}; + + +/** rtl_cache_magazine_type + * @internal + */ +#define RTL_CACHE_MAGAZINE_SIZE 61 + +struct rtl_cache_magazine_type +{ + rtl_cache_magazine_type * m_mag_next; /* depot linkage */ + + sal_Size m_mag_size; + sal_Size m_mag_used; + + void * m_objects[RTL_CACHE_MAGAZINE_SIZE]; +}; + + +/** rtl_cache_depot_type + * @internal + */ +struct rtl_cache_depot_type +{ + /* magazine list */ + rtl_cache_magazine_type * m_mag_next; /* linkage */ + sal_Size m_mag_count; /* count */ + + /* working set parameters */ + sal_Size m_curr_min; + sal_Size m_prev_min; +}; + + +/** rtl_cache_type + * @internal + */ +#define RTL_CACHE_HASH_SIZE 8 + +#define RTL_CACHE_FEATURE_HASH 1 +#define RTL_CACHE_FEATURE_BULKDESTROY 2 +#define RTL_CACHE_FEATURE_RESCALE 4 /* within hash rescale operation */ + +struct rtl_cache_st +{ + /* linkage */ + rtl_cache_type * m_cache_next; + rtl_cache_type * m_cache_prev; + + /* properties */ + char m_name[RTL_CACHE_NAME_LENGTH + 1]; + long m_features; + + sal_Size m_type_size; /* const */ + sal_Size m_type_align; /* const */ + sal_Size m_type_shift; /* log2(m_type_size); const */ + + int (SAL_CALL * m_constructor)(void * obj, void * userarg); /* const */ + void (SAL_CALL * m_destructor) (void * obj, void * userarg); /* const */ + void (SAL_CALL * m_reclaim) (void * userarg); /* const */ + void * m_userarg; + + /* slab layer */ + rtl_memory_lock_type m_slab_lock; + rtl_cache_stat_type m_slab_stats; + + rtl_arena_type * m_source; /* slab supplier; const */ + sal_Size m_slab_size; /* const */ + sal_Size m_ntypes; /* number of buffers per slab; const */ + sal_Size m_ncolor; /* next slab color */ + sal_Size m_ncolor_max; /* max. slab color */ + + rtl_cache_slab_type m_free_head; + rtl_cache_slab_type m_used_head; + + rtl_cache_bufctl_type ** m_hash_table; + rtl_cache_bufctl_type * m_hash_table_0[RTL_CACHE_HASH_SIZE]; + sal_Size m_hash_size; /* m_hash_mask + 1 */ + sal_Size m_hash_shift; /* log2(m_hash_size) */ + + /* depot layer */ + rtl_memory_lock_type m_depot_lock; + + rtl_cache_depot_type m_depot_empty; + rtl_cache_depot_type m_depot_full; + + rtl_cache_type * m_magazine_cache; /* magazine supplier; const */ + + /* cpu layer */ + rtl_cache_magazine_type * m_cpu_curr; + rtl_cache_magazine_type * m_cpu_prev; + + rtl_cache_stat_type m_cpu_stats; +}; + +#endif /* INCLUDED_RTL_ALLOC_CACHE_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/alloc_fini.cxx b/sal/rtl/source/alloc_fini.cxx index c19e8dcb47ef..ad9ff0881dbe 100644 --- a/sal/rtl/source/alloc_fini.cxx +++ b/sal/rtl/source/alloc_fini.cxx @@ -28,10 +28,8 @@ #include -#include "internal/rtl_locale_init.h" +#include "internal/rtllifecycle.h" -extern "C" void rtl_memory_fini(); -extern "C" void rtl_memory_init(); namespace { struct rtlMemorySingleton @@ -48,13 +46,12 @@ namespace class theMemorySingleton : public rtl::Static{}; } -extern "C" void ensureMemorySingleton() + +void ensureMemorySingleton() { theMemorySingleton::get(); } -extern "C" void rtl_cache_fini(); -extern "C" void rtl_cache_init(); namespace { struct rtlCacheSingleton @@ -71,13 +68,12 @@ namespace class theCacheSingleton : public rtl::Static{}; } -extern "C" void ensureCacheSingleton() + +void ensureCacheSingleton() { theCacheSingleton::get(); } -extern "C" void rtl_arena_fini(); -extern "C" void rtl_arena_init(); namespace { struct rtlArenaSingleton @@ -94,7 +90,8 @@ namespace class theArenaSingleton : public rtl::Static{}; } -extern "C" void ensureArenaSingleton() + +void ensureArenaSingleton() { theArenaSingleton::get(); } diff --git a/sal/rtl/source/alloc_global.c b/sal/rtl/source/alloc_global.c deleted file mode 100644 index 57728f61ffb4..000000000000 --- a/sal/rtl/source/alloc_global.c +++ /dev/null @@ -1,386 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "alloc_impl.h" -#include "rtl/alloc.h" -#include -#include - -#include -#include - -AllocMode alloc_mode = AMode_UNSET; - -#if !defined(FORCE_SYSALLOC) -static void determine_alloc_mode(void) -{ - OSL_ASSERT(alloc_mode == AMode_UNSET); - alloc_mode = (getenv("G_SLICE") == NULL ? AMode_CUSTOM : AMode_SYSTEM); -} - -/* ================================================================= * - * - * custom allocator includes. - * - * ================================================================= */ - -#include "internal/once.h" -#include "sal/macros.h" - -/* ================================================================= * - * - * custom allocator internals. - * - * ================================================================= */ - -static const sal_Size g_alloc_sizes[] = -{ - /* powers of 2**(1/4) */ - 4 * 4, 6 * 4, - 4 * 8, 5 * 8, 6 * 8, 7 * 8, - 4 * 16, 5 * 16, 6 * 16, 7 * 16, - 4 * 32, 5 * 32, 6 * 32, 7 * 32, - 4 * 64, 5 * 64, 6 * 64, 7 * 64, - 4 * 128, 5 * 128, 6 * 128, 7 * 128, - 4 * 256, 5 * 256, 6 * 256, 7 * 256, - 4 * 512, 5 * 512, 6 * 512, 7 * 512, - 4 * 1024, 5 * 1024, 6 * 1024, 7 * 1024, - 4 * 2048, 5 * 2048, 6 * 2048, 7 * 2048, - 4 * 4096 -}; - -#define RTL_MEMORY_CACHED_LIMIT 4 * 4096 -#define RTL_MEMORY_CACHED_SIZES (SAL_N_ELEMENTS(g_alloc_sizes)) - -static rtl_cache_type * g_alloc_caches[RTL_MEMORY_CACHED_SIZES] = -{ - 0, -}; - -#define RTL_MEMALIGN 8 -#define RTL_MEMALIGN_SHIFT 3 - -static rtl_cache_type * g_alloc_table[RTL_MEMORY_CACHED_LIMIT >> RTL_MEMALIGN_SHIFT] = -{ - 0, -}; - -static rtl_arena_type * gp_alloc_arena = 0; - -extern void ensureMemorySingleton(); - -/* ================================================================= * - * - * custom allocator implemenation. - * - * ================================================================= */ - -void * -SAL_CALL rtl_allocateMemory_CUSTOM (sal_Size n) SAL_THROW_EXTERN_C() -{ - void * p = 0; - if (n > 0) - { - char * addr; - sal_Size size = RTL_MEMORY_ALIGN(n + RTL_MEMALIGN, RTL_MEMALIGN); - - OSL_ASSERT(RTL_MEMALIGN >= sizeof(sal_Size)); - if (n >= SAL_MAX_SIZE - (RTL_MEMALIGN + RTL_MEMALIGN - 1)) - { - /* requested size too large for roundup alignment */ - return 0; - } - -try_alloc: - if (size <= RTL_MEMORY_CACHED_LIMIT) - addr = (char*)rtl_cache_alloc(g_alloc_table[(size - 1) >> RTL_MEMALIGN_SHIFT]); - else - addr = (char*)rtl_arena_alloc (gp_alloc_arena, &size); - - if (addr != 0) - { - ((sal_Size*)(addr))[0] = size; - p = addr + RTL_MEMALIGN; - } - else if (gp_alloc_arena == 0) - { - ensureMemorySingleton(); - if (gp_alloc_arena) - { - /* try again */ - goto try_alloc; - } - } - } - return (p); -} - -/* ================================================================= */ - -void SAL_CALL rtl_freeMemory_CUSTOM (void * p) SAL_THROW_EXTERN_C() -{ - if (p != 0) - { - char * addr = (char*)(p) - RTL_MEMALIGN; - sal_Size size = ((sal_Size*)(addr))[0]; - - if (size <= RTL_MEMORY_CACHED_LIMIT) - rtl_cache_free(g_alloc_table[(size - 1) >> RTL_MEMALIGN_SHIFT], addr); - else - rtl_arena_free (gp_alloc_arena, addr, size); - } -} - -/* ================================================================= */ - -void * SAL_CALL rtl_reallocateMemory_CUSTOM (void * p, sal_Size n) SAL_THROW_EXTERN_C() -{ - if (n > 0) - { - if (p != 0) - { - void * p_old = p; - sal_Size n_old = ((sal_Size*)( (char*)(p) - RTL_MEMALIGN ))[0] - RTL_MEMALIGN; - - p = rtl_allocateMemory (n); - if (p != 0) - { - memcpy (p, p_old, SAL_MIN(n, n_old)); - rtl_freeMemory (p_old); - } - } - else - { - p = rtl_allocateMemory (n); - } - } - else if (p != 0) - { - rtl_freeMemory (p), p = 0; - } - return (p); -} - -#endif - -/* ================================================================= * - * - * custom allocator initialization / finalization. - * - * ================================================================= */ - -void rtl_memory_init (void) -{ -#if !defined(FORCE_SYSALLOC) - { - /* global memory arena */ - OSL_ASSERT(gp_alloc_arena == 0); - - gp_alloc_arena = rtl_arena_create ( - "rtl_alloc_arena", - 2048, /* quantum */ - 0, /* w/o quantum caching */ - 0, /* default source */ - rtl_arena_alloc, - rtl_arena_free, - 0 /* flags */ - ); - OSL_ASSERT(gp_alloc_arena != 0); - } - { - sal_Size size; - int i, n = RTL_MEMORY_CACHED_SIZES; - - for (i = 0; i < n; i++) - { - char name[RTL_CACHE_NAME_LENGTH + 1]; - (void) snprintf (name, sizeof(name), "rtl_alloc_%lu", g_alloc_sizes[i]); - g_alloc_caches[i] = rtl_cache_create (name, g_alloc_sizes[i], 0, NULL, NULL, NULL, NULL, NULL, 0); - } - - size = RTL_MEMALIGN; - for (i = 0; i < n; i++) - { - while (size <= g_alloc_sizes[i]) - { - g_alloc_table[(size - 1) >> RTL_MEMALIGN_SHIFT] = g_alloc_caches[i]; - size += RTL_MEMALIGN; - } - } - } -#endif - OSL_TRACE("rtl_memory_init completed"); -} - -/* ================================================================= */ - -void rtl_memory_fini (void) -{ -#if !defined(FORCE_SYSALLOC) - int i, n; - - /* clear g_alloc_table */ - memset (g_alloc_table, 0, sizeof(g_alloc_table)); - - /* cleanup g_alloc_caches */ - for (i = 0, n = RTL_MEMORY_CACHED_SIZES; i < n; i++) - { - if (g_alloc_caches[i] != 0) - { - rtl_cache_destroy (g_alloc_caches[i]); - g_alloc_caches[i] = 0; - } - } - - /* cleanup gp_alloc_arena */ - if (gp_alloc_arena != 0) - { - rtl_arena_destroy (gp_alloc_arena); - gp_alloc_arena = 0; - } -#endif - OSL_TRACE("rtl_memory_fini completed"); -} - -/* ================================================================= * - * - * system allocator implemenation. - * - * ================================================================= */ - -void * SAL_CALL rtl_allocateMemory_SYSTEM (sal_Size n) -{ - return malloc (n); -} - -/* ================================================================= */ - -void SAL_CALL rtl_freeMemory_SYSTEM (void * p) -{ - free (p); -} - -/* ================================================================= */ - -void * SAL_CALL rtl_reallocateMemory_SYSTEM (void * p, sal_Size n) -{ - return realloc (p, n); -} - -/* ================================================================= */ - -void* SAL_CALL rtl_allocateMemory (sal_Size n) SAL_THROW_EXTERN_C() -{ -#if !defined(FORCE_SYSALLOC) - while (1) - { - if (alloc_mode == AMode_CUSTOM) - { - return rtl_allocateMemory_CUSTOM(n); - } - if (alloc_mode == AMode_SYSTEM) - { - return rtl_allocateMemory_SYSTEM(n); - } - determine_alloc_mode(); - } -#else - return rtl_allocateMemory_SYSTEM(n); -#endif -} - -void* SAL_CALL rtl_reallocateMemory (void * p, sal_Size n) SAL_THROW_EXTERN_C() -{ -#if !defined(FORCE_SYSALLOC) - while (1) - { - if (alloc_mode == AMode_CUSTOM) - { - return rtl_reallocateMemory_CUSTOM(p,n); - } - if (alloc_mode == AMode_SYSTEM) - { - return rtl_reallocateMemory_SYSTEM(p,n); - } - determine_alloc_mode(); - } -#else - return rtl_reallocateMemory_SYSTEM(p,n); -#endif -} - -void SAL_CALL rtl_freeMemory (void * p) SAL_THROW_EXTERN_C() -{ -#if !defined(FORCE_SYSALLOC) - while (1) - { - if (alloc_mode == AMode_CUSTOM) - { - rtl_freeMemory_CUSTOM(p); - return; - } - if (alloc_mode == AMode_SYSTEM) - { - rtl_freeMemory_SYSTEM(p); - return; - } - determine_alloc_mode(); - } -#else - rtl_freeMemory_SYSTEM(p); -#endif -} - -/* ================================================================= * - * - * rtl_(allocate|free)ZeroMemory() implemenation. - * - * ================================================================= */ - -void * SAL_CALL rtl_allocateZeroMemory (sal_Size n) SAL_THROW_EXTERN_C() -{ - void * p = rtl_allocateMemory (n); - if (p != 0) - memset (p, 0, n); - return (p); -} - -/* ================================================================= */ - -void SAL_CALL rtl_freeZeroMemory (void * p, sal_Size n) SAL_THROW_EXTERN_C() -{ - if (p != 0) - { - memset (p, 0, n); - rtl_freeMemory (p); - } -} - -/* ================================================================= */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/alloc_global.cxx b/sal/rtl/source/alloc_global.cxx new file mode 100644 index 000000000000..e48fdd1072c7 --- /dev/null +++ b/sal/rtl/source/alloc_global.cxx @@ -0,0 +1,386 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "alloc_impl.hxx" +#include "rtl/alloc.h" +#include +#include + +#include +#include + +#include "internal/rtllifecycle.h" + +AllocMode alloc_mode = AMode_UNSET; + +#if !defined(FORCE_SYSALLOC) +static void determine_alloc_mode() +{ + OSL_ASSERT(alloc_mode == AMode_UNSET); + alloc_mode = (getenv("G_SLICE") == NULL ? AMode_CUSTOM : AMode_SYSTEM); +} + +/* ================================================================= * + * + * custom allocator includes. + * + * ================================================================= */ + +#include "internal/once.h" +#include "sal/macros.h" + +/* ================================================================= * + * + * custom allocator internals. + * + * ================================================================= */ + +static const sal_Size g_alloc_sizes[] = +{ + /* powers of 2**(1/4) */ + 4 * 4, 6 * 4, + 4 * 8, 5 * 8, 6 * 8, 7 * 8, + 4 * 16, 5 * 16, 6 * 16, 7 * 16, + 4 * 32, 5 * 32, 6 * 32, 7 * 32, + 4 * 64, 5 * 64, 6 * 64, 7 * 64, + 4 * 128, 5 * 128, 6 * 128, 7 * 128, + 4 * 256, 5 * 256, 6 * 256, 7 * 256, + 4 * 512, 5 * 512, 6 * 512, 7 * 512, + 4 * 1024, 5 * 1024, 6 * 1024, 7 * 1024, + 4 * 2048, 5 * 2048, 6 * 2048, 7 * 2048, + 4 * 4096 +}; + +#define RTL_MEMORY_CACHED_LIMIT 4 * 4096 +#define RTL_MEMORY_CACHED_SIZES (SAL_N_ELEMENTS(g_alloc_sizes)) + +static rtl_cache_type * g_alloc_caches[RTL_MEMORY_CACHED_SIZES] = +{ + 0, +}; + +#define RTL_MEMALIGN 8 +#define RTL_MEMALIGN_SHIFT 3 + +static rtl_cache_type * g_alloc_table[RTL_MEMORY_CACHED_LIMIT >> RTL_MEMALIGN_SHIFT] = +{ + 0, +}; + +static rtl_arena_type * gp_alloc_arena = 0; + +/* ================================================================= * + * + * custom allocator implemenation. + * + * ================================================================= */ + +void * +SAL_CALL rtl_allocateMemory_CUSTOM (sal_Size n) SAL_THROW_EXTERN_C() +{ + void * p = 0; + if (n > 0) + { + char * addr; + sal_Size size = RTL_MEMORY_ALIGN(n + RTL_MEMALIGN, RTL_MEMALIGN); + + OSL_ASSERT(RTL_MEMALIGN >= sizeof(sal_Size)); + if (n >= SAL_MAX_SIZE - (RTL_MEMALIGN + RTL_MEMALIGN - 1)) + { + /* requested size too large for roundup alignment */ + return 0; + } + +try_alloc: + if (size <= RTL_MEMORY_CACHED_LIMIT) + addr = (char*)rtl_cache_alloc(g_alloc_table[(size - 1) >> RTL_MEMALIGN_SHIFT]); + else + addr = (char*)rtl_arena_alloc (gp_alloc_arena, &size); + + if (addr != 0) + { + ((sal_Size*)(addr))[0] = size; + p = addr + RTL_MEMALIGN; + } + else if (gp_alloc_arena == 0) + { + ensureMemorySingleton(); + if (gp_alloc_arena) + { + /* try again */ + goto try_alloc; + } + } + } + return (p); +} + +/* ================================================================= */ + +void SAL_CALL rtl_freeMemory_CUSTOM (void * p) SAL_THROW_EXTERN_C() +{ + if (p != 0) + { + char * addr = (char*)(p) - RTL_MEMALIGN; + sal_Size size = ((sal_Size*)(addr))[0]; + + if (size <= RTL_MEMORY_CACHED_LIMIT) + rtl_cache_free(g_alloc_table[(size - 1) >> RTL_MEMALIGN_SHIFT], addr); + else + rtl_arena_free (gp_alloc_arena, addr, size); + } +} + +/* ================================================================= */ + +void * SAL_CALL rtl_reallocateMemory_CUSTOM (void * p, sal_Size n) SAL_THROW_EXTERN_C() +{ + if (n > 0) + { + if (p != 0) + { + void * p_old = p; + sal_Size n_old = ((sal_Size*)( (char*)(p) - RTL_MEMALIGN ))[0] - RTL_MEMALIGN; + + p = rtl_allocateMemory (n); + if (p != 0) + { + memcpy (p, p_old, SAL_MIN(n, n_old)); + rtl_freeMemory (p_old); + } + } + else + { + p = rtl_allocateMemory (n); + } + } + else if (p != 0) + { + rtl_freeMemory (p), p = 0; + } + return (p); +} + +#endif + +/* ================================================================= * + * + * custom allocator initialization / finalization. + * + * ================================================================= */ + +void rtl_memory_init() +{ +#if !defined(FORCE_SYSALLOC) + { + /* global memory arena */ + OSL_ASSERT(gp_alloc_arena == 0); + + gp_alloc_arena = rtl_arena_create ( + "rtl_alloc_arena", + 2048, /* quantum */ + 0, /* w/o quantum caching */ + 0, /* default source */ + rtl_arena_alloc, + rtl_arena_free, + 0 /* flags */ + ); + OSL_ASSERT(gp_alloc_arena != 0); + } + { + sal_Size size; + int i, n = RTL_MEMORY_CACHED_SIZES; + + for (i = 0; i < n; i++) + { + char name[RTL_CACHE_NAME_LENGTH + 1]; + (void) snprintf (name, sizeof(name), "rtl_alloc_%lu", g_alloc_sizes[i]); + g_alloc_caches[i] = rtl_cache_create (name, g_alloc_sizes[i], 0, NULL, NULL, NULL, NULL, NULL, 0); + } + + size = RTL_MEMALIGN; + for (i = 0; i < n; i++) + { + while (size <= g_alloc_sizes[i]) + { + g_alloc_table[(size - 1) >> RTL_MEMALIGN_SHIFT] = g_alloc_caches[i]; + size += RTL_MEMALIGN; + } + } + } +#endif + OSL_TRACE("rtl_memory_init completed"); +} + +/* ================================================================= */ + +void rtl_memory_fini() +{ +#if !defined(FORCE_SYSALLOC) + int i, n; + + /* clear g_alloc_table */ + memset (g_alloc_table, 0, sizeof(g_alloc_table)); + + /* cleanup g_alloc_caches */ + for (i = 0, n = RTL_MEMORY_CACHED_SIZES; i < n; i++) + { + if (g_alloc_caches[i] != 0) + { + rtl_cache_destroy (g_alloc_caches[i]); + g_alloc_caches[i] = 0; + } + } + + /* cleanup gp_alloc_arena */ + if (gp_alloc_arena != 0) + { + rtl_arena_destroy (gp_alloc_arena); + gp_alloc_arena = 0; + } +#endif + OSL_TRACE("rtl_memory_fini completed"); +} + +/* ================================================================= * + * + * system allocator implemenation. + * + * ================================================================= */ + +void * SAL_CALL rtl_allocateMemory_SYSTEM (sal_Size n) +{ + return malloc (n); +} + +/* ================================================================= */ + +void SAL_CALL rtl_freeMemory_SYSTEM (void * p) +{ + free (p); +} + +/* ================================================================= */ + +void * SAL_CALL rtl_reallocateMemory_SYSTEM (void * p, sal_Size n) +{ + return realloc (p, n); +} + +/* ================================================================= */ + +void* SAL_CALL rtl_allocateMemory (sal_Size n) SAL_THROW_EXTERN_C() +{ +#if !defined(FORCE_SYSALLOC) + while (1) + { + if (alloc_mode == AMode_CUSTOM) + { + return rtl_allocateMemory_CUSTOM(n); + } + if (alloc_mode == AMode_SYSTEM) + { + return rtl_allocateMemory_SYSTEM(n); + } + determine_alloc_mode(); + } +#else + return rtl_allocateMemory_SYSTEM(n); +#endif +} + +void* SAL_CALL rtl_reallocateMemory (void * p, sal_Size n) SAL_THROW_EXTERN_C() +{ +#if !defined(FORCE_SYSALLOC) + while (1) + { + if (alloc_mode == AMode_CUSTOM) + { + return rtl_reallocateMemory_CUSTOM(p,n); + } + if (alloc_mode == AMode_SYSTEM) + { + return rtl_reallocateMemory_SYSTEM(p,n); + } + determine_alloc_mode(); + } +#else + return rtl_reallocateMemory_SYSTEM(p,n); +#endif +} + +void SAL_CALL rtl_freeMemory (void * p) SAL_THROW_EXTERN_C() +{ +#if !defined(FORCE_SYSALLOC) + while (1) + { + if (alloc_mode == AMode_CUSTOM) + { + rtl_freeMemory_CUSTOM(p); + return; + } + if (alloc_mode == AMode_SYSTEM) + { + rtl_freeMemory_SYSTEM(p); + return; + } + determine_alloc_mode(); + } +#else + rtl_freeMemory_SYSTEM(p); +#endif +} + +/* ================================================================= * + * + * rtl_(allocate|free)ZeroMemory() implemenation. + * + * ================================================================= */ + +void * SAL_CALL rtl_allocateZeroMemory (sal_Size n) SAL_THROW_EXTERN_C() +{ + void * p = rtl_allocateMemory (n); + if (p != 0) + memset (p, 0, n); + return (p); +} + +/* ================================================================= */ + +void SAL_CALL rtl_freeZeroMemory (void * p, sal_Size n) SAL_THROW_EXTERN_C() +{ + if (p != 0) + { + memset (p, 0, n); + rtl_freeMemory (p); + } +} + +/* ================================================================= */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/alloc_impl.h b/sal/rtl/source/alloc_impl.h deleted file mode 100644 index 3b63f07fe1f8..000000000000 --- a/sal/rtl/source/alloc_impl.h +++ /dev/null @@ -1,284 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef INCLUDED_RTL_ALLOC_IMPL_H -#define INCLUDED_RTL_ALLOC_IMPL_H - -#include "sal/types.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -/** Alignment macros - */ -#if SAL_TYPES_ALIGNMENT4 > 1 -#define RTL_MEMORY_ALIGNMENT_4 SAL_TYPES_ALIGNMENT4 -#else -#define RTL_MEMORY_ALIGNMENT_4 sizeof(int) -#endif /* SAL_TYPES_ALIGNMENT4 */ - -#if SAL_TYPES_ALIGNMENT8 > 1 -#define RTL_MEMORY_ALIGNMENT_8 SAL_TYPES_ALIGNMENT8 -#else -#define RTL_MEMORY_ALIGNMENT_8 sizeof(void*) -#endif /* SAL_TYPES_ALIGNMENT8 */ - -#if 0 /* @@@ */ -#define RTL_MEMORY_ALIGNMENT_1 8 -#define RTL_MEMORY_ALIGNMENT_2 (sizeof(void*) * 2) -#endif /* @@@ */ - -#define RTL_MEMORY_ALIGN(value, align) (((value) + ((align) - 1)) & ~((align) - 1)) - -#define RTL_MEMORY_ISP2(value) (((value) & ((value) - 1)) == 0) -#define RTL_MEMORY_P2ALIGN(value, align) ((value) & -(sal_IntPtr)(align)) - -#define RTL_MEMORY_P2ROUNDUP(value, align) \ - (-(-(sal_IntPtr)(value) & -(sal_IntPtr)(align))) -#define RTL_MEMORY_P2END(value, align) \ - (-(~(sal_IntPtr)(value) & -(sal_IntPtr)(align))) - - -/** Function inlining macros - * (compiler dependent) - */ -#ifndef RTL_MEMORY_INLINE -#if defined(__GNUC__) -#define RTL_MEMORY_INLINE __inline__ -#elif defined(_MSC_VER) -#define RTL_MEMORY_INLINE __inline -#else -#define RTL_MEMORY_INLINE -#endif /* __GNUC__ || _MSC_VER */ -#endif /* RTL_MEMORY_INLINE */ - - -/** printf() format specifier(s) - * (from C90 ) - */ -#ifndef PRIu64 -#if defined(_MSC_VER) -#define PRIu64 "I64u" -#else /* !_MSC_VER */ -#define PRIu64 "llu" -#endif /* !_MSC_VER */ -#endif /* PRIu64 */ - - -/** highbit(): log2() + 1 - * (complexity O(1)) - */ -static RTL_MEMORY_INLINE int -highbit(sal_Size n) -{ - int k = 1; - - if (n == 0) - return (0); -#if SAL_TYPES_SIZEOFLONG == 8 - if (n & 0xffffffff00000000ul) - k |= 32, n >>= 32; -#endif - if (n & 0xffff0000) - k |= 16, n >>= 16; - if (n & 0xff00) - k |= 8, n >>= 8; - if (n & 0xf0) - k |= 4, n >>= 4; - if (n & 0x0c) - k |= 2, n >>= 2; - if (n & 0x02) - k++; - - return (k); -} - -#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) -#pragma inline(highbit) -#endif /* __SUNPRO_C */ - - -/** lowbit(): find first bit set - * (complexity O(1)) - */ -static RTL_MEMORY_INLINE int -lowbit(sal_Size n) -{ - int k = 1; - - if (n == 0) - return (0); -#if SAL_TYPES_SIZEOFLONG == 8 - if (!(n & 0xffffffff)) - k |= 32, n >>= 32; -#endif - if (!(n & 0xffff)) - k |= 16, n >>= 16; - if (!(n & 0xff)) - k |= 8, n >>= 8; - if (!(n & 0xf)) - k |= 4, n >>= 4; - if (!(n & 0x3)) - k |= 2, n >>= 2; - if (!(n & 0x1)) - k++; - return (k); -} - -#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) -#pragma inline(lowbit) -#endif /* __SUNPRO_C */ - - -/** Queue manipulation macros - * (doubly linked circular list) - * (complexity O(1)) - */ -#define QUEUE_STARTED_NAMED(entry, name) \ - (((entry)->m_##name##next == (entry)) && ((entry)->m_##name##prev == (entry))) - -#define QUEUE_START_NAMED(entry, name) \ -{ \ - (entry)->m_##name##next = (entry); \ - (entry)->m_##name##prev = (entry); \ -} - -#define QUEUE_REMOVE_NAMED(entry, name) \ -{ \ - (entry)->m_##name##prev->m_##name##next = (entry)->m_##name##next; \ - (entry)->m_##name##next->m_##name##prev = (entry)->m_##name##prev; \ - QUEUE_START_NAMED(entry, name); \ -} - -#define QUEUE_INSERT_HEAD_NAMED(head, entry, name) \ -{ \ - (entry)->m_##name##prev = (head); \ - (entry)->m_##name##next = (head)->m_##name##next; \ - (head)->m_##name##next = (entry); \ - (entry)->m_##name##next->m_##name##prev = (entry); \ -} - -#define QUEUE_INSERT_TAIL_NAMED(head, entry, name) \ -{ \ - (entry)->m_##name##next = (head); \ - (entry)->m_##name##prev = (head)->m_##name##prev; \ - (head)->m_##name##prev = (entry); \ - (entry)->m_##name##prev->m_##name##next = (entry); \ -} - - -/** rtl_memory_lock_type - * (platform dependent) - */ -#if defined(SAL_UNX) - -#include -#include - -typedef pthread_mutex_t rtl_memory_lock_type; - -#define RTL_MEMORY_LOCK_INIT(lock) pthread_mutex_init((lock), NULL) -#define RTL_MEMORY_LOCK_DESTROY(lock) pthread_mutex_destroy((lock)) - -#define RTL_MEMORY_LOCK_ACQUIRE(lock) pthread_mutex_lock((lock)) -#define RTL_MEMORY_LOCK_RELEASE(lock) pthread_mutex_unlock((lock)) - -#elif defined(SAL_W32) - -#define WIN32_LEAN_AND_MEAN -#ifdef _MSC_VER -#pragma warning(push,1) /* disable warnings within system headers */ -#endif -#include -#ifdef _MSC_VER -#pragma warning(pop) -#endif - -typedef CRITICAL_SECTION rtl_memory_lock_type; - -#define RTL_MEMORY_LOCK_INIT(lock) InitializeCriticalSection((lock)) -#define RTL_MEMORY_LOCK_DESTROY(lock) DeleteCriticalSection((lock)) - -#define RTL_MEMORY_LOCK_ACQUIRE(lock) EnterCriticalSection((lock)) -#define RTL_MEMORY_LOCK_RELEASE(lock) LeaveCriticalSection((lock)) - -#else -#error Unknown platform -#endif /* SAL_UNX | SAL_W32 */ - - -/** Cache creation flags. - * @internal - */ -#define RTL_CACHE_FLAG_NOMAGAZINE (1 << 13) /* w/o magazine layer */ -#define RTL_CACHE_FLAG_QUANTUMCACHE (2 << 13) /* used as arena quantum cache */ - - -/** Valgrind support macros. - */ -#if !defined(HAVE_MEMCHECK_H) || (OSL_DEBUG_LEVEL == 0) -#if !defined(NVALGRIND) -#define NVALGRIND 1 -#endif /* ! NVALGRIND */ -#endif /* ! HAVE_MEMCHECK_H || (OSL_DEBUG_LEVEL == 0) */ - -#if defined(NVALGRIND) -#define VALGRIND_MAKE_MEM_UNDEFINED(addr, size) -#define VALGRIND_MAKE_MEM_DEFINED(addr, size) -#define VALGRIND_MALLOCLIKE_BLOCK(addr, sizeB, rzB, is_zeroed) -#define VALGRIND_FREELIKE_BLOCK(addr, rzB) -#define VALGRIND_CREATE_MEMPOOL(pool, rzB, is_zeroed) -#define VALGRIND_DESTROY_MEMPOOL(pool) -#define VALGRIND_MEMPOOL_ALLOC(pool, addr, size) -#define VALGRIND_MEMPOOL_FREE(pool, addr) -#define RTL_VALGRIND_IGNORE_VAL -#elif defined(HAVE_MEMCHECK_H) -#include -/* valgrind macros contain unused variables... */ -#define GCC_VERSION (__GNUC__ * 10000 \ - + __GNUC_MINOR__ * 100 \ - + __GNUC_PATCHLEVEL__) -#if GCC_VERSION >= 40201 && !defined __clang__ -#pragma GCC diagnostic warning "-Wunused-but-set-variable" -#endif -#define RTL_VALGRIND_IGNORE_VAL (void) -#endif /* NVALGRIND || HAVE_MEMCHECK_H */ - -typedef enum { AMode_CUSTOM, AMode_SYSTEM, AMode_UNSET } AllocMode; - -extern AllocMode alloc_mode; - -#ifdef __cplusplus -} -#endif - -#endif /* INCLUDED_RTL_ALLOC_IMPL_H */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/alloc_impl.hxx b/sal/rtl/source/alloc_impl.hxx new file mode 100644 index 000000000000..2e51abe2149b --- /dev/null +++ b/sal/rtl/source/alloc_impl.hxx @@ -0,0 +1,275 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_RTL_ALLOC_IMPL_HXX +#define INCLUDED_RTL_ALLOC_IMPL_HXX + +#include "sal/types.h" + +/** Alignment macros + */ +#if SAL_TYPES_ALIGNMENT4 > 1 +#define RTL_MEMORY_ALIGNMENT_4 SAL_TYPES_ALIGNMENT4 +#else +#define RTL_MEMORY_ALIGNMENT_4 sizeof(int) +#endif /* SAL_TYPES_ALIGNMENT4 */ + +#if SAL_TYPES_ALIGNMENT8 > 1 +#define RTL_MEMORY_ALIGNMENT_8 SAL_TYPES_ALIGNMENT8 +#else +#define RTL_MEMORY_ALIGNMENT_8 sizeof(void*) +#endif /* SAL_TYPES_ALIGNMENT8 */ + +#if 0 /* @@@ */ +#define RTL_MEMORY_ALIGNMENT_1 8 +#define RTL_MEMORY_ALIGNMENT_2 (sizeof(void*) * 2) +#endif /* @@@ */ + +#define RTL_MEMORY_ALIGN(value, align) (((value) + ((align) - 1)) & ~((align) - 1)) + +#define RTL_MEMORY_ISP2(value) (((value) & ((value) - 1)) == 0) +#define RTL_MEMORY_P2ALIGN(value, align) ((value) & -(sal_IntPtr)(align)) + +#define RTL_MEMORY_P2ROUNDUP(value, align) \ + (-(-(sal_IntPtr)(value) & -(sal_IntPtr)(align))) +#define RTL_MEMORY_P2END(value, align) \ + (-(~(sal_IntPtr)(value) & -(sal_IntPtr)(align))) + + +/** Function inlining macros + * (compiler dependent) + */ +#ifndef RTL_MEMORY_INLINE +#if defined(__GNUC__) +#define RTL_MEMORY_INLINE __inline__ +#elif defined(_MSC_VER) +#define RTL_MEMORY_INLINE __inline +#else +#define RTL_MEMORY_INLINE +#endif /* __GNUC__ || _MSC_VER */ +#endif /* RTL_MEMORY_INLINE */ + + +/** printf() format specifier(s) + * (from C90 ) + */ +#ifndef PRIu64 +#if defined(_MSC_VER) +#define PRIu64 "I64u" +#else /* !_MSC_VER */ +#define PRIu64 "llu" +#endif /* !_MSC_VER */ +#endif /* PRIu64 */ + + +/** highbit(): log2() + 1 + * (complexity O(1)) + */ +static RTL_MEMORY_INLINE int +highbit(sal_Size n) +{ + int k = 1; + + if (n == 0) + return (0); +#if SAL_TYPES_SIZEOFLONG == 8 + if (n & 0xffffffff00000000ul) + k |= 32, n >>= 32; +#endif + if (n & 0xffff0000) + k |= 16, n >>= 16; + if (n & 0xff00) + k |= 8, n >>= 8; + if (n & 0xf0) + k |= 4, n >>= 4; + if (n & 0x0c) + k |= 2, n >>= 2; + if (n & 0x02) + k++; + + return (k); +} + +#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) +#pragma inline(highbit) +#endif /* __SUNPRO_C */ + + +/** lowbit(): find first bit set + * (complexity O(1)) + */ +static RTL_MEMORY_INLINE int +lowbit(sal_Size n) +{ + int k = 1; + + if (n == 0) + return (0); +#if SAL_TYPES_SIZEOFLONG == 8 + if (!(n & 0xffffffff)) + k |= 32, n >>= 32; +#endif + if (!(n & 0xffff)) + k |= 16, n >>= 16; + if (!(n & 0xff)) + k |= 8, n >>= 8; + if (!(n & 0xf)) + k |= 4, n >>= 4; + if (!(n & 0x3)) + k |= 2, n >>= 2; + if (!(n & 0x1)) + k++; + return (k); +} + +#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) +#pragma inline(lowbit) +#endif /* __SUNPRO_C */ + + +/** Queue manipulation macros + * (doubly linked circular list) + * (complexity O(1)) + */ +#define QUEUE_STARTED_NAMED(entry, name) \ + (((entry)->m_##name##next == (entry)) && ((entry)->m_##name##prev == (entry))) + +#define QUEUE_START_NAMED(entry, name) \ +{ \ + (entry)->m_##name##next = (entry); \ + (entry)->m_##name##prev = (entry); \ +} + +#define QUEUE_REMOVE_NAMED(entry, name) \ +{ \ + (entry)->m_##name##prev->m_##name##next = (entry)->m_##name##next; \ + (entry)->m_##name##next->m_##name##prev = (entry)->m_##name##prev; \ + QUEUE_START_NAMED(entry, name); \ +} + +#define QUEUE_INSERT_HEAD_NAMED(head, entry, name) \ +{ \ + (entry)->m_##name##prev = (head); \ + (entry)->m_##name##next = (head)->m_##name##next; \ + (head)->m_##name##next = (entry); \ + (entry)->m_##name##next->m_##name##prev = (entry); \ +} + +#define QUEUE_INSERT_TAIL_NAMED(head, entry, name) \ +{ \ + (entry)->m_##name##next = (head); \ + (entry)->m_##name##prev = (head)->m_##name##prev; \ + (head)->m_##name##prev = (entry); \ + (entry)->m_##name##prev->m_##name##next = (entry); \ +} + + +/** rtl_memory_lock_type + * (platform dependent) + */ +#if defined(SAL_UNX) + +#include +#include + +typedef pthread_mutex_t rtl_memory_lock_type; + +#define RTL_MEMORY_LOCK_INIT(lock) pthread_mutex_init((lock), NULL) +#define RTL_MEMORY_LOCK_DESTROY(lock) pthread_mutex_destroy((lock)) + +#define RTL_MEMORY_LOCK_ACQUIRE(lock) pthread_mutex_lock((lock)) +#define RTL_MEMORY_LOCK_RELEASE(lock) pthread_mutex_unlock((lock)) + +#elif defined(SAL_W32) + +#define WIN32_LEAN_AND_MEAN +#ifdef _MSC_VER +#pragma warning(push,1) /* disable warnings within system headers */ +#endif +#include +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +typedef CRITICAL_SECTION rtl_memory_lock_type; + +#define RTL_MEMORY_LOCK_INIT(lock) InitializeCriticalSection((lock)) +#define RTL_MEMORY_LOCK_DESTROY(lock) DeleteCriticalSection((lock)) + +#define RTL_MEMORY_LOCK_ACQUIRE(lock) EnterCriticalSection((lock)) +#define RTL_MEMORY_LOCK_RELEASE(lock) LeaveCriticalSection((lock)) + +#else +#error Unknown platform +#endif /* SAL_UNX | SAL_W32 */ + + +/** Cache creation flags. + * @internal + */ +#define RTL_CACHE_FLAG_NOMAGAZINE (1 << 13) /* w/o magazine layer */ +#define RTL_CACHE_FLAG_QUANTUMCACHE (2 << 13) /* used as arena quantum cache */ + + +/** Valgrind support macros. + */ +#if !defined(HAVE_MEMCHECK_H) || (OSL_DEBUG_LEVEL == 0) +#if !defined(NVALGRIND) +#define NVALGRIND 1 +#endif /* ! NVALGRIND */ +#endif /* ! HAVE_MEMCHECK_H || (OSL_DEBUG_LEVEL == 0) */ + +#if defined(NVALGRIND) +#define VALGRIND_MAKE_MEM_UNDEFINED(addr, size) +#define VALGRIND_MAKE_MEM_DEFINED(addr, size) +#define VALGRIND_MALLOCLIKE_BLOCK(addr, sizeB, rzB, is_zeroed) +#define VALGRIND_FREELIKE_BLOCK(addr, rzB) +#define VALGRIND_CREATE_MEMPOOL(pool, rzB, is_zeroed) +#define VALGRIND_DESTROY_MEMPOOL(pool) +#define VALGRIND_MEMPOOL_ALLOC(pool, addr, size) +#define VALGRIND_MEMPOOL_FREE(pool, addr) +#define RTL_VALGRIND_IGNORE_VAL +#elif defined(HAVE_MEMCHECK_H) +#include +/* valgrind macros contain unused variables... */ +#define GCC_VERSION (__GNUC__ * 10000 \ + + __GNUC_MINOR__ * 100 \ + + __GNUC_PATCHLEVEL__) +#if GCC_VERSION >= 40201 && !defined __clang__ +#pragma GCC diagnostic warning "-Wunused-but-set-variable" +#endif +#define RTL_VALGRIND_IGNORE_VAL (void) +#endif /* NVALGRIND || HAVE_MEMCHECK_H */ + +typedef enum { AMode_CUSTOM, AMode_SYSTEM, AMode_UNSET } AllocMode; + +extern AllocMode alloc_mode; + +#endif /* INCLUDED_RTL_ALLOC_IMPL_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/locale.cxx b/sal/rtl/source/locale.cxx index 3e58c4cbb791..1d975ad6fd6b 100644 --- a/sal/rtl/source/locale.cxx +++ b/sal/rtl/source/locale.cxx @@ -32,7 +32,7 @@ #include "rtl/alloc.h" #include "internal/once.h" -#include "internal/rtl_locale_init.h" +#include "internal/rtllifecycle.h" static sal_Int32 RTL_HASHTABLE_SIZE[] = { -- cgit From 54760dfdc26fcded5c62bbad05429db5c9cee935 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 31 Oct 2011 22:32:07 +0100 Subject: Moved sal/rtl/source string files from C to C++, for easier maintenance. --- sal/rtl/source/hash.cxx | 4 +- sal/rtl/source/hash.h | 24 - sal/rtl/source/hash.hxx | 16 + sal/rtl/source/strbuf.c | 179 ----- sal/rtl/source/strbuf.cxx | 179 +++++ sal/rtl/source/strimp.c | 61 -- sal/rtl/source/strimp.cxx | 61 ++ sal/rtl/source/strimp.h | 67 -- sal/rtl/source/strimp.hxx | 59 ++ sal/rtl/source/string.c | 323 -------- sal/rtl/source/string.cxx | 327 +++++++++ sal/rtl/source/strtmpl.c | 1567 --------------------------------------- sal/rtl/source/strtmpl.cxx | 1617 +++++++++++++++++++++++++++++++++++++++++ sal/rtl/source/surrogates.h | 53 -- sal/rtl/source/surrogates.hxx | 53 ++ sal/rtl/source/uri.cxx | 2 +- sal/rtl/source/ustrbuf.c | 239 ------ sal/rtl/source/ustrbuf.cxx | 240 ++++++ sal/rtl/source/ustring.c | 983 ------------------------- sal/rtl/source/ustring.cxx | 997 +++++++++++++++++++++++++ 20 files changed, 3552 insertions(+), 3499 deletions(-) delete mode 100644 sal/rtl/source/hash.h create mode 100644 sal/rtl/source/hash.hxx delete mode 100644 sal/rtl/source/strbuf.c create mode 100644 sal/rtl/source/strbuf.cxx delete mode 100644 sal/rtl/source/strimp.c create mode 100644 sal/rtl/source/strimp.cxx delete mode 100644 sal/rtl/source/strimp.h create mode 100644 sal/rtl/source/strimp.hxx delete mode 100644 sal/rtl/source/string.c create mode 100644 sal/rtl/source/string.cxx delete mode 100644 sal/rtl/source/strtmpl.c create mode 100644 sal/rtl/source/strtmpl.cxx delete mode 100644 sal/rtl/source/surrogates.h create mode 100644 sal/rtl/source/surrogates.hxx delete mode 100644 sal/rtl/source/ustrbuf.c create mode 100644 sal/rtl/source/ustrbuf.cxx delete mode 100644 sal/rtl/source/ustring.c create mode 100644 sal/rtl/source/ustring.cxx diff --git a/sal/rtl/source/hash.cxx b/sal/rtl/source/hash.cxx index 4e03dfc2a6d7..8ddf2683ad53 100644 --- a/sal/rtl/source/hash.cxx +++ b/sal/rtl/source/hash.cxx @@ -29,8 +29,8 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sal.hxx" -#include "hash.h" -#include "strimp.h" +#include "hash.hxx" +#include "strimp.hxx" #include #include diff --git a/sal/rtl/source/hash.h b/sal/rtl/source/hash.h deleted file mode 100644 index 6a6518833dfd..000000000000 --- a/sal/rtl/source/hash.h +++ /dev/null @@ -1,24 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -#ifndef INCLUDED_RTL_SOURCE_HASH_H -#define INCLUDED_RTL_SOURCE_HASH_H - -#include -#include - -#if defined __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* These functions are not multi-thread safe: */ - -rtl_uString *rtl_str_hash_intern (rtl_uString *pString, - int can_return); -void rtl_str_hash_remove (rtl_uString *pString); - -#if defined __cplusplus -} -#endif /* __cplusplus */ - -#endif /* INCLUDED_RTL_SOURCE_HASH_H */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/hash.hxx b/sal/rtl/source/hash.hxx new file mode 100644 index 000000000000..d103efcd64e7 --- /dev/null +++ b/sal/rtl/source/hash.hxx @@ -0,0 +1,16 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +#ifndef INCLUDED_RTL_SOURCE_HASH_HXX +#define INCLUDED_RTL_SOURCE_HASH_HXX + +#include +#include + +/* These functions are not multi-thread safe: */ + +rtl_uString *rtl_str_hash_intern (rtl_uString *pString, + int can_return); +void rtl_str_hash_remove (rtl_uString *pString); + +#endif /* INCLUDED_RTL_SOURCE_HASH_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/strbuf.c b/sal/rtl/source/strbuf.c deleted file mode 100644 index c9a4f3140643..000000000000 --- a/sal/rtl/source/strbuf.c +++ /dev/null @@ -1,179 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include - -#ifndef _RTL_STRING_HXX_ -#include -#endif -#include - -/* -#include -*/ - - - -/************************************************************************* - * rtl_stringbuffer_newFromStr_WithLength - */ -void SAL_CALL rtl_stringbuffer_newFromStr_WithLength( rtl_String ** newStr, - const sal_Char * value, - sal_Int32 count ) -{ - if (!value) - { - rtl_string_new_WithLength( newStr, 16 ); - return; - } - - rtl_string_new_WithLength( newStr, count + 16 ); - (*newStr)->length = count; - rtl_copyMemory( (*newStr)->buffer, value, count ); - return; -} - -/************************************************************************* - * rtl_stringbuffer_newFromStringBuffer - */ -sal_Int32 SAL_CALL rtl_stringbuffer_newFromStringBuffer( rtl_String ** newStr, - sal_Int32 capacity, - rtl_String * oldStr ) -{ - sal_Int32 newCapacity = capacity; - - if (newCapacity < oldStr->length) - newCapacity = oldStr->length; - - rtl_string_new_WithLength( newStr, newCapacity ); - if (oldStr->length > 0) { - (*newStr)->length = oldStr->length; - rtl_copyMemory( (*newStr)->buffer, oldStr->buffer, oldStr->length ); - } - return newCapacity; -} - -/************************************************************************* - * rtl_stringbuffer_ensureCapacity - */ -void SAL_CALL rtl_stringbuffer_ensureCapacity - (rtl_String ** This, sal_Int32* capacity, sal_Int32 minimumCapacity) -{ - if (minimumCapacity > *capacity) - { - rtl_String * pTmp = *This; - rtl_String * pNew = NULL; - *capacity = ((*This)->length + 1) * 2; - if (minimumCapacity > *capacity) - /* still lower, set to the minimum capacity */ - *capacity = minimumCapacity; - - rtl_string_new_WithLength(&pNew, *capacity); - pNew->length = (*This)->length; - *This = pNew; - - rtl_copyMemory( (*This)->buffer, pTmp->buffer, pTmp->length ); - rtl_string_release( pTmp ); - } -} - -/************************************************************************* - * rtl_stringbuffer_insert - */ -void SAL_CALL rtl_stringbuffer_insert( rtl_String ** This, - sal_Int32 * capacity, - sal_Int32 offset, - const sal_Char * str, - sal_Int32 len ) -{ - sal_Int32 nOldLen; - sal_Char * pBuf; - sal_Int32 n; - if( len != 0 ) - { - if (*capacity < (*This)->length + len) - rtl_stringbuffer_ensureCapacity( This, capacity, (*This)->length + len ); - - /* - if( len == 1 ) - This->buffer - */ - nOldLen = (*This)->length; - pBuf = (*This)->buffer; - - /* copy the tail */ - n = (nOldLen - offset); - if( n == 1 ) - /* optimized for 1 character */ - pBuf[offset + len] = pBuf[offset]; - else if( n > 1 ) - rtl_moveMemory( pBuf + offset + len, pBuf + offset, n * sizeof(sal_Char) ); - - /* insert the new characters */ - n = len; - if( len == 1 ) - /* optimized for 1 character */ - pBuf[offset] = *str; - else if( n > 1 ) - rtl_copyMemory( pBuf + offset, str, len * sizeof(sal_Char) ); - (*This)->length = nOldLen + len; - pBuf[ nOldLen + len ] = 0; - } -} - -/************************************************************************* - * rtl_stringbuffer_remove - */ -void SAL_CALL rtl_stringbuffer_remove( rtl_String ** This, - sal_Int32 start, - sal_Int32 len ) -{ - sal_Int32 nTailLen; - sal_Char * pBuf; - - if (len > (*This)->length - start) - len = (*This)->length - start; - - //remove nothing - if (!len) - return; - - pBuf = (*This)->buffer; - nTailLen = (*This)->length - ( start + len ); - - if (nTailLen) - { - /* move the tail */ - rtl_moveMemory(pBuf + start, pBuf + start + len, nTailLen * sizeof(sal_Char)); - } - - (*This)->length-=len; - pBuf[ (*This)->length ] = 0; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/strbuf.cxx b/sal/rtl/source/strbuf.cxx new file mode 100644 index 000000000000..c9a4f3140643 --- /dev/null +++ b/sal/rtl/source/strbuf.cxx @@ -0,0 +1,179 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include + +#ifndef _RTL_STRING_HXX_ +#include +#endif +#include + +/* +#include +*/ + + + +/************************************************************************* + * rtl_stringbuffer_newFromStr_WithLength + */ +void SAL_CALL rtl_stringbuffer_newFromStr_WithLength( rtl_String ** newStr, + const sal_Char * value, + sal_Int32 count ) +{ + if (!value) + { + rtl_string_new_WithLength( newStr, 16 ); + return; + } + + rtl_string_new_WithLength( newStr, count + 16 ); + (*newStr)->length = count; + rtl_copyMemory( (*newStr)->buffer, value, count ); + return; +} + +/************************************************************************* + * rtl_stringbuffer_newFromStringBuffer + */ +sal_Int32 SAL_CALL rtl_stringbuffer_newFromStringBuffer( rtl_String ** newStr, + sal_Int32 capacity, + rtl_String * oldStr ) +{ + sal_Int32 newCapacity = capacity; + + if (newCapacity < oldStr->length) + newCapacity = oldStr->length; + + rtl_string_new_WithLength( newStr, newCapacity ); + if (oldStr->length > 0) { + (*newStr)->length = oldStr->length; + rtl_copyMemory( (*newStr)->buffer, oldStr->buffer, oldStr->length ); + } + return newCapacity; +} + +/************************************************************************* + * rtl_stringbuffer_ensureCapacity + */ +void SAL_CALL rtl_stringbuffer_ensureCapacity + (rtl_String ** This, sal_Int32* capacity, sal_Int32 minimumCapacity) +{ + if (minimumCapacity > *capacity) + { + rtl_String * pTmp = *This; + rtl_String * pNew = NULL; + *capacity = ((*This)->length + 1) * 2; + if (minimumCapacity > *capacity) + /* still lower, set to the minimum capacity */ + *capacity = minimumCapacity; + + rtl_string_new_WithLength(&pNew, *capacity); + pNew->length = (*This)->length; + *This = pNew; + + rtl_copyMemory( (*This)->buffer, pTmp->buffer, pTmp->length ); + rtl_string_release( pTmp ); + } +} + +/************************************************************************* + * rtl_stringbuffer_insert + */ +void SAL_CALL rtl_stringbuffer_insert( rtl_String ** This, + sal_Int32 * capacity, + sal_Int32 offset, + const sal_Char * str, + sal_Int32 len ) +{ + sal_Int32 nOldLen; + sal_Char * pBuf; + sal_Int32 n; + if( len != 0 ) + { + if (*capacity < (*This)->length + len) + rtl_stringbuffer_ensureCapacity( This, capacity, (*This)->length + len ); + + /* + if( len == 1 ) + This->buffer + */ + nOldLen = (*This)->length; + pBuf = (*This)->buffer; + + /* copy the tail */ + n = (nOldLen - offset); + if( n == 1 ) + /* optimized for 1 character */ + pBuf[offset + len] = pBuf[offset]; + else if( n > 1 ) + rtl_moveMemory( pBuf + offset + len, pBuf + offset, n * sizeof(sal_Char) ); + + /* insert the new characters */ + n = len; + if( len == 1 ) + /* optimized for 1 character */ + pBuf[offset] = *str; + else if( n > 1 ) + rtl_copyMemory( pBuf + offset, str, len * sizeof(sal_Char) ); + (*This)->length = nOldLen + len; + pBuf[ nOldLen + len ] = 0; + } +} + +/************************************************************************* + * rtl_stringbuffer_remove + */ +void SAL_CALL rtl_stringbuffer_remove( rtl_String ** This, + sal_Int32 start, + sal_Int32 len ) +{ + sal_Int32 nTailLen; + sal_Char * pBuf; + + if (len > (*This)->length - start) + len = (*This)->length - start; + + //remove nothing + if (!len) + return; + + pBuf = (*This)->buffer; + nTailLen = (*This)->length - ( start + len ); + + if (nTailLen) + { + /* move the tail */ + rtl_moveMemory(pBuf + start, pBuf + start + len, nTailLen * sizeof(sal_Char)); + } + + (*This)->length-=len; + pBuf[ (*This)->length ] = 0; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/strimp.c b/sal/rtl/source/strimp.c deleted file mode 100644 index ae75249fb4aa..000000000000 --- a/sal/rtl/source/strimp.c +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "strimp.h" - -sal_Int16 rtl_ImplGetDigit( sal_Unicode ch, sal_Int16 nRadix ) -{ - sal_Int16 n = -1; - if ( (ch >= '0') && (ch <= '9') ) - n = ch-'0'; - else if ( (ch >= 'a') && (ch <= 'z') ) - n = ch-'a'+10; - else if ( (ch >= 'A') && (ch <= 'Z') ) - n = ch-'A'+10; - return (n < nRadix) ? n : -1; -} - -sal_Bool rtl_ImplIsWhitespace( sal_Unicode c ) -{ - /* Space or Control character? */ - if ( (c <= 32) && c ) - return sal_True; - - /* Only in the General Punctuation area Space or Control characters are included? */ - if ( (c < 0x2000) || (c > 0x206F) ) - return sal_False; - - if ( ((c >= 0x2000) && (c <= 0x200B)) || /* All Spaces */ - (c == 0x2028) || /* LINE SEPARATOR */ - (c == 0x2029) ) /* PARAGRAPH SEPARATOR */ - return sal_True; - - return sal_False; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/strimp.cxx b/sal/rtl/source/strimp.cxx new file mode 100644 index 000000000000..a5b8f827a1b8 --- /dev/null +++ b/sal/rtl/source/strimp.cxx @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "strimp.hxx" + +sal_Int16 rtl_ImplGetDigit( sal_Unicode ch, sal_Int16 nRadix ) +{ + sal_Int16 n = -1; + if ( (ch >= '0') && (ch <= '9') ) + n = ch-'0'; + else if ( (ch >= 'a') && (ch <= 'z') ) + n = ch-'a'+10; + else if ( (ch >= 'A') && (ch <= 'Z') ) + n = ch-'A'+10; + return (n < nRadix) ? n : -1; +} + +sal_Bool rtl_ImplIsWhitespace( sal_Unicode c ) +{ + /* Space or Control character? */ + if ( (c <= 32) && c ) + return sal_True; + + /* Only in the General Punctuation area Space or Control characters are included? */ + if ( (c < 0x2000) || (c > 0x206F) ) + return sal_False; + + if ( ((c >= 0x2000) && (c <= 0x200B)) || /* All Spaces */ + (c == 0x2028) || /* LINE SEPARATOR */ + (c == 0x2029) ) /* PARAGRAPH SEPARATOR */ + return sal_True; + + return sal_False; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/strimp.h b/sal/rtl/source/strimp.h deleted file mode 100644 index 3db89cec8145..000000000000 --- a/sal/rtl/source/strimp.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef INCLUDED_RTL_SOURCE_STRIMP_H -#define INCLUDED_RTL_SOURCE_STRIMP_H - -#include - -#include "sal/types.h" - -/* ======================================================================= */ -/* Help functions for String and UString */ -/* ======================================================================= */ - -#if defined __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* - * refCount is opaqueincludes 2 bit-fields; - * MSB: 'interned' - is stored in the intern hash - * MSB-1: 'static' - is a const / static string, - * do no ref counting - */ -#define SAL_STRING_INTERN_FLAG 0x80000000 -#define SAL_STRING_STATIC_FLAG 0x40000000 -#define SAL_STRING_REFCOUNT(a) ((a) & 0x3fffffff) - -#define SAL_STRING_IS_INTERN(a) ((a)->refCount & SAL_STRING_INTERN_FLAG) -#define SAL_STRING_IS_STATIC(a) ((a)->refCount & SAL_STRING_STATIC_FLAG) - -sal_Int16 rtl_ImplGetDigit( sal_Unicode ch, sal_Int16 nRadix ); - -sal_Bool rtl_ImplIsWhitespace( sal_Unicode c ); - -#if defined __cplusplus -} -#endif /* __cplusplus */ - -#endif /* INCLUDED_RTL_SOURCE_STRIMP_H */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/strimp.hxx b/sal/rtl/source/strimp.hxx new file mode 100644 index 000000000000..a9e5a38f6da7 --- /dev/null +++ b/sal/rtl/source/strimp.hxx @@ -0,0 +1,59 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_RTL_SOURCE_STRIMP_HXX +#define INCLUDED_RTL_SOURCE_STRIMP_HXX + +#include + +#include "sal/types.h" + +/* ======================================================================= */ +/* Help functions for String and UString */ +/* ======================================================================= */ + +/* + * refCount is opaqueincludes 2 bit-fields; + * MSB: 'interned' - is stored in the intern hash + * MSB-1: 'static' - is a const / static string, + * do no ref counting + */ +#define SAL_STRING_INTERN_FLAG 0x80000000 +#define SAL_STRING_STATIC_FLAG 0x40000000 +#define SAL_STRING_REFCOUNT(a) ((a) & 0x3fffffff) + +#define SAL_STRING_IS_INTERN(a) ((a)->refCount & SAL_STRING_INTERN_FLAG) +#define SAL_STRING_IS_STATIC(a) ((a)->refCount & SAL_STRING_STATIC_FLAG) + +sal_Int16 rtl_ImplGetDigit( sal_Unicode ch, sal_Int16 nRadix ); + +sal_Bool rtl_ImplIsWhitespace( sal_Unicode c ); + +#endif /* INCLUDED_RTL_SOURCE_STRIMP_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/string.c b/sal/rtl/source/string.c deleted file mode 100644 index 2ee79611218a..000000000000 --- a/sal/rtl/source/string.c +++ /dev/null @@ -1,323 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#if defined(_MSC_VER) && (_MSC_VER >= 1400) -#pragma warning(disable:4738) // storing 32-bit float result in memory, possible loss of performance -#endif - -#include -#include -#include -#include -#include - -#include "strimp.h" -#include "surrogates.h" -#include - -#include "rtl/math.h" -#include "rtl/tencinfo.h" - -/* ======================================================================= */ - -/* static data to be referenced by all empty strings - * the refCount is predefined to 1 and must never become 0 ! - */ -static rtl_String const aImplEmpty_rtl_String = -{ - SAL_STRING_STATIC_FLAG|1, - /* sal_Int32 refCount; */ - 0, /* sal_Int32 length; */ - { 0 } /* sal_Char buffer[1]; */ -}; - -/* ======================================================================= */ - -#define IMPL_RTL_STRCODE sal_Char -#define IMPL_RTL_USTRCODE( c ) ((unsigned char)c) -#define IMPL_RTL_STRNAME( n ) rtl_str_ ## n - -#define IMPL_RTL_STRINGNAME( n ) rtl_string_ ## n -#define IMPL_RTL_STRINGDATA rtl_String -#define IMPL_RTL_EMPTYSTRING aImplEmpty_rtl_String - -/* ======================================================================= */ - -/* Include String/UString template code */ - -#include "strtmpl.c" - -sal_Int32 SAL_CALL rtl_str_valueOfFloat(sal_Char * pStr, float f) -{ - rtl_String * pResult = NULL; - sal_Int32 nLen; - rtl_math_doubleToString( - &pResult, 0, 0, f, rtl_math_StringFormat_G, - RTL_STR_MAX_VALUEOFFLOAT - RTL_CONSTASCII_LENGTH("-x.E-xxx"), '.', 0, 0, - sal_True); - nLen = pResult->length; - OSL_ASSERT(nLen < RTL_STR_MAX_VALUEOFFLOAT); - rtl_copyMemory(pStr, pResult->buffer, (nLen + 1) * sizeof(sal_Char)); - rtl_string_release(pResult); - return nLen; -} - -sal_Int32 SAL_CALL rtl_str_valueOfDouble(sal_Char * pStr, double d) -{ - rtl_String * pResult = NULL; - sal_Int32 nLen; - rtl_math_doubleToString( - &pResult, 0, 0, d, rtl_math_StringFormat_G, - RTL_STR_MAX_VALUEOFDOUBLE - RTL_CONSTASCII_LENGTH("-x.E-xxx"), '.', 0, - 0, sal_True); - nLen = pResult->length; - OSL_ASSERT(nLen < RTL_STR_MAX_VALUEOFDOUBLE); - rtl_copyMemory(pStr, pResult->buffer, (nLen + 1) * sizeof(sal_Char)); - rtl_string_release(pResult); - return nLen; -} - -float SAL_CALL rtl_str_toFloat(sal_Char const * pStr) -{ - return (float) rtl_math_stringToDouble(pStr, pStr + rtl_str_getLength(pStr), - '.', 0, 0, 0); -} - -double SAL_CALL rtl_str_toDouble(sal_Char const * pStr) -{ - return rtl_math_stringToDouble(pStr, pStr + rtl_str_getLength(pStr), '.', 0, - 0, 0); -} - -/* ======================================================================= */ - -static int rtl_ImplGetFastUTF8ByteLen( const sal_Unicode* pStr, sal_Int32 nLen ) -{ - int n; - sal_Unicode c; - sal_uInt32 nUCS4Char; - const sal_Unicode* pEndStr; - - n = 0; - pEndStr = pStr+nLen; - while ( pStr < pEndStr ) - { - c = *pStr; - - if ( c < 0x80 ) - n++; - else if ( c < 0x800 ) - n += 2; - else - { - if ( !SAL_RTL_IS_HIGH_SURROGATE(c) ) - n += 3; - else - { - nUCS4Char = c; - - if ( pStr+1 < pEndStr ) - { - c = *(pStr+1); - if ( SAL_RTL_IS_LOW_SURROGATE(c) ) - { - nUCS4Char = SAL_RTL_COMBINE_SURROGATES(nUCS4Char, c); - pStr++; - } - } - - if ( nUCS4Char < 0x10000 ) - n += 3; - else if ( nUCS4Char < 0x200000 ) - n += 4; - else if ( nUCS4Char < 0x4000000 ) - n += 5; - else - n += 6; - } - } - - pStr++; - } - - return n; -} - -/* ----------------------------------------------------------------------- */ - -sal_Bool SAL_CALL rtl_impl_convertUStringToString(rtl_String ** pTarget, - sal_Unicode const * pSource, - sal_Int32 nLength, - rtl_TextEncoding nEncoding, - sal_uInt32 nFlags, - sal_Bool bCheckErrors) -{ - OSL_ASSERT(pTarget != NULL - && (pSource != NULL || nLength == 0) - && nLength >= 0 - && (nLength == 0 || rtl_isOctetTextEncoding(nEncoding))); - - if ( !nLength ) - rtl_string_new( pTarget ); - else - { - rtl_String* pTemp; - rtl_UnicodeToTextConverter hConverter; - sal_uInt32 nInfo; - sal_Size nSrcChars; - sal_Size nDestBytes; - sal_Size nNewLen; - sal_Size nNotConvertedChars; - sal_Size nMaxCharLen; - - /* Optimization for UTF-8 - we try to calculate the exact length */ - /* For all other encoding we try an good estimation */ - if ( nEncoding == RTL_TEXTENCODING_UTF8 ) - { - nNewLen = rtl_ImplGetFastUTF8ByteLen( pSource, nLength ); - /* Includes the string only ASCII, then we could copy - the buffer faster */ - if ( nNewLen == (sal_Size)nLength ) - { - IMPL_RTL_STRCODE* pBuffer; - if ( *pTarget ) - IMPL_RTL_STRINGNAME( release )( *pTarget ); - *pTarget = IMPL_RTL_STRINGNAME( ImplAlloc )( nLength ); - OSL_ASSERT(*pTarget != NULL); - pBuffer = (*pTarget)->buffer; - do - { - /* Check ASCII range */ - OSL_ENSURE( *pSource <= 127, - "rtl_uString2String() - UTF8 test is encoding is wrong" ); - - *pBuffer = (IMPL_RTL_STRCODE)(unsigned char)*pSource; - pBuffer++; - pSource++; - nLength--; - } - while ( nLength ); - return sal_True; - } - - nMaxCharLen = 4; - } - else - { - rtl_TextEncodingInfo aTextEncInfo; - aTextEncInfo.StructSize = sizeof( aTextEncInfo ); - if ( !rtl_getTextEncodingInfo( nEncoding, &aTextEncInfo ) ) - { - aTextEncInfo.AverageCharSize = 1; - aTextEncInfo.MaximumCharSize = 8; - } - - nNewLen = nLength*aTextEncInfo.AverageCharSize; - nMaxCharLen = aTextEncInfo.MaximumCharSize; - } - - nFlags |= RTL_UNICODETOTEXT_FLAGS_FLUSH; - hConverter = rtl_createUnicodeToTextConverter( nEncoding ); - - for (;;) - { - pTemp = IMPL_RTL_STRINGNAME( ImplAlloc )( nNewLen ); - OSL_ASSERT(pTemp != NULL); - nDestBytes = rtl_convertUnicodeToText( hConverter, 0, - pSource, nLength, - pTemp->buffer, nNewLen, - nFlags, - &nInfo, &nSrcChars ); - if (bCheckErrors && (nInfo & RTL_UNICODETOTEXT_INFO_ERROR) != 0) - { - rtl_freeMemory(pTemp); - rtl_destroyUnicodeToTextConverter(hConverter); - return sal_False; - } - - if ((nInfo & RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL) == 0) - break; - - /* Buffer not big enough, try again with enough space */ - rtl_freeMemory( pTemp ); - - /* Try with the max. count of characters with - additional overhead for replacing functionality */ - nNotConvertedChars = nLength-nSrcChars; - nNewLen = nDestBytes+(nNotConvertedChars*nMaxCharLen)+nNotConvertedChars+4; - } - - /* Set the buffer to the correct size or is there to - much overhead, reallocate to the correct size */ - if ( nNewLen > nDestBytes+8 ) - { - rtl_String* pTemp2 = IMPL_RTL_STRINGNAME( ImplAlloc )( nDestBytes ); - OSL_ASSERT(pTemp2 != NULL); - rtl_str_ImplCopy( pTemp2->buffer, pTemp->buffer, nDestBytes ); - rtl_freeMemory( pTemp ); - pTemp = pTemp2; - } - else - { - pTemp->length = nDestBytes; - pTemp->buffer[nDestBytes] = 0; - } - - rtl_destroyUnicodeToTextConverter( hConverter ); - if ( *pTarget ) - IMPL_RTL_STRINGNAME( release )( *pTarget ); - *pTarget = pTemp; - - /* Results the conversion in an empty buffer - - create an empty string */ - if ( pTemp && !nDestBytes ) - rtl_string_new( pTarget ); - } - return sal_True; -} - -void SAL_CALL rtl_uString2String( rtl_String** ppThis, - const sal_Unicode* pUStr, - sal_Int32 nULen, - rtl_TextEncoding eTextEncoding, - sal_uInt32 nCvtFlags ) -{ - rtl_impl_convertUStringToString(ppThis, pUStr, nULen, eTextEncoding, - nCvtFlags, sal_False); -} - -sal_Bool SAL_CALL rtl_convertUStringToString(rtl_String ** pTarget, - sal_Unicode const * pSource, - sal_Int32 nLength, - rtl_TextEncoding nEncoding, - sal_uInt32 nFlags) -{ - return rtl_impl_convertUStringToString(pTarget, pSource, nLength, nEncoding, - nFlags, sal_True); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/string.cxx b/sal/rtl/source/string.cxx new file mode 100644 index 000000000000..c43b564a2099 --- /dev/null +++ b/sal/rtl/source/string.cxx @@ -0,0 +1,327 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#if defined(_MSC_VER) && (_MSC_VER >= 1400) +#pragma warning(disable:4738) // storing 32-bit float result in memory, possible loss of performance +#endif + +#include +#include +#include +#include +#include + +#include "strimp.hxx" +#include "surrogates.hxx" +#include + +#include "rtl/math.h" +#include "rtl/tencinfo.h" + +/* ======================================================================= */ + +/* static data to be referenced by all empty strings + * the refCount is predefined to 1 and must never become 0 ! + */ +static rtl_String const aImplEmpty_rtl_String = +{ + SAL_STRING_STATIC_FLAG|1, + /* sal_Int32 refCount; */ + 0, /* sal_Int32 length; */ + { 0 } /* sal_Char buffer[1]; */ +}; + +/* ======================================================================= */ + +#define IMPL_RTL_STRCODE sal_Char +#define IMPL_RTL_USTRCODE( c ) ((unsigned char)c) +#define IMPL_RTL_STRNAME( n ) rtl_str_ ## n + +#define IMPL_RTL_STRINGNAME( n ) rtl_string_ ## n +#define IMPL_RTL_STRINGDATA rtl_String +#define IMPL_RTL_EMPTYSTRING aImplEmpty_rtl_String + +/* ======================================================================= */ + +/* Include String/UString template code */ + +#include "strtmpl.cxx" + +sal_Int32 SAL_CALL rtl_str_valueOfFloat(sal_Char * pStr, float f) + SAL_THROW_EXTERN_C() +{ + rtl_String * pResult = NULL; + sal_Int32 nLen; + rtl_math_doubleToString( + &pResult, 0, 0, f, rtl_math_StringFormat_G, + RTL_STR_MAX_VALUEOFFLOAT - RTL_CONSTASCII_LENGTH("-x.E-xxx"), '.', 0, 0, + sal_True); + nLen = pResult->length; + OSL_ASSERT(nLen < RTL_STR_MAX_VALUEOFFLOAT); + rtl_copyMemory(pStr, pResult->buffer, (nLen + 1) * sizeof(sal_Char)); + rtl_string_release(pResult); + return nLen; +} + +sal_Int32 SAL_CALL rtl_str_valueOfDouble(sal_Char * pStr, double d) + SAL_THROW_EXTERN_C() +{ + rtl_String * pResult = NULL; + sal_Int32 nLen; + rtl_math_doubleToString( + &pResult, 0, 0, d, rtl_math_StringFormat_G, + RTL_STR_MAX_VALUEOFDOUBLE - RTL_CONSTASCII_LENGTH("-x.E-xxx"), '.', 0, + 0, sal_True); + nLen = pResult->length; + OSL_ASSERT(nLen < RTL_STR_MAX_VALUEOFDOUBLE); + rtl_copyMemory(pStr, pResult->buffer, (nLen + 1) * sizeof(sal_Char)); + rtl_string_release(pResult); + return nLen; +} + +float SAL_CALL rtl_str_toFloat(sal_Char const * pStr) SAL_THROW_EXTERN_C() +{ + return (float) rtl_math_stringToDouble(pStr, pStr + rtl_str_getLength(pStr), + '.', 0, 0, 0); +} + +double SAL_CALL rtl_str_toDouble(sal_Char const * pStr) SAL_THROW_EXTERN_C() +{ + return rtl_math_stringToDouble(pStr, pStr + rtl_str_getLength(pStr), '.', 0, + 0, 0); +} + +/* ======================================================================= */ + +static int rtl_ImplGetFastUTF8ByteLen( const sal_Unicode* pStr, sal_Int32 nLen ) +{ + int n; + sal_Unicode c; + sal_uInt32 nUCS4Char; + const sal_Unicode* pEndStr; + + n = 0; + pEndStr = pStr+nLen; + while ( pStr < pEndStr ) + { + c = *pStr; + + if ( c < 0x80 ) + n++; + else if ( c < 0x800 ) + n += 2; + else + { + if ( !SAL_RTL_IS_HIGH_SURROGATE(c) ) + n += 3; + else + { + nUCS4Char = c; + + if ( pStr+1 < pEndStr ) + { + c = *(pStr+1); + if ( SAL_RTL_IS_LOW_SURROGATE(c) ) + { + nUCS4Char = SAL_RTL_COMBINE_SURROGATES(nUCS4Char, c); + pStr++; + } + } + + if ( nUCS4Char < 0x10000 ) + n += 3; + else if ( nUCS4Char < 0x200000 ) + n += 4; + else if ( nUCS4Char < 0x4000000 ) + n += 5; + else + n += 6; + } + } + + pStr++; + } + + return n; +} + +/* ----------------------------------------------------------------------- */ + +sal_Bool SAL_CALL rtl_impl_convertUStringToString(rtl_String ** pTarget, + sal_Unicode const * pSource, + sal_Int32 nLength, + rtl_TextEncoding nEncoding, + sal_uInt32 nFlags, + sal_Bool bCheckErrors) +{ + OSL_ASSERT(pTarget != NULL + && (pSource != NULL || nLength == 0) + && nLength >= 0 + && (nLength == 0 || rtl_isOctetTextEncoding(nEncoding))); + + if ( !nLength ) + rtl_string_new( pTarget ); + else + { + rtl_String* pTemp; + rtl_UnicodeToTextConverter hConverter; + sal_uInt32 nInfo; + sal_Size nSrcChars; + sal_Size nDestBytes; + sal_Size nNewLen; + sal_Size nNotConvertedChars; + sal_Size nMaxCharLen; + + /* Optimization for UTF-8 - we try to calculate the exact length */ + /* For all other encoding we try an good estimation */ + if ( nEncoding == RTL_TEXTENCODING_UTF8 ) + { + nNewLen = rtl_ImplGetFastUTF8ByteLen( pSource, nLength ); + /* Includes the string only ASCII, then we could copy + the buffer faster */ + if ( nNewLen == (sal_Size)nLength ) + { + IMPL_RTL_STRCODE* pBuffer; + if ( *pTarget ) + IMPL_RTL_STRINGNAME( release )( *pTarget ); + *pTarget = IMPL_RTL_STRINGNAME( ImplAlloc )( nLength ); + OSL_ASSERT(*pTarget != NULL); + pBuffer = (*pTarget)->buffer; + do + { + /* Check ASCII range */ + OSL_ENSURE( *pSource <= 127, + "rtl_uString2String() - UTF8 test is encoding is wrong" ); + + *pBuffer = (IMPL_RTL_STRCODE)(unsigned char)*pSource; + pBuffer++; + pSource++; + nLength--; + } + while ( nLength ); + return sal_True; + } + + nMaxCharLen = 4; + } + else + { + rtl_TextEncodingInfo aTextEncInfo; + aTextEncInfo.StructSize = sizeof( aTextEncInfo ); + if ( !rtl_getTextEncodingInfo( nEncoding, &aTextEncInfo ) ) + { + aTextEncInfo.AverageCharSize = 1; + aTextEncInfo.MaximumCharSize = 8; + } + + nNewLen = nLength*aTextEncInfo.AverageCharSize; + nMaxCharLen = aTextEncInfo.MaximumCharSize; + } + + nFlags |= RTL_UNICODETOTEXT_FLAGS_FLUSH; + hConverter = rtl_createUnicodeToTextConverter( nEncoding ); + + for (;;) + { + pTemp = IMPL_RTL_STRINGNAME( ImplAlloc )( nNewLen ); + OSL_ASSERT(pTemp != NULL); + nDestBytes = rtl_convertUnicodeToText( hConverter, 0, + pSource, nLength, + pTemp->buffer, nNewLen, + nFlags, + &nInfo, &nSrcChars ); + if (bCheckErrors && (nInfo & RTL_UNICODETOTEXT_INFO_ERROR) != 0) + { + rtl_freeMemory(pTemp); + rtl_destroyUnicodeToTextConverter(hConverter); + return sal_False; + } + + if ((nInfo & RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL) == 0) + break; + + /* Buffer not big enough, try again with enough space */ + rtl_freeMemory( pTemp ); + + /* Try with the max. count of characters with + additional overhead for replacing functionality */ + nNotConvertedChars = nLength-nSrcChars; + nNewLen = nDestBytes+(nNotConvertedChars*nMaxCharLen)+nNotConvertedChars+4; + } + + /* Set the buffer to the correct size or is there to + much overhead, reallocate to the correct size */ + if ( nNewLen > nDestBytes+8 ) + { + rtl_String* pTemp2 = IMPL_RTL_STRINGNAME( ImplAlloc )( nDestBytes ); + OSL_ASSERT(pTemp2 != NULL); + rtl_str_ImplCopy( pTemp2->buffer, pTemp->buffer, nDestBytes ); + rtl_freeMemory( pTemp ); + pTemp = pTemp2; + } + else + { + pTemp->length = nDestBytes; + pTemp->buffer[nDestBytes] = 0; + } + + rtl_destroyUnicodeToTextConverter( hConverter ); + if ( *pTarget ) + IMPL_RTL_STRINGNAME( release )( *pTarget ); + *pTarget = pTemp; + + /* Results the conversion in an empty buffer - + create an empty string */ + if ( pTemp && !nDestBytes ) + rtl_string_new( pTarget ); + } + return sal_True; +} + +void SAL_CALL rtl_uString2String( rtl_String** ppThis, + const sal_Unicode* pUStr, + sal_Int32 nULen, + rtl_TextEncoding eTextEncoding, + sal_uInt32 nCvtFlags ) + SAL_THROW_EXTERN_C() +{ + rtl_impl_convertUStringToString(ppThis, pUStr, nULen, eTextEncoding, + nCvtFlags, sal_False); +} + +sal_Bool SAL_CALL rtl_convertUStringToString(rtl_String ** pTarget, + sal_Unicode const * pSource, + sal_Int32 nLength, + rtl_TextEncoding nEncoding, + sal_uInt32 nFlags) + SAL_THROW_EXTERN_C() +{ + return rtl_impl_convertUStringToString(pTarget, pSource, nLength, nEncoding, + nFlags, sal_True); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/strtmpl.c b/sal/rtl/source/strtmpl.c deleted file mode 100644 index 830521d7b94f..000000000000 --- a/sal/rtl/source/strtmpl.c +++ /dev/null @@ -1,1567 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -/* ======================================================================= */ -/* Internal C-String help functions which could be used without the */ -/* String-Class */ -/* ======================================================================= */ - -#include - -/* -inline void rtl_str_ImplCopy( IMPL_RTL_STRCODE* pDest, - const IMPL_RTL_STRCODE* pSrc, - sal_Int32 nCount ) -{ - while ( nCount > 0 ) - { - *pDest = *pSrc; - pDest++; - pSrc++; - nCount--; - } -} -*/ - -#define rtl_str_ImplCopy( _pDest, _pSrc, _nCount ) \ -{ \ - IMPL_RTL_STRCODE* __mm_pDest = _pDest; \ - const IMPL_RTL_STRCODE* __mm_pSrc = _pSrc; \ - sal_Int32 __mm_nCount = _nCount; \ - while ( __mm_nCount > 0 ) \ - { \ - *__mm_pDest = *__mm_pSrc; \ - __mm_pDest++; \ - __mm_pSrc++; \ - __mm_nCount--; \ - } \ -} - -/* ======================================================================= */ -/* C-String functions which could be used without the String-Class */ -/* ======================================================================= */ - -sal_Int32 SAL_CALL IMPL_RTL_STRNAME( getLength )( const IMPL_RTL_STRCODE* pStr ) -{ - const IMPL_RTL_STRCODE* pTempStr = pStr; - while( *pTempStr ) - pTempStr++; - return pTempStr-pStr; -} - -/* ----------------------------------------------------------------------- */ - -sal_Int32 SAL_CALL IMPL_RTL_STRNAME( compare )( const IMPL_RTL_STRCODE* pStr1, - const IMPL_RTL_STRCODE* pStr2 ) -{ - sal_Int32 nRet; - while ( ((nRet = ((sal_Int32)(IMPL_RTL_USTRCODE(*pStr1)))- - ((sal_Int32)(IMPL_RTL_USTRCODE(*pStr2)))) == 0) && - *pStr2 ) - { - pStr1++; - pStr2++; - } - - return nRet; -} - -/* ----------------------------------------------------------------------- */ - -sal_Int32 SAL_CALL IMPL_RTL_STRNAME( compare_WithLength )( const IMPL_RTL_STRCODE* pStr1, - sal_Int32 nStr1Len, - const IMPL_RTL_STRCODE* pStr2, - sal_Int32 nStr2Len ) -{ - sal_Int32 nRet = nStr1Len - nStr2Len; - int nCount = (nRet <= 0) ? nStr1Len : nStr2Len; - - --pStr1; - --pStr2; - while( (--nCount >= 0) && (*++pStr1 == *++pStr2) ); - - if( nCount >= 0 ) - nRet = ((sal_Int32)(IMPL_RTL_USTRCODE( *pStr1 ))) - - ((sal_Int32)(IMPL_RTL_USTRCODE( *pStr2 ))); - - return nRet; -} - -/* ----------------------------------------------------------------------- */ - -sal_Int32 SAL_CALL IMPL_RTL_STRNAME( shortenedCompare_WithLength )( const IMPL_RTL_STRCODE* pStr1, - sal_Int32 nStr1Len, - const IMPL_RTL_STRCODE* pStr2, - sal_Int32 nStr2Len, - sal_Int32 nShortenedLength ) -{ - const IMPL_RTL_STRCODE* pStr1End = pStr1 + nStr1Len; - const IMPL_RTL_STRCODE* pStr2End = pStr2 + nStr2Len; - sal_Int32 nRet; - while ( (nShortenedLength > 0) && - (pStr1 < pStr1End) && (pStr2 < pStr2End) ) - { - nRet = ((sal_Int32)(IMPL_RTL_USTRCODE( *pStr1 )))- - ((sal_Int32)(IMPL_RTL_USTRCODE( *pStr2 ))); - if ( nRet ) - return nRet; - - nShortenedLength--; - pStr1++; - pStr2++; - } - - if ( nShortenedLength <= 0 ) - return 0; - return nStr1Len - nStr2Len; -} - -/* ----------------------------------------------------------------------- */ - -sal_Int32 SAL_CALL IMPL_RTL_STRNAME( reverseCompare_WithLength )( const IMPL_RTL_STRCODE* pStr1, - sal_Int32 nStr1Len, - const IMPL_RTL_STRCODE* pStr2, - sal_Int32 nStr2Len ) -{ - const IMPL_RTL_STRCODE* pStr1Run = pStr1+nStr1Len; - const IMPL_RTL_STRCODE* pStr2Run = pStr2+nStr2Len; - sal_Int32 nRet; - while ( (pStr1 < pStr1Run) && (pStr2 < pStr2Run) ) - { - pStr1Run--; - pStr2Run--; - nRet = ((sal_Int32)(IMPL_RTL_USTRCODE( *pStr1Run )))- - ((sal_Int32)(IMPL_RTL_USTRCODE( *pStr2Run ))); - if ( nRet ) - return nRet; - } - - return nStr1Len - nStr2Len; -} - -/* ----------------------------------------------------------------------- */ - -sal_Int32 SAL_CALL IMPL_RTL_STRNAME( compareIgnoreAsciiCase )( const IMPL_RTL_STRCODE* pStr1, - const IMPL_RTL_STRCODE* pStr2 ) -{ - sal_Int32 nRet; - sal_Int32 c1; - sal_Int32 c2; - do - { - /* If character between 'A' and 'Z', than convert it to lowercase */ - c1 = (sal_Int32)IMPL_RTL_USTRCODE( *pStr1 ); - c2 = (sal_Int32)IMPL_RTL_USTRCODE( *pStr2 ); - if ( (c1 >= 65) && (c1 <= 90) ) - c1 += 32; - if ( (c2 >= 65) && (c2 <= 90) ) - c2 += 32; - nRet = c1-c2; - if ( nRet != 0 ) - return nRet; - - pStr1++; - pStr2++; - } - while ( c2 ); - - return 0; -} - -/* ----------------------------------------------------------------------- */ - -sal_Int32 SAL_CALL IMPL_RTL_STRNAME( compareIgnoreAsciiCase_WithLength )( const IMPL_RTL_STRCODE* pStr1, - sal_Int32 nStr1Len, - const IMPL_RTL_STRCODE* pStr2, - sal_Int32 nStr2Len ) -{ - const IMPL_RTL_STRCODE* pStr1End = pStr1 + nStr1Len; - const IMPL_RTL_STRCODE* pStr2End = pStr2 + nStr2Len; - sal_Int32 nRet; - sal_Int32 c1; - sal_Int32 c2; - while ( (pStr1 < pStr1End) && (pStr2 < pStr2End) ) - { - /* If character between 'A' and 'Z', than convert it to lowercase */ - c1 = (sal_Int32)IMPL_RTL_USTRCODE( *pStr1 ); - c2 = (sal_Int32)IMPL_RTL_USTRCODE( *pStr2 ); - if ( (c1 >= 65) && (c1 <= 90) ) - c1 += 32; - if ( (c2 >= 65) && (c2 <= 90) ) - c2 += 32; - nRet = c1-c2; - if ( nRet != 0 ) - return nRet; - - pStr1++; - pStr2++; - } - - return nStr1Len - nStr2Len; -} - -/* ----------------------------------------------------------------------- */ - -sal_Int32 SAL_CALL IMPL_RTL_STRNAME( shortenedCompareIgnoreAsciiCase_WithLength )( const IMPL_RTL_STRCODE* pStr1, - sal_Int32 nStr1Len, - const IMPL_RTL_STRCODE* pStr2, - sal_Int32 nStr2Len, - sal_Int32 nShortenedLength ) -{ - const IMPL_RTL_STRCODE* pStr1End = pStr1 + nStr1Len; - const IMPL_RTL_STRCODE* pStr2End = pStr2 + nStr2Len; - sal_Int32 nRet; - sal_Int32 c1; - sal_Int32 c2; - while ( (nShortenedLength > 0) && - (pStr1 < pStr1End) && (pStr2 < pStr2End) ) - { - /* If character between 'A' and 'Z', than convert it to lowercase */ - c1 = (sal_Int32)IMPL_RTL_USTRCODE( *pStr1 ); - c2 = (sal_Int32)IMPL_RTL_USTRCODE( *pStr2 ); - if ( (c1 >= 65) && (c1 <= 90) ) - c1 += 32; - if ( (c2 >= 65) && (c2 <= 90) ) - c2 += 32; - nRet = c1-c2; - if ( nRet != 0 ) - return nRet; - - nShortenedLength--; - pStr1++; - pStr2++; - } - - if ( nShortenedLength <= 0 ) - return 0; - return nStr1Len - nStr2Len; -} - -/* ----------------------------------------------------------------------- */ - -sal_Int32 SAL_CALL IMPL_RTL_STRNAME( hashCode )( const IMPL_RTL_STRCODE* pStr ) -{ - return IMPL_RTL_STRNAME( hashCode_WithLength )( pStr, IMPL_RTL_STRNAME( getLength )( pStr ) ); -} - -/* ----------------------------------------------------------------------- */ - -sal_Int32 SAL_CALL IMPL_RTL_STRNAME( hashCode_WithLength )( const IMPL_RTL_STRCODE* pStr, - sal_Int32 nLen ) -{ - sal_Int32 h = nLen; - - if ( nLen < 256 ) - { - while ( nLen > 0 ) - { - h = (h*37) + IMPL_RTL_USTRCODE( *pStr ); - pStr++; - nLen--; - } - } - else - { - sal_Int32 nSkip; - const IMPL_RTL_STRCODE* pEndStr = pStr+nLen-5; - - /* only sample some characters */ - /* the first 3, some characters between, and the last 5 */ - h = (h*39) + IMPL_RTL_USTRCODE( *pStr ); - pStr++; - h = (h*39) + IMPL_RTL_USTRCODE( *pStr ); - pStr++; - h = (h*39) + IMPL_RTL_USTRCODE( *pStr ); - pStr++; - - if ( nLen < 32 ) - nSkip = nLen / 4; - else - nSkip = nLen / 8; - nLen -= 8; - while ( nLen > 0 ) - { - h = (h*39) + IMPL_RTL_USTRCODE( *pStr ); - pStr += nSkip; - nLen -= nSkip; - } - - h = (h*39) + IMPL_RTL_USTRCODE( *pEndStr ); - pEndStr++; - h = (h*39) + IMPL_RTL_USTRCODE( *pEndStr ); - pEndStr++; - h = (h*39) + IMPL_RTL_USTRCODE( *pEndStr ); - pEndStr++; - h = (h*39) + IMPL_RTL_USTRCODE( *pEndStr ); - pEndStr++; - h = (h*39) + IMPL_RTL_USTRCODE( *pEndStr ); - } - - return h; -} - -/* ----------------------------------------------------------------------- */ - -sal_Int32 SAL_CALL IMPL_RTL_STRNAME( indexOfChar )( const IMPL_RTL_STRCODE* pStr, - IMPL_RTL_STRCODE c ) -{ - const IMPL_RTL_STRCODE* pTempStr = pStr; - while ( *pTempStr ) - { - if ( *pTempStr == c ) - return pTempStr-pStr; - - pTempStr++; - } - - return -1; -} - -/* ----------------------------------------------------------------------- */ - -sal_Int32 SAL_CALL IMPL_RTL_STRNAME( indexOfChar_WithLength )( const IMPL_RTL_STRCODE* pStr, - sal_Int32 nLen, - IMPL_RTL_STRCODE c ) -{ - const IMPL_RTL_STRCODE* pTempStr = pStr; - while ( nLen > 0 ) - { - if ( *pTempStr == c ) - return pTempStr-pStr; - - pTempStr++; - nLen--; - } - - return -1; -} - -/* ----------------------------------------------------------------------- */ - -sal_Int32 SAL_CALL IMPL_RTL_STRNAME( lastIndexOfChar )( const IMPL_RTL_STRCODE* pStr, - IMPL_RTL_STRCODE c ) -{ - return IMPL_RTL_STRNAME( lastIndexOfChar_WithLength )( pStr, IMPL_RTL_STRNAME( getLength )( pStr ), c ); -} - -/* ----------------------------------------------------------------------- */ - -sal_Int32 SAL_CALL IMPL_RTL_STRNAME( lastIndexOfChar_WithLength )( const IMPL_RTL_STRCODE* pStr, - sal_Int32 nLen, - IMPL_RTL_STRCODE c ) -{ - pStr += nLen; - while ( nLen > 0 ) - { - nLen--; - pStr--; - - if ( *pStr == c ) - return nLen; - } - - return -1; -} - -/* ----------------------------------------------------------------------- */ - -sal_Int32 SAL_CALL IMPL_RTL_STRNAME( indexOfStr )( const IMPL_RTL_STRCODE* pStr, - const IMPL_RTL_STRCODE* pSubStr ) -{ - return IMPL_RTL_STRNAME( indexOfStr_WithLength )( pStr, IMPL_RTL_STRNAME( getLength )( pStr ), - pSubStr, IMPL_RTL_STRNAME( getLength )( pSubStr ) ); -} - -/* ----------------------------------------------------------------------- */ - -sal_Int32 SAL_CALL IMPL_RTL_STRNAME( indexOfStr_WithLength )( const IMPL_RTL_STRCODE* pStr, - sal_Int32 nStrLen, - const IMPL_RTL_STRCODE* pSubStr, - sal_Int32 nSubLen ) -{ - /* faster search for a single character */ - if ( nSubLen < 2 ) - { - /* an empty SubString is always not foundable */ - if ( nSubLen == 1 ) - { - IMPL_RTL_STRCODE c = *pSubStr; - const IMPL_RTL_STRCODE* pTempStr = pStr; - while ( nStrLen > 0 ) - { - if ( *pTempStr == c ) - return pTempStr-pStr; - - pTempStr++; - nStrLen--; - } - } - } - else - { - const IMPL_RTL_STRCODE* pTempStr = pStr; - while ( nStrLen > 0 ) - { - if ( *pTempStr == *pSubStr ) - { - /* Compare SubString */ - if ( nSubLen <= nStrLen ) - { - const IMPL_RTL_STRCODE* pTempStr1 = pTempStr; - const IMPL_RTL_STRCODE* pTempStr2 = pSubStr; - sal_Int32 nTempLen = nSubLen; - while ( nTempLen ) - { - if ( *pTempStr1 != *pTempStr2 ) - break; - - pTempStr1++; - pTempStr2++; - nTempLen--; - } - - if ( !nTempLen ) - return pTempStr-pStr; - } - else - break; - } - - nStrLen--; - pTempStr++; - } - } - - return -1; -} - -/* ----------------------------------------------------------------------- */ - -sal_Int32 SAL_CALL IMPL_RTL_STRNAME( lastIndexOfStr )( const IMPL_RTL_STRCODE* pStr, - const IMPL_RTL_STRCODE* pSubStr ) -{ - return IMPL_RTL_STRNAME( lastIndexOfStr_WithLength )( pStr, IMPL_RTL_STRNAME( getLength )( pStr ), - pSubStr, IMPL_RTL_STRNAME( getLength )( pSubStr ) ); -} - -/* ----------------------------------------------------------------------- */ - -sal_Int32 SAL_CALL IMPL_RTL_STRNAME( lastIndexOfStr_WithLength )( const IMPL_RTL_STRCODE* pStr, - sal_Int32 nStrLen, - const IMPL_RTL_STRCODE* pSubStr, - sal_Int32 nSubLen ) -{ - /* faster search for a single character */ - if ( nSubLen < 2 ) - { - /* an empty SubString is always not foundable */ - if ( nSubLen == 1 ) - { - IMPL_RTL_STRCODE c = *pSubStr; - pStr += nStrLen; - while ( nStrLen > 0 ) - { - nStrLen--; - pStr--; - - if ( *pStr == c ) - return nStrLen; - } - } - } - else - { - pStr += nStrLen; - nStrLen -= nSubLen; - pStr -= nSubLen; - while ( nStrLen >= 0 ) - { - const IMPL_RTL_STRCODE* pTempStr1 = pStr; - const IMPL_RTL_STRCODE* pTempStr2 = pSubStr; - sal_Int32 nTempLen = nSubLen; - while ( nTempLen ) - { - if ( *pTempStr1 != *pTempStr2 ) - break; - - pTempStr1++; - pTempStr2++; - nTempLen--; - } - - if ( !nTempLen ) - return nStrLen; - - nStrLen--; - pStr--; - } - } - - return -1; -} - -/* ----------------------------------------------------------------------- */ - -void SAL_CALL IMPL_RTL_STRNAME( replaceChar )( IMPL_RTL_STRCODE* pStr, - IMPL_RTL_STRCODE cOld, - IMPL_RTL_STRCODE cNew ) -{ - while ( *pStr ) - { - if ( *pStr == cOld ) - *pStr = cNew; - - pStr++; - } -} - -/* ----------------------------------------------------------------------- */ - -void SAL_CALL IMPL_RTL_STRNAME( replaceChar_WithLength )( IMPL_RTL_STRCODE* pStr, - sal_Int32 nLen, - IMPL_RTL_STRCODE cOld, - IMPL_RTL_STRCODE cNew ) -{ - while ( nLen > 0 ) - { - if ( *pStr == cOld ) - *pStr = cNew; - - pStr++; - nLen--; - } -} - -/* ----------------------------------------------------------------------- */ - -void SAL_CALL IMPL_RTL_STRNAME( toAsciiLowerCase )( IMPL_RTL_STRCODE* pStr ) -{ - while ( *pStr ) - { - /* Between A-Z (65-90), than to lowercase (+32) */ - if ( (*pStr >= 65) && (*pStr <= 90) ) - *pStr += 32; - - pStr++; - } -} - -/* ----------------------------------------------------------------------- */ - -void SAL_CALL IMPL_RTL_STRNAME( toAsciiLowerCase_WithLength )( IMPL_RTL_STRCODE* pStr, - sal_Int32 nLen ) -{ - while ( nLen > 0 ) - { - /* Between A-Z (65-90), than to lowercase (+32) */ - if ( (*pStr >= 65) && (*pStr <= 90) ) - *pStr += 32; - - pStr++; - nLen--; - } -} - -/* ----------------------------------------------------------------------- */ - -void SAL_CALL IMPL_RTL_STRNAME( toAsciiUpperCase )( IMPL_RTL_STRCODE* pStr ) -{ - while ( *pStr ) - { - /* Between a-z (97-122), than to uppercase (-32) */ - if ( (*pStr >= 97) && (*pStr <= 122) ) - *pStr -= 32; - - pStr++; - } -} - -/* ----------------------------------------------------------------------- */ - -void SAL_CALL IMPL_RTL_STRNAME( toAsciiUpperCase_WithLength )( IMPL_RTL_STRCODE* pStr, - sal_Int32 nLen ) -{ - while ( nLen > 0 ) - { - /* Between a-z (97-122), than to uppercase (-32) */ - if ( (*pStr >= 97) && (*pStr <= 122) ) - *pStr -= 32; - - pStr++; - nLen--; - } -} - -/* ----------------------------------------------------------------------- */ - -sal_Int32 SAL_CALL IMPL_RTL_STRNAME( trim )( IMPL_RTL_STRCODE* pStr ) -{ - return IMPL_RTL_STRNAME( trim_WithLength )( pStr, IMPL_RTL_STRNAME( getLength )( pStr ) ); -} - -/* ----------------------------------------------------------------------- */ - -sal_Int32 SAL_CALL IMPL_RTL_STRNAME( trim_WithLength )( IMPL_RTL_STRCODE* pStr, sal_Int32 nLen ) -{ - sal_Int32 nPreSpaces = 0; - sal_Int32 nPostSpaces = 0; - sal_Int32 nIndex = nLen-1; - - while ( (nPreSpaces < nLen) && rtl_ImplIsWhitespace( IMPL_RTL_USTRCODE(*(pStr+nPreSpaces)) ) ) - nPreSpaces++; - - while ( (nIndex > nPreSpaces) && rtl_ImplIsWhitespace( IMPL_RTL_USTRCODE(*(pStr+nIndex)) ) ) - { - nPostSpaces++; - nIndex--; - } - - if ( nPostSpaces ) - { - nLen -= nPostSpaces; - *(pStr+nLen) = 0; - } - - if ( nPreSpaces ) - { - IMPL_RTL_STRCODE* pNewStr = pStr+nPreSpaces; - - nLen -= nPreSpaces; - nIndex = nLen; - - while ( nIndex ) - { - *pStr = *pNewStr; - pStr++; - pNewStr++; - nIndex--; - } - *pStr = 0; - } - - return nLen; -} - -/* ----------------------------------------------------------------------- */ - -sal_Int32 SAL_CALL IMPL_RTL_STRNAME( valueOfBoolean )( IMPL_RTL_STRCODE* pStr, sal_Bool b ) -{ - if ( b ) - { - *pStr = 't'; - pStr++; - *pStr = 'r'; - pStr++; - *pStr = 'u'; - pStr++; - *pStr = 'e'; - pStr++; - *pStr = 0; - return 4; - } - else - { - *pStr = 'f'; - pStr++; - *pStr = 'a'; - pStr++; - *pStr = 'l'; - pStr++; - *pStr = 's'; - pStr++; - *pStr = 'e'; - pStr++; - *pStr = 0; - return 5; - } -} - -/* ----------------------------------------------------------------------- */ - -sal_Int32 SAL_CALL IMPL_RTL_STRNAME( valueOfChar )( IMPL_RTL_STRCODE* pStr, - IMPL_RTL_STRCODE c ) -{ - *pStr++ = c; - *pStr = 0; - return 1; -} - -/* ----------------------------------------------------------------------- */ - -sal_Int32 SAL_CALL IMPL_RTL_STRNAME( valueOfInt32 )( IMPL_RTL_STRCODE* pStr, - sal_Int32 n, - sal_Int16 nRadix ) -{ - sal_Char aBuf[RTL_STR_MAX_VALUEOFINT32]; - sal_Char* pBuf = aBuf; - sal_Int32 nLen = 0; - sal_uInt32 nValue; - - /* Radix must be valid */ - if ( (nRadix < RTL_STR_MIN_RADIX) || (nRadix > RTL_STR_MAX_RADIX) ) - nRadix = 10; - - /* is value negativ */ - if ( n < 0 ) - { - *pStr = '-'; - pStr++; - nLen++; - nValue = -n; /* FIXME this code is not portable for n == -2147483648 - (smallest negative value for sal_Int32) */ - } - else - nValue = n; - - /* create a recursive buffer with all values, except the last one */ - do - { - sal_Char nDigit = (sal_Char)(nValue % nRadix); - nValue /= nRadix; - if ( nDigit > 9 ) - *pBuf = (nDigit-10) + 'a'; - else - *pBuf = (nDigit + '0' ); - pBuf++; - } - while ( nValue > 0 ); - - /* copy the values in the right direction into the destination buffer */ - do - { - pBuf--; - *pStr = *pBuf; - pStr++; - nLen++; - } - while ( pBuf != aBuf ); - *pStr = 0; - - return nLen; -} - -/* ----------------------------------------------------------------------- */ - -sal_Int32 SAL_CALL IMPL_RTL_STRNAME( valueOfInt64 )( IMPL_RTL_STRCODE* pStr, - sal_Int64 n, - sal_Int16 nRadix ) -{ - sal_Char aBuf[RTL_STR_MAX_VALUEOFINT64]; - sal_Char* pBuf = aBuf; - sal_Int32 nLen = 0; - sal_uInt64 nValue; - - /* Radix must be valid */ - if ( (nRadix < RTL_STR_MIN_RADIX) || (nRadix > RTL_STR_MAX_RADIX) ) - nRadix = 10; - - /* is value negativ */ - if ( n < 0 ) - { - *pStr = '-'; - pStr++; - nLen++; - nValue = -n; /* FIXME this code is not portable for - n == -9223372036854775808 (smallest negative value for - sal_Int64) */ - } - else - nValue = n; - - /* create a recursive buffer with all values, except the last one */ - do - { - sal_Char nDigit = (sal_Char)(nValue % nRadix); - nValue /= nRadix; - if ( nDigit > 9 ) - *pBuf = (nDigit-10) + 'a'; - else - *pBuf = (nDigit + '0' ); - pBuf++; - } - while ( nValue > 0 ); - - /* copy the values in the right direction into the destination buffer */ - do - { - pBuf--; - *pStr = *pBuf; - pStr++; - nLen++; - } - while ( pBuf != aBuf ); - *pStr = 0; - - return nLen; -} - -/* ----------------------------------------------------------------------- */ - -sal_Bool SAL_CALL IMPL_RTL_STRNAME( toBoolean )( const IMPL_RTL_STRCODE* pStr ) -{ - if ( *pStr == '1' ) - return sal_True; - - if ( (*pStr == 'T') || (*pStr == 't') ) - { - pStr++; - if ( (*pStr == 'R') || (*pStr == 'r') ) - { - pStr++; - if ( (*pStr == 'U') || (*pStr == 'u') ) - { - pStr++; - if ( (*pStr == 'E') || (*pStr == 'e') ) - return sal_True; - } - } - } - - return sal_False; -} - -/* ----------------------------------------------------------------------- */ - -sal_Int32 SAL_CALL IMPL_RTL_STRNAME( toInt32 )( const IMPL_RTL_STRCODE* pStr, - sal_Int16 nRadix ) -{ - sal_Bool bNeg; - sal_Int16 nDigit; - sal_Int32 n = 0; - - if ( (nRadix < RTL_STR_MIN_RADIX) || (nRadix > RTL_STR_MAX_RADIX) ) - nRadix = 10; - - /* Skip whitespaces */ - while ( *pStr && rtl_ImplIsWhitespace( IMPL_RTL_USTRCODE( *pStr ) ) ) - pStr++; - - if ( *pStr == '-' ) - { - bNeg = sal_True; - pStr++; - } - else - { - if ( *pStr == '+' ) - pStr++; - bNeg = sal_False; - } - - while ( *pStr ) - { - nDigit = rtl_ImplGetDigit( IMPL_RTL_USTRCODE( *pStr ), nRadix ); - if ( nDigit < 0 ) - break; - - n *= nRadix; - n += nDigit; - - pStr++; - } - - if ( bNeg ) - return -n; - else - return n; -} - -/* ----------------------------------------------------------------------- */ - -sal_Int64 SAL_CALL IMPL_RTL_STRNAME( toInt64 )( const IMPL_RTL_STRCODE* pStr, - sal_Int16 nRadix ) -{ - sal_Bool bNeg; - sal_Int16 nDigit; - sal_Int64 n = 0; - - if ( (nRadix < RTL_STR_MIN_RADIX) || (nRadix > RTL_STR_MAX_RADIX) ) - nRadix = 10; - - /* Skip whitespaces */ - while ( *pStr && rtl_ImplIsWhitespace( IMPL_RTL_USTRCODE( *pStr ) ) ) - pStr++; - - if ( *pStr == '-' ) - { - bNeg = sal_True; - pStr++; - } - else - { - if ( *pStr == '+' ) - pStr++; - bNeg = sal_False; - } - - while ( *pStr ) - { - nDigit = rtl_ImplGetDigit( IMPL_RTL_USTRCODE( *pStr ), nRadix ); - if ( nDigit < 0 ) - break; - - n *= nRadix; - n += nDigit; - - pStr++; - } - - if ( bNeg ) - return -n; - else - return n; -} - -/* ======================================================================= */ -/* Internal String-Class help functions */ -/* ======================================================================= */ - -static IMPL_RTL_STRINGDATA* IMPL_RTL_STRINGNAME( ImplAlloc )( sal_Int32 nLen ) -{ - IMPL_RTL_STRINGDATA * pData - = (SAL_INT_CAST(sal_uInt32, nLen) - <= ((SAL_MAX_UINT32 - sizeof (IMPL_RTL_STRINGDATA)) - / sizeof (IMPL_RTL_STRCODE))) - ? (IMPL_RTL_STRINGDATA *) rtl_allocateMemory( - sizeof (IMPL_RTL_STRINGDATA) + nLen * sizeof (IMPL_RTL_STRCODE)) - : NULL; - if (pData != NULL) { - pData->refCount = 1; - pData->length = nLen; - pData->buffer[nLen] = 0; - } - return pData; -} - -/* ----------------------------------------------------------------------- */ - -static IMPL_RTL_STRCODE* IMPL_RTL_STRINGNAME( ImplNewCopy )( IMPL_RTL_STRINGDATA** ppThis, - IMPL_RTL_STRINGDATA* pStr, - sal_Int32 nCount ) -{ - IMPL_RTL_STRCODE* pDest; - const IMPL_RTL_STRCODE* pSrc; - IMPL_RTL_STRINGDATA* pData = IMPL_RTL_STRINGNAME( ImplAlloc )( pStr->length ); - OSL_ASSERT(pData != NULL); - - pDest = pData->buffer; - pSrc = pStr->buffer; - while ( nCount > 0 ) - { - *pDest = *pSrc; - pDest++; - pSrc++; - nCount--; - } - - *ppThis = pData; - return pDest; -} - -/* ======================================================================= */ -/* String-Class functions */ -/* ======================================================================= */ - -#define IMPL_RTL_AQUIRE( pThis ) \ -{ \ - if (!SAL_STRING_IS_STATIC (pThis)) \ - osl_incrementInterlockedCount( &((pThis)->refCount) ); \ -} - -/* ----------------------------------------------------------------------- */ - -void SAL_CALL IMPL_RTL_STRINGNAME( acquire )( IMPL_RTL_STRINGDATA* pThis ) -{ - IMPL_RTL_AQUIRE( pThis ); -} - -/* ----------------------------------------------------------------------- */ - -void SAL_CALL IMPL_RTL_STRINGNAME( release )( IMPL_RTL_STRINGDATA* pThis ) -{ - if (SAL_STRING_IS_STATIC (pThis)) - return; - -/* OString doesn't have an 'intern' */ -#ifdef IMPL_RTL_INTERN - if (SAL_STRING_IS_INTERN (pThis)) - { - internRelease (pThis); - return; - } -#endif - - if ( pThis->refCount == 1 || - !osl_decrementInterlockedCount( &(pThis->refCount) ) ) - { - rtl_freeMemory( pThis ); - } -} - -/* ----------------------------------------------------------------------- */ - -void SAL_CALL IMPL_RTL_STRINGNAME( new )( IMPL_RTL_STRINGDATA** ppThis ) -{ - if ( *ppThis) - IMPL_RTL_STRINGNAME( release )( *ppThis ); - - *ppThis = (IMPL_RTL_STRINGDATA*) (&IMPL_RTL_EMPTYSTRING); - IMPL_RTL_AQUIRE( *ppThis ); -} - -/* ----------------------------------------------------------------------- */ - -void SAL_CALL IMPL_RTL_STRINGNAME( new_WithLength )( IMPL_RTL_STRINGDATA** ppThis, sal_Int32 nLen ) -{ - if ( nLen <= 0 ) - IMPL_RTL_STRINGNAME( new )( ppThis ); - else - { - if ( *ppThis) - IMPL_RTL_STRINGNAME( release )( *ppThis ); - - *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( nLen ); - OSL_ASSERT(*ppThis != NULL); - (*ppThis)->length = 0; - - { - IMPL_RTL_STRCODE* pTempStr = (*ppThis)->buffer; - memset(pTempStr, 0, nLen*sizeof(IMPL_RTL_STRCODE)); - } - } -} - -/* ----------------------------------------------------------------------- */ - -void SAL_CALL IMPL_RTL_STRINGNAME( newFromString )( IMPL_RTL_STRINGDATA** ppThis, - const IMPL_RTL_STRINGDATA* pStr ) -{ - IMPL_RTL_STRINGDATA* pOrg; - - if ( !pStr->length ) - { - IMPL_RTL_STRINGNAME( new )( ppThis ); - return; - } - - pOrg = *ppThis; - *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( pStr->length ); - OSL_ASSERT(*ppThis != NULL); - rtl_str_ImplCopy( (*ppThis)->buffer, pStr->buffer, pStr->length ); - - /* must be done at least, if pStr == *ppThis */ - if ( pOrg ) - IMPL_RTL_STRINGNAME( release )( pOrg ); -} - -/* ----------------------------------------------------------------------- */ - -void SAL_CALL IMPL_RTL_STRINGNAME( newFromStr )( IMPL_RTL_STRINGDATA** ppThis, - const IMPL_RTL_STRCODE* pCharStr ) -{ - IMPL_RTL_STRCODE* pBuffer; - IMPL_RTL_STRINGDATA* pOrg; - sal_Int32 nLen; - - if ( pCharStr ) - { - const IMPL_RTL_STRCODE* pTempStr = pCharStr; - while( *pTempStr ) - pTempStr++; - nLen = pTempStr-pCharStr; - } - else - nLen = 0; - - if ( !nLen ) - { - IMPL_RTL_STRINGNAME( new )( ppThis ); - return; - } - - pOrg = *ppThis; - *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( nLen ); - OSL_ASSERT(*ppThis != NULL); - pBuffer = (*ppThis)->buffer; - do - { - *pBuffer = *pCharStr; - pBuffer++; - pCharStr++; - } - while ( *pCharStr ); - - /* must be done at least, if pCharStr == *ppThis */ - if ( pOrg ) - IMPL_RTL_STRINGNAME( release )( pOrg ); -} - -/* ----------------------------------------------------------------------- */ - -void SAL_CALL IMPL_RTL_STRINGNAME( newFromStr_WithLength )( IMPL_RTL_STRINGDATA** ppThis, - const IMPL_RTL_STRCODE* pCharStr, - sal_Int32 nLen ) -{ - IMPL_RTL_STRINGDATA* pOrg; - - if ( !pCharStr || (nLen <= 0) ) - { - IMPL_RTL_STRINGNAME( new )( ppThis ); - return; - } - - pOrg = *ppThis; - *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( nLen ); - OSL_ASSERT(*ppThis != NULL); - rtl_str_ImplCopy( (*ppThis)->buffer, pCharStr, nLen ); - - /* must be done at least, if pCharStr == *ppThis */ - if ( pOrg ) - IMPL_RTL_STRINGNAME( release )( pOrg ); -} - -/* ----------------------------------------------------------------------- */ - -void SAL_CALL IMPL_RTL_STRINGNAME( assign )( IMPL_RTL_STRINGDATA** ppThis, - IMPL_RTL_STRINGDATA* pStr ) -{ - /* must be done at first, if pStr == *ppThis */ - IMPL_RTL_AQUIRE( pStr ); - - if ( *ppThis ) - IMPL_RTL_STRINGNAME( release )( *ppThis ); - - *ppThis = pStr; -} - -/* ----------------------------------------------------------------------- */ - -sal_Int32 SAL_CALL IMPL_RTL_STRINGNAME( getLength )( const IMPL_RTL_STRINGDATA* pThis ) -{ - return pThis->length; -} - -/* ----------------------------------------------------------------------- */ - -IMPL_RTL_STRCODE* SAL_CALL IMPL_RTL_STRINGNAME( getStr )( IMPL_RTL_STRINGDATA * pThis ) -{ - return pThis->buffer; -} - -/* ----------------------------------------------------------------------- */ - -void SAL_CALL IMPL_RTL_STRINGNAME( newConcat )( IMPL_RTL_STRINGDATA** ppThis, - IMPL_RTL_STRINGDATA* pLeft, - IMPL_RTL_STRINGDATA* pRight ) -{ - IMPL_RTL_STRINGDATA* pOrg = *ppThis; - - /* Test for 0-Pointer - if not, change newReplaceStrAt! */ - if ( !pRight || !pRight->length ) - { - *ppThis = pLeft; - IMPL_RTL_AQUIRE( pLeft ); - } - else if ( !pLeft || !pLeft->length ) - { - *ppThis = pRight; - IMPL_RTL_AQUIRE( pRight ); - } - else - { - IMPL_RTL_STRINGDATA* pTempStr = IMPL_RTL_STRINGNAME( ImplAlloc )( pLeft->length + pRight->length ); - OSL_ASSERT(pTempStr != NULL); - rtl_str_ImplCopy( pTempStr->buffer, pLeft->buffer, pLeft->length ); - rtl_str_ImplCopy( pTempStr->buffer+pLeft->length, pRight->buffer, pRight->length ); - *ppThis = pTempStr; - } - - /* must be done at least, if left or right == *ppThis */ - if ( pOrg ) - IMPL_RTL_STRINGNAME( release )( pOrg ); -} - -/* ----------------------------------------------------------------------- */ - -void SAL_CALL IMPL_RTL_STRINGNAME( newReplaceStrAt )( IMPL_RTL_STRINGDATA** ppThis, - IMPL_RTL_STRINGDATA* pStr, - sal_Int32 nIndex, - sal_Int32 nCount, - IMPL_RTL_STRINGDATA* pNewSubStr ) -{ - /* Append? */ - if ( nIndex >= pStr->length ) - { - /* newConcat test, if pNewSubStr is 0 */ - IMPL_RTL_STRINGNAME( newConcat )( ppThis, pStr, pNewSubStr ); - return; - } - - /* negativ index? */ - if ( nIndex < 0 ) - { - nCount -= nIndex; - nIndex = 0; - } - - /* not more than the String length could be deleted */ - if ( nCount >= pStr->length-nIndex ) - { - nCount = pStr->length-nIndex; - - /* Assign of NewSubStr? */ - if ( !nIndex && (nCount >= pStr->length) ) - { - if ( !pNewSubStr ) - IMPL_RTL_STRINGNAME( new )( ppThis ); - else - IMPL_RTL_STRINGNAME( assign )( ppThis, pNewSubStr ); - return; - } - } - - /* Assign of Str? */ - if ( !nCount && (!pNewSubStr || !pNewSubStr->length) ) - { - IMPL_RTL_STRINGNAME( assign )( ppThis, pStr ); - return; - } - - { - IMPL_RTL_STRINGDATA* pOrg = *ppThis; - IMPL_RTL_STRCODE* pBuffer; - sal_Int32 nNewLen; - - /* Calculate length of the new string */ - nNewLen = pStr->length-nCount; - if ( pNewSubStr ) - nNewLen += pNewSubStr->length; - - /* Alloc New Buffer */ - *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( nNewLen ); - OSL_ASSERT(*ppThis != NULL); - pBuffer = (*ppThis)->buffer; - if ( nIndex ) - { - rtl_str_ImplCopy( pBuffer, pStr->buffer, nIndex ); - pBuffer += nIndex; - } - if ( pNewSubStr && pNewSubStr->length ) - { - rtl_str_ImplCopy( pBuffer, pNewSubStr->buffer, pNewSubStr->length ); - pBuffer += pNewSubStr->length; - } - rtl_str_ImplCopy( pBuffer, pStr->buffer+nIndex+nCount, pStr->length-nIndex-nCount ); - - /* must be done at least, if pStr or pNewSubStr == *ppThis */ - if ( pOrg ) - IMPL_RTL_STRINGNAME( release )( pOrg ); - } -} - -/* ----------------------------------------------------------------------- */ - -void SAL_CALL IMPL_RTL_STRINGNAME( newReplace )( IMPL_RTL_STRINGDATA** ppThis, - IMPL_RTL_STRINGDATA* pStr, - IMPL_RTL_STRCODE cOld, - IMPL_RTL_STRCODE cNew ) -{ - IMPL_RTL_STRINGDATA* pOrg = *ppThis; - int bChanged = 0; - sal_Int32 nLen = pStr->length; - const IMPL_RTL_STRCODE* pCharStr = pStr->buffer; - - while ( nLen > 0 ) - { - if ( *pCharStr == cOld ) - { - /* Copy String */ - IMPL_RTL_STRCODE* pNewCharStr = IMPL_RTL_STRINGNAME( ImplNewCopy )( ppThis, pStr, pCharStr-pStr->buffer ); - - /* replace/copy rest of the string */ - if ( pNewCharStr ) - { - *pNewCharStr = cNew; - pNewCharStr++; - pCharStr++; - nLen--; - - while ( nLen > 0 ) - { - if ( *pCharStr == cOld ) - *pNewCharStr = cNew; - else - *pNewCharStr = *pCharStr; - - pNewCharStr++; - pCharStr++; - nLen--; - } - } - - bChanged = 1; - break; - } - - pCharStr++; - nLen--; - } - - if ( !bChanged ) - { - *ppThis = pStr; - IMPL_RTL_AQUIRE( pStr ); - } - - /* must be done at least, if pStr == *ppThis */ - if ( pOrg ) - IMPL_RTL_STRINGNAME( release )( pOrg ); -} - -/* ----------------------------------------------------------------------- */ - -void SAL_CALL IMPL_RTL_STRINGNAME( newToAsciiLowerCase )( IMPL_RTL_STRINGDATA** ppThis, - IMPL_RTL_STRINGDATA* pStr ) -{ - IMPL_RTL_STRINGDATA* pOrg = *ppThis; - int bChanged = 0; - sal_Int32 nLen = pStr->length; - const IMPL_RTL_STRCODE* pCharStr = pStr->buffer; - - while ( nLen > 0 ) - { - /* Between A-Z (65-90), than to lowercase (+32) */ - if ( (*pCharStr >= 65) && (*pCharStr <= 90) ) - { - /* Copy String */ - IMPL_RTL_STRCODE* pNewCharStr = IMPL_RTL_STRINGNAME( ImplNewCopy )( ppThis, pStr, pCharStr-pStr->buffer ); - - /* replace/copy rest of the string */ - if ( pNewCharStr ) - { - /* to lowercase (+32) */ - *pNewCharStr = *pCharStr+32; - pNewCharStr++; - pCharStr++; - nLen--; - - while ( nLen > 0 ) - { - /* Between A-Z (65-90), than to lowercase (+32) */ - if ( (*pCharStr >= 65) && (*pCharStr <= 90) ) - *pNewCharStr = *pCharStr+32; - else - *pNewCharStr = *pCharStr; - - pNewCharStr++; - pCharStr++; - nLen--; - } - } - - bChanged = 1; - break; - } - - pCharStr++; - nLen--; - } - - if ( !bChanged ) - { - *ppThis = pStr; - IMPL_RTL_AQUIRE( pStr ); - } - - /* must be done at least, if pStr == *ppThis */ - if ( pOrg ) - IMPL_RTL_STRINGNAME( release )( pOrg ); -} - -/* ----------------------------------------------------------------------- */ - -void SAL_CALL IMPL_RTL_STRINGNAME( newToAsciiUpperCase )( IMPL_RTL_STRINGDATA** ppThis, - IMPL_RTL_STRINGDATA* pStr ) -{ - IMPL_RTL_STRINGDATA* pOrg = *ppThis; - int bChanged = 0; - sal_Int32 nLen = pStr->length; - const IMPL_RTL_STRCODE* pCharStr = pStr->buffer; - - while ( nLen > 0 ) - { - /* Between a-z (97-122), than to uppercase (-32) */ - if ( (*pCharStr >= 97) && (*pCharStr <= 122) ) - { - /* Copy String */ - IMPL_RTL_STRCODE* pNewCharStr = IMPL_RTL_STRINGNAME( ImplNewCopy )( ppThis, pStr, pCharStr-pStr->buffer ); - - /* replace/copy rest of the string */ - if ( pNewCharStr ) - { - /* to uppercase (-32) */ - *pNewCharStr = *pCharStr-32; - pNewCharStr++; - pCharStr++; - nLen--; - - while ( nLen > 0 ) - { - /* Between a-z (97-122), than to uppercase (-32) */ - if ( (*pCharStr >= 97) && (*pCharStr <= 122) ) - *pNewCharStr = *pCharStr-32; - else - *pNewCharStr = *pCharStr; - - pNewCharStr++; - pCharStr++; - nLen--; - } - } - - bChanged = 1; - break; - } - - pCharStr++; - nLen--; - } - - if ( !bChanged ) - { - *ppThis = pStr; - IMPL_RTL_AQUIRE( pStr ); - } - - /* must be done at least, if pStr == *ppThis */ - if ( pOrg ) - IMPL_RTL_STRINGNAME( release )( pOrg ); -} - -/* ----------------------------------------------------------------------- */ - -void SAL_CALL IMPL_RTL_STRINGNAME( newTrim )( IMPL_RTL_STRINGDATA** ppThis, - IMPL_RTL_STRINGDATA* pStr ) -{ - IMPL_RTL_STRINGDATA* pOrg = *ppThis; - const IMPL_RTL_STRCODE* pCharStr = pStr->buffer; - sal_Int32 nPreSpaces = 0; - sal_Int32 nPostSpaces = 0; - sal_Int32 nLen = pStr->length; - sal_Int32 nIndex = nLen-1; - - while ( (nPreSpaces < nLen) && rtl_ImplIsWhitespace( IMPL_RTL_USTRCODE(*(pCharStr+nPreSpaces)) ) ) - nPreSpaces++; - - while ( (nIndex > nPreSpaces) && rtl_ImplIsWhitespace( IMPL_RTL_USTRCODE(*(pCharStr+nIndex)) ) ) - { - nPostSpaces++; - nIndex--; - } - - if ( !nPreSpaces && !nPostSpaces ) - { - *ppThis = pStr; - IMPL_RTL_AQUIRE( pStr ); - } - else - { - nLen -= nPostSpaces+nPreSpaces; - *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( nLen ); - OSL_ASSERT(*ppThis != NULL); - if ( *ppThis ) - rtl_str_ImplCopy( (*ppThis)->buffer, pStr->buffer+nPreSpaces, nLen ); - } - - /* must be done at least, if pStr == *ppThis */ - if ( pOrg ) - IMPL_RTL_STRINGNAME( release )( pOrg ); -} - -/* ----------------------------------------------------------------------- */ - -sal_Int32 SAL_CALL IMPL_RTL_STRINGNAME( getToken )( IMPL_RTL_STRINGDATA** ppThis, - IMPL_RTL_STRINGDATA* pStr, - sal_Int32 nToken, - IMPL_RTL_STRCODE cTok, - sal_Int32 nIndex ) -{ - const IMPL_RTL_STRCODE* pCharStr = pStr->buffer; - const IMPL_RTL_STRCODE* pCharStrStart; - const IMPL_RTL_STRCODE* pOrgCharStr; - sal_Int32 nLen = pStr->length-nIndex; - sal_Int32 nTokCount = 0; - - // Set ppThis to an empty string and return -1 if either nToken or nIndex is - // negative: - if (nIndex < 0) { - nToken = -1; - } - - pCharStr += nIndex; - pOrgCharStr = pCharStr; - pCharStrStart = pCharStr; - while ( nLen > 0 ) - { - if ( *pCharStr == cTok ) - { - nTokCount++; - - if ( nTokCount == nToken ) - pCharStrStart = pCharStr+1; - else - { - if ( nTokCount > nToken ) - break; - } - } - - pCharStr++; - nLen--; - } - - if ( (nToken < 0) || (nTokCount < nToken) || (pCharStr == pCharStrStart) ) - { - IMPL_RTL_STRINGNAME( new )( ppThis ); - if( (nToken < 0) || (nTokCount < nToken ) ) - return -1; - else if( nLen > 0 ) - return nIndex+(pCharStr-pOrgCharStr)+1; - else return -1; - } - else - { - IMPL_RTL_STRINGNAME( newFromStr_WithLength )( ppThis, pCharStrStart, pCharStr-pCharStrStart ); - if ( nLen ) - return nIndex+(pCharStr-pOrgCharStr)+1; - else - return -1; - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/strtmpl.cxx b/sal/rtl/source/strtmpl.cxx new file mode 100644 index 000000000000..93f91331d376 --- /dev/null +++ b/sal/rtl/source/strtmpl.cxx @@ -0,0 +1,1617 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +/* ======================================================================= */ +/* Internal C-String help functions which could be used without the */ +/* String-Class */ +/* ======================================================================= */ + +#include + +/* +inline void rtl_str_ImplCopy( IMPL_RTL_STRCODE* pDest, + const IMPL_RTL_STRCODE* pSrc, + sal_Int32 nCount ) +{ + while ( nCount > 0 ) + { + *pDest = *pSrc; + pDest++; + pSrc++; + nCount--; + } +} +*/ + +#define rtl_str_ImplCopy( _pDest, _pSrc, _nCount ) \ +{ \ + IMPL_RTL_STRCODE* __mm_pDest = _pDest; \ + const IMPL_RTL_STRCODE* __mm_pSrc = _pSrc; \ + sal_Int32 __mm_nCount = _nCount; \ + while ( __mm_nCount > 0 ) \ + { \ + *__mm_pDest = *__mm_pSrc; \ + __mm_pDest++; \ + __mm_pSrc++; \ + __mm_nCount--; \ + } \ +} + +/* ======================================================================= */ +/* C-String functions which could be used without the String-Class */ +/* ======================================================================= */ + +sal_Int32 SAL_CALL IMPL_RTL_STRNAME( getLength )( const IMPL_RTL_STRCODE* pStr ) + SAL_THROW_EXTERN_C() +{ + const IMPL_RTL_STRCODE* pTempStr = pStr; + while( *pTempStr ) + pTempStr++; + return pTempStr-pStr; +} + +/* ----------------------------------------------------------------------- */ + +sal_Int32 SAL_CALL IMPL_RTL_STRNAME( compare )( const IMPL_RTL_STRCODE* pStr1, + const IMPL_RTL_STRCODE* pStr2 ) + SAL_THROW_EXTERN_C() +{ + sal_Int32 nRet; + while ( ((nRet = ((sal_Int32)(IMPL_RTL_USTRCODE(*pStr1)))- + ((sal_Int32)(IMPL_RTL_USTRCODE(*pStr2)))) == 0) && + *pStr2 ) + { + pStr1++; + pStr2++; + } + + return nRet; +} + +/* ----------------------------------------------------------------------- */ + +sal_Int32 SAL_CALL IMPL_RTL_STRNAME( compare_WithLength )( const IMPL_RTL_STRCODE* pStr1, + sal_Int32 nStr1Len, + const IMPL_RTL_STRCODE* pStr2, + sal_Int32 nStr2Len ) + SAL_THROW_EXTERN_C() +{ + sal_Int32 nRet = nStr1Len - nStr2Len; + int nCount = (nRet <= 0) ? nStr1Len : nStr2Len; + + --pStr1; + --pStr2; + while( (--nCount >= 0) && (*++pStr1 == *++pStr2) ); + + if( nCount >= 0 ) + nRet = ((sal_Int32)(IMPL_RTL_USTRCODE( *pStr1 ))) + - ((sal_Int32)(IMPL_RTL_USTRCODE( *pStr2 ))); + + return nRet; +} + +/* ----------------------------------------------------------------------- */ + +sal_Int32 SAL_CALL IMPL_RTL_STRNAME( shortenedCompare_WithLength )( const IMPL_RTL_STRCODE* pStr1, + sal_Int32 nStr1Len, + const IMPL_RTL_STRCODE* pStr2, + sal_Int32 nStr2Len, + sal_Int32 nShortenedLength ) + SAL_THROW_EXTERN_C() +{ + const IMPL_RTL_STRCODE* pStr1End = pStr1 + nStr1Len; + const IMPL_RTL_STRCODE* pStr2End = pStr2 + nStr2Len; + sal_Int32 nRet; + while ( (nShortenedLength > 0) && + (pStr1 < pStr1End) && (pStr2 < pStr2End) ) + { + nRet = ((sal_Int32)(IMPL_RTL_USTRCODE( *pStr1 )))- + ((sal_Int32)(IMPL_RTL_USTRCODE( *pStr2 ))); + if ( nRet ) + return nRet; + + nShortenedLength--; + pStr1++; + pStr2++; + } + + if ( nShortenedLength <= 0 ) + return 0; + return nStr1Len - nStr2Len; +} + +/* ----------------------------------------------------------------------- */ + +sal_Int32 SAL_CALL IMPL_RTL_STRNAME( reverseCompare_WithLength )( const IMPL_RTL_STRCODE* pStr1, + sal_Int32 nStr1Len, + const IMPL_RTL_STRCODE* pStr2, + sal_Int32 nStr2Len ) + SAL_THROW_EXTERN_C() +{ + const IMPL_RTL_STRCODE* pStr1Run = pStr1+nStr1Len; + const IMPL_RTL_STRCODE* pStr2Run = pStr2+nStr2Len; + sal_Int32 nRet; + while ( (pStr1 < pStr1Run) && (pStr2 < pStr2Run) ) + { + pStr1Run--; + pStr2Run--; + nRet = ((sal_Int32)(IMPL_RTL_USTRCODE( *pStr1Run )))- + ((sal_Int32)(IMPL_RTL_USTRCODE( *pStr2Run ))); + if ( nRet ) + return nRet; + } + + return nStr1Len - nStr2Len; +} + +/* ----------------------------------------------------------------------- */ + +sal_Int32 SAL_CALL IMPL_RTL_STRNAME( compareIgnoreAsciiCase )( const IMPL_RTL_STRCODE* pStr1, + const IMPL_RTL_STRCODE* pStr2 ) + SAL_THROW_EXTERN_C() +{ + sal_Int32 nRet; + sal_Int32 c1; + sal_Int32 c2; + do + { + /* If character between 'A' and 'Z', than convert it to lowercase */ + c1 = (sal_Int32)IMPL_RTL_USTRCODE( *pStr1 ); + c2 = (sal_Int32)IMPL_RTL_USTRCODE( *pStr2 ); + if ( (c1 >= 65) && (c1 <= 90) ) + c1 += 32; + if ( (c2 >= 65) && (c2 <= 90) ) + c2 += 32; + nRet = c1-c2; + if ( nRet != 0 ) + return nRet; + + pStr1++; + pStr2++; + } + while ( c2 ); + + return 0; +} + +/* ----------------------------------------------------------------------- */ + +sal_Int32 SAL_CALL IMPL_RTL_STRNAME( compareIgnoreAsciiCase_WithLength )( const IMPL_RTL_STRCODE* pStr1, + sal_Int32 nStr1Len, + const IMPL_RTL_STRCODE* pStr2, + sal_Int32 nStr2Len ) + SAL_THROW_EXTERN_C() +{ + const IMPL_RTL_STRCODE* pStr1End = pStr1 + nStr1Len; + const IMPL_RTL_STRCODE* pStr2End = pStr2 + nStr2Len; + sal_Int32 nRet; + sal_Int32 c1; + sal_Int32 c2; + while ( (pStr1 < pStr1End) && (pStr2 < pStr2End) ) + { + /* If character between 'A' and 'Z', than convert it to lowercase */ + c1 = (sal_Int32)IMPL_RTL_USTRCODE( *pStr1 ); + c2 = (sal_Int32)IMPL_RTL_USTRCODE( *pStr2 ); + if ( (c1 >= 65) && (c1 <= 90) ) + c1 += 32; + if ( (c2 >= 65) && (c2 <= 90) ) + c2 += 32; + nRet = c1-c2; + if ( nRet != 0 ) + return nRet; + + pStr1++; + pStr2++; + } + + return nStr1Len - nStr2Len; +} + +/* ----------------------------------------------------------------------- */ + +sal_Int32 SAL_CALL IMPL_RTL_STRNAME( shortenedCompareIgnoreAsciiCase_WithLength )( const IMPL_RTL_STRCODE* pStr1, + sal_Int32 nStr1Len, + const IMPL_RTL_STRCODE* pStr2, + sal_Int32 nStr2Len, + sal_Int32 nShortenedLength ) + SAL_THROW_EXTERN_C() +{ + const IMPL_RTL_STRCODE* pStr1End = pStr1 + nStr1Len; + const IMPL_RTL_STRCODE* pStr2End = pStr2 + nStr2Len; + sal_Int32 nRet; + sal_Int32 c1; + sal_Int32 c2; + while ( (nShortenedLength > 0) && + (pStr1 < pStr1End) && (pStr2 < pStr2End) ) + { + /* If character between 'A' and 'Z', than convert it to lowercase */ + c1 = (sal_Int32)IMPL_RTL_USTRCODE( *pStr1 ); + c2 = (sal_Int32)IMPL_RTL_USTRCODE( *pStr2 ); + if ( (c1 >= 65) && (c1 <= 90) ) + c1 += 32; + if ( (c2 >= 65) && (c2 <= 90) ) + c2 += 32; + nRet = c1-c2; + if ( nRet != 0 ) + return nRet; + + nShortenedLength--; + pStr1++; + pStr2++; + } + + if ( nShortenedLength <= 0 ) + return 0; + return nStr1Len - nStr2Len; +} + +/* ----------------------------------------------------------------------- */ + +sal_Int32 SAL_CALL IMPL_RTL_STRNAME( hashCode )( const IMPL_RTL_STRCODE* pStr ) + SAL_THROW_EXTERN_C() +{ + return IMPL_RTL_STRNAME( hashCode_WithLength )( pStr, IMPL_RTL_STRNAME( getLength )( pStr ) ); +} + +/* ----------------------------------------------------------------------- */ + +sal_Int32 SAL_CALL IMPL_RTL_STRNAME( hashCode_WithLength )( const IMPL_RTL_STRCODE* pStr, + sal_Int32 nLen ) + SAL_THROW_EXTERN_C() +{ + sal_Int32 h = nLen; + + if ( nLen < 256 ) + { + while ( nLen > 0 ) + { + h = (h*37) + IMPL_RTL_USTRCODE( *pStr ); + pStr++; + nLen--; + } + } + else + { + sal_Int32 nSkip; + const IMPL_RTL_STRCODE* pEndStr = pStr+nLen-5; + + /* only sample some characters */ + /* the first 3, some characters between, and the last 5 */ + h = (h*39) + IMPL_RTL_USTRCODE( *pStr ); + pStr++; + h = (h*39) + IMPL_RTL_USTRCODE( *pStr ); + pStr++; + h = (h*39) + IMPL_RTL_USTRCODE( *pStr ); + pStr++; + + if ( nLen < 32 ) + nSkip = nLen / 4; + else + nSkip = nLen / 8; + nLen -= 8; + while ( nLen > 0 ) + { + h = (h*39) + IMPL_RTL_USTRCODE( *pStr ); + pStr += nSkip; + nLen -= nSkip; + } + + h = (h*39) + IMPL_RTL_USTRCODE( *pEndStr ); + pEndStr++; + h = (h*39) + IMPL_RTL_USTRCODE( *pEndStr ); + pEndStr++; + h = (h*39) + IMPL_RTL_USTRCODE( *pEndStr ); + pEndStr++; + h = (h*39) + IMPL_RTL_USTRCODE( *pEndStr ); + pEndStr++; + h = (h*39) + IMPL_RTL_USTRCODE( *pEndStr ); + } + + return h; +} + +/* ----------------------------------------------------------------------- */ + +sal_Int32 SAL_CALL IMPL_RTL_STRNAME( indexOfChar )( const IMPL_RTL_STRCODE* pStr, + IMPL_RTL_STRCODE c ) + SAL_THROW_EXTERN_C() +{ + const IMPL_RTL_STRCODE* pTempStr = pStr; + while ( *pTempStr ) + { + if ( *pTempStr == c ) + return pTempStr-pStr; + + pTempStr++; + } + + return -1; +} + +/* ----------------------------------------------------------------------- */ + +sal_Int32 SAL_CALL IMPL_RTL_STRNAME( indexOfChar_WithLength )( const IMPL_RTL_STRCODE* pStr, + sal_Int32 nLen, + IMPL_RTL_STRCODE c ) + SAL_THROW_EXTERN_C() +{ + const IMPL_RTL_STRCODE* pTempStr = pStr; + while ( nLen > 0 ) + { + if ( *pTempStr == c ) + return pTempStr-pStr; + + pTempStr++; + nLen--; + } + + return -1; +} + +/* ----------------------------------------------------------------------- */ + +sal_Int32 SAL_CALL IMPL_RTL_STRNAME( lastIndexOfChar )( const IMPL_RTL_STRCODE* pStr, + IMPL_RTL_STRCODE c ) + SAL_THROW_EXTERN_C() +{ + return IMPL_RTL_STRNAME( lastIndexOfChar_WithLength )( pStr, IMPL_RTL_STRNAME( getLength )( pStr ), c ); +} + +/* ----------------------------------------------------------------------- */ + +sal_Int32 SAL_CALL IMPL_RTL_STRNAME( lastIndexOfChar_WithLength )( const IMPL_RTL_STRCODE* pStr, + sal_Int32 nLen, + IMPL_RTL_STRCODE c ) + SAL_THROW_EXTERN_C() +{ + pStr += nLen; + while ( nLen > 0 ) + { + nLen--; + pStr--; + + if ( *pStr == c ) + return nLen; + } + + return -1; +} + +/* ----------------------------------------------------------------------- */ + +sal_Int32 SAL_CALL IMPL_RTL_STRNAME( indexOfStr )( const IMPL_RTL_STRCODE* pStr, + const IMPL_RTL_STRCODE* pSubStr ) + SAL_THROW_EXTERN_C() +{ + return IMPL_RTL_STRNAME( indexOfStr_WithLength )( pStr, IMPL_RTL_STRNAME( getLength )( pStr ), + pSubStr, IMPL_RTL_STRNAME( getLength )( pSubStr ) ); +} + +/* ----------------------------------------------------------------------- */ + +sal_Int32 SAL_CALL IMPL_RTL_STRNAME( indexOfStr_WithLength )( const IMPL_RTL_STRCODE* pStr, + sal_Int32 nStrLen, + const IMPL_RTL_STRCODE* pSubStr, + sal_Int32 nSubLen ) + SAL_THROW_EXTERN_C() +{ + /* faster search for a single character */ + if ( nSubLen < 2 ) + { + /* an empty SubString is always not foundable */ + if ( nSubLen == 1 ) + { + IMPL_RTL_STRCODE c = *pSubStr; + const IMPL_RTL_STRCODE* pTempStr = pStr; + while ( nStrLen > 0 ) + { + if ( *pTempStr == c ) + return pTempStr-pStr; + + pTempStr++; + nStrLen--; + } + } + } + else + { + const IMPL_RTL_STRCODE* pTempStr = pStr; + while ( nStrLen > 0 ) + { + if ( *pTempStr == *pSubStr ) + { + /* Compare SubString */ + if ( nSubLen <= nStrLen ) + { + const IMPL_RTL_STRCODE* pTempStr1 = pTempStr; + const IMPL_RTL_STRCODE* pTempStr2 = pSubStr; + sal_Int32 nTempLen = nSubLen; + while ( nTempLen ) + { + if ( *pTempStr1 != *pTempStr2 ) + break; + + pTempStr1++; + pTempStr2++; + nTempLen--; + } + + if ( !nTempLen ) + return pTempStr-pStr; + } + else + break; + } + + nStrLen--; + pTempStr++; + } + } + + return -1; +} + +/* ----------------------------------------------------------------------- */ + +sal_Int32 SAL_CALL IMPL_RTL_STRNAME( lastIndexOfStr )( const IMPL_RTL_STRCODE* pStr, + const IMPL_RTL_STRCODE* pSubStr ) + SAL_THROW_EXTERN_C() +{ + return IMPL_RTL_STRNAME( lastIndexOfStr_WithLength )( pStr, IMPL_RTL_STRNAME( getLength )( pStr ), + pSubStr, IMPL_RTL_STRNAME( getLength )( pSubStr ) ); +} + +/* ----------------------------------------------------------------------- */ + +sal_Int32 SAL_CALL IMPL_RTL_STRNAME( lastIndexOfStr_WithLength )( const IMPL_RTL_STRCODE* pStr, + sal_Int32 nStrLen, + const IMPL_RTL_STRCODE* pSubStr, + sal_Int32 nSubLen ) + SAL_THROW_EXTERN_C() +{ + /* faster search for a single character */ + if ( nSubLen < 2 ) + { + /* an empty SubString is always not foundable */ + if ( nSubLen == 1 ) + { + IMPL_RTL_STRCODE c = *pSubStr; + pStr += nStrLen; + while ( nStrLen > 0 ) + { + nStrLen--; + pStr--; + + if ( *pStr == c ) + return nStrLen; + } + } + } + else + { + pStr += nStrLen; + nStrLen -= nSubLen; + pStr -= nSubLen; + while ( nStrLen >= 0 ) + { + const IMPL_RTL_STRCODE* pTempStr1 = pStr; + const IMPL_RTL_STRCODE* pTempStr2 = pSubStr; + sal_Int32 nTempLen = nSubLen; + while ( nTempLen ) + { + if ( *pTempStr1 != *pTempStr2 ) + break; + + pTempStr1++; + pTempStr2++; + nTempLen--; + } + + if ( !nTempLen ) + return nStrLen; + + nStrLen--; + pStr--; + } + } + + return -1; +} + +/* ----------------------------------------------------------------------- */ + +void SAL_CALL IMPL_RTL_STRNAME( replaceChar )( IMPL_RTL_STRCODE* pStr, + IMPL_RTL_STRCODE cOld, + IMPL_RTL_STRCODE cNew ) + SAL_THROW_EXTERN_C() +{ + while ( *pStr ) + { + if ( *pStr == cOld ) + *pStr = cNew; + + pStr++; + } +} + +/* ----------------------------------------------------------------------- */ + +void SAL_CALL IMPL_RTL_STRNAME( replaceChar_WithLength )( IMPL_RTL_STRCODE* pStr, + sal_Int32 nLen, + IMPL_RTL_STRCODE cOld, + IMPL_RTL_STRCODE cNew ) + SAL_THROW_EXTERN_C() +{ + while ( nLen > 0 ) + { + if ( *pStr == cOld ) + *pStr = cNew; + + pStr++; + nLen--; + } +} + +/* ----------------------------------------------------------------------- */ + +void SAL_CALL IMPL_RTL_STRNAME( toAsciiLowerCase )( IMPL_RTL_STRCODE* pStr ) + SAL_THROW_EXTERN_C() +{ + while ( *pStr ) + { + /* Between A-Z (65-90), than to lowercase (+32) */ + if ( (*pStr >= 65) && (*pStr <= 90) ) + *pStr += 32; + + pStr++; + } +} + +/* ----------------------------------------------------------------------- */ + +void SAL_CALL IMPL_RTL_STRNAME( toAsciiLowerCase_WithLength )( IMPL_RTL_STRCODE* pStr, + sal_Int32 nLen ) + SAL_THROW_EXTERN_C() +{ + while ( nLen > 0 ) + { + /* Between A-Z (65-90), than to lowercase (+32) */ + if ( (*pStr >= 65) && (*pStr <= 90) ) + *pStr += 32; + + pStr++; + nLen--; + } +} + +/* ----------------------------------------------------------------------- */ + +void SAL_CALL IMPL_RTL_STRNAME( toAsciiUpperCase )( IMPL_RTL_STRCODE* pStr ) + SAL_THROW_EXTERN_C() +{ + while ( *pStr ) + { + /* Between a-z (97-122), than to uppercase (-32) */ + if ( (*pStr >= 97) && (*pStr <= 122) ) + *pStr -= 32; + + pStr++; + } +} + +/* ----------------------------------------------------------------------- */ + +void SAL_CALL IMPL_RTL_STRNAME( toAsciiUpperCase_WithLength )( IMPL_RTL_STRCODE* pStr, + sal_Int32 nLen ) + SAL_THROW_EXTERN_C() +{ + while ( nLen > 0 ) + { + /* Between a-z (97-122), than to uppercase (-32) */ + if ( (*pStr >= 97) && (*pStr <= 122) ) + *pStr -= 32; + + pStr++; + nLen--; + } +} + +/* ----------------------------------------------------------------------- */ + +sal_Int32 SAL_CALL IMPL_RTL_STRNAME( trim )( IMPL_RTL_STRCODE* pStr ) + SAL_THROW_EXTERN_C() +{ + return IMPL_RTL_STRNAME( trim_WithLength )( pStr, IMPL_RTL_STRNAME( getLength )( pStr ) ); +} + +/* ----------------------------------------------------------------------- */ + +sal_Int32 SAL_CALL IMPL_RTL_STRNAME( trim_WithLength )( IMPL_RTL_STRCODE* pStr, sal_Int32 nLen ) + SAL_THROW_EXTERN_C() +{ + sal_Int32 nPreSpaces = 0; + sal_Int32 nPostSpaces = 0; + sal_Int32 nIndex = nLen-1; + + while ( (nPreSpaces < nLen) && rtl_ImplIsWhitespace( IMPL_RTL_USTRCODE(*(pStr+nPreSpaces)) ) ) + nPreSpaces++; + + while ( (nIndex > nPreSpaces) && rtl_ImplIsWhitespace( IMPL_RTL_USTRCODE(*(pStr+nIndex)) ) ) + { + nPostSpaces++; + nIndex--; + } + + if ( nPostSpaces ) + { + nLen -= nPostSpaces; + *(pStr+nLen) = 0; + } + + if ( nPreSpaces ) + { + IMPL_RTL_STRCODE* pNewStr = pStr+nPreSpaces; + + nLen -= nPreSpaces; + nIndex = nLen; + + while ( nIndex ) + { + *pStr = *pNewStr; + pStr++; + pNewStr++; + nIndex--; + } + *pStr = 0; + } + + return nLen; +} + +/* ----------------------------------------------------------------------- */ + +sal_Int32 SAL_CALL IMPL_RTL_STRNAME( valueOfBoolean )( IMPL_RTL_STRCODE* pStr, sal_Bool b ) + SAL_THROW_EXTERN_C() +{ + if ( b ) + { + *pStr = 't'; + pStr++; + *pStr = 'r'; + pStr++; + *pStr = 'u'; + pStr++; + *pStr = 'e'; + pStr++; + *pStr = 0; + return 4; + } + else + { + *pStr = 'f'; + pStr++; + *pStr = 'a'; + pStr++; + *pStr = 'l'; + pStr++; + *pStr = 's'; + pStr++; + *pStr = 'e'; + pStr++; + *pStr = 0; + return 5; + } +} + +/* ----------------------------------------------------------------------- */ + +sal_Int32 SAL_CALL IMPL_RTL_STRNAME( valueOfChar )( IMPL_RTL_STRCODE* pStr, + IMPL_RTL_STRCODE c ) + SAL_THROW_EXTERN_C() +{ + *pStr++ = c; + *pStr = 0; + return 1; +} + +/* ----------------------------------------------------------------------- */ + +sal_Int32 SAL_CALL IMPL_RTL_STRNAME( valueOfInt32 )( IMPL_RTL_STRCODE* pStr, + sal_Int32 n, + sal_Int16 nRadix ) + SAL_THROW_EXTERN_C() +{ + sal_Char aBuf[RTL_STR_MAX_VALUEOFINT32]; + sal_Char* pBuf = aBuf; + sal_Int32 nLen = 0; + sal_uInt32 nValue; + + /* Radix must be valid */ + if ( (nRadix < RTL_STR_MIN_RADIX) || (nRadix > RTL_STR_MAX_RADIX) ) + nRadix = 10; + + /* is value negativ */ + if ( n < 0 ) + { + *pStr = '-'; + pStr++; + nLen++; + nValue = -n; /* FIXME this code is not portable for n == -2147483648 + (smallest negative value for sal_Int32) */ + } + else + nValue = n; + + /* create a recursive buffer with all values, except the last one */ + do + { + sal_Char nDigit = (sal_Char)(nValue % nRadix); + nValue /= nRadix; + if ( nDigit > 9 ) + *pBuf = (nDigit-10) + 'a'; + else + *pBuf = (nDigit + '0' ); + pBuf++; + } + while ( nValue > 0 ); + + /* copy the values in the right direction into the destination buffer */ + do + { + pBuf--; + *pStr = *pBuf; + pStr++; + nLen++; + } + while ( pBuf != aBuf ); + *pStr = 0; + + return nLen; +} + +/* ----------------------------------------------------------------------- */ + +sal_Int32 SAL_CALL IMPL_RTL_STRNAME( valueOfInt64 )( IMPL_RTL_STRCODE* pStr, + sal_Int64 n, + sal_Int16 nRadix ) + SAL_THROW_EXTERN_C() +{ + sal_Char aBuf[RTL_STR_MAX_VALUEOFINT64]; + sal_Char* pBuf = aBuf; + sal_Int32 nLen = 0; + sal_uInt64 nValue; + + /* Radix must be valid */ + if ( (nRadix < RTL_STR_MIN_RADIX) || (nRadix > RTL_STR_MAX_RADIX) ) + nRadix = 10; + + /* is value negativ */ + if ( n < 0 ) + { + *pStr = '-'; + pStr++; + nLen++; + nValue = -n; /* FIXME this code is not portable for + n == -9223372036854775808 (smallest negative value for + sal_Int64) */ + } + else + nValue = n; + + /* create a recursive buffer with all values, except the last one */ + do + { + sal_Char nDigit = (sal_Char)(nValue % nRadix); + nValue /= nRadix; + if ( nDigit > 9 ) + *pBuf = (nDigit-10) + 'a'; + else + *pBuf = (nDigit + '0' ); + pBuf++; + } + while ( nValue > 0 ); + + /* copy the values in the right direction into the destination buffer */ + do + { + pBuf--; + *pStr = *pBuf; + pStr++; + nLen++; + } + while ( pBuf != aBuf ); + *pStr = 0; + + return nLen; +} + +/* ----------------------------------------------------------------------- */ + +sal_Bool SAL_CALL IMPL_RTL_STRNAME( toBoolean )( const IMPL_RTL_STRCODE* pStr ) + SAL_THROW_EXTERN_C() +{ + if ( *pStr == '1' ) + return sal_True; + + if ( (*pStr == 'T') || (*pStr == 't') ) + { + pStr++; + if ( (*pStr == 'R') || (*pStr == 'r') ) + { + pStr++; + if ( (*pStr == 'U') || (*pStr == 'u') ) + { + pStr++; + if ( (*pStr == 'E') || (*pStr == 'e') ) + return sal_True; + } + } + } + + return sal_False; +} + +/* ----------------------------------------------------------------------- */ + +sal_Int32 SAL_CALL IMPL_RTL_STRNAME( toInt32 )( const IMPL_RTL_STRCODE* pStr, + sal_Int16 nRadix ) + SAL_THROW_EXTERN_C() +{ + sal_Bool bNeg; + sal_Int16 nDigit; + sal_Int32 n = 0; + + if ( (nRadix < RTL_STR_MIN_RADIX) || (nRadix > RTL_STR_MAX_RADIX) ) + nRadix = 10; + + /* Skip whitespaces */ + while ( *pStr && rtl_ImplIsWhitespace( IMPL_RTL_USTRCODE( *pStr ) ) ) + pStr++; + + if ( *pStr == '-' ) + { + bNeg = sal_True; + pStr++; + } + else + { + if ( *pStr == '+' ) + pStr++; + bNeg = sal_False; + } + + while ( *pStr ) + { + nDigit = rtl_ImplGetDigit( IMPL_RTL_USTRCODE( *pStr ), nRadix ); + if ( nDigit < 0 ) + break; + + n *= nRadix; + n += nDigit; + + pStr++; + } + + if ( bNeg ) + return -n; + else + return n; +} + +/* ----------------------------------------------------------------------- */ + +sal_Int64 SAL_CALL IMPL_RTL_STRNAME( toInt64 )( const IMPL_RTL_STRCODE* pStr, + sal_Int16 nRadix ) + SAL_THROW_EXTERN_C() +{ + sal_Bool bNeg; + sal_Int16 nDigit; + sal_Int64 n = 0; + + if ( (nRadix < RTL_STR_MIN_RADIX) || (nRadix > RTL_STR_MAX_RADIX) ) + nRadix = 10; + + /* Skip whitespaces */ + while ( *pStr && rtl_ImplIsWhitespace( IMPL_RTL_USTRCODE( *pStr ) ) ) + pStr++; + + if ( *pStr == '-' ) + { + bNeg = sal_True; + pStr++; + } + else + { + if ( *pStr == '+' ) + pStr++; + bNeg = sal_False; + } + + while ( *pStr ) + { + nDigit = rtl_ImplGetDigit( IMPL_RTL_USTRCODE( *pStr ), nRadix ); + if ( nDigit < 0 ) + break; + + n *= nRadix; + n += nDigit; + + pStr++; + } + + if ( bNeg ) + return -n; + else + return n; +} + +/* ======================================================================= */ +/* Internal String-Class help functions */ +/* ======================================================================= */ + +static IMPL_RTL_STRINGDATA* IMPL_RTL_STRINGNAME( ImplAlloc )( sal_Int32 nLen ) +{ + IMPL_RTL_STRINGDATA * pData + = (sal::static_int_cast< sal_uInt32 >(nLen) + <= ((SAL_MAX_UINT32 - sizeof (IMPL_RTL_STRINGDATA)) + / sizeof (IMPL_RTL_STRCODE))) + ? (IMPL_RTL_STRINGDATA *) rtl_allocateMemory( + sizeof (IMPL_RTL_STRINGDATA) + nLen * sizeof (IMPL_RTL_STRCODE)) + : NULL; + if (pData != NULL) { + pData->refCount = 1; + pData->length = nLen; + pData->buffer[nLen] = 0; + } + return pData; +} + +/* ----------------------------------------------------------------------- */ + +static IMPL_RTL_STRCODE* IMPL_RTL_STRINGNAME( ImplNewCopy )( IMPL_RTL_STRINGDATA** ppThis, + IMPL_RTL_STRINGDATA* pStr, + sal_Int32 nCount ) +{ + IMPL_RTL_STRCODE* pDest; + const IMPL_RTL_STRCODE* pSrc; + IMPL_RTL_STRINGDATA* pData = IMPL_RTL_STRINGNAME( ImplAlloc )( pStr->length ); + OSL_ASSERT(pData != NULL); + + pDest = pData->buffer; + pSrc = pStr->buffer; + while ( nCount > 0 ) + { + *pDest = *pSrc; + pDest++; + pSrc++; + nCount--; + } + + *ppThis = pData; + return pDest; +} + +/* ======================================================================= */ +/* String-Class functions */ +/* ======================================================================= */ + +#define IMPL_RTL_AQUIRE( pThis ) \ +{ \ + if (!SAL_STRING_IS_STATIC (pThis)) \ + osl_incrementInterlockedCount( &((pThis)->refCount) ); \ +} + +/* ----------------------------------------------------------------------- */ + +void SAL_CALL IMPL_RTL_STRINGNAME( acquire )( IMPL_RTL_STRINGDATA* pThis ) + SAL_THROW_EXTERN_C() +{ + IMPL_RTL_AQUIRE( pThis ); +} + +/* ----------------------------------------------------------------------- */ + +void SAL_CALL IMPL_RTL_STRINGNAME( release )( IMPL_RTL_STRINGDATA* pThis ) + SAL_THROW_EXTERN_C() +{ + if (SAL_STRING_IS_STATIC (pThis)) + return; + +/* OString doesn't have an 'intern' */ +#ifdef IMPL_RTL_INTERN + if (SAL_STRING_IS_INTERN (pThis)) + { + internRelease (pThis); + return; + } +#endif + + if ( pThis->refCount == 1 || + !osl_decrementInterlockedCount( &(pThis->refCount) ) ) + { + rtl_freeMemory( pThis ); + } +} + +/* ----------------------------------------------------------------------- */ + +void SAL_CALL IMPL_RTL_STRINGNAME( new )( IMPL_RTL_STRINGDATA** ppThis ) + SAL_THROW_EXTERN_C() +{ + if ( *ppThis) + IMPL_RTL_STRINGNAME( release )( *ppThis ); + + *ppThis = (IMPL_RTL_STRINGDATA*) (&IMPL_RTL_EMPTYSTRING); + IMPL_RTL_AQUIRE( *ppThis ); +} + +/* ----------------------------------------------------------------------- */ + +void SAL_CALL IMPL_RTL_STRINGNAME( new_WithLength )( IMPL_RTL_STRINGDATA** ppThis, sal_Int32 nLen ) + SAL_THROW_EXTERN_C() +{ + if ( nLen <= 0 ) + IMPL_RTL_STRINGNAME( new )( ppThis ); + else + { + if ( *ppThis) + IMPL_RTL_STRINGNAME( release )( *ppThis ); + + *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( nLen ); + OSL_ASSERT(*ppThis != NULL); + (*ppThis)->length = 0; + + { + IMPL_RTL_STRCODE* pTempStr = (*ppThis)->buffer; + memset(pTempStr, 0, nLen*sizeof(IMPL_RTL_STRCODE)); + } + } +} + +/* ----------------------------------------------------------------------- */ + +void SAL_CALL IMPL_RTL_STRINGNAME( newFromString )( IMPL_RTL_STRINGDATA** ppThis, + const IMPL_RTL_STRINGDATA* pStr ) + SAL_THROW_EXTERN_C() +{ + IMPL_RTL_STRINGDATA* pOrg; + + if ( !pStr->length ) + { + IMPL_RTL_STRINGNAME( new )( ppThis ); + return; + } + + pOrg = *ppThis; + *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( pStr->length ); + OSL_ASSERT(*ppThis != NULL); + rtl_str_ImplCopy( (*ppThis)->buffer, pStr->buffer, pStr->length ); + + /* must be done at least, if pStr == *ppThis */ + if ( pOrg ) + IMPL_RTL_STRINGNAME( release )( pOrg ); +} + +/* ----------------------------------------------------------------------- */ + +void SAL_CALL IMPL_RTL_STRINGNAME( newFromStr )( IMPL_RTL_STRINGDATA** ppThis, + const IMPL_RTL_STRCODE* pCharStr ) + SAL_THROW_EXTERN_C() +{ + IMPL_RTL_STRCODE* pBuffer; + IMPL_RTL_STRINGDATA* pOrg; + sal_Int32 nLen; + + if ( pCharStr ) + { + const IMPL_RTL_STRCODE* pTempStr = pCharStr; + while( *pTempStr ) + pTempStr++; + nLen = pTempStr-pCharStr; + } + else + nLen = 0; + + if ( !nLen ) + { + IMPL_RTL_STRINGNAME( new )( ppThis ); + return; + } + + pOrg = *ppThis; + *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( nLen ); + OSL_ASSERT(*ppThis != NULL); + pBuffer = (*ppThis)->buffer; + do + { + *pBuffer = *pCharStr; + pBuffer++; + pCharStr++; + } + while ( *pCharStr ); + + /* must be done at least, if pCharStr == *ppThis */ + if ( pOrg ) + IMPL_RTL_STRINGNAME( release )( pOrg ); +} + +/* ----------------------------------------------------------------------- */ + +void SAL_CALL IMPL_RTL_STRINGNAME( newFromStr_WithLength )( IMPL_RTL_STRINGDATA** ppThis, + const IMPL_RTL_STRCODE* pCharStr, + sal_Int32 nLen ) + SAL_THROW_EXTERN_C() +{ + IMPL_RTL_STRINGDATA* pOrg; + + if ( !pCharStr || (nLen <= 0) ) + { + IMPL_RTL_STRINGNAME( new )( ppThis ); + return; + } + + pOrg = *ppThis; + *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( nLen ); + OSL_ASSERT(*ppThis != NULL); + rtl_str_ImplCopy( (*ppThis)->buffer, pCharStr, nLen ); + + /* must be done at least, if pCharStr == *ppThis */ + if ( pOrg ) + IMPL_RTL_STRINGNAME( release )( pOrg ); +} + +/* ----------------------------------------------------------------------- */ + +void SAL_CALL IMPL_RTL_STRINGNAME( assign )( IMPL_RTL_STRINGDATA** ppThis, + IMPL_RTL_STRINGDATA* pStr ) + SAL_THROW_EXTERN_C() +{ + /* must be done at first, if pStr == *ppThis */ + IMPL_RTL_AQUIRE( pStr ); + + if ( *ppThis ) + IMPL_RTL_STRINGNAME( release )( *ppThis ); + + *ppThis = pStr; +} + +/* ----------------------------------------------------------------------- */ + +sal_Int32 SAL_CALL IMPL_RTL_STRINGNAME( getLength )( const IMPL_RTL_STRINGDATA* pThis ) + SAL_THROW_EXTERN_C() +{ + return pThis->length; +} + +/* ----------------------------------------------------------------------- */ + +IMPL_RTL_STRCODE* SAL_CALL IMPL_RTL_STRINGNAME( getStr )( IMPL_RTL_STRINGDATA * pThis ) + SAL_THROW_EXTERN_C() +{ + return pThis->buffer; +} + +/* ----------------------------------------------------------------------- */ + +void SAL_CALL IMPL_RTL_STRINGNAME( newConcat )( IMPL_RTL_STRINGDATA** ppThis, + IMPL_RTL_STRINGDATA* pLeft, + IMPL_RTL_STRINGDATA* pRight ) + SAL_THROW_EXTERN_C() +{ + IMPL_RTL_STRINGDATA* pOrg = *ppThis; + + /* Test for 0-Pointer - if not, change newReplaceStrAt! */ + if ( !pRight || !pRight->length ) + { + *ppThis = pLeft; + IMPL_RTL_AQUIRE( pLeft ); + } + else if ( !pLeft || !pLeft->length ) + { + *ppThis = pRight; + IMPL_RTL_AQUIRE( pRight ); + } + else + { + IMPL_RTL_STRINGDATA* pTempStr = IMPL_RTL_STRINGNAME( ImplAlloc )( pLeft->length + pRight->length ); + OSL_ASSERT(pTempStr != NULL); + rtl_str_ImplCopy( pTempStr->buffer, pLeft->buffer, pLeft->length ); + rtl_str_ImplCopy( pTempStr->buffer+pLeft->length, pRight->buffer, pRight->length ); + *ppThis = pTempStr; + } + + /* must be done at least, if left or right == *ppThis */ + if ( pOrg ) + IMPL_RTL_STRINGNAME( release )( pOrg ); +} + +/* ----------------------------------------------------------------------- */ + +void SAL_CALL IMPL_RTL_STRINGNAME( newReplaceStrAt )( IMPL_RTL_STRINGDATA** ppThis, + IMPL_RTL_STRINGDATA* pStr, + sal_Int32 nIndex, + sal_Int32 nCount, + IMPL_RTL_STRINGDATA* pNewSubStr ) + SAL_THROW_EXTERN_C() +{ + /* Append? */ + if ( nIndex >= pStr->length ) + { + /* newConcat test, if pNewSubStr is 0 */ + IMPL_RTL_STRINGNAME( newConcat )( ppThis, pStr, pNewSubStr ); + return; + } + + /* negativ index? */ + if ( nIndex < 0 ) + { + nCount -= nIndex; + nIndex = 0; + } + + /* not more than the String length could be deleted */ + if ( nCount >= pStr->length-nIndex ) + { + nCount = pStr->length-nIndex; + + /* Assign of NewSubStr? */ + if ( !nIndex && (nCount >= pStr->length) ) + { + if ( !pNewSubStr ) + IMPL_RTL_STRINGNAME( new )( ppThis ); + else + IMPL_RTL_STRINGNAME( assign )( ppThis, pNewSubStr ); + return; + } + } + + /* Assign of Str? */ + if ( !nCount && (!pNewSubStr || !pNewSubStr->length) ) + { + IMPL_RTL_STRINGNAME( assign )( ppThis, pStr ); + return; + } + + { + IMPL_RTL_STRINGDATA* pOrg = *ppThis; + IMPL_RTL_STRCODE* pBuffer; + sal_Int32 nNewLen; + + /* Calculate length of the new string */ + nNewLen = pStr->length-nCount; + if ( pNewSubStr ) + nNewLen += pNewSubStr->length; + + /* Alloc New Buffer */ + *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( nNewLen ); + OSL_ASSERT(*ppThis != NULL); + pBuffer = (*ppThis)->buffer; + if ( nIndex ) + { + rtl_str_ImplCopy( pBuffer, pStr->buffer, nIndex ); + pBuffer += nIndex; + } + if ( pNewSubStr && pNewSubStr->length ) + { + rtl_str_ImplCopy( pBuffer, pNewSubStr->buffer, pNewSubStr->length ); + pBuffer += pNewSubStr->length; + } + rtl_str_ImplCopy( pBuffer, pStr->buffer+nIndex+nCount, pStr->length-nIndex-nCount ); + + /* must be done at least, if pStr or pNewSubStr == *ppThis */ + if ( pOrg ) + IMPL_RTL_STRINGNAME( release )( pOrg ); + } +} + +/* ----------------------------------------------------------------------- */ + +void SAL_CALL IMPL_RTL_STRINGNAME( newReplace )( IMPL_RTL_STRINGDATA** ppThis, + IMPL_RTL_STRINGDATA* pStr, + IMPL_RTL_STRCODE cOld, + IMPL_RTL_STRCODE cNew ) + SAL_THROW_EXTERN_C() +{ + IMPL_RTL_STRINGDATA* pOrg = *ppThis; + int bChanged = 0; + sal_Int32 nLen = pStr->length; + const IMPL_RTL_STRCODE* pCharStr = pStr->buffer; + + while ( nLen > 0 ) + { + if ( *pCharStr == cOld ) + { + /* Copy String */ + IMPL_RTL_STRCODE* pNewCharStr = IMPL_RTL_STRINGNAME( ImplNewCopy )( ppThis, pStr, pCharStr-pStr->buffer ); + + /* replace/copy rest of the string */ + if ( pNewCharStr ) + { + *pNewCharStr = cNew; + pNewCharStr++; + pCharStr++; + nLen--; + + while ( nLen > 0 ) + { + if ( *pCharStr == cOld ) + *pNewCharStr = cNew; + else + *pNewCharStr = *pCharStr; + + pNewCharStr++; + pCharStr++; + nLen--; + } + } + + bChanged = 1; + break; + } + + pCharStr++; + nLen--; + } + + if ( !bChanged ) + { + *ppThis = pStr; + IMPL_RTL_AQUIRE( pStr ); + } + + /* must be done at least, if pStr == *ppThis */ + if ( pOrg ) + IMPL_RTL_STRINGNAME( release )( pOrg ); +} + +/* ----------------------------------------------------------------------- */ + +void SAL_CALL IMPL_RTL_STRINGNAME( newToAsciiLowerCase )( IMPL_RTL_STRINGDATA** ppThis, + IMPL_RTL_STRINGDATA* pStr ) + SAL_THROW_EXTERN_C() +{ + IMPL_RTL_STRINGDATA* pOrg = *ppThis; + int bChanged = 0; + sal_Int32 nLen = pStr->length; + const IMPL_RTL_STRCODE* pCharStr = pStr->buffer; + + while ( nLen > 0 ) + { + /* Between A-Z (65-90), than to lowercase (+32) */ + if ( (*pCharStr >= 65) && (*pCharStr <= 90) ) + { + /* Copy String */ + IMPL_RTL_STRCODE* pNewCharStr = IMPL_RTL_STRINGNAME( ImplNewCopy )( ppThis, pStr, pCharStr-pStr->buffer ); + + /* replace/copy rest of the string */ + if ( pNewCharStr ) + { + /* to lowercase (+32) */ + *pNewCharStr = *pCharStr+32; + pNewCharStr++; + pCharStr++; + nLen--; + + while ( nLen > 0 ) + { + /* Between A-Z (65-90), than to lowercase (+32) */ + if ( (*pCharStr >= 65) && (*pCharStr <= 90) ) + *pNewCharStr = *pCharStr+32; + else + *pNewCharStr = *pCharStr; + + pNewCharStr++; + pCharStr++; + nLen--; + } + } + + bChanged = 1; + break; + } + + pCharStr++; + nLen--; + } + + if ( !bChanged ) + { + *ppThis = pStr; + IMPL_RTL_AQUIRE( pStr ); + } + + /* must be done at least, if pStr == *ppThis */ + if ( pOrg ) + IMPL_RTL_STRINGNAME( release )( pOrg ); +} + +/* ----------------------------------------------------------------------- */ + +void SAL_CALL IMPL_RTL_STRINGNAME( newToAsciiUpperCase )( IMPL_RTL_STRINGDATA** ppThis, + IMPL_RTL_STRINGDATA* pStr ) + SAL_THROW_EXTERN_C() +{ + IMPL_RTL_STRINGDATA* pOrg = *ppThis; + int bChanged = 0; + sal_Int32 nLen = pStr->length; + const IMPL_RTL_STRCODE* pCharStr = pStr->buffer; + + while ( nLen > 0 ) + { + /* Between a-z (97-122), than to uppercase (-32) */ + if ( (*pCharStr >= 97) && (*pCharStr <= 122) ) + { + /* Copy String */ + IMPL_RTL_STRCODE* pNewCharStr = IMPL_RTL_STRINGNAME( ImplNewCopy )( ppThis, pStr, pCharStr-pStr->buffer ); + + /* replace/copy rest of the string */ + if ( pNewCharStr ) + { + /* to uppercase (-32) */ + *pNewCharStr = *pCharStr-32; + pNewCharStr++; + pCharStr++; + nLen--; + + while ( nLen > 0 ) + { + /* Between a-z (97-122), than to uppercase (-32) */ + if ( (*pCharStr >= 97) && (*pCharStr <= 122) ) + *pNewCharStr = *pCharStr-32; + else + *pNewCharStr = *pCharStr; + + pNewCharStr++; + pCharStr++; + nLen--; + } + } + + bChanged = 1; + break; + } + + pCharStr++; + nLen--; + } + + if ( !bChanged ) + { + *ppThis = pStr; + IMPL_RTL_AQUIRE( pStr ); + } + + /* must be done at least, if pStr == *ppThis */ + if ( pOrg ) + IMPL_RTL_STRINGNAME( release )( pOrg ); +} + +/* ----------------------------------------------------------------------- */ + +void SAL_CALL IMPL_RTL_STRINGNAME( newTrim )( IMPL_RTL_STRINGDATA** ppThis, + IMPL_RTL_STRINGDATA* pStr ) + SAL_THROW_EXTERN_C() +{ + IMPL_RTL_STRINGDATA* pOrg = *ppThis; + const IMPL_RTL_STRCODE* pCharStr = pStr->buffer; + sal_Int32 nPreSpaces = 0; + sal_Int32 nPostSpaces = 0; + sal_Int32 nLen = pStr->length; + sal_Int32 nIndex = nLen-1; + + while ( (nPreSpaces < nLen) && rtl_ImplIsWhitespace( IMPL_RTL_USTRCODE(*(pCharStr+nPreSpaces)) ) ) + nPreSpaces++; + + while ( (nIndex > nPreSpaces) && rtl_ImplIsWhitespace( IMPL_RTL_USTRCODE(*(pCharStr+nIndex)) ) ) + { + nPostSpaces++; + nIndex--; + } + + if ( !nPreSpaces && !nPostSpaces ) + { + *ppThis = pStr; + IMPL_RTL_AQUIRE( pStr ); + } + else + { + nLen -= nPostSpaces+nPreSpaces; + *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( nLen ); + OSL_ASSERT(*ppThis != NULL); + if ( *ppThis ) + rtl_str_ImplCopy( (*ppThis)->buffer, pStr->buffer+nPreSpaces, nLen ); + } + + /* must be done at least, if pStr == *ppThis */ + if ( pOrg ) + IMPL_RTL_STRINGNAME( release )( pOrg ); +} + +/* ----------------------------------------------------------------------- */ + +sal_Int32 SAL_CALL IMPL_RTL_STRINGNAME( getToken )( IMPL_RTL_STRINGDATA** ppThis, + IMPL_RTL_STRINGDATA* pStr, + sal_Int32 nToken, + IMPL_RTL_STRCODE cTok, + sal_Int32 nIndex ) + SAL_THROW_EXTERN_C() +{ + const IMPL_RTL_STRCODE* pCharStr = pStr->buffer; + const IMPL_RTL_STRCODE* pCharStrStart; + const IMPL_RTL_STRCODE* pOrgCharStr; + sal_Int32 nLen = pStr->length-nIndex; + sal_Int32 nTokCount = 0; + + // Set ppThis to an empty string and return -1 if either nToken or nIndex is + // negative: + if (nIndex < 0) { + nToken = -1; + } + + pCharStr += nIndex; + pOrgCharStr = pCharStr; + pCharStrStart = pCharStr; + while ( nLen > 0 ) + { + if ( *pCharStr == cTok ) + { + nTokCount++; + + if ( nTokCount == nToken ) + pCharStrStart = pCharStr+1; + else + { + if ( nTokCount > nToken ) + break; + } + } + + pCharStr++; + nLen--; + } + + if ( (nToken < 0) || (nTokCount < nToken) || (pCharStr == pCharStrStart) ) + { + IMPL_RTL_STRINGNAME( new )( ppThis ); + if( (nToken < 0) || (nTokCount < nToken ) ) + return -1; + else if( nLen > 0 ) + return nIndex+(pCharStr-pOrgCharStr)+1; + else return -1; + } + else + { + IMPL_RTL_STRINGNAME( newFromStr_WithLength )( ppThis, pCharStrStart, pCharStr-pCharStrStart ); + if ( nLen ) + return nIndex+(pCharStr-pOrgCharStr)+1; + else + return -1; + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/surrogates.h b/sal/rtl/source/surrogates.h deleted file mode 100644 index c686e181047a..000000000000 --- a/sal/rtl/source/surrogates.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef INCLUDED_SAL_RTL_SOURCE_SURROGATES_H -#define INCLUDED_SAL_RTL_SOURCE_SURROGATES_H - -#include "sal/config.h" - -#define SAL_RTL_FIRST_HIGH_SURROGATE 0xD800 -#define SAL_RTL_LAST_HIGH_SURROGATE 0xDBFF -#define SAL_RTL_FIRST_LOW_SURROGATE 0xDC00 -#define SAL_RTL_LAST_LOW_SURROGATE 0xDFFF - -#define SAL_RTL_IS_HIGH_SURROGATE(utf16) \ - ((utf16) >= SAL_RTL_FIRST_HIGH_SURROGATE && \ - (utf16) <= SAL_RTL_LAST_HIGH_SURROGATE) - -#define SAL_RTL_IS_LOW_SURROGATE(utf16) \ - ((utf16) >= SAL_RTL_FIRST_LOW_SURROGATE && \ - (utf16) <= SAL_RTL_LAST_LOW_SURROGATE) - -#define SAL_RTL_COMBINE_SURROGATES(high, low) \ - ((((high) - SAL_RTL_FIRST_HIGH_SURROGATE) << 10) + \ - ((low) - SAL_RTL_FIRST_LOW_SURROGATE) + 0x10000) - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/surrogates.hxx b/sal/rtl/source/surrogates.hxx new file mode 100644 index 000000000000..42d4355ade00 --- /dev/null +++ b/sal/rtl/source/surrogates.hxx @@ -0,0 +1,53 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_SAL_RTL_SOURCE_SURROGATES_HXX +#define INCLUDED_SAL_RTL_SOURCE_SURROGATES_HXX + +#include "sal/config.h" + +#define SAL_RTL_FIRST_HIGH_SURROGATE 0xD800 +#define SAL_RTL_LAST_HIGH_SURROGATE 0xDBFF +#define SAL_RTL_FIRST_LOW_SURROGATE 0xDC00 +#define SAL_RTL_LAST_LOW_SURROGATE 0xDFFF + +#define SAL_RTL_IS_HIGH_SURROGATE(utf16) \ + ((utf16) >= SAL_RTL_FIRST_HIGH_SURROGATE && \ + (utf16) <= SAL_RTL_LAST_HIGH_SURROGATE) + +#define SAL_RTL_IS_LOW_SURROGATE(utf16) \ + ((utf16) >= SAL_RTL_FIRST_LOW_SURROGATE && \ + (utf16) <= SAL_RTL_LAST_LOW_SURROGATE) + +#define SAL_RTL_COMBINE_SURROGATES(high, low) \ + ((((high) - SAL_RTL_FIRST_HIGH_SURROGATE) << 10) + \ + ((low) - SAL_RTL_FIRST_LOW_SURROGATE) + 0x10000) + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/uri.cxx b/sal/rtl/source/uri.cxx index 928614eb32ce..191d319c6474 100644 --- a/sal/rtl/source/uri.cxx +++ b/sal/rtl/source/uri.cxx @@ -31,7 +31,7 @@ #include "rtl/uri.h" -#include "surrogates.h" +#include "surrogates.hxx" #include "osl/diagnose.h" #include "rtl/strbuf.hxx" diff --git a/sal/rtl/source/ustrbuf.c b/sal/rtl/source/ustrbuf.c deleted file mode 100644 index 374913ae78b8..000000000000 --- a/sal/rtl/source/ustrbuf.c +++ /dev/null @@ -1,239 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include - -#ifndef _RTL_STRING_HXX_ -#include -#endif -#include - -/* -#include -*/ - - - -/************************************************************************* - * rtl_uStringbuffer_newFromStr_WithLength - */ -void SAL_CALL rtl_uStringbuffer_newFromStr_WithLength( rtl_uString ** newStr, - const sal_Unicode * value, - sal_Int32 count) -{ - if (!value) - { - rtl_uString_new_WithLength( newStr, 16 ); - return; - } - - rtl_uString_new_WithLength( newStr, count + 16 ); - (*newStr)->length = count; - rtl_copyMemory( (*newStr)->buffer, value, count * sizeof(sal_Unicode)); - return; -} - -/************************************************************************* - * rtl_uStringbuffer_newFromStringBuffer - */ -sal_Int32 SAL_CALL rtl_uStringbuffer_newFromStringBuffer( rtl_uString ** newStr, - sal_Int32 capacity, - rtl_uString * oldStr ) -{ - sal_Int32 newCapacity = capacity; - - if (newCapacity < oldStr->length) - newCapacity = oldStr->length; - - rtl_uString_new_WithLength( newStr, newCapacity ); - - if (oldStr->length > 0) { - (*newStr)->length = oldStr->length; - rtl_copyMemory( (*newStr)->buffer, oldStr->buffer, oldStr->length * sizeof(sal_Unicode)); - } - return newCapacity; -} - -/************************************************************************* - * rtl_uStringbuffer_ensureCapacity - */ -void SAL_CALL rtl_uStringbuffer_ensureCapacity - (rtl_uString ** This, sal_Int32* capacity, sal_Int32 minimumCapacity) -{ - if (minimumCapacity > *capacity) - { - rtl_uString * pTmp = *This; - rtl_uString * pNew = NULL; - *capacity = ((*This)->length + 1) * 2; - if (minimumCapacity > *capacity) - /* still lower, set to the minimum capacity */ - *capacity = minimumCapacity; - - rtl_uString_new_WithLength(&pNew, *capacity); - pNew->length = (*This)->length; - *This = pNew; - - rtl_copyMemory( (*This)->buffer, pTmp->buffer, pTmp->length * sizeof(sal_Unicode) ); - rtl_uString_release( pTmp ); - } -} - -/************************************************************************* - * rtl_uStringbuffer_insert - */ -void SAL_CALL rtl_uStringbuffer_insert( rtl_uString ** This, - sal_Int32 * capacity, - sal_Int32 offset, - const sal_Unicode * str, - sal_Int32 len) -{ - sal_Int32 nOldLen; - sal_Unicode * pBuf; - sal_Int32 n; - if( len != 0 ) - { - if (*capacity < (*This)->length + len) - rtl_uStringbuffer_ensureCapacity( This, capacity, (*This)->length + len ); - - /* - if( len == 1 ) - This->buffer - */ - nOldLen = (*This)->length; - pBuf = (*This)->buffer; - - /* copy the tail */ - n = (nOldLen - offset); - if( n == 1 ) - /* optimized for 1 character */ - pBuf[offset + len] = pBuf[offset]; - else if( n > 1 ) - rtl_moveMemory( pBuf + offset + len, pBuf + offset, n * sizeof(sal_Unicode) ); - - /* insert the new characters */ - if( len == 1 ) - /* optimized for 1 character */ - pBuf[offset] = *str; - else if( len > 1 ) - rtl_copyMemory( pBuf + offset, str, len * sizeof(sal_Unicode) ); - (*This)->length = nOldLen + len; - pBuf[ nOldLen + len ] = 0; - } -} - -void rtl_uStringbuffer_insertUtf32( - rtl_uString ** pThis, sal_Int32 * capacity, sal_Int32 offset, sal_uInt32 c) -{ - sal_Unicode buf[2]; - sal_Int32 len; - OSL_ASSERT(c <= 0x10FFFF && !(c >= 0xD800 && c <= 0xDFFF)); - if (c <= 0xFFFF) { - buf[0] = (sal_Unicode) c; - len = 1; - } else { - c -= 0x10000; - buf[0] = (sal_Unicode) ((c >> 10) | 0xD800); - buf[1] = (sal_Unicode) ((c & 0x3FF) | 0xDC00); - len = 2; - } - rtl_uStringbuffer_insert(pThis, capacity, offset, buf, len); -} - -/************************************************************************* - * rtl_uStringbuffer_insert_ascii - */ -void SAL_CALL rtl_uStringbuffer_insert_ascii( /*inout*/rtl_uString ** This, - /*inout*/sal_Int32 * capacity, - sal_Int32 offset, - const sal_Char * str, - sal_Int32 len) -{ - sal_Int32 nOldLen; - sal_Unicode * pBuf; - sal_Int32 n; - if( len != 0 ) - { - if (*capacity < (*This)->length + len) - rtl_uStringbuffer_ensureCapacity( This, capacity, (*This)->length + len ); - - nOldLen = (*This)->length; - pBuf = (*This)->buffer; - - /* copy the tail */ - n = (nOldLen - offset); - if( n == 1 ) - /* optimized for 1 character */ - pBuf[offset + len] = pBuf[offset]; - else if( n > 1 ) - rtl_moveMemory( pBuf + offset + len, pBuf + offset, n * sizeof(sal_Unicode) ); - - /* insert the new characters */ - for( n = 0; n < len; n++ ) - { - /* Check ASCII range */ - OSL_ENSURE( (*str & 0x80) == 0, "Found ASCII char > 127"); - - pBuf[offset + n] = (sal_Unicode)*(str++); - } - - (*This)->length = nOldLen + len; - pBuf[ nOldLen + len ] = 0; - } -} - -/************************************************************************* - * rtl_uStringbuffer_remove - */ -void SAL_CALL rtl_uStringbuffer_remove( rtl_uString ** This, - sal_Int32 start, - sal_Int32 len ) -{ - sal_Int32 nTailLen; - sal_Unicode * pBuf; - - if (len > (*This)->length - start) - len = (*This)->length - start; - - //remove nothing - if (!len) - return; - - pBuf = (*This)->buffer; - nTailLen = (*This)->length - ( start + len ); - - if (nTailLen) - { - /* move the tail */ - rtl_moveMemory(pBuf + start, pBuf + start + len, nTailLen * sizeof(sal_Unicode)); - } - - (*This)->length-=len; - pBuf[ (*This)->length ] = 0; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/ustrbuf.cxx b/sal/rtl/source/ustrbuf.cxx new file mode 100644 index 000000000000..82b2fcb43d1b --- /dev/null +++ b/sal/rtl/source/ustrbuf.cxx @@ -0,0 +1,240 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include + +#ifndef _RTL_STRING_HXX_ +#include +#endif +#include + +/* +#include +*/ + + + +/************************************************************************* + * rtl_uStringbuffer_newFromStr_WithLength + */ +void SAL_CALL rtl_uStringbuffer_newFromStr_WithLength( rtl_uString ** newStr, + const sal_Unicode * value, + sal_Int32 count) +{ + if (!value) + { + rtl_uString_new_WithLength( newStr, 16 ); + return; + } + + rtl_uString_new_WithLength( newStr, count + 16 ); + (*newStr)->length = count; + rtl_copyMemory( (*newStr)->buffer, value, count * sizeof(sal_Unicode)); + return; +} + +/************************************************************************* + * rtl_uStringbuffer_newFromStringBuffer + */ +sal_Int32 SAL_CALL rtl_uStringbuffer_newFromStringBuffer( rtl_uString ** newStr, + sal_Int32 capacity, + rtl_uString * oldStr ) +{ + sal_Int32 newCapacity = capacity; + + if (newCapacity < oldStr->length) + newCapacity = oldStr->length; + + rtl_uString_new_WithLength( newStr, newCapacity ); + + if (oldStr->length > 0) { + (*newStr)->length = oldStr->length; + rtl_copyMemory( (*newStr)->buffer, oldStr->buffer, oldStr->length * sizeof(sal_Unicode)); + } + return newCapacity; +} + +/************************************************************************* + * rtl_uStringbuffer_ensureCapacity + */ +void SAL_CALL rtl_uStringbuffer_ensureCapacity + (rtl_uString ** This, sal_Int32* capacity, sal_Int32 minimumCapacity) +{ + if (minimumCapacity > *capacity) + { + rtl_uString * pTmp = *This; + rtl_uString * pNew = NULL; + *capacity = ((*This)->length + 1) * 2; + if (minimumCapacity > *capacity) + /* still lower, set to the minimum capacity */ + *capacity = minimumCapacity; + + rtl_uString_new_WithLength(&pNew, *capacity); + pNew->length = (*This)->length; + *This = pNew; + + rtl_copyMemory( (*This)->buffer, pTmp->buffer, pTmp->length * sizeof(sal_Unicode) ); + rtl_uString_release( pTmp ); + } +} + +/************************************************************************* + * rtl_uStringbuffer_insert + */ +void SAL_CALL rtl_uStringbuffer_insert( rtl_uString ** This, + sal_Int32 * capacity, + sal_Int32 offset, + const sal_Unicode * str, + sal_Int32 len) +{ + sal_Int32 nOldLen; + sal_Unicode * pBuf; + sal_Int32 n; + if( len != 0 ) + { + if (*capacity < (*This)->length + len) + rtl_uStringbuffer_ensureCapacity( This, capacity, (*This)->length + len ); + + /* + if( len == 1 ) + This->buffer + */ + nOldLen = (*This)->length; + pBuf = (*This)->buffer; + + /* copy the tail */ + n = (nOldLen - offset); + if( n == 1 ) + /* optimized for 1 character */ + pBuf[offset + len] = pBuf[offset]; + else if( n > 1 ) + rtl_moveMemory( pBuf + offset + len, pBuf + offset, n * sizeof(sal_Unicode) ); + + /* insert the new characters */ + if( len == 1 ) + /* optimized for 1 character */ + pBuf[offset] = *str; + else if( len > 1 ) + rtl_copyMemory( pBuf + offset, str, len * sizeof(sal_Unicode) ); + (*This)->length = nOldLen + len; + pBuf[ nOldLen + len ] = 0; + } +} + +void rtl_uStringbuffer_insertUtf32( + rtl_uString ** pThis, sal_Int32 * capacity, sal_Int32 offset, sal_uInt32 c) + SAL_THROW_EXTERN_C() +{ + sal_Unicode buf[2]; + sal_Int32 len; + OSL_ASSERT(c <= 0x10FFFF && !(c >= 0xD800 && c <= 0xDFFF)); + if (c <= 0xFFFF) { + buf[0] = (sal_Unicode) c; + len = 1; + } else { + c -= 0x10000; + buf[0] = (sal_Unicode) ((c >> 10) | 0xD800); + buf[1] = (sal_Unicode) ((c & 0x3FF) | 0xDC00); + len = 2; + } + rtl_uStringbuffer_insert(pThis, capacity, offset, buf, len); +} + +/************************************************************************* + * rtl_uStringbuffer_insert_ascii + */ +void SAL_CALL rtl_uStringbuffer_insert_ascii( /*inout*/rtl_uString ** This, + /*inout*/sal_Int32 * capacity, + sal_Int32 offset, + const sal_Char * str, + sal_Int32 len) +{ + sal_Int32 nOldLen; + sal_Unicode * pBuf; + sal_Int32 n; + if( len != 0 ) + { + if (*capacity < (*This)->length + len) + rtl_uStringbuffer_ensureCapacity( This, capacity, (*This)->length + len ); + + nOldLen = (*This)->length; + pBuf = (*This)->buffer; + + /* copy the tail */ + n = (nOldLen - offset); + if( n == 1 ) + /* optimized for 1 character */ + pBuf[offset + len] = pBuf[offset]; + else if( n > 1 ) + rtl_moveMemory( pBuf + offset + len, pBuf + offset, n * sizeof(sal_Unicode) ); + + /* insert the new characters */ + for( n = 0; n < len; n++ ) + { + /* Check ASCII range */ + OSL_ENSURE( (*str & 0x80) == 0, "Found ASCII char > 127"); + + pBuf[offset + n] = (sal_Unicode)*(str++); + } + + (*This)->length = nOldLen + len; + pBuf[ nOldLen + len ] = 0; + } +} + +/************************************************************************* + * rtl_uStringbuffer_remove + */ +void SAL_CALL rtl_uStringbuffer_remove( rtl_uString ** This, + sal_Int32 start, + sal_Int32 len ) +{ + sal_Int32 nTailLen; + sal_Unicode * pBuf; + + if (len > (*This)->length - start) + len = (*This)->length - start; + + //remove nothing + if (!len) + return; + + pBuf = (*This)->buffer; + nTailLen = (*This)->length - ( start + len ); + + if (nTailLen) + { + /* move the tail */ + rtl_moveMemory(pBuf + start, pBuf + start + len, nTailLen * sizeof(sal_Unicode)); + } + + (*This)->length-=len; + pBuf[ (*This)->length ] = 0; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/ustring.c b/sal/rtl/source/ustring.c deleted file mode 100644 index feb597547ae1..000000000000 --- a/sal/rtl/source/ustring.c +++ /dev/null @@ -1,983 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#if defined(_MSC_VER) && (_MSC_VER >= 1400) -#pragma warning(disable:4738) // storing 32-bit float result in memory, possible loss of performance -#endif - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "hash.h" -#include "strimp.h" -#include "surrogates.h" -#include - -#include "rtl/math.h" -#include "rtl/tencinfo.h" - -/* ======================================================================= */ - -/* static data to be referenced by all empty strings - * the refCount is predefined to 1 and must never become 0 ! - */ -static rtl_uString const aImplEmpty_rtl_uString = -{ - (sal_Int32) (SAL_STRING_INTERN_FLAG|SAL_STRING_STATIC_FLAG|1), /*sal_Int32 refCount; */ - 0, /*sal_Int32 length; */ - { 0 } /*sal_Unicode buffer[1];*/ -}; - -/* ======================================================================= */ - -#define IMPL_RTL_STRCODE sal_Unicode -#define IMPL_RTL_USTRCODE( c ) (c) -#define IMPL_RTL_STRNAME( n ) rtl_ustr_ ## n - -#define IMPL_RTL_STRINGNAME( n ) rtl_uString_ ## n -#define IMPL_RTL_STRINGDATA rtl_uString -#define IMPL_RTL_EMPTYSTRING aImplEmpty_rtl_uString -#define IMPL_RTL_INTERN -static void internRelease (rtl_uString *pThis); - -/* ======================================================================= */ - -/* Include String/UString template code */ - -#include "strtmpl.c" - -sal_Int32 rtl_ustr_indexOfAscii_WithLength( - sal_Unicode const * str, sal_Int32 len, - char const * subStr, sal_Int32 subLen) -{ - if (subLen > 0 && subLen <= len) { - sal_Int32 i; - for (i = 0; i <= len - subLen; ++i) { - if (rtl_ustr_asciil_reverseEquals_WithLength( - str + i, subStr, subLen)) - { - return i; - } - } - } - return -1; -} - -sal_Int32 rtl_ustr_lastIndexOfAscii_WithLength( - sal_Unicode const * str, sal_Int32 len, - char const * subStr, sal_Int32 subLen) -{ - if (subLen > 0 && subLen <= len) { - sal_Int32 i; - for (i = len - subLen; i >= 0; --i) { - if (rtl_ustr_asciil_reverseEquals_WithLength( - str + i, subStr, subLen)) - { - return i; - } - } - } - return -1; -} - -sal_Int32 SAL_CALL rtl_ustr_valueOfFloat(sal_Unicode * pStr, float f) -{ - rtl_uString * pResult = NULL; - sal_Int32 nLen; - rtl_math_doubleToUString( - &pResult, 0, 0, f, rtl_math_StringFormat_G, - RTL_USTR_MAX_VALUEOFFLOAT - RTL_CONSTASCII_LENGTH("-x.E-xxx"), '.', 0, - 0, sal_True); - nLen = pResult->length; - OSL_ASSERT(nLen < RTL_USTR_MAX_VALUEOFFLOAT); - rtl_copyMemory(pStr, pResult->buffer, (nLen + 1) * sizeof(sal_Unicode)); - rtl_uString_release(pResult); - return nLen; -} - -sal_Int32 SAL_CALL rtl_ustr_valueOfDouble(sal_Unicode * pStr, double d) -{ - rtl_uString * pResult = NULL; - sal_Int32 nLen; - rtl_math_doubleToUString( - &pResult, 0, 0, d, rtl_math_StringFormat_G, - RTL_USTR_MAX_VALUEOFDOUBLE - RTL_CONSTASCII_LENGTH("-x.E-xxx"), '.', 0, - 0, sal_True); - nLen = pResult->length; - OSL_ASSERT(nLen < RTL_USTR_MAX_VALUEOFDOUBLE); - rtl_copyMemory(pStr, pResult->buffer, (nLen + 1) * sizeof(sal_Unicode)); - rtl_uString_release(pResult); - return nLen; -} - -float SAL_CALL rtl_ustr_toFloat(sal_Unicode const * pStr) -{ - return (float) rtl_math_uStringToDouble(pStr, - pStr + rtl_ustr_getLength(pStr), - '.', 0, 0, 0); -} - -double SAL_CALL rtl_ustr_toDouble(sal_Unicode const * pStr) -{ - return rtl_math_uStringToDouble(pStr, pStr + rtl_ustr_getLength(pStr), '.', - 0, 0, 0); -} - -/* ======================================================================= */ - -sal_Int32 SAL_CALL rtl_ustr_ascii_compare( const sal_Unicode* pStr1, - const sal_Char* pStr2 ) -{ - sal_Int32 nRet; - while ( ((nRet = ((sal_Int32)(*pStr1))- - ((sal_Int32)((unsigned char)(*pStr2)))) == 0) && - *pStr2 ) - { - pStr1++; - pStr2++; - } - - return nRet; -} - -/* ----------------------------------------------------------------------- */ - -sal_Int32 SAL_CALL rtl_ustr_ascii_compare_WithLength( const sal_Unicode* pStr1, - sal_Int32 nStr1Len, - const sal_Char* pStr2 ) -{ - sal_Int32 nRet = 0; - while( ((nRet = (nStr1Len ? (sal_Int32)(*pStr1) : 0)- - ((sal_Int32)((unsigned char)(*pStr2)))) == 0) && - nStr1Len && *pStr2 ) - { - pStr1++; - pStr2++; - nStr1Len--; - } - - return nRet; -} - -/* ----------------------------------------------------------------------- */ - -sal_Int32 SAL_CALL rtl_ustr_ascii_shortenedCompare_WithLength( const sal_Unicode* pStr1, - sal_Int32 nStr1Len, - const sal_Char* pStr2, - sal_Int32 nShortenedLength ) -{ - const sal_Unicode* pStr1End = pStr1 + nStr1Len; - sal_Int32 nRet; - while ( (nShortenedLength > 0) && - (pStr1 < pStr1End) && *pStr2 ) - { - /* Check ASCII range */ - OSL_ENSURE( (*pStr2 & 0x80) == 0, "Found ASCII char > 127"); - - nRet = ((sal_Int32)*pStr1)- - ((sal_Int32)(unsigned char)*pStr2); - if ( nRet != 0 ) - return nRet; - - nShortenedLength--; - pStr1++; - pStr2++; - } - - if ( nShortenedLength <= 0 ) - return 0; - - if ( *pStr2 ) - { - OSL_ENSURE( pStr1 == pStr1End, "pStr1 == pStr1End failed" ); - // first is a substring of the second string => less (negative value) - nRet = -1; - } - else - { - // greater or equal - nRet = pStr1End - pStr1; - } - - return nRet; -} - -/* ----------------------------------------------------------------------- */ - -sal_Int32 SAL_CALL rtl_ustr_asciil_reverseCompare_WithLength( const sal_Unicode* pStr1, - sal_Int32 nStr1Len, - const sal_Char* pStr2, - sal_Int32 nStr2Len ) -{ - const sal_Unicode* pStr1Run = pStr1+nStr1Len; - const sal_Char* pStr2Run = pStr2+nStr2Len; - sal_Int32 nRet; - while ( (pStr1 < pStr1Run) && (pStr2 < pStr2Run) ) - { - pStr1Run--; - pStr2Run--; - nRet = ((sal_Int32)*pStr1Run)-((sal_Int32)*pStr2Run); - if ( nRet ) - return nRet; - } - - return nStr1Len - nStr2Len; -} - -/* ----------------------------------------------------------------------- */ - -sal_Bool SAL_CALL rtl_ustr_asciil_reverseEquals_WithLength( const sal_Unicode* pStr1, - const sal_Char* pStr2, - sal_Int32 nStrLen ) -{ - const sal_Unicode* pStr1Run = pStr1+nStrLen; - const sal_Char* pStr2Run = pStr2+nStrLen; - while ( pStr1 < pStr1Run ) - { - pStr1Run--; - pStr2Run--; - if( *pStr1Run != (sal_Unicode)*pStr2Run ) - return sal_False; - } - - return sal_True; -} - -/* ----------------------------------------------------------------------- */ - -sal_Int32 SAL_CALL rtl_ustr_ascii_compareIgnoreAsciiCase( const sal_Unicode* pStr1, - const sal_Char* pStr2 ) -{ - sal_Int32 nRet; - sal_Int32 c1; - sal_Int32 c2; - do - { - /* If character between 'A' and 'Z', than convert it to lowercase */ - c1 = (sal_Int32)*pStr1; - c2 = (sal_Int32)((unsigned char)*pStr2); - if ( (c1 >= 65) && (c1 <= 90) ) - c1 += 32; - if ( (c2 >= 65) && (c2 <= 90) ) - c2 += 32; - nRet = c1-c2; - if ( nRet != 0 ) - return nRet; - - pStr1++; - pStr2++; - } - while ( c2 ); - - return 0; -} - -/* ----------------------------------------------------------------------- */ - -sal_Int32 SAL_CALL rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( const sal_Unicode* pStr1, - sal_Int32 nStr1Len, - const sal_Char* pStr2 ) -{ - sal_Int32 nRet; - sal_Int32 c1; - sal_Int32 c2; - do - { - if ( !nStr1Len ) - return *pStr2 == '\0' ? 0 : -1; - - /* If character between 'A' and 'Z', than convert it to lowercase */ - c1 = (sal_Int32)*pStr1; - c2 = (sal_Int32)((unsigned char)*pStr2); - if ( (c1 >= 65) && (c1 <= 90) ) - c1 += 32; - if ( (c2 >= 65) && (c2 <= 90) ) - c2 += 32; - nRet = c1-c2; - if ( nRet != 0 ) - return nRet; - - pStr1++; - pStr2++; - nStr1Len--; - } - while( c2 ); - - return 0; -} - -sal_Int32 rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths( - sal_Unicode const * first, sal_Int32 firstLen, - char const * second, sal_Int32 secondLen) -{ - sal_Int32 i; - sal_Int32 len = firstLen < secondLen ? firstLen : secondLen; - for (i = 0; i < len; ++i) { - sal_Int32 c1 = *first++; - sal_Int32 c2 = (unsigned char) *second++; - sal_Int32 d; - if (c1 >= 65 && c1 <= 90) { - c1 += 32; - } - if (c2 >= 65 && c2 <= 90) { - c2 += 32; - } - d = c1 - c2; - if (d != 0) { - return d; - } - } - return firstLen - secondLen; -} - -/* ----------------------------------------------------------------------- */ - -sal_Int32 SAL_CALL rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( const sal_Unicode* pStr1, - sal_Int32 nStr1Len, - const sal_Char* pStr2, - sal_Int32 nShortenedLength ) -{ - const sal_Unicode* pStr1End = pStr1 + nStr1Len; - sal_Int32 nRet; - sal_Int32 c1; - sal_Int32 c2; - while ( (nShortenedLength > 0) && - (pStr1 < pStr1End) && *pStr2 ) - { - /* Check ASCII range */ - OSL_ENSURE( (*pStr2 & 0x80) == 0, "Found ASCII char > 127"); - - /* If character between 'A' and 'Z', than convert it to lowercase */ - c1 = (sal_Int32)*pStr1; - c2 = (sal_Int32)((unsigned char)*pStr2); - if ( (c1 >= 65) && (c1 <= 90) ) - c1 += 32; - if ( (c2 >= 65) && (c2 <= 90) ) - c2 += 32; - nRet = c1-c2; - if ( nRet != 0 ) - return nRet; - - nShortenedLength--; - pStr1++; - pStr2++; - } - - if ( nShortenedLength <= 0 ) - return 0; - - if ( *pStr2 ) - { - OSL_ENSURE( pStr1 == pStr1End, "pStr1 == pStr1End failed" ); - // first is a substring of the second string => less (negative value) - nRet = -1; - } - else - { - // greater or equal - nRet = pStr1End - pStr1; - } - - return nRet; -} - -/* ----------------------------------------------------------------------- */ - -void SAL_CALL rtl_uString_newFromAscii( rtl_uString** ppThis, - const sal_Char* pCharStr ) -{ - sal_Int32 nLen; - - if ( pCharStr ) - { - const sal_Char* pTempStr = pCharStr; - while( *pTempStr ) - pTempStr++; - nLen = pTempStr-pCharStr; - } - else - nLen = 0; - - if ( !nLen ) - { - IMPL_RTL_STRINGNAME( new )( ppThis ); - return; - } - - if ( *ppThis ) - IMPL_RTL_STRINGNAME( release )( *ppThis ); - - *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( nLen ); - OSL_ASSERT(*ppThis != NULL); - if ( (*ppThis) ) - { - IMPL_RTL_STRCODE* pBuffer = (*ppThis)->buffer; - do - { - /* Check ASCII range */ - OSL_ENSURE( ((unsigned char)*pCharStr) <= 127, - "rtl_uString_newFromAscii() - Found ASCII char > 127" ); - - *pBuffer = *pCharStr; - pBuffer++; - pCharStr++; - } - while ( *pCharStr ); - } -} - -void SAL_CALL rtl_uString_newFromCodePoints( - rtl_uString ** newString, sal_uInt32 const * codePoints, - sal_Int32 codePointCount) -{ - sal_Int32 n; - sal_Int32 i; - sal_Unicode * p; - OSL_ASSERT( - newString != NULL && - (codePoints != NULL || codePointCount == 0) && - codePointCount >= 0); - if (codePointCount == 0) { - rtl_uString_new(newString); - return; - } - if (*newString != NULL) { - rtl_uString_release(*newString); - } - n = codePointCount; - for (i = 0; i < codePointCount; ++i) { - OSL_ASSERT(codePoints[i] <= 0x10FFFF); - if (codePoints[i] >= 0x10000) { - ++n; - } - } - /* Builds on the assumption that sal_Int32 uses 32 bit two's complement - representation with wrap around (the necessary number of UTF-16 code - units will be no larger than 2 * SAL_MAX_INT32, represented as - sal_Int32 -2): */ - if (n < 0) { - *newString = NULL; - return; - } - *newString = rtl_uString_ImplAlloc(n); - if (*newString == NULL) { - return; - } - p = (*newString)->buffer; - for (i = 0; i < codePointCount; ++i) { - sal_uInt32 c = codePoints[i]; - if (c < 0x10000) { - *p++ = (sal_Unicode) c; - } else { - c -= 0x10000; - *p++ = (sal_Unicode) ((c >> 10) | SAL_RTL_FIRST_HIGH_SURROGATE); - *p++ = (sal_Unicode) ((c & 0x3FF) | SAL_RTL_FIRST_LOW_SURROGATE); - } - } -} - -/* ======================================================================= */ - -static int rtl_ImplGetFastUTF8UnicodeLen( const sal_Char* pStr, sal_Int32 nLen ) -{ - int n; - sal_uChar c; - const sal_Char* pEndStr; - - n = 0; - pEndStr = pStr+nLen; - while ( pStr < pEndStr ) - { - c = (sal_uChar)*pStr; - - if ( !(c & 0x80) ) - pStr++; - else if ( (c & 0xE0) == 0xC0 ) - pStr += 2; - else if ( (c & 0xF0) == 0xE0 ) - pStr += 3; - else if ( (c & 0xF8) == 0xF0 ) - pStr += 4; - else if ( (c & 0xFC) == 0xF8 ) - pStr += 5; - else if ( (c & 0xFE) == 0xFC ) - pStr += 6; - else - pStr++; - - n++; - } - - return n; -} - -/* ----------------------------------------------------------------------- */ - -static void rtl_string2UString_status( rtl_uString** ppThis, - const sal_Char* pStr, - sal_Int32 nLen, - rtl_TextEncoding eTextEncoding, - sal_uInt32 nCvtFlags, - sal_uInt32 *pInfo ) -{ - OSL_ENSURE(nLen == 0 || rtl_isOctetTextEncoding(eTextEncoding), - "rtl_string2UString_status() - Wrong TextEncoding" ); - - if ( !nLen ) - { - rtl_uString_new( ppThis ); - if (pInfo != NULL) { - *pInfo = 0; - } - } - else - { - if ( *ppThis ) - IMPL_RTL_STRINGNAME( release )( *ppThis ); - - /* Optimization for US-ASCII */ - if ( eTextEncoding == RTL_TEXTENCODING_ASCII_US ) - { - IMPL_RTL_STRCODE* pBuffer; - *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( nLen ); - if (*ppThis == NULL) { - if (pInfo != NULL) { - *pInfo = RTL_TEXTTOUNICODE_INFO_ERROR | - RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL; - } - return; - } - pBuffer = (*ppThis)->buffer; - do - { - /* Check ASCII range */ - OSL_ENSURE( ((unsigned char)*pStr) <= 127, - "rtl_string2UString_status() - Found char > 127 and RTL_TEXTENCODING_ASCII_US is specified" ); - - *pBuffer = *pStr; - pBuffer++; - pStr++; - nLen--; - } - while ( nLen ); - if (pInfo != NULL) { - *pInfo = 0; - } - } - else - { - rtl_uString* pTemp; - rtl_uString* pTemp2 = NULL; - rtl_TextToUnicodeConverter hConverter; - sal_uInt32 nInfo; - sal_Size nSrcBytes; - sal_Size nDestChars; - sal_Size nNewLen; - - /* Optimization for UTF-8 - we try to calculate the exact length */ - /* For all other encoding we try the maximum - and reallocate - the buffer if needed */ - if ( eTextEncoding == RTL_TEXTENCODING_UTF8 ) - { - nNewLen = rtl_ImplGetFastUTF8UnicodeLen( pStr, nLen ); - /* Includes the string only ASCII, then we could copy - the buffer faster */ - if ( nNewLen == (sal_Size)nLen ) - { - IMPL_RTL_STRCODE* pBuffer; - *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( nLen ); - if (*ppThis == NULL) - { - if (pInfo != NULL) { - *pInfo = RTL_TEXTTOUNICODE_INFO_ERROR | - RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL; - } - return; - } - pBuffer = (*ppThis)->buffer; - do - { - /* Check ASCII range */ - OSL_ENSURE( ((unsigned char)*pStr) <= 127, - "rtl_string2UString_status() - UTF8 test encoding is wrong" ); - - *pBuffer = *pStr; - pBuffer++; - pStr++; - nLen--; - } - while ( nLen ); - if (pInfo != NULL) { - *pInfo = 0; - } - return; - } - } - else - nNewLen = nLen; - - nCvtFlags |= RTL_TEXTTOUNICODE_FLAGS_FLUSH; - hConverter = rtl_createTextToUnicodeConverter( eTextEncoding ); - - pTemp = IMPL_RTL_STRINGNAME( ImplAlloc )( nNewLen ); - if (pTemp == NULL) { - if (pInfo != NULL) { - *pInfo = RTL_TEXTTOUNICODE_INFO_ERROR | - RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL; - } - return; - } - nDestChars = rtl_convertTextToUnicode( hConverter, 0, - pStr, nLen, - pTemp->buffer, nNewLen, - nCvtFlags, - &nInfo, &nSrcBytes ); - - /* Buffer not big enough, try again with enough space */ - /* Shouldn't be the case, but if we get textencoding which - could results in more unicode characters we have this - code here. Could be the case for apple encodings */ - while ( nInfo & RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL ) - { - rtl_freeMemory( pTemp ); - nNewLen += 8; - pTemp = IMPL_RTL_STRINGNAME( ImplAlloc )( nNewLen ); - if (pTemp == NULL) { - if (pInfo != NULL) { - *pInfo = RTL_TEXTTOUNICODE_INFO_ERROR | - RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL; - } - return; - } - nDestChars = rtl_convertTextToUnicode( hConverter, 0, - pStr, nLen, - pTemp->buffer, nNewLen, - nCvtFlags, - &nInfo, &nSrcBytes ); - } - - if (pInfo) - *pInfo = nInfo; - - /* Set the buffer to the correct size or if there is too - much overhead, reallocate to the correct size */ - if ( nNewLen > nDestChars+8 ) - { - pTemp2 = IMPL_RTL_STRINGNAME( ImplAlloc )( nDestChars ); - } - if (pTemp2 != NULL) - { - rtl_str_ImplCopy(pTemp2->buffer, pTemp->buffer, nDestChars); - rtl_freeMemory(pTemp); - pTemp = pTemp2; - } - else - { - pTemp->length = nDestChars; - pTemp->buffer[nDestChars] = 0; - } - - rtl_destroyTextToUnicodeConverter( hConverter ); - *ppThis = pTemp; - - /* Results the conversion in an empty buffer - - create an empty string */ - if ( pTemp && !nDestChars ) - rtl_uString_new( ppThis ); - } - } -} - -void SAL_CALL rtl_string2UString( rtl_uString** ppThis, - const sal_Char* pStr, - sal_Int32 nLen, - rtl_TextEncoding eTextEncoding, - sal_uInt32 nCvtFlags ) -{ - rtl_string2UString_status( ppThis, pStr, nLen, eTextEncoding, - nCvtFlags, NULL ); -} - -/* ----------------------------------------------------------------------- */ - -typedef enum { - CANNOT_RETURN, - CAN_RETURN = 1 -} StrLifecycle; - -static oslMutex -getInternMutex() -{ - static oslMutex pPoolGuard = NULL; - if( !pPoolGuard ) - { - oslMutex pGlobalGuard; - pGlobalGuard = *osl_getGlobalMutex(); - osl_acquireMutex( pGlobalGuard ); - if( !pPoolGuard ) - { - oslMutex p = osl_createMutex(); - OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); - pPoolGuard = p; - } - osl_releaseMutex( pGlobalGuard ); - } - else - { - OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); - } - - return pPoolGuard; -} - -/* returns true if we found a dup in the pool */ -static void rtl_ustring_intern_internal( rtl_uString ** newStr, - rtl_uString * str, - StrLifecycle can_return ) -{ - oslMutex pPoolMutex; - - pPoolMutex = getInternMutex(); - - osl_acquireMutex( pPoolMutex ); - - *newStr = rtl_str_hash_intern (str, can_return); - - osl_releaseMutex( pPoolMutex ); - - if( can_return && *newStr != str ) - { /* we dupped, then found a match */ - rtl_freeMemory( str ); - } -} - -void SAL_CALL rtl_uString_intern( rtl_uString ** newStr, - rtl_uString * str) -{ - if (SAL_STRING_IS_INTERN(str)) - { - IMPL_RTL_AQUIRE( str ); - *newStr = str; - } - else - { - rtl_uString *pOrg = *newStr; - *newStr = NULL; - rtl_ustring_intern_internal( newStr, str, CANNOT_RETURN ); - if (pOrg) - rtl_uString_release (pOrg); - } -} - -static int rtl_canGuessUOutputLength( int len, rtl_TextEncoding eTextEncoding ) -{ - // FIXME: Maybe we should use a bit flag in the higher bits of the - // eTextEncoding value itself to determine the encoding type. But if we - // do, be sure to mask the value in certain places that expect the values - // to be numbered serially from 0 and up. One such place is - // Impl_getTextEncodingData(). - - switch ( eTextEncoding ) - { - // 1 to 1 (with no zero elements) - case RTL_TEXTENCODING_IBM_437: - case RTL_TEXTENCODING_IBM_850: - case RTL_TEXTENCODING_IBM_860: - case RTL_TEXTENCODING_IBM_861: - case RTL_TEXTENCODING_IBM_863: - case RTL_TEXTENCODING_IBM_865: - return len; - break; - } - return 0; -} - -void SAL_CALL rtl_uString_internConvert( rtl_uString ** newStr, - const sal_Char * str, - sal_Int32 len, - rtl_TextEncoding eTextEncoding, - sal_uInt32 convertFlags, - sal_uInt32 * pInfo ) -{ - rtl_uString *scratch; - - if (*newStr) - { - rtl_uString_release (*newStr); - *newStr = NULL; - } - - if ( len < 256 ) - { // try various optimisations - sal_Int32 ulen; - if ( len < 0 ) - len = strlen( str ); - if ( eTextEncoding == RTL_TEXTENCODING_ASCII_US ) - { - int i; - rtl_uString *pScratch; - pScratch = alloca( sizeof( rtl_uString ) - + len * sizeof (IMPL_RTL_STRCODE ) ); - for (i = 0; i < len; i++) - { - /* Check ASCII range */ - OSL_ENSURE( ((unsigned char)str[i]) <= 127, - "rtl_ustring_internConvert() - Found char > 127 and RTL_TEXTENCODING_ASCII_US is specified" ); - pScratch->buffer[i] = str[i]; - } - pScratch->length = len; - rtl_ustring_intern_internal( newStr, pScratch, CANNOT_RETURN ); - return; - } - else if ( (ulen = rtl_canGuessUOutputLength(len, eTextEncoding)) != 0 ) - { - rtl_uString *pScratch; - rtl_TextToUnicodeConverter hConverter; - sal_Size nSrcBytes; - sal_uInt32 nInfo; - - pScratch = alloca( sizeof(rtl_uString) + ulen * sizeof (IMPL_RTL_STRCODE) ); - - hConverter = rtl_createTextToUnicodeConverter( eTextEncoding ); - rtl_convertTextToUnicode( - hConverter, 0, str, len, pScratch->buffer, ulen, convertFlags, &nInfo, &nSrcBytes ); - rtl_destroyTextToUnicodeConverter( hConverter ); - - if (pInfo) - *pInfo = nInfo; - - pScratch->length = ulen; - rtl_ustring_intern_internal( newStr, pScratch, CANNOT_RETURN ); - return; - } - - /* FIXME: we want a nice UTF-8 / alloca shortcut here */ - } - - scratch = NULL; - rtl_string2UString_status( &scratch, str, len, eTextEncoding, convertFlags, - pInfo ); - if (!scratch) { - return; - } - rtl_ustring_intern_internal( newStr, scratch, CAN_RETURN ); -} - -static void -internRelease (rtl_uString *pThis) -{ - oslMutex pPoolMutex; - - rtl_uString *pFree = NULL; - if ( SAL_STRING_REFCOUNT( - osl_decrementInterlockedCount( &(pThis->refCount) ) ) == 0) - { - pPoolMutex = getInternMutex(); - osl_acquireMutex( pPoolMutex ); - - rtl_str_hash_remove (pThis); - - /* May have been separately acquired */ - if ( SAL_STRING_REFCOUNT( - osl_incrementInterlockedCount( &(pThis->refCount) ) ) == 1 ) - { - /* we got the last ref */ - pFree = pThis; - } - else /* very unusual */ - { - internRelease (pThis); - } - - osl_releaseMutex( pPoolMutex ); - } - if (pFree) - rtl_freeMemory (pFree); -} - -sal_uInt32 SAL_CALL rtl_uString_iterateCodePoints( - rtl_uString const * string, sal_Int32 * indexUtf16, - sal_Int32 incrementCodePoints) -{ - sal_Int32 n; - sal_Unicode cu; - sal_uInt32 cp; - OSL_ASSERT(string != NULL && indexUtf16 != NULL); - n = *indexUtf16; - OSL_ASSERT(n >= 0 && n <= string->length); - while (incrementCodePoints < 0) { - OSL_ASSERT(n > 0); - cu = string->buffer[--n]; - if (SAL_RTL_IS_LOW_SURROGATE(cu) && n != 0 && - SAL_RTL_IS_HIGH_SURROGATE(string->buffer[n - 1])) - { - --n; - } - ++incrementCodePoints; - } - OSL_ASSERT(n >= 0 && n < string->length); - cu = string->buffer[n]; - if (SAL_RTL_IS_HIGH_SURROGATE(cu) && string->length - n >= 2 && - SAL_RTL_IS_LOW_SURROGATE(string->buffer[n + 1])) - { - cp = SAL_RTL_COMBINE_SURROGATES(cu, string->buffer[n + 1]); - } else { - cp = cu; - } - while (incrementCodePoints > 0) { - OSL_ASSERT(n < string->length); - cu = string->buffer[n++]; - if (SAL_RTL_IS_HIGH_SURROGATE(cu) && n != string->length && - SAL_RTL_IS_LOW_SURROGATE(string->buffer[n])) - { - ++n; - } - --incrementCodePoints; - } - OSL_ASSERT(n >= 0 && n <= string->length); - *indexUtf16 = n; - return cp; -} - -sal_Bool rtl_convertStringToUString( - rtl_uString ** target, char const * source, sal_Int32 length, - rtl_TextEncoding encoding, sal_uInt32 flags) SAL_THROW_EXTERN_C() -{ - sal_uInt32 info; - rtl_string2UString_status(target, source, length, encoding, flags, &info); - return (sal_Bool) ((info & RTL_TEXTTOUNICODE_INFO_ERROR) == 0); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/ustring.cxx b/sal/rtl/source/ustring.cxx new file mode 100644 index 000000000000..a37353c99161 --- /dev/null +++ b/sal/rtl/source/ustring.cxx @@ -0,0 +1,997 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#if defined(_MSC_VER) && (_MSC_VER >= 1400) +#pragma warning(disable:4738) // storing 32-bit float result in memory, possible loss of performance +#endif + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "hash.hxx" +#include "strimp.hxx" +#include "surrogates.hxx" +#include + +#include "rtl/math.h" +#include "rtl/tencinfo.h" + +/* ======================================================================= */ + +/* static data to be referenced by all empty strings + * the refCount is predefined to 1 and must never become 0 ! + */ +static rtl_uString const aImplEmpty_rtl_uString = +{ + (sal_Int32) (SAL_STRING_INTERN_FLAG|SAL_STRING_STATIC_FLAG|1), /*sal_Int32 refCount; */ + 0, /*sal_Int32 length; */ + { 0 } /*sal_Unicode buffer[1];*/ +}; + +/* ======================================================================= */ + +#define IMPL_RTL_STRCODE sal_Unicode +#define IMPL_RTL_USTRCODE( c ) (c) +#define IMPL_RTL_STRNAME( n ) rtl_ustr_ ## n + +#define IMPL_RTL_STRINGNAME( n ) rtl_uString_ ## n +#define IMPL_RTL_STRINGDATA rtl_uString +#define IMPL_RTL_EMPTYSTRING aImplEmpty_rtl_uString +#define IMPL_RTL_INTERN +static void internRelease (rtl_uString *pThis); + +/* ======================================================================= */ + +/* Include String/UString template code */ + +#include "strtmpl.cxx" + +sal_Int32 rtl_ustr_indexOfAscii_WithLength( + sal_Unicode const * str, sal_Int32 len, + char const * subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C() +{ + if (subLen > 0 && subLen <= len) { + sal_Int32 i; + for (i = 0; i <= len - subLen; ++i) { + if (rtl_ustr_asciil_reverseEquals_WithLength( + str + i, subStr, subLen)) + { + return i; + } + } + } + return -1; +} + +sal_Int32 rtl_ustr_lastIndexOfAscii_WithLength( + sal_Unicode const * str, sal_Int32 len, + char const * subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C() +{ + if (subLen > 0 && subLen <= len) { + sal_Int32 i; + for (i = len - subLen; i >= 0; --i) { + if (rtl_ustr_asciil_reverseEquals_WithLength( + str + i, subStr, subLen)) + { + return i; + } + } + } + return -1; +} + +sal_Int32 SAL_CALL rtl_ustr_valueOfFloat(sal_Unicode * pStr, float f) + SAL_THROW_EXTERN_C() +{ + rtl_uString * pResult = NULL; + sal_Int32 nLen; + rtl_math_doubleToUString( + &pResult, 0, 0, f, rtl_math_StringFormat_G, + RTL_USTR_MAX_VALUEOFFLOAT - RTL_CONSTASCII_LENGTH("-x.E-xxx"), '.', 0, + 0, sal_True); + nLen = pResult->length; + OSL_ASSERT(nLen < RTL_USTR_MAX_VALUEOFFLOAT); + rtl_copyMemory(pStr, pResult->buffer, (nLen + 1) * sizeof(sal_Unicode)); + rtl_uString_release(pResult); + return nLen; +} + +sal_Int32 SAL_CALL rtl_ustr_valueOfDouble(sal_Unicode * pStr, double d) + SAL_THROW_EXTERN_C() +{ + rtl_uString * pResult = NULL; + sal_Int32 nLen; + rtl_math_doubleToUString( + &pResult, 0, 0, d, rtl_math_StringFormat_G, + RTL_USTR_MAX_VALUEOFDOUBLE - RTL_CONSTASCII_LENGTH("-x.E-xxx"), '.', 0, + 0, sal_True); + nLen = pResult->length; + OSL_ASSERT(nLen < RTL_USTR_MAX_VALUEOFDOUBLE); + rtl_copyMemory(pStr, pResult->buffer, (nLen + 1) * sizeof(sal_Unicode)); + rtl_uString_release(pResult); + return nLen; +} + +float SAL_CALL rtl_ustr_toFloat(sal_Unicode const * pStr) SAL_THROW_EXTERN_C() +{ + return (float) rtl_math_uStringToDouble(pStr, + pStr + rtl_ustr_getLength(pStr), + '.', 0, 0, 0); +} + +double SAL_CALL rtl_ustr_toDouble(sal_Unicode const * pStr) SAL_THROW_EXTERN_C() +{ + return rtl_math_uStringToDouble(pStr, pStr + rtl_ustr_getLength(pStr), '.', + 0, 0, 0); +} + +/* ======================================================================= */ + +sal_Int32 SAL_CALL rtl_ustr_ascii_compare( const sal_Unicode* pStr1, + const sal_Char* pStr2 ) + SAL_THROW_EXTERN_C() +{ + sal_Int32 nRet; + while ( ((nRet = ((sal_Int32)(*pStr1))- + ((sal_Int32)((unsigned char)(*pStr2)))) == 0) && + *pStr2 ) + { + pStr1++; + pStr2++; + } + + return nRet; +} + +/* ----------------------------------------------------------------------- */ + +sal_Int32 SAL_CALL rtl_ustr_ascii_compare_WithLength( const sal_Unicode* pStr1, + sal_Int32 nStr1Len, + const sal_Char* pStr2 ) + SAL_THROW_EXTERN_C() +{ + sal_Int32 nRet = 0; + while( ((nRet = (nStr1Len ? (sal_Int32)(*pStr1) : 0)- + ((sal_Int32)((unsigned char)(*pStr2)))) == 0) && + nStr1Len && *pStr2 ) + { + pStr1++; + pStr2++; + nStr1Len--; + } + + return nRet; +} + +/* ----------------------------------------------------------------------- */ + +sal_Int32 SAL_CALL rtl_ustr_ascii_shortenedCompare_WithLength( const sal_Unicode* pStr1, + sal_Int32 nStr1Len, + const sal_Char* pStr2, + sal_Int32 nShortenedLength ) + SAL_THROW_EXTERN_C() +{ + const sal_Unicode* pStr1End = pStr1 + nStr1Len; + sal_Int32 nRet; + while ( (nShortenedLength > 0) && + (pStr1 < pStr1End) && *pStr2 ) + { + /* Check ASCII range */ + OSL_ENSURE( (*pStr2 & 0x80) == 0, "Found ASCII char > 127"); + + nRet = ((sal_Int32)*pStr1)- + ((sal_Int32)(unsigned char)*pStr2); + if ( nRet != 0 ) + return nRet; + + nShortenedLength--; + pStr1++; + pStr2++; + } + + if ( nShortenedLength <= 0 ) + return 0; + + if ( *pStr2 ) + { + OSL_ENSURE( pStr1 == pStr1End, "pStr1 == pStr1End failed" ); + // first is a substring of the second string => less (negative value) + nRet = -1; + } + else + { + // greater or equal + nRet = pStr1End - pStr1; + } + + return nRet; +} + +/* ----------------------------------------------------------------------- */ + +sal_Int32 SAL_CALL rtl_ustr_asciil_reverseCompare_WithLength( const sal_Unicode* pStr1, + sal_Int32 nStr1Len, + const sal_Char* pStr2, + sal_Int32 nStr2Len ) + SAL_THROW_EXTERN_C() +{ + const sal_Unicode* pStr1Run = pStr1+nStr1Len; + const sal_Char* pStr2Run = pStr2+nStr2Len; + sal_Int32 nRet; + while ( (pStr1 < pStr1Run) && (pStr2 < pStr2Run) ) + { + pStr1Run--; + pStr2Run--; + nRet = ((sal_Int32)*pStr1Run)-((sal_Int32)*pStr2Run); + if ( nRet ) + return nRet; + } + + return nStr1Len - nStr2Len; +} + +/* ----------------------------------------------------------------------- */ + +sal_Bool SAL_CALL rtl_ustr_asciil_reverseEquals_WithLength( const sal_Unicode* pStr1, + const sal_Char* pStr2, + sal_Int32 nStrLen ) + SAL_THROW_EXTERN_C() +{ + const sal_Unicode* pStr1Run = pStr1+nStrLen; + const sal_Char* pStr2Run = pStr2+nStrLen; + while ( pStr1 < pStr1Run ) + { + pStr1Run--; + pStr2Run--; + if( *pStr1Run != (sal_Unicode)*pStr2Run ) + return sal_False; + } + + return sal_True; +} + +/* ----------------------------------------------------------------------- */ + +sal_Int32 SAL_CALL rtl_ustr_ascii_compareIgnoreAsciiCase( const sal_Unicode* pStr1, + const sal_Char* pStr2 ) + SAL_THROW_EXTERN_C() +{ + sal_Int32 nRet; + sal_Int32 c1; + sal_Int32 c2; + do + { + /* If character between 'A' and 'Z', than convert it to lowercase */ + c1 = (sal_Int32)*pStr1; + c2 = (sal_Int32)((unsigned char)*pStr2); + if ( (c1 >= 65) && (c1 <= 90) ) + c1 += 32; + if ( (c2 >= 65) && (c2 <= 90) ) + c2 += 32; + nRet = c1-c2; + if ( nRet != 0 ) + return nRet; + + pStr1++; + pStr2++; + } + while ( c2 ); + + return 0; +} + +/* ----------------------------------------------------------------------- */ + +sal_Int32 SAL_CALL rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( const sal_Unicode* pStr1, + sal_Int32 nStr1Len, + const sal_Char* pStr2 ) + SAL_THROW_EXTERN_C() +{ + sal_Int32 nRet; + sal_Int32 c1; + sal_Int32 c2; + do + { + if ( !nStr1Len ) + return *pStr2 == '\0' ? 0 : -1; + + /* If character between 'A' and 'Z', than convert it to lowercase */ + c1 = (sal_Int32)*pStr1; + c2 = (sal_Int32)((unsigned char)*pStr2); + if ( (c1 >= 65) && (c1 <= 90) ) + c1 += 32; + if ( (c2 >= 65) && (c2 <= 90) ) + c2 += 32; + nRet = c1-c2; + if ( nRet != 0 ) + return nRet; + + pStr1++; + pStr2++; + nStr1Len--; + } + while( c2 ); + + return 0; +} + +sal_Int32 rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths( + sal_Unicode const * first, sal_Int32 firstLen, + char const * second, sal_Int32 secondLen) SAL_THROW_EXTERN_C() +{ + sal_Int32 i; + sal_Int32 len = firstLen < secondLen ? firstLen : secondLen; + for (i = 0; i < len; ++i) { + sal_Int32 c1 = *first++; + sal_Int32 c2 = (unsigned char) *second++; + sal_Int32 d; + if (c1 >= 65 && c1 <= 90) { + c1 += 32; + } + if (c2 >= 65 && c2 <= 90) { + c2 += 32; + } + d = c1 - c2; + if (d != 0) { + return d; + } + } + return firstLen - secondLen; +} + +/* ----------------------------------------------------------------------- */ + +sal_Int32 SAL_CALL rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( const sal_Unicode* pStr1, + sal_Int32 nStr1Len, + const sal_Char* pStr2, + sal_Int32 nShortenedLength ) + SAL_THROW_EXTERN_C() +{ + const sal_Unicode* pStr1End = pStr1 + nStr1Len; + sal_Int32 nRet; + sal_Int32 c1; + sal_Int32 c2; + while ( (nShortenedLength > 0) && + (pStr1 < pStr1End) && *pStr2 ) + { + /* Check ASCII range */ + OSL_ENSURE( (*pStr2 & 0x80) == 0, "Found ASCII char > 127"); + + /* If character between 'A' and 'Z', than convert it to lowercase */ + c1 = (sal_Int32)*pStr1; + c2 = (sal_Int32)((unsigned char)*pStr2); + if ( (c1 >= 65) && (c1 <= 90) ) + c1 += 32; + if ( (c2 >= 65) && (c2 <= 90) ) + c2 += 32; + nRet = c1-c2; + if ( nRet != 0 ) + return nRet; + + nShortenedLength--; + pStr1++; + pStr2++; + } + + if ( nShortenedLength <= 0 ) + return 0; + + if ( *pStr2 ) + { + OSL_ENSURE( pStr1 == pStr1End, "pStr1 == pStr1End failed" ); + // first is a substring of the second string => less (negative value) + nRet = -1; + } + else + { + // greater or equal + nRet = pStr1End - pStr1; + } + + return nRet; +} + +/* ----------------------------------------------------------------------- */ + +void SAL_CALL rtl_uString_newFromAscii( rtl_uString** ppThis, + const sal_Char* pCharStr ) + SAL_THROW_EXTERN_C() +{ + sal_Int32 nLen; + + if ( pCharStr ) + { + const sal_Char* pTempStr = pCharStr; + while( *pTempStr ) + pTempStr++; + nLen = pTempStr-pCharStr; + } + else + nLen = 0; + + if ( !nLen ) + { + IMPL_RTL_STRINGNAME( new )( ppThis ); + return; + } + + if ( *ppThis ) + IMPL_RTL_STRINGNAME( release )( *ppThis ); + + *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( nLen ); + OSL_ASSERT(*ppThis != NULL); + if ( (*ppThis) ) + { + IMPL_RTL_STRCODE* pBuffer = (*ppThis)->buffer; + do + { + /* Check ASCII range */ + OSL_ENSURE( ((unsigned char)*pCharStr) <= 127, + "rtl_uString_newFromAscii() - Found ASCII char > 127" ); + + *pBuffer = *pCharStr; + pBuffer++; + pCharStr++; + } + while ( *pCharStr ); + } +} + +void SAL_CALL rtl_uString_newFromCodePoints( + rtl_uString ** newString, sal_uInt32 const * codePoints, + sal_Int32 codePointCount) SAL_THROW_EXTERN_C() +{ + sal_Int32 n; + sal_Int32 i; + sal_Unicode * p; + OSL_ASSERT( + newString != NULL && + (codePoints != NULL || codePointCount == 0) && + codePointCount >= 0); + if (codePointCount == 0) { + rtl_uString_new(newString); + return; + } + if (*newString != NULL) { + rtl_uString_release(*newString); + } + n = codePointCount; + for (i = 0; i < codePointCount; ++i) { + OSL_ASSERT(codePoints[i] <= 0x10FFFF); + if (codePoints[i] >= 0x10000) { + ++n; + } + } + /* Builds on the assumption that sal_Int32 uses 32 bit two's complement + representation with wrap around (the necessary number of UTF-16 code + units will be no larger than 2 * SAL_MAX_INT32, represented as + sal_Int32 -2): */ + if (n < 0) { + *newString = NULL; + return; + } + *newString = rtl_uString_ImplAlloc(n); + if (*newString == NULL) { + return; + } + p = (*newString)->buffer; + for (i = 0; i < codePointCount; ++i) { + sal_uInt32 c = codePoints[i]; + if (c < 0x10000) { + *p++ = (sal_Unicode) c; + } else { + c -= 0x10000; + *p++ = (sal_Unicode) ((c >> 10) | SAL_RTL_FIRST_HIGH_SURROGATE); + *p++ = (sal_Unicode) ((c & 0x3FF) | SAL_RTL_FIRST_LOW_SURROGATE); + } + } +} + +/* ======================================================================= */ + +static int rtl_ImplGetFastUTF8UnicodeLen( const sal_Char* pStr, sal_Int32 nLen ) +{ + int n; + sal_uChar c; + const sal_Char* pEndStr; + + n = 0; + pEndStr = pStr+nLen; + while ( pStr < pEndStr ) + { + c = (sal_uChar)*pStr; + + if ( !(c & 0x80) ) + pStr++; + else if ( (c & 0xE0) == 0xC0 ) + pStr += 2; + else if ( (c & 0xF0) == 0xE0 ) + pStr += 3; + else if ( (c & 0xF8) == 0xF0 ) + pStr += 4; + else if ( (c & 0xFC) == 0xF8 ) + pStr += 5; + else if ( (c & 0xFE) == 0xFC ) + pStr += 6; + else + pStr++; + + n++; + } + + return n; +} + +/* ----------------------------------------------------------------------- */ + +static void rtl_string2UString_status( rtl_uString** ppThis, + const sal_Char* pStr, + sal_Int32 nLen, + rtl_TextEncoding eTextEncoding, + sal_uInt32 nCvtFlags, + sal_uInt32 *pInfo ) +{ + OSL_ENSURE(nLen == 0 || rtl_isOctetTextEncoding(eTextEncoding), + "rtl_string2UString_status() - Wrong TextEncoding" ); + + if ( !nLen ) + { + rtl_uString_new( ppThis ); + if (pInfo != NULL) { + *pInfo = 0; + } + } + else + { + if ( *ppThis ) + IMPL_RTL_STRINGNAME( release )( *ppThis ); + + /* Optimization for US-ASCII */ + if ( eTextEncoding == RTL_TEXTENCODING_ASCII_US ) + { + IMPL_RTL_STRCODE* pBuffer; + *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( nLen ); + if (*ppThis == NULL) { + if (pInfo != NULL) { + *pInfo = RTL_TEXTTOUNICODE_INFO_ERROR | + RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL; + } + return; + } + pBuffer = (*ppThis)->buffer; + do + { + /* Check ASCII range */ + OSL_ENSURE( ((unsigned char)*pStr) <= 127, + "rtl_string2UString_status() - Found char > 127 and RTL_TEXTENCODING_ASCII_US is specified" ); + + *pBuffer = *pStr; + pBuffer++; + pStr++; + nLen--; + } + while ( nLen ); + if (pInfo != NULL) { + *pInfo = 0; + } + } + else + { + rtl_uString* pTemp; + rtl_uString* pTemp2 = NULL; + rtl_TextToUnicodeConverter hConverter; + sal_uInt32 nInfo; + sal_Size nSrcBytes; + sal_Size nDestChars; + sal_Size nNewLen; + + /* Optimization for UTF-8 - we try to calculate the exact length */ + /* For all other encoding we try the maximum - and reallocate + the buffer if needed */ + if ( eTextEncoding == RTL_TEXTENCODING_UTF8 ) + { + nNewLen = rtl_ImplGetFastUTF8UnicodeLen( pStr, nLen ); + /* Includes the string only ASCII, then we could copy + the buffer faster */ + if ( nNewLen == (sal_Size)nLen ) + { + IMPL_RTL_STRCODE* pBuffer; + *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( nLen ); + if (*ppThis == NULL) + { + if (pInfo != NULL) { + *pInfo = RTL_TEXTTOUNICODE_INFO_ERROR | + RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL; + } + return; + } + pBuffer = (*ppThis)->buffer; + do + { + /* Check ASCII range */ + OSL_ENSURE( ((unsigned char)*pStr) <= 127, + "rtl_string2UString_status() - UTF8 test encoding is wrong" ); + + *pBuffer = *pStr; + pBuffer++; + pStr++; + nLen--; + } + while ( nLen ); + if (pInfo != NULL) { + *pInfo = 0; + } + return; + } + } + else + nNewLen = nLen; + + nCvtFlags |= RTL_TEXTTOUNICODE_FLAGS_FLUSH; + hConverter = rtl_createTextToUnicodeConverter( eTextEncoding ); + + pTemp = IMPL_RTL_STRINGNAME( ImplAlloc )( nNewLen ); + if (pTemp == NULL) { + if (pInfo != NULL) { + *pInfo = RTL_TEXTTOUNICODE_INFO_ERROR | + RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL; + } + return; + } + nDestChars = rtl_convertTextToUnicode( hConverter, 0, + pStr, nLen, + pTemp->buffer, nNewLen, + nCvtFlags, + &nInfo, &nSrcBytes ); + + /* Buffer not big enough, try again with enough space */ + /* Shouldn't be the case, but if we get textencoding which + could results in more unicode characters we have this + code here. Could be the case for apple encodings */ + while ( nInfo & RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL ) + { + rtl_freeMemory( pTemp ); + nNewLen += 8; + pTemp = IMPL_RTL_STRINGNAME( ImplAlloc )( nNewLen ); + if (pTemp == NULL) { + if (pInfo != NULL) { + *pInfo = RTL_TEXTTOUNICODE_INFO_ERROR | + RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL; + } + return; + } + nDestChars = rtl_convertTextToUnicode( hConverter, 0, + pStr, nLen, + pTemp->buffer, nNewLen, + nCvtFlags, + &nInfo, &nSrcBytes ); + } + + if (pInfo) + *pInfo = nInfo; + + /* Set the buffer to the correct size or if there is too + much overhead, reallocate to the correct size */ + if ( nNewLen > nDestChars+8 ) + { + pTemp2 = IMPL_RTL_STRINGNAME( ImplAlloc )( nDestChars ); + } + if (pTemp2 != NULL) + { + rtl_str_ImplCopy(pTemp2->buffer, pTemp->buffer, nDestChars); + rtl_freeMemory(pTemp); + pTemp = pTemp2; + } + else + { + pTemp->length = nDestChars; + pTemp->buffer[nDestChars] = 0; + } + + rtl_destroyTextToUnicodeConverter( hConverter ); + *ppThis = pTemp; + + /* Results the conversion in an empty buffer - + create an empty string */ + if ( pTemp && !nDestChars ) + rtl_uString_new( ppThis ); + } + } +} + +void SAL_CALL rtl_string2UString( rtl_uString** ppThis, + const sal_Char* pStr, + sal_Int32 nLen, + rtl_TextEncoding eTextEncoding, + sal_uInt32 nCvtFlags ) SAL_THROW_EXTERN_C() +{ + rtl_string2UString_status( ppThis, pStr, nLen, eTextEncoding, + nCvtFlags, NULL ); +} + +/* ----------------------------------------------------------------------- */ + +enum StrLifecycle { + CANNOT_RETURN, + CAN_RETURN = 1 +}; + +static oslMutex +getInternMutex() +{ + static oslMutex pPoolGuard = NULL; + if( !pPoolGuard ) + { + oslMutex pGlobalGuard; + pGlobalGuard = *osl_getGlobalMutex(); + osl_acquireMutex( pGlobalGuard ); + if( !pPoolGuard ) + { + oslMutex p = osl_createMutex(); + OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); + pPoolGuard = p; + } + osl_releaseMutex( pGlobalGuard ); + } + else + { + OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); + } + + return pPoolGuard; +} + +/* returns true if we found a dup in the pool */ +static void rtl_ustring_intern_internal( rtl_uString ** newStr, + rtl_uString * str, + StrLifecycle can_return ) +{ + oslMutex pPoolMutex; + + pPoolMutex = getInternMutex(); + + osl_acquireMutex( pPoolMutex ); + + *newStr = rtl_str_hash_intern (str, can_return); + + osl_releaseMutex( pPoolMutex ); + + if( can_return && *newStr != str ) + { /* we dupped, then found a match */ + rtl_freeMemory( str ); + } +} + +void SAL_CALL rtl_uString_intern( rtl_uString ** newStr, + rtl_uString * str) SAL_THROW_EXTERN_C() +{ + if (SAL_STRING_IS_INTERN(str)) + { + IMPL_RTL_AQUIRE( str ); + *newStr = str; + } + else + { + rtl_uString *pOrg = *newStr; + *newStr = NULL; + rtl_ustring_intern_internal( newStr, str, CANNOT_RETURN ); + if (pOrg) + rtl_uString_release (pOrg); + } +} + +static int rtl_canGuessUOutputLength( int len, rtl_TextEncoding eTextEncoding ) +{ + // FIXME: Maybe we should use a bit flag in the higher bits of the + // eTextEncoding value itself to determine the encoding type. But if we + // do, be sure to mask the value in certain places that expect the values + // to be numbered serially from 0 and up. One such place is + // Impl_getTextEncodingData(). + + switch ( eTextEncoding ) + { + // 1 to 1 (with no zero elements) + case RTL_TEXTENCODING_IBM_437: + case RTL_TEXTENCODING_IBM_850: + case RTL_TEXTENCODING_IBM_860: + case RTL_TEXTENCODING_IBM_861: + case RTL_TEXTENCODING_IBM_863: + case RTL_TEXTENCODING_IBM_865: + return len; + break; + } + return 0; +} + +void SAL_CALL rtl_uString_internConvert( rtl_uString ** newStr, + const sal_Char * str, + sal_Int32 len, + rtl_TextEncoding eTextEncoding, + sal_uInt32 convertFlags, + sal_uInt32 * pInfo ) + SAL_THROW_EXTERN_C() +{ + rtl_uString *scratch; + + if (*newStr) + { + rtl_uString_release (*newStr); + *newStr = NULL; + } + + if ( len < 256 ) + { // try various optimisations + sal_Int32 ulen; + if ( len < 0 ) + len = strlen( str ); + if ( eTextEncoding == RTL_TEXTENCODING_ASCII_US ) + { + int i; + rtl_uString *pScratch; + pScratch = static_cast< rtl_uString * >( + alloca(sizeof (rtl_uString) + len * sizeof (IMPL_RTL_STRCODE))); + for (i = 0; i < len; i++) + { + /* Check ASCII range */ + OSL_ENSURE( ((unsigned char)str[i]) <= 127, + "rtl_ustring_internConvert() - Found char > 127 and RTL_TEXTENCODING_ASCII_US is specified" ); + pScratch->buffer[i] = str[i]; + } + pScratch->length = len; + rtl_ustring_intern_internal( newStr, pScratch, CANNOT_RETURN ); + return; + } + else if ( (ulen = rtl_canGuessUOutputLength(len, eTextEncoding)) != 0 ) + { + rtl_uString *pScratch; + rtl_TextToUnicodeConverter hConverter; + sal_Size nSrcBytes; + sal_uInt32 nInfo; + + pScratch = static_cast< rtl_uString * >( + alloca( + sizeof (rtl_uString) + ulen * sizeof (IMPL_RTL_STRCODE))); + + hConverter = rtl_createTextToUnicodeConverter( eTextEncoding ); + rtl_convertTextToUnicode( + hConverter, 0, str, len, pScratch->buffer, ulen, convertFlags, &nInfo, &nSrcBytes ); + rtl_destroyTextToUnicodeConverter( hConverter ); + + if (pInfo) + *pInfo = nInfo; + + pScratch->length = ulen; + rtl_ustring_intern_internal( newStr, pScratch, CANNOT_RETURN ); + return; + } + + /* FIXME: we want a nice UTF-8 / alloca shortcut here */ + } + + scratch = NULL; + rtl_string2UString_status( &scratch, str, len, eTextEncoding, convertFlags, + pInfo ); + if (!scratch) { + return; + } + rtl_ustring_intern_internal( newStr, scratch, CAN_RETURN ); +} + +static void +internRelease (rtl_uString *pThis) +{ + oslMutex pPoolMutex; + + rtl_uString *pFree = NULL; + if ( SAL_STRING_REFCOUNT( + osl_decrementInterlockedCount( &(pThis->refCount) ) ) == 0) + { + pPoolMutex = getInternMutex(); + osl_acquireMutex( pPoolMutex ); + + rtl_str_hash_remove (pThis); + + /* May have been separately acquired */ + if ( SAL_STRING_REFCOUNT( + osl_incrementInterlockedCount( &(pThis->refCount) ) ) == 1 ) + { + /* we got the last ref */ + pFree = pThis; + } + else /* very unusual */ + { + internRelease (pThis); + } + + osl_releaseMutex( pPoolMutex ); + } + if (pFree) + rtl_freeMemory (pFree); +} + +sal_uInt32 SAL_CALL rtl_uString_iterateCodePoints( + rtl_uString const * string, sal_Int32 * indexUtf16, + sal_Int32 incrementCodePoints) +{ + sal_Int32 n; + sal_Unicode cu; + sal_uInt32 cp; + OSL_ASSERT(string != NULL && indexUtf16 != NULL); + n = *indexUtf16; + OSL_ASSERT(n >= 0 && n <= string->length); + while (incrementCodePoints < 0) { + OSL_ASSERT(n > 0); + cu = string->buffer[--n]; + if (SAL_RTL_IS_LOW_SURROGATE(cu) && n != 0 && + SAL_RTL_IS_HIGH_SURROGATE(string->buffer[n - 1])) + { + --n; + } + ++incrementCodePoints; + } + OSL_ASSERT(n >= 0 && n < string->length); + cu = string->buffer[n]; + if (SAL_RTL_IS_HIGH_SURROGATE(cu) && string->length - n >= 2 && + SAL_RTL_IS_LOW_SURROGATE(string->buffer[n + 1])) + { + cp = SAL_RTL_COMBINE_SURROGATES(cu, string->buffer[n + 1]); + } else { + cp = cu; + } + while (incrementCodePoints > 0) { + OSL_ASSERT(n < string->length); + cu = string->buffer[n++]; + if (SAL_RTL_IS_HIGH_SURROGATE(cu) && n != string->length && + SAL_RTL_IS_LOW_SURROGATE(string->buffer[n])) + { + ++n; + } + --incrementCodePoints; + } + OSL_ASSERT(n >= 0 && n <= string->length); + *indexUtf16 = n; + return cp; +} + +sal_Bool rtl_convertStringToUString( + rtl_uString ** target, char const * source, sal_Int32 length, + rtl_TextEncoding encoding, sal_uInt32 flags) SAL_THROW_EXTERN_C() +{ + sal_uInt32 info; + rtl_string2UString_status(target, source, length, encoding, flags, &info); + return (sal_Bool) ((info & RTL_TEXTTOUNICODE_INFO_ERROR) == 0); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit From 61f74ecffe8e0685a022e5d224595891de64bb2c Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Tue, 1 Nov 2011 12:48:59 -0400 Subject: Unit test for testing cell functions referencing external ranges. --- sc/qa/unit/ucalc.cxx | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 21db934c46e4..6c1ab7554900 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -127,6 +127,7 @@ public: void testSheetCopy(); void testSheetMove(); void testExternalRef(); + void testExternalRefFunctions(); void testDataArea(); void testAutofilter(); void testCopyPaste(); @@ -169,6 +170,7 @@ public: CPPUNIT_TEST(testSheetCopy); CPPUNIT_TEST(testSheetMove); CPPUNIT_TEST(testExternalRef); + CPPUNIT_TEST(testExternalRefFunctions); CPPUNIT_TEST(testDataArea); CPPUNIT_TEST(testGraphicsInGroup); CPPUNIT_TEST(testStreamValid); @@ -1498,6 +1500,60 @@ void Test::testExternalRef() m_pDoc->DeleteTab(0); } +void Test::testExternalRefFunctions() +{ + ScDocShellRef xExtDocSh = new ScDocShell; + OUString aExtDocName(RTL_CONSTASCII_USTRINGPARAM("file:///extdata.fake")); + SfxMedium* pMed = new SfxMedium(aExtDocName, STREAM_STD_READWRITE); + xExtDocSh->DoInitNew(pMed); + CPPUNIT_ASSERT_MESSAGE("external document instance not loaded.", + findLoadedDocShellByName(aExtDocName) != NULL); + + // Populate the external source document. + ScDocument* pExtDoc = xExtDocSh->GetDocument(); + pExtDoc->InsertTab(0, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Data"))); + double val = 1; + pExtDoc->SetValue(0, 0, 0, val); + // leave cell B1 empty. + val = 2; + pExtDoc->SetValue(0, 1, 0, val); + pExtDoc->SetValue(1, 1, 0, val); + val = 3; + pExtDoc->SetValue(0, 2, 0, val); + pExtDoc->SetValue(1, 2, 0, val); + val = 4; + pExtDoc->SetValue(0, 3, 0, val); + pExtDoc->SetValue(1, 3, 0, val); + + m_pDoc->InsertTab(0, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Test"))); + + struct { + const char* pFormula; double fResult; + } aChecks[] = { + { "=SUM('file:///extdata.fake'#Data.A1:A4)", 10 }, + { "=SUM('file:///extdata.fake'#Data.B1:B4)", 9 }, + { "=AVERAGE('file:///extdata.fake'#Data.A1:A4)", 2.5 }, + { "=AVERAGE('file:///extdata.fake'#Data.B1:B4)", 3 }, + { "=COUNT('file:///extdata.fake'#Data.A1:A4)", 4 }, + { "=COUNT('file:///extdata.fake'#Data.B1:B4)", 3 } + }; + + for (size_t i = 0; i < SAL_N_ELEMENTS(aChecks); ++i) + { + m_pDoc->SetString(0, 0, 0, rtl::OUString::createFromAscii(aChecks[i].pFormula)); + m_pDoc->CalcAll(); + m_pDoc->GetValue(0, 0, 0, val); + CPPUNIT_ASSERT_MESSAGE("unexpected result involving external ranges.", val == aChecks[i].fResult); + } + + // Unload the external document shell. + xExtDocSh->DoClose(); + CPPUNIT_ASSERT_MESSAGE("external document instance should have been unloaded.", + findLoadedDocShellByName(aExtDocName) == NULL); + + m_pDoc->DeleteTab(0); +} + void Test::testDataArea() { m_pDoc->InsertTab(0, OUString(RTL_CONSTASCII_USTRINGPARAM("Data"))); -- cgit From 95da84dbcaf118f9b1ec65444198d70bf7459045 Mon Sep 17 00:00:00 2001 From: Thorsten Behrens Date: Tue, 1 Nov 2011 19:06:08 +0100 Subject: Fix .dmg background image some more. --- setup_native/source/mac/ooo/DS_Store | Bin 15364 -> 15364 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/setup_native/source/mac/ooo/DS_Store b/setup_native/source/mac/ooo/DS_Store index 9431578cebb3..fec0edc61bc5 100644 Binary files a/setup_native/source/mac/ooo/DS_Store and b/setup_native/source/mac/ooo/DS_Store differ -- cgit From 30e4e8c2a7d9caa2e40193baa195891e662a2242 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Tue, 1 Nov 2011 17:08:19 +0100 Subject: boolean values are valid for matrix evaluation (fdo#49967) --- sc/source/core/tool/scmatrix.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx index 9470e76a0886..6044003ccb94 100644 --- a/sc/source/core/tool/scmatrix.cxx +++ b/sc/source/core/tool/scmatrix.cxx @@ -732,7 +732,7 @@ bool EvalMatrix(const MatrixImplType& rMat) for (size_t j = 0; j < nCols; ++j) { matrix_element_t eType = rMat.get_type(i, j); - if (eType != mdds::element_numeric && eType == mdds::element_boolean) + if (eType != mdds::element_numeric && eType != mdds::element_boolean) // assuming a CompareMat this is an error return CreateDoubleError(errIllegalArgument); -- cgit From 2f46c82072470599f1fe92dc2235873d6a5ef4ac Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Tue, 1 Nov 2011 17:02:09 -0400 Subject: New unit test to test AND and OR evaluations of matrix objects. This is in response to fdo#40967. --- sc/qa/unit/ucalc.cxx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 6c1ab7554900..a19e300da250 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -640,6 +640,24 @@ void Test::testMatrix() pMat->And() && pMat->Or()); } + // Test the AND and OR evaluations. + for (int i = 0; i < 2; ++i) + { + pMat = new ScMatrix(2, 2, eDT[i]); + + // Only some of the elements are non-zero. + pMat->PutBoolean(true, 0, 0); + pMat->PutDouble(1.0, 1, 1); + CPPUNIT_ASSERT_MESSAGE("incorrect OR result", pMat->Or()); + CPPUNIT_ASSERT_MESSAGE("incorrect AND result", !pMat->And()); + + // All of the elements are non-zero. + pMat->PutBoolean(true, 0, 1); + pMat->PutDouble(2.3, 1, 0); + CPPUNIT_ASSERT_MESSAGE("incorrect OR result", pMat->Or()); + CPPUNIT_ASSERT_MESSAGE("incorrect AND result", pMat->And()); + } + // Now test the emtpy matrix types. eDT[0] = ScMatrix::FILLED_EMPTY; eDT[1] = ScMatrix::SPARSE_EMPTY; -- cgit From cf0dd2113527ba0a601c5c59de7f7f44da161d21 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Tue, 1 Nov 2011 21:56:10 +0100 Subject: prevent access to non existing mdds elements (fdo#41807) --- sc/source/core/tool/scmatrix.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx index 6044003ccb94..1767fceefe7b 100644 --- a/sc/source/core/tool/scmatrix.cxx +++ b/sc/source/core/tool/scmatrix.cxx @@ -591,8 +591,10 @@ bool ScMatrixImpl::IsEmpty( SCSIZE nC, SCSIZE nR ) const bool ScMatrixImpl::IsEmptyPath( SCSIZE nC, SCSIZE nR ) const { // 'Empty path' is empty plus non-zero flag. - ValidColRowReplicated( nC, nR ); - return maMat.get_type(nR, nC) == ::mdds::element_empty && maMat.get_flag(nR, nC) != 0; + if (ValidColRowReplicated( nC, nR )) + return maMat.get_type(nR, nC) == ::mdds::element_empty && maMat.get_flag(nR, nC) != 0; + else + return true; } bool ScMatrixImpl::IsValue( SCSIZE nIndex ) const -- cgit From 0eae161aa3bd0a7abef6f9a5cf6afef171b09704 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Tue, 1 Nov 2011 23:09:17 +0100 Subject: add tests related to fdo#41807 --- .../unit/data/contentCSV/spreadsheet-functions.csv | 4 ++-- sc/qa/unit/data/ods/functions.ods | Bin 10500 -> 10519 bytes 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sc/qa/unit/data/contentCSV/spreadsheet-functions.csv b/sc/qa/unit/data/contentCSV/spreadsheet-functions.csv index da534337f3ed..83a33b299820 100644 --- a/sc/qa/unit/data/contentCSV/spreadsheet-functions.csv +++ b/sc/qa/unit/data/contentCSV/spreadsheet-functions.csv @@ -1,4 +1,4 @@ $C$2, $A$1, Sheet.B$2, Sheet!R2C2 -2, 4, 4, 5, 6, 15, 15, 6 +2, 4, 4, 5, 6, 15, 15, 6, 9 1, 3, 4, 4, 2, 2 -2, 4, 7, 8 +2, 4, 7, 8, 4 diff --git a/sc/qa/unit/data/ods/functions.ods b/sc/qa/unit/data/ods/functions.ods index 231747370137..cfdd26351808 100644 Binary files a/sc/qa/unit/data/ods/functions.ods and b/sc/qa/unit/data/ods/functions.ods differ -- cgit From 84ae3c9853b7b90d7b859fd562dabc7b31e8deb8 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Wed, 2 Nov 2011 00:49:39 +0100 Subject: add test cases for fdo#40967 --- sc/qa/unit/data/contentCSV/bugFix_Sheet2.csv | 6 ++++++ sc/qa/unit/data/ods/bug-fixes.ods | Bin 9361 -> 10467 bytes sc/qa/unit/filters-test.cxx | 6 +++++- 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 sc/qa/unit/data/contentCSV/bugFix_Sheet2.csv diff --git a/sc/qa/unit/data/contentCSV/bugFix_Sheet2.csv b/sc/qa/unit/data/contentCSV/bugFix_Sheet2.csv new file mode 100644 index 000000000000..c6fbdda00504 --- /dev/null +++ b/sc/qa/unit/data/contentCSV/bugFix_Sheet2.csv @@ -0,0 +1,6 @@ +success +fail +success +fail +success +fail diff --git a/sc/qa/unit/data/ods/bug-fixes.ods b/sc/qa/unit/data/ods/bug-fixes.ods index dcdbd69e66c7..686423527107 100644 Binary files a/sc/qa/unit/data/ods/bug-fixes.ods and b/sc/qa/unit/data/ods/bug-fixes.ods differ diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx index 059ef174f988..74a90065201a 100644 --- a/sc/qa/unit/filters-test.cxx +++ b/sc/qa/unit/filters-test.cxx @@ -599,7 +599,11 @@ void ScFiltersTest::testBugFixesODS() CPPUNIT_ASSERT_MESSAGE("Failed to load bugFixes.ods", xDocSh.Is()); ScDocument* pDoc = xDocSh->GetDocument(); - CPPUNIT_ASSERT_MESSAGE("No Document", pDoc); //remove with first test + + rtl::OUString aCSVFileName; + createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("bugFix_Sheet2.")), aCSVFileName); + testFile(aCSVFileName, pDoc, 1); + xDocSh->DoClose(); } -- cgit From 0bcda87664af59e01f4e1048991e5cf752547556 Mon Sep 17 00:00:00 2001 From: Bjoern Michaelsen Date: Tue, 1 Nov 2011 20:24:57 -0400 Subject: fix smoketest linkage --- smoketestoo_native/makefile.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smoketestoo_native/makefile.mk b/smoketestoo_native/makefile.mk index cd801847d3a6..8c7d811a71f8 100755 --- a/smoketestoo_native/makefile.mk +++ b/smoketestoo_native/makefile.mk @@ -42,7 +42,7 @@ SHL1IMPLIB = i$(SHL1TARGET) SHL1TARGET = smoketest SHL1OBJS = $(SLO)/smoketest.obj SHL1RPATH = NONE -SHL1STDLIBS = $(CPPUHELPERLIB) $(CPPULIB) $(CPPUNITLIB) $(SALLIB) $(TESTLIB) +SHL1STDLIBS = $(CPPUHELPERLIB) $(CPPULIB) $(CPPUNITLIB) $(SALLIB) $(UNOTESTLIB) SHL1USE_EXPORTS = name DEF1NAME = $(SHL1TARGET) -- cgit From 11e227371aa5f9bc6434ed9e14866c63555401f2 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 2 Nov 2011 02:29:35 +0100 Subject: Related: i#95668 Fix encoding of non-continuous font indexes The non-continuous font index first has to be converted before the encoding can be looked up. --- writerfilter/source/rtftok/rtfdocumentimpl.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index e17b4b5b302a..bdbd3f483a5d 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -2006,9 +2006,10 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) } else { - RTFValue::Pointer_t pValue(new RTFValue(std::find(m_aFontIndexes.begin(), m_aFontIndexes.end(), nParam) - m_aFontIndexes.begin())); + int nFontIndex = std::find(m_aFontIndexes.begin(), m_aFontIndexes.end(), nParam) - m_aFontIndexes.begin(); + RTFValue::Pointer_t pValue(new RTFValue(nFontIndex)); m_aStates.top().aCharacterSprms->push_back(make_pair(NS_sprm::LN_CRgFtc0, pValue)); - m_aStates.top().nCurrentEncoding = getEncodingTable(nParam); + m_aStates.top().nCurrentEncoding = getEncodingTable(nFontIndex); } break; case RTF_RED: -- cgit From b645f9195f4da3014e001fb27b8a117d89c8f389 Mon Sep 17 00:00:00 2001 From: Muthu Subramanian Date: Wed, 2 Nov 2011 13:50:20 +0530 Subject: n#706792: Fix crash while opening certain pptx files. --- oox/source/drawingml/chart/seriesconverter.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oox/source/drawingml/chart/seriesconverter.cxx b/oox/source/drawingml/chart/seriesconverter.cxx index 8a98471abca9..3ed07e6b914a 100644 --- a/oox/source/drawingml/chart/seriesconverter.cxx +++ b/oox/source/drawingml/chart/seriesconverter.cxx @@ -196,7 +196,7 @@ void DataLabelConverter::convertFromModel( const Reference< XDataSeries >& rxDat PropertySet aPropSet( rxDataSeries->getDataPointByIndex( mrModel.mnIndex ) ); lclConvertLabelFormatting( aPropSet, getFormatter(), mrModel, rTypeGroup, false ); - if( !mrModel.mxLayout->mbAutoLayout ) + if( mrModel.mxLayout && !mrModel.mxLayout->mbAutoLayout ) { // bnc#694340 - nasty hack - chart2 cannot individually // place data labels, let's try to find a useful -- cgit From 79b26e3a113f86237dc787bdb5edb238d8a1ad70 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Wed, 2 Nov 2011 08:48:34 +0100 Subject: .DELETE_ON_ERROR is a global flag (that should always be set). --- solenv/gbuild/UnoApiTarget.mk | 4 ---- solenv/gbuild/gbuild.mk | 2 ++ 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/solenv/gbuild/UnoApiTarget.mk b/solenv/gbuild/UnoApiTarget.mk index 35c05c2b6e37..de2dc74306b6 100644 --- a/solenv/gbuild/UnoApiTarget.mk +++ b/solenv/gbuild/UnoApiTarget.mk @@ -53,10 +53,6 @@ $(call gb_UnoApiOutTarget_get_clean_target,$(1)) : $(call gb_UnoApiTarget_get_cl gb_UnoApiTarget_HPPFILES_$(1) := gb_UnoApiTarget_IDLFILES_$(1) := -.DELETE_ON_ERROR : \ - $(call gb_UnoApiTarget_get_clean_target,$(1)) \ - $(call gb_UnoApiTarget_get_target,$(1)) - endef define gb_UnoApiTarget_add_idlfiles diff --git a/solenv/gbuild/gbuild.mk b/solenv/gbuild/gbuild.mk index 4ff643a33f3c..7daaa918806b 100644 --- a/solenv/gbuild/gbuild.mk +++ b/solenv/gbuild/gbuild.mk @@ -46,6 +46,8 @@ # SYSTEM_JPEG (Linux) # SYSTEM_LIBXML (Linux) +.DELETE_ON_ERROR: + SHELL := /bin/sh MAKEFLAGS+=-r true := T -- cgit From 20528637ef3f9517cf73f71fdcf701e945642989 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Wed, 2 Nov 2011 09:04:37 +0100 Subject: Add gbuild support for .jar in .oxt. --- solenv/gbuild/Jar.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/solenv/gbuild/Jar.mk b/solenv/gbuild/Jar.mk index 9d410badf347..54d6a238e30b 100644 --- a/solenv/gbuild/Jar.mk +++ b/solenv/gbuild/Jar.mk @@ -166,9 +166,10 @@ endef gb_Jar_COMPONENTPREFIXES := \ OOO:vnd.sun.star.expand:\dBRAND_BASE_DIR/program/classes/ \ URE:vnd.sun.star.expand:\dURE_INTERNAL_JAVA_DIR/ \ + OXT:./ \ INTERN:vnd.sun.star.expand:\dOOO_INBUILD_JAVA_DIR/ -# get component prefix from layer name ("OOO", "URE", "INTERN") +# get component prefix from layer name ("OOO", "URE", "OXT", "INTERN") gb_Jar__get_componentprefix = \ $(patsubst $(1):%,%,$(or \ $(filter $(1):%,$(gb_Jar_COMPONENTPREFIXES)), \ -- cgit From ea5021e2d7db54be402c99ee551b470b95f1e92b Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Wed, 2 Nov 2011 09:05:57 +0100 Subject: Add gbuild support for .components files. --- solenv/gbuild/ComponentsTarget.mk | 77 +++++++++++++++++++++++++++++++++++++++ solenv/gbuild/TargetLocations.mk | 2 + solenv/gbuild/gbuild.mk | 1 + 3 files changed, 80 insertions(+) create mode 100644 solenv/gbuild/ComponentsTarget.mk diff --git a/solenv/gbuild/ComponentsTarget.mk b/solenv/gbuild/ComponentsTarget.mk new file mode 100644 index 000000000000..686a7eea966c --- /dev/null +++ b/solenv/gbuild/ComponentsTarget.mk @@ -0,0 +1,77 @@ +# +# Version: MPL 1.1 / GPLv3+ / LGPLv3+ +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License or as specified alternatively below. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# Major Contributor(s): +# [ Copyright (C) 2011 Stephan Bergmann, Red Hat (initial +# developer) ] +# +# All Rights Reserved. +# +# For minor contributions see the git repository. +# +# Alternatively, the contents of this file may be used under the terms of +# either the GNU General Public License Version 3 or later (the "GPLv3+"), or +# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), +# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable +# instead of those above. +# + +# Create a .components file bundling multiple .component files: + +# $(1): ID of this components entity (a relative pathname without ".components" +# extension) +define gb_ComponentsTarget_ComponentsTarget +$(call gb_ComponentsTarget_get_target,$(1)): \ + $(call gb_ComponentsTarget_get_target,$(1)).input +$(call gb_ComponentsTarget_get_target,$(1)).input: COMPONENTFILES := +$(eval $(call gb_Module_register_target,$(call gb_ComponentsTarget_get_target,$(1)),$(call gb_ComponentsTarget_get_clean_target,$(1)))) + +endef + +# $(1): ID of this components entity +# $(2): absolute .component pathname (must be underneath $(WORKDIR) due to the +# --stringparam prefix approach of $(SOLARENV)/bin/packcomponents.xslt) +define gb_ComponentsTarget_add_componentfile +$(call gb_ComponentsTarget_get_target,$(1)): $(2) +$(call gb_ComponentsTarget_get_target,$(1)).input: COMPONENTFILES += $(2) + +endef + +$(call gb_ComponentsTarget_get_target,%): \ + $(call gb_ComponentsTarget_get_target,%).input + $(call gb_Output_announce,$*,$(true),CPS,1) + $(call gb_Helper_abbreviate_dirs_native, \ + mkdir -p $(dir $@)) + $(call gb_Helper_abbreviate_dirs_native, \ + $(gb_XSLTPROC) --nonet --stringparam prefix $(WORKDIR) -o $@ \ + $(SOLARENV)/bin/packcomponents.xslt $@.input) + +$(call gb_ComponentsTarget_get_clean_target,%): \ + $(call gb_ComponentsTarget_get_clean_target,%).input + $(call gb_Output_announce,$*,$(false),CPS,1) + $(call gb_Helper_abbreviate_dirs_native, \ + rm -f $(call gb_ComponentsTarget_get_target,$*)) + +$(call gb_ComponentsTarget_get_target,%).input: + $(call gb_Output_announce,$*,$(true),CPI,1) + $(call gb_Helper_abbreviate_dirs_native, \ + mkdir -p $(dir $@)) + $(call gb_Helper_abbreviate_dirs_native, \ + printf '%s' \ + "$(foreach i,$(COMPONENTFILES),$(subst $(WORKDIR),,$i))" \ + > $@) + +$(call gb_ComponentsTarget_get_clean_target,%).input: + $(call gb_Output_announce,$*,$(false),CPI,1) + $(call gb_Helper_abbreviate_dirs_native, \ + rm -f $(call gb_ComponentsTarget_get_target,$*).input) diff --git a/solenv/gbuild/TargetLocations.mk b/solenv/gbuild/TargetLocations.mk index 9205d444c868..fe907b170ce3 100644 --- a/solenv/gbuild/TargetLocations.mk +++ b/solenv/gbuild/TargetLocations.mk @@ -72,6 +72,7 @@ gb_CObject_get_target = $(WORKDIR)/CObject/$(1).o gb_GenCObject_get_target = $(WORKDIR)/GenCObject/$(1).o gb_ComponentTarget_get_target = $(WORKDIR)/ComponentTarget/$(1).component gb_ComponentTarget_get_inbuild_target = $(WORKDIR)/ComponentTarget/$(1).inbuild.component +gb_ComponentsTarget_get_target = $(WORKDIR)/ComponentsTarget/$(1).components gb_CppunitTest_get_target = $(WORKDIR)/CppunitTest/$(1).test gb_CustomTarget_get_repo_target = $(WORKDIR)/CustomTarget/$(2)_$(1).done gb_CustomTarget_get_target = $(WORKDIR)/CustomTarget/$(1).done @@ -155,6 +156,7 @@ endef $(eval $(call gb_Helper_make_clean_targets,\ AllLangResTarget \ ComponentTarget \ + ComponentsTarget \ Extension \ JavaClassSet \ Jar \ diff --git a/solenv/gbuild/gbuild.mk b/solenv/gbuild/gbuild.mk index 7daaa918806b..530fd9f646d1 100644 --- a/solenv/gbuild/gbuild.mk +++ b/solenv/gbuild/gbuild.mk @@ -309,6 +309,7 @@ include $(SOLARENV)/inc/minor.mk include $(foreach class, \ ComponentTarget \ + ComponentsTarget \ AllLangResTarget \ WinResTarget \ LinkTarget \ -- cgit From 793274a6cf555cb2af783a0ec6da14bbc6547a77 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Wed, 2 Nov 2011 10:36:50 +0100 Subject: Minor clean up. --- cppuhelper/source/bootstrap.cxx | 68 +++++++++++++---------------------------- 1 file changed, 22 insertions(+), 46 deletions(-) diff --git a/cppuhelper/source/bootstrap.cxx b/cppuhelper/source/bootstrap.cxx index 0da5cb0bdfd5..90a16af1be41 100644 --- a/cppuhelper/source/bootstrap.cxx +++ b/cppuhelper/source/bootstrap.cxx @@ -38,9 +38,6 @@ #include "rtl/string.hxx" #include "rtl/ustrbuf.hxx" #include "rtl/uri.hxx" -#if OSL_DEBUG_LEVEL > 0 -#include "rtl/strbuf.hxx" -#endif #include "osl/diagnose.h" #include "osl/file.hxx" #include "osl/module.hxx" @@ -150,7 +147,7 @@ inline beans::PropertyValue createPropertyValue( name, -1, makeAny( value ), beans::PropertyState_DIRECT_VALUE ); } -OUString findBoostrapArgument( +OUString findBootstrapArgument( const Bootstrap & bootstrap, const OUString & arg_name, sal_Bool * pFallenBack ) @@ -180,33 +177,22 @@ OUString findBoostrapArgument( result_buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(".rdb") ); result = result_buf.makeStringAndClear(); -#if OSL_DEBUG_LEVEL > 1 - OString result_dbg = - OUStringToOString(result, RTL_TEXTENCODING_ASCII_US); - OString arg_name_dbg = - OUStringToOString(arg_name, RTL_TEXTENCODING_ASCII_US); OSL_TRACE( - "cppuhelper::findBoostrapArgument - " - "setting %s relative to executable: %s\n", - arg_name_dbg.getStr(), - result_dbg.getStr() ); -#endif + (OSL_LOG_PREFIX "findBootstrapArgument, setting \"%s\" relative to" + " executable \"%s\""), + OUStringToOString(arg_name, RTL_TEXTENCODING_UTF8).getStr(), + OUStringToOString(result, RTL_TEXTENCODING_UTF8).getStr()); } else { if(pFallenBack) *pFallenBack = sal_False; -#if OSL_DEBUG_LEVEL > 1 - OString prefixed_arg_name_dbg = OUStringToOString( - prefixed_arg_name, RTL_TEXTENCODING_ASCII_US ); - OString result_dbg = OUStringToOString( - result, RTL_TEXTENCODING_ASCII_US ); OSL_TRACE( - "cppuhelper::findBoostrapArgument - found %s in env: %s", - prefixed_arg_name_dbg.getStr(), - result_dbg.getStr() ); -#endif + OSL_LOG_PREFIX "findBootstrapArgument, found \"%s\" in env \"%s\"", + (OUStringToOString(prefixed_arg_name, RTL_TEXTENCODING_UTF8). + getStr()), + OUStringToOString(result, RTL_TEXTENCODING_UTF8).getStr()); } return result; @@ -233,18 +219,13 @@ Reference< registry::XSimpleRegistry > nestRegistries( { lastRegistry->open(write_rdb, sal_False, forceWrite_rdb); } - catch (registry::InvalidRegistryException & invalidRegistryException) + catch (registry::InvalidRegistryException & e) { - (void) invalidRegistryException; -#if OSL_DEBUG_LEVEL > 1 - OString rdb_name_tmp = OUStringToOString( - write_rdb, RTL_TEXTENCODING_ASCII_US); - OString message_dbg = OUStringToOString( - invalidRegistryException.Message, RTL_TEXTENCODING_ASCII_US); + (void) e; // avoid warnings OSL_TRACE( - "warning: couldn't open %s cause of %s", - rdb_name_tmp.getStr(), message_dbg.getStr() ); -#endif + OSL_LOG_PREFIX "warning, could not open \"%s\": \"%s\"", + OUStringToOString(write_rdb, RTL_TEXTENCODING_UTF8).getStr(), + OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr()); } if(!lastRegistry->isValid()) @@ -290,17 +271,13 @@ Reference< registry::XSimpleRegistry > nestRegistries( else lastRegistry = simpleRegistry; } - catch(registry::InvalidRegistryException & invalidRegistryException) + catch(registry::InvalidRegistryException & e) { -#if OSL_DEBUG_LEVEL > 1 - OString rdb_name_tmp = OUStringToOString( - rdb_name, RTL_TEXTENCODING_ASCII_US ); - OString message_dbg = OUStringToOString( - invalidRegistryException.Message, RTL_TEXTENCODING_ASCII_US ); + (void) e; // avoid warnings OSL_TRACE( - "warning: couldn't open %s cause of %s", - rdb_name_tmp.getStr(), message_dbg.getStr() ); -#endif + OSL_LOG_PREFIX "warning, could not open \"%s\": \"%s\"", + OUStringToOString(rdb_name, RTL_TEXTENCODING_UTF8).getStr(), + OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr()); if (! optional) { // if a registry was explicitly given, the exception shall fly @@ -308,7 +285,6 @@ Reference< registry::XSimpleRegistry > nestRegistries( throw; } - (void) invalidRegistryException; } } while(index != -1 && csl_rdbs.getLength()); // are there more rdbs in list? @@ -356,7 +332,7 @@ SAL_CALL defaultBootstrap_InitialComponentContext( sal_Bool bFallenback_types; OUString cls_uno_types = - findBoostrapArgument( bootstrap, OUSTR("TYPES"), &bFallenback_types ); + findBootstrapArgument( bootstrap, OUSTR("TYPES"), &bFallenback_types ); Reference types_xRegistry = nestRegistries( @@ -366,11 +342,11 @@ SAL_CALL defaultBootstrap_InitialComponentContext( // ==== bootstrap from services registry ==== sal_Bool bFallenback_services; - OUString cls_uno_services = findBoostrapArgument( + OUString cls_uno_services = findBootstrapArgument( bootstrap, OUSTR("SERVICES"), &bFallenback_services ); sal_Bool fallenBackWriteRegistry; - OUString write_rdb = findBoostrapArgument( + OUString write_rdb = findBootstrapArgument( bootstrap, OUSTR("WRITERDB"), &fallenBackWriteRegistry ); if (fallenBackWriteRegistry) { -- cgit From 72e0dfc02e15ba82b4b4051d050f5aad046cfc2a Mon Sep 17 00:00:00 2001 From: Lior Kaplan Date: Sun, 30 Oct 2011 21:18:36 +0100 Subject: Change strings to reflect text orientation not text directionlity --- sw/source/ui/table/tabledlg.src | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sw/source/ui/table/tabledlg.src b/sw/source/ui/table/tabledlg.src index 1a0fc0ea55ee..1ea1046afae1 100644 --- a/sw/source/ui/table/tabledlg.src +++ b/sw/source/ui/table/tabledlg.src @@ -737,7 +737,7 @@ TabPage TP_TABLE_TEXTFLOW { Pos = MAP_APPFONT ( 12 , 132 ) ; Size = MAP_APPFONT ( 70 , 10 ) ; - Text [ en-US ] = "Text ~direction" ; + Text [ en-US ] = "Text ~orientation" ; }; ListBox LB_TEXTDIRECTION { @@ -748,8 +748,8 @@ TabPage TP_TABLE_TEXTFLOW Border = TRUE; StringList [ en-US ] = { - < "Left-to-right" ; 0; > ; - < "Right-to-left (vertical)" ; 2; > ; + < "horizontal" ; 0; > ; + < "vertical" ; 2; > ; < "Use superordinate object settings" ; 4; > ; }; }; -- cgit From c6189de19431869eafcba64428858ff5410f2a98 Mon Sep 17 00:00:00 2001 From: Lior Kaplan Date: Sun, 30 Oct 2011 21:19:42 +0100 Subject: rename TEXTDIRECTION variables to TEXTORIENTATION to represent the previous string change --- sw/source/ui/table/tabledlg.cxx | 14 +++++++------- sw/source/ui/table/tabledlg.hrc | 4 ++-- sw/source/ui/table/tabledlg.src | 12 ++++++------ 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/sw/source/ui/table/tabledlg.cxx b/sw/source/ui/table/tabledlg.cxx index 25bc3a864017..695c849bbc3d 100644 --- a/sw/source/ui/table/tabledlg.cxx +++ b/sw/source/ui/table/tabledlg.cxx @@ -106,8 +106,8 @@ SwFormatTablePage::SwFormatTablePage( Window* pParent, const SfxItemSet& rSet ) aBottomMF(this, SW_RES( ED_BOTTOM_DIST )), aPropertiesFL(this, SW_RES( FL_PROPERTIES )), - aTextDirectionFT(this, SW_RES( FT_TEXTDIRECTION )), - aTextDirectionLB(this, SW_RES( LB_TEXTDIRECTION )), + aTextDirectionFT(this, SW_RES( FT_TEXTORIENTATION )), + aTextDirectionLB(this, SW_RES( LB_TEXTORIENTATION )), pTblData(0), nSaveWidth(0), @@ -1343,8 +1343,8 @@ SwTextFlowPage::SwTextFlowPage( Window* pParent, aRepeatHeaderNF (this, SW_RES(NF_REPEAT_HEADER )), aRepeatHeaderAfterFT (this), aRepeatHeaderCombo (this, SW_RES(WIN_REPEAT_HEADER), aRepeatHeaderNF, aRepeatHeaderBeforeFT, aRepeatHeaderAfterFT), - aTextDirectionFT(this, SW_RES(FT_TEXTDIRECTION )), - aTextDirectionLB(this, SW_RES(LB_TEXTDIRECTION )), + aTextDirectionFT(this, SW_RES(FT_TEXTORIENTATION )), + aTextDirectionLB(this, SW_RES(LB_TEXTORIENTATION )), aVertOrientFL (this, SW_RES(FL_VERT_ORIENT )), aVertOrientFT(this, SW_RES(FT_VERTORIENT )), @@ -1503,7 +1503,7 @@ sal_Bool SwTextFlowPage::FillItemSet( SfxItemSet& rSet ) bModified |= 0 != rSet.Put( SvxFrameDirectionItem( (SvxFrameDirection)(sal_uLong)aTextDirectionLB.GetEntryData(aTextDirectionLB.GetSelectEntryPos()) - , FN_TABLE_BOX_TEXTDIRECTION)); + , FN_TABLE_BOX_TEXTORIENTATION)); } if(aVertOrientLB.GetSelectEntryPos() != aVertOrientLB.GetSavedValue()) @@ -1675,9 +1675,9 @@ void SwTextFlowPage::Reset( const SfxItemSet& rSet ) aRepeatHeaderNF.SetValue( nRep ); aRepeatHeaderNF.SaveValue(); } - if ( rSet.GetItemState(FN_TABLE_BOX_TEXTDIRECTION) > SFX_ITEM_AVAILABLE ) + if ( rSet.GetItemState(FN_TABLE_BOX_TEXTORIENTATION) > SFX_ITEM_AVAILABLE ) { - sal_uLong nDirection = ((const SvxFrameDirectionItem&)rSet.Get(FN_TABLE_BOX_TEXTDIRECTION)).GetValue(); + sal_uLong nDirection = ((const SvxFrameDirectionItem&)rSet.Get(FN_TABLE_BOX_TEXTORIENTATION)).GetValue(); aTextDirectionLB.SelectEntryPos(aTextDirectionLB.GetEntryPos( (const void*)nDirection )); } diff --git a/sw/source/ui/table/tabledlg.hrc b/sw/source/ui/table/tabledlg.hrc index f03aed6afffc..3933cd3fc37f 100644 --- a/sw/source/ui/table/tabledlg.hrc +++ b/sw/source/ui/table/tabledlg.hrc @@ -58,8 +58,8 @@ #define WIN_REPEAT_HEADER 40 #define FL_HEADLINE 41 #define FL_PROPERTIES 42 -#define FT_TEXTDIRECTION 43 -#define LB_TEXTDIRECTION 44 +#define FT_TEXTORIENTATION 43 +#define LB_TEXTORIENTATION 44 #define BT_OK 100 #define BT_CANCEL 101 diff --git a/sw/source/ui/table/tabledlg.src b/sw/source/ui/table/tabledlg.src index 1ea1046afae1..dbaa2a09eb03 100644 --- a/sw/source/ui/table/tabledlg.src +++ b/sw/source/ui/table/tabledlg.src @@ -307,16 +307,16 @@ TabPage TP_FORMAT_TABLE Hide = TRUE ; Text [ en-US ] = "Properties"; }; - FixedText FT_TEXTDIRECTION + FixedText FT_TEXTORIENTATION { Pos = MAP_APPFONT ( 12 , 138 ) ; Size = MAP_APPFONT ( 60 , 8 ) ; Hide = TRUE ; Text [ en-US ] = "Text ~direction"; }; - ListBox LB_TEXTDIRECTION + ListBox LB_TEXTORIENTATION { - HelpID = "sw:ListBox:TP_FORMAT_TABLE:LB_TEXTDIRECTION"; + HelpID = "sw:ListBox:TP_FORMAT_TABLE:LB_TEXTORIENTATION"; Border = TRUE ; Pos = MAP_APPFONT ( 75 , 136 ) ; Size = MAP_APPFONT ( 176 , 50 ) ; @@ -733,15 +733,15 @@ TabPage TP_TABLE_TEXTFLOW Pos = MAP_APPFONT ( 21 , 113 ) ; Size = MAP_APPFONT ( 2 , 1 ) ; }; - FixedText FT_TEXTDIRECTION + FixedText FT_TEXTORIENTATION { Pos = MAP_APPFONT ( 12 , 132 ) ; Size = MAP_APPFONT ( 70 , 10 ) ; Text [ en-US ] = "Text ~orientation" ; }; - ListBox LB_TEXTDIRECTION + ListBox LB_TEXTORIENTATION { - HelpID = "sw:ListBox:TP_TABLE_TEXTFLOW:LB_TEXTDIRECTION"; + HelpID = "sw:ListBox:TP_TABLE_TEXTFLOW:LB_TEXTORIENTATION"; Pos = MAP_APPFONT ( 85 , 130 ) ; Size = MAP_APPFONT ( 163 , 50 ) ; DropDown = TRUE; -- cgit From 057d3225203543f6d0f2d658d884ed11241e88ee Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 1 Nov 2011 22:38:51 +0000 Subject: ByteString->rtl::OString --- sw/source/core/access/accmap.cxx | 6 +++--- sw/source/core/doc/docbasic.cxx | 8 ++++---- sw/source/core/edit/edtox.cxx | 4 ++-- sw/source/core/tox/toxhlp.cxx | 36 ++++++++++++++++++------------------ sw/source/core/unocore/unofield.cxx | 9 +++++---- sw/source/core/unocore/unoframe.cxx | 14 +++++++++----- sw/source/ui/dbui/dbmgr.cxx | 2 +- sw/source/ui/dbui/mmoutputpage.cxx | 2 +- 8 files changed, 43 insertions(+), 38 deletions(-) diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx index 1dc2c8c99f4e..4c03c4c147a9 100644 --- a/sw/source/core/access/accmap.cxx +++ b/sw/source/core/access/accmap.cxx @@ -185,9 +185,9 @@ void SwDrawModellListener_Impl::Notify( SfxBroadcaster& /*rBC*/, { (void)r; #if OSL_DEBUG_LEVEL > 1 - ByteString aError( "Runtime exception caught while notifying shape.:\n" ); - aError += ByteString( String( r.Message), RTL_TEXTENCODING_ASCII_US ); - OSL_FAIL( aError.GetBuffer() ); + rtl::OStringBuffer aError(RTL_CONSTASCII_STRINGPARAM("Runtime exception caught while notifying shape.:\n")); + aError.append(rtl::OUStringToOString(r.Message, RTL_TEXTENCODING_ASCII_US)); + OSL_FAIL( aError.getStr() ); #endif } } diff --git a/sw/source/core/doc/docbasic.cxx b/sw/source/core/doc/docbasic.cxx index 00c6d40b5d91..4f621331132c 100644 --- a/sw/source/core/doc/docbasic.cxx +++ b/sw/source/core/doc/docbasic.cxx @@ -128,8 +128,8 @@ sal_Bool SwDoc::ExecMacro( const SvxMacro& rMacro, String* pRet, SbxArray* pArgs Sequence< sal_Int16 > aOutArgsIndex; Sequence< Any > aOutArgs; - OSL_TRACE( "SwDoc::ExecMacro URL is %s", ByteString( rMacro.GetMacName(), - RTL_TEXTENCODING_UTF8).GetBuffer() ); + OSL_TRACE( "SwDoc::ExecMacro URL is %s", rtl::OUStringToOString( rMacro.GetMacName(), + RTL_TEXTENCODING_UTF8).getStr() ); eErr = pDocShell->CallXScript( rMacro.GetMacName(), *pUnoArgs, aRet, aOutArgsIndex, aOutArgs); @@ -242,8 +242,8 @@ sal_uInt16 SwDoc::CallEvent( sal_uInt16 nEvent, const SwCallMouseEvent& rCallEve Sequence< sal_Int16 > aOutArgsIndex; Sequence< Any > aOutArgs; - OSL_TRACE( "SwDoc::CallEvent URL is %s", ByteString( - rMacro.GetMacName(), RTL_TEXTENCODING_UTF8).GetBuffer() ); + OSL_TRACE( "SwDoc::CallEvent URL is %s", rtl::OUStringToOString( + rMacro.GetMacName(), RTL_TEXTENCODING_UTF8).getStr() ); nRet += 0 == pDocShell->CallXScript( rMacro.GetMacName(), *pUnoArgs,aRet, aOutArgsIndex, aOutArgs) ? 1 : 0; diff --git a/sw/source/core/edit/edtox.cxx b/sw/source/core/edit/edtox.cxx index 1bbf0b3b9e9a..1e26155d2aca 100644 --- a/sw/source/core/edit/edtox.cxx +++ b/sw/source/core/edit/edtox.cxx @@ -385,14 +385,14 @@ void SwEditShell::ApplyAutoMark() while( !rStrm.GetError() && !rStrm.IsEof() ) { - ByteString aRdLine; + rtl::OString aRdLine; rStrm.ReadLine( aRdLine ); // # -> comment // ; -> delimiter between entries -> // Format: TextToSearchFor;AlternativeString;PrimaryKey;SecondaryKey;CaseSensitive;WordOnly // Leading and trailing blanks are ignored - if( aRdLine.Len() && '#' != aRdLine.GetChar(0) ) + if( aRdLine.getLength() && '#' != aRdLine[0] ) { String sLine( aRdLine, eChrSet ); diff --git a/sw/source/core/tox/toxhlp.cxx b/sw/source/core/tox/toxhlp.cxx index cca45d8f83aa..e28323292a4f 100644 --- a/sw/source/core/tox/toxhlp.cxx +++ b/sw/source/core/tox/toxhlp.cxx @@ -63,9 +63,9 @@ IndexEntrySupplierWrapper::IndexEntrySupplierWrapper() ) { #if OSL_DEBUG_LEVEL > 1 - ByteString aMsg( "IndexEntrySupplierWrapper: Exception caught\n" ); - aMsg += ByteString( String( e.Message ), RTL_TEXTENCODING_UTF8 ); - OSL_FAIL( aMsg.GetBuffer() ); + rtl::OStringBuffer aMsg(RTL_CONSTASCII_STRINGPARAM("IndexEntrySupplierWrapper: Exception caught\n")); + aMsg.append(rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8)); + OSL_FAIL( aMsg.getStr() ); #endif } } @@ -89,9 +89,9 @@ String IndexEntrySupplierWrapper::GetIndexKey( const String& rTxt, ) { #if OSL_DEBUG_LEVEL > 1 - ByteString aMsg( "getIndexKey: Exception caught\n" ); - aMsg += ByteString( String( e.Message ), RTL_TEXTENCODING_UTF8 ); - OSL_FAIL( aMsg.GetBuffer() ); + rtl::OStringBuffer aMsg(RTL_CONSTASCII_STRINGPARAM("getIndexKey: Exception caught\n")); + aMsg.append(rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8)); + OSL_FAIL( aMsg.getStr() ); #endif } return sRet; @@ -110,9 +110,9 @@ String IndexEntrySupplierWrapper::GetFollowingText( sal_Bool bMorePages ) const ) { #if OSL_DEBUG_LEVEL > 1 - ByteString aMsg( "getIndexFollowPageWord: Exception caught\n" ); - aMsg += ByteString( String( e.Message ), RTL_TEXTENCODING_UTF8 ); - OSL_FAIL( aMsg.GetBuffer() ); + rtl::OStringBuffer aMsg(RTL_CONSTASCII_STRINGPARAM("getIndexFollowPageWord: Exception caught\n")); + aMsg.append(rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8)); + OSL_FAIL( aMsg.getStr() ); #endif } return sRet; @@ -133,9 +133,9 @@ IndexEntrySupplierWrapper::GetAlgorithmList( const STAR_NMSPC::lang::Locale& rLc ) { #if OSL_DEBUG_LEVEL > 1 - ByteString aMsg( "getAlgorithmList: Exception caught\n" ); - aMsg += ByteString( String( e.Message ), RTL_TEXTENCODING_UTF8 ); - OSL_FAIL( aMsg.GetBuffer() ); + rtl::OStringBuffer aMsg(RTL_CONSTASCII_STRINGPARAM("getAlgorithmList: Exception caught\n")); + aMsg.append(rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8)); + OSL_FAIL( aMsg.getStr() ); #endif } return sRet; @@ -156,9 +156,9 @@ sal_Bool IndexEntrySupplierWrapper::LoadAlgorithm( ) { #if OSL_DEBUG_LEVEL > 1 - ByteString aMsg( "loadAlgorithm: Exception caught\n" ); - aMsg += ByteString( String( e.Message ), RTL_TEXTENCODING_UTF8 ); - OSL_FAIL( aMsg.GetBuffer() ); + rtl::OStringBuffer aMsg(RTL_CONSTASCII_STRINGPARAM("loadAlgorithm: Exception caught\n")); + aMsg.append(rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8)); + OSL_FAIL( aMsg.getStr() ); #endif } return bRet; @@ -182,9 +182,9 @@ sal_Int16 IndexEntrySupplierWrapper::CompareIndexEntry( ) { #if OSL_DEBUG_LEVEL > 1 - ByteString aMsg( "compareIndexEntry: Exception caught\n" ); - aMsg += ByteString( String( e.Message ), RTL_TEXTENCODING_UTF8 ); - OSL_FAIL( aMsg.GetBuffer() ); + rtl::OStringBuffer aMsg(RTL_CONSTASCII_STRINGPARAM("compareIndexEntry: Exception caught\n")); + aMsg.append(rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8)); + OSL_FAIL( aMsg.getStr() ); #endif } return nRet; diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index 4206c76388db..578a8390751a 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -96,6 +96,7 @@ #include #include // MetaFieldManager #include +#include using ::rtl::OUString; using namespace ::com::sun::star; @@ -444,10 +445,10 @@ sal_Bool SwXFieldMaster::supportsService(const OUString& rServiceName) throw( un } if( pEntry ) { - ByteString aTmp( RTL_CONSTASCII_STRINGPARAM( - "com.sun.star.text.fieldmaster.")); - aTmp.Append( pEntry ); - bRet = rServiceName.equalsAsciiL(aTmp.GetBuffer(), aTmp.Len()); + rtl::OString aTmp = rtl::OStringBuffer(RTL_CONSTASCII_STRINGPARAM( + "com.sun.star.text.fieldmaster.")).append(pEntry). + makeStringAndClear(); + bRet = rServiceName.equalsAsciiL(aTmp.getStr(), aTmp.getLength()); } } return bRet; diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index 8a8ffca43e64..5ba469f2c31e 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -1115,8 +1115,9 @@ void SwXFrame::setPropertyValue(const :: OUString& rPropertyName, const :: uno:: else if( sTmp.EqualsAscii( sGraphicObjectProtocol, 0, sizeof(sGraphicObjectProtocol)-1 ) ) { - ByteString sId( sTmp.Copy(sizeof(sGraphicObjectProtocol)-1), - RTL_TEXTENCODING_ASCII_US ); + rtl::OString sId(rtl::OUStringToOString( + sTmp.Copy(sizeof(sGraphicObjectProtocol)-1), + RTL_TEXTENCODING_ASCII_US)); pGrfObj = new GraphicObject( sId ); sGrfName.Erase(); } @@ -1184,7 +1185,9 @@ void SwXFrame::setPropertyValue(const :: OUString& rPropertyName, const :: uno:: ::rtl::OUString aGraphicProtocol( RTL_CONSTASCII_USTRINGPARAM( sGraphicObjectProtocol ) ); if( aGrfUrl.compareTo( aGraphicProtocol, aGraphicProtocol.getLength() ) == 0 ) { - ByteString sId( aGrfUrl.copy(sizeof(sGraphicObjectProtocol)-1).getStr(), RTL_TEXTENCODING_ASCII_US ); + rtl::OString sId(rtl::OUStringToOString( + aGrfUrl.copy(sizeof(sGraphicObjectProtocol)-1), + RTL_TEXTENCODING_ASCII_US)); pGrfObj = new GraphicObject( sId ); aGraphic = pGrfObj->GetGraphic(); bApply = true; @@ -2137,8 +2140,9 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan else if( sGraphicURL.EqualsAscii( sGraphicObjectProtocol, 0, sizeof(sGraphicObjectProtocol)-1 ) ) { - ByteString sId( sGraphicURL.Copy( sizeof(sGraphicObjectProtocol)-1 ), - RTL_TEXTENCODING_ASCII_US ); + rtl::OString sId(rtl::OUStringToOString( + sGraphicURL.Copy( sizeof(sGraphicObjectProtocol)-1 ), + RTL_TEXTENCODING_ASCII_US)); pGrfObj = new GraphicObject( sId ); sGraphicURL.Erase(); } diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx index 2bdd83ce6f4f..a732303b06f2 100644 --- a/sw/source/ui/dbui/dbmgr.cxx +++ b/sw/source/ui/dbui/dbmgr.cxx @@ -1207,7 +1207,7 @@ sal_Bool SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell, if(pInStream) { pInStream->SetStreamCharSet( eEncoding ); - ByteString sLine; + rtl::OString sLine; sal_Bool bDone = pInStream->ReadLine( sLine ); while ( bDone ) { diff --git a/sw/source/ui/dbui/mmoutputpage.cxx b/sw/source/ui/dbui/mmoutputpage.cxx index 1c6917b1d568..6e2e5099c1b3 100644 --- a/sw/source/ui/dbui/mmoutputpage.cxx +++ b/sw/source/ui/dbui/mmoutputpage.cxx @@ -1248,7 +1248,7 @@ IMPL_LINK(SwMailMergeOutputPage, SendDocumentsHdl_Impl, PushButton*, pButton) OSL_FAIL("no output file created?"); continue; } - ByteString sLine; + rtl::OString sLine; sal_Bool bDone = pInStream->ReadLine( sLine ); while ( bDone ) { -- cgit From 40fbc430fdd9366cd0047724f831929378cdf679 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 1 Nov 2011 22:44:45 +0000 Subject: callcatcher: some unused code --- .../inc/comphelper/embeddedobjectcontainer.hxx | 3 --- comphelper/inc/comphelper/mimeconfighelper.hxx | 3 --- .../source/container/embeddedobjectcontainer.cxx | 24 ---------------------- comphelper/source/misc/mimeconfighelper.cxx | 15 -------------- unusedcode.easy | 3 --- xmloff/inc/xmloff/txtparae.hxx | 2 -- xmloff/source/text/txtparae.cxx | 16 --------------- 7 files changed, 66 deletions(-) diff --git a/comphelper/inc/comphelper/embeddedobjectcontainer.hxx b/comphelper/inc/comphelper/embeddedobjectcontainer.hxx index 7983dec4b662..8d1aab98ed24 100644 --- a/comphelper/inc/comphelper/embeddedobjectcontainer.hxx +++ b/comphelper/inc/comphelper/embeddedobjectcontainer.hxx @@ -124,9 +124,6 @@ public: ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject > InsertEmbeddedObject( const ::com::sun::star::uno::Reference < ::com::sun::star::io::XInputStream >&, ::rtl::OUString& ); - // copy an embedded object into the storage - sal_Bool CopyEmbeddedObject( EmbeddedObjectContainer& rSrc, const ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject >&, ::rtl::OUString& ); - // copy an embedded object into the storage, open the new copy and return it ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject > CopyAndGetEmbeddedObject( EmbeddedObjectContainer& rSrc, const ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject >& xObj, /* TODO const ::rtl::OUString& aOrigName,*/ ::rtl::OUString& rName ); diff --git a/comphelper/inc/comphelper/mimeconfighelper.hxx b/comphelper/inc/comphelper/mimeconfighelper.hxx index 992f367d67df..c8eeed153015 100644 --- a/comphelper/inc/comphelper/mimeconfighelper.hxx +++ b/comphelper/inc/comphelper/mimeconfighelper.hxx @@ -138,9 +138,6 @@ public: static ::com::sun::star::uno::Sequence< sal_Int8 > GetSequenceClassID( sal_uInt32 n1, sal_uInt16 n2, sal_uInt16 n3, sal_uInt8 b8, sal_uInt8 b9, sal_uInt8 b10, sal_uInt8 b11, sal_uInt8 b12, sal_uInt8 b13, sal_uInt8 b14, sal_uInt8 b15 ); - - ::com::sun::star::uno::Sequence GetSequenceClassIDFromObjectName(const ::rtl::OUString& _sObjectName) ; - }; } diff --git a/comphelper/source/container/embeddedobjectcontainer.cxx b/comphelper/source/container/embeddedobjectcontainer.cxx index 9f84b7afa053..8842205a42dd 100644 --- a/comphelper/source/container/embeddedobjectcontainer.cxx +++ b/comphelper/source/container/embeddedobjectcontainer.cxx @@ -711,30 +711,6 @@ sal_Bool EmbeddedObjectContainer::TryToCopyGraphReplacement( EmbeddedObjectConta return bResult; } -sal_Bool EmbeddedObjectContainer::CopyEmbeddedObject( EmbeddedObjectContainer& rSrc, const uno::Reference < embed::XEmbeddedObject >& xObj, ::rtl::OUString& rName ) -{ - RTL_LOGFILE_CONTEXT( aLog, "comphelper (mv76033) comphelper::EmbeddedObjectContainer::CopyEmbeddedObject" ); - - OSL_FAIL( "This method is depricated! Use EmbeddedObjectContainer::CopyAndGetEmbeddedObject() to copy object!\n" ); - - // get the object name before(!) it is assigned to a new storage - ::rtl::OUString aOrigName; - uno::Reference < embed::XEmbedPersist > xPersist( xObj, uno::UNO_QUERY ); - if ( xPersist.is() ) - aOrigName = xPersist->getEntryName(); - - if ( !rName.getLength() ) - rName = CreateUniqueObjectName(); - - if ( StoreEmbeddedObject( xObj, rName, sal_True ) ) - { - TryToCopyGraphReplacement( rSrc, aOrigName, rName ); - return sal_True; - } - - return sal_False; -} - uno::Reference < embed::XEmbeddedObject > EmbeddedObjectContainer::CopyAndGetEmbeddedObject( EmbeddedObjectContainer& rSrc, const uno::Reference < embed::XEmbeddedObject >& xObj, ::rtl::OUString& rName ) { RTL_LOGFILE_CONTEXT( aLog, "comphelper (mv76033) comphelper::EmbeddedObjectContainer::CopyAndGetEmbeddedObject" ); diff --git a/comphelper/source/misc/mimeconfighelper.cxx b/comphelper/source/misc/mimeconfighelper.cxx index c81e761392b9..dfa66e839bd9 100644 --- a/comphelper/source/misc/mimeconfighelper.cxx +++ b/comphelper/source/misc/mimeconfighelper.cxx @@ -925,19 +925,4 @@ uno::Sequence< sal_Int8 > MimeConfigurationHelper::GetSequenceClassID( sal_uInt3 return aResult; } -//------------------------------------------------------------------------- -uno::Sequence MimeConfigurationHelper::GetSequenceClassIDFromObjectName(const ::rtl::OUString& _sObjectName) -{ - uno::Sequence aClassId; - uno::Reference< container::XNameAccess > xObjectNames = GetConfigurationByPath(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Office.Embedding/ObjectNames"))); - uno::Reference< container::XNameAccess > xProps; - if ( xObjectNames.is() && (xObjectNames->getByName(_sObjectName) >>= xProps) && xProps.is() ) - { - ::rtl::OUString sValue; - xProps->getByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ClassID"))) >>= sValue; - aClassId = GetSequenceClassIDRepresentation(sValue); - } - return aClassId; -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/unusedcode.easy b/unusedcode.easy index fddda51431c2..59369992ea56 100644 --- a/unusedcode.easy +++ b/unusedcode.easy @@ -1354,7 +1354,6 @@ XMLTextListAutoStylePoolNames_Impl::Remove(rtl::OUString*) XMLTextListAutoStylePool_Impl::GetPos(XMLTextListAutoStylePoolEntry_Impl const*) const XMLTextListAutoStylePool_Impl::Remove(XMLTextListAutoStylePoolEntry_Impl*) XMLTextParagraphExport::FindTextStyle(com::sun::star::uno::Reference const&, unsigned char&) const -XMLTextParagraphExport::GetHeadingLevel(rtl::OUString const&) XMLVisAreaContext::XMLVisAreaContext(SvXMLImport&, unsigned short, rtl::OUString const&, com::sun::star::uno::Reference const&, Rectangle&, short) XPropertyList::Clear() XSecController::collectToSign(int, rtl::OUString const&) @@ -1982,7 +1981,6 @@ codemaker::cpp::typeToPrefix(TypeManager const&, rtl::OString const&) comphelper::AccessibleEventNotifier::getEventListeners(unsigned int) comphelper::AttributeList::AppendAttributeList(com::sun::star::uno::Reference const&) comphelper::AttributeList::Clear() -comphelper::EmbeddedObjectContainer::CopyEmbeddedObject(comphelper::EmbeddedObjectContainer&, com::sun::star::uno::Reference const&, rtl::OUString&) comphelper::EventLogger::addLogHandler(com::sun::star::uno::Reference const&) comphelper::EventLogger::getLogLevel() const comphelper::EventLogger::getName() const @@ -1991,7 +1989,6 @@ comphelper::EventLogger::setLogLevel(int) const comphelper::FastPropertySetInfo::FastPropertySetInfo() comphelper::FastPropertySetInfo::addProperty(com::sun::star::beans::Property const&) comphelper::MimeConfigurationHelper::AddFilterNameCheckOwnFile(com::sun::star::uno::Sequence&) -comphelper::MimeConfigurationHelper::GetSequenceClassIDFromObjectName(rtl::OUString const&) comphelper::OAccessibleImplementationAccess::setForeignControlledState(com::sun::star::uno::Reference const&, short, unsigned char) comphelper::OAccessibleSelectionHelper::OAccessibleSelectionHelper() comphelper::OAccessibleTextHelper::OAccessibleTextHelper() diff --git a/xmloff/inc/xmloff/txtparae.hxx b/xmloff/inc/xmloff/txtparae.hxx index 17b0b3d65dae..cb095ebcfc75 100644 --- a/xmloff/inc/xmloff/txtparae.hxx +++ b/xmloff/inc/xmloff/txtparae.hxx @@ -673,8 +673,6 @@ public: SinglePropertySetInfoCache& GetCharStyleNamesPropInfoCache() { return aCharStyleNamesPropInfoCache; } - sal_Int32 GetHeadingLevel( const ::rtl::OUString& rStyleName ); - void PushNewTextListsHelper(); void PopTextListsHelper(); diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx index 14501ae9f498..dac0b8e5afc5 100644 --- a/xmloff/source/text/txtparae.cxx +++ b/xmloff/source/text/txtparae.cxx @@ -3695,22 +3695,6 @@ void XMLTextParagraphExport::PreventExportOfControlsInMuteSections( // else: no control shape -> nothing to do } } -sal_Int32 XMLTextParagraphExport::GetHeadingLevel( const OUString& rStyleName ) -{ - if( !pHeadingStyles ) - { - pHeadingStyles = new XMLStringVector; - SvxXMLNumRuleExport::GetOutlineStyles( *pHeadingStyles, - GetExport().GetModel() ); - } - for( XMLStringVector::size_type i=0; i < pHeadingStyles->size(); ++i ) - { - if( (*pHeadingStyles)[i] == rStyleName ) - return static_cast < sal_Int32 >( i ); - } - - return -1; -} void XMLTextParagraphExport::PushNewTextListsHelper() { -- cgit From 7297ec19950c48f498d22bd88c1d3fccbe7d77ea Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 2 Nov 2011 09:55:01 +0000 Subject: update list post SvUShorts removal --- unusedcode.easy | 6 ++---- xmloff/inc/xmloff/xmlnume.hxx | 5 ----- xmloff/source/style/xmlnume.cxx | 42 ----------------------------------------- 3 files changed, 2 insertions(+), 51 deletions(-) diff --git a/unusedcode.easy b/unusedcode.easy index 59369992ea56..3baabe9eb5f7 100644 --- a/unusedcode.easy +++ b/unusedcode.easy @@ -487,6 +487,8 @@ ScInputBarGroup::LinkStubImpl_ScrollHdl(void*, void*) ScJobSetup::ScJobSetup(SfxPrinter*) ScLeftFooterEditPage::GetRanges() ScLeftHeaderEditPage::GetRanges() +ScMacrosTest::testStarBasic() +ScMacrosTest::testVba() ScMatrix::CalcOffset(unsigned long, unsigned long) const ScMultiTextWnd::GetLineCount() ScMyCellInfo::ScMyCellInfo() @@ -804,10 +806,6 @@ SvStringsSortDtor::Insert(SvStringsSortDtor const*, unsigned short, unsigned sho SvStringsSortDtor::Remove(String* const&, unsigned short) SvStringsSortDtor::Remove(unsigned short, unsigned short) SvTabListBox::GetTabJustify(unsigned short) const -SvUShorts::Insert(SvUShorts const*, unsigned short, unsigned short, unsigned short) -SvUShorts::Replace(unsigned short const&, unsigned short) -SvUShorts::Replace(unsigned short const*, unsigned short, unsigned short) -SvUShorts::_ForEach(unsigned short, unsigned short, unsigned char (*)(unsigned short const&, void*), void*) SvUnoAttributeContainer::getImplementation(com::sun::star::uno::Reference) SvXMLAutoStylePoolNamesP_Impl::GetPos(rtl::OUString const*) const SvXMLAutoStylePoolNamesP_Impl::Remove(rtl::OUString*) diff --git a/xmloff/inc/xmloff/xmlnume.hxx b/xmloff/inc/xmloff/xmlnume.hxx index 473bec6d5dec..7edda8ca02ae 100644 --- a/xmloff/inc/xmloff/xmlnume.hxx +++ b/xmloff/inc/xmloff/xmlnume.hxx @@ -98,11 +98,6 @@ public: const ::rtl::OUString& rName, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexReplace > & xNumRule ); - - static sal_Bool GetOutlineStyles( XMLStringVector& rStyleNames, - const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & rModel ); - }; #endif // _XMLOFF_XMLNUME_HXX diff --git a/xmloff/source/style/xmlnume.cxx b/xmloff/source/style/xmlnume.cxx index 58145c4d1378..954587bcdea0 100644 --- a/xmloff/source/style/xmlnume.cxx +++ b/xmloff/source/style/xmlnume.cxx @@ -871,46 +871,4 @@ void SvxXMLNumRuleExport::exportStyles( sal_Bool bUsed, } } -sal_Bool SvxXMLNumRuleExport::GetOutlineStyles( XMLStringVector& rStyleNames, - const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & rModel ) -{ - Reference< XChapterNumberingSupplier > xCNSupplier( rModel, - UNO_QUERY ); - sal_Int32 nLevels = 0; - Reference< XIndexReplace > xNumRule; - if( xCNSupplier.is() ) - { - xNumRule = xCNSupplier->getChapterNumberingRules(); - if( xNumRule.is() ) - nLevels = xNumRule->getCount(); - } - - rStyleNames.resize( nLevels ); - for( sal_Int32 i=0; igetByIndex( i ) ); - uno::Sequence aSeq; - if( aEntry >>= aSeq ) - { - const sal_Int32 nCount = aSeq.getLength(); - const beans::PropertyValue* pPropArray = aSeq.getConstArray(); - for( sal_Int32 j=0; j>= rStyleNames[i]; - break; - } - } - } - } - - return nLevels != 0; -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit From de04c92dea40c906fdf2b9058bd3139134d62f15 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 2 Nov 2011 10:36:12 +0000 Subject: make this build --- sw/inc/cmdid.h | 2 +- sw/source/ui/shells/tabsh.cxx | 6 +++--- sw/source/ui/uiview/formatclipboard.cxx | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h index fae2a9506e09..94d9692bbd21 100644 --- a/sw/inc/cmdid.h +++ b/sw/inc/cmdid.h @@ -614,7 +614,7 @@ included in c-context files, so c++ style stuff will cause problems. #define FN_TABLE_MODE_FIX (FN_FORMAT + 189) /* table mode */ #define FN_TABLE_MODE_FIX_PROP (FN_FORMAT + 190) /* -"- */ #define FN_TABLE_MODE_VARIABLE (FN_FORMAT + 191) /* -"- */ -#define FN_TABLE_BOX_TEXTDIRECTION (FN_FORMAT + 192) /* text direction of table cells */ +#define FN_TABLE_BOX_TEXTORIENTATION (FN_FORMAT + 192) /* text orientation of table cells */ #define FN_TABLE_AUTOSUM (FN_FORMAT + 195) /* */ #define FN_SET_CONTROL_HANDLER (FN_FORMAT + 199) /* set macro */ diff --git a/sw/source/ui/shells/tabsh.cxx b/sw/source/ui/shells/tabsh.cxx index 44500b80fdac..3c892ad78443 100644 --- a/sw/source/ui/shells/tabsh.cxx +++ b/sw/source/ui/shells/tabsh.cxx @@ -140,7 +140,7 @@ const sal_uInt16 aUITableAttrRange[] = FN_TABLE_SET_VERT_ALIGN, FN_TABLE_SET_VERT_ALIGN, RES_FRAMEDIR, RES_FRAMEDIR, RES_ROW_SPLIT, RES_ROW_SPLIT, - FN_TABLE_BOX_TEXTDIRECTION, FN_TABLE_BOX_TEXTDIRECTION, + FN_TABLE_BOX_TEXTORIENTATION, FN_TABLE_BOX_TEXTORIENTATION, // #i29550# RES_COLLAPSING_BORDERS, RES_COLLAPSING_BORDERS, // <-- collapsing borders @@ -188,7 +188,7 @@ static SwTableRep* lcl_TableParamToItemSet( SfxItemSet& rSet, SwWrtShell &rSh ) // text direction in boxes SvxFrameDirectionItem aBoxDirection( FRMDIR_ENVIRONMENT, RES_FRAMEDIR ); if(rSh.GetBoxDirection( aBoxDirection )) - rSet.Put(aBoxDirection, FN_TABLE_BOX_TEXTDIRECTION); + rSet.Put(aBoxDirection, FN_TABLE_BOX_TEXTORIENTATION); sal_Bool bTableSel = rSh.IsTableMode(); if(!bTableSel) @@ -309,7 +309,7 @@ void ItemSetToTableParam( const SfxItemSet& rSet, const SfxPoolItem* pSplit = 0; sal_Bool bRowSplit = SFX_ITEM_SET == rSet.GetItemState( RES_ROW_SPLIT, sal_False, &pSplit ); const SfxPoolItem* pBoxDirection = 0; - sal_Bool bBoxDirection = SFX_ITEM_SET == rSet.GetItemState( FN_TABLE_BOX_TEXTDIRECTION, sal_False, &pBoxDirection ); + sal_Bool bBoxDirection = SFX_ITEM_SET == rSet.GetItemState( FN_TABLE_BOX_TEXTORIENTATION, sal_False, &pBoxDirection ); if( bBackground || bBorder || bRowSplit || bBoxDirection) { /* diff --git a/sw/source/ui/uiview/formatclipboard.cxx b/sw/source/ui/uiview/formatclipboard.cxx index 0fa7a6a00071..a9bfa3f97c39 100644 --- a/sw/source/ui/uiview/formatclipboard.cxx +++ b/sw/source/ui/uiview/formatclipboard.cxx @@ -117,7 +117,7 @@ SfxItemSet* lcl_CreateEmptyItemSet( int nSelectionType, SfxItemPool& rPool RES_KEEP, RES_KEEP, RES_FRAMEDIR, RES_FRAMEDIR, FN_PARAM_TABLE_HEADLINE, FN_PARAM_TABLE_HEADLINE, - FN_TABLE_BOX_TEXTDIRECTION, FN_TABLE_BOX_TEXTDIRECTION, + FN_TABLE_BOX_TEXTORIENTATION, FN_TABLE_BOX_TEXTORIENTATION, FN_TABLE_SET_VERT_ALIGN, FN_TABLE_SET_VERT_ALIGN, 0); } @@ -158,7 +158,7 @@ void lcl_getTableAttributes( SfxItemSet& rSet, SwWrtShell &rSh ) SvxFrameDirectionItem aBoxDirection( FRMDIR_ENVIRONMENT, RES_FRAMEDIR ); if(rSh.GetBoxDirection( aBoxDirection )) - rSet.Put(aBoxDirection, FN_TABLE_BOX_TEXTDIRECTION); + rSet.Put(aBoxDirection, FN_TABLE_BOX_TEXTORIENTATION); rSet.Put(SfxUInt16Item(FN_TABLE_SET_VERT_ALIGN, rSh.GetBoxAlign())); @@ -255,7 +255,7 @@ void lcl_setTableAttributes( const SfxItemSet& rSet, SwWrtShell &rSh ) pFrmFmt->SetFmtAttr( *pItem ); } - if( SFX_ITEM_SET == rSet.GetItemState( FN_TABLE_BOX_TEXTDIRECTION, sal_False, &pItem) ) + if( SFX_ITEM_SET == rSet.GetItemState( FN_TABLE_BOX_TEXTORIENTATION, sal_False, &pItem) ) { SvxFrameDirectionItem aDirection( FRMDIR_ENVIRONMENT, RES_FRAMEDIR ); aDirection.SetValue(static_cast< const SvxFrameDirectionItem* >(pItem)->GetValue()); -- cgit From b03e931439c54f4abaa520cf11ed24560ca1709a Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Wed, 2 Nov 2011 12:34:27 +0100 Subject: we need to use ValidColRowOrRepeated, silly mistake by make --- sc/source/core/tool/scmatrix.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx index 1767fceefe7b..dea2c2896948 100644 --- a/sc/source/core/tool/scmatrix.cxx +++ b/sc/source/core/tool/scmatrix.cxx @@ -591,7 +591,7 @@ bool ScMatrixImpl::IsEmpty( SCSIZE nC, SCSIZE nR ) const bool ScMatrixImpl::IsEmptyPath( SCSIZE nC, SCSIZE nR ) const { // 'Empty path' is empty plus non-zero flag. - if (ValidColRowReplicated( nC, nR )) + if (ValidColRowOrReplicated( nC, nR )) return maMat.get_type(nR, nC) == ::mdds::element_empty && maMat.get_flag(nR, nC) != 0; else return true; -- cgit From 610b7bc5943579d8cacb421c9a6b401b83bda149 Mon Sep 17 00:00:00 2001 From: Cédric Bosdonnat Date: Sat, 22 Oct 2011 04:18:39 -0700 Subject: Page Break: fix crash when changing from break before to break after Keeping a temporary copy of the shared_ptr to avoid the object to be deleted during the Select method. --- sw/source/ui/docvw/FrameControlsManager.cxx | 15 ++++++++++ sw/source/ui/docvw/PageBreakWin.cxx | 43 +++++++++++++++++++---------- sw/source/ui/inc/FrameControlsManager.hxx | 1 + sw/source/ui/inc/PageBreakWin.hxx | 1 + 4 files changed, 45 insertions(+), 15 deletions(-) diff --git a/sw/source/ui/docvw/FrameControlsManager.cxx b/sw/source/ui/docvw/FrameControlsManager.cxx index 62f9b32b1b42..6b00d56f8c62 100644 --- a/sw/source/ui/docvw/FrameControlsManager.cxx +++ b/sw/source/ui/docvw/FrameControlsManager.cxx @@ -83,6 +83,21 @@ const SwFrameControlsManager& SwFrameControlsManager::operator=( const SwFrameCo return *this; } +SwFrameControlPtr SwFrameControlsManager::GetControl( FrameControlType eType, const SwFrm* pFrm ) +{ + SwFrameControlPtr pControl; + + vector< SwFrameControlPtr >& aControls = m_aControls[eType]; + + vector< SwFrameControlPtr >::iterator pIt = find_if( + aControls.begin(), aControls.end( ), FramePredicate( pFrm ) ); + + if ( pIt != aControls.end() ) + pControl = *pIt; + + return pControl; +} + std::vector< SwFrameControlPtr >& SwFrameControlsManager::GetControls( FrameControlType eType ) { return m_aControls[eType]; diff --git a/sw/source/ui/docvw/PageBreakWin.cxx b/sw/source/ui/docvw/PageBreakWin.cxx index b48e450af0e7..2194bd92dba4 100644 --- a/sw/source/ui/docvw/PageBreakWin.cxx +++ b/sw/source/ui/docvw/PageBreakWin.cxx @@ -183,7 +183,8 @@ SwPageBreakWin::SwPageBreakWin( SwEditWin* pEditWin, const SwPageFrm* pPageFrm ) m_pPopupMenu( NULL ), m_pLine( NULL ), m_bIsAppearing( false ), - m_nFadeRate( 100 ) + m_nFadeRate( 100 ), + m_bDestroyed( false ) { // Use pixels for the rest of the drawing SetMapMode( MapMode ( MAP_PIXEL ) ); @@ -202,6 +203,9 @@ SwPageBreakWin::SwPageBreakWin( SwEditWin* pEditWin, const SwPageFrm* pPageFrm ) SwPageBreakWin::~SwPageBreakWin( ) { + m_bDestroyed = true; + m_aFadeTimer.Stop(); + delete m_pPopupMenu; delete m_pLine; } @@ -290,6 +294,8 @@ void SwPageBreakWin::Paint( const Rectangle& ) void SwPageBreakWin::Select( ) { + SwFrameControlPtr pThis = GetEditWin()->GetFrameControlsManager( ).GetControl( PageBreak, GetFrame() ); + switch( GetCurItemId( ) ) { case FN_PAGEBREAK_EDIT: @@ -298,25 +304,27 @@ void SwPageBreakWin::Select( ) while ( pBodyFrm && !pBodyFrm->IsBodyFrm() ) pBodyFrm = static_cast< const SwLayoutFrm* >( pBodyFrm->GetNext() ); + SwEditWin* pEditWin = GetEditWin(); + if ( pBodyFrm ) { + SwWrtShell& rSh = pEditWin->GetView().GetWrtShell(); + sal_Bool bOldLock = rSh.IsViewLocked(); + rSh.LockView( sal_True ); + if ( pBodyFrm->Lower()->IsTabFrm() ) { - SwWrtShell& rSh = GetEditWin()->GetView().GetWrtShell(); rSh.Push( ); rSh.ClearMark(); - sal_Bool bOldLock = rSh.IsViewLocked(); - rSh.LockView( sal_True ); SwCntntFrm *pCnt = const_cast< SwCntntFrm* >( pBodyFrm->ContainsCntnt() ); SwCntntNode* pNd = pCnt->GetNode(); rSh.SetSelection( *pNd ); - SfxUInt16Item aItem( GetEditWin()->GetView().GetPool( ).GetWhich( FN_FORMAT_TABLE_DLG ), TP_TABLE_TEXTFLOW ); - GetEditWin()->GetView().GetViewFrame()->GetDispatcher()->Execute( + SfxUInt16Item aItem( pEditWin->GetView().GetPool( ).GetWhich( FN_FORMAT_TABLE_DLG ), TP_TABLE_TEXTFLOW ); + pEditWin->GetView().GetViewFrame()->GetDispatcher()->Execute( FN_FORMAT_TABLE_DLG, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD, &aItem, NULL ); - rSh.LockView( bOldLock ); rSh.Pop( sal_False ); } else @@ -325,12 +333,13 @@ void SwPageBreakWin::Select( ) SwCntntNode* pNd = pCnt->GetNode(); SwPaM aPaM( *pNd ); - SwPaMItem aPaMItem( GetEditWin()->GetView().GetPool( ).GetWhich( FN_PARAM_PAM ), &aPaM ); - SfxUInt16Item aItem( GetEditWin()->GetView().GetPool( ).GetWhich( SID_PARA_DLG ), TP_PARA_EXT ); - GetEditWin()->GetView().GetViewFrame()->GetDispatcher()->Execute( + SwPaMItem aPaMItem( pEditWin->GetView().GetPool( ).GetWhich( FN_PARAM_PAM ), &aPaM ); + SfxUInt16Item aItem( pEditWin->GetView().GetPool( ).GetWhich( SID_PARA_DLG ), TP_PARA_EXT ); + pEditWin->GetView().GetViewFrame()->GetDispatcher()->Execute( SID_PARA_DLG, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD, &aItem, &aPaMItem, NULL ); } - GetEditWin()->GrabFocus( ); + rSh.LockView( bOldLock ); + pEditWin->GrabFocus( ); } } break; @@ -343,7 +352,6 @@ void SwPageBreakWin::Select( ) if ( pBodyFrm ) { SwCntntFrm *pCnt = const_cast< SwCntntFrm* >( pBodyFrm->ContainsCntnt() ); - //sal_uInt16 nWhich = pCnt->GetAttrSet()->GetPool()->GetWhich( SID_ATTR_PARA_PAGEBREAK ); SwCntntNode* pNd = pCnt->GetNode(); pNd->GetDoc()->GetIDocumentUndoRedo( ).StartUndo( UNDO_UI_DELETE_PAGE_BREAK, NULL ); @@ -363,7 +371,11 @@ void SwPageBreakWin::Select( ) } break; } - Fade( false ); + + // Only fade if there is more than this temporary shared pointer: + // The main reference has been deleted due to a page break removal + if ( pThis.use_count() > 1 ) + Fade( false ); } void SwPageBreakWin::MouseMove( const MouseEvent& rMEvt ) @@ -480,9 +492,10 @@ void SwPageBreakWin::Fade( bool bFadeIn ) if ( !PopupMenu::IsInExecute() ) { m_bIsAppearing = bFadeIn; - if ( m_aFadeTimer.IsActive( ) ) + if ( !m_bDestroyed && m_aFadeTimer.IsActive( ) ) m_aFadeTimer.Stop(); - m_aFadeTimer.Start( ); + if ( !m_bDestroyed ) + m_aFadeTimer.Start( ); } } diff --git a/sw/source/ui/inc/FrameControlsManager.hxx b/sw/source/ui/inc/FrameControlsManager.hxx index 798c0b9ed816..453466ec9cd0 100644 --- a/sw/source/ui/inc/FrameControlsManager.hxx +++ b/sw/source/ui/inc/FrameControlsManager.hxx @@ -60,6 +60,7 @@ class SwFrameControlsManager SwFrameControlsManager( const SwFrameControlsManager& rCopy ); const SwFrameControlsManager& operator=( const SwFrameControlsManager& rCopy ); + SwFrameControlPtr GetControl( FrameControlType eType, const SwFrm* pFrm ); std::vector< SwFrameControlPtr >& GetControls( FrameControlType eType ); void AddControl( FrameControlType eType, SwFrameControlPtr pControl ); void RemoveControls( const SwFrm* pFrm ); diff --git a/sw/source/ui/inc/PageBreakWin.hxx b/sw/source/ui/inc/PageBreakWin.hxx index 263ec56db9e9..bac664c6ac37 100644 --- a/sw/source/ui/inc/PageBreakWin.hxx +++ b/sw/source/ui/inc/PageBreakWin.hxx @@ -46,6 +46,7 @@ class SwPageBreakWin : public MenuButton, public SwFrameControl bool m_bIsAppearing; int m_nFadeRate; Timer m_aFadeTimer; + bool m_bDestroyed; public: SwPageBreakWin( SwEditWin* pEditWin, const SwPageFrm* pPageFrm ); -- cgit From bc3c10b5ce88869871761000e9724bcad9a0d556 Mon Sep 17 00:00:00 2001 From: Cédric Bosdonnat Date: Sun, 23 Oct 2011 07:35:06 -0700 Subject: Grammar checking dialog: reworked how explanations are shown --- cui/source/dialogs/SpellAttrib.hxx | 10 +- cui/source/dialogs/SpellDialog.cxx | 149 +++++++++++++++------ cui/source/dialogs/SpellDialog.hrc | 5 +- cui/source/dialogs/SpellDialog.src | 69 +++++----- cui/source/inc/SpellDialog.hxx | 29 ++-- .../star/linguistic2/SingleProofreadingError.idl | 4 + 6 files changed, 165 insertions(+), 101 deletions(-) diff --git a/cui/source/dialogs/SpellAttrib.hxx b/cui/source/dialogs/SpellAttrib.hxx index 9ebc229380ce..731c6942a082 100644 --- a/cui/source/dialogs/SpellAttrib.hxx +++ b/cui/source/dialogs/SpellAttrib.hxx @@ -47,6 +47,7 @@ struct SpellErrorDescription ::rtl::OUString sErrorText; ::rtl::OUString sDialogTitle; ::rtl::OUString sExplanation; + ::rtl::OUString sExplanationURL; ::com::sun::star::lang::Locale aLocale; ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XProofreader > xGrammarChecker; ::rtl::OUString sServiceName; //service name of GrammarChecker/SpellChecker @@ -64,9 +65,13 @@ struct SpellErrorDescription const ::rtl::OUString& rServiceName, const ::rtl::OUString* pDialogTitle = 0, const ::rtl::OUString* pExplanation = 0, - const ::rtl::OUString* pRuleId = 0 ) : + const ::rtl::OUString* pRuleId = 0, + const ::rtl::OUString* pExplanationURL = 0 ) : bIsGrammarError( bGrammar ), sErrorText( rText ), + sDialogTitle( ), + sExplanation( ), + sExplanationURL( ), aLocale( rLocale ), xGrammarChecker( rxGrammarChecker ), sServiceName( rServiceName ), @@ -76,6 +81,8 @@ struct SpellErrorDescription sDialogTitle = *pDialogTitle; if( pExplanation ) sExplanation = *pExplanation; + if( pExplanationURL ) + sExplanationURL = *pExplanationURL; if( pRuleId ) sRuleId = *pRuleId; }; @@ -91,6 +98,7 @@ struct SpellErrorDescription xGrammarChecker == rDesc.xGrammarChecker && sDialogTitle.equals( rDesc.sDialogTitle ) && sExplanation.equals( rDesc.sExplanation ) && + sExplanationURL.equals( rDesc.sExplanationURL ) && sRuleId == rDesc.sRuleId; } }; diff --git a/cui/source/dialogs/SpellDialog.cxx b/cui/source/dialogs/SpellDialog.cxx index 389cee6a7887..9990e4c28e7c 100644 --- a/cui/source/dialogs/SpellDialog.cxx +++ b/cui/source/dialogs/SpellDialog.cxx @@ -51,6 +51,8 @@ #include #include #include +#include +#include #include #include #include @@ -68,6 +70,8 @@ #include #include "treeopt.hxx" #include +#include +#include using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -189,6 +193,26 @@ sal_uInt16 SpellUndoAction_Impl::GetId()const return m_nId; } +HelpFixedText::HelpFixedText( Window* pParent, const ResId& rResId ): + FixedText( pParent, rResId ) +{ +} + +void HelpFixedText::Paint( const Rectangle& rRect ) +{ + Rectangle aTextRect( rRect.Left() + 6, rRect.Top(), rRect.Right() - 6, rRect.Bottom() ); + DrawText( aTextRect, GetText(), TEXT_DRAW_WORDBREAK | TEXT_DRAW_MULTILINE ); +} + +long HelpFixedText::GetActualHeight( ) +{ + Rectangle rRect( GetPosPixel( ), GetSizePixel() ); + Rectangle aTextRect( rRect.Left() + 6, rRect.Top(), rRect.Right() - 6, rRect.Bottom() ); + Rectangle aBounds = GetTextRect( aTextRect, GetText(), TEXT_DRAW_WORDBREAK | TEXT_DRAW_MULTILINE ); + + return aBounds.getHeight(); +} + // class SvxSpellCheckDialog --------------------------------------------- SpellDialog::SpellDialog( @@ -200,9 +224,10 @@ SpellDialog::SpellDialog( pParent, CUI_RES(RID_SVXDLG_SPELLCHECK)), - aVendorImageFI ( this , CUI_RES( IMG_VENDOR ) ), aLanguageFT ( this, CUI_RES( FT_LANGUAGE ) ), aLanguageLB ( this, CUI_RES( LB_LANGUAGE ) ), + aExplainFT ( this, CUI_RES( FT_EXPLAIN ) ), + aExplainLink ( this, CUI_RES( LINK_EXPLAIN ) ), aNotInDictFT ( this, CUI_RES( FT_NOTINDICT ) ), aSentenceED ( this, CUI_RES( ED_NEWWORD ) ), aSuggestionFT ( this, CUI_RES( FT_SUGGESTION ) ), @@ -215,7 +240,6 @@ SpellDialog::SpellDialog( aChangePB ( this, CUI_RES( PB_CHANGE ) ), aChangeAllPB ( this, CUI_RES( PB_CHANGEALL ) ), - aExplainPB ( this, CUI_RES( PB_EXPLAIN) ), aAutoCorrPB ( this, CUI_RES( PB_AUTOCORR ) ), aCheckGrammarCB ( this, CUI_RES( CB_CHECK_GRAMMAR ) ), @@ -226,8 +250,6 @@ SpellDialog::SpellDialog( aClosePB ( this, CUI_RES( PB_CLOSE ) ), aBackgroundGB ( this, CUI_RES( GB_BACKGROUND ) ), - aVendorImage ( CUI_RES( IMG_DEFAULT_VENDOR ) ), - aResumeST ( CUI_RES(ST_RESUME )), aIgnoreOnceST ( aIgnorePB.GetText()), aNoSuggestionsST( CUI_RES(ST_NOSUGGESTIONS)), @@ -244,6 +266,12 @@ SpellDialog::SpellDialog( xSpell = LinguMgr::GetSpellChecker(); pImpl = new SpellDialog_Impl; + const StyleSettings& rSettings = GetSettings().GetStyleSettings(); + Color aCol = rSettings.GetHelpColor(); + Wallpaper aWall( aCol ); + aExplainLink.SetBackground( aWall ); + aExplainFT.SetBackground( aWall ); + //HelpIds aClosePB. SetHelpId(HID_SPLDLG_BUTTON_CLOSE ); aIgnorePB. SetHelpId(HID_SPLDLG_BUTTON_IGNORE ); @@ -251,7 +279,7 @@ SpellDialog::SpellDialog( aIgnoreRulePB. SetHelpId(HID_SPLDLG_BUTTON_IGNORERULE); aChangePB. SetHelpId(HID_SPLDLG_BUTTON_CHANGE ); aChangeAllPB. SetHelpId(HID_SPLDLG_BUTTON_CHANGEALL); - aExplainPB. SetHelpId(HID_SPLDLG_BUTTON_EXPLAIN ); + aExplainLink. SetHelpId(HID_SPLDLG_BUTTON_EXPLAIN ); Init_Impl(); // disable controls if service is missing @@ -300,6 +328,8 @@ void SpellDialog::Init_Impl() aAddToDictMB.SetSelectHdl(LINK ( this, SpellDialog, AddToDictionaryHdl ) ); aLanguageLB.SetSelectHdl(LINK( this, SpellDialog, LanguageSelectHdl ) ); + aExplainLink.SetClickHdl( LINK( this, SpellDialog, HandleHyperlink ) ); + // initialize language ListBox aLanguageLB.SetLanguageList( LANG_LIST_SPELL_USED, sal_False, sal_False, sal_True ); @@ -324,7 +354,8 @@ void SpellDialog::UpdateBoxes_Impl() nAltLanguage = SvxLocaleToLanguage( pSpellErrorDescription->aLocale ); aNewWords = pSpellErrorDescription->aSuggestions; bIsGrammarError = pSpellErrorDescription->bIsGrammarError; - aExplainPB.SetExplanation(pSpellErrorDescription->sExplanation ); + aExplainLink.SetURL( pSpellErrorDescription->sExplanationURL ); + aExplainFT.SetText( pSpellErrorDescription->sExplanation ); } if( pSpellErrorDescription && pSpellErrorDescription->sDialogTitle.getLength() ) { @@ -363,13 +394,12 @@ void SpellDialog::UpdateBoxes_Impl() aChangeAllPB.Enable(nSize > 0); bool bShowChangeAll = !bIsGrammarError; aChangeAllPB.Show( bShowChangeAll ); - aExplainPB.Show( !bShowChangeAll ); + aExplainFT.Show( !bShowChangeAll ); aLanguageLB.Enable( bShowChangeAll ); aIgnoreAllPB.Show( bShowChangeAll ); aAddToDictMB.Show( bShowChangeAll ); aIgnoreRulePB.Show( !bShowChangeAll ); aIgnoreRulePB.Enable(pSpellErrorDescription && pSpellErrorDescription->sRuleId.getLength()); - aExplainPB.Enable( aExplainPB.HasExplanation() ); aAutoCorrPB.Show( bShowChangeAll && rParent.HasAutoCorrection() ); } @@ -463,23 +493,37 @@ IMPL_STATIC_LINK( SpellDialog, InitHdl, SpellDialog *, EMPTYARG ) } else { - if( SvtLinguConfig().HasVendorImages( "SpellAndGrammarDialogImage" ) ) + if( pThis->aExplainLink.GetURL().Len() == 0 ) + { + pThis->aExplainLink.Hide(); + Size aExplainSize = pThis->aExplainFT.GetSizePixel(); + aExplainSize.Width() += pThis->aExplainLink.GetSizePixel().Width(); + pThis->aExplainFT.SetSizePixel( aExplainSize ); + } + + sal_Int32 nExplainHeight = pThis->aExplainFT.GetActualHeight(); + sal_Int32 nCurrentHeight = pThis->aExplainFT.GetSizePixel().Height(); + if( pThis->aExplainFT.GetText().Len() == 0 ) + { + nExplainHeight = 0; + pThis->aExplainFT.Hide(); + pThis->aExplainLink.Hide(); + } + else + { + Size aSize = pThis->aExplainFT.GetSizePixel(); + aSize.Height() = nExplainHeight; + pThis->aExplainFT.SetSizePixel( aSize ); + + aSize = pThis->aExplainLink.GetSizePixel(); + aSize.Height() = nExplainHeight; + pThis->aExplainLink.SetSizePixel( aSize ); + } + + sal_Int32 nDiff = - ( nCurrentHeight - nExplainHeight ); + if ( nDiff != 0 ) { - pThis->aVendorImageFI.Show(); - Size aVendorSize = pThis->aVendorImageFI.GetSizePixel(); - Size aImageSize = pThis->aVendorImageFI.GetImage().GetSizePixel(); - if( aImageSize.Height() ) - { - aVendorSize.Height() = aImageSize.Height(); - if(aVendorSize.Width() < aImageSize.Width()) - aVendorSize.Width() = aImageSize.Width(); - pThis->aVendorImageFI.SetSizePixel( aVendorSize ); - } - sal_Int32 nDiff = aVendorSize.Height(); - pThis->aVendorImageFI.SetSizePixel(aVendorSize); Control* aControls[] = { - &pThis->aLanguageFT, - &pThis->aLanguageLB, &pThis->aNotInDictFT, &pThis->aSentenceED, &pThis->aSuggestionFT, @@ -490,7 +534,6 @@ IMPL_STATIC_LINK( SpellDialog, InitHdl, SpellDialog *, EMPTYARG ) &pThis->aAddToDictMB, &pThis->aChangePB, &pThis->aChangeAllPB, - &pThis->aExplainPB, &pThis->aAutoCorrPB, &pThis->aCheckGrammarCB, &pThis->aHelpPB, @@ -884,17 +927,10 @@ void SpellDialog::SetTitle_Impl(LanguageType nLang) const SpellErrorDescription* pSpellErrorDescription = aSentenceED.GetAlternatives(); if( pSpellErrorDescription && pSpellErrorDescription->sServiceName.getLength() ) { - ::rtl::OUString sSuggestionImageUrl = - SvtLinguConfig().GetSpellAndGrammarDialogImage( pSpellErrorDescription->sServiceName ); - aVendorImageFI.SetImage( lcl_GetImageFromPngUrl( sSuggestionImageUrl ) ); uno::Reference< lang::XServiceDisplayName > xDisplayName( pSpellErrorDescription->xGrammarChecker, uno::UNO_QUERY ); if( xDisplayName.is() ) sVendor = xDisplayName->getServiceDisplayName( pSpellErrorDescription->aLocale ); } - else - { - aVendorImageFI.SetImage( aVendorImage ); - } if( sVendor.Len() ) { @@ -1193,6 +1229,19 @@ bool SpellDialog::GetNextSentence_Impl(bool bUseSavedSentence, bool bRecheck) } else if(aStart->bIsGrammarError ) { + beans::PropertyValues aProperties = aStart->aGrammarError.aProperties; + rtl::OUString sFullCommentURL; + sal_Int32 i = 0; + while ( !sFullCommentURL.isEmpty() && i < aProperties.getLength() ) + { + if ( aProperties[i].Name.equalsAscii( "FullCommentURL" ) ) + { + uno::Any aValue = aProperties[i].Value; + aValue >>= sFullCommentURL; + } + ++i; + } + uno::Reference< lang::XServiceInfo > xInfo( aStart->xGrammarChecker, uno::UNO_QUERY ); SpellErrorDescription aDesc( true, aStart->sText, @@ -1202,7 +1251,8 @@ bool SpellDialog::GetNextSentence_Impl(bool bUseSavedSentence, bool bRecheck) xInfo->getImplementationName(), &aStart->sDialogTitle, &aStart->aGrammarError.aFullComment, - &aStart->aGrammarError.aRuleIdentifier ); + &aStart->aGrammarError.aRuleIdentifier, + &sFullCommentURL ); aSentenceED.SetAttrib( SpellErrorAttrib(aDesc), 0, (sal_uInt16) nStartPosition, (sal_uInt16) nEndPosition ); } if(aStart->bIsField) @@ -2056,7 +2106,7 @@ void SentenceEditWindow_Impl::SetUndoEditMode(bool bSet) Control* aControls[] = { &pSpellDialog->aChangeAllPB, - &pSpellDialog->aExplainPB, + &pSpellDialog->aExplainFT, &pSpellDialog->aIgnoreAllPB, &pSpellDialog->aIgnoreRulePB, &pSpellDialog->aIgnorePB, @@ -2087,20 +2137,31 @@ void SentenceEditWindow_Impl::SetUndoEditMode(bool bSet) pSpellDialog->aChangePB.Enable(); } -//----------------------------------------------------------------------- -ExplainButton::~ExplainButton() +IMPL_LINK( SpellDialog, HandleHyperlink, svt::FixedHyperlink*, pHyperlink ) { -} + rtl::OUString sURL=pHyperlink->GetURL(); + rtl::OUString sTitle=GetText(); -//----------------------------------------------------------------------- -void ExplainButton::RequestHelp( const HelpEvent& ) -{ - Help::ShowBalloon( this, GetPosPixel(), m_sExplanation ); -} + if ( ! sURL.getLength() ) // Nothing to do, when the URL is empty + return 1; + try + { + uno::Reference< com::sun::star::system::XSystemShellExecute > xSystemShellExecute( + ::comphelper::getProcessServiceFactory()->createInstance( + DEFINE_CONST_UNICODE("com.sun.star.system.SystemShellExecute") ), uno::UNO_QUERY_THROW ); + xSystemShellExecute->execute( sURL, rtl::OUString(), com::sun::star::system::SystemShellExecuteFlags::DEFAULTS ); + } + catch ( uno::Exception& ) + { + uno::Any exc( ::cppu::getCaughtException() ); + rtl::OUString msg( ::comphelper::anyToString( exc ) ); + const SolarMutexGuard guard; + ErrorBox aErrorBox( NULL, WB_OK, msg ); + aErrorBox.SetText( sTitle ); + aErrorBox.Execute(); + } -void ExplainButton::Click() -{ - RequestHelp( HelpEvent() ); + return 1; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/dialogs/SpellDialog.hrc b/cui/source/dialogs/SpellDialog.hrc index d51ec1e82249..36b6c56d584d 100644 --- a/cui/source/dialogs/SpellDialog.hrc +++ b/cui/source/dialogs/SpellDialog.hrc @@ -48,7 +48,6 @@ #define ST_SPELLING_AND_GRAMMAR 52 #define ST_SPELLING_AND_GRAMMAR_VENDORNAME 53 #define CB_CHECK_GRAMMAR 54 -#define PB_EXPLAIN 55 -#define IMG_VENDOR 56 -#define IMG_DEFAULT_VENDOR 57 +#define LINK_EXPLAIN 55 +#define FT_EXPLAIN 56 #define PB_IGNORERULE 59 diff --git a/cui/source/dialogs/SpellDialog.src b/cui/source/dialogs/SpellDialog.src index 88da8b74e7b7..4a5b2c9c127f 100644 --- a/cui/source/dialogs/SpellDialog.src +++ b/cui/source/dialogs/SpellDialog.src @@ -36,7 +36,7 @@ ModelessDialog RID_SVXDLG_SPELLCHECK { HelpId = HID_SPELLCHECK ; - Size = MAP_APPFONT( 270, 188 ); + Size = MAP_APPFONT( 270, 208 ); OutputSize = TRUE; Closeable = TRUE ; SVLook = TRUE; @@ -45,13 +45,6 @@ ModelessDialog RID_SVXDLG_SPELLCHECK Moveable = TRUE ; - FixedImage IMG_VENDOR - { - Pos = MAP_APPFONT ( 0, 0 ) ; - Size = MAP_APPFONT ( 270, 21 ) ; - Hide = TRUE; - }; - FixedText FT_LANGUAGE { Pos = MAP_APPFONT( 6, 8 ); @@ -67,9 +60,23 @@ ModelessDialog RID_SVXDLG_SPELLCHECK Sort = TRUE; DropDown = TRUE; }; + FixedText FT_EXPLAIN + { + Pos = MAP_APPFONT( 1, 18 ); + Size = MAP_APPFONT( 239, 20 ); + VCenter = TRUE ; + }; + FixedText LINK_EXPLAIN + { + Pos = MAP_APPFONT( 240, 18 ); + Size = MAP_APPFONT( 29, 20 ); + Text [ en-US ] = "More..." ; + Right = TRUE ; + VCenter = TRUE ; + }; FixedText FT_NOTINDICT { - Pos = MAP_APPFONT( 6, 26 ); + Pos = MAP_APPFONT( 6, 46 ); Size = MAP_APPFONT( 120, 8 ); Text [ en-US ] = "~Not in dictionary" ; }; @@ -77,7 +84,7 @@ ModelessDialog RID_SVXDLG_SPELLCHECK MultiLineEdit ED_NEWWORD { HelpID = "cui:MultiLineEdit:RID_SVXDLG_SPELLCHECK:ED_NEWWORD"; - Pos = MAP_APPFONT( 6, 37 ); + Pos = MAP_APPFONT( 6, 57 ); Size = MAP_APPFONT( 197, 48 ); Border = TRUE; VScroll = TRUE; @@ -86,14 +93,14 @@ ModelessDialog RID_SVXDLG_SPELLCHECK FixedText FT_SUGGESTION { - Pos = MAP_APPFONT( 6, 88 ); + Pos = MAP_APPFONT( 6, 108 ); Size = MAP_APPFONT( 120, 8 ); Text [ en-US ] = "~Suggestions" ; }; ListBox LB_SUGGESTION { HelpID = "cui:ListBox:RID_SVXDLG_SPELLCHECK:LB_SUGGESTION"; - Pos = MAP_APPFONT( 6, 99 ); + Pos = MAP_APPFONT( 6, 119 ); Size = MAP_APPFONT( 197, 48 ); Border = TRUE; }; @@ -101,7 +108,7 @@ ModelessDialog RID_SVXDLG_SPELLCHECK CheckBox CB_CHECK_GRAMMAR { HelpID = "cui:CheckBox:RID_SVXDLG_SPELLCHECK:CB_CHECK_GRAMMAR"; - Pos = MAP_APPFONT( 6, 153 ); + Pos = MAP_APPFONT( 6, 173 ); Size = MAP_APPFONT( 100, 10 ); Text [ en-US ] = "Check ~grammar" ; Hide = TRUE; @@ -110,7 +117,7 @@ ModelessDialog RID_SVXDLG_SPELLCHECK PushButton PB_IGNORE { HelpID = "cui:PushButton:RID_SVXDLG_SPELLCHECK:PB_IGNORE"; - Pos = MAP_APPFONT( 209, 37 ); + Pos = MAP_APPFONT( 209, 57 ); Size = MAP_APPFONT( 55, 14 ); Text [ en-US ] = "~Ignore Once" ; }; @@ -118,14 +125,14 @@ ModelessDialog RID_SVXDLG_SPELLCHECK PushButton PB_IGNOREALL { HelpID = "cui:PushButton:RID_SVXDLG_SPELLCHECK:PB_IGNOREALL"; - Pos = MAP_APPFONT( 209, 54 ); + Pos = MAP_APPFONT( 209, 74 ); Size = MAP_APPFONT( 55, 14 ); Text [ en-US ] = "I~gnore All" ; }; PushButton PB_IGNORERULE { HelpID = "cui:PushButton:RID_SVXDLG_SPELLCHECK:PB_IGNORERULE"; - Pos = MAP_APPFONT( 209, 54 ); + Pos = MAP_APPFONT( 209, 74 ); Size = MAP_APPFONT( 55, 14 ); Text [ en-US ] = "I~gnore Rule" ; Hide = TRUE; @@ -133,7 +140,7 @@ ModelessDialog RID_SVXDLG_SPELLCHECK MenuButton MB_ADDTODICT { HelpID = "cui:MenuButton:RID_SVXDLG_SPELLCHECK:MB_ADDTODICT"; - Pos = MAP_APPFONT( 209, 71 ); + Pos = MAP_APPFONT( 209, 91 ); Size = MAP_APPFONT( 55, 14 ); Text [ en-US ] = "~Add" ; }; @@ -141,7 +148,7 @@ ModelessDialog RID_SVXDLG_SPELLCHECK PushButton PB_CHANGE { HelpID = "cui:PushButton:RID_SVXDLG_SPELLCHECK:PB_CHANGE"; - Pos = MAP_APPFONT( 209, 99 ); + Pos = MAP_APPFONT( 209, 119 ); Size = MAP_APPFONT( 55, 14 ); Text [ en-US ] = "~Change" ; DefButton = TRUE ; @@ -150,48 +157,40 @@ ModelessDialog RID_SVXDLG_SPELLCHECK PushButton PB_CHANGEALL { HelpID = "cui:PushButton:RID_SVXDLG_SPELLCHECK:PB_CHANGEALL"; - Pos = MAP_APPFONT( 209, 117 ); + Pos = MAP_APPFONT( 209, 137 ); Size = MAP_APPFONT( 55, 14 ); Text [ en-US ] = "Change A~ll" ; }; - PushButton PB_EXPLAIN - { - HelpID = "cui:PushButton:RID_SVXDLG_SPELLCHECK:PB_EXPLAIN"; - Pos = MAP_APPFONT( 209, 117 ); - Size = MAP_APPFONT( 55, 14 ); - Hide = TRUE; - Text [ en-US ] = "~Explain..." ; - }; PushButton PB_AUTOCORR { HelpID = "cui:PushButton:RID_SVXDLG_SPELLCHECK:PB_AUTOCORR"; - Pos = MAP_APPFONT( 209, 134 ); + Pos = MAP_APPFONT( 209, 154 ); Size = MAP_APPFONT( 55, 14 ); Text [ en-US ] = "AutoCor~rect" ; }; GroupBox GB_BACKGROUND { - Pos = MAP_APPFONT( 1, 21 ); + Pos = MAP_APPFONT( 1, 41 ); Size = MAP_APPFONT( 268, 146 ); Hide=TRUE; }; HelpButton PB_HELP { - Pos = MAP_APPFONT( 6, 170 ); + Pos = MAP_APPFONT( 6, 191 ); Size = MAP_APPFONT( 55, 14 ); }; PushButton PB_OPTIONS { HelpID = "cui:PushButton:RID_SVXDLG_SPELLCHECK:PB_OPTIONS"; - Pos = MAP_APPFONT( 87, 170 ); + Pos = MAP_APPFONT( 87, 191 ); Size = MAP_APPFONT( 55, 14 ); Text [ en-US ] = "O~ptions..." ; }; PushButton PB_UNDO { HelpID = "cui:PushButton:RID_SVXDLG_SPELLCHECK:PB_UNDO"; - Pos = MAP_APPFONT( 148, 170 ); + Pos = MAP_APPFONT( 148, 191 ); Size = MAP_APPFONT( 55, 14 ); Text [ en-US ] = "~Undo" ; }; @@ -199,7 +198,7 @@ ModelessDialog RID_SVXDLG_SPELLCHECK PushButton PB_CLOSE { HelpID = "cui:PushButton:RID_SVXDLG_SPELLCHECK:PB_CLOSE"; - Pos = MAP_APPFONT ( 209 , 170 ) ; + Pos = MAP_APPFONT ( 209 , 191 ) ; Size = MAP_APPFONT ( 55 , 14 ) ; TabStop = TRUE ; Text [ en-US ] = "Cl~ose" ; @@ -224,9 +223,5 @@ ModelessDialog RID_SVXDLG_SPELLCHECK { Text[ en-US ] = "Spelling and Grammar: $LANGUAGE ($LOCATION) [$VendorName]"; }; - Image IMG_DEFAULT_VENDOR - { - ImageBitmap = Bitmap { File = "vendor01.png"; }; - }; }; // ********************************************************************** EOF diff --git a/cui/source/inc/SpellDialog.hxx b/cui/source/inc/SpellDialog.hxx index 99d6af3d444b..71d502c322b2 100644 --- a/cui/source/inc/SpellDialog.hxx +++ b/cui/source/inc/SpellDialog.hxx @@ -48,6 +48,7 @@ #include #include #include +#include #include #include @@ -129,23 +130,18 @@ public: void ResetIgnoreErrorsAt() { m_aIgnoreErrorsAt.clear(); } }; - -// class SvxSpellDialog --------------------------------------------- -class SpellDialogChildWindow; -class ExplainButton : public PushButton +class HelpFixedText : public FixedText { - String m_sExplanation; - - virtual void RequestHelp( const HelpEvent& rHEvt ); - virtual void Click(); -public: - ExplainButton( Window* pParent, const ResId& rResId ) : PushButton( pParent, rResId ){} - ~ExplainButton(); - void SetExplanation( const String& rText ) {m_sExplanation = rText;} - bool HasExplanation() { return m_sExplanation.Len() > 0;} + public: + HelpFixedText( Window* pParent, const ResId& rResId ); + virtual void Paint( const Rectangle& rRect ); + long GetActualHeight( ); }; +// class SvxSpellDialog --------------------------------------------- +class SpellDialogChildWindow; + class SpellDialog : public SfxModelessDialog { using Window::Invalidate; @@ -153,11 +149,12 @@ class SpellDialog : public SfxModelessDialog friend class SentenceEditWindow_Impl; private: - FixedImage aVendorImageFI; - FixedText aLanguageFT; SvxLanguageBox aLanguageLB; + HelpFixedText aExplainFT; + svt::FixedHyperlink aExplainLink; + FixedText aNotInDictFT; SentenceEditWindow_Impl aSentenceED; @@ -171,7 +168,6 @@ private: PushButton aChangePB; PushButton aChangeAllPB; - ExplainButton aExplainPB; PushButton aAutoCorrPB; CheckBox aCheckGrammarCB; @@ -219,6 +215,7 @@ private: DECL_LINK( AddToDictionaryHdl, MenuButton* ); DECL_LINK( LanguageSelectHdl, SvxLanguageBox* ); DECL_LINK( DialogUndoHdl, SpellUndoAction_Impl* ); + DECL_LINK( HandleHyperlink, svt::FixedHyperlink * ); DECL_STATIC_LINK( SpellDialog, InitHdl, SpellDialog * ); diff --git a/offapi/com/sun/star/linguistic2/SingleProofreadingError.idl b/offapi/com/sun/star/linguistic2/SingleProofreadingError.idl index 385b13dd7cbc..d4944e0f98e3 100644 --- a/offapi/com/sun/star/linguistic2/SingleProofreadingError.idl +++ b/offapi/com/sun/star/linguistic2/SingleProofreadingError.idl @@ -66,6 +66,10 @@ struct SingleProofreadingError sequence< string > aSuggestions; // a list of properties + //
    + //
  • FullCommentURL: URL to a page providing more details on the + // error.
  • + //
sequence< com::sun::star::beans::PropertyValue > aProperties; }; -- cgit From 1b717cee8c7e9d321dc8fdbfb47719cbd9b6c870 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Wed, 2 Nov 2011 13:00:48 +0100 Subject: export DBUS_{CFLAGS,LIBS} --- RepositoryExternal.mk | 28 ++++++++++++++++++++++++++++ configure.in | 4 ++++ set_soenv.in | 2 ++ 3 files changed, 34 insertions(+) diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk index db8138cf9ebb..8891d6bfc48f 100644 --- a/RepositoryExternal.mk +++ b/RepositoryExternal.mk @@ -646,6 +646,34 @@ $(call gb_LinkTarget_add_libs,$(1),$(GTHREAD_LIBS)) endef + +ifeq ($(ENABLE_DBUS),YES) + +define gb_LinkTarget__use_dbus +$(call gb_LinkTarget_set_include,$(1),\ + $$(INCLUDE) \ + $(DBUS_CFLAGS) \ +) + +$(call gb_Library_add_defs,$(1),\ + -DENABLE_DBUS \ +) + +$(call gb_LinkTarget_add_libs,$(1),\ + $(DBUS_LIBS) \ +) + +endef + +else # ENABLE_DBUS + +define gb_LinkTarget__use_dbus + +endef + +endif # ENABLE_DBUS + + define gb_LinkTarget__use_dbusmenugtk $(call gb_LinkTarget_set_include,$(1),\ $$(INCLUDE) \ diff --git a/configure.in b/configure.in index 6052587e70d8..a260a0a775fd 100644 --- a/configure.in +++ b/configure.in @@ -6985,6 +6985,8 @@ GTK_CFLAGS="" GTK_LIBS="" ENABLE_SYSTRAY_GTK="" ENABLE_DBUS="" +DBUS_CFLAGS="" +DBUS_LIBS="" if test "$test_gtk" = "yes"; then if test "$ENABLE_GTK" = "TRUE" ; then @@ -7027,6 +7029,8 @@ AC_SUBST(GTK_CFLAGS) AC_SUBST(GTK_LIBS) AC_SUBST(GTHREAD_CFLAGS) AC_SUBST(GTHREAD_LIBS) +AC_SUBST(DBUS_CFLAGS) +AC_SUBST(DBUS_LIBS) PKG_CHECK_MODULES( LIBPNG, libpng, ENABLE_QUICKSTART_LIBPNG="TRUE", ENABLE_QUICKSTART_LIBPNG="" ) AC_SUBST(LIBPNG_LIBS) diff --git a/set_soenv.in b/set_soenv.in index dc2d996c2b5a..2505e193e8f0 100755 --- a/set_soenv.in +++ b/set_soenv.in @@ -1530,6 +1530,8 @@ ToFile( "COMMONS_LOGGING_JAR","@COMMONS_LOGGING_JAR@","e" ); ToFile( "SYSTEM_SERVLETAPI", "@SYSTEM_SERVLETAPI@", "e" ); ToFile( "SERVLETAPI_JAR", "@SERVLETAPI_JAR@", "e" ); ToFile( "ENABLE_DBUS", "@ENABLE_DBUS@", "e" ); +ToFile( "DBUS_CFLAGS", "@DBUS_CFLAGS@", "e" ); +ToFile( "DBUS_LIBS", "@DBUS_LIBS@", "e" ); ToFile( "ENABLE_GCONF", "@ENABLE_GCONF@", "e" ); ToFile( "ENABLE_GNOMEVFS", "@ENABLE_GNOMEVFS@", "e" ); ToFile( "ENABLE_GSTREAMER", "@ENABLE_GSTREAMER@", "e" ); -- cgit From 337b07d872e903cdc5f4411d76aca873567eee81 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Wed, 2 Nov 2011 13:04:19 +0100 Subject: use external --- vcl/Library_vclplug_gtk.mk | 15 +-------------- vcl/Library_vclplug_gtk3.mk | 17 ++++------------- 2 files changed, 5 insertions(+), 27 deletions(-) diff --git a/vcl/Library_vclplug_gtk.mk b/vcl/Library_vclplug_gtk.mk index 2e1983ecdb84..e2f9b8d68479 100644 --- a/vcl/Library_vclplug_gtk.mk +++ b/vcl/Library_vclplug_gtk.mk @@ -41,20 +41,6 @@ $(eval $(call gb_Library_add_defs,vclplug_gtk,\ -DVERSION=\"$(UPD)$(LAST_MINOR)\" \ )) -ifneq ($(ENABLE_DBUS),) -# FIXME: pkg-config calls should be done in configure, and this should be _use_external -$(eval $(call gb_Library_set_include,vclplug_gtk,\ - $$(INCLUDE) \ - $(filter -I%,$(shell pkg-config --cflags dbus-glib-1)) \ -)) -$(eval $(call gb_Library_add_defs,vclplug_gtk,\ - -DENABLE_DBUS \ -)) -$(eval $(call gb_Library_add_libs,vclplug_gtk,\ - $(shell pkg-config --libs dbus-glib-1)\ -)) -endif - $(eval $(call gb_Library_add_api,vclplug_gtk,\ offapi \ udkapi \ @@ -84,6 +70,7 @@ $(eval $(call gb_Library_add_linked_libs,vclplug_gtk,\ )) $(eval $(call gb_Library_use_externals,vclplug_gtk,\ + dbus \ gtk \ gthread \ icule \ diff --git a/vcl/Library_vclplug_gtk3.mk b/vcl/Library_vclplug_gtk3.mk index 72e7a7596754..9c589ff71606 100644 --- a/vcl/Library_vclplug_gtk3.mk +++ b/vcl/Library_vclplug_gtk3.mk @@ -51,19 +51,6 @@ $(eval $(call gb_Library_add_api,vclplug_gtk3,\ udkapi \ )) -ifneq ($(ENABLE_DBUS),) -$(eval $(call gb_Library_set_include,vclplug_gtk3,\ - $$(INCLUDE) \ - $(filter -I%,$(shell pkg-config --cflags dbus-glib-1)) \ -)) -$(eval $(call gb_Library_add_defs,vclplug_gtk3,\ - -DENABLE_DBUS \ -)) -$(eval $(call gb_Library_add_libs,vclplug_gtk3,\ - $(shell pkg-config --libs dbus-glib-1)\ -)) -endif - $(eval $(call gb_Library_add_libs,vclplug_gtk3,\ $$(GTK3_LIBS) \ $$(GTHREAD_LIBS) \ @@ -92,6 +79,10 @@ $(eval $(call gb_Library_add_linked_libs,vclplug_gtk3,\ $(gb_STDLIBS) \ )) +$(eval $(call gb_Library_use_externals,vclplug_gtk,\ + dbus \ +)) + $(eval $(call gb_Library_add_exception_objects,vclplug_gtk3,\ vcl/unx/gtk3/a11y/gtk3atkaction \ vcl/unx/gtk3/a11y/gtk3atkbridge \ -- cgit From f65946944eca8da10d1e54a78eb2537e205e855c Mon Sep 17 00:00:00 2001 From: Joseph Powers Date: Wed, 2 Nov 2011 05:56:25 -0700 Subject: Remove an unused header from basctl --- basctl/source/basicide/bastype4.hxx | 69 ------------------------------------- 1 file changed, 69 deletions(-) delete mode 100644 basctl/source/basicide/bastype4.hxx diff --git a/basctl/source/basicide/bastype4.hxx b/basctl/source/basicide/bastype4.hxx deleted file mode 100644 index 000eec70755e..000000000000 --- a/basctl/source/basicide/bastype4.hxx +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _BASTYPE4_HXX -#define _BASTYPE4_HXX - - -#include - -class EditEngine; -class EditView; - -class ExtendedTabBar : public TabBar -{ - EditEngine* pEditEngine; - EditView* pEditView; - sal_Bool bIsInKeyInput; -#if _SOLAR__PRIVATE - void ImpCheckEditEngine( sal_Bool bKeepNewText ); -#endif -protected: - virtual void MouseButtonDown( const MouseEvent& rMEvt ); - virtual void MouseButtonUp( const MouseEvent& rMEvt ); - virtual void MouseMove( const MouseEvent& rMEvt ); - virtual void LoseFocus(); - virtual void KeyInput( const KeyEvent& rKEvent ); - virtual void Paint( const Rectangle& ); - - virtual sal_Bool StartRenamingTab( sal_uInt16 nCurId ); - virtual sal_Bool AllowRenamingTab( sal_uInt16 nCurId, const String& rNewName ); - virtual void TabRenamed( sal_uInt16 nCurId, const String& rNewName ); - -public: - ExtendedTabBar( Window* pParent, WinBits nStyle ); - ~ExtendedTabBar(); - - void RenameSelectedTab(); - sal_Bool IsInEditMode() const { return pEditEngine ? sal_True : sal_False; } - void StopEditMode( sal_Bool bKeepCurText = sal_False ); -}; - -#endif //_BASTYPE4_HXX - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit From 8c4b9f7c6bdecca8ec405272a23c7ca35ca0617e Mon Sep 17 00:00:00 2001 From: Felix Zhang Date: Wed, 2 Nov 2011 18:47:32 +0800 Subject: remove unused methods in layout --- toolkit/inc/layout/layout-post.hxx | 23 - toolkit/inc/layout/layout-pre.hxx | 29 +- toolkit/inc/layout/layout.hxx | 346 +--- toolkit/source/layout/vcl/wbutton.cxx | 447 +---- toolkit/source/layout/vcl/wcontainer.cxx | 135 -- toolkit/source/layout/vcl/wfield.cxx | 407 ----- toolkit/source/layout/vcl/wrapper.cxx | 405 +---- toolkit/workben/controls.cxx | 272 --- toolkit/workben/layout/.gitignore | 4 - toolkit/workben/layout/README | 43 - toolkit/workben/layout/TEST | 11 - toolkit/workben/layout/adjust.xml | 44 - toolkit/workben/layout/align-test.xml | 30 - toolkit/workben/layout/align.xml | 44 - toolkit/workben/layout/boxtest.xml | 36 - toolkit/workben/layout/dialogbuttons-ok.xml | 49 - toolkit/workben/layout/dialogbuttons-reset.xml | 54 - toolkit/workben/layout/dialogbuttons-save.xml | 49 - toolkit/workben/layout/dialogbuttons-yes.xml | 49 - toolkit/workben/layout/editor-normal.xml | 53 - toolkit/workben/layout/editor.cxx | 1856 -------------------- toolkit/workben/layout/editor.hxx | 51 - toolkit/workben/layout/editor.xml | 52 - toolkit/workben/layout/empty.xml | 26 - toolkit/workben/layout/flow-container.xml | 48 - toolkit/workben/layout/flow.xml | 17 - toolkit/workben/layout/insert-sheet.xml | 57 - toolkit/workben/layout/interactable-containers.xml | 49 - toolkit/workben/layout/layout-flat.xml | 14 - toolkit/workben/layout/layout.xml | 15 - toolkit/workben/layout/message-box.xml | 41 - toolkit/workben/layout/more.xml | 19 - toolkit/workben/layout/move-copy-sheet.xml | 21 - .../workben/layout/non-interactable-containers.xml | 41 - toolkit/workben/layout/number-format.xml | 65 - toolkit/workben/layout/numeric.xml | 10 - toolkit/workben/layout/ooo-patch | 7 - toolkit/workben/layout/paragraph.xml | 77 - toolkit/workben/layout/plugin.cxx | 68 - toolkit/workben/layout/plugin.hxx | 59 - toolkit/workben/layout/plugin.xml | 29 - toolkit/workben/layout/radio-groups.xml | 21 - toolkit/workben/layout/recover.cxx | 113 -- toolkit/workben/layout/recover.hxx | 81 - toolkit/workben/layout/recover.xml | 67 - toolkit/workben/layout/refresh | 7 - toolkit/workben/layout/run-s2x | 6 - toolkit/workben/layout/scroller.xml | 32 - toolkit/workben/layout/sequence.xml | 13 - toolkit/workben/layout/shutdown.xml | 54 - toolkit/workben/layout/simple-paragraph.cxx | 183 -- toolkit/workben/layout/simple-paragraph.hxx | 55 - toolkit/workben/layout/simple-paragraph.xml | 11 - toolkit/workben/layout/sort-options.xml | 40 - toolkit/workben/layout/sortdlg.cxx | 72 - toolkit/workben/layout/sortdlg.hrc | 71 - toolkit/workben/layout/sortdlg.hxx | 76 - toolkit/workben/layout/sortdlg.src | 331 ---- toolkit/workben/layout/sortdlg.xml | 65 - toolkit/workben/layout/splitter.xml | 13 - toolkit/workben/layout/string-input.xml | 16 - toolkit/workben/layout/tab-dialog.xml | 20 - toolkit/workben/layout/tabcontrol.xml | 18 - toolkit/workben/layout/table.xml | 15 - toolkit/workben/layout/test.cxx | 369 ---- toolkit/workben/layout/test.xml | 12 - toolkit/workben/layout/testrc.in | 8 - toolkit/workben/layout/tpsort.cxx | 1107 ------------ toolkit/workben/layout/tpsort.hxx | 219 --- toolkit/workben/layout/un-test.sh | 14 - toolkit/workben/layout/uno.hxx | 109 -- toolkit/workben/layout/wordcount-plain.xml | 37 - toolkit/workben/layout/wordcount-tight.xml | 43 - toolkit/workben/layout/wordcount.xml | 59 - toolkit/workben/layout/wordcountdialog.cxx | 111 -- toolkit/workben/layout/wordcountdialog.hxx | 70 - toolkit/workben/layout/zoom-1.xml | 38 - toolkit/workben/layout/zoom-2.xml | 39 - toolkit/workben/layout/zoom-indent.xml | 41 - toolkit/workben/layout/zoom-plain.xml | 20 - toolkit/workben/layout/zoom.cxx | 614 ------- toolkit/workben/layout/zoom.hrc | 53 - toolkit/workben/layout/zoom.hxx | 121 -- toolkit/workben/layout/zoom.xml | 60 - toolkit/workben/layout/zoom_def.hxx | 38 - toolkit/workben/no_localization | 1 - toolkit/workben/unodialog.cxx | 270 --- unusedcode.easy | 217 --- 88 files changed, 60 insertions(+), 10142 deletions(-) delete mode 100644 toolkit/workben/controls.cxx delete mode 100644 toolkit/workben/layout/.gitignore delete mode 100644 toolkit/workben/layout/README delete mode 100755 toolkit/workben/layout/TEST delete mode 100644 toolkit/workben/layout/adjust.xml delete mode 100644 toolkit/workben/layout/align-test.xml delete mode 100644 toolkit/workben/layout/align.xml delete mode 100644 toolkit/workben/layout/boxtest.xml delete mode 100644 toolkit/workben/layout/dialogbuttons-ok.xml delete mode 100644 toolkit/workben/layout/dialogbuttons-reset.xml delete mode 100644 toolkit/workben/layout/dialogbuttons-save.xml delete mode 100644 toolkit/workben/layout/dialogbuttons-yes.xml delete mode 100644 toolkit/workben/layout/editor-normal.xml delete mode 100644 toolkit/workben/layout/editor.cxx delete mode 100644 toolkit/workben/layout/editor.hxx delete mode 100644 toolkit/workben/layout/editor.xml delete mode 100644 toolkit/workben/layout/empty.xml delete mode 100644 toolkit/workben/layout/flow-container.xml delete mode 100644 toolkit/workben/layout/flow.xml delete mode 100644 toolkit/workben/layout/insert-sheet.xml delete mode 100644 toolkit/workben/layout/interactable-containers.xml delete mode 100644 toolkit/workben/layout/layout-flat.xml delete mode 100644 toolkit/workben/layout/layout.xml delete mode 100644 toolkit/workben/layout/message-box.xml delete mode 100644 toolkit/workben/layout/more.xml delete mode 100644 toolkit/workben/layout/move-copy-sheet.xml delete mode 100644 toolkit/workben/layout/non-interactable-containers.xml delete mode 100644 toolkit/workben/layout/number-format.xml delete mode 100644 toolkit/workben/layout/numeric.xml delete mode 100644 toolkit/workben/layout/ooo-patch delete mode 100644 toolkit/workben/layout/paragraph.xml delete mode 100644 toolkit/workben/layout/plugin.cxx delete mode 100644 toolkit/workben/layout/plugin.hxx delete mode 100644 toolkit/workben/layout/plugin.xml delete mode 100644 toolkit/workben/layout/radio-groups.xml delete mode 100644 toolkit/workben/layout/recover.cxx delete mode 100644 toolkit/workben/layout/recover.hxx delete mode 100644 toolkit/workben/layout/recover.xml delete mode 100644 toolkit/workben/layout/refresh delete mode 100644 toolkit/workben/layout/run-s2x delete mode 100644 toolkit/workben/layout/scroller.xml delete mode 100644 toolkit/workben/layout/sequence.xml delete mode 100644 toolkit/workben/layout/shutdown.xml delete mode 100644 toolkit/workben/layout/simple-paragraph.cxx delete mode 100644 toolkit/workben/layout/simple-paragraph.hxx delete mode 100644 toolkit/workben/layout/simple-paragraph.xml delete mode 100644 toolkit/workben/layout/sort-options.xml delete mode 100644 toolkit/workben/layout/sortdlg.cxx delete mode 100644 toolkit/workben/layout/sortdlg.hrc delete mode 100644 toolkit/workben/layout/sortdlg.hxx delete mode 100644 toolkit/workben/layout/sortdlg.src delete mode 100644 toolkit/workben/layout/sortdlg.xml delete mode 100644 toolkit/workben/layout/splitter.xml delete mode 100644 toolkit/workben/layout/string-input.xml delete mode 100644 toolkit/workben/layout/tab-dialog.xml delete mode 100644 toolkit/workben/layout/tabcontrol.xml delete mode 100644 toolkit/workben/layout/table.xml delete mode 100644 toolkit/workben/layout/test.cxx delete mode 100644 toolkit/workben/layout/test.xml delete mode 100644 toolkit/workben/layout/testrc.in delete mode 100644 toolkit/workben/layout/tpsort.cxx delete mode 100644 toolkit/workben/layout/tpsort.hxx delete mode 100644 toolkit/workben/layout/un-test.sh delete mode 100644 toolkit/workben/layout/uno.hxx delete mode 100644 toolkit/workben/layout/wordcount-plain.xml delete mode 100644 toolkit/workben/layout/wordcount-tight.xml delete mode 100644 toolkit/workben/layout/wordcount.xml delete mode 100644 toolkit/workben/layout/wordcountdialog.cxx delete mode 100644 toolkit/workben/layout/wordcountdialog.hxx delete mode 100644 toolkit/workben/layout/zoom-1.xml delete mode 100644 toolkit/workben/layout/zoom-2.xml delete mode 100644 toolkit/workben/layout/zoom-indent.xml delete mode 100644 toolkit/workben/layout/zoom-plain.xml delete mode 100644 toolkit/workben/layout/zoom.cxx delete mode 100644 toolkit/workben/layout/zoom.hrc delete mode 100644 toolkit/workben/layout/zoom.hxx delete mode 100644 toolkit/workben/layout/zoom.xml delete mode 100644 toolkit/workben/layout/zoom_def.hxx delete mode 100644 toolkit/workben/no_localization delete mode 100644 toolkit/workben/unodialog.cxx diff --git a/toolkit/inc/layout/layout-post.hxx b/toolkit/inc/layout/layout-post.hxx index 46d4c383a984..da9a052e1b6b 100644 --- a/toolkit/inc/layout/layout-post.hxx +++ b/toolkit/inc/layout/layout-post.hxx @@ -35,45 +35,24 @@ #undef _LAYOUT_PRE_HXX -#undef AdvancedButton -#undef ApplyButton #undef Box #undef Button #undef CancelButton -#undef CheckBox -#undef ComboBox #undef Container #undef Control #undef Dialog #undef Edit -#undef ErrorBox #undef FixedImage -#undef FixedInfo -#undef FixedLine #undef FixedText -#undef HBox #undef HelpButton #undef IgnoreButton -#undef ImageButton -#undef InfoBox #undef ListBox #undef MessBox #undef MessageBox -#undef MetricField #undef MetricFormatter -#undef MoreButton -#undef MultiLineEdit -#undef MultiListBox #undef NoButton -#undef NumericField #undef NumericFormatter -#undef OKButton -#undef Plugin -#undef ProgressBar #undef PushButton -#undef QueryBox -#undef RadioButton -#undef ResetButton #undef RetryButton #undef SfxTabDialog #undef SfxTabPage @@ -84,8 +63,6 @@ #undef TabControl #undef TabPage #undef Table -#undef VBox -#undef WarningBox #undef YesButton #undef SvxFontListBox diff --git a/toolkit/inc/layout/layout-pre.hxx b/toolkit/inc/layout/layout-pre.hxx index 4205a44f1f54..9f6b59e3ab2f 100644 --- a/toolkit/inc/layout/layout-pre.hxx +++ b/toolkit/inc/layout/layout-pre.hxx @@ -34,57 +34,32 @@ ///* Allow re-inclusion for next hxx file. */ #undef _LAYOUT_POST_HXX -#define AdvancedButton layout::AdvancedButton -#define ApplyButton layout::ApplyButton #define Box layout::Box #define Button layout::Button #define CancelButton layout::CancelButton -#define CheckBox layout::CheckBox -#define ComboBox layout::ComboBox #define Container layout::Container #define Control layout::Control #define Dialog layout::Dialog #define Edit layout::Edit -#define ErrorBox layout::ErrorBox #define FixedImage layout::FixedImage -#define FixedInfo layout::FixedInfo -#define FixedLine layout::FixedLine #define FixedText layout::FixedText -#define HBox layout::HBox #define HelpButton layout::HelpButton #define IgnoreButton layout::IgnoreButton -#define ImageButton layout::ImageButton -#define InfoBox layout::InfoBox -#define LocalizedString layout::LocalizedString #define ListBox layout::ListBox #define MessBox layout::MessBox #define MessageBox layout::MessageBox -#define MetricField layout::MetricField #define MetricFormatter layout::MetricFormatter -#define MoreButton layout::MoreButton -#define MultiLineEdit layout::MultiLineEdit -#define MultiListBox layout::MultiListBox #define NoButton layout::NoButton -#define NumericField layout::NumericField #define NumericFormatter layout::NumericFormatter -#define OKButton layout::OKButton -#define Plugin layout::Plugin -#define ProgressBar layout::ProgressBar #define PushButton layout::PushButton -#define QueryBox layout::QueryBox -#define RadioButton layout::RadioButton -#define ResetButton layout::ResetButton #define RetryButton layout::RetryButton #define SfxTabDialog layout::SfxTabDialog #define SfxTabPage layout::SfxTabPage #define SvxFontListBox layout::SvxFontListBox #define SvxLanguageBox layout::SvxLanguageBox -#define SpinField layout::SpinField #define TabControl layout::TabControl #define TabPage layout::TabPage #define Table layout::Table -#define VBox layout::VBox -#define WarningBox layout::WarningBox #define YesButton layout::YesButton #define ModalDialog Dialog @@ -97,12 +72,10 @@ #define Window ::Window -#else +#endif /* ENABLE_LAYOUT */ #define LocalizedString String -#endif /* ENABLE_LAYOUT */ - #endif /* _LAYOUT_PRE_HXX */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/layout/layout.hxx b/toolkit/inc/layout/layout.hxx index de53a4687ddb..e2f8d76d032c 100644 --- a/toolkit/inc/layout/layout.hxx +++ b/toolkit/inc/layout/layout.hxx @@ -38,13 +38,11 @@ #include #include #include -#include #include #include #include class Button; -class ComboBox; class Color; class Control; class Dialog; @@ -53,16 +51,12 @@ class Font; class Image; class ListBox; class MapMode; -class MultiListBox; -class NotifyEvent; class Pointer; class PushButton; -class RadioButton; class ResId; struct SfxChildWinInfo; class TabControl; class TabPage; -class VCLXRadioButton; class VCLXWindow; class Window; @@ -89,8 +83,6 @@ public: Context( char const* pPath ); virtual ~Context(); PeerHandle GetPeerHandle( char const* id, sal_uInt32 nId = 0 ) const; - void setToplevel( PeerHandle xToplevel ); - PeerHandle getToplevel(); PeerHandle getRoot(); }; @@ -195,28 +187,16 @@ class TOOLKIT_DLLPUBLIC Control : public Window public: ~Control (); void SetGetFocusHdl (Link const& link); - Link& GetGetFocusHdl (); void SetLoseFocusHdl (Link const& link); - Link& GetLoseFocusHdl (); -}; - -class FixedLineImpl; -class TOOLKIT_DLLPUBLIC FixedLine : public Control -{ - DECL_GET_IMPL( FixedLine ); - DECL_CONSTRUCTORS( FixedLine, Control, WB_HORZ ); - -public: - bool IsEnabled() const; }; class FixedTextImpl; class TOOLKIT_DLLPUBLIC FixedText : public Control { DECL_GET_IMPL( FixedText ); - DECL_CONSTRUCTORS( FixedText, Control, 0 ); public: + FixedText( Context *context, char const* id, sal_uInt32 nId = 0 ); ~FixedText (); void SetText( rtl::OUString const& rStr ); }; @@ -225,16 +205,9 @@ class FixedImageImpl; class TOOLKIT_DLLPUBLIC FixedImage : public Control { DECL_GET_IMPL( FixedImage ); - DECL_CONSTRUCTORS( FixedImage, Control, 0 ); -public: - void setImage( ::Image const& ); -}; -class FixedInfoImpl; -class TOOLKIT_DLLPUBLIC FixedInfo : public FixedText -{ - DECL_GET_IMPL( FixedInfo ); - DECL_CONSTRUCTORS( FixedInfo, FixedText, 0 ); +public: + FixedImage( Context *context, char const* id, sal_uInt32 nId = 0 ); }; class ImageImpl; @@ -242,8 +215,6 @@ class TOOLKIT_DLLPUBLIC Image { ImageImpl *pImpl; public: - Image( char const* pName ); - ~Image(); ImageImpl &getImpl() const { return *pImpl; } }; @@ -258,133 +229,55 @@ public: ~Button (); static String GetStandardText (sal_uInt16 button_type); void SetText( rtl::OUString const& rStr ); - bool SetModeImage (Image const& image); - bool SetModeImage (::Image const& image); - void SetImageAlign( ImageAlign eAlign ); - void SetClickHdl( Link const& rLink ); virtual void Click() /* pure virtual? */; - Link& GetClickHdl (); }; class PushButtonImpl; class TOOLKIT_DLLPUBLIC PushButton : public Button { DECL_GET_IMPL( PushButton ); - DECL_CONSTRUCTORS( PushButton, Button, 0 ); DECL_GET_WINDOW (PushButton); +protected: + explicit PushButton( WindowImpl *pImpl ) : Button( pImpl ) {} + public: ~PushButton (); void Check( bool bCheck=true ); - bool IsChecked() const; - void Toggle(); void SetToggleHdl( Link const& rLink ); }; -class TOOLKIT_DLLPUBLIC OKButton : public PushButton -{ - DECL_CONSTRUCTORS( OKButton, PushButton, WB_DEFBUTTON ); -}; class TOOLKIT_DLLPUBLIC CancelButton : public PushButton { - DECL_CONSTRUCTORS( CancelButton, PushButton, 0 ); +public: + CancelButton( Context *context, char const* id, sal_uInt32 nId = 0 ); }; class TOOLKIT_DLLPUBLIC YesButton : public PushButton { - DECL_CONSTRUCTORS( YesButton, PushButton, WB_DEFBUTTON ); +public: + YesButton( Context *context, char const* id, sal_uInt32 nId = 0 ); }; class TOOLKIT_DLLPUBLIC NoButton : public PushButton { - DECL_CONSTRUCTORS( NoButton, PushButton, 0 ); +public: + NoButton( Context *context, char const* id, sal_uInt32 nId = 0 ); }; class TOOLKIT_DLLPUBLIC RetryButton : public PushButton { - DECL_CONSTRUCTORS( RetryButton, PushButton, 0 ); +public: + RetryButton( Context *context, char const* id, sal_uInt32 nId = 0 ); }; class TOOLKIT_DLLPUBLIC IgnoreButton : public PushButton { - DECL_CONSTRUCTORS( IgnoreButton, PushButton, 0 ); -}; -class TOOLKIT_DLLPUBLIC ResetButton : public PushButton -{ - DECL_CONSTRUCTORS( ResetButton, PushButton, 0 ); -}; -class TOOLKIT_DLLPUBLIC ApplyButton : public PushButton -{ - DECL_CONSTRUCTORS( ApplyButton, PushButton, 0 ); -}; -class TOOLKIT_DLLPUBLIC HelpButton : public PushButton -{ - DECL_CONSTRUCTORS( HelpButton, PushButton, 0 ); -}; -class TOOLKIT_DLLPUBLIC ImageButton : public PushButton -{ - DECL_CONSTRUCTORS( ImageButton, PushButton, 0 ); -}; - -class AdvancedButtonImpl; -class TOOLKIT_DLLPUBLIC AdvancedButton : public PushButton -{ - DECL_CONSTRUCTORS( AdvancedButton, PushButton, 0 ); - DECL_GET_IMPL( AdvancedButton ); - - void AddAdvanced( Window* w ); - void AddSimple( Window* w ); - void RemoveAdvanced( Window* w ); - void RemoveSimple( Window* w ); - - void SetAdvancedText (rtl::OUString const& text); - void SetSimpleText (rtl::OUString const& text); - rtl::OUString GetAdvancedText () const; - rtl::OUString GetSimpleText () const; - void SetDelta (int); -}; - -class MoreButtonImpl; -class TOOLKIT_DLLPUBLIC MoreButton : public AdvancedButton -{ - DECL_CONSTRUCTORS( MoreButton, AdvancedButton, 0 ); - DECL_GET_IMPL( MoreButton ); - void AddWindow( Window* w ); - void RemoveWindow( Window* w ); - - void SetMoreText (rtl::OUString const& text); - void SetLessText (rtl::OUString const& text); - rtl::OUString GetMoreText () const; - rtl::OUString GetLessText () const; -}; - -class RadioButtonImpl; -class TOOLKIT_DLLPUBLIC RadioButton : public Button -{ - DECL_GET_IMPL( RadioButton ); - DECL_CONSTRUCTORS( RadioButton, Button, 0 ); - DECL_GET_WINDOW( RadioButton ); - DECL_GET_VCLXWINDOW( RadioButton ); public: - ~RadioButton (); - void Check( bool bCheck=true ); - bool IsChecked() const; - - void Toggle(); - void SetToggleHdl( Link const& rLink ); + IgnoreButton( Context *context, char const* id, sal_uInt32 nId = 0 ); }; - -class CheckBoxImpl; -class TOOLKIT_DLLPUBLIC CheckBox : public Button +class TOOLKIT_DLLPUBLIC HelpButton : public PushButton { - DECL_GET_IMPL( CheckBox ); - DECL_CONSTRUCTORS( CheckBox, Button, 0 ); - public: - ~CheckBox (); - void Check( bool bCheck=true ); - bool IsChecked() const; - - void Toggle(); - void SetToggleHdl( Link const& rLink ); + HelpButton( Context *context, char const* id, sal_uInt32 nId = 0 ); }; class EditImpl; @@ -396,24 +289,7 @@ class TOOLKIT_DLLPUBLIC Edit : public Control public: ~Edit (); - void SetText( rtl::OUString const& rStr ); - String GetText() const; void SetModifyHdl( Link const& rLink ); - void SetSelection( Selection const& rSelection ); -}; - -class MultiLineEditImpl; -class TOOLKIT_DLLPUBLIC MultiLineEdit : public Edit -{ - DECL_GET_IMPL( MultiLineEdit ); - DECL_CONSTRUCTORS( MultiLineEdit, Edit, WB_LEFT|WB_BORDER ); -}; - -class SpinFieldImpl; -class TOOLKIT_DLLPUBLIC SpinField : public Edit -{ - DECL_GET_IMPL( SpinField ); - DECL_CONSTRUCTORS( SpinField, Edit, 0 ); }; class FormatterBaseImpl; @@ -430,24 +306,6 @@ class TOOLKIT_DLLPUBLIC NumericFormatter : public FormatterBase protected: explicit NumericFormatter( FormatterBaseImpl *pImpl ); NumericFormatterImpl &getFormatImpl() const; -public: - void SetMin( sal_Int64 nNewMin ); - void SetMax( sal_Int64 nNewMax ); - void SetFirst( sal_Int64 nNewFirst ); - void SetLast( sal_Int64 nNewLast ); - void SetSpinSize( sal_Int64 nNewSize ); - - void SetValue( sal_Int64 nNewValue ); - sal_Int64 GetValue() const; -}; - -class NumericFieldImpl; -class TOOLKIT_DLLPUBLIC NumericField : public SpinField, public NumericFormatter -{ - DECL_GET_IMPL( NumericField ); -public: - NumericField( Context *context, char const* id, sal_uInt32 nId=0 ); - NumericField( Window *parent, WinBits nStyle ); }; class MetricFormatterImpl; @@ -457,47 +315,6 @@ class TOOLKIT_DLLPUBLIC MetricFormatter : public FormatterBase protected: explicit MetricFormatter( FormatterBaseImpl *pImpl ); MetricFormatterImpl &getFormatImpl() const; -public: - void SetMin( sal_Int64 nNewMin, FieldUnit nUnit=FUNIT_NONE ); - void SetMax( sal_Int64 nNewMax, FieldUnit nUnit=FUNIT_NONE ); - void SetFirst( sal_Int64 nNewFirst, FieldUnit nUnit=FUNIT_NONE ); - void SetLast( sal_Int64 nNewLast, FieldUnit nUnit=FUNIT_NONE ); - void SetValue( sal_Int64 nNewValue, FieldUnit nUnit=FUNIT_NONE ); - sal_Int64 GetValue( FieldUnit nUnit=FUNIT_NONE ) const; - - void SetSpinSize( sal_Int64 nNewSize ); -}; - -class MetricFieldImpl; -class TOOLKIT_DLLPUBLIC MetricField : public SpinField, public MetricFormatter -{ - DECL_GET_IMPL( MetricField ); -public: - MetricField( Context *context, char const* id, sal_uInt32 nId=0 ); - MetricField( Window *parent, WinBits nStyle ); -}; - -class ComboBoxImpl; -class TOOLKIT_DLLPUBLIC ComboBox : public Edit -{ - DECL_GET_IMPL( ComboBox ); - DECL_GET_WINDOW (ComboBox ); - DECL_CONSTRUCTORS( ComboBox, Edit, 0 ); - -public: - ~ComboBox (); - sal_uInt16 InsertEntry( String const& rStr, sal_uInt16 nPos=COMBOBOX_APPEND ); - void RemoveEntry( String const& rStr ); - void RemoveEntry( sal_uInt16 nPos ); - void Clear(); - - sal_uInt16 GetEntryPos( String const& rStr ) const; - String GetEntry( sal_uInt16 nPos ) const; - sal_uInt16 GetEntryCount() const; - - void SetClickHdl( Link const& rLink ); - void SetSelectHdl( Link const& rLink ); - void EnableAutocomplete (bool enable, bool matchCase=false ); }; class ListBoxImpl; @@ -509,46 +326,17 @@ class TOOLKIT_DLLPUBLIC ListBox : public Control public: ~ListBox (); - sal_uInt16 InsertEntry( String const& rStr, sal_uInt16 nPos=LISTBOX_APPEND ); - - void RemoveEntry( String const& rStr ); - void RemoveEntry( sal_uInt16 nPos ); - void Clear(); sal_uInt16 GetEntryPos( String const& rStr ) const; String GetEntry( sal_uInt16 nPos ) const; - sal_uInt16 GetEntryCount() const; - void SelectEntry( String const& rStr, bool bSelect=true ); void SelectEntryPos( sal_uInt16 nPos, bool bSelect=true ); - sal_uInt16 GetSelectEntryCount() const; - String GetSelectEntry( sal_uInt16 nSelIndex=0 ) const; sal_uInt16 GetSelectEntryPos( sal_uInt16 nSelIndex=0 ) const; - void SetSelectHdl (Link const& link); - Link& GetSelectHdl (); - - void SetClickHdl (Link const& link); - Link& GetClickHdl (); - - void SetDoubleClickHdl (Link const& link); - Link& GetDoubleClickHdl (); - - void SetEntryData (sal_uInt16 pos, void* data); - void* GetEntryData (sal_uInt16 pos) const; - virtual void SetNoSelection (); }; -class MultiListBoxImpl; -class TOOLKIT_DLLPUBLIC MultiListBox : public ListBox -{ - DECL_GET_IMPL( MultiListBox ); - DECL_CONSTRUCTORS( MultiListBox, ListBox, 0 ); - DECL_GET_WINDOW( MultiListBox ); -}; - class DialogImpl; class TOOLKIT_DLLPUBLIC Dialog : public Context, public Window { @@ -556,19 +344,14 @@ class TOOLKIT_DLLPUBLIC Dialog : public Context, public Window public: DECL_GET_IMPL (Dialog); - Dialog( Window *parent, char const* xml_file, char const* id, sal_uInt32 nId=0 ); Dialog( ::Window *parent, char const* xml_file, char const* id, sal_uInt32 nId=0 ); ~Dialog (); virtual short Execute(); void EndDialog( long nResult=0 ); - void SetText( rtl::OUString const& rStr ); void SetTitle (rtl::OUString const& rStr ); - bool Close (); - long Notify (NotifyEvent & event); // Sxf*Dialog bool bConstruct; - void Initialize (SfxChildWinInfo*); }; #define DECL_MESSAGE_BOX_CTORS(Name)\ @@ -624,8 +407,6 @@ protected: typedef MessageBox MessBox; CLASS_MESSAGE_BOX (Error); CLASS_MESSAGE_BOX (Info); -CLASS_MESSAGE_BOX (Query); -CLASS_MESSAGE_BOX (Warning); #undef CLASS_MESSAGE_BOX @@ -639,27 +420,13 @@ class TOOLKIT_DLLPUBLIC TabControl : public Control //#endif /* !TAB_APPEND */ DECL_GET_IMPL (TabControl); - DECL_CONSTRUCTORS (TabControl, Control, 0); DECL_GET_WINDOW (TabControl); - DECL_GET_LAYOUT_VCLXWINDOW (TabControl); public: ~TabControl (); - void InsertPage (sal_uInt16 id, rtl::OUString const& title, sal_uInt16 pos=TAB_APPEND); - void RemovePage (sal_uInt16 id); - sal_uInt16 GetPageCount () const; - sal_uInt16 GetPageId (sal_uInt16 pos) const; - sal_uInt16 GetPagePos (sal_uInt16 id) const; void SetCurPageId (sal_uInt16 id); - sal_uInt16 GetCurPageId () const; - void SetTabPage (sal_uInt16 id, ::TabPage* page); - ::TabPage* GetTabPage (sal_uInt16 id) const; void SetActivatePageHdl (Link const& link); - Link& GetActivatePageHdl () const; void SetDeactivatePageHdl (Link const& link); - Link& GetDeactivatePageHdl () const; - void SetTabPageSizePixel (Size const& size); - Size GetTabPageSizePixel () const; }; class TabPageImpl; @@ -670,27 +437,12 @@ public: static ::Window* global_parent; static TabControl* global_tabcontrol; - TabPage( Window *parent, char const* xml_file, char const* id, sal_uInt32 nId=0 ); - TabPage( ::Window *parent, char const* xml_file, char const* id, sal_uInt32 nId=0 ); ~TabPage(); DECL_GET_WINDOW( TabPage ); virtual void ActivatePage(); virtual void DeactivatePage(); }; -class ProgressBarImpl; -class TOOLKIT_DLLPUBLIC ProgressBar : public Control -{ - DECL_GET_IMPL( ProgressBar ); - DECL_CONSTRUCTORS( ProgressBar, Control, WB_BORDER ); -public: - void SetForegroundColor( css::util::Color color ); - void SetBackgroundColor( css::util::Color color ); - void SetValue( sal_Int32 i ); - void SetRange( sal_Int32 min, sal_Int32 max ); - sal_Int32 GetValue(); -}; - // ----------------------------------------------------------------- // layout container / helper wrappers // ----------------------------------------------------------------- @@ -703,18 +455,10 @@ protected: public: Container( Context const* context, char const* id ); - void Add( Window *pWindow ); - void Add( Container *pContainer ); - - void Remove( Window *pWindow ); - void Remove( Container *pContainer ); - void Clear(); // we can't really do a GetChildren() as they don't have a common class, // besides we would need to keep track of children, uh void ShowAll( bool bVisible ); - void Show(); - void Hide(); css::uno::Reference< css::awt::XLayoutContainer > getImpl() { return mxContainer; } @@ -722,16 +466,6 @@ public: class TOOLKIT_DLLPUBLIC Table : public Container { -protected: - Table( sal_Int32 nBorder, sal_Int32 nColumns ); -public: - Table( Context const* context, char const* id ); - void Add( Window *pWindow, bool bXExpand, bool bYExpand, - sal_Int32 nXSpan=1, sal_Int32 nYSpan=1 ); - void Add( Container *pContainer, bool bXExpand, bool bYExpand, - sal_Int32 nXSpan=1, sal_Int32 nYSpan=1 ); - -private: void setProps( css::uno::Reference< css::awt::XLayoutConstrains > xChild, bool bXExpand, bool bYExpand, sal_Int32 nXSpan, sal_Int32 nYSpan ); }; @@ -742,64 +476,18 @@ protected: Box( rtl::OUString const& rName, sal_Int32 nBorder, bool bHomogeneous ); public: Box( Context const* context, char const* id ); - void Add( Window *pWindow, bool bExpand, bool bFill, sal_Int32 nPadding); - void Add( Container *pContainer, bool bExpand, bool bFill, sal_Int32 nPadding); private: void setProps( css::uno::Reference< css::awt::XLayoutConstrains > xChild, bool bXExpand, bool bYExpand, sal_Int32 nPadding ); }; -class TOOLKIT_DLLPUBLIC HBox : public Box -{ -public: - HBox( Context const* context, char const* id ); - HBox( sal_Int32 nBorder, bool bHomogeneous ); -}; -class TOOLKIT_DLLPUBLIC VBox : public Box -{ -public: - VBox( Context const* context, char const* id ); - VBox( sal_Int32 nBorder, bool bHomogeneous ); -}; - -class PluginImpl; -class TOOLKIT_DLLPUBLIC Plugin : public Control -{ - DECL_GET_IMPL( Plugin ); -public: - ::Control *mpPlugin; - Plugin( Context *context, char const* id, ::Control *plugin ); -}; - -class LocalizedStringImpl; -class TOOLKIT_DLLPUBLIC LocalizedString : public Window -{ - DECL_GET_IMPL( LocalizedString ); - -public: - LocalizedString( Context *context, char const* id ); - - rtl::OUString operator= (rtl::OUString const&); - rtl::OUString operator+= (sal_Unicode ); - rtl::OUString operator+= (rtl::OUString const&); - - operator rtl::OUString (); - operator rtl::OUString const& (); - operator String(); - String getString (); - rtl::OUString getOUString (); - String GetToken (sal_uInt16 i, sal_Char c); -}; - class InPlugImpl; class TOOLKIT_DLLPUBLIC InPlug : public Context, public Window { DECL_GET_IMPL (InPlug); public: - InPlug ( Window *parent, char const* xml_file, char const* id, sal_uInt32 nId=0); - InPlug ( ::Window *parent, char const* xml_file, char const* id, sal_uInt32 nId=0); void ParentSet (Window *window); }; diff --git a/toolkit/source/layout/vcl/wbutton.cxx b/toolkit/source/layout/vcl/wbutton.cxx index 5c72b1707f3d..f3272dcc1c85 100644 --- a/toolkit/source/layout/vcl/wbutton.cxx +++ b/toolkit/source/layout/vcl/wbutton.cxx @@ -31,8 +31,6 @@ #include #include #include -#include -#include #include #include #include @@ -69,16 +67,6 @@ class ImageImpl } }; -Image::Image( const char *pName ) - : pImpl( new ImageImpl( pName ) ) -{ -} - -Image::~Image() -{ - delete pImpl; -} - class ButtonImpl : public ControlImpl , public ::cppu::WeakImplHelper1< awt::XActionListener > { @@ -150,38 +138,11 @@ void Button::SetText( OUString const& rStr ) getImpl().mxButton->setLabel( rStr ); } -void Button::SetClickHdl( const Link& link ) -{ - if (&getImpl () && getImpl().mxButton.is ()) - getImpl().SetClickHdl( link ); -} - -Link& Button::GetClickHdl () -{ - return getImpl().GetClickHdl (); -} - -bool Button::SetModeImage (Image const& image) -{ - return getImpl().SetModeImage (image.getImpl().mxGraphic); -} - -bool Button::SetModeImage (::Image const& image) -{ - return GetButton ()->SetModeImage (image); -} - -void Button::SetImageAlign( ImageAlign eAlign ) -{ - getImpl().setProperty( "ImageAlign", uno::Any( (sal_Int16) eAlign ) ); -} - void Button::Click() { } IMPL_GET_IMPL( Button ); -IMPL_CONSTRUCTORS( Button, Control, "button" ); IMPL_GET_WINDOW (Button); class PushButtonImpl : public ButtonImpl @@ -239,16 +200,6 @@ void PushButton::Check( bool bCheck ) getImpl().fireToggle(); } -bool PushButton::IsChecked() const -{ - return !!( getImpl().getProperty( "State" ).get< sal_Int16 >() ); -} - -void PushButton::Toggle() -{ - Check( true ); -} - void PushButton::SetToggleHdl( const Link& link ) { if (&getImpl () && getImpl().mxButton.is ()) @@ -256,173 +207,8 @@ void PushButton::SetToggleHdl( const Link& link ) } IMPL_GET_IMPL( PushButton ); -IMPL_CONSTRUCTORS( PushButton, Button, "pushbutton" ); IMPL_GET_WINDOW (PushButton); -class RadioButtonImpl : public ButtonImpl - , public ::cppu::WeakImplHelper1< awt::XItemListener > -{ - Link maToggleHdl; -public: - uno::Reference< awt::XRadioButton > mxRadioButton; - RadioButtonImpl( Context *context, const PeerHandle &peer, Window *window ) - : ButtonImpl( context, peer, window ) - , mxRadioButton( peer, uno::UNO_QUERY ) - { - } - - void Check( bool bCheck ) - { - if ( !mxRadioButton.is() ) - return; - - // Have setState fire item event for - // RadioGroups::RadioGroup::itemStateChanged () - ::RadioButton *r = static_cast(mpWindow)->GetRadioButton (); - bool state = r->IsRadioCheckEnabled (); - r->EnableRadioCheck(); - mxRadioButton->setState( !!bCheck ); - r->EnableRadioCheck (state); - fireToggle(); - } - - bool IsChecked() - { - if ( !mxRadioButton.is() ) - return false; - return mxRadioButton->getState(); - } - - void SetToggleHdl( const Link& link ) - { - if (!link && !!maToggleHdl) - mxRadioButton->removeItemListener( this ); - else if (!!link && !maToggleHdl) - mxRadioButton->addItemListener( this ); - maToggleHdl = link; - } - - inline void fireToggle() - { - maToggleHdl.Call( static_cast( mpWindow ) ); - } - - virtual void SetClickHdl( const Link& link ) - { - // Keep RadioGroups::RadioGroup's actionListener at HEAD - // of list. This way, it can handle RadioGroup's button - // states before all other callbacks and make sure the - // client code has the right state. - - // IWBN to add an XRadioButton2 and layout::VCLXRadioButton - // with {get,set}RadioGroup() (and a "radiogroup" property - // even) and handle the grouping here in RadioButtonImpl. - uno::Reference< uno::XInterface > x = static_cast (mpWindow->GetVCLXWindow ())->getFirstActionListener (); - uno::Reference< awt::XActionListener > a = uno::Reference< awt::XActionListener> (x ,uno::UNO_QUERY ); - mxButton->removeActionListener (a); - ButtonImpl::SetClickHdl (link); - mxButton->addActionListener (a); - } - - void SAL_CALL disposing( lang::EventObject const& e ) - throw (uno::RuntimeException) - { - ButtonImpl::disposing (e); - } - - virtual void SAL_CALL itemStateChanged( const awt::ItemEvent& ) - throw (uno::RuntimeException) - { - maToggleHdl.Call( static_cast( mpWindow ) ); - } -}; - -RadioButton::~RadioButton () -{ - SetToggleHdl (Link ()); -} - -void RadioButton::Check( bool bCheck ) -{ - getImpl().Check( bCheck ); -} - -bool RadioButton::IsChecked() const -{ - return getImpl().IsChecked(); -} - -void RadioButton::SetToggleHdl( const Link& link ) -{ - if (&getImpl () && getImpl().mxRadioButton.is ()) - getImpl().SetToggleHdl( link ); -} - -IMPL_GET_IMPL( RadioButton ); -IMPL_GET_WINDOW( RadioButton ); -IMPL_GET_VCLXWINDOW( RadioButton ); -IMPL_CONSTRUCTORS( RadioButton, Button, "radiobutton" ); - -class CheckBoxImpl : public ButtonImpl - , public ::cppu::WeakImplHelper1< awt::XItemListener > -{ - Link maToggleHdl; - public: - uno::Reference< awt::XCheckBox > mxCheckBox; - CheckBoxImpl( Context *context, const PeerHandle &peer, Window *window ) - : ButtonImpl( context, peer, window ) - , mxCheckBox( peer, uno::UNO_QUERY ) - { - } - - void SetToggleHdl( const Link& link ) - { - if (!link && !!maToggleHdl) - mxCheckBox->removeItemListener( this ); - else if (!!link && !maToggleHdl) - mxCheckBox->addItemListener( this ); - maToggleHdl = link; - } - void SAL_CALL disposing( lang::EventObject const& e ) - throw (uno::RuntimeException) - { - ButtonImpl::disposing (e); - } - virtual void SAL_CALL itemStateChanged( const awt::ItemEvent& ) - throw (uno::RuntimeException) - { - maToggleHdl.Call( static_cast( mpWindow ) ); - } -}; - -CheckBox::~CheckBox () -{ - SetToggleHdl (Link ()); -} - -void CheckBox::Check( bool bCheck ) -{ - if ( !getImpl().mxCheckBox.is() ) - return; - getImpl().mxCheckBox->setState( !!bCheck ); -} - -bool CheckBox::IsChecked() const -{ - if ( !getImpl().mxCheckBox.is() ) - return false; - return getImpl().mxCheckBox->getState() != 0; -} - -void CheckBox::SetToggleHdl( const Link& link ) -{ - if (&getImpl () && getImpl().mxCheckBox.is ()) - getImpl().SetToggleHdl( link ); -} - -IMPL_GET_IMPL( CheckBox ); -IMPL_CONSTRUCTORS( CheckBox, Button, "checkbox" ); - #define BUTTON_IMPL(t, parent, response) \ class t##Impl : public parent##Impl \ { \ @@ -447,232 +233,59 @@ IMPL_CONSTRUCTORS( CheckBox, Button, "checkbox" ); #define BUTTONID_RESET RET_RESET #define BUTTONID_APPLY RET_APPLY -BUTTON_IMPL( OKButton, PushButton, BUTTONID_OK ); BUTTON_IMPL( CancelButton, PushButton, BUTTONID_CANCEL ); BUTTON_IMPL( YesButton, PushButton, BUTTONID_YES ); BUTTON_IMPL( NoButton, PushButton, BUTTONID_NO ); BUTTON_IMPL( RetryButton, PushButton, BUTTONID_RETRY ); BUTTON_IMPL( IgnoreButton, PushButton, BUTTONID_IGNORE ); -BUTTON_IMPL( ResetButton, PushButton, BUTTONID_RESET ); -BUTTON_IMPL( ApplyButton, PushButton, BUTTONID_APPLY ); /* Deprecated? */ BUTTON_IMPL( HelpButton, PushButton, BUTTONID_HELP ); -IMPL_CONSTRUCTORS( OKButton, PushButton, "okbutton" ); -IMPL_CONSTRUCTORS( CancelButton, PushButton, "cancelbutton" ); -IMPL_CONSTRUCTORS( YesButton, PushButton, "yesbutton" ); -IMPL_CONSTRUCTORS( NoButton, PushButton, "nobutton" ); -IMPL_CONSTRUCTORS( RetryButton, PushButton, "retrybutton" ); -IMPL_CONSTRUCTORS( IgnoreButton, PushButton, "ignorebutton" ); -IMPL_CONSTRUCTORS( ResetButton, PushButton, "resetbutton" ); -IMPL_CONSTRUCTORS( ApplyButton, PushButton, "applybutton" ); /* Deprecated? */ -IMPL_CONSTRUCTORS( HelpButton, PushButton, "helpbutton" ); - -IMPL_IMPL (ImageButton, PushButton) - - -IMPL_CONSTRUCTORS( ImageButton, PushButton, "imagebutton" ); - -class AdvancedButtonImpl : public PushButtonImpl -{ -protected: - bool bAdvancedMode; - std::list< Window*> maAdvanced; - std::list< Window*> maSimple; - -public: - rtl::OUString mAdvancedLabel; - rtl::OUString mSimpleLabel; - -protected: - Window* Remove( std::list< Window*> lst, Window* w ) - { - for ( std::list< Window*>::iterator it = maAdvanced.begin(); - it != maAdvanced.end(); ++it ) - if ( *it == w ) - { - it = lst.erase( it ); - return *it; - } - return 0; - } - -public: - AdvancedButtonImpl( Context *context, PeerHandle const& peer, Window *window ) - : PushButtonImpl( context, peer, window ) - , bAdvancedMode( false ) - // TODO: i18n - // Button::GetStandardText( BUTTON_ADVANCED ); - // Button::GetStandardText( BUTTON_SIMPLE ); - , mAdvancedLabel( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Advanced...")) ) - , mSimpleLabel( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Simple...")) ) - { - } - void Click() - { - bAdvancedMode = !bAdvancedMode; - if ( bAdvancedMode ) - advancedMode(); - else - simpleMode(); - } - void setAlign () - { - ::PushButton *b = static_cast (mpWindow)->GetPushButton (); - b->SetSymbolAlign (SYMBOLALIGN_RIGHT); - b->SetSmallSymbol (); - //mpWindow->SetStyle (mpWindow->GetStyle() | WB_CENTER); - } - void advancedMode() - { - ::PushButton *b = static_cast (mpWindow)->GetPushButton (); - b->SetSymbol (SYMBOL_PAGEUP); - setAlign (); - if (mSimpleLabel.getLength ()) - b->SetText (mSimpleLabel); - for ( std::list< Window*>::iterator it = maAdvanced.begin(); - it != maAdvanced.end(); ++it ) - ( *it )->Show(); - for ( std::list< Window*>::iterator it = maSimple.begin(); - it != maSimple.end(); ++it ) - ( *it )->Hide(); - - redraw (); - } - void simpleMode() - { - //mxButton->setLabel( mSimpleLabel ); - ::PushButton *b = static_cast (mpWindow)->GetPushButton (); - b->SetSymbol (SYMBOL_PAGEDOWN); - if (mAdvancedLabel.getLength ()) - b->SetText (mAdvancedLabel); - setAlign (); - for ( std::list< Window*>::iterator it = maAdvanced.begin(); - it != maAdvanced.end(); ++it ) - ( *it )->Hide(); - for ( std::list< Window*>::iterator it = maSimple.begin(); - it != maSimple.end(); ++it ) - ( *it )->Show(); - - redraw (true); - } - void AddAdvanced( Window* w ) - { - maAdvanced.push_back( w ); - if ( !bAdvancedMode ) - w->Hide(); - } - void AddSimple( Window* w ) - { - maSimple.push_back( w ); - if ( bAdvancedMode ) - w->Hide(); - } - void RemoveAdvanced( Window* w ) - { - Remove( maAdvanced, w ); - } - void RemoveSimple( Window* w ) - { - Remove( maSimple, w ); - } -}; - -void AdvancedButton::AddAdvanced( Window* w ) -{ - getImpl().AddAdvanced( w ); -} - -void AdvancedButton::AddSimple( Window* w ) -{ - getImpl().AddSimple( w ); -} - -void AdvancedButton::RemoveAdvanced( Window* w ) -{ - getImpl().RemoveAdvanced( w ); -} - -void AdvancedButton::RemoveSimple( Window* w ) -{ - getImpl().RemoveSimple( w ); -} - -void AdvancedButton::SetAdvancedText (rtl::OUString const& text) -{ - if (text.getLength ()) - getImpl ().mAdvancedLabel = text; -} - -void AdvancedButton::SetSimpleText (rtl::OUString const& text) -{ - if (text.getLength ()) - getImpl ().mSimpleLabel = text; -} - -rtl::OUString AdvancedButton::GetAdvancedText () const -{ - return getImpl ().mAdvancedLabel; -} - -rtl::OUString AdvancedButton::GetSimpleText () const -{ - return getImpl ().mSimpleLabel; -} - -void AdvancedButton::SetDelta (int) -{ -} - -IMPL_CONSTRUCTORS_BODY( AdvancedButton, PushButton, "advancedbutton", getImpl().simpleMode () ); -IMPL_GET_IMPL( AdvancedButton ); - - -class MoreButtonImpl : public AdvancedButtonImpl -{ -public: - MoreButtonImpl( Context *context, PeerHandle const& peer, Window *window ) - : AdvancedButtonImpl( context, peer, window) - { - mSimpleLabel = Button::GetStandardText( BUTTON_MORE ); - mAdvancedLabel = Button::GetStandardText( BUTTON_LESS ); - } - void AddWindow( Window* w ) { AddAdvanced( w ); } - void RemoveWindow( Window* w ) { RemoveAdvanced( w ); } -}; - -// TODO -//BUTTON_IMPL( MoreButton, PushButton, 0 ); -IMPL_CONSTRUCTORS_BODY( MoreButton, AdvancedButton, "morebutton", getImpl().simpleMode () ); -IMPL_GET_IMPL( MoreButton ); - -void MoreButton::AddWindow( Window* w ) +CancelButton::CancelButton ( Context *context, char const* pId, sal_uInt32 nId ) + : PushButton( new CancelButtonImpl( context, context->GetPeerHandle( pId, nId ), this ) ) { - getImpl().AddWindow( w ); + Window *parent = dynamic_cast (context); + if (parent) + SetParent (parent); } -void MoreButton::RemoveWindow( Window* w ) +YesButton::YesButton ( Context *context, char const* pId, sal_uInt32 nId ) + : PushButton( new YesButtonImpl( context, context->GetPeerHandle( pId, nId ), this ) ) { - getImpl().RemoveWindow( w ); + Window *parent = dynamic_cast (context); + if (parent) + SetParent (parent); } -void MoreButton::SetMoreText (rtl::OUString const& text) +NoButton::NoButton ( Context *context, char const* pId, sal_uInt32 nId ) + : PushButton( new NoButtonImpl( context, context->GetPeerHandle( pId, nId ), this ) ) { - SetAdvancedText (text); + Window *parent = dynamic_cast (context); + if (parent) + SetParent (parent); } -void MoreButton::SetLessText (rtl::OUString const& text) +RetryButton::RetryButton ( Context *context, char const* pId, sal_uInt32 nId ) + : PushButton( new RetryButtonImpl( context, context->GetPeerHandle( pId, nId ), this ) ) { - SetSimpleText (text); + Window *parent = dynamic_cast (context); + if (parent) + SetParent (parent); } -rtl::OUString MoreButton::GetMoreText () const +IgnoreButton::IgnoreButton ( Context *context, char const* pId, sal_uInt32 nId ) + : PushButton( new IgnoreButtonImpl( context, context->GetPeerHandle( pId, nId ), this ) ) { - return GetAdvancedText (); + Window *parent = dynamic_cast (context); + if (parent) + SetParent (parent); } -rtl::OUString MoreButton::GetLessText () const +HelpButton::HelpButton ( Context *context, char const* pId, sal_uInt32 nId ) + : PushButton( new HelpButtonImpl( context, context->GetPeerHandle( pId, nId ), this ) ) { - return GetSimpleText (); + Window *parent = dynamic_cast (context); + if (parent) + SetParent (parent); } } // namespace layout diff --git a/toolkit/source/layout/vcl/wcontainer.cxx b/toolkit/source/layout/vcl/wcontainer.cxx index 699a1af14761..868915b33f47 100644 --- a/toolkit/source/layout/vcl/wcontainer.cxx +++ b/toolkit/source/layout/vcl/wcontainer.cxx @@ -57,50 +57,6 @@ Container::Container( rtl::OUString const& rName, sal_Int32 nBorder ) uno::Any( nBorder ) ); } -void Container::Add( Window *pChild ) -{ - if ( pChild ) - { - uno::Reference< awt::XLayoutConstrains > xChild( pChild->GetPeer(), uno::UNO_QUERY ); - mxContainer->addChild( xChild ); - } -} - -void Container::Add( Container *pChild ) -{ - if ( pChild ) - { - uno::Reference< awt::XLayoutConstrains > xChild( pChild->getImpl(), uno::UNO_QUERY ); - mxContainer->addChild( xChild ); - } -} - -void Container::Remove( Window *pChild ) -{ - if ( pChild ) - { - uno::Reference< awt::XLayoutConstrains > xChild( pChild->GetPeer(), uno::UNO_QUERY ); - mxContainer->removeChild( xChild ); - } -} - -void Container::Remove( Container *pChild ) -{ - if ( pChild ) - { - uno::Reference< awt::XLayoutConstrains > xChild( pChild->getImpl(), uno::UNO_QUERY ); - mxContainer->removeChild( xChild ); - } -} - -void Container::Clear() -{ - css::uno::Sequence< css::uno::Reference < css::awt::XLayoutConstrains > > children; - children = mxContainer->getChildren(); - for (int i = 0; i < children.getLength(); i++) - mxContainer->removeChild( children[i] ); -} - void Container::ShowAll( bool bShow ) { struct inner @@ -131,47 +87,6 @@ void Container::ShowAll( bool bShow ) inner::setChildrenVisible( mxContainer, bShow ); } -void Container::Show() -{ - ShowAll( true ); -} - -void Container::Hide() -{ - ShowAll( false ); -} - -Table::Table( sal_Int32 nBorder, sal_Int32 nColumns ) - : Container( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "table" ) ), nBorder ) -{ - uno::Reference< beans::XPropertySet > xProps( mxContainer, uno::UNO_QUERY_THROW ); - xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Columns" ) ), - uno::Any( nColumns ) ); -} - -void Table::Add( Window *window, bool bXExpand, bool bYExpand, - sal_Int32 nXSpan, sal_Int32 nYSpan ) -{ - if ( !window ) - return; - WindowImpl &rImpl = window->getImpl(); - uno::Reference< awt::XLayoutConstrains > xChild( rImpl.mxWindow, - uno::UNO_QUERY ); - mxContainer->addChild( xChild ); - setProps( xChild, bXExpand, bYExpand, nXSpan, nYSpan ); -} - -void Table::Add( Container *pContainer, bool bXExpand, bool bYExpand, - sal_Int32 nXSpan, sal_Int32 nYSpan ) -{ - if ( !pContainer ) - return; - uno::Reference< awt::XLayoutConstrains > xChild( pContainer->getImpl(), - uno::UNO_QUERY ); - mxContainer->addChild( xChild ); - setProps( xChild, bXExpand, bYExpand, nXSpan, nYSpan ); -} - void Table::setProps( uno::Reference< awt::XLayoutConstrains > xChild, bool bXExpand, bool bYExpand, sal_Int32 nXSpan, sal_Int32 nYSpan ) { @@ -195,29 +110,6 @@ Box::Box( rtl::OUString const& rName, sal_Int32 nBorder, bool bHomogeneous ) uno::Any( bHomogeneous ) ); } -void Box::Add( Window *window, bool bExpand, bool bFill, sal_Int32 nPadding) -{ - if ( !window ) - return; - WindowImpl &rImpl = window->getImpl(); - uno::Reference< awt::XLayoutConstrains > xChild( rImpl.mxWindow, - uno::UNO_QUERY ); - - mxContainer->addChild( xChild ); - setProps( xChild, bExpand, bFill, nPadding ); -} - -void Box::Add( Container *pContainer, bool bExpand, bool bFill, sal_Int32 nPadding) -{ - if ( !pContainer ) - return; - - uno::Reference< awt::XLayoutConstrains > xChild( pContainer->getImpl(), - uno::UNO_QUERY ); - mxContainer->addChild( xChild ); - setProps( xChild, bExpand, bFill, nPadding ); -} - void Box::setProps( uno::Reference< awt::XLayoutConstrains > xChild, bool bExpand, bool bFill, sal_Int32 nPadding ) { @@ -232,38 +124,11 @@ void Box::setProps( uno::Reference< awt::XLayoutConstrains > xChild, uno::Any( nPadding ) ); } -Table::Table( Context const* context, char const* pId ) - : Container( context, pId ) -{ -} - Box::Box( Context const* context, char const* pId ) : Container( context, pId ) { } -HBox::HBox( sal_Int32 nBorder, bool bHomogeneous ) - : Box( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "hbox" ) ), - nBorder, bHomogeneous ) -{ -} - -HBox::HBox( Context const* context, char const* pId ) - : Box( context, pId ) -{ -} - -VBox::VBox( sal_Int32 nBorder, bool bHomogeneous ) - : Box( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "vbox" ) ), - nBorder, bHomogeneous ) -{ -} - -VBox::VBox( Context const* context, char const* pId ) - : Box( context, pId ) -{ -} - } // namespace layout /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/source/layout/vcl/wfield.cxx b/toolkit/source/layout/vcl/wfield.cxx index ce8b59f6023f..04b0757ca999 100644 --- a/toolkit/source/layout/vcl/wfield.cxx +++ b/toolkit/source/layout/vcl/wfield.cxx @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -103,89 +102,15 @@ Edit::~Edit () SetModifyHdl (Link ()); } -void Edit::SetSelection( Selection const& rSelection ) -{ -#if LAYOUT_API_CALLS_HANDLER - if ( !getImpl().mxEdit.is() ) - getImpl().mxEdit->setSelection( awt::Selection( rSelection.Min(), rSelection.Max() ) ); -#else /* !LAYOUT_API_CALLS_HANDLER */ - GetEdit ()->SetSelection (rSelection); -#endif /* !LAYOUT_API_CALLS_HANDLER */ -} - -void Edit::SetText( OUString const& rStr ) -{ -#if LAYOUT_API_CALLS_HANDLER - if ( getImpl().mxEdit.is() ) - /// this calls handlers; endless loop in numfmt.cxx - getImpl().mxEdit->setText( rStr ); -#else /* !LAYOUT_API_CALLS_HANDLER */ - GetEdit ()->SetText (rStr); -#endif /* !LAYOUT_API_CALLS_HANDLER */ -} - -String Edit::GetText() const -{ - if ( !getImpl().mxEdit.is() ) - return getImpl().mxEdit->getText(); - return OUString(); -} - void Edit::SetModifyHdl( const Link& link ) { if (&getImpl () && getImpl().mxEdit.is ()) getImpl().SetModifyHdl( link ); } -IMPL_CONSTRUCTORS( Edit, Control, "edit" ); IMPL_GET_IMPL( Edit ); IMPL_GET_WINDOW (Edit); -class MultiLineEditImpl : public EditImpl -{ -public: - MultiLineEditImpl( Context *context, const PeerHandle &peer, Window *window ) - : EditImpl( context, peer, window ) - { - } -}; - -IMPL_CONSTRUCTORS( MultiLineEdit, Edit, "multilineedit" ); -IMPL_GET_IMPL( MultiLineEdit ); - -class SpinFieldImpl : public EditImpl -{ - public: - SpinFieldImpl( Context *context, const PeerHandle &peer, Window *window ) - : EditImpl( context, peer, window ) - { - } -}; - -IMPL_CONSTRUCTORS( SpinField, Edit, "spinfield" ); - -class NumericFieldImpl : public SpinFieldImpl -{ - public: - NumericFieldImpl( Context *context, const PeerHandle &peer, Window *window ) - : SpinFieldImpl( context, peer, window ) - { - } -}; - -class MetricFieldImpl : public SpinFieldImpl -{ - public: - MetricFieldImpl( Context *context, const PeerHandle &peer, Window *window ) - : SpinFieldImpl( context, peer, window ) - { - } -}; - -IMPL_GET_IMPL( SpinField ); -IMPL_GET_IMPL( NumericField ); -IMPL_GET_IMPL( MetricField ); - class FormatterBaseImpl { protected: @@ -252,32 +177,6 @@ NumericFormatterImpl& NumericFormatter::getFormatImpl() const return *( static_cast( mpFormatImpl ) ); } -#define SET_IMPL(vclmethod, idlmethod) \ - void NumericFormatter::vclmethod( sal_Int64 nValue ) \ - { \ - if ( !getFormatImpl().mxField.is() ) \ - return; \ - getFormatImpl().mxField->idlmethod( getFormatImpl().valueToDouble( nValue ) ); \ - } - -SET_IMPL( SetMin, setMin ) -SET_IMPL( SetMax, setMax ) -SET_IMPL( SetLast, setLast ) -SET_IMPL( SetFirst, setFirst ) -SET_IMPL( SetValue, setValue ) -SET_IMPL( SetSpinSize, setSpinSize ) - -sal_Int64 NumericFormatter::GetValue() const -{ - if ( !getFormatImpl().mxField.is() ) - return 0; - return getFormatImpl().doubleToValue( getFormatImpl().mxField->getValue() ); -} - -#undef SET_IMPL - -IMPL_CONSTRUCTORS_2( NumericField, SpinField, NumericFormatter, "numericfield" ); - MetricFormatter::MetricFormatter( FormatterBaseImpl *pImpl ) : FormatterBase( pImpl ) { @@ -285,225 +184,6 @@ MetricFormatter::MetricFormatter( FormatterBaseImpl *pImpl ) MetricFormatterImpl& MetricFormatter::getFormatImpl() const { return *( static_cast( mpFormatImpl ) ); } -#define MetricUnitVclToUno(a) ((sal_uInt16)(a)) - -#define SET_IMPL(vclmethod, idlmethod) \ - void MetricFormatter::vclmethod( sal_Int64 nValue, FieldUnit nUnit ) \ - { \ - if ( !getFormatImpl().mxField.is() ) \ - return; \ - getFormatImpl().mxField->idlmethod( nValue, MetricUnitVclToUno( nUnit ) ); \ - } - -SET_IMPL( SetMin, setMin ) -SET_IMPL( SetMax, setMax ) -SET_IMPL( SetLast, setLast ) -SET_IMPL( SetFirst, setFirst ) -SET_IMPL( SetValue, setValue ) - -#undef SET_IMPL - -void MetricFormatter::SetSpinSize( sal_Int64 nValue ) -{ - if ( !getFormatImpl().mxField.is() ) - return; - getFormatImpl().mxField->setSpinSize( nValue ); -} - -sal_Int64 MetricFormatter::GetValue( FieldUnit nUnit ) const -{ - if ( !getFormatImpl().mxField.is() ) - return 0; - return getFormatImpl().mxField->getValue( MetricUnitVclToUno( nUnit ) ); -} - -IMPL_CONSTRUCTORS_2( MetricField, SpinField, MetricFormatter, "metricfield" ); - -class ComboBoxImpl : public EditImpl - , public ::cppu::WeakImplHelper1< awt::XActionListener > - , public ::cppu::WeakImplHelper1< awt::XItemListener > -{ -public: - uno::Reference< awt::XComboBox > mxComboBox; - - Link maClickHdl; - Link maSelectHdl; - - Window *parent; - - ComboBoxImpl( Context *context, const PeerHandle &peer, Window *window ) - : EditImpl( context, peer, window ) - , mxComboBox( peer, uno::UNO_QUERY ) - { - } - - ~ComboBoxImpl (); - - sal_uInt16 InsertEntry( OUString const& rStr, sal_uInt16 nPos ) - { - if ( nPos == COMBOBOX_APPEND ) - nPos = GetEntryCount(); - mxComboBox->addItem( rtl::OUString( rStr ), nPos ); - return nPos; - } - - void RemoveEntry( sal_uInt16 nPos ) - { - mxComboBox->removeItems( nPos, 1 ); - } - - sal_uInt16 GetEntryPos( String const& rStr ) const - { - uno::Sequence< rtl::OUString> aItems( mxComboBox->getItems() ); - rtl::OUString rKey( rStr ); - sal_uInt16 n = sal::static_int_cast< sal_uInt16 >(aItems.getLength()); - for (sal_uInt16 i = 0; i < n; i++) - { - if ( aItems[ i ] == rKey ) - return i; - } - return COMBOBOX_ENTRY_NOTFOUND; - } - - OUString GetEntry( sal_uInt16 nPos ) const - { - return OUString( mxComboBox->getItem( nPos ) ); - } - - sal_uInt16 GetEntryCount() const - { - return mxComboBox->getItemCount(); - } - - void SetClickHdl( Link const& link ) - { - if (!link && !!maClickHdl) - mxComboBox->removeActionListener( this ); - else if (!!link && !maClickHdl) - mxComboBox->addActionListener( this ); - maClickHdl = link; - } - - void SetSelectHdl( Link const& link ) - { - if (!link && !!maSelectHdl) - mxComboBox->removeItemListener( this ); - else if (!!link && !maSelectHdl) - mxComboBox->addItemListener( this ); - maSelectHdl = link; - } - - void SAL_CALL disposing( lang::EventObject const& e ) - throw (uno::RuntimeException); - - void SAL_CALL actionPerformed (const awt::ActionEvent&) - throw (uno::RuntimeException) - { - ComboBox* pComboBox = static_cast( mpWindow ); - if ( !pComboBox ) - return; - maClickHdl.Call( pComboBox ); - } - - void SAL_CALL itemStateChanged( awt::ItemEvent const&) - throw (uno::RuntimeException) - { - ComboBox* pComboBox = static_cast( mpWindow ); - if ( !pComboBox ) - return; - maSelectHdl.Call( pComboBox ); - } -}; - -ComboBox::~ComboBox () -{ -#ifndef __SUNPRO_CC - OSL_TRACE ("%s: deleting ComboBox for window: %p", __FUNCTION__, GetWindow ()); -#endif -} - -ComboBoxImpl::~ComboBoxImpl () -{ -#ifndef __SUNPRO_CC - OSL_TRACE ("%s: deleting ComboBoxImpl for window: %p", __FUNCTION__, mpWindow ? mpWindow->GetWindow () : 0); - OSL_TRACE ("%s: deleting ComboBoxImpl for listener: %p", __FUNCTION__, static_cast (this)); -#endif -} - -void ComboBoxImpl::disposing( lang::EventObject const& e ) - throw (uno::RuntimeException) -{ - EditImpl::disposing (e); - mxComboBox.clear (); -} - -sal_uInt16 ComboBox::InsertEntry( String const& rStr, sal_uInt16 nPos ) -{ - return getImpl().InsertEntry( rStr, nPos ); -} - -void ComboBox::RemoveEntry( String const& rStr ) -{ - getImpl().RemoveEntry( GetEntryPos( rStr ) ); -} - -void ComboBox::RemoveEntry( sal_uInt16 nPos ) -{ - getImpl().RemoveEntry( nPos ); -} - -void ComboBox::Clear() -{ - uno::Sequence< rtl::OUString> aNoItems; - getImpl().setProperty( "StringItemList", uno::Any( aNoItems ) ); -} - -sal_uInt16 ComboBox::GetEntryPos( String const& rStr ) const -{ - return getImpl().GetEntryPos( rStr ); -} - -String ComboBox::GetEntry( sal_uInt16 nPos ) const -{ - rtl::OUString rItem = getImpl().mxComboBox->getItem( nPos ); - return OUString( rItem ); -} - -sal_uInt16 ComboBox::GetEntryCount() const -{ - return getImpl().GetEntryCount(); -} - -void ComboBox::SetClickHdl( const Link& link ) -{ - if (&getImpl () && getImpl().mxComboBox.is ()) - getImpl().SetClickHdl( link ); -} - -void ComboBox::SetSelectHdl( const Link& link ) -{ - if (&getImpl () && getImpl().mxComboBox.is ()) - getImpl().SetSelectHdl( link ); -} - -void ComboBox::EnableAutocomplete (bool enable, bool matchCase) -{ - GetComboBox ()->EnableAutocomplete (enable, matchCase); -} - -IMPL_CONSTRUCTORS_BODY( ComboBox, Edit, "combobox", getImpl().parent = parent; ); -IMPL_GET_WINDOW (ComboBox); -/// IMPL_GET_IMPL( ComboBox ); - -static ComboBoxImpl* null_combobox_impl = 0; - -ComboBoxImpl &ComboBox::getImpl () const -{ - if (ComboBoxImpl* c = static_cast(mpImpl)) - return *c; - return *null_combobox_impl; -} - class ListBoxImpl : public ControlImpl , public ::cppu::WeakImplHelper1< awt::XActionListener > , public ::cppu::WeakImplHelper1< awt::XItemListener > @@ -671,27 +351,6 @@ ListBox::~ListBox () { } -sal_uInt16 ListBox::InsertEntry (String const& rStr, sal_uInt16 nPos) -{ - return getImpl().InsertEntry(rStr, nPos); -} - -void ListBox::RemoveEntry( sal_uInt16 nPos ) -{ - return getImpl().RemoveEntry( nPos ); -} - -void ListBox::RemoveEntry( String const& rStr ) -{ - return getImpl().RemoveEntry( GetEntryPos( rStr ) ); -} - -void ListBox::Clear() -{ - uno::Sequence< rtl::OUString> aNoItems; - getImpl().setProperty( "StringItemList", uno::Any( aNoItems ) ); -} - sal_uInt16 ListBox::GetEntryPos( String const& rStr ) const { return getImpl().GetEntryPos( rStr ); @@ -702,11 +361,6 @@ String ListBox::GetEntry( sal_uInt16 nPos ) const return getImpl().GetEntry( nPos ); } -sal_uInt16 ListBox::GetEntryCount() const -{ - return getImpl().GetEntryCount(); -} - void ListBox::SelectEntryPos( sal_uInt16 nPos, bool bSelect ) { #if LAYOUT_API_CALLS_HANDLER @@ -716,80 +370,19 @@ void ListBox::SelectEntryPos( sal_uInt16 nPos, bool bSelect ) #endif /* !LAYOUT_API_CALLS_HANDLER */ } -void ListBox::SelectEntry( String const& rStr, bool bSelect ) -{ - SelectEntryPos( GetEntryPos( rStr ), bSelect ); -} - -sal_uInt16 ListBox::GetSelectEntryCount() const -{ - return getImpl().GetSelectEntryCount(); -} - sal_uInt16 ListBox::GetSelectEntryPos( sal_uInt16 nSelIndex ) const { return getImpl().GetSelectEntryPos( nSelIndex ); } -String ListBox::GetSelectEntry( sal_uInt16 nSelIndex ) const -{ - return GetEntry( GetSelectEntryPos( nSelIndex ) ); -} - -Link& ListBox::GetSelectHdl () -{ - return getImpl ().GetSelectHdl (); -} - -void ListBox::SetSelectHdl( Link const& link ) -{ - getImpl().SetSelectHdl( link ); -} - -Link& ListBox::GetClickHdl () -{ - return getImpl ().GetSelectHdl (); -} - -void ListBox::SetClickHdl( Link const& link ) -{ - if (&getImpl () && getImpl().mxListBox.is ()) - getImpl().SetClickHdl( link ); -} - -Link& ListBox::GetDoubleClickHdl () -{ - return getImpl ().GetSelectHdl (); -} - -void ListBox::SetDoubleClickHdl( Link const& link ) -{ - getImpl().SetDoubleClickHdl( link ); -} - -void ListBox::SetEntryData( sal_uInt16 pos, void* data) -{ - GetListBox ()->SetEntryData (pos, data); -} - -void* ListBox::GetEntryData( sal_uInt16 pos) const -{ - return GetListBox ()->GetEntryData (pos); -} - void ListBox::SetNoSelection () { GetListBox ()->SetNoSelection (); } -IMPL_CONSTRUCTORS (ListBox, Control, "listbox"); IMPL_GET_IMPL (ListBox); IMPL_GET_WINDOW (ListBox); -IMPL_IMPL (MultiListBox, ListBox) -IMPL_CONSTRUCTORS_BODY( MultiListBox, ListBox, "multilistbox", GetMultiListBox()->EnableMultiSelection( true ); ); -IMPL_GET_IMPL( MultiListBox ); -IMPL_GET_WINDOW( MultiListBox ); } // namespace layout /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/source/layout/vcl/wrapper.cxx b/toolkit/source/layout/vcl/wrapper.cxx index 9713e04b3e40..b175ea2be0b9 100644 --- a/toolkit/source/layout/vcl/wrapper.cxx +++ b/toolkit/source/layout/vcl/wrapper.cxx @@ -115,10 +115,6 @@ public: { mxTopLevel = xToplevel; } - PeerHandle getRoot() - { - return mxRoot; - } }; Context::Context( const char *pPath ) @@ -131,20 +127,6 @@ Context::~Context() pImpl = NULL; } -void Context::setToplevel( PeerHandle xToplevel ) -{ - pImpl->setTopLevel( xToplevel ); -} - -PeerHandle Context::getToplevel() -{ - return pImpl->getTopLevel(); -} -PeerHandle Context::getRoot() -{ - return pImpl->getRoot(); -} - PeerHandle Context::GetPeerHandle( const char *id, sal_uInt32 nId ) const { PeerHandle xHandle; @@ -558,22 +540,12 @@ void SAL_CALL ControlImpl::focusLost (awt::FocusEvent const&) mLoseFocusHdl.Call (mpWindow); } -Link& Control::GetGetFocusHdl () -{ - return getImpl ().GetGetFocusHdl (); -} - void Control::SetGetFocusHdl (Link const& link) { if (&getImpl () && getImpl().mxWindow.is ()) getImpl ().SetGetFocusHdl (link); } -Link& Control::GetLoseFocusHdl () -{ - return getImpl ().GetLoseFocusHdl (); -} - void Control::SetLoseFocusHdl (Link const& link) { if (&getImpl () && getImpl().mxWindow.is ()) @@ -593,15 +565,6 @@ DialogImpl::DialogImpl( Context *context, const PeerHandle &peer, Window *window { } -Dialog::Dialog( Window *parent, const char *xml_file, const char *id, sal_uInt32 nId ) - : Context( xml_file ) - , Window( new DialogImpl( this, Context::GetPeerHandle( id, nId ), this ) ) - , bConstruct (true) -{ - if ( parent ) - SetParent( parent ); -} - Dialog::Dialog( ::Window *parent, const char *xml_file, const char *id, sal_uInt32 nId ) : Context( xml_file ) , Window( new DialogImpl( this, Context::GetPeerHandle( id, nId ), this ) ) @@ -631,31 +594,11 @@ void Dialog::EndDialog( long result ) MX_DIALOG->endDialog (result); } -void Dialog::SetText( OUString const& str ) -{ - SetTitle (str); -} - void Dialog::SetTitle( OUString const& str ) { MX_DIALOG->setTitle (str); } -bool Dialog::Close () -{ - EndDialog (false); - return true; -} - -long Dialog::Notify (NotifyEvent& event) -{ - return GetDialog ()->Notify (event); -} - -void Dialog::Initialize (SfxChildWinInfo*) -{ -} - #define MESSAGE_BOX_MEMBER_INIT\ Dialog (parent, xml_file, id)\ , imageError (this, "FI_ERROR")\ @@ -809,8 +752,6 @@ void MessageBox::init (OUString const& message, OUString const& yes, OUString co MESSAGE_BOX_IMPL (Error); MESSAGE_BOX_IMPL (Info); -MESSAGE_BOX_IMPL (Query); -MESSAGE_BOX_IMPL (Warning); class TabControlImpl : public ControlImpl @@ -834,11 +775,6 @@ public: mxTabControl.clear (); } - Link& GetActivatePageHdl () - { - return mActivatePageHdl; - } - void SetActivatePageHdl (Link const& link) { if (!mDeactivatePageHdl || !link) @@ -846,11 +782,6 @@ public: mActivatePageHdl = link; } - Link& GetDeactivatePageHdl () - { - return mDeactivatePageHdl; - } - void SetDeactivatePageHdl (Link const& link) { if (!mActivatePageHdl || !link) @@ -895,7 +826,6 @@ public: }; IMPL_GET_WINDOW (TabControl); -IMPL_GET_LAYOUT_VCLXWINDOW (TabControl); #define MX_TABCONTROL if (getImpl ().mxTabControl.is ()) getImpl ().mxTabControl #define RETURN_MX_TABCONTROL if (getImpl ().mxTabControl.is ()) return getImpl ().mxTabControl @@ -906,92 +836,22 @@ TabControl::~TabControl () SetDeactivatePageHdl (Link ()); } -void TabControl::InsertPage (sal_uInt16 id, OUString const& title, sal_uInt16 pos) -{ - (void) pos; - - MX_TABCONTROL->insertTab (); - SetCurPageId (id); - -#if 1 // colour me loc productive -- NOT -#define ADD_PROP( seq, i, name, val )\ - { \ - beans::NamedValue value; \ - value.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( name ) ); \ - value.Value = uno::makeAny( val ); \ - seq[i] = value; \ - } - - uno::Sequence< beans::NamedValue > seq (1); - ADD_PROP ( seq, 0, "Title", OUString (title) ); - MX_TABCONTROL->setTabProps (id, seq); -#else - GetTabPage (id)->SetText (title); -#endif -} -void TabControl::RemovePage (sal_uInt16 id) -{ - GetTabControl ()->RemovePage (id); -} -sal_uInt16 TabControl::GetPageCount () const -{ - return GetTabControl ()->GetPageCount (); -} -sal_uInt16 TabControl::GetPageId (sal_uInt16 pos) const -{ - return GetTabControl ()->GetPageId (pos); -} -sal_uInt16 TabControl::GetPagePos (sal_uInt16 id) const -{ - getImpl ().redraw (); - return GetTabControl ()->GetPagePos (id); -} void TabControl::SetCurPageId (sal_uInt16 id) { getImpl ().redraw (); GetTabControl ()->SetCurPageId (id); } -sal_uInt16 TabControl::GetCurPageId () const -{ - return GetTabControl ()->GetCurPageId (); -} -void TabControl::SetTabPage (sal_uInt16 id, ::TabPage* page) -{ - GetTabControl ()->SetTabPage (id, page); - getImpl ().redraw (); -} -::TabPage* TabControl::GetTabPage (sal_uInt16 id) const -{ - return GetTabControl ()->GetTabPage (id); -} void TabControl::SetActivatePageHdl (Link const& link) { if (&getImpl () && getImpl().mxTabControl.is ()) getImpl ().SetActivatePageHdl (link); } -Link& TabControl::GetActivatePageHdl () const -{ - return getImpl ().GetActivatePageHdl (); -} void TabControl::SetDeactivatePageHdl (Link const& link) { if (&getImpl () && getImpl().mxTabControl.is ()) getImpl ().SetDeactivatePageHdl (link); } -Link& TabControl::GetDeactivatePageHdl () const -{ - return getImpl ().GetDeactivatePageHdl (); -} -void TabControl::SetTabPageSizePixel (Size const& size) -{ - GetTabControl ()->SetTabPageSizePixel (size); -} -Size TabControl::GetTabPageSizePixel () const -{ - return GetTabControl ()->GetTabPageSizePixel (); -} -IMPL_CONSTRUCTORS (TabControl, Control, "tabcontrol"); IMPL_GET_IMPL (TabControl); class TabPageImpl : public WindowImpl @@ -1010,22 +870,6 @@ TabControl* TabPage::global_tabcontrol = 0; IMPL_GET_IMPL( TabPage ); -TabPage::TabPage( Window *parent, const char *xml_file, const char *id, sal_uInt32 nId) - : Context( xml_file ) - , Window( new TabPageImpl( this, Context::GetPeerHandle( id, nId ), this ) ) -{ - if ( parent ) - SetParent( parent ); -} - -TabPage::TabPage( ::Window *parent, const char *xml_file, const char *id, sal_uInt32 nId) - : Context( xml_file ) - , Window( new TabPageImpl( this, Context::GetPeerHandle( id, nId ), this ) ) -{ - if ( parent ) - SetParent( parent ); -} - TabPage::~TabPage() { delete GetTabPage(); @@ -1041,24 +885,6 @@ void TabPage::DeactivatePage() { } -class FixedLineImpl : public ControlImpl -{ -public: - FixedLineImpl( Context *context, const PeerHandle &peer, Window *window ) - : ControlImpl( context, peer, window ) - { - } -}; - -IMPL_CONSTRUCTORS( FixedLine, Control, "hfixedline" ); -IMPL_GET_IMPL( FixedLine ); - -bool FixedLine::IsEnabled() const -{ - //FIXME - return true; -} - class FixedTextImpl : public ControlImpl { public: @@ -1086,11 +912,18 @@ void SAL_CALL FixedTextImpl::disposing( lang::EventObject const& e ) mxFixedText.clear (); } +FixedText::FixedText ( Context *context, char const* pId, sal_uInt32 nId ) + : Control( new FixedTextImpl( context, context->GetPeerHandle( pId, nId ), this ) ) +{ + Window *parent = dynamic_cast (context); + if (parent) + SetParent (parent); +} + FixedText::~FixedText () { } -IMPL_CONSTRUCTORS( FixedText, Control, "fixedtext" ); IMPL_GET_IMPL( FixedText ); void FixedText::SetText( OUString const& rStr ) @@ -1100,18 +933,6 @@ void FixedText::SetText( OUString const& rStr ) getImpl().mxFixedText->setText( rStr ); } -class FixedInfoImpl : public FixedTextImpl -{ -public: - FixedInfoImpl( Context *context, const PeerHandle &peer, Window *window ) - : FixedTextImpl( context, peer, window ) - { - } -}; - -IMPL_CONSTRUCTORS( FixedInfo, FixedText, "fixedinfo" ); -IMPL_GET_IMPL( FixedInfo ); - class ProgressBarImpl : public ControlImpl { public: @@ -1146,217 +967,15 @@ public: } }; -IMPL_CONSTRUCTORS( FixedImage, Control, "fixedimage" ); -IMPL_GET_IMPL( FixedImage ) - -void FixedImage::setImage( ::Image const& i ) -{ - (void) i; - if ( !getImpl().mxGraphic.is() ) - return; - //FIXME: hack moved to proplist - //getImpl().mxGraphic = -} - - -IMPL_CONSTRUCTORS( ProgressBar, Control, "ProgressBar" ); -IMPL_GET_IMPL( ProgressBar ); - -void ProgressBar::SetForegroundColor( util::Color color ) -{ - if ( !getImpl().mxProgressBar.is() ) - return; - getImpl().mxProgressBar->setForegroundColor( color ); -} - -void ProgressBar::SetBackgroundColor( util::Color color ) -{ - if ( !getImpl().mxProgressBar.is() ) - return; - getImpl().mxProgressBar->setBackgroundColor( color ); -} - -void ProgressBar::SetValue( sal_Int32 i ) -{ - if ( !getImpl().mxProgressBar.is() ) - return; - getImpl().mxProgressBar->setValue( i ); -} - -void ProgressBar::SetRange( sal_Int32 min, sal_Int32 max ) -{ - if ( !getImpl().mxProgressBar.is() ) - return; - getImpl().mxProgressBar->setRange( min, max ); -} - -sal_Int32 ProgressBar::GetValue() -{ - if ( !getImpl().mxProgressBar.is() ) - return 0; - return getImpl().mxProgressBar->getValue(); -} - -class PluginImpl: public ControlImpl -{ -public: - ::Control *mpPlugin; - - PluginImpl( Context *context, const PeerHandle &peer, Window *window, :: Control *plugin ) - : ControlImpl( context, peer, window ) - , mpPlugin( plugin ) - { - uno::Reference ref( mxWindow, uno::UNO_QUERY ); - layoutimpl::VCLXPlugin *vcl - = static_cast( VCLXWindow::GetImplementation( ref ) ); - ::Window *parent = vcl->mpWindow->GetParent(); - vcl->SetWindow( plugin ); - vcl->SetPlugin( mpPlugin ); - plugin->SetParent( parent ); - plugin->SetStyle( vcl->mStyle ); - plugin->SetCreatedWithToolkit( true ); - plugin->SetComponentInterface( vcl ); - plugin->Show(); - } -}; - -Plugin::Plugin( Context *context, char const *id, ::Control *plugin ) - : Control( new PluginImpl( context, context->GetPeerHandle( id, 0 ), this, plugin ) ) - , mpPlugin( plugin ) -{ -} - -IMPL_GET_IMPL( Plugin ); - -class LocalizedStringImpl : public WindowImpl -{ -public: - layoutimpl::LocalizedString *mpString; - OUString maString; - LocalizedStringImpl( Context *context, const PeerHandle &peer, Window *window ) - : WindowImpl( context, peer, window ) - , mpString( static_cast( VCLXWindow::GetImplementation( uno::Reference ( mxWindow, uno::UNO_QUERY ) ) ) ) - , maString () - { - } - OUString getText() - { - if (mpString) - maString = mpString->getText (); - return maString; - } - void setText( OUString const& s ) - { - if (mpString) - mpString->setText( s ); - } -}; - -IMPL_GET_IMPL( LocalizedString ); - -LocalizedString::LocalizedString( Context *context, char const* id ) - : Window( new LocalizedStringImpl( context, context->GetPeerHandle( id, 0 ), this ) ) -{ -} - -String LocalizedString::getString () -{ - return getImpl ().getText (); -} - -OUString LocalizedString::getOUString () -{ - return getImpl ().getText (); -} - -LocalizedString::operator OUString () -{ - return getOUString (); -} - -LocalizedString::operator OUString const& () -{ - getOUString (); - return getImpl ().maString; -} - -LocalizedString::operator String() -{ - getOUString (); - return getImpl ().maString; -} - -String LocalizedString::GetToken (sal_uInt16 i, sal_Char c) -{ - return getString ().GetToken (i, c); -} - -OUString LocalizedString::operator= (OUString const& s) -{ - getImpl().setText( s ); - return getImpl().getText(); -} - -OUString LocalizedString::operator+= (OUString const& b) -{ - OUString a = getImpl ().getText (); - a += b; - getImpl ().setText (a); - return getImpl ().getText (); -} - -OUString LocalizedString::operator+= (sal_Unicode const b) -{ - String a = getImpl ().getText (); - a += b; - getImpl ().setText (a); - return getImpl ().getText (); -} - -class InPlugImpl : public WindowImpl -{ -public: - InPlugImpl (Context *context, const PeerHandle &peer, Window *window) - : WindowImpl (context, peer, window) - { - } -}; - -IMPL_GET_IMPL (InPlug); - -static char const *FIXME_set_parent (::Window *parent, char const *xml_file) -{ - layout::TabPage::global_parent = parent; - return xml_file; -} - -InPlug::InPlug (Window *parent, char const* xml_file, char const* id, sal_uInt32 nId) - : Context (FIXME_set_parent (parent ? parent->GetWindow () : 0, xml_file)) - , layout::Window (new InPlugImpl (this, Context::GetPeerHandle (id, nId), this)) +FixedImage::FixedImage ( Context *context, char const* pId, sal_uInt32 nId ) + : Control( new FixedImageImpl( context, context->GetPeerHandle( pId, nId ), this ) ) { + Window *parent = dynamic_cast (context); if (parent) SetParent (parent); - if (::Window *w = dynamic_cast< ::Window* > (this)) - w->SetComponentInterface (GetVCLXWindow ()); -} - -InPlug::InPlug (::Window *parent, char const* xml_file, char const* id, sal_uInt32 nId) - : Context (FIXME_set_parent (parent, xml_file)) - , layout::Window (new InPlugImpl (this, Context::GetPeerHandle (id, nId), this)) -{ - if (parent) - layout::Window::SetParent (parent); - if (::Window *w = dynamic_cast< ::Window* > (this)) - w->SetComponentInterface (GetVCLXWindow ()); } -void InPlug::ParentSet (Window *window) -{ - window->SetParent (dynamic_cast< ::Window* > (this)); - - /// FIXME: for standalone run of layout::SfxTabDialog - SetParent (window->GetParent ()); -} +IMPL_GET_IMPL( FixedImage ) } // namespace layout diff --git a/toolkit/workben/controls.cxx b/toolkit/workben/controls.cxx deleted file mode 100644 index 93b68649db82..000000000000 --- a/toolkit/workben/controls.cxx +++ /dev/null @@ -1,272 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_toolkit.hxx" -#include - -#include -#include -#include -#include - - -#include -#include -#include -#include -#include - - -#include - -#include // InitExtToolkit - -UsrAny UsrAny_UINT16( UINT16 n ) -{ - UsrAny aVal; - aVal.setUINT16( n ); - return aVal; -} - -// ----------------------------------------------------------------------- - -class MyApp : public Application -{ -public: - void Main(); -}; - -MyApp aMyApp; - -// ----------------------------------------------------------------------- - -class MyWin : public WorkWindow -{ - XControlRef xCtrl; - XPropertySetRef xCtrlModel; - XControlContainerRef xCont; - XPropertySetRef xContModel; - XControlRef xDrawCtrl; - XGraphicsRef xG; - -public: - MyWin( Window* pParent, WinBits nWinStyle ); - ~MyWin(); - - void MouseButtonDown( const MouseEvent& rMEvt ); - void Resize(); - void Paint( const Rectangle& r ); -}; - -// ----------------------------------------------------------------------- - -void MyApp::Main() -{ - createAndSetDefaultServiceManager(); - - MyWin aMainWin( NULL, WB_APP | WB_STDWORK ); - aMainWin.SetText( "Uno-Controls - Workbench" ); - aMainWin.Show(); - Execute(); -} - -// ----------------------------------------------------------------------- - -MyWin::MyWin( Window* pParent, WinBits nWinStyle ) : - WorkWindow( pParent, nWinStyle ) -{ -} - -// ----------------------------------------------------------------------- -MyWin::~MyWin() -{ - XComponentRef xC1( xCont, USR_QUERY ); - xC1->dispose(); - XComponentRef xC2( xContModel, USR_QUERY ); - xC2->dispose(); -} - -// ----------------------------------------------------------------------- - -void MyWin::MouseButtonDown( const MouseEvent& rMEvt ) -{ - if( rMEvt.GetClicks() == 2 ) - { - XViewRef xV( xDrawCtrl, USR_QUERY ); - XWindowRef xC( xDrawCtrl, USR_QUERY ); - xV->draw( xC->getPosSize().Left(), xC->getPosSize().Top() ); - } - else if( rMEvt.GetClicks() == 1 ) - { - if( xContModel ) - { - static INT32 nColor = 0x001788ab; - xContModel->setPropertyValue( L"BackgroundColor", UsrAny( nColor ) ); - nColor += 0x00111111; - nColor &= 0xFFFFFF; - } - else - { - XServiceManagerRef xProv = getGlobalServiceManager(); - - XMultiServiceFactoryRef xMSF = NAMESPACE_USR( getProcessServiceManager )(); - - XServiceProviderRef xSSI = xProv->queryServiceProvider( L"stardiv.vcl.VclToolkit" ); - XToolkitRef xToolkit( xMSF->createInstance( L"stardiv.vcl.VclToolkit" ), USR_QUERY ); - DBG_ASSERT( xToolkit, "No Toolkit!" ); - - // Uno Container + Model erzeugen - XServiceProviderRef xModelProv; // = xProv->queryServiceProvider( L"stardiv.vcl.controlmodel.ControlContainer" ); - XInterfaceRef xCMRef( xMSF->createInstance(L"stardiv.vcl.controlmodel.ControlContainer") ); - xCMRef->queryInterface( XPropertySet::getSmartUik(), xContModel ); - xContModel->setPropertyValue( L"Border", UsrAny_UINT16( 1 ) ); - xContModel->setPropertyValue( L"BackgroundColor", UsrAny( (UINT32)0x00CCCCCC) ); - - xModelProv = xProv->queryServiceProvider( L"stardiv.vcl.control.ControlContainer" ); - XInterfaceRef xCCRef( xModelProv->createInstance(), USR_QUERY ); - xCCRef->queryInterface( XControlContainer::getSmartUik(), xCont ); - - XControlModelRef xCM( xContModel, USR_QUERY ); - XControlRef xContControl( xCont, USR_QUERY ); - xContControl->setModel( xCM ); - XWindowRef xContComp( xCont, USR_QUERY ); - xContComp->setPosSize( 0, 0, 500, 600, PosSize_POSSIZE ); - - // Zwei EditControls auf einem Model... -// xModelProv = xProv->queryServiceProvider( L"stardiv.uno.awt.UnoControlEditModel" ); - XInterfaceRef xModel( xMSF->createInstance(L"stardiv.uno.awt.UnoControlEditModel") ); - DBG_ASSERT( xModel, "No Model!" ); - - XPropertySetRef xPSet( xModel, USR_QUERY ); - xPSet->setPropertyValue( L"Text", UsrAny( UString( L"Hallo!" ) ) ); - xPSet->setPropertyValue( L"FontName", UsrAny( UString( L"Times New Roman" ) ) ); -// xPSet->setPropertyValue( L"FontWeight", UsrAny( 200 ) ); - - XServiceProviderRef xEditCtrlProv = xProv->queryServiceProvider( L"stardiv.uno.awt.UnoControlEdit" ); - // Edit1 - XControlRef xEdit1( xMSF->createInstance(L"stardiv.uno.awt.UnoControlEdit"), USR_QUERY ); - xModel->queryInterface( XControlModel::getSmartUik(), xCM ); - xEdit1->setModel( xCM ); - XWindowRef xEditCmp1( xEdit1, USR_QUERY ); - xEditCmp1->setPosSize( 50, 50, 100, 60, PosSize_POSSIZE ); - xCont->addControl( L"", xEdit1 ); - // Edit2 - XControlRef xEdit2( xMSF->createInstance(L"stardiv.uno.awt.UnoControlEdit"), USR_QUERY ); - xModel->queryInterface( XControlModel::getSmartUik(), xCM ); - xEdit2->setModel( xCM ); - XWindowRef xEditCmp2( xEdit2, USR_QUERY ); - XLayoutConstrainsRef xL( xEdit2, USR_QUERY ); - if ( xL.is() ) - { - Size aSz = xL->getPreferredSize(); - xEditCmp2->setPosSize( 100, 180, aSz.Width(), aSz.Height(), PosSize_POSSIZE ); - } - else - xEditCmp2->setPosSize( 100, 180, 100, 40, PosSize_POSSIZE ); - xCont->addControl( L"", xEdit2 ); - - xModelProv = xProv->queryServiceProvider( L"stardiv.vcl.controlmodel.NumericField" ); - XInterfaceRef xNumModel( xModelProv->createInstance(), USR_QUERY ); - DBG_ASSERT( xNumModel, "No Model!" ); - - - XServiceProviderRef xNumFieldProv = xProv->queryServiceProvider( L"stardiv.vcl.control.NumericField" ); - XControlRef xNumField( xNumFieldProv->createInstance(), USR_QUERY ); - xNumModel->queryInterface( XControlModel::getSmartUik(), xCM ); - xNumField->setModel( xCM ); - XWindowRef xNumFieldWin( xNumField, USR_QUERY ); - xNumFieldWin->setPosSize( 50, 250, 100, 60, PosSize_POSSIZE ); - xCont->addControl( L"", xNumField ); - - XMultiPropertySetRef xPSet2( xNumModel, USR_QUERY ); - Sequence Names( 2 ); - Names.getArray()[0] = L"Value"; - Names.getArray()[1] = L"ValueMin"; - Sequence Values( 2 ); - Values.getArray()[0] = UsrAny( -2000000.0 ); - Values.getArray()[1] = UsrAny( -2000000.0 ); - xPSet2->setPropertyValues( Names, Values ); - - - // Button... - xModelProv = xProv->queryServiceProvider( L"stardiv.vcl.controlmodel.Button" ); - xModelProv->createInstance()->queryInterface( XInterface::getSmartUik(), xModel ); - DBG_ASSERT( xModel, "No Model!" ); - - xModel->queryInterface( XPropertySet::getSmartUik(), xPSet ); - xPSet->setPropertyValue( L"Label", UsrAny( L"Press!" ) ); - - XServiceProviderRef xButtonCtrlProv = xProv->queryServiceProvider( L"stardiv.vcl.control.Button" ); - XControlRef xButton1( xButtonCtrlProv->createInstance(), USR_QUERY ); - xModel->queryInterface( XControlModel::getSmartUik(), xCM ); - xButton1->setModel( xCM ); - XWindowRef xButtonCmp1( xButton1, USR_QUERY ); - xButtonCmp1->setPosSize( 170, 80, 80, 80, PosSize_POSSIZE ); - // Unsichtbar, nur im MBDown mit DrawRoutine bei Doppel-Klick... - xButtonCmp1->setVisible( FALSE ); - xDrawCtrl = xButton1; - - xCont->addControl( L"", xButton1 ); - - // Container anzeigen... - // Als Child zu diesem Fenster - xContControl->createPeer( XToolkitRef(), GetComponentInterface( TRUE ) ); - - XDeviceRef xD( xContControl->getPeer(), USR_QUERY ); - xG = xD->createGraphics(); - XViewRef xV ( xDrawCtrl, USR_QUERY ); - xV->setGraphics( xG ); - - } - return; - } - WorkWindow::MouseButtonDown( rMEvt ); -} - - -// ----------------------------------------------------------------------- - -void MyWin::Resize() -{ - WorkWindow::Resize(); -} - -void MyWin::Paint( const Rectangle& r ) -{ - // Muss ueber PaintListener geschehen... - if ( xDrawCtrl.is() ) - { - XViewRef xV( xDrawCtrl, USR_QUERY ); - XWindowRef xC( xDrawCtrl, USR_QUERY ); - xV->draw( xC->getPosSize().Left(), xC->getPosSize().Top() ); - } - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/workben/layout/.gitignore b/toolkit/workben/layout/.gitignore deleted file mode 100644 index 142ba57c1444..000000000000 --- a/toolkit/workben/layout/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -/de -/en-US -/nl -/ja \ No newline at end of file diff --git a/toolkit/workben/layout/README b/toolkit/workben/layout/README deleted file mode 100644 index 3ab112e50ff2..000000000000 --- a/toolkit/workben/layout/README +++ /dev/null @@ -1,43 +0,0 @@ -Testing workbench and editor for Layout engine. - -* Configure using --enable-layout. - -* [d]make all - -* export OOO_INSTALL_PREFIX=$(pwd)/ooo-layout - -* [d]make install DESTDIR=$OOO_INSTALL_PREFIX - -* Compile test program in toolkit/workben/layout - - cd toolkit/workben/layout && dmake all - -* FIXME: New three layer install/rpath feature needs these workarounds -| -| test -d $OOO_INSTALL_PREFIX/openoffice.org3 && export OOO_PREFIX_BRAND=$OOO_INSTALL_PREFIX/openoffice.org3 || export OOO_PREFIX_BRAND=$OOO_INSTALL_PREFIX -| cp -f ../..$INPATH/lib/libtkx.so $OOO_PREFIX/openoffice.org/program -| export LD_LIBRARY_PATH=$OOO_PREFIX_BRAND/program:$OOO_PREFIX_BRAND/ure-link/lib -| -| (see source/layout/helper.cxx) - -* Run it on any .xml file - - ../../$INPATH/bin/test [--inst $OOO_INSTALL_PREFIX] zoom.xml - -* Run it for specific dialogs, see test.cxx - - ../../$INPATH/bin/test [--inst $OOO_INSTALL_PREFIX] --test zoom - ../../$INPATH/bin/test [--inst $OOO_INSTALL_PREFIX] --test wordcount - -* Or source refresh in workben/layout, do something like - - cd toolkit/workben/layout && . ./refresh [--inst $OOO_INSTALL_PREFIX] - -Integration into OOo: - -* After instaling, run - - cd ooo-cvs/program - ./soffice.bin - - Start a [Writer] document and choose View/Zoom or Extra/Word count. diff --git a/toolkit/workben/layout/TEST b/toolkit/workben/layout/TEST deleted file mode 100755 index e1376e1f2867..000000000000 --- a/toolkit/workben/layout/TEST +++ /dev/null @@ -1,11 +0,0 @@ -#! /bin/sh -for d in $(cd ../../../../.. && pwd)/ooo-svn /usr/lib/ooo3/; do - if test -d $d; then - export OOO_INSTALL_PREFIX=$d - break - fi -done -export SAL_ALLOW_LINKOO_SYMLINKS=1 -test -d $OOO_INSTALL_PREFIX/openoffice.org3 && export OOO_PREFIX_BRAND=$OOO_INSTALL_PREFIX/openoffice.org3 || export OOO_PREFIX_BRAND=$OOO_INSTALL_PREFIX -export LD_LIBRARY_PATH="$OOO_PREFIX_BRAND/program:$OOO_PREFIX_BRAND/ure-link/lib" -../../unx*.pro/bin/test "$@" diff --git a/toolkit/workben/layout/adjust.xml b/toolkit/workben/layout/adjust.xml deleted file mode 100644 index 186a94bf5e6a..000000000000 --- a/toolkit/workben/layout/adjust.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/toolkit/workben/layout/align-test.xml b/toolkit/workben/layout/align-test.xml deleted file mode 100644 index 60c34b4655a5..000000000000 --- a/toolkit/workben/layout/align-test.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/toolkit/workben/layout/align.xml b/toolkit/workben/layout/align.xml deleted file mode 100644 index 85aee220fc78..000000000000 --- a/toolkit/workben/layout/align.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/toolkit/workben/layout/boxtest.xml b/toolkit/workben/layout/boxtest.xml deleted file mode 100644 index 24ead837c057..000000000000 --- a/toolkit/workben/layout/boxtest.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - -
-
-
diff --git a/toolkit/workben/layout/dialogbuttons-ok.xml b/toolkit/workben/layout/dialogbuttons-ok.xml deleted file mode 100644 index 86c7a1b13818..000000000000 --- a/toolkit/workben/layout/dialogbuttons-ok.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/toolkit/workben/layout/dialogbuttons-reset.xml b/toolkit/workben/layout/dialogbuttons-reset.xml deleted file mode 100644 index 6c1c613fe96d..000000000000 --- a/toolkit/workben/layout/dialogbuttons-reset.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/toolkit/workben/layout/dialogbuttons-save.xml b/toolkit/workben/layout/dialogbuttons-save.xml deleted file mode 100644 index 38bd90773d0e..000000000000 --- a/toolkit/workben/layout/dialogbuttons-save.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/toolkit/workben/layout/dialogbuttons-yes.xml b/toolkit/workben/layout/dialogbuttons-yes.xml deleted file mode 100644 index 78845598bffc..000000000000 --- a/toolkit/workben/layout/dialogbuttons-yes.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/toolkit/workben/layout/editor-normal.xml b/toolkit/workben/layout/editor-normal.xml deleted file mode 100644 index 7f0dc0b69e74..000000000000 --- a/toolkit/workben/layout/editor-normal.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/toolkit/workben/layout/editor.cxx b/toolkit/workben/layout/editor.cxx deleted file mode 100644 index f46afb62dfe1..000000000000 --- a/toolkit/workben/layout/editor.cxx +++ /dev/null @@ -1,1856 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "editor.hxx" - -#undef NDEBUG - -/* -#include -#include -*/ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace layout::css; - -using rtl::OUString; - -// FIXME: -//#define FILEDLG - -#include -#include -#include - -// TODO: automatically generated -struct WidgetSpec { - const char *pLabel, *pName, *pIconName; - bool bIsContainer; }; -static const WidgetSpec WIDGETS_SPECS[] = { - { "Label", "fixedtext" , "sc_label.png", false }, - { "Button", "pushbutton" , "sc_pushbutton.png", false }, - { "Radio Button", "radiobutton" , "sc_radiobutton.png", false }, - { "Check Box", "checkbox" , "sc_checkbox.png", false }, - { "Line Edit", "edit" , "sc_edit.png", false }, - { "Numeric Field", "numericfield", "sc_numericfield.png", false }, - { "List Box ", "listbox" , NULL, false }, - // containers - { "Hor Box", "hbox" , NULL, true }, - { "Ver Box", "vbox" , NULL, true }, - { "Table", "table" , NULL, true }, - { "Alignment", "align" , NULL, true }, - { "Tab Control", "tabcontrol" , NULL, true }, - { "Hor Splitter", "hsplitter" , NULL, true }, - { "Ver Splitter", "vsplitter" , NULL, true }, - { "Scroller", "scroller" , NULL, true }, -}; -const int WIDGETS_SPECS_LEN = sizeof (WIDGETS_SPECS) / sizeof (WidgetSpec); - -using namespace layout; -using namespace layoutimpl; -namespace css = ::com::sun::star; - -static rtl::OUString anyToString (uno::Any value) -{ - try - { - switch (value.getValueTypeClass()) { - case uno::TypeClass_STRING: - return value.get(); - case uno::TypeClass_CONSTANT: - return rtl::OUString::valueOf (value.get()); - case uno::TypeClass_LONG: - return rtl::OUString::valueOf (value.get()); - case uno::TypeClass_SHORT: - // FIXME: seems broken - return rtl::OUString::valueOf ((sal_Int32) value.get()); - - case uno::TypeClass_FLOAT: - return rtl::OUString::valueOf (value.get()); - case uno::TypeClass_DOUBLE: - return rtl::OUString::valueOf (value.get()); - - case uno::TypeClass_BOOLEAN: - { - bool val = value.get(); - return rtl::OUString( val ? "1" : "0", 1, RTL_TEXTENCODING_ASCII_US ); -/* if ( val ) - return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "true" ) ); - else - return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "false" ) );*/ - } - default: - break; - } - } - catch(...) {} - return rtl::OUString(); -} - -static inline long anyToNatural (uno::Any value) -{ return sal::static_int_cast(anyToString( value ).toInt64()); } -static inline double anyToDecimal (uno::Any value) -{ return anyToString( value ).toDouble(); } - -/* XLayoutContainer/XLayoutConstrains are a bit of a hasle to work with. - Let's wrap them. */ -class Widget : public layoutimpl::LayoutWidget -{ - friend class EditorRoot; - - Widget *mpParent; - std::vector< Widget *> maChildren; - bool mbForeign; - - rtl::OUString mrId; - rtl::OUString mrLabel, mrUnoName; - -// TODO: store original properties. And some property handling methods. - long mnOriAttrbs; - layoutimpl::PropList maOriProps, maOriChildProps; - -public: - - // to be used to wrap the root - Widget( uno::Reference< awt::XLayoutConstrains > xImport, const char *label ) - : mpParent( 0 ), mbForeign( true ) - { - mxWidget = xImport; - mxContainer = uno::Reference< awt::XLayoutContainer >( mxWidget, uno::UNO_QUERY ); - - mrLabel = rtl::OUString( label, strlen( label ), RTL_TEXTENCODING_UTF8 ); - } - - Widget( rtl::OUString id, uno::Reference< awt::XToolkit > xToolkit, - uno::Reference< awt::XLayoutContainer > xParent, - rtl::OUString unoName, long nAttrbs ) - : mpParent( 0 ), mbForeign( false ), mrId( id ), - mnOriAttrbs( nAttrbs ) - { - while ( xParent.is() && !uno::Reference< awt::XWindow >( xParent, uno::UNO_QUERY ).is() ) - { - uno::Reference< awt::XLayoutContainer > xContainer( xParent, uno::UNO_QUERY ); - OSL_ASSERT( xContainer.is() ); - xParent = uno::Reference< awt::XLayoutContainer >( xContainer->getParent(), uno::UNO_QUERY ); - } - - mxWidget = WidgetFactory::createWidget( xToolkit, xParent, unoName, nAttrbs ); - OSL_ASSERT( mxWidget.is() ); - mxContainer = uno::Reference< awt::XLayoutContainer >( mxWidget, uno::UNO_QUERY ); - - mrLabel = mrUnoName = unoName; - // try to get a nicer label for the widget - for ( int i = 0; i < WIDGETS_SPECS_LEN; i++ ) - if ( unoName.equalsAscii( WIDGETS_SPECS[ i ].pName ) ) - { - const char *label = WIDGETS_SPECS[ i ].pLabel; - mrLabel = rtl::OUString( label, strlen( label ), RTL_TEXTENCODING_UTF8 ); - break; - } - - // set default Text property - // TODO: disable editing of text fields, check boxes selected, etc... - - - // store original properties - { - PropertyIterator it( this, WINDOW_PROPERTY ); - while ( it.hasNext() ) - { - beans::Property prop = it.next(); - rtl::OUString name( prop.Name ); - rtl::OUString value( getProperty( name, WINDOW_PROPERTY ) ); -#if DEBUG_PRINT - fprintf(stderr, "original property: %s = %s\n", OUSTRING_CSTR(name), OUSTRING_CSTR(value)); -#endif - std::pair< rtl::OUString, rtl::OUString > pair( name, value ); - maOriProps.push_back( pair ); - } - } - - } - - ~Widget() - { - for ( std::vector< Widget *>::const_iterator it = maChildren.begin(); - it != maChildren.end(); ++it ) - delete *it; - if ( !mbForeign ) - { - uno::Reference< lang::XComponent > xComp( mxWidget, uno::UNO_QUERY ); - if ( xComp.is() ) - // some widgets, like our containers, don't implement this interface... - xComp->dispose(); - } - } - - uno::Reference< awt::XLayoutConstrains > impl() - { - return mxWidget; - } - - // LayoutWidget - virtual bool addChild( LayoutWidget *pChild ) - { - return addChild( static_cast< Widget * >( pChild ) ); - } - - virtual void setProperties( const PropList &rProps ) - { -// maOriProps = rProps; - LayoutWidget::setProperties( rProps ); - } - - virtual void setChildProperties( LayoutWidget *pChild, const PropList &rProps ) - { - maOriChildProps = rProps; - LayoutWidget::setChildProperties( pChild, rProps ); - } - - // tree travel - Widget *up() - { - return mpParent; - } - - Widget *down() - { - if ( maChildren.empty() ) - return NULL; - return maChildren.front(); - } - - Widget *next() - { - if ( mpParent ) - { - int pos = mpParent->getChildPos( this ); - return mpParent->getChild( pos+1 ); - } - return NULL; - } - - Widget *prev() - { - if ( mpParent ) - { - int pos = mpParent->getChildPos( this ); - return mpParent->getChild( pos-1 ); - } - return NULL; - } - - // handle - bool addChild( Widget *pChild, int pos = 0xffff ) - { - if ( !mxContainer.is() ) - return false; - - uno::Sequence< uno::Reference < awt::XLayoutConstrains > > aChildren; - aChildren = mxContainer->getChildren(); - int nChildrenLen = aChildren.getLength(); - - // ugly, but let's check if the container is next to full... - try { - mxContainer->addChild( pChild->mxWidget ); - } - catch( awt::MaxChildrenException& rEx) { - fprintf (stderr, "ERROR: MaxChildrenException: '%s'.\n", - rtl::OUStringToOString (rEx.Message, RTL_TEXTENCODING_UTF8).getStr()); - return false; - } - - if ( pos < nChildrenLen ) - { // if its on the middle, we need to make space for it - mxContainer->removeChild( pChild->mxWidget ); - for ( int i = pos; i < nChildrenLen; i++ ) - mxContainer->removeChild( aChildren[ i ] ); - mxContainer->addChild( pChild->mxWidget ); - for ( int i = pos; i < nChildrenLen; i++ ) - mxContainer->addChild( aChildren[ i ] ); - maChildren.insert( maChildren.begin()+pos, pChild ); - } - else - maChildren.push_back( pChild ); - - OSL_ASSERT( pChild->mpParent == NULL ); - pChild->mpParent = this; - - // store container props - { - pChild->maOriChildProps.clear(); - PropertyIterator it( pChild, CONTAINER_PROPERTY ); - while ( it.hasNext() ) - { - beans::Property prop = it.next(); - rtl::OUString name( prop.Name ); - try { - rtl::OUString value( pChild->getProperty( name, CONTAINER_PROPERTY ) ); - std::pair< rtl::OUString, rtl::OUString > pair( name, value ); - pChild->maOriChildProps.push_back( pair ); - } catch ( beans::UnknownPropertyException &rEx ) { - fprintf (stderr, "ERROR: widget reports that it has a property it cannot return: '%s' this normally means that someone screwed up their PROPERTY_SET_INFO macro usage.\n", - rtl::OUStringToOString (rEx.Message, RTL_TEXTENCODING_UTF8).getStr()); - return false; - } - } - } - - return true; - } - - bool removeChild( Widget *pChild ) - { - if ( !mxContainer.is() || pChild->mpParent != this ) - return false; - - mxContainer->removeChild( pChild->mxWidget ); - - unsigned int pos = getChildPos( pChild ); - if ( pos < maChildren.size() ) - maChildren.erase( maChildren.begin()+pos ); - pChild->mpParent = NULL; - - return true; - } - - bool swapWithChild( Widget *pChild ) - { - if ( !pChild->isContainer() ) - return false; - - // remove all child's childrens, and try to add them here - removeChild( pChild ); - - // keep a copy for failure - std::vector< Widget *> aChildren = maChildren; - std::vector< Widget *> aChildChildren = pChild->maChildren; - - for ( std::vector< Widget *>::const_iterator it = aChildChildren.begin(); - it != aChildChildren.end(); ++it ) - pChild->removeChild( *it ); - - for ( std::vector< Widget *>::const_iterator it = aChildChildren.begin(); - it != aChildChildren.end(); ++it ) - if ( !addChild( *it ) ) - { // failure - for ( std::vector< Widget *>::const_iterator jt = aChildChildren.begin(); - jt != it; ++jt ) - removeChild( *jt ); - for ( std::vector< Widget *>::const_iterator jt = aChildChildren.begin(); - jt != aChildChildren.end(); ++jt ) - pChild->addChild( *jt ); - return false; - } - - Widget *pParent = up(); - - if ( pParent ) - { - pParent->removeChild( this ); - pParent->addChild( pChild ); - } - pChild->addChild( this ); - return true; - } - - unsigned int getChildPos( Widget *pChild ) - { - int i = 0; - for ( std::vector< Widget *>::const_iterator it = maChildren.begin(); - it != maChildren.end(); ++it, ++i ) - if ( *it == pChild ) - break; - return i; - } - - Widget *getChild( int pos ) - { - if ( pos >= 0 && pos < (signed) maChildren.size() ) - return *(maChildren.begin() + pos); - return NULL; - } - - bool isContainer() - { return mxContainer.is(); } - unsigned int getChildrenLen() - { return maChildren.size(); } - - rtl::OUString getLabel() const - { return mrLabel; } - rtl::OUString getUnoName() const - { return mrUnoName; } - - int getDepth() - { - int depth = 0; - for ( Widget *pWidget = mpParent; pWidget; pWidget = pWidget->mpParent ) - depth++; - return depth; - } - - enum PropertyKind { - WINDOW_PROPERTY, CONTAINER_PROPERTY, WINBITS_PROPERTY - }; - - static rtl::OUString findProperty( const PropList &props, rtl::OUString propName ) - { - for ( PropList::const_iterator it = props.begin(); it != props.end(); ++it ) - if ( it->first.equalsIgnoreAsciiCase( propName ) ) - return it->second; -#if DEBUG_PRINT - fprintf(stderr, "Serious error: property '%s' not found\n", OUSTRING_CSTR(propName)); -#endif - return rtl::OUString(); - } - - rtl::OUString getOriginalProperty( rtl::OUString rPropName, PropertyKind rKind ) - { - rtl::OUString rValue; - switch ( rKind ) { - case WINDOW_PROPERTY: - rValue = findProperty( maOriProps, rPropName ); - break; - case CONTAINER_PROPERTY: - rValue = findProperty( maOriChildProps, rPropName ); - break; - case WINBITS_PROPERTY: - // TODO - break; - } - - return rValue; - } - - rtl::OUString getProperty( rtl::OUString rPropName, PropertyKind rKind ) - { - rtl::OUString rValue; - switch ( rKind ) { - case WINDOW_PROPERTY: - rValue = anyToString( layoutimpl::prophlp::getProperty( mxWidget, rPropName ) ); - break; - case CONTAINER_PROPERTY: - if ( mpParent ) - rValue = anyToString( layoutimpl::prophlp::getProperty( - mpParent->mxContainer->getChildProperties( mxWidget ), rPropName ) ); - break; - case WINBITS_PROPERTY: - // TODO - break; - } - - return rValue; - } - - bool isPropertyTouched( rtl::OUString propName, PropertyKind rKind ) - { - rtl::OUString oriValue = getOriginalProperty( propName, rKind ); - rtl::OUString newValue = getProperty( propName, rKind ); - bool isTouched = oriValue != newValue; -#if DEBUG_PRINT - fprintf(stderr, "is property '%s' touched? %s (%s vs %s)\n", OUSTRING_CSTR(propName), isTouched ? "yes" : "no", OUSTRING_CSTR(oriValue), OUSTRING_CSTR(newValue)); -#endif - return isTouched; - } - - using LayoutWidget::setProperty; - - void setProperty( rtl::OUString rPropName, PropertyKind rKind, uno::Any rValue ) - { - switch ( rKind ) { - case WINDOW_PROPERTY: - layoutimpl::prophlp::setProperty( mxWidget, rPropName, rValue ); - break; - case CONTAINER_PROPERTY: - if ( mpParent ) - layoutimpl::prophlp::setProperty( - mpParent->mxContainer->getChildProperties( mxWidget ), rPropName, rValue ); - break; - case WINBITS_PROPERTY: - // TODO - break; - } - } - - struct PropertyIterator { - friend class Widget; - PropertyKind mrKind; - uno::Sequence< beans::Property > maProps; - int nPropIt; - - PropertyIterator( Widget *pWidget, PropertyKind rKind ) - : mrKind( rKind ), nPropIt( 0 ) - { - switch ( rKind ) - { - case WINDOW_PROPERTY: - if ( layoutimpl::prophlp::canHandleProps( pWidget->mxWidget ) ) - { - uno::Reference< beans::XPropertySetInfo > xInfo - = layoutimpl::prophlp::queryPropertyInfo( pWidget->mxWidget ); - if ( !xInfo.is() ) - return; - - maProps = xInfo->getProperties(); - } - break; - case CONTAINER_PROPERTY: - if ( pWidget->mpParent ) - { - uno::Reference< beans::XPropertySet >xParentSet( - pWidget->mpParent->mxContainer->getChildProperties( pWidget->mxWidget ) ); - if ( xParentSet.is()) - { - uno::Reference< beans::XPropertySetInfo > xInfo( xParentSet->getPropertySetInfo() ); - if ( xInfo.is() ) - maProps = xInfo->getProperties(); - } - } - break; - case WINBITS_PROPERTY: - // TODO - break; - } - } - - bool hasNext() - { - return nPropIt < maProps.getLength(); - } - - beans::Property next() - { -/* rtl::OUString propName, propValue; - propName = maProps[ nPropIt ]; - propValue = getProperty( propName, mrKind, false); - nPropIt++; - return std::pair< rtl::OUString, rtl::OUString > propPair( propName, propValue );*/ - return maProps[ nPropIt++ ]; - } - }; -}; - -class EditorRoot : public layoutimpl::LayoutRoot { - Widget *mpParent; - -public: - EditorRoot( const uno::Reference< lang::XMultiServiceFactory >& xFactory, - Widget *pParent ) - : layoutimpl::LayoutRoot( xFactory ), mpParent( pParent ) - { - } - - // generation - virtual layoutimpl::LayoutWidget *create( rtl::OUString id, const rtl::OUString unoName, - long attrbs, uno::Reference< awt::XLayoutContainer > xParent ) - { - if ( unoName.compareToAscii( "dialog" ) == 0 ) - return mpParent; - - // TODO: go through specs to map unoName to a more human-readable label - Widget *pWidget = new Widget( id, mxToolkit, xParent, unoName, attrbs ); - if ( !mxWindow.is() ) - mxWindow = uno::Reference< awt::XWindow >( pWidget->getPeer(), uno::UNO_QUERY ); - - if ( pWidget->mxContainer.is() ) - pWidget->mxContainer->setLayoutUnit( mpParent->mxContainer->getLayoutUnit() ); - - return pWidget; - } -}; - -/* Working with the layout in 1D, as if it was a flat list. */ -namespace FlatLayout -{ -Widget *next( Widget *pWidget ) -{ - Widget *pNext; - pNext = pWidget->down(); - if ( pNext ) return pNext; - pNext = pWidget->next(); - if ( pNext ) return pNext; - for ( Widget *pUp = pWidget->up(); pUp != NULL; pUp = pUp->up() ) - if ( (pNext = pUp->next()) != NULL ) - return pNext; - return NULL; -} - -/* - Widget *prev( Widget *pWidget ) - { - Widget *pPrev; - pPrev = pWidget->prev(); - if ( !pPrev ) - return pWidget->up(); - - Widget *pBottom = pPrev->down(); - if ( pBottom ) - { - while ( pBottom->down() || pBottom->next() ) - { - for ( Widget *pNext = pBottom->next(); pNext; pNext = pNext->next() ) - pBottom = pNext; - Widget *pDown = pBottom->down(); - if ( pDown ) - pBottom = pDown; - } - return pBottom; - } - return pPrev; - } -*/ - -bool moveWidget( Widget *pWidget, bool up /*or down*/ ) -{ - // Keep child parent&pos for in case of failure - Widget *pOriContainer = pWidget->up(); - unsigned int oriChildPos = pOriContainer->getChildPos( pWidget ); - - // Get parent&sibling before removing it, since relations get cut - Widget *pSibling = up ? pWidget->prev() : pWidget->next(); - Widget *pContainer = pWidget->up(); - if ( !pContainer ) - return false; - - // try to swap with parent or child - // We need to allow for this at least for the root node... - if ( !pSibling ) - { - if ( up ) - { - if ( pContainer->swapWithChild( pWidget ) ) - return true; - } - else - { - } - } - - pContainer->removeChild( pWidget ); - - // if has up sibling -- append to it, else swap with it - if ( pSibling ) - { - if ( pSibling->addChild( pWidget, up ? 0xffff : 0 ) ) - return true; - - unsigned int childPos = pContainer->getChildPos( pSibling ); - if ( pContainer->addChild( pWidget, childPos + (up ? 0 : 1) ) ) - return true; // should always be succesful - } - // go through parents -- try to get prepended to them - else - { - for ( ; pContainer && pContainer->up(); pContainer = pContainer->up() ) - { - unsigned int childPos = pContainer->up()->getChildPos( pContainer ); - if ( pContainer->up()->addChild( pWidget, childPos + (up ? 0 : 1) ) ) - return true; - } - } - - // failed -- try to get it to its old position - if ( !pOriContainer->addChild( pWidget, oriChildPos ) ) - { - // a parent should never reject a child back. but if it ever - // happens, just kill it, we don't run an orphanate here ;P - delete pWidget; - return true; - } - return false; -} - -// NOTE: root is considered to be number -1 -Widget *get( Widget *pRoot, int nb ) -{ - Widget *it; - for ( it = pRoot; it != NULL && nb >= 0; it = next( it ) ) - nb--; - return it; -} - -int get( Widget *pRoot, Widget *pWidget ) -{ - int nRet = -1; - Widget *it; - for ( it = pRoot; it != NULL && it != pWidget; it = next( it ) ) - nRet++; - return nRet; -} -} - -//** PropertiesList widget - -class PropertiesList : public layout::Table -{ - class PropertyEntry - { - friend class PropertiesList; - - /* wrapper between the widget and Any */ - struct AnyWidget - { - DECL_LINK( ApplyPropertyHdl, layout::Window* ); - DECL_LINK( FlagToggledHdl, layout::CheckBox* ); - - AnyWidget( Widget *pWidget, rtl::OUString aPropName, Widget::PropertyKind aPropKind ) - : mpWidget( pWidget ), maPropName( aPropName ), maPropKind( aPropKind ) - { - mpFlag = 0; - mbBlockFlagCallback = false; - bFirstGet = true; - } - - virtual ~AnyWidget() - { -#if DEBUG_PRINT - fprintf(stderr, "~AnyWidget\n"); -#endif - } - - void save( uno::Any aValue ) - { - mpWidget->setProperty( maPropName, maPropKind, aValue ); - checkProperty(); - } - - void checkProperty() - { - bool flag = mpWidget->isPropertyTouched( maPropName, maPropKind ); - - if ( mpFlag && mpFlag->IsChecked() != (BOOL)flag ) - { - CheckFlag( flag, true ); - } - } - - void CheckFlag( bool bValue, bool bBlockCallback ) - { - if ( bBlockCallback ) - mbBlockFlagCallback = true; - mpFlag->Check( bValue ); - mbBlockFlagCallback = false; - } - - bool bFirstGet; // HACK - rtl::OUString getValue() - { -// return mpWidget->getOriProperty( maPropName ); - rtl::OUString value; - if ( bFirstGet ) // king of ugliness - value = mpWidget->getProperty( maPropName, maPropKind ); - else - value = mpWidget->getOriginalProperty( maPropName, maPropKind ); - bFirstGet = false; - return value; - } - - // FIXME: wrapper should have a base class for this... - virtual layout::Window *getWindow() = 0; - virtual layout::Container *getContainer() { return NULL; } - - virtual void load() = 0; - virtual void store() = 0; - - Widget *mpWidget; - rtl::OUString maPropName; - Widget::PropertyKind maPropKind; - layout::CheckBox *mpFlag; - bool mbBlockFlagCallback; - }; - - struct AnyEdit : public AnyWidget, layout::HBox - { - layout::Edit *mpEdit; - bool mbMultiLine; - layout::PushButton *mpExpand; - DECL_LINK( ExpandEditHdl, layout::PushButton* ); - - // so we can create widgets (like transforming the Edit into a - // MultiLineEdit) - layout::Window *mpWinParent; - - AnyEdit( Widget *pWidget, rtl::OUString aPropName, - Widget::PropertyKind aPropKind, layout::Window *pWinParent ) - : AnyWidget( pWidget, aPropName, aPropKind ), layout::HBox( 0, false ), mpWinParent( pWinParent ) - { - mpEdit = NULL; - mpExpand = new layout::PushButton( pWinParent, WB_TOGGLE ); - mpExpand->SetToggleHdl( LINK( this, AnyEdit, ExpandEditHdl ) ); - setAsMultiLine( false ); - - load(); - } - - virtual ~AnyEdit() - { - delete mpEdit; - delete mpExpand; - } - - virtual layout::Window *getWindow() - { return NULL; } - virtual layout::Container *getContainer() - { return this; } - - void setAsMultiLine( bool bMultiLine ) - { - Clear(); - XubString text; - if ( mpEdit ) - { - text = mpEdit->GetText(); - printf("Remove mpEdit and expand\n"); - Remove( mpEdit ); - Remove( mpExpand ); - delete mpEdit; - } - - if ( bMultiLine ) - { - mpEdit = new layout::Edit( mpWinParent, WB_BORDER ); - mpExpand->SetText( String::CreateFromAscii( "-" ) ); - } - else - { - mpEdit = new layout::Edit( mpWinParent, WB_BORDER ); - mpExpand->SetText( String::CreateFromAscii( "+" ) ); - } - - mpEdit->SetText( text ); - mpEdit->SetModifyHdl( LINK( this, AnyEdit, ApplyPropertyHdl ) ); - - Add( mpEdit, true, true, 0 ); - Add( mpExpand, false, true, 0 ); - - mbMultiLine = bMultiLine; - } - - virtual void load() - { - mpEdit->SetText( getValue() ); - checkProperty(); - } - - virtual void store() - { - save( uno::makeAny( (rtl::OUString) mpEdit->GetText() ) ); - } - }; - - struct AnyInteger : public AnyWidget, NumericField - { - AnyInteger( Widget *pWidget, rtl::OUString aPropName, - Widget::PropertyKind aPropKind, Window *pWinParent ) - : AnyWidget( pWidget, aPropName, aPropKind ), NumericField( pWinParent, WB_SPIN|WB_BORDER ) - { - load(); - SetModifyHdl( LINK( this, AnyInteger, ApplyPropertyHdl ) ); - } - - virtual Window *getWindow() - { return this; } - - virtual void load() - { - OUString text = getValue(); - SetText( text.getStr() ); - checkProperty(); - } - - virtual void store() - { -#if DEBUG_PRINT - fprintf(stderr, "store number: %ld\n", rtl::OUString( GetText() ).toInt64()); -#endif - save( uno::makeAny( rtl::OUString( GetText() ).toInt64() ) ); - } - }; - - struct AnyFloat : public AnyInteger - { - AnyFloat( Widget *pWidget, rtl::OUString aPropName, - Widget::PropertyKind aPropKind, Window *pWinParent ) - : AnyInteger( pWidget, aPropName, aPropKind, pWinParent ) - {} - - virtual void store() - { - save( uno::makeAny( rtl::OUString( GetText() ).toDouble() ) ); - } - }; - - struct AnyCheckBox : public AnyWidget, layout::CheckBox - { - AnyCheckBox( Widget *pWidget, rtl::OUString aPropName, - Widget::PropertyKind aPropKind, layout::Window *pWinParent ) - : AnyWidget( pWidget, aPropName, aPropKind ), layout::CheckBox( pWinParent ) - { - // adding some whitespaces to make the hit area larger -// SetText( String::CreateFromAscii( "" ) ); - load(); - SetToggleHdl( LINK( this, AnyWidget, ApplyPropertyHdl ) ); - } - - virtual ~AnyCheckBox() - { -#if DEBUG_PRINT - fprintf(stderr, "~AnyCheckBox\n"); -#endif - } - - virtual layout::Window *getWindow() - { return this; } - - virtual void load() - { -#if DEBUG_PRINT - fprintf(stderr, "loading boolean value\n"); -#endif - Check( getValue().toInt64() != 0 ); - setLabel(); - checkProperty(); - } - - virtual void store() - { - save( uno::makeAny( IsChecked() ) ); - setLabel(); - } - - void setLabel() - { - SetText( String::CreateFromAscii( IsChecked() ? "true" : "false" ) ); - } - }; - - struct AnyListBox : public AnyWidget, layout::ListBox - { - AnyListBox( Widget *pWidget, rtl::OUString aPropName, - Widget::PropertyKind aPropKind, Window *pWinParent ) - : AnyWidget( pWidget, aPropName, aPropKind ), layout::ListBox( pWinParent, WB_DROPDOWN ) - { - SetSelectHdl( LINK( this, AnyWidget, ApplyPropertyHdl ) ); - } - - virtual layout::Window *getWindow() - { return this; } - - virtual void load() - { - SelectEntryPos( sal::static_int_cast< USHORT >( getValue().toInt32() ) ); - checkProperty(); - } - - virtual void store() - { - save( uno::makeAny( (short) GetSelectEntryPos() ) ); - } - }; - - struct AnyAlign : public AnyListBox - { - AnyAlign( Widget *pWidget, rtl::OUString aPropName, - Widget::PropertyKind aPropKind, Window *pWinParent ) - : AnyListBox( pWidget, aPropName, aPropKind, pWinParent ) - { - InsertEntry( XubString::CreateFromAscii( "Left" ) ); - InsertEntry( XubString::CreateFromAscii( "Center" ) ); - InsertEntry( XubString::CreateFromAscii( "Right" ) ); - load(); - } - }; - - /* AnyListBox and AnyComboBox different in that a ComboBox allows the user - to add other options, operating in strings, instead of constants. - (its more like a suggestive AnyEdit) */ - struct AnyComboBox : public AnyWidget, layout::ComboBox - { - AnyComboBox( Widget *pWidget, rtl::OUString aPropName, - Widget::PropertyKind aPropKind, Window *pWinParent ) - : AnyWidget( pWidget, aPropName, aPropKind ), layout::ComboBox( pWinParent, WB_DROPDOWN ) - { - SetModifyHdl( LINK( this, AnyComboBox, ApplyPropertyHdl ) ); - } - - virtual layout::Window *getWindow() - { return this; } - - virtual void load() - { - SetText( getValue() ); - checkProperty(); - } - - virtual void store() - { - save( uno::makeAny( (rtl::OUString) GetText() ) ); - } - }; - - struct AnyFontStyle : public AnyComboBox - { - AnyFontStyle( Widget *pWidget, rtl::OUString aPropName, - Widget::PropertyKind aPropKind, Window *pWinParent ) - : AnyComboBox( pWidget, aPropName, aPropKind, pWinParent ) - { - InsertEntry( XubString::CreateFromAscii( "Bold" ) ); - InsertEntry( XubString::CreateFromAscii( "Italic" ) ); - InsertEntry( XubString::CreateFromAscii( "Bold Italic" ) ); - InsertEntry( XubString::CreateFromAscii( "Fett" ) ); - load(); - } - }; - - layout::FixedText *mpLabel; - layout::CheckBox *mpFlag; - AnyWidget *mpValue; - - public: - PropertyEntry( layout::Window *pWinParent, AnyWidget *pAnyWidget ) - { - mpLabel = new layout::FixedText( pWinParent ); - { - // append ':' to aPropName - rtl::OUStringBuffer buf( pAnyWidget->maPropName ); - buf.append( sal_Unicode (':') ); - mpLabel->SetText( buf.makeStringAndClear() ); - } - mpValue = pAnyWidget; - mpFlag = new layout::CheckBox( pWinParent ); - mpFlag->SetToggleHdl( LINK( mpValue, AnyWidget, FlagToggledHdl ) ); - mpValue->mpFlag = mpFlag; - } - - ~PropertyEntry() - { -#if DEBUG_PRINT - fprintf(stderr, "REMOVING label, flag and value\n"); -#endif - delete mpLabel; - delete mpFlag; - delete mpValue; - } - - // Use this factory rather than the constructor -- check for NULL - static PropertyEntry *construct( Widget *pWidget, rtl::OUString aPropName, - Widget::PropertyKind aPropKind, sal_uInt16 nType, - layout::Window *pWinParent ) - { - AnyWidget *pAnyWidget; - switch (nType) { - case uno::TypeClass_STRING: - if ( aPropName.compareToAscii( "FontStyleName" ) == 0 ) - { - pAnyWidget = new AnyFontStyle( pWidget, aPropName, aPropKind, pWinParent ); - break; - } - pAnyWidget = new AnyEdit( pWidget, aPropName, aPropKind, pWinParent ); - break; - case uno::TypeClass_SHORT: - if ( aPropName.compareToAscii( "Align" ) == 0 ) - { - pAnyWidget = new AnyAlign( pWidget, aPropName, aPropKind, pWinParent ); - break; - } - // otherwise, treat as any other number... - case uno::TypeClass_LONG: - case uno::TypeClass_UNSIGNED_LONG: - pAnyWidget = new AnyInteger( pWidget, aPropName, aPropKind, pWinParent ); - break; - case uno::TypeClass_FLOAT: - case uno::TypeClass_DOUBLE: - pAnyWidget = new AnyFloat( pWidget, aPropName, aPropKind, pWinParent ); - break; - case uno::TypeClass_BOOLEAN: - pAnyWidget = new AnyCheckBox( pWidget, aPropName, aPropKind, pWinParent ); - break; - default: - return NULL; - } - return new PropertyEntry( pWinParent, pAnyWidget ); - } - }; - - layout::Window *mpParentWindow; - - std::list< PropertyEntry* > maPropertiesList; - layout::FixedLine *mpSeparator; - - // some properties are obscure, or simply don't make sense in this - // context. Let's just ignore them. - // Maybe we could offer them in an expander or something... - static bool toIgnore( rtl::OUString prop ) - { - // binary search -- keep the list sorted alphabetically - static char const *toIgnoreList[] = { - "DefaultControl", "FocusOnClick", "FontCharWidth", "FontCharset", - "FontEmphasisMark", "FontFamily", "FontHeight", "FontKerning", "FontName", - "FontOrientation", "FontPitch", "FontRelief", "FontSlant", "FontStrikeout", - "FontType", "FontWordLineMode", "HelpText", "HelpURL", "MultiLine", - "Printable", "Repeat", "RepeatDelay", "Tabstop" - }; - - int min = 0, max = sizeof( toIgnoreList )/sizeof( char * ) - 1, mid, cmp; - do { - mid = min + (max - min)/2; - cmp = prop.compareToAscii( toIgnoreList[ mid ] ); - if ( cmp > 0 ) - min = mid+1; - else if ( cmp < 0 ) - max = mid-1; - else - return true; - } while ( min <= max ); - return false; - } - -public: - PropertiesList( layout::Dialog *dialog ) - : layout::Table( dialog, "properties-box" ) - , mpParentWindow( dialog ), mpSeparator( 0 ) - { - } - - ~PropertiesList() - { - clear(); - } - -private: - // auxiliary, add properties from the peer to the list - void addProperties( Widget *pWidget, Widget::PropertyKind rKind ) - { - Widget::PropertyIterator it( pWidget, rKind ); - while ( it.hasNext() ) - { - beans::Property prop = it.next(); - rtl::OUString name( prop.Name ); - if ( toIgnore( name ) ) - continue; - sal_uInt16 type = static_cast< sal_uInt16 >( prop.Type.getTypeClass() ); - - PropertyEntry *propEntry = PropertyEntry::construct( - pWidget, name, rKind, type, mpParentWindow ); - - if ( propEntry ) - { - Add( propEntry->mpLabel, false, false ); - - // HACK: one of these will return Null... - Add( propEntry->mpValue->getWindow(), true, false ); - Add( propEntry->mpValue->getContainer(), true, false ); - - Add( propEntry->mpFlag, false, false ); - maPropertiesList.push_back( propEntry ); - } - } - } - -public: - void selectedWidget( Widget *pWidget ) - { - clear(); - - if ( !pWidget ) - return; - - addProperties( pWidget, Widget::CONTAINER_PROPERTY ); - - mpSeparator = new layout::FixedLine( mpParentWindow ); - // TODO: we may want to have to separate list widgets here... - Add( mpSeparator, false, false, 3, 1 ); - - addProperties( pWidget, Widget::WINDOW_PROPERTY ); - - ShowAll( true ); - } - - void clear() - { - ///FIXME: crash - Container::Clear(); - - for ( std::list< PropertyEntry* >::iterator it = maPropertiesList.begin(); - it != maPropertiesList.end(); ++it) - delete *it; - maPropertiesList.clear(); - - delete mpSeparator; - mpSeparator = NULL; - } -}; - -IMPL_LINK( PropertiesList::PropertyEntry::AnyWidget, ApplyPropertyHdl, layout::Window *, pWin ) -{ - (void) pWin; - store(); - return 0; -} - -IMPL_LINK( PropertiesList::PropertyEntry::AnyWidget, FlagToggledHdl, layout::CheckBox *, pCheck ) -{ -#if DEBUG_PRINT - fprintf(stderr, "Property flag pressed -- is: %d\n", pCheck->IsChecked()); -#endif - if ( !mbBlockFlagCallback ) - { - bool checked = pCheck->IsChecked(); - if ( !checked ) // revert - { -#if DEBUG_PRINT - fprintf(stderr, "revert\n"); -#endif - load(); - } - else - { -#if DEBUG_PRINT - fprintf(stderr, "user can't dirty the flag!\n"); -#endif - // User can't flag the property as dirty - // Actually, we may want to allow the designer to force a property to be stored. - // Could be useful when the default value of some new property wasn't yet decided... - CheckFlag( false, true ); - } - } -#if DEBUG_PRINT - else - fprintf(stderr, "Property flag pressed -- BLOCKED\n"); -#endif - return 0; -} - -IMPL_LINK( PropertiesList::PropertyEntry::AnyEdit, ExpandEditHdl, layout::PushButton *, pBtn ) -{ - setAsMultiLine( pBtn->IsChecked() ); - return 0; -} - -//** SortListBox auxiliary widget - -class SortListBox -{ // For a manual sort ListBox; asks for a ListBox and Up/Down/Remove - // buttons to wrap - DECL_LINK( ItemSelectedHdl, layout::ListBox* ); - DECL_LINK( UpPressedHdl, layout::Button* ); - DECL_LINK( DownPressedHdl, layout::Button* ); - DECL_LINK( RemovePressedHdl, layout::Button* ); - layout::PushButton *mpUpButton, *mpDownButton, *mpRemoveButton; - -protected: - layout::ListBox *mpListBox; - - virtual void upPressed( USHORT nPos ) - { - XubString str = mpListBox->GetSelectEntry(); - mpListBox->RemoveEntry( nPos ); - nPos = mpListBox->InsertEntry( str, nPos-1 ); - mpListBox->SelectEntryPos( nPos ); - } - - virtual void downPressed( USHORT nPos ) - { - XubString str = mpListBox->GetSelectEntry(); - mpListBox->RemoveEntry( nPos ); - nPos = mpListBox->InsertEntry( str, nPos+1 ); - mpListBox->SelectEntryPos( nPos ); - } - - virtual void removePressed( USHORT nPos ) - { - mpListBox->RemoveEntry( nPos ); - } - - virtual void itemSelected( USHORT nPos ) - { - // if we had some XLayoutContainer::canAdd() or maxChildren() function - // we could make a function to check if we can move selected and enable/ - // /disable the move buttons as appropriate - - if ( nPos == LISTBOX_ENTRY_NOTFOUND ) - { - mpUpButton->Disable(); - mpDownButton->Disable(); - mpRemoveButton->Disable(); - } - else - { - mpUpButton->Enable(); - mpDownButton->Enable(); - mpRemoveButton->Enable(); - } - } - -public: - SortListBox( layout::ListBox *pListBox, layout::PushButton *pUpButton, layout::PushButton *pDownButton, - layout::PushButton *pRemoveButton ) - : mpUpButton( pUpButton), mpDownButton( pDownButton), mpRemoveButton( pRemoveButton ), - mpListBox( pListBox ) - { - mpListBox->SetSelectHdl( LINK( this, SortListBox, ItemSelectedHdl ) ); - - mpUpButton->SetModeImage( layout::Image ( "cmd/lc_moveup.png" ) ); - mpUpButton->SetImageAlign( IMAGEALIGN_LEFT ); - mpUpButton->SetClickHdl( LINK( this, SortListBox, UpPressedHdl ) ); - - mpDownButton->SetModeImage( layout::Image ( "cmd/lc_movedown.png" ) ); - mpDownButton->SetImageAlign( IMAGEALIGN_LEFT ); - mpDownButton->SetClickHdl( LINK( this, SortListBox, DownPressedHdl ) ); - - // "cmd/lch_delete.png", "cmd/lc_delete.png" - mpRemoveButton->SetModeImage( layout::Image ( "cmd/sc_closedoc.png" ) ); - mpRemoveButton->SetImageAlign( IMAGEALIGN_LEFT ); - mpRemoveButton->SetClickHdl( LINK( this, SortListBox, RemovePressedHdl ) ); - - // fire an un-select event - itemSelected( LISTBOX_ENTRY_NOTFOUND ); - } - - virtual ~SortListBox(); -}; - -SortListBox::~SortListBox() -{ - delete mpListBox; - delete mpUpButton; - delete mpDownButton; - delete mpRemoveButton; -} - -IMPL_LINK( SortListBox, UpPressedHdl, layout::Button *, pBtn ) -{ - (void) pBtn; - USHORT pos = mpListBox->GetSelectEntryPos(); - if ( pos > 0 && pos != LISTBOX_ENTRY_NOTFOUND ) - upPressed( pos ); - return 0; -} - -IMPL_LINK( SortListBox, DownPressedHdl, layout::Button *, pBtn ) -{ - (void) pBtn; - USHORT pos = mpListBox->GetSelectEntryPos(); - if ( pos < mpListBox->GetEntryCount() && pos != LISTBOX_ENTRY_NOTFOUND ) - downPressed( pos ); - return 0; -} - -IMPL_LINK( SortListBox, RemovePressedHdl, layout::Button *, pBtn ) -{ - (void) pBtn; - USHORT pos = mpListBox->GetSelectEntryPos(); - if ( pos != LISTBOX_ENTRY_NOTFOUND ) - removePressed( pos ); - return 0; -} - -IMPL_LINK( SortListBox, ItemSelectedHdl, layout::ListBox *, pList ) -{ - (void) pList; - USHORT pos = mpListBox->GetSelectEntryPos(); - itemSelected( pos ); - return 0; -} - -//** LayoutTree widget - -class LayoutTree : public SortListBox -{ -public: - struct Listener - { - virtual void widgetSelected( Widget *pWidget ) = 0; - }; - -private: - Listener *mpListener; - -public: - Widget *mpRootWidget; - - LayoutTree( layout::Dialog *dialog ) - : SortListBox( new layout::ListBox( dialog, "layout-tree" ), - new layout::PushButton( dialog, "layout-up-button" ), - new layout::PushButton( dialog, "layout-down-button" ), - new layout::PushButton( dialog, "layout-remove-button" ) ) - { - layout::PeerHandle handle = dialog->GetPeerHandle( "preview-box" ); - uno::Reference< awt::XLayoutConstrains > xWidget( handle, uno::UNO_QUERY ); - mpRootWidget = new Widget( xWidget, "root" ); - } - - virtual ~LayoutTree(); - - Widget *getWidget( int nPos ) - { - if ( nPos != LISTBOX_ENTRY_NOTFOUND ) - return FlatLayout::get( mpRootWidget, nPos ); - return NULL; - } - - Widget *getSelectedWidget() - { - Widget *pWidget = getWidget( mpListBox->GetSelectEntryPos() ); - if ( !pWidget ) // return root, if none selected - pWidget = mpRootWidget; - return pWidget; - } - - void selectWidget( Widget *pWidget ) - { - int pos = FlatLayout::get( mpRootWidget, pWidget ); - if ( pos == -1 ) - // if asked to select hidden root, select visible root - pos = 0; - mpListBox->SelectEntryPos( sal::static_int_cast< USHORT >( pos ) ); - } - - void rebuild() - { - struct inner - { - // pads a string with whitespaces - static rtl::OUString padString( rtl::OUString name, int depth ) - { - rtl::OStringBuffer aBuf( depth * 4 + name.getLength() + 2 ); - for (int i = 0; i < depth; i++) - aBuf.append( " " ); - aBuf.append( rtl::OUStringToOString( name, RTL_TEXTENCODING_ASCII_US ) ); - return rtl::OUString( aBuf.getStr(), aBuf.getLength(), - RTL_TEXTENCODING_UTF8 ); - } - }; - - mpListBox->Clear(); - for ( Widget *i = FlatLayout::next( mpRootWidget ); i; i = FlatLayout::next( i ) ) - mpListBox->InsertEntry( inner::padString( i->getLabel(), i->getDepth()-1 ) ); - - // any selection, no longer is. ListBox doesn't fire the event on this case; - // force it. - itemSelected( LISTBOX_ENTRY_NOTFOUND ); - } - - void setListener( Listener *pListener ) - { mpListener = pListener; } - - // print in XML format... - - static rtl::OUString toXMLNaming (const rtl::OUString &string) - { - rtl::OUStringBuffer buffer (string.getLength()); - sal_Unicode *str = string.pData->buffer; - for (int i = 0; i < string.getLength(); i++) { - if ( str[i] >= 'A' && str[i] <= 'Z' ) - { - if ( i > 0 ) - buffer.append ((sal_Unicode) '-'); - buffer.append ((sal_Unicode) (str[i] - 'A' + 'a')); - } - else - buffer.append ((sal_Unicode) str[i]); - } - - return buffer.makeStringAndClear(); - } - - void print() - { - printf("\t\tExport:\n"); - printf("\n" - "\n"); - - for ( Widget *i = FlatLayout::next( mpRootWidget ); i; i = FlatLayout::next( i ) ) - { - for ( int d = i->getDepth(); d > 0; d-- ) - printf(" "); - printf("<%s ", OUSTRING_CSTR( i->getUnoName() ) ); - - for ( int kind = 0; kind < 2; kind++ ) - { - Widget::PropertyKind wKind = kind == 0 ? Widget::WINDOW_PROPERTY - : Widget::CONTAINER_PROPERTY; - Widget::PropertyIterator it( i, wKind ); - while ( it.hasNext() ) - { - beans::Property prop = it.next(); - if ( !i->isPropertyTouched( prop.Name, wKind ) ) - continue; - - rtl::OUString value = i->getProperty( prop.Name, wKind ); - if ( prop.Type.getTypeClass() == uno::TypeClass_BOOLEAN ) - { - if ( value.compareToAscii( "0" ) ) - value = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("false") ); - else - value = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("true") ); - } - - if ( value.getLength() > 0 ) - printf("%s%s=\"%s\" ", - kind == 0 ? "" : "cnt:", - OUSTRING_CSTR( toXMLNaming( prop.Name ) ), OUSTRING_CSTR( value ) - ); - - } - } - printf("/>\n"); - } - printf("\n"); - } - -protected: - virtual void upPressed( USHORT nPos ) - { - Widget *pWidget = getWidget( nPos ); - if ( FlatLayout::moveWidget( pWidget, true ) ) - rebuild(); - selectWidget( pWidget ); - } - - virtual void downPressed( USHORT nPos ) - { - Widget *pWidget = getWidget( nPos ); - if ( FlatLayout::moveWidget( pWidget, false ) ) - rebuild(); - selectWidget( pWidget ); - } - - virtual void removePressed( USHORT nPos ) - { - Widget *pWidget = getWidget( nPos ); - if ( pWidget ) - { - pWidget->up()->removeChild( pWidget ); - delete pWidget; - rebuild(); - } - } - - virtual void itemSelected( USHORT nPos ) - { - mpListener->widgetSelected( getWidget( nPos ) ); - SortListBox::itemSelected( nPos ); - } -}; - -LayoutTree::~LayoutTree() -{ - delete mpRootWidget; -} - -//** EditorImpl - -class EditorImpl : public LayoutTree::Listener -{ - void createWidget( const char *unoName ); - - PropertiesList *mpPropertiesList; - LayoutTree *mpLayoutTree; - - layout::PushButton *pImportButton, *pExportButton; -#ifdef FILEDLG - FileDialog *pImportDialog; -#endif - DECL_LINK( ImportButtonHdl, layout::PushButton* ); - DECL_LINK( ExportButtonHdl, layout::PushButton* ); -#ifdef FILEDLG - DECL_LINK( ImportDialogHdl, FileDialog* ); -#endif - - // framework stuff - uno::Reference< lang::XMultiServiceFactory > mxFactory; - uno::Reference< awt::XToolkit > mxToolkit; - uno::Reference< awt::XWindow > mxToplevel; - - virtual void widgetSelected( Widget *pWidget ); - DECL_LINK( CreateWidgetHdl, layout::Button* ); - - std::list< layout::PushButton *> maCreateButtons; - -public: - - EditorImpl( layout::Dialog *dialog, - // we should probable open this channel (or whatever its called) ourselves - uno::Reference< lang::XMultiServiceFactory > xMSF ); - virtual ~EditorImpl(); - - void loadFile( const rtl::OUString &aTestFile ); -}; - -EditorImpl::EditorImpl( layout::Dialog *dialog, - uno::Reference< lang::XMultiServiceFactory > xFactory ) - : mxFactory( xFactory ) - , mxToplevel( dialog->GetPeerHandle( "dialog" ), uno::UNO_QUERY ) - // FIXME: any of these should work - //dialog->getContext()->getRoot(), uno::UNO_QUERY ) - // dialog->GetPeer(), uno::UNO_QUERY ) -{ -#if DEBUG_PRINT - fprintf (stderr, "EditorImpl()\n"); -#endif - // framework - mxToolkit = uno::Reference< awt::XToolkit >( - mxFactory->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.Toolkit" ) ) ), - uno::UNO_QUERY ); - OSL_ASSERT( mxToolkit.is() ); - - // custom widgets -#if DEBUG_PRINT - fprintf (stderr, "custom widgets\n"); -#endif - mpPropertiesList = new PropertiesList( dialog ); - - mpLayoutTree = new LayoutTree( dialog ); - mpLayoutTree->setListener( this ); - -/* if ( xImport.is() ) - mpLayoutTree->getWidget( -1 )->addChild( new Widget( xImport, "import" ) );*/ - - // create buttons - layout::Container aWidgets( dialog, "create-widget" ); - layout::Container aContainers( dialog, "create-container" ); - for ( int i = 0; i < WIDGETS_SPECS_LEN; i++ ) - { - layout::PushButton *pBtn = new layout::PushButton( (layout::Window *) dialog ); - pBtn->SetText( rtl::OUString::createFromAscii( WIDGETS_SPECS[ i ].pLabel ) ); - pBtn->SetClickHdl( LINK( this, EditorImpl, CreateWidgetHdl ) ); - if ( WIDGETS_SPECS[ i ].pIconName != NULL ) - { - rtl::OString aPath ("cmd/"); - aPath += WIDGETS_SPECS[ i ].pIconName; - layout::Image aImg( aPath ); - pBtn->SetModeImage( aImg ); - pBtn->SetImageAlign( IMAGEALIGN_LEFT ); - } - pBtn->Show(); - maCreateButtons.push_back( pBtn ); - layout::Container *pBox = WIDGETS_SPECS[ i ].bIsContainer ? &aContainers : &aWidgets; - pBox->Add( pBtn ); - } - -#ifdef FILEDLG - fprintf(stderr,"creating file dialog\n"); - pImportDialog = new FileDialog( NULL/*(layout::Window *) dialog*/, 0 ); - fprintf(stderr,"connecting it\n"); - pImportDialog->SetFileSelectHdl( LINK( this, EditorImpl, ImportDialogHdl ) ); - fprintf(stderr,"done file dialog\n"); -#endif - -/* pImportButton = new layout::PushButton( dialog, "import-button" ); - pImportButton->SetClickHdl( LINK( this, EditorImpl, ImportButtonHdl ) );*/ - pExportButton = new layout::PushButton( dialog, "export-button" ); - pExportButton->SetClickHdl( LINK( this, EditorImpl, ExportButtonHdl ) ); -} - -EditorImpl::~EditorImpl() -{ - delete mpPropertiesList; - delete mpLayoutTree; - for ( std::list< layout::PushButton * >::const_iterator i = maCreateButtons.begin(); - i != maCreateButtons.end(); ++i) - delete *i; - delete pImportButton; - delete pExportButton; -#ifdef FILEDLG - delete pImportDialog; -#endif -} - -void EditorImpl::loadFile( const rtl::OUString &aTestFile ) -{ - fprintf( stderr, "TEST: layout instance\n" ); - uno::Reference< awt::XLayoutRoot > xRoot - ( new EditorRoot( mxFactory, mpLayoutTree->mpRootWidget ) ); - -/* - mxMSF->createInstance - ( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.Layout")) ), - uno::UNO_QUERY ); -*/ - if ( !xRoot.is() ) - { - throw uno::RuntimeException( - OUString( RTL_CONSTASCII_USTRINGPARAM("could not create awt Layout component!") ), - uno::Reference< uno::XInterface >() ); - } - -#if DEBUG_PRINT - fprintf( stderr, "TEST: initing root\n" ); -#endif - - uno::Reference< lang::XInitialization > xInit( xRoot, uno::UNO_QUERY ); - if ( !xInit.is() ) - { - throw uno::RuntimeException( - OUString( RTL_CONSTASCII_USTRINGPARAM("Layout has no XInitialization!") ), - uno::Reference< uno::XInterface >() ); - } - -#if DEBUG_PRINT - fprintf( stderr, "TEST: running parser\n" ); -#endif - uno::Sequence< uno::Any > aParams( 1 ); - aParams[0] <<= aTestFile; -#if DEBUG_PRINT - fprintf( stderr, "TEST: do it\n" ); -#endif - xInit->initialize( aParams ); -#if DEBUG_PRINT - fprintf( stderr, "TEST: file loaded\n" ); -#endif - - mpLayoutTree->rebuild(); -} - -void EditorImpl::createWidget( const char *name ) -{ - Widget *pWidget = mpLayoutTree->getSelectedWidget(); - - Widget *pChild = new Widget( rtl::OUString(), mxToolkit, uno::Reference< awt::XLayoutContainer >( mxToplevel, uno::UNO_QUERY ), rtl::OUString::createFromAscii( name ), awt::WindowAttribute::SHOW ); - if ( !pWidget->addChild( pChild ) ) - { - delete pChild; - // we may want to popup an error message - } - else - { - mpLayoutTree->rebuild(); - mpLayoutTree->selectWidget( pWidget ); - } -} - -void EditorImpl::widgetSelected( Widget *pWidget ) -{ - // we know can't add widget to a non-container, so let's disable the create - // buttons then. Would be nice to have a method to check if a container is - // full as well... - if ( !pWidget || pWidget->isContainer() ) - { - for ( std::list< layout::PushButton *>::const_iterator it = maCreateButtons.begin(); - it != maCreateButtons.end(); ++it) - (*it)->Enable(); - } - else - { - for ( std::list< layout::PushButton *>::const_iterator it = maCreateButtons.begin(); - it != maCreateButtons.end(); ++it) - (*it)->Disable(); - } - - mpPropertiesList->selectedWidget( pWidget ); -} - -IMPL_LINK( EditorImpl, CreateWidgetHdl, layout::Button *, pBtn ) -{ - int i = 0; - for ( std::list< layout::PushButton *>::const_iterator it = maCreateButtons.begin(); - it != maCreateButtons.end(); ++it, ++i ) - { - if ( pBtn == *it ) - break; - } - OSL_ASSERT( i < WIDGETS_SPECS_LEN ); - createWidget( WIDGETS_SPECS[i].pName ); - return 0; -} - -IMPL_LINK( EditorImpl, ImportButtonHdl, layout::PushButton *, pBtn ) -{ - (void) pBtn; -#if DEBUG_PRINT - fprintf(stderr, "IMPORT!\n"); -#endif -#ifdef FILEDLG - pImportDialog->Execute(); -#endif - - return 0; -} - -#ifdef FILEDLG -IMPL_LINK( EditorImpl, ImportDialogHdl, FileDialog *, pDialog ) -{ - UniString path = pDialog->GetPath(); -//fprintf(stderr, "Executing import dialog!\n"); - -#if DEBUG_PRINT - fprintf(stderr, "got import file: %s\n",rtl::OUStringToOString( path, RTL_TEXTENCODING_ASCII_US ).getStr() ); -#endif - - return 0; -} -#endif - -IMPL_LINK( EditorImpl, ExportButtonHdl, layout::PushButton *, pBtn ) -{ - (void) pBtn; - mpLayoutTree->print(); - return 0; -} - -//** Editor, the Dialog - -Editor::Editor( uno::Reference< lang::XMultiServiceFactory > xFactory, - rtl::OUString aFile ) - : layout::Dialog( (Window*) (NULL), "editor.xml", "dialog" ) - , mpImpl( new EditorImpl( this, xFactory ) ) -{ - if ( aFile.getLength() ) - mpImpl->loadFile( aFile ); - - // parent: - FreeResource(); -} - -Editor::~Editor() -{ - delete mpImpl; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/workben/layout/editor.hxx b/toolkit/workben/layout/editor.hxx deleted file mode 100644 index c977941703fa..000000000000 --- a/toolkit/workben/layout/editor.hxx +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef EDITOR_HXX -#define EDITOR_HXX - -#include -#include - -class EditorImpl; - -class Editor : public layout::Dialog -{ -EditorImpl *mpImpl; - -public: - Editor( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > xMSF, - rtl::OUString aFile ); - ~Editor(); - - void loadFile( const rtl::OUString &aTestFile ); -}; - -#endif /*EDITOR_HXX*/ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/workben/layout/editor.xml b/toolkit/workben/layout/editor.xml deleted file mode 100644 index 4126dea8b289..000000000000 --- a/toolkit/workben/layout/editor.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - diff --git a/toolkit/workben/layout/empty.xml b/toolkit/workben/layout/empty.xml deleted file mode 100644 index a8408e55719e..000000000000 --- a/toolkit/workben/layout/empty.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/toolkit/workben/layout/flow-container.xml b/toolkit/workben/layout/flow-container.xml deleted file mode 100644 index 3d48b1683216..000000000000 --- a/toolkit/workben/layout/flow-container.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - -
- - - - -
- - - - - - - - - -
- - - - - -
- - - - - - - - - - - - - - - - - -
-
diff --git a/toolkit/workben/layout/flow.xml b/toolkit/workben/layout/flow.xml deleted file mode 100644 index 03e879bb13c1..000000000000 --- a/toolkit/workben/layout/flow.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/toolkit/workben/layout/insert-sheet.xml b/toolkit/workben/layout/insert-sheet.xml deleted file mode 100644 index 2350da9aec77..000000000000 --- a/toolkit/workben/layout/insert-sheet.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/toolkit/workben/layout/interactable-containers.xml b/toolkit/workben/layout/interactable-containers.xml deleted file mode 100644 index afb663951d6c..000000000000 --- a/toolkit/workben/layout/interactable-containers.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - -
-
-
-
diff --git a/toolkit/workben/layout/layout-flat.xml b/toolkit/workben/layout/layout-flat.xml deleted file mode 100644 index 0d3b969020fb..000000000000 --- a/toolkit/workben/layout/layout-flat.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/toolkit/workben/layout/layout.xml b/toolkit/workben/layout/layout.xml deleted file mode 100644 index 4d9e71bbc5b9..000000000000 --- a/toolkit/workben/layout/layout.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - diff --git a/toolkit/workben/layout/message-box.xml b/toolkit/workben/layout/message-box.xml deleted file mode 100644 index 2bd19bbb42fb..000000000000 --- a/toolkit/workben/layout/message-box.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/toolkit/workben/layout/more.xml b/toolkit/workben/layout/more.xml deleted file mode 100644 index 79e9c8214356..000000000000 --- a/toolkit/workben/layout/more.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/toolkit/workben/layout/move-copy-sheet.xml b/toolkit/workben/layout/move-copy-sheet.xml deleted file mode 100644 index 3d26db1aa73d..000000000000 --- a/toolkit/workben/layout/move-copy-sheet.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/toolkit/workben/layout/non-interactable-containers.xml b/toolkit/workben/layout/non-interactable-containers.xml deleted file mode 100644 index 29b37b6a7a49..000000000000 --- a/toolkit/workben/layout/non-interactable-containers.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - -
- - - - - - - - - - -
- - - - - -
- - - - -
-
diff --git a/toolkit/workben/layout/number-format.xml b/toolkit/workben/layout/number-format.xml deleted file mode 100644 index 77460ea79ceb..000000000000 --- a/toolkit/workben/layout/number-format.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/toolkit/workben/layout/numeric.xml b/toolkit/workben/layout/numeric.xml deleted file mode 100644 index becab18cdf9b..000000000000 --- a/toolkit/workben/layout/numeric.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - diff --git a/toolkit/workben/layout/ooo-patch b/toolkit/workben/layout/ooo-patch deleted file mode 100644 index 89fc58db8748..000000000000 --- a/toolkit/workben/layout/ooo-patch +++ /dev/null @@ -1,7 +0,0 @@ -#! /bin/sh -commit=${1-3249db59} # m5 - -git diff $commit layout | sed 's@^\([+-]\{3\}\) \(a\|b\)/@\1 @' > layout-dialogs-layout.diff -git diff $commit config_office scp2 | sed 's@^\([+-]\{3\}\) \(a\|b\)/@\1 @' > layout-dialogs-config_office-scp2.diff -git diff $commit svx sw | sed 's@^\([+-]\{3\}\) \(a\|b\)/@\1 @' > layout-dialogs-svx-sw.diff -git diff $commit transex3 | sed 's@^\([+-]\{3\}\) \(a\|b\)/@\1 @' > layout-dialogs-transex3.diff diff --git a/toolkit/workben/layout/paragraph.xml b/toolkit/workben/layout/paragraph.xml deleted file mode 100644 index 847e04ec0568..000000000000 --- a/toolkit/workben/layout/paragraph.xml +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - - - - - - - - - - -
- - - - - - - - - -
- - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - -
- - - - - - - - - -
-
diff --git a/toolkit/workben/layout/plugin.cxx b/toolkit/workben/layout/plugin.cxx deleted file mode 100644 index 65af2e510021..000000000000 --- a/toolkit/workben/layout/plugin.cxx +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#define _LAYOUT_PLUGIN_CXX - -#include "plugin.hxx" - -#include -#include -#include - -#include - -using namespace com::sun::star; - -#define LAYOUT_RES(x) #x - -#undef ModalDialog -#define ModalDialog( parent, id ) Dialog( parent, "plugin.xml", id ) - -PluginDialog::PluginDialog( Window* pParent ) - : ModalDialog( pParent, LAYOUT_RES( RID_DLG_PLUGIN ) ) - , aHeaderImage( this, LAYOUT_RES( FI_HEADER ) ) - , aHeaderText( this, LAYOUT_RES( FT_HEADER ) ) - , aHeaderLine( this, LAYOUT_RES( FL_HEADER ) ) - , aPlugin( this, LAYOUT_RES( PL_DIAL ), -// FIXME: width=, height=, are not recognized as properties. -// new svx::DialControl( LAYOUT_DIALOG_PARENT, Size( 0, 0 ), 0 ) ) - new svx::DialControl( LAYOUT_DIALOG_PARENT, Size( 80, 80 ), 0 ) ) - //, aDialControl( static_cast ( aPlugin.GetPlugin() ) ) - , aDialControl( static_cast ( *aPlugin.mpPlugin ) ) - , aOKBtn( this, LAYOUT_RES( BTN_OK ) ) - , aCancelBtn( this, LAYOUT_RES( BTN_CANCEL ) ) - , aHelpBtn( this, LAYOUT_RES( BTN_HELP ) ) -{ - aDialControl.SetRotation( 425 ); -} - -PluginDialog::~PluginDialog() -{ -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/workben/layout/plugin.hxx b/toolkit/workben/layout/plugin.hxx deleted file mode 100644 index 862e6f6dc85a..000000000000 --- a/toolkit/workben/layout/plugin.hxx +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _LAYOUT_PLUGIN_HXX -#define _LAYOUT_PLUGIN_HXX - -#include -#include - -namespace svx { -class DialControl; -} - -class PluginDialog : public ModalDialog -{ -private: - FixedImage aHeaderImage; - FixedText aHeaderText; - FixedLine aHeaderLine; - Plugin aPlugin; - svx::DialControl& aDialControl; - OKButton aOKBtn; - CancelButton aCancelBtn; - HelpButton aHelpBtn; - -public: - PluginDialog( Window* pParent ); - ~PluginDialog(); -}; - -#include - -#endif /* _LAYOUT_PLUGIN_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/workben/layout/plugin.xml b/toolkit/workben/layout/plugin.xml deleted file mode 100644 index 5303e3a2329e..000000000000 --- a/toolkit/workben/layout/plugin.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/toolkit/workben/layout/radio-groups.xml b/toolkit/workben/layout/radio-groups.xml deleted file mode 100644 index 43a1372297ee..000000000000 --- a/toolkit/workben/layout/radio-groups.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - diff --git a/toolkit/workben/layout/recover.cxx b/toolkit/workben/layout/recover.cxx deleted file mode 100644 index c776ec0bd8d2..000000000000 --- a/toolkit/workben/layout/recover.cxx +++ /dev/null @@ -1,113 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifdef SVX_DLLIMPLEMENTATION -#undef SVX_DLLIMPLEMENTATION -#endif - -#if TEST_LAYOUT -#include -#endif /* TEST_LAYOUT */ -#include -#include -#include -#include -#include -#include -#include - - -#include //redrawAlready - -using namespace com::sun::star; - -#define _SVX_RECOVER_CXX - -#include "recover.hxx" - -#include - -#if ENABLE_LAYOUT -#undef SVX_RES -#define SVX_RES(x) #x -#undef SfxModalDialog -#define SfxModalDialog( parent, id ) Dialog( parent, "recover.xml", id ) -#endif /* ENABLE_LAYOUT */ - -#if TEST_LAYOUT -SvxRecoverDialog::SvxRecoverDialog( Window* pParent ) -#else /* !TEST_LAYOUT */ -SvxRecoverDialog::SvxRecoverDialog( Window* pParent, const SfxItemSet& rCoreSet ) -#endif /* !TEST_LAYOUT */ -: SfxModalDialog( pParent, SVX_RES( RID_SVXDLG_RECOVER ) ) - - , aHeaderImage( this, SVX_RES( FI_HEADER ) ) - , aHeaderText( this, SVX_RES( FT_HEADER ) ) - , aHeaderLine( this, SVX_RES( FL_HEADER ) ) - , aRecoverText( this, SVX_RES( FT_RECOVER ) ) - , aTextAdvanced( this, SVX_RES( FT_ADVANCED ) ) - - , aCheckBoxDoc( this, SVX_RES( CB_DOC ) ) - , aImageDoc( this, SVX_RES( FI_DOC ) ) - , aTextDoc( this, SVX_RES( FT_DOC ) ) - - , aCheckBoxSheet( this, SVX_RES( CB_SHEET ) ) - , aImageSheet( this, SVX_RES( FI_SHEET ) ) - , aTextSheet( this, SVX_RES( FT_SHEET ) ) - - , aCheckBoxDraw( this, SVX_RES( CB_DRAW ) ) - , aImageDraw( this, SVX_RES( FI_DRAW ) ) - , aTextDraw( this, SVX_RES( FT_DRAW ) ) - - , aCheckBoxPresent( this, SVX_RES( CB_PRESENT ) ) - , aImagePresent( this, SVX_RES( FI_PRESENT ) ) - , aTextPresent( this, SVX_RES( FT_PRESENT ) ) - - , aButtonAdvanced( this, SVX_RES( PB_ADVANCED ) ) - - , aProgressText( this, SVX_RES( FT_PROGRESS ) ) - , aProgressBar( this, SVX_RES( PB_RECOVER ) ) - , aCheckBoxLogFile( this, SVX_RES( CH_LOGFILE ) ) - , aOKBtn( this, SVX_RES( BTN_OK ) ) - , aCancelBtn( this, SVX_RES( BTN_CANCEL ) ) - , aHelpBtn( this, SVX_RES( BTN_HELP ) ) -{ - aButtonAdvanced.AddAdvanced( &aTextAdvanced ); - aButtonAdvanced.AddAdvanced( &aCheckBoxDoc ); - aButtonAdvanced.AddAdvanced( &aCheckBoxSheet ); - aButtonAdvanced.AddAdvanced( &aCheckBoxDraw ); - aButtonAdvanced.AddAdvanced( &aCheckBoxPresent ); - aButtonAdvanced.AddAdvanced( &aCheckBoxLogFile ); -} - - -SvxRecoverDialog::~SvxRecoverDialog() -{ -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/workben/layout/recover.hxx b/toolkit/workben/layout/recover.hxx deleted file mode 100644 index de3a63c84510..000000000000 --- a/toolkit/workben/layout/recover.hxx +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _SVX_RECOVER_HXX -#define _SVX_RECOVER_HXX - -#include -#include -#include -#include -#include -#include - -class SvxRecoverDialog : public SfxModalDialog -{ -private: - FixedImage aHeaderImage; - FixedText aHeaderText; - FixedLine aHeaderLine; - FixedText aRecoverText; - FixedText aTextAdvanced; - - CheckBox aCheckBoxDoc; - FixedImage aImageDoc; - FixedText aTextDoc; - CheckBox aCheckBoxSheet; - FixedImage aImageSheet; - FixedText aTextSheet; - CheckBox aCheckBoxDraw; - FixedImage aImageDraw; - FixedText aTextDraw; - CheckBox aCheckBoxPresent; - FixedImage aImagePresent; - FixedText aTextPresent; - AdvancedButton aButtonAdvanced; - - FixedText aProgressText; - ProgressBar aProgressBar; - CheckBox aCheckBoxLogFile; - OKButton aOKBtn; - CancelButton aCancelBtn; - HelpButton aHelpBtn; - -public: -#if TEST_LAYOUT - SvxRecoverDialog( Window* pParent ); -#else /* !TEST_LAYOUT */ - SvxRecoverDialog( Window* pParent, const SfxItemSet& rCoreSet ); -#endif /* !TEST_LAYOUT */ - ~SvxRecoverDialog(); -}; - -#include - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/workben/layout/recover.xml b/toolkit/workben/layout/recover.xml deleted file mode 100644 index 790a6b694658..000000000000 --- a/toolkit/workben/layout/recover.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/toolkit/workben/layout/refresh b/toolkit/workben/layout/refresh deleted file mode 100644 index 796999549c36..000000000000 --- a/toolkit/workben/layout/refresh +++ /dev/null @@ -1,7 +0,0 @@ -echo "source me ..." -test -n "${INPATH}" && rm -Rf ../../${INPATH} -build debug=true\ - && cp ../../${INPATH}/lib/*.so ../../../solver/300/${INPATH}/lib \ - && cp -f ../..$INPATH/lib/libtkx.so $OOO_INSTALL_PREFIX/openoffice.org/basis3.0/program \ - && dmake debug=true \ - && ../../${INPATH}/bin/test "$@" diff --git a/toolkit/workben/layout/run-s2x b/toolkit/workben/layout/run-s2x deleted file mode 100644 index 926addf49047..000000000000 --- a/toolkit/workben/layout/run-s2x +++ /dev/null @@ -1,6 +0,0 @@ -#! /bin/sh - -SRC=${1-../../svx/source/dialog/zoom.src} -SRC=${1-../../sw/source/ui/dialog/wordcountdialog.src} - -../src2xml/source/src2xml.py --ignore-includes --post-process --output-dir=. $SRC diff --git a/toolkit/workben/layout/scroller.xml b/toolkit/workben/layout/scroller.xml deleted file mode 100644 index 44e63d15df5e..000000000000 --- a/toolkit/workben/layout/scroller.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/toolkit/workben/layout/sequence.xml b/toolkit/workben/layout/sequence.xml deleted file mode 100644 index e89db54db2dc..000000000000 --- a/toolkit/workben/layout/sequence.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - diff --git a/toolkit/workben/layout/shutdown.xml b/toolkit/workben/layout/shutdown.xml deleted file mode 100644 index fbe49e046cb4..000000000000 --- a/toolkit/workben/layout/shutdown.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/toolkit/workben/layout/simple-paragraph.cxx b/toolkit/workben/layout/simple-paragraph.cxx deleted file mode 100644 index 4cd204d107f7..000000000000 --- a/toolkit/workben/layout/simple-paragraph.cxx +++ /dev/null @@ -1,183 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifdef SVX_DLLIMPLEMENTATION -#undef SVX_DLLIMPLEMENTATION -#endif - -#include - -// include --------------------------------------------------------------- - -#include -#include -#include -#include - -#include - -namespace SVX { -#include // Preview -}; - -#include "simple-paragraph.hxx" - -#include - - - - - -// StandardTabPage ---------------------------------------------------------- - -#define FT_LEFTINDENT 10 -#define ED_LEFTINDENT 11 -#define FT_FLINEINDENT 12 -#define ED_FLINEINDENT 13 -#define FT_RIGHTINDENT 14 -#define ED_RIGHTINDENT 15 -#define FL_INDENT 16 - -#define FT_TOPDIST 20 -#define ED_TOPDIST 21 -#define FT_BOTTOMDIST 22 -#define ED_BOTTOMDIST 23 -#define FL_DIST 24 - -#define BTN_LEFTALIGN 30 -#define BTN_RIGHTALIGN 31 -#define BTN_CENTERALIGN 32 -#define BTN_JUSTIFYALIGN 33 -#define FL_ALIGN 34 -#define FL_VERTALIGN 35 -#define LB_VERTALIGN 36 -#define FL_VERTEX 37 -#define CB_SNAP 38 -#define FT_VERTALIGN 39 - - -#define LB_LINEDIST 40 -#define FT_LINEDIST 41 -#define ED_LINEDISTPERCENT 42 -#define ED_LINEDISTMETRIC 43 -#define FL_LINEDIST 44 -#define WN_EXAMPLE 46 - -#define CB_AUTO 48 -#define FT_LASTLINE 49 -#define LB_LASTLINE 50 -#define CB_EXPAND 51 -#define ST_LINEDIST_ABS 52 -#define ST_LEFTALIGN_ASIAN 53 -#define ST_RIGHTALIGN_ASIAN 54 - -// ExtendedTabPage ---------------------------------------------------------- - -#define BTN_HYPHEN 50 -#define ED_HYPHENBEFORE 52 -#define FT_HYPHENBEFORE 53 -#define ED_HYPHENAFTER 55 -#define FT_HYPHENAFTER 56 -#define FL_HYPHEN 57 - -#define BTN_PAGEBREAK 60 -#define FT_BREAKTYPE 61 -#define LB_BREAKTYPE 62 -#define FT_BREAKPOSITION 63 -#define LB_BREAKPOSITION 64 -#define BTN_PAGECOLL 65 -#define LB_PAGECOLL 66 -#define BTN_KEEPTOGETHER 67 -#define BTN_WIDOWS 68 -#define ED_WIDOWS 69 -#define FT_WIDOWS 70 -#define BTN_ORPHANS 71 -#define ED_ORPHANS 72 -#define FT_ORPHANS 73 -#define FL_OPTIONS 74 -#define FT_PAGENUM 75 -#define ED_PAGENUM 76 -#define FL_BREAKS 77 - -#define CB_KEEPTOGETHER 80 -#define FT_MAXHYPH 81 -#define ED_MAXHYPH 83 - -#define CB_REGISTER 84 -#define FL_REGISTER 85 -#define FL_PROPERTIES 90 -#define FT_TEXTDIRECTION 91 -#define LB_TEXTDIRECTION 92 - - -//asian typography -#define FL_AS_OPTIONS 1 -#define CB_AS_HANG_PUNC 2 -#define CB_AS_ALLOW_WORD_BREAK 3 -#define CB_AS_FORBIDDEN 4 -#define FL_AS_CHAR_DIST 5 -#define CB_AS_PUNCTUATION 6 -#define CB_AS_SCRIPT_SPACE 7 -#define CB_AS_ADJUST_NUMBERS 8 - - - - - - - - -SvxSimpleParagraphDialog::SvxSimpleParagraphDialog( Window* pParent ) - : SfxTabPage( pParent, SVX_RES( RID_SVXPAGE_STD_PARAGRAPH ), rAttr ) - , Dialog( pParent, "simple-paragraph.xml", "dialog" ) - , aLineSpacingList( this, "line-spacing-list" ) - , pPrevWin(NULL) -{ -fprintf(stderr, "creating res mgr\n"); - pMgr = ResMgr::CreateResMgr("SOME_NAME"); -fprintf(stderr, "getting parent\n"); - VCLXWindow *pCompParent = VCLXWindow::GetImplementation( GetPeer() ); - assert( pCompParent != NULL ); - assert( pCompParent->GetWindow() != NULL ); -fprintf(stderr, "creating foreign vcl widget\n"); -/* pPrevWin = new SVX::SvxParaPrevWindow( - pCompParent->GetWindow(), - ResId(1234, *pMgr) - );*/ - -fprintf(stderr, "done\n"); - FreeResource(); -} - -// ----------------------------------------------------------------------- - -SvxSimpleParagraphDialog::~SvxSimpleParagraphDialog() -{ -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/workben/layout/simple-paragraph.hxx b/toolkit/workben/layout/simple-paragraph.hxx deleted file mode 100644 index d4feff479135..000000000000 --- a/toolkit/workben/layout/simple-paragraph.hxx +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef _SVX_SIMPLE_PARAGRAPH_HXX -#define _SVX_SIMPLE_PARAGRAPH_HXX - -#include - -#include // Preview - -namespace SVX { - class SvxParaPrevWindow; -}; -class ResMgr; - -class SvxSimpleParagraphDialog : public SfxTabPage, public layout::Dialog -{ -private: - ListBox aLineSpacingList; - SVX::SvxParaPrevWindow *pPrevWin; - ResMgr *pMgr; - -public: - SvxSimpleParagraphDialog( Window* pParent ); - ~SvxSimpleParagraphDialog(); -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/workben/layout/simple-paragraph.xml b/toolkit/workben/layout/simple-paragraph.xml deleted file mode 100644 index e07909dc8a39..000000000000 --- a/toolkit/workben/layout/simple-paragraph.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - diff --git a/toolkit/workben/layout/sort-options.xml b/toolkit/workben/layout/sort-options.xml deleted file mode 100644 index a409ac2d530a..000000000000 --- a/toolkit/workben/layout/sort-options.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/toolkit/workben/layout/sortdlg.cxx b/toolkit/workben/layout/sortdlg.cxx deleted file mode 100644 index ecc18da4fbc8..000000000000 --- a/toolkit/workben/layout/sortdlg.cxx +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#if !TEST_LAYOUT -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sc.hxx" -#endif /*! TEST_LAYOUT */ - -#undef SC_DLLIMPLEMENTATION - - - -#include "tpsort.hxx" -#include "sortdlg.hxx" -#include "scresid.hxx" -#include "sortdlg.hrc" - -#if !LAYOUT_SFX_TABDIALOG_BROKEN -#include -#endif - -ScSortDlg::ScSortDlg( Window* pParent, - const SfxItemSet* pArgSet ) : - SfxTabDialog( pParent, - ScResId( RID_SCDLG_SORT ), - pArgSet ), - bIsHeaders ( FALSE ), - bIsByRows ( FALSE ) - -{ -#if LAYOUT_SFX_TABDIALOG_BROKEN - AddTabPage( TP_FIELDS, ScTabPageSortFields::Create, 0 ); - AddTabPage( TP_OPTIONS, ScTabPageSortOptions::Create, 0 ); -#else /* !LAYOUT_SFX_TABDIALOG_BROKEN */ - String fields(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("fields"))); - AddTabPage( TP_FIELDS, fields, ScTabPageSortFields::Create, 0, FALSE, TAB_APPEND); - String options(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("options"))); - AddTabPage( TP_OPTIONS, options, ScTabPageSortOptions::Create, 0, FALSE, TAB_APPEND); -#endif /* !LAYOUT_SFX_TABDIALOG_BROKEN */ - FreeResource(); -} - -ScSortDlg::~ScSortDlg() -{ -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/workben/layout/sortdlg.hrc b/toolkit/workben/layout/sortdlg.hrc deleted file mode 100644 index 1b62f3f8cbac..000000000000 --- a/toolkit/workben/layout/sortdlg.hrc +++ /dev/null @@ -1,71 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -#include "sc.hrc" // -> RID_SCDLG_SORT - // -> RID_SCPAGE_SORT_FIELDS - // -> RID_SCPAGE_SORT_OPTIONS - // -> SCSTR_NONAME - // -> SCSTR_UNDEFINED - // -> SCSTR_FIELD - -#define TP_FIELDS 1 -#define TP_OPTIONS 2 - -// TP_SORT_FIELDS: -#define FL_SORT1 1 -#define FL_SORT2 2 -#define FL_SORT3 3 -#define LB_SORT1 4 -#define LB_SORT2 5 -#define LB_SORT3 6 -#define BTN_UP1 7 -#define BTN_UP2 8 -#define BTN_UP3 9 -#define BTN_DOWN1 10 -#define BTN_DOWN2 11 -#define BTN_DOWN3 12 - -// TP_SORT_OPTIONS: -#define FL_DIRECTION 1 -#define LB_SORT_USER 2 -#define LB_OUTAREA 3 -#define ED_OUTAREA 4 -#define BTN_SORT_USER 7 -#define BTN_CASESENSITIVE 8 -#define BTN_LABEL 9 -#define BTN_FORMATS 10 -#define BTN_COPYRESULT 11 -#define BTN_TOP_DOWN 12 -#define BTN_LEFT_RIGHT 13 -#define STR_COL_LABEL 14 -#define STR_ROW_LABEL 15 -#define FT_LANGUAGE 16 -#define LB_LANGUAGE 17 -#define FT_ALGORITHM 18 -#define LB_ALGORITHM 19 -#define BTN_NATURALSORT 20 diff --git a/toolkit/workben/layout/sortdlg.hxx b/toolkit/workben/layout/sortdlg.hxx deleted file mode 100644 index c63f24989aca..000000000000 --- a/toolkit/workben/layout/sortdlg.hxx +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef SC_SORTDLG_HXX -#define SC_SORTDLG_HXX - -#include - -#if TEST_LAYOUT -#define LAYOUT_SFX_TABDIALOG_BROKEN 0 -#else /* !TEST_LAYOUT */ -#ifndef LAYOUT_SFX_TABDIALOG_BROKEN -#define LAYOUT_SFX_TABDIALOG_BROKEN 1 -#endif /* !LAYOUT_SFX_TABDIALOG_BROKEN */ -#endif /* !TEST_LAYOUT */ - -#if !LAYOUT_SFX_TABDIALOG_BROKEN -#include -#include -#endif - -class ScSortDlg : public SfxTabDialog -{ -public: - ScSortDlg( Window* pParent, - const SfxItemSet* pArgSet ); - ~ScSortDlg(); - - void SetHeaders( BOOL bHeaders ); - void SetByRows ( BOOL bByRows ); - BOOL GetHeaders() const; - BOOL GetByRows () const; - - -private: - BOOL bIsHeaders; - BOOL bIsByRows; -}; - -inline void ScSortDlg::SetHeaders( BOOL bHeaders ) { bIsHeaders = bHeaders; } -inline void ScSortDlg::SetByRows ( BOOL bByRows ) { bIsByRows = bByRows; } -inline BOOL ScSortDlg::GetHeaders() const { return bIsHeaders; } -inline BOOL ScSortDlg::GetByRows () const { return bIsByRows; } - -#if !LAYOUT_SFX_TABDIALOG_BROKEN -#include -#endif - -#endif // SC_SORTDLG_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/workben/layout/sortdlg.src b/toolkit/workben/layout/sortdlg.src deleted file mode 100644 index f52758f61785..000000000000 --- a/toolkit/workben/layout/sortdlg.src +++ /dev/null @@ -1,331 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "sortdlg.hrc" -TabPage RID_SCPAGE_SORT_FIELDS -{ - Hide = TRUE ; - SVLook = TRUE ; - HelpId = HID_SCPAGE_SORT_FIELDS ; - Size = MAP_APPFONT ( 260 , 185 ) ; - ListBox LB_SORT1 - { - HelpID = "toolkit:ListBox:RID_SCPAGE_SORT_FIELDS:LB_SORT1"; - Border = TRUE ; - Pos = MAP_APPFONT ( 12 , 19 ) ; - Size = MAP_APPFONT ( 154 , 90 ) ; - TabStop = TRUE ; - DropDown = TRUE ; - }; - RadioButton BTN_UP1 - { - HelpID = "toolkit:RadioButton:RID_SCPAGE_SORT_FIELDS:BTN_UP1"; - Pos = MAP_APPFONT ( 172 , 14 ) ; - Size = MAP_APPFONT ( 79 , 10 ) ; - Text [ en-US ] = "~Ascending" ; - TabStop = TRUE ; - }; - RadioButton BTN_DOWN1 - { - HelpID = "toolkit:RadioButton:RID_SCPAGE_SORT_FIELDS:BTN_DOWN1"; - Pos = MAP_APPFONT ( 172 , 28 ) ; - Size = MAP_APPFONT ( 79 , 10 ) ; - Text [ en-US ] = "~Descending" ; - TabStop = TRUE ; - }; - FixedLine FL_SORT1 - { - Pos = MAP_APPFONT ( 6 , 3 ) ; - Size = MAP_APPFONT ( 248 , 8 ) ; - Text [ en-US ] = "Sort ~by" ; - }; - ListBox LB_SORT2 - { - HelpID = "toolkit:ListBox:RID_SCPAGE_SORT_FIELDS:LB_SORT2"; - Border = TRUE ; - Pos = MAP_APPFONT ( 12 , 60 ) ; - Size = MAP_APPFONT ( 154 , 90 ) ; - TabStop = TRUE ; - DropDown = TRUE ; - }; - RadioButton BTN_UP2 - { - HelpID = "toolkit:RadioButton:RID_SCPAGE_SORT_FIELDS:BTN_UP2"; - Pos = MAP_APPFONT ( 172 , 55 ) ; - Size = MAP_APPFONT ( 79 , 10 ) ; - Text [ en-US ] = "A~scending" ; - TabStop = TRUE ; - }; - RadioButton BTN_DOWN2 - { - HelpID = "toolkit:RadioButton:RID_SCPAGE_SORT_FIELDS:BTN_DOWN2"; - Pos = MAP_APPFONT ( 172 , 69 ) ; - Size = MAP_APPFONT ( 79 , 10 ) ; - Text [ en-US ] = "D~escending" ; - TabStop = TRUE ; - }; - FixedLine FL_SORT2 - { - Pos = MAP_APPFONT ( 6 , 44 ) ; - Size = MAP_APPFONT ( 248 , 8 ) ; - Text [ en-US ] = "Then b~y" ; - }; - ListBox LB_SORT3 - { - HelpID = "toolkit:ListBox:RID_SCPAGE_SORT_FIELDS:LB_SORT3"; - Border = TRUE ; - Pos = MAP_APPFONT ( 12 , 101 ) ; - Size = MAP_APPFONT ( 154 , 90 ) ; - TabStop = TRUE ; - DropDown = TRUE ; - }; - RadioButton BTN_UP3 - { - HelpID = "toolkit:RadioButton:RID_SCPAGE_SORT_FIELDS:BTN_UP3"; - Pos = MAP_APPFONT ( 172 , 96 ) ; - Size = MAP_APPFONT ( 79 , 10 ) ; - Text [ en-US ] = "As~cending" ; - TabStop = TRUE ; - }; - RadioButton BTN_DOWN3 - { - HelpID = "toolkit:RadioButton:RID_SCPAGE_SORT_FIELDS:BTN_DOWN3"; - Pos = MAP_APPFONT ( 172 , 110 ) ; - Size = MAP_APPFONT ( 79 , 10 ) ; - Text [ en-US ] = "Desce~nding" ; - TabStop = TRUE ; - }; - FixedLine FL_SORT3 - { - Pos = MAP_APPFONT ( 6 , 85 ) ; - Size = MAP_APPFONT ( 248 , 8 ) ; - Text [ en-US ] = "T~hen by" ; - }; -}; - -TabPage RID_SCPAGE_SORT_OPTIONS -{ - Hide = TRUE ; - SVLook = TRUE ; - HelpId = HID_SCPAGE_SORT_OPTIONS ; - Pos = MAP_APPFONT ( 0 , 0 ) ; - Size = MAP_APPFONT ( 260 , 185 ) ; - CheckBox BTN_CASESENSITIVE - { - HelpID = "toolkit:CheckBox:RID_SCPAGE_SORT_OPTIONS:BTN_CASESENSITIVE"; - Pos = MAP_APPFONT ( 12 , 6 ) ; - Size = MAP_APPFONT ( 242 , 10 ) ; - Text [ en-US ] = "Case ~sensitive" ; - TabStop = TRUE ; - }; - CheckBox BTN_LABEL - { - HelpID = "toolkit:CheckBox:RID_SCPAGE_SORT_OPTIONS:BTN_LABEL"; - Pos = MAP_APPFONT ( 12 , 20 ) ; - Size = MAP_APPFONT ( 242 , 10 ) ; - TabStop = TRUE ; - }; - String STR_COL_LABEL - { - Text [ en-US ] = "Range contains column la~bels" ; - }; - String STR_ROW_LABEL - { - Text [ en-US ] = "Range contains ~row labels" ; - }; - CheckBox BTN_FORMATS - { - HelpID = "toolkit:CheckBox:RID_SCPAGE_SORT_OPTIONS:BTN_FORMATS"; - Pos = MAP_APPFONT ( 12 , 34 ) ; - Size = MAP_APPFONT ( 242 , 10 ) ; - Text [ en-US ] = "Include ~formats" ; - TabStop = TRUE ; - }; - CheckBox BTN_NATURALSORT - { - HelpID = "toolkit:CheckBox:RID_SCPAGE_SORT_OPTIONS:BTN_NATURALSORT"; - Pos = MAP_APPFONT ( 12 , 48 ) ; - Size = MAP_APPFONT ( 242 , 10 ) ; - Text [ de ] = "Enable ~natural sort" ; - Text [ en-US ] = "Enable ~natural sort" ; - Text [ cs ] = "Aktivovat přirozené třídění" ; - Text [ sk ] = "Aktivovať prirodzené triedenie" ; - TabStop = TRUE ; - Text [ x-comment ] = " " ; - }; - CheckBox BTN_COPYRESULT - { - HelpID = "toolkit:CheckBox:RID_SCPAGE_SORT_OPTIONS:BTN_COPYRESULT"; - Pos = MAP_APPFONT ( 12 , 62 ) ; - Size = MAP_APPFONT ( 242 , 10 ) ; - Text [ en-US ] = "~Copy sort results to:" ; - TabStop = TRUE ; - }; - ListBox LB_OUTAREA - { - HelpID = "toolkit:ListBox:RID_SCPAGE_SORT_OPTIONS:LB_OUTAREA"; - Border = TRUE ; - Pos = MAP_APPFONT ( 20 , 73 ) ; - Size = MAP_APPFONT ( 93 , 90 ) ; - TabStop = TRUE ; - DropDown = TRUE ; - }; - Edit ED_OUTAREA - { - HelpID = "toolkit:Edit:RID_SCPAGE_SORT_OPTIONS:ED_OUTAREA"; - Disable = TRUE ; - Border = TRUE ; - Pos = MAP_APPFONT ( 119 , 73 ) ; - Size = MAP_APPFONT ( 132 , 12 ) ; - TabStop = TRUE ; - }; - CheckBox BTN_SORT_USER - { - HelpID = "toolkit:CheckBox:RID_SCPAGE_SORT_OPTIONS:BTN_SORT_USER"; - Pos = MAP_APPFONT ( 12 , 89 ) ; - Size = MAP_APPFONT ( 242 , 10 ) ; - Text [ en-US ] = "Custom sort ~order" ; - TabStop = TRUE ; - }; - ListBox LB_SORT_USER - { - HelpID = "toolkit:ListBox:RID_SCPAGE_SORT_OPTIONS:LB_SORT_USER"; - Disable = TRUE ; - Border = TRUE ; - Pos = MAP_APPFONT ( 20 , 100 ) ; - Size = MAP_APPFONT ( 231 , 90 ) ; - TabStop = TRUE ; - DropDown = TRUE ; - }; - FixedText FT_LANGUAGE - { - Pos = MAP_APPFONT ( 12 , 118 ) ; - Size = MAP_APPFONT ( 101 , 8 ) ; - Text [ en-US ] = "~Language"; - }; - ListBox LB_LANGUAGE - { - HelpID = "toolkit:ListBox:RID_SCPAGE_SORT_OPTIONS:LB_LANGUAGE"; - Border = TRUE ; - Pos = MAP_APPFONT ( 12 , 129 ) ; - Size = MAP_APPFONT ( 101 , 90 ) ; - TabStop = TRUE ; - DropDown = TRUE ; - Sort = TRUE ; - }; - FixedText FT_ALGORITHM - { - Pos = MAP_APPFONT ( 119 , 118 ) ; - Size = MAP_APPFONT ( 132 , 8 ) ; - Text [ en-US ] = "O~ptions"; - }; - ListBox LB_ALGORITHM - { - HelpID = "toolkit:ListBox:RID_SCPAGE_SORT_OPTIONS:LB_ALGORITHM"; - Border = TRUE ; - Pos = MAP_APPFONT ( 119 , 129 ) ; - Size = MAP_APPFONT ( 132 , 90 ) ; - TabStop = TRUE ; - DropDown = TRUE ; - }; - FixedLine FL_DIRECTION - { - Pos = MAP_APPFONT ( 6 , 147 ) ; - Size = MAP_APPFONT ( 248 , 8 ) ; - Text [ en-US ] = "Direction" ; - }; - RadioButton BTN_TOP_DOWN - { - HelpID = "toolkit:RadioButton:RID_SCPAGE_SORT_OPTIONS:BTN_TOP_DOWN"; - Pos = MAP_APPFONT ( 12 , 158 ) ; - Size = MAP_APPFONT ( 242 , 10 ) ; - Text [ en-US ] = "~Top to bottom (sort rows)" ; - TabStop = TRUE ; - }; - RadioButton BTN_LEFT_RIGHT - { - HelpID = "toolkit:RadioButton:RID_SCPAGE_SORT_OPTIONS:BTN_LEFT_RIGHT"; - Pos = MAP_APPFONT ( 12 , 172 ) ; - Size = MAP_APPFONT ( 242 , 10 ) ; - Text [ en-US ] = "L~eft to right (sort columns)" ; - TabStop = TRUE ; - }; -}; - -TabDialog RID_SCDLG_SORT -{ - OutputSize = TRUE ; - SVLook = TRUE ; - Size = MAP_APPFONT ( 220 , 175 ) ; - Text [ en-US ] = "Sort" ; - Moveable = TRUE ; - Closeable = FALSE ; - TabControl 1 - { - OutputSize = TRUE ; - Pos = MAP_APPFONT ( 0 , 0 ) ; - Size = MAP_APPFONT ( 210 , 170 ) ; - PageList = - { - PageItem - { - Identifier = TP_FIELDS ; - PageResID = TP_FIELDS ; - Text [ en-US ] = "Sort Criteria" ; - }; - PageItem - { - Identifier = TP_OPTIONS ; - PageResID = TP_OPTIONS ; - Text [ en-US ] = "Options" ; - }; - }; - }; - OKButton 1 - { - Pos = MAP_APPFONT ( 3 , 157 ) ; - Size = MAP_APPFONT ( 40 , 12 ) ; - TabStop = TRUE ; - }; - CancelButton 1 - { - Pos = MAP_APPFONT ( 49 , 157 ) ; - Size = MAP_APPFONT ( 40 , 12 ) ; - TabStop = TRUE ; - }; - PushButton 1 - { - Pos = MAP_APPFONT ( 137 , 157 ) ; - Size = MAP_APPFONT ( 40 , 12 ) ; - TabStop = TRUE ; - }; - HelpButton 1 - { - Pos = MAP_APPFONT ( 94 , 157 ) ; - Size = MAP_APPFONT ( 40 , 12 ) ; - TabStop = TRUE ; - }; -}; diff --git a/toolkit/workben/layout/sortdlg.xml b/toolkit/workben/layout/sortdlg.xml deleted file mode 100644 index ce45a60ff1ee..000000000000 --- a/toolkit/workben/layout/sortdlg.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/toolkit/workben/layout/splitter.xml b/toolkit/workben/layout/splitter.xml deleted file mode 100644 index 634ad829b001..000000000000 --- a/toolkit/workben/layout/splitter.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - diff --git a/toolkit/workben/layout/string-input.xml b/toolkit/workben/layout/string-input.xml deleted file mode 100644 index b1aed5197c17..000000000000 --- a/toolkit/workben/layout/string-input.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - diff --git a/toolkit/workben/layout/tab-dialog.xml b/toolkit/workben/layout/tab-dialog.xml deleted file mode 100644 index da75f03e9df5..000000000000 --- a/toolkit/workben/layout/tab-dialog.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/toolkit/workben/layout/tabcontrol.xml b/toolkit/workben/layout/tabcontrol.xml deleted file mode 100644 index 2986f1f9e0d9..000000000000 --- a/toolkit/workben/layout/tabcontrol.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/toolkit/workben/layout/table.xml b/toolkit/workben/layout/table.xml deleted file mode 100644 index 673bd85ddab3..000000000000 --- a/toolkit/workben/layout/table.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - -
-
diff --git a/toolkit/workben/layout/test.cxx b/toolkit/workben/layout/test.cxx deleted file mode 100644 index f90317a5ae37..000000000000 --- a/toolkit/workben/layout/test.cxx +++ /dev/null @@ -1,369 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include - -// This works and was used before for standalone test, not sure why -// we'd want it. -#define LAYOUT_WEAK 1 -#include "uno.hxx" - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#define SORT_DLG 1 /* requires sfx2, svx to be compiled */ -#if SORT_DLG -#include "scitems.hxx" -#include "uiitems.hxx" -#endif /* SORT_DLG */ - -#include "editor.hxx" - -#include "plugin.hxx" -#undef _LAYOUT_POST_HXX - -#include "recover.hxx" -#undef _LAYOUT_POST_HXX - -#if SORT_DLG -#include "sortdlg.hxx" -#undef _LAYOUT_POST_HXX -#endif /* SORT_DLG */ - -#include "wordcountdialog.hxx" -#undef _LAYOUT_POST_HXX - -#include "zoom.hxx" -#undef _LAYOUT_POST_HXX - -#include - -using namespace ::rtl; -using namespace ::cppu; -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; - -class LayoutTest : public Application -{ - Reference< XComponentContext > mxContext; - Reference< lang::XMultiServiceFactory > mxMSF; - OUString mInstallDir; - OUString mTestDialog; - bool mEditMode; - std::list< OUString > mFiles; - -public: - LayoutTest( char const* installDir ); - - void RunEditor(); - void RunFiles(); - void ExceptionalMain(); - void Init(); - void InitUCB(); - void LoadFile( OUString const &aName ); - void Main(); - void ParseCommandLine(); -}; - -static void usage() -{ - fprintf (stderr, "usage: test [--inst OOO_INSTALL_PREFIX] [DIALOG.XML]... | --test [DIALOG.XML]\n" ); - exit( 2 ); -} - -static uno::Reference< lang::XSingleServiceFactory > get_factory( char const *service ) -{ - uno::Reference< lang::XSingleServiceFactory > xFactory( - comphelper::createProcessComponent( - rtl::OUString::createFromAscii( service ) ), uno::UNO_QUERY ); - - if ( !xFactory.is() ) - fprintf( stderr, "error loading: %s\n", service ); - return xFactory; -} - -#define GET_FACTORY(x) get_factory( #x ) - -void LayoutTest::LoadFile( const OUString &aTestFile ) -{ - fprintf( stderr, "TEST: layout instance\n" ); - - uno::Reference< lang::XSingleServiceFactory > xFactory - = GET_FACTORY( com.sun.star.awt.Layout ); - if ( !xFactory.is() ) - { - fprintf( stderr, "Layout engine not installed\n" ); - throw uno::RuntimeException( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Layout engine not installed" ) ), - uno::Reference< uno::XInterface >() ); - } - fprintf( stderr, "TEST: initing root\n" ); - - uno::Sequence< uno::Any > aParams( 1 ); - aParams[0] <<= aTestFile; - - uno::Reference< awt::XLayoutRoot > xRoot ( - xFactory->createInstanceWithArguments( aParams ), - uno::UNO_QUERY ); - - fprintf( stderr, "TEST: file loaded\n" ); -} - -void LayoutTest::InitUCB() -{ - OUString aEmpty; - Sequence< Any > aArgs( 6 ); - aArgs[0] - <<= OUString(RTL_CONSTASCII_USTRINGPARAM( UCB_CONFIGURATION_KEY1_LOCAL )); - aArgs[1] - <<= OUString(RTL_CONSTASCII_USTRINGPARAM( UCB_CONFIGURATION_KEY2_OFFICE )); - aArgs[2] <<= OUString(RTL_CONSTASCII_USTRINGPARAM("PIPE")); - aArgs[3] <<= aEmpty; - aArgs[4] <<= OUString(RTL_CONSTASCII_USTRINGPARAM("PORTAL")); - aArgs[5] <<= aEmpty; - - if ( !::ucbhelper::ContentBroker::initialize( mxMSF, aArgs ) ) - { - fprintf( stderr, "Failed to init content broker\n" ); - fprintf( stderr, "arg[0]: %s\n", UCB_CONFIGURATION_KEY1_LOCAL ); - fprintf( stderr, "arg[1]: %s\n", UCB_CONFIGURATION_KEY2_OFFICE ); - } -} - -static void support_upstream_brand_prefix () -{ - if ( char const* inst = getenv( "OOO_INSTALL_PREFIX" ) ) - { - char const *brand_prefix = "/openoffice.org3"; - OUString brand_dir = OUString::createFromAscii( inst ) - + OUString::createFromAscii( brand_prefix ); - struct stat stat_info; - if ( !stat ( OUSTRING_CSTR( brand_dir ), &stat_info ) ) - { - OSL_TRACE( "Appending %s to OOO_INSTALL_PREFIX", brand_prefix ); - setenv( "OOO_INSTALL_PREFIX", OUSTRING_CSTR( brand_dir ), 1 ); - } - } -} - -void LayoutTest::Init() -{ - ParseCommandLine(); - setenv( "OOO_INSTALL_PREFIX", OUSTRING_CSTR( mInstallDir ), 0 ); - support_upstream_brand_prefix (); - OSL_TRACE( "OOO_INSTALL_PREFIX=%s", getenv( "OOO_INSTALL_PREFIX" ) ); - - mxContext = defaultBootstrap_InitialComponentContext(); - mxMSF = new UnoBootstrapLayout( Reference< lang::XMultiServiceFactory >( mxContext->getServiceManager(), UNO_QUERY ) ); - ::comphelper::setProcessServiceFactory( mxMSF ); - InitUCB(); -} - -void LayoutTest::ParseCommandLine() -{ - printf ("%s\n", __PRETTY_FUNCTION__); - for ( sal_uInt16 i = 0; i < GetCommandLineParamCount(); i++ ) - { - OUString aParam = OUString( GetCommandLineParam( i ) ); - if ( aParam.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-h" ) ) || aParam.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "--help" ) ) ) - usage(); - if ( aParam.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "--inst" ) ) ) - { - if ( i >= GetCommandLineParamCount() - 1) - usage(); - mInstallDir = GetCommandLineParam( ++i ); - setenv( "OOO_INSTALL_PREFIX", OUSTRING_CSTR( mInstallDir ), 1 ); - } - else if ( aParam.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "--test" ) ) ) - { - mTestDialog = OUString(RTL_CONSTASCII_USTRINGPARAM("zoom")); - if (i + 1 < GetCommandLineParamCount()) - mTestDialog = GetCommandLineParam( ++i ); - } - else if ( aParam.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "--editor" ) ) ) - mEditMode = true; - else - mFiles.push_back( aParam ); - } - - if ( mFiles.size() <= 0 ) - mFiles.push_back( OUString(RTL_CONSTASCII_USTRINGPARAM("layout.xml")) ); -} - -void LayoutTest::RunEditor() -{ - OUString aFile; - if ( !mFiles.empty() - && mFiles.front().compareToAscii( "layout.xml" ) != 0 ) - aFile = mFiles.front(); - Editor editor( mxMSF, aFile ); - editor.Show(); - editor.Execute(); -} - -short RunDialog( Dialog& dialog ) -{ - dialog.Show(); - short result = dialog.Execute(); - fprintf( stderr, "Done: dialog execute exited:%d\n", result); - return result; -} - -#undef Dialog -short RunDialog( ::Dialog& dialog ) -{ - dialog.Show(); - short result = dialog.Execute(); - fprintf( stderr, "Done: dialog execute exited:%d\n", result); - return result; -} - -#if SORT_DLG -static void LoadSC() -{ - get_factory( "com.sun.star.comp.sfx2.DocumentTemplates" ); - get_factory( "com.sun.star.comp.Calc.SpreadsheetDocument" ); - GET_FACTORY( com.sun.star.i18n.Transliteration.l10n ); -} -#endif /* SORT_DLG */ - -void TestDialog( OUString const& name ) -{ - if ( 0 ) - ; - else if ( name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "plugin" ) ) ) - { - PluginDialog plugin ( 0 ); - RunDialog( plugin ); - } - else if ( name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "query" ) ) ) - { - QueryBox query ( 0, "Do you want to do?", "do"); - RunDialog( query ); - } - else if ( name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "query-compat" ) ) ) - { - QueryBox query ( 0, - WinBits( WB_YES_NO | WB_DEF_YES ), -// WinBits( WB_ABORT_RETRY_IGNORE ), - OUString(RTL_CONSTASCII_USTRINGPARAM ("Do you want to do?"))); - RunDialog( query ); - } - else if ( name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "recover" ) ) ) - { - SvxRecoverDialog recover ( 0 ); - RunDialog( recover ); - } -#if SORT_DLG - else if ( name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "sort" ) ) ) - { - LoadSC(); - ScSortDlg sort (0, 0); - RunDialog( sort ); - } -#endif /* SORT_DLG */ - else if ( name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "wordcount" ) ) ) - { - SwWordCountDialog words ( 0 ); - RunDialog( words ); - } - else if ( name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "zoom" ) ) ) - { - SvxZoomDialog zoom( 0 ); - RunDialog( zoom ); - } -} - -void LayoutTest::RunFiles() -{ - fprintf( stderr, "TEST: loading files\n" ); - for ( std::list< OUString >::iterator i = mFiles.begin(); i != mFiles.end(); ++i ) - LoadFile( *i ); - fprintf( stderr, "TEST: executing\n" ); - Execute(); - fprintf( stderr, "TEST: done executing\n" ); -} - -void LayoutTest::ExceptionalMain() -{ - if ( mTestDialog.getLength() ) - TestDialog( mTestDialog ); - else if ( mEditMode ) - RunEditor(); - else - RunFiles(); -} - -void LayoutTest::Main() -{ - try - { - ExceptionalMain(); - } - catch (xml::sax::SAXException & rExc) - { - OString aStr( OUStringToOString( rExc.Message, - RTL_TEXTENCODING_ASCII_US ) ); - uno::Exception exc; - if (rExc.WrappedException >>= exc) - { - aStr += OString( " >>> " ); - aStr += OUStringToOString( exc.Message, RTL_TEXTENCODING_ASCII_US ); - } - fprintf (stderr, "Parsing error: '%s'\n", aStr.getStr()); - OSL_FAIL( aStr.getStr() ); - } - catch ( uno::Exception & rExc ) - { - OString aStr( OUStringToOString( rExc.Message, - RTL_TEXTENCODING_ASCII_US ) ); - fprintf (stderr, "UNO error: '%s'\n", aStr.getStr()); - OSL_FAIL( aStr.getStr() ); - } - - Reference< lang::XComponent > xComp( mxContext, UNO_QUERY ); - if ( xComp.is() ) - xComp->dispose(); -} - -LayoutTest::LayoutTest( char const* installDir ) - : mInstallDir( OUString::createFromAscii ( installDir ) ) -{ -} - -LayoutTest layout_test( "/usr/local/lib/ooo" ); - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/workben/layout/test.xml b/toolkit/workben/layout/test.xml deleted file mode 100644 index d0b4f9062912..000000000000 --- a/toolkit/workben/layout/test.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - diff --git a/toolkit/workben/layout/testrc.in b/toolkit/workben/layout/testrc.in deleted file mode 100644 index b6c232aae60f..000000000000 --- a/toolkit/workben/layout/testrc.in +++ /dev/null @@ -1,8 +0,0 @@ -OOO_INSTALL_PREFIX_URL=file://${OOO_INSTALL_PREFIX} -OOO_BASIS_BIN_URL=${OOO_INSTALL_PREFIX_URL}/program -OOO_URE_URL=${OOO_INSTALL_PREFIX_URL}/ure-link -# -BRAND_BASE_DIR=${OOO_INSTALL_PREFIX_URL} -# -UNO_TYPES=${OOO_URE_URL}/share/misc/types.rdb ${OOO_BASIS_BIN_URL}/offapi.rdb -UNO_SERVICES=${OOO_URE_URL}/share/misc/services.rdb ${OOO_BASIS_BIN_URL}/services.rdb diff --git a/toolkit/workben/layout/tpsort.cxx b/toolkit/workben/layout/tpsort.cxx deleted file mode 100644 index ff8526c890aa..000000000000 --- a/toolkit/workben/layout/tpsort.cxx +++ /dev/null @@ -1,1107 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#if !TEST_LAYOUT -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sc.hxx" -#endif /* !TEST_LAYOUT */ - -#undef SC_DLLIMPLEMENTATION - - - -#include -#include -#include -#include -#include -#include - -#include "scitems.hxx" -#include "uiitems.hxx" -#include "viewdata.hxx" -#include "document.hxx" -#include "global.hxx" -#include "dbcolect.hxx" -#include "userlist.hxx" -#include "rangeutl.hxx" -#include "scresid.hxx" -#include "sc.hrc" // -> Slot IDs -#include "globstr.hrc" - -#include "sortdlg.hxx" -#include "sortdlg.hrc" - -#define _TPSORT_CXX -#include "tpsort.hxx" -#undef _TPSORT_CXX - -using namespace com::sun::star; - -// STATIC DATA ----------------------------------------------------------- - -static USHORT pSortRanges[] = -{ - SID_SORT, - SID_SORT, - 0 -}; - -// ----------------------------------------------------------------------- - -/* - * Da sich Einstellungen auf der zweiten TabPage (Optionen) auf - * die erste TabPage auswirken, muss es die Moeglichkeit geben, - * dies der jeweils anderen Seite mitzuteilen. - * - * Im Moment wird dieses Problem ueber zwei Datenmember des TabDialoges - * geloest. Wird eine Seite Aktiviert/Deaktiviert, so gleicht sie diese - * Datenmember mit dem eigenen Zustand ab (->Activate()/Deactivate()). - * - * 31.01.95: - * Die Klasse SfxTabPage bietet mittlerweile ein Verfahren an: - * - * virtual BOOL HasExchangeSupport() const; -> return TRUE; - * virtual void ActivatePage(const SfxItemSet &); - * virtual int DeactivatePage(SfxItemSet * = 0); - * - * muss noch geaendert werden! - */ - -//======================================================================== -//======================================================================== -// Sortierkriterien-Tabpage: - -ScTabPageSortFields::ScTabPageSortFields( Window* pParent, - const SfxItemSet& rArgSet ) - - : SfxTabPage ( pParent, - ScResId( RID_SCPAGE_SORT_FIELDS ), - rArgSet ), - // - aFlSort1 ( this, ScResId( FL_SORT1 ) ), - aLbSort1 ( this, ScResId( LB_SORT1 ) ), - aBtnUp1 ( this, ScResId( BTN_UP1 ) ), - aBtnDown1 ( this, ScResId( BTN_DOWN1 ) ), - // - aFlSort2 ( this, ScResId( FL_SORT2 ) ), - aLbSort2 ( this, ScResId( LB_SORT2 ) ), - aBtnUp2 ( this, ScResId( BTN_UP2 ) ), - aBtnDown2 ( this, ScResId( BTN_DOWN2 ) ), - // - aFlSort3 ( this, ScResId( FL_SORT3 ) ), - aLbSort3 ( this, ScResId( LB_SORT3 ) ), - aBtnUp3 ( this, ScResId( BTN_UP3 ) ), - aBtnDown3 ( this, ScResId( BTN_DOWN3 ) ), - - aStrUndefined ( ScResId( SCSTR_UNDEFINED ) ), - aStrColumn ( ScResId( SCSTR_COLUMN ) ), - aStrRow ( ScResId( SCSTR_ROW ) ), - // -#if !TEST_LAYOUT - nWhichSort ( rArgSet.GetPool()->GetWhich( SID_SORT ) ), -#else /* TEST_LAYOUT */ - nWhichSort ( 0 ), -#endif /* TEST_LAYOUT */ - pDlg ( (ScSortDlg*)(GetParent()->GetParent()) ), - pViewData ( NULL ), -#if !TEST_LAYOUT - rSortData ( ((const ScSortItem&) - rArgSet.Get( nWhichSort )). - GetSortData() ), -#else /* TEST_LAYOUT */ - rSortData ( *new ScSortParam() ), -#endif /* TEST_LAYOUT */ - nFieldCount ( 0 ), - bHasHeader ( FALSE ), - bSortByRows ( FALSE ) -{ - Init(); - FreeResource(); - SetExchangeSupport(); -} - -// ----------------------------------------------------------------------- - -ScTabPageSortFields::~ScTabPageSortFields() -{ -} - -// ----------------------------------------------------------------------- - -void ScTabPageSortFields::Init() -{ -#if !TEST_LAYOUT - const ScSortItem& rSortItem = (const ScSortItem&) - GetItemSet().Get( nWhichSort ); - - pViewData = rSortItem.GetViewData(); - - DBG_ASSERT( pViewData, "ViewData not found!" ); -#endif /* !TEST_LAYOUT */ - - nFieldArr[0] = 0; - nFirstCol = 0; - nFirstRow = 0; - - aLbSort1.SetSelectHdl( LINK( this, ScTabPageSortFields, SelectHdl ) ); - aLbSort2.SetSelectHdl( LINK( this, ScTabPageSortFields, SelectHdl ) ); - aLbSort3.SetSelectHdl( LINK( this, ScTabPageSortFields, SelectHdl ) ); - aLbSort1.Clear(); - aLbSort2.Clear(); - aLbSort3.Clear(); - - aSortLbArr[0] = &aLbSort1; - aSortLbArr[1] = &aLbSort2; - aSortLbArr[2] = &aLbSort3; - aDirBtnArr[0][0] = &aBtnUp1; - aDirBtnArr[0][1] = &aBtnDown1; - aDirBtnArr[1][0] = &aBtnUp2; - aDirBtnArr[1][1] = &aBtnDown2; - aDirBtnArr[2][0] = &aBtnUp3; - aDirBtnArr[2][1] = &aBtnDown3; - aFlArr[0] = &aFlSort1; - aFlArr[1] = &aFlSort2; - aFlArr[2] = &aFlSort3; -} - -//------------------------------------------------------------------------ - -USHORT* ScTabPageSortFields::GetRanges() -{ - return pSortRanges; -} - -// ----------------------------------------------------------------------- - -SfxTabPage* ScTabPageSortFields::Create( Window* pParent, - const SfxItemSet& rArgSet ) -{ - return ( new ScTabPageSortFields( pParent, rArgSet ) ); -} - -// ----------------------------------------------------------------------- - -void ScTabPageSortFields::Reset( const SfxItemSet& /* rArgSet */ ) -{ - bSortByRows = rSortData.bByRow; - bHasHeader = rSortData.bHasHeader; - - if ( aLbSort1.GetEntryCount() == 0 ) - FillFieldLists(); - - // Selektieren der ListBoxen: - - if ( rSortData.bDoSort[0] ) - { - for ( USHORT i=0; i<3; i++ ) - { - if ( rSortData.bDoSort[i] ) - { - aSortLbArr[i]->SelectEntryPos( - GetFieldSelPos( rSortData.nField[i] ) ); - - (rSortData.bAscending[i]) - ? aDirBtnArr[i][0]->Check() // Up - : aDirBtnArr[i][1]->Check(); // Down - } - else - { - aSortLbArr[i]->SelectEntryPos( 0 ); // "keiner" selektieren - aDirBtnArr[i][0]->Check(); // Up - } - } - - EnableField( 1 ); - EnableField( 2 ); - EnableField( 3 ); - if ( aLbSort1.GetSelectEntryPos() == 0 ) - DisableField( 2 ); - if ( aLbSort2.GetSelectEntryPos() == 0 ) - DisableField( 3 ); - } - else - { - aLbSort1.SelectEntryPos( 1 ); - aLbSort2.SelectEntryPos( 0 ); - aLbSort3.SelectEntryPos( 0 ); - aBtnUp1.Check(); - aBtnUp2.Check(); - aBtnUp3.Check(); - EnableField ( 1 ); - EnableField ( 2 ); - DisableField( 3 ); - } - - if ( pDlg ) - { - pDlg->SetByRows ( bSortByRows ); - pDlg->SetHeaders( bHasHeader ); - } -} - -// ----------------------------------------------------------------------- - -BOOL ScTabPageSortFields::FillItemSet( SfxItemSet& rArgSet ) -{ - ScSortParam theSortData = rSortData; - if (pDlg) - { - const SfxItemSet* pExample = pDlg->GetExampleSet(); - const SfxPoolItem* pItem; - if ( pExample && pExample->GetItemState( nWhichSort, TRUE, &pItem ) == SFX_ITEM_SET ) - theSortData = ((const ScSortItem*)pItem)->GetSortData(); - } - - USHORT nSort1Pos = aLbSort1.GetSelectEntryPos(); - USHORT nSort2Pos = aLbSort2.GetSelectEntryPos(); - USHORT nSort3Pos = aLbSort3.GetSelectEntryPos(); - - DBG_ASSERT( (nSort1Pos <= SC_MAXFIELDS) - && (nSort2Pos <= SC_MAXFIELDS) - && (nSort3Pos <= SC_MAXFIELDS), - "Array-Range Fehler!" ); - - if ( nSort1Pos == LISTBOX_ENTRY_NOTFOUND ) nSort1Pos = 0; - if ( nSort2Pos == LISTBOX_ENTRY_NOTFOUND ) nSort2Pos = 0; - if ( nSort3Pos == LISTBOX_ENTRY_NOTFOUND ) nSort3Pos = 0; - - if ( nSort1Pos > 0 ) - { - theSortData.bDoSort[0] = (nSort1Pos > 0); - theSortData.bDoSort[1] = (nSort2Pos > 0); - theSortData.bDoSort[2] = (nSort3Pos > 0); - - // wenn auf Optionen-Seite "OK" gewaehlt wurde und - // dabei die Sortierrichtung umgestellt wurde, so - // wird das erste Feld der jeweiligen Richtung als - // Sortierkriterium gewaehlt (steht in nFieldArr[0]): - if ( bSortByRows != pDlg->GetByRows() ) - { - theSortData.nField[0] = - theSortData.nField[1] = - theSortData.nField[2] = ( bSortByRows ? - static_cast(nFirstRow) : - static_cast(nFirstCol) ); - } - else - { - theSortData.nField[0] = nFieldArr[nSort1Pos]; - theSortData.nField[1] = nFieldArr[nSort2Pos]; - theSortData.nField[2] = nFieldArr[nSort3Pos]; - } - - theSortData.bAscending[0] = aBtnUp1.IsChecked(); - theSortData.bAscending[1] = aBtnUp2.IsChecked(); - theSortData.bAscending[2] = aBtnUp3.IsChecked(); - // bHasHeader ist in ScTabPageSortOptions::FillItemSet, wo es hingehoert - } - else - { - theSortData.bDoSort[0] = - theSortData.bDoSort[1] = - theSortData.bDoSort[2] = FALSE; - } - - rArgSet.Put( ScSortItem( SCITEM_SORTDATA, NULL, &theSortData ) ); - - return TRUE; -} - -// ----------------------------------------------------------------------- - -// fuer Datenaustausch ohne Dialog-Umweg: (! noch zu tun !) -// void ScTabPageSortFields::ActivatePage( const SfxItemSet& rSet ) - -void ScTabPageSortFields::ActivatePage() -{ - if ( pDlg ) - { - if ( bHasHeader != pDlg->GetHeaders() - || bSortByRows != pDlg->GetByRows() ) - { - USHORT nCurSel1 = aLbSort1.GetSelectEntryPos(); - USHORT nCurSel2 = aLbSort2.GetSelectEntryPos(); - USHORT nCurSel3 = aLbSort3.GetSelectEntryPos(); - - bHasHeader = pDlg->GetHeaders(); - bSortByRows = pDlg->GetByRows(); - FillFieldLists(); - aLbSort1.SelectEntryPos( nCurSel1 ); - aLbSort2.SelectEntryPos( nCurSel2 ); - aLbSort3.SelectEntryPos( nCurSel3 ); - } - } -} - -// ----------------------------------------------------------------------- - -int ScTabPageSortFields::DeactivatePage( SfxItemSet* pSetP ) -{ - if ( pDlg ) - { - if ( bHasHeader != pDlg->GetHeaders() ) - pDlg->SetHeaders( bHasHeader ); - - if ( bSortByRows != pDlg->GetByRows() ) - pDlg->SetByRows( bSortByRows ); - } - - if ( pSetP ) - FillItemSet( *pSetP ); - - return SfxTabPage::LEAVE_PAGE; -} - -// ----------------------------------------------------------------------- - -void ScTabPageSortFields::DisableField( USHORT nField ) -{ - nField--; - - if ( nField<=2 ) - { - aSortLbArr[nField] ->Disable(); - aDirBtnArr[nField][0]->Disable(); - aDirBtnArr[nField][1]->Disable(); - aFlArr[nField] ->Disable(); - } -} - -// ----------------------------------------------------------------------- - -void ScTabPageSortFields::EnableField( USHORT nField ) -{ - nField--; - - if ( nField<=2 ) - { - aSortLbArr[nField] ->Enable(); - aDirBtnArr[nField][0]->Enable(); - aDirBtnArr[nField][1]->Enable(); - aFlArr[nField] ->Enable(); - } -} - -// ----------------------------------------------------------------------- - -void ScTabPageSortFields::FillFieldLists() -{ - if ( pViewData ) - { - ScDocument* pDoc = pViewData->GetDocument(); - - if ( pDoc ) - { - aLbSort1.Clear(); - aLbSort2.Clear(); - aLbSort3.Clear(); - aLbSort1.InsertEntry( aStrUndefined, 0 ); - aLbSort2.InsertEntry( aStrUndefined, 0 ); - aLbSort3.InsertEntry( aStrUndefined, 0 ); - - SCCOL nFirstSortCol = rSortData.nCol1; - SCROW nFirstSortRow = rSortData.nRow1; - SCTAB nTab = pViewData->GetTabNo(); - USHORT i = 1; - - if ( bSortByRows ) - { - String aFieldName; - SCCOL nMaxCol = rSortData.nCol2; - SCCOL col; - - for ( col=nFirstSortCol; col<=nMaxCol && iGetString( col, nFirstSortRow, nTab, aFieldName ); - if ( !bHasHeader || (aFieldName.Len() == 0) ) - { - aFieldName = aStrColumn; - aFieldName += ' '; - aFieldName += ColToAlpha( col ); - } - nFieldArr[i] = col; - aLbSort1.InsertEntry( aFieldName, i ); - aLbSort2.InsertEntry( aFieldName, i ); - aLbSort3.InsertEntry( aFieldName, i ); - i++; - } - } - else - { - String aFieldName; - SCROW nMaxRow = rSortData.nRow2; - SCROW row; - - for ( row=nFirstSortRow; row<=nMaxRow && iGetString( nFirstSortCol, row, nTab, aFieldName ); - if ( !bHasHeader || (aFieldName.Len() == 0) ) - { - aFieldName = aStrRow; - aFieldName += ' '; - aFieldName += String::CreateFromInt32( row+1 ); - } - nFieldArr[i] = row; - aLbSort1.InsertEntry( aFieldName, i ); - aLbSort2.InsertEntry( aFieldName, i ); - aLbSort3.InsertEntry( aFieldName, i ); - i++; - } - } - nFieldCount = i; - } - } -} - -//------------------------------------------------------------------------ - -USHORT ScTabPageSortFields::GetFieldSelPos( SCCOLROW nField ) -{ - USHORT nFieldPos = 0; - BOOL bFound = FALSE; - - for ( USHORT n=1; nGetSelectEntry(); - - if ( pLb == &aLbSort1 ) - { - if ( aSelEntry == aStrUndefined ) - { - aLbSort2.SelectEntryPos( 0 ); - aLbSort3.SelectEntryPos( 0 ); - - if ( aFlSort2.IsEnabled() ) - DisableField( 2 ); - - if ( aFlSort3.IsEnabled() ) - DisableField( 3 ); - } - else - { - if ( !aFlSort2.IsEnabled() ) - EnableField( 2 ); - } - } - else if ( pLb == &aLbSort2 ) - { - if ( aSelEntry == aStrUndefined ) - { - aLbSort3.SelectEntryPos( 0 ); - if ( aFlSort3.IsEnabled() ) - DisableField( 3 ); - } - else - { - if ( !aFlSort3.IsEnabled() ) - EnableField( 3 ); - } - } - return 0; -} - -//======================================================================== -// Sortieroptionen-Tabpage: -//======================================================================== - -#include - -#if ENABLE_LAYOUT -#undef ScResId -#define ScResId(x) #x -#undef SfxTabPage -#define SfxTabPage( parent, id, args ) SfxTabPage( parent, "sort-options.xml", id, &args ) -#endif /* ENABLE_LAYOUT */ - -ScTabPageSortOptions::ScTabPageSortOptions( Window* pParent, - const SfxItemSet& rArgSet ) - - : SfxTabPage ( pParent, - ScResId( RID_SCPAGE_SORT_OPTIONS ), - rArgSet ), - // - aBtnCase ( this, ScResId( BTN_CASESENSITIVE ) ), - aBtnHeader ( this, ScResId( BTN_LABEL ) ), - aBtnFormats ( this, ScResId( BTN_FORMATS ) ), - aBtnCopyResult ( this, ScResId( BTN_COPYRESULT ) ), - aBtnNaturalSort ( this, ScResId( BTN_NATURALSORT ) ), - aLbOutPos ( this, ScResId( LB_OUTAREA ) ), - aEdOutPos ( this, ScResId( ED_OUTAREA ) ), - aBtnSortUser ( this, ScResId( BTN_SORT_USER ) ), - aLbSortUser ( this, ScResId( LB_SORT_USER ) ), - aFtLanguage ( this, ScResId( FT_LANGUAGE ) ), - aLbLanguage ( this, ScResId( LB_LANGUAGE ) ), - aFtAlgorithm ( this, ScResId( FT_ALGORITHM ) ), - aLbAlgorithm ( this, ScResId( LB_ALGORITHM ) ), - aLineDirection ( this, ScResId( FL_DIRECTION ) ), - aBtnTopDown ( this, ScResId( BTN_TOP_DOWN ) ), - aBtnLeftRight ( this, ScResId( BTN_LEFT_RIGHT ) ), -// aFtAreaLabel ( this, ScResId( FT_AREA_LABEL ) ), -// aFtArea ( this, ScResId( FT_AREA ) ), - // -#if ENABLE_LAYOUT -#undef this -#undef ScResId -#define ScResId(x) this, #x -#endif /* ENABLE_LAYOUT */ - aStrRowLabel ( ScResId( STR_ROW_LABEL ) ), - aStrColLabel ( ScResId( STR_COL_LABEL ) ), - aStrUndefined ( ScResId( SCSTR_UNDEFINED ) ), - aStrNoName ( ScGlobal::GetRscString(STR_DB_NONAME) ), - // -#if !TEST_LAYOUT - nWhichSort ( rArgSet.GetPool()->GetWhich( SID_SORT ) ), - rSortData ( ((const ScSortItem&) - rArgSet.Get( nWhichSort )).GetSortData() ), -#else /* TEST_LAYOUT */ - nWhichSort ( 0 ), - rSortData ( *new ScSortParam() ), -#endif /* TEST_LAYOUT */ - pViewData ( NULL ), - pDoc ( NULL ), - pDlg ( (ScSortDlg*)(GetParent() ? GetParent()->GetParent() : 0 ) ), - pColRes ( NULL ), - pColWrap ( NULL ) -{ -#if TEST_LAYOUT - (void) rArgSet; -#endif /* TEST_LAYOUT */ - Init(); - FreeResource(); - SetExchangeSupport(); -} - -// ----------------------------------------------------------------------- - -ScTabPageSortOptions::~ScTabPageSortOptions() -{ -#if !TEST_LAYOUT - USHORT nEntries = aLbOutPos.GetEntryCount(); - - for ( USHORT i=1; iGetDocument() : NULL; - - DBG_ASSERT( pViewData, "ViewData not found! :-/" ); - -#if !TEST_LAYOUT - if ( pViewData && pDoc ) - { - String theArea; - ScDBCollection* pDBColl = pDoc->GetDBCollection(); - String theDbArea; - String theDbName = aStrNoName; - const SCTAB nCurTab = pViewData->GetTabNo(); - const ScAddress::Convention eConv = pDoc->GetAddressConvention(); -#endif /* !TEST_LAYOUT */ - - aLbOutPos.Clear(); - aLbOutPos.InsertEntry( aStrUndefined, 0 ); - aLbOutPos.Disable(); - -#if !TEST_LAYOUT - ScAreaNameIterator aIter( pDoc ); - String aName; - ScRange aRange; - String aRefStr; - while ( aIter.Next( aName, aRange ) ) - { - USHORT nInsert = aLbOutPos.InsertEntry( aName ); - - aRange.aStart.Format( aRefStr, SCA_ABS_3D, pDoc, eConv ); - aLbOutPos.SetEntryData( nInsert, new String( aRefStr ) ); - } -#endif /* !TEST_LAYOUT */ - - aLbOutPos.SelectEntryPos( 0 ); - aEdOutPos.SetText( EMPTY_STRING ); - -#if !TEST_LAYOUT - /* - * Ueberpruefen, ob es sich bei dem uebergebenen - * Bereich um einen Datenbankbereich handelt: - */ - - ScAddress aScAddress( rSortData.nCol1, rSortData.nRow1, nCurTab ); - ScRange( aScAddress, - ScAddress( rSortData.nCol2, rSortData.nRow2, nCurTab ) - ).Format( theArea, SCR_ABS, pDoc, eConv ); - - if ( pDBColl ) - { - ScDBData* pDBData - = pDBColl->GetDBAtArea( nCurTab, - rSortData.nCol1, rSortData.nRow1, - rSortData.nCol2, rSortData.nRow2 ); - if ( pDBData ) - { - pDBData->GetName( theDbName ); - aBtnHeader.Check( pDBData->HasHeader() ); - } - } - - theArea.AppendAscii(RTL_CONSTASCII_STRINGPARAM(" (")); - theArea += theDbName; - theArea += ')'; - - //aFtArea.SetText( theArea ); - //theArea.Insert( aStrAreaLabel, 0 ); - //aFtAreaLabel.SetText( theArea ); - - aBtnHeader.SetText( aStrColLabel ); - } -#endif /* TEST_LAYOUT */ - - FillUserSortListBox(); - - // get available languages - - aLbLanguage.SetLanguageList( LANG_LIST_ALL | LANG_LIST_ONLY_KNOWN, FALSE ); - aLbLanguage.InsertLanguage( LANGUAGE_SYSTEM ); -} - -//------------------------------------------------------------------------ - -USHORT* ScTabPageSortOptions::GetRanges() -{ - return pSortRanges; -} - -// ----------------------------------------------------------------------- - -#if ENABLE_LAYOUT -#undef SfxTabPage -#endif /* ENABLE_LAYOUT */ -SfxTabPage* ScTabPageSortOptions::Create( - Window* pParent, - const SfxItemSet& rArgSet ) -{ - return ( new ScTabPageSortOptions( pParent, rArgSet ) ); -} - -// ----------------------------------------------------------------------- - -void ScTabPageSortOptions::Reset( const SfxItemSet& /* rArgSet */ ) -{ - if ( rSortData.bUserDef ) - { - aBtnSortUser.Check( TRUE ); - aLbSortUser.Enable(); - aLbSortUser.SelectEntryPos( rSortData.nUserIndex ); - } - else - { - aBtnSortUser.Check( FALSE ); - aLbSortUser.Disable(); - aLbSortUser.SelectEntryPos( 0 ); - } - - aBtnCase.Check ( rSortData.bCaseSens ); - aBtnFormats.Check ( rSortData.bIncludePattern ); - aBtnHeader.Check ( rSortData.bHasHeader ); - aBtnNaturalSort.Check ( rSortData.bNaturalSort ); - - if ( rSortData.bByRow ) - { - aBtnTopDown.Check(); - aBtnHeader.SetText( aStrColLabel ); - } - else - { - aBtnLeftRight.Check(); - aBtnHeader.SetText( aStrRowLabel ); - } - - LanguageType eLang = MsLangId::convertLocaleToLanguage( rSortData.aCollatorLocale ); - if ( eLang == LANGUAGE_DONTKNOW ) - eLang = LANGUAGE_SYSTEM; - aLbLanguage.SelectLanguage( eLang ); - FillAlgorHdl( &aLbLanguage ); // get algorithms, select default - if ( rSortData.aCollatorAlgorithm.Len() ) - aLbAlgorithm.SelectEntry( pColRes->GetTranslation( rSortData.aCollatorAlgorithm ) ); - - if ( pDoc && !rSortData.bInplace ) - { - String aStr; - USHORT nFormat = (rSortData.nDestTab != pViewData->GetTabNo()) - ? SCR_ABS_3D - : SCR_ABS; - - theOutPos.Set( rSortData.nDestCol, - rSortData.nDestRow, - rSortData.nDestTab ); - - theOutPos.Format( aStr, nFormat, pDoc, pDoc->GetAddressConvention() ); - aBtnCopyResult.Check(); - aLbOutPos.Enable(); - aEdOutPos.Enable(); - aEdOutPos.SetText( aStr ); - EdOutPosModHdl( &aEdOutPos ); - aEdOutPos.GrabFocus(); - aEdOutPos.SetSelection( Selection( 0, SELECTION_MAX ) ); - } - else - { - aBtnCopyResult.Check( FALSE ); - aLbOutPos.Disable(); - aEdOutPos.Disable(); - aEdOutPos.SetText( EMPTY_STRING ); - } -} - -// ----------------------------------------------------------------------- - -BOOL ScTabPageSortOptions::FillItemSet( SfxItemSet& rArgSet ) -{ - ScSortParam theSortData = rSortData; - if (pDlg) - { - const SfxItemSet* pExample = pDlg->GetExampleSet(); - const SfxPoolItem* pItem; - if ( pExample && pExample->GetItemState( nWhichSort, TRUE, &pItem ) == SFX_ITEM_SET ) - theSortData = ((const ScSortItem*)pItem)->GetSortData(); - } - - theSortData.bByRow = aBtnTopDown.IsChecked(); - theSortData.bHasHeader = aBtnHeader.IsChecked(); - theSortData.bCaseSens = aBtnCase.IsChecked(); - theSortData.bNaturalSort = aBtnNaturalSort.IsChecked(); - theSortData.bIncludePattern = aBtnFormats.IsChecked(); - theSortData.bInplace = !aBtnCopyResult.IsChecked(); - theSortData.nDestCol = theOutPos.Col(); - theSortData.nDestRow = theOutPos.Row(); - theSortData.nDestTab = theOutPos.Tab(); - theSortData.bUserDef = aBtnSortUser.IsChecked(); - theSortData.nUserIndex = (aBtnSortUser.IsChecked()) - ? aLbSortUser.GetSelectEntryPos() - : 0; - - // get locale - LanguageType eLang = aLbLanguage.GetSelectLanguage(); - theSortData.aCollatorLocale = MsLangId::convertLanguageToLocale( eLang, false ); - - // get algorithm - String sAlg; - if ( eLang != LANGUAGE_SYSTEM ) - { - uno::Sequence aAlgos = pColWrap->listCollatorAlgorithms( - theSortData.aCollatorLocale ); - USHORT nSel = aLbAlgorithm.GetSelectEntryPos(); - if ( nSel < aAlgos.getLength() ) - sAlg = aAlgos[nSel]; - } - theSortData.aCollatorAlgorithm = sAlg; - -#if !TEST_LAYOUT - rArgSet.Put( ScSortItem( SCITEM_SORTDATA, &theSortData ) ); -#endif /* TEST_LAYOUT */ - return TRUE; -} - -// ----------------------------------------------------------------------- - -// fuer Datenaustausch ohne Dialog-Umweg: (! noch zu tun !) -// void ScTabPageSortOptions::ActivatePage( const SfxItemSet& rSet ) -void ScTabPageSortOptions::ActivatePage() -{ - if ( pDlg ) - { - if ( aBtnHeader.IsChecked() != pDlg->GetHeaders() ) - { - aBtnHeader.Check( pDlg->GetHeaders() ); - } - - if ( aBtnTopDown.IsChecked() != pDlg->GetByRows() ) - { - aBtnTopDown.Check( pDlg->GetByRows() ); - aBtnLeftRight.Check( !pDlg->GetByRows() ); - } - - aBtnHeader.SetText( (pDlg->GetByRows()) - ? aStrColLabel - : aStrRowLabel ); - } -} - -// ----------------------------------------------------------------------- - -int ScTabPageSortOptions::DeactivatePage( SfxItemSet* pSetP ) -{ - BOOL bPosInputOk = TRUE; - - if ( aBtnCopyResult.IsChecked() ) - { - String thePosStr = aEdOutPos.GetText(); - ScAddress thePos; - xub_StrLen nColonPos = thePosStr.Search( ':' ); - - if ( STRING_NOTFOUND != nColonPos ) - thePosStr.Erase( nColonPos ); - - if ( pViewData ) - { - // visible table is default for input without table - // must be changed to GetRefTabNo when sorting has RefInput! - thePos.SetTab( pViewData->GetTabNo() ); - } - - USHORT nResult = thePos.Parse( thePosStr, pDoc, pDoc->GetAddressConvention() ); - - bPosInputOk = ( SCA_VALID == (nResult & SCA_VALID) ); - - if ( !bPosInputOk ) - { -#if !ENABLE_LAYOUT - ErrorBox( this, WinBits( WB_OK | WB_DEF_OK ), - ScGlobal::GetRscString( STR_INVALID_TABREF ) - ).Execute(); -#endif /* ENABLE_LAYOUT */ - aEdOutPos.GrabFocus(); - aEdOutPos.SetSelection( Selection( 0, SELECTION_MAX ) ); - theOutPos.Set(0,0,0); - } - else - { - aEdOutPos.SetText( thePosStr ); - theOutPos = thePos; - } - } - - if ( pDlg && bPosInputOk ) - { - pDlg->SetHeaders( aBtnHeader.IsChecked() ); - pDlg->SetByRows ( aBtnTopDown.IsChecked() ); - } - - if ( pSetP && bPosInputOk ) - FillItemSet( *pSetP ); - - return bPosInputOk ? SfxTabPage::LEAVE_PAGE : SfxTabPage::KEEP_PAGE; -} - -// ----------------------------------------------------------------------- - -void ScTabPageSortOptions::FillUserSortListBox() -{ - ScUserList* pUserLists = ScGlobal::GetUserList(); - - aLbSortUser.Clear(); - if ( pUserLists ) - { - USHORT nCount = pUserLists->GetCount(); - if ( nCount > 0 ) - for ( USHORT i=0; iGetString() ); - } -} - -// ----------------------------------------------------------------------- -// Handler: - -IMPL_LINK( ScTabPageSortOptions, EnableHdl, CheckBox *, pBox ) -{ - if ( pBox == &aBtnCopyResult ) - { - if ( pBox->IsChecked() ) - { - aLbOutPos.Enable(); - aEdOutPos.Enable(); - aEdOutPos.GrabFocus(); - } - else - { - aLbOutPos.Disable(); - aEdOutPos.Disable(); - } - } - else if ( pBox == &aBtnSortUser ) - { - if ( pBox->IsChecked() ) - { - aLbSortUser.Enable(); - aLbSortUser.GrabFocus(); - } - else - aLbSortUser.Disable(); - } - return 0; -} - -// ----------------------------------------------------------------------- - -IMPL_LINK( ScTabPageSortOptions, SelOutPosHdl, ListBox *, pLb ) -{ - if ( pLb == &aLbOutPos ) - { - String aString; - USHORT nSelPos = aLbOutPos.GetSelectEntryPos(); - - if ( nSelPos > 0 ) - aString = *(String*)aLbOutPos.GetEntryData( nSelPos ); - - aEdOutPos.SetText( aString ); - } - return 0; -} - -// ----------------------------------------------------------------------- - -IMPL_LINK( ScTabPageSortOptions, SortDirHdl, RadioButton *, pBtn ) -{ - if ( pBtn == &aBtnTopDown ) - { - aBtnHeader.SetText( aStrColLabel ); - } - else if ( pBtn == &aBtnLeftRight ) - { - aBtnHeader.SetText( aStrRowLabel ); - } - return 0; -} - -// ----------------------------------------------------------------------- - -void ScTabPageSortOptions::EdOutPosModHdl( Edit* pEd ) -{ - if ( pEd == &aEdOutPos ) - { - String theCurPosStr = aEdOutPos.GetText(); - USHORT nResult = ScAddress().Parse( theCurPosStr, pDoc, pDoc->GetAddressConvention() ); - - if ( SCA_VALID == (nResult & SCA_VALID) ) - { - String* pStr = NULL; - BOOL bFound = FALSE; - USHORT i = 0; - USHORT nCount = aLbOutPos.GetEntryCount(); - - for ( i=2; i leave list box empty if LANGUAGE_SYSTEM is selected - aFtAlgorithm.Enable( FALSE ); // nothing to select - aLbAlgorithm.Enable( FALSE ); // nothing to select - } - else - { - lang::Locale aLocale( MsLangId::convertLanguageToLocale( eLang )); - uno::Sequence aAlgos = pColWrap->listCollatorAlgorithms( aLocale ); - - long nCount = aAlgos.getLength(); - const rtl::OUString* pArray = aAlgos.getConstArray(); - for (long i=0; iGetTranslation( sAlg ); - aLbAlgorithm.InsertEntry( sUser, LISTBOX_APPEND ); - } - aLbAlgorithm.SelectEntryPos( 0 ); // first entry is default - aFtAlgorithm.Enable( nCount > 1 ); // enable only if there is a choice - aLbAlgorithm.Enable( nCount > 1 ); // enable only if there is a choice - } - - aLbAlgorithm.SetUpdateMode( TRUE ); - return 0; -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/workben/layout/tpsort.hxx b/toolkit/workben/layout/tpsort.hxx deleted file mode 100644 index 64e4f4b6de42..000000000000 --- a/toolkit/workben/layout/tpsort.hxx +++ /dev/null @@ -1,219 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef SC_TPSORT_HXX -#define SC_TPSORT_HXX - - -#include -#include -#include -#include -#include -#include - - -#include "global.hxx" -#include "address.hxx" - -//------------------------------------------------------------------------ - -// +1 because one field is reserved for the "- undefined -" entry -#define SC_MAXFIELDS MAXCOLCOUNT+1 - -class ScViewData; -class ScSortDlg; -struct ScSortParam; - -//======================================================================== -// Kriterien (Sort Criteria) - -class ScTabPageSortFields : public SfxTabPage -{ -public: - ScTabPageSortFields( Window* pParent, - const SfxItemSet& rArgSet ); - ~ScTabPageSortFields(); - - static SfxTabPage* Create ( Window* pParent, - const SfxItemSet& rArgSet ); - static USHORT* GetRanges (); - virtual BOOL FillItemSet ( SfxItemSet& rArgSet ); - virtual void Reset ( const SfxItemSet& rArgSet ); - -protected: -// fuer Datenaustausch (sollte noch umgestellt werden!) -// virtual void ActivatePage ( const SfxItemSet& rSet ); - using SfxTabPage::ActivatePage; - using SfxTabPage::DeactivatePage; - virtual void ActivatePage (); - virtual int DeactivatePage ( SfxItemSet* pSet = 0); - -private: - FixedLine aFlSort1; - ListBox aLbSort1; - RadioButton aBtnUp1; - RadioButton aBtnDown1; - - FixedLine aFlSort2; - ListBox aLbSort2; - RadioButton aBtnUp2; - RadioButton aBtnDown2; - - FixedLine aFlSort3; - ListBox aLbSort3; - RadioButton aBtnUp3; - RadioButton aBtnDown3; - - String aStrUndefined; - String aStrColumn; - String aStrRow; - - const USHORT nWhichSort; - ScSortDlg* pDlg; - ScViewData* pViewData; - const ScSortParam& rSortData; - SCCOLROW nFieldArr[SC_MAXFIELDS]; - USHORT nFieldCount; - SCCOL nFirstCol; - SCROW nFirstRow; - BOOL bHasHeader; - BOOL bSortByRows; - - ListBox* aSortLbArr[3]; - RadioButton* aDirBtnArr[3][2]; - FixedLine* aFlArr[3]; - -#ifdef _TPSORT_CXX -private: - void Init (); - void DisableField ( USHORT nField ); - void EnableField ( USHORT nField ); - void FillFieldLists (); - USHORT GetFieldSelPos ( SCCOLROW nField ); - - // Handler ------------------------ - DECL_LINK( SelectHdl, ListBox * ); -#endif -}; - -//======================================================================== -// Sortieroptionen (Sort Options) - -class ScDocument; -class ScRangeData; -class CollatorRessource; -class CollatorWrapper; - -#include -#include - -class ScTabPageSortOptions : public SfxTabPage -{ -public: - ScTabPageSortOptions( Window* pParent, - const SfxItemSet& rArgSet ); - ~ScTabPageSortOptions(); - -#undef SfxTabPage -#define SfxTabPage ::SfxTabPage - static SfxTabPage* Create ( Window* pParent, - const SfxItemSet& rArgSet ); - static USHORT* GetRanges (); - virtual BOOL FillItemSet ( SfxItemSet& rArgSet ); - virtual void Reset ( const SfxItemSet& rArgSet ); - -protected: -// fuer Datenaustausch (sollte noch umgestellt werden!) -// virtual void ActivatePage ( const SfxItemSet& rSet ); - using SfxTabPage::ActivatePage; - using SfxTabPage::DeactivatePage; - virtual void ActivatePage (); - virtual int DeactivatePage ( SfxItemSet* pSet = 0); - -private: - - CheckBox aBtnCase; - CheckBox aBtnHeader; - CheckBox aBtnFormats; - CheckBox aBtnCopyResult; - - CheckBox aBtnNaturalSort; - ListBox aLbOutPos; - Edit aEdOutPos; - - CheckBox aBtnSortUser; - ListBox aLbSortUser; - - FixedText aFtLanguage; - SvxLanguageBox aLbLanguage; - FixedText aFtAlgorithm; - ListBox aLbAlgorithm; - - FixedLine aLineDirection; - RadioButton aBtnTopDown; - RadioButton aBtnLeftRight; - -// FixedText aFtAreaLabel; -// FixedInfo aFtArea; - LocalizedString aStrRowLabel; - LocalizedString aStrColLabel; - LocalizedString aStrUndefined; - String aStrNoName; - String aStrAreaLabel; - - const USHORT nWhichSort; - const ScSortParam& rSortData; - ScViewData* pViewData; - ScDocument* pDoc; - ScSortDlg* pDlg; - ScAddress theOutPos; - - CollatorRessource* pColRes; - CollatorWrapper* pColWrap; - -#ifdef _TPSORT_CXX -private: - void Init (); - void FillUserSortListBox (); - void FillOutPosList (); - - // Handler ------------------------ - DECL_LINK( EnableHdl, CheckBox * ); - DECL_LINK( SelOutPosHdl, ListBox * ); - void EdOutPosModHdl ( Edit* pEd ); - DECL_LINK( SortDirHdl, RadioButton * ); - DECL_LINK( FillAlgorHdl, void * ); -#endif -}; - -#include - -#endif // SC_TPSORT_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/workben/layout/un-test.sh b/toolkit/workben/layout/un-test.sh deleted file mode 100644 index ef2518ffa1b8..000000000000 --- a/toolkit/workben/layout/un-test.sh +++ /dev/null @@ -1,14 +0,0 @@ -#! /bin/sh - -# un-test.sh: remove TEST_LAYOUT code from OO.o implementation - -sed -e 's!^#!@!' < $1\ - -e 's!$! /*$*/!' \ - -e 's!^@\(.*TEST_LAYOUT\)!#\1!'\ - | tee i \ - | cpp -traditional -C -CC -DNON_LAYOUT_COMPILE_FIXES=1 \ - | grep -F '/*$*/' \ - | sed -e 's! /\*\$\*/!!' \ - -e 's!^@!#!' \ - -e 's!#define 1 1!#define NON_LAYOUT_COMPILE_FIXES 1!' - diff --git a/toolkit/workben/layout/uno.hxx b/toolkit/workben/layout/uno.hxx deleted file mode 100644 index 94a70e9fdc1e..000000000000 --- a/toolkit/workben/layout/uno.hxx +++ /dev/null @@ -1,109 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef _LAYOUT_UNO_HXX -#define _LAYOUT_UNO_HXX - -#include -#include -#include -#include - -#include -#include - -#if LAYOUT_WEAK -#include -class UnoBootstrapLayout : public ::cppu::WeakImplHelper1< com::sun::star::lang::XMultiServiceFactory > -#else /* !LAYOUT_WEAK */ -class UnoBootstrapLayout : public com::sun::star::lang::XMultiServiceFactory -#endif /* LAYOUT_WEAK */ -{ -public: - com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > mxMSF; - UnoBootstrapLayout( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > xMSF ) - : mxMSF( xMSF ) - { - fprintf( stderr, "UnoBootstrap Layout\n" ); - } - virtual com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL - createInstance( const rtl::OUString& aServiceSpecifier ) throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException) - { - if ( aServiceSpecifier.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.awt.Layout" ) ) ) - { - fprintf( stderr, "UnoBootstrapLayout: create service '%s'\n", - rtl::OUStringToOString (aServiceSpecifier, RTL_TEXTENCODING_UTF8 ).getStr() ); - return com::sun::star::uno::Reference< com::sun::star::lang::XSingleServiceFactory >( new ::LayoutFactory( this ) ); - } - else - { - fprintf( stderr, "UnoBootstrapLayout: create service '%s'\n", - rtl::OUStringToOString (aServiceSpecifier, RTL_TEXTENCODING_UTF8 ).getStr() ); - try - { - return mxMSF->createInstance( aServiceSpecifier ); - } - catch ( const com::sun::star::uno::Exception &rExc ) - { - rtl::OString aStr( rtl::OUStringToOString( rExc.Message, RTL_TEXTENCODING_ASCII_US ) ); - fprintf( stderr, "service construction exception '%s'\n", aStr.getStr()); - throw rExc; - } - } - } - virtual com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL - createInstanceWithArguments( const rtl::OUString& ServiceSpecifier, const com::sun::star::uno::Sequence< com::sun::star::uno::Any >& Arguments ) throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException) - { - return mxMSF->createInstanceWithArguments( ServiceSpecifier, Arguments ); - } - virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL - getAvailableServiceNames() throw (com::sun::star::uno::RuntimeException) - { - return mxMSF->getAvailableServiceNames(); - } - -#if !LAYOUT_WEAK - // XInterface - virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) - { - return mxMSF->queryInterface( rType ); - } - virtual void SAL_CALL acquire() throw() - { - mxMSF->acquire(); - } - virtual void SAL_CALL release() throw() - { - mxMSF->release(); - } -#endif /* !LAYOUT_WEAK */ -}; - -#endif /* _LAYOUT_UNO_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/workben/layout/wordcount-plain.xml b/toolkit/workben/layout/wordcount-plain.xml deleted file mode 100644 index 5adce42acdbd..000000000000 --- a/toolkit/workben/layout/wordcount-plain.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/toolkit/workben/layout/wordcount-tight.xml b/toolkit/workben/layout/wordcount-tight.xml deleted file mode 100644 index bcf6a6d86fca..000000000000 --- a/toolkit/workben/layout/wordcount-tight.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/toolkit/workben/layout/wordcount.xml b/toolkit/workben/layout/wordcount.xml deleted file mode 100644 index 4b4e362e8583..000000000000 --- a/toolkit/workben/layout/wordcount.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/toolkit/workben/layout/wordcountdialog.cxx b/toolkit/workben/layout/wordcountdialog.cxx deleted file mode 100644 index da0083e09456..000000000000 --- a/toolkit/workben/layout/wordcountdialog.cxx +++ /dev/null @@ -1,111 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#if !TEST_LAYOUT -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sw.hxx" -#ifdef SW_DLLIMPLEMENTATION -#undef SW_DLLIMPLEMENTATION -#endif -#include -#endif /* !TEST_LAYOUT */ -#include -#if !TEST_LAYOUT -#include - -#include -#endif /* !TEST_LAYOUT */ -#include -#if !TEST_LAYOUT -#include -#endif /* !TEST_LAYOUT */ - -#if ENABLE_LAYOUT -#undef SW_RES -#define SW_RES(x) #x -#undef SfxModalDialog -#define SfxModalDialog( parent, id ) Dialog( parent, "wordcount.xml", id ) -#define SW_WORDCOUNTDIALOG_HRC -#include -#endif /* ENABLE_LAYOUT */ - -SwWordCountDialog::SwWordCountDialog(Window* pParent) : - SfxModalDialog(pParent, SW_RES(DLG_WORDCOUNT)), -#if defined _MSC_VER -#pragma warning (disable : 4355) -#endif - aCurrentFL( this, SW_RES( FL_CURRENT )), - aCurrentWordFT( this, SW_RES( FT_CURRENTWORD )), - aCurrentWordFI( this, SW_RES( FI_CURRENTWORD )), - aCurrentCharacterFT( this, SW_RES( FT_CURRENTCHARACTER )), - aCurrentCharacterFI( this, SW_RES( FI_CURRENTCHARACTER )), - aCurrentCharacterExcludingSpacesFT( this, SW_RES( FT_CURRENTCHARACTEREXCLUDINGSPACES )), - aCurrentCharacterExcludingSpacesFI( this, SW_RES( FI_CURRENTCHARACTEREXCLUDINGSPACES )), - - aDocFL( this, SW_RES( FL_DOC )), - aDocWordFT( this, SW_RES( FT_DOCWORD )), - aDocWordFI( this, SW_RES( FI_DOCWORD )), - aDocCharacterFT( this, SW_RES( FT_DOCCHARACTER )), - aDocCharacterFI( this, SW_RES( FI_DOCCHARACTER )), - aDocCharacterExcludingSpacesFT( this, SW_RES( FT_DOCCHARACTEREXCLUDINGSPACES )), - aDocCharacterExcludingSpacesFI( this, SW_RES( FI_DOCCHARACTEREXCLUDINGSPACES )), - aBottomFL(this, SW_RES( FL_BOTTOM )), - aOK( this, SW_RES( PB_OK )), - aHelp( this, SW_RES( PB_HELP )) -#if defined _MSC_VER -#pragma warning (default : 4355) -#endif -{ -#if ENABLE_LAYOUT - SetHelpId (HID_DLG_WORDCOUNT); -#endif /* ENABLE_LAYOUT */ - FreeResource(); -} - -SwWordCountDialog::~SwWordCountDialog() -{ -} - -void SwWordCountDialog::SetValues(const SwDocStat& rCurrent, const SwDocStat& rDoc) -{ -#if TEST_LAYOUT - (void) rCurrent; - (void) rDoc; -#else /* !TEST_LAYOUT */ - aCurrentWordFI.SetText( String::CreateFromInt32(rCurrent.nWord )); - aCurrentCharacterFI.SetText(String::CreateFromInt32(rCurrent.nChar )); - aCurrentCharacterExcludingSpacesFI.SetText(String::CreateFromInt32(rCurrent.nCharExcludingSpaces )); - aDocWordFI.SetText( String::CreateFromInt32(rDoc.nWord )); - aDocCharacterFI.SetText( String::CreateFromInt32(rDoc.nChar )); - aDocCharacterExcludingSpacesFI.SetText( String::CreateFromInt32(rDoc.nCharExcludingSpaces )); -#endif /* !TEST_LAYOUT */ -} - - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/workben/layout/wordcountdialog.hxx b/toolkit/workben/layout/wordcountdialog.hxx deleted file mode 100644 index 5c6dbabea04f..000000000000 --- a/toolkit/workben/layout/wordcountdialog.hxx +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_WORDCOUNTDIALOG_HXX -#define SW_WORDCOUNTDIALOG_HXX -#include -#include -#include -#include -#include -struct SwDocStat; -class SwWordCountDialog : public SfxModalDialog -{ - FixedLine aCurrentFL; - FixedText aCurrentWordFT; - FixedInfo aCurrentWordFI; - FixedText aCurrentCharacterFT; - FixedInfo aCurrentCharacterFI; - FixedText aCurrentCharacterExcludingSpacesFT; - FixedInfo aCurrentCharacterExcludingSpacesFI; - - FixedLine aDocFL; - FixedText aDocWordFT; - FixedInfo aDocWordFI; - FixedText aDocCharacterFT; - FixedInfo aDocCharacterFI; - FixedText aDocCharacterExcludingSpacesFT; - FixedInfo aDocCharacterExcludingSpacesFI; - - FixedLine aBottomFL; - - OKButton aOK; - HelpButton aHelp; - -public: - SwWordCountDialog(Window* pParent); - ~SwWordCountDialog(); - - void SetValues(const SwDocStat& rCurrent, const SwDocStat& rDoc); -}; - -#include - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/workben/layout/zoom-1.xml b/toolkit/workben/layout/zoom-1.xml deleted file mode 100644 index 5fe06a3f270e..000000000000 --- a/toolkit/workben/layout/zoom-1.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - Set Zoom - - Zoom factor - Whole Page - Page Width - Optimal - 200 % - 15~0 % - 100 % - 75 % - 50 % - - - Variable - - - - - - - - - - - - - diff --git a/toolkit/workben/layout/zoom-2.xml b/toolkit/workben/layout/zoom-2.xml deleted file mode 100644 index c74e0c9a9da7..000000000000 --- a/toolkit/workben/layout/zoom-2.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - Set Zoom - - Zoom factor - Whole Page - Page Width - Optimal - 200 % - 15~0 % - 100 % - 75 % - 50 % - - - Variable - - - - - - - - - - - - - diff --git a/toolkit/workben/layout/zoom-indent.xml b/toolkit/workben/layout/zoom-indent.xml deleted file mode 100644 index bd5853acdce4..000000000000 --- a/toolkit/workben/layout/zoom-indent.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/toolkit/workben/layout/zoom-plain.xml b/toolkit/workben/layout/zoom-plain.xml deleted file mode 100644 index c8383b8767a7..000000000000 --- a/toolkit/workben/layout/zoom-plain.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/toolkit/workben/layout/zoom.cxx b/toolkit/workben/layout/zoom.cxx deleted file mode 100644 index d05074908475..000000000000 --- a/toolkit/workben/layout/zoom.cxx +++ /dev/null @@ -1,614 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#if !TEST_LAYOUT -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_svx.hxx" -#endif /* !TEST_LAYOUT */ - -#ifdef SVX_DLLIMPLEMENTATION -#undef SVX_DLLIMPLEMENTATION -#endif - -// include --------------------------------------------------------------- - -#if TEST_LAYOUT -#include -#endif /* TEST_LAYOUT */ -#include -#include -#include -#include -#include - -#define _SVX_ZOOM_CXX - -#include -#if !TEST_LAYOUT -#include "zoom.hrc" -#endif /* !TEST_LAYOUT */ - -#include "zoom.hxx" -#if TEST_LAYOUT -#define SVX_ZOOM_OPTIMAL "Zoom optimal" -#define SVX_ZOOM_PAGEWIDTH "Zoom page width" -#define SVX_ZOOM_WHOLEPAGE "Zoom whole page" -struct SvxZoomItem -{ - void SetType( char const* s ) - { - fputs( s, stderr ); - } - - void SetValue( int n ) - { - fprintf( stderr, "Zoom factor: %d\n", int( n ) ); - } -}; -#define SfxPoolItem LAYOUT_SfxPoolItem -class LAYOUT_SfxPoolItem -{ -}; -struct SvxViewLayoutItem : public LAYOUT_SfxPoolItem -{ - bool IsBookMode() - { - return false; - } - USHORT GetValue() - { - return 0; - } - - void SetValue( int n ) - { - fprintf( stderr, "Zoom factor: %d\n", int( n ) ); - } - void SetBookMode( bool ) - { - } -}; -#else /* !TEST_LAYOUT */ -#include -#include -#include -#endif /* !TEST_LAYOUT */ -#include "zoom_def.hxx" - -#include - -#if ENABLE_LAYOUT -#undef SVX_RES -#define SVX_RES(x) #x -#undef SfxModalDialog -#define SfxModalDialog( parent, id ) Dialog( parent, "zoom.xml", id ) -#endif /* ENABLE_LAYOUT */ - -// static ---------------------------------------------------------------- - -static USHORT pRanges[] = -{ - SID_ATTR_ZOOM, - SID_ATTR_ZOOM, - 0 -}; - -#define SPECIAL_FACTOR ((USHORT)0xFFFF) - -// class SvxZoomDialog --------------------------------------------------- - -USHORT SvxZoomDialog::GetFactor() const -{ - if ( a100Btn.IsChecked() ) - return 100; - if ( aUserBtn.IsChecked() ) - return (USHORT)aUserEdit.GetValue(); - else - return SPECIAL_FACTOR; -} - -// ----------------------------------------------------------------------- - -void SvxZoomDialog::SetFactor( USHORT nNewFactor, USHORT nBtnId ) -{ -#if TEST_LAYOUT - printf ("\t\t set factor %d\n", (int)nNewFactor); -#endif /* !TEST_LAYOUT */ - aUserEdit.Disable(); - - if ( !nBtnId ) - { - if ( nNewFactor == 100 ) - { - a100Btn.Check(); - a100Btn.GrabFocus(); - } - else - { - aUserBtn.Check(); - aUserEdit.Enable(); - aUserEdit.SetValue( (long)nNewFactor ); - aUserEdit.GrabFocus(); - } - } - else - { - aUserEdit.SetValue( (long)nNewFactor ); - - if ( ZOOMBTN_OPTIMAL == nBtnId ) - { - aOptimalBtn.Check(); - aOptimalBtn.GrabFocus(); - } - else if ( ZOOMBTN_PAGEWIDTH == nBtnId ) - { - aPageWidthBtn.Check(); - aPageWidthBtn.GrabFocus(); - } - else if ( ZOOMBTN_WHOLEPAGE == nBtnId ) - { - aWholePageBtn.Check(); - aWholePageBtn.GrabFocus(); - } - } -} - -// ----------------------------------------------------------------------- - -void SvxZoomDialog::SetButtonText( USHORT nBtnId, const String& rNewTxt ) -{ - switch ( nBtnId ) - { - case ZOOMBTN_OPTIMAL: // Optimal-Button - aOptimalBtn.SetText( rNewTxt ); - break; - - case ZOOMBTN_PAGEWIDTH: // Seitenbreite-Button - aPageWidthBtn.SetText( rNewTxt ); - break; - - case ZOOMBTN_WHOLEPAGE: // Ganze Seite-Button - aWholePageBtn.SetText( rNewTxt ); - break; - - default: - OSL_FAIL( "wrong button number" ); - } -} - -// ----------------------------------------------------------------------- - -void SvxZoomDialog::HideButton( USHORT nBtnId ) -{ - switch ( nBtnId ) - { - case ZOOMBTN_OPTIMAL: // Optimal-Button - aOptimalBtn.Hide(); - break; - - case ZOOMBTN_PAGEWIDTH: // Seitenbreite-Button - aPageWidthBtn.Hide(); - break; - - case ZOOMBTN_WHOLEPAGE: // Ganze Seite-Button - aWholePageBtn.Hide(); - break; - - default: - OSL_FAIL( "Falsche Button-Nummer!!!" ); - } -} - -// ----------------------------------------------------------------------- - -void SvxZoomDialog::SetLimits( USHORT nMin, USHORT nMax ) -{ - DBG_ASSERT( nMin < nMax, "invalid limits" ); - aUserEdit.SetMin( nMin ); - aUserEdit.SetFirst( nMin ); - aUserEdit.SetMax( nMax ); - aUserEdit.SetLast( nMax ); -} - -// ----------------------------------------------------------------------- - -void SvxZoomDialog::SetSpinSize( USHORT nNewSpin ) -{ - aUserEdit.SetSpinSize( nNewSpin ); -} - -// ----------------------------------------------------------------------- - -#if TEST_LAYOUT -SvxZoomDialog::SvxZoomDialog( Window* pParent ) : -#else /* !TEST_LAYOUT */ -SvxZoomDialog::SvxZoomDialog( Window* pParent, const SfxItemSet& rCoreSet ) : -#endif /* !TEST_LAYOUT */ - - SfxModalDialog( pParent, SVX_RES( RID_SVXDLG_ZOOM ) ), - - aZoomFl ( this, SVX_RES( FL_ZOOM ) ), - aOptimalBtn ( this, SVX_RES( BTN_OPTIMAL ) ), - aWholePageBtn ( this, SVX_RES( BTN_WHOLE_PAGE ) ), - aPageWidthBtn ( this, SVX_RES( BTN_PAGE_WIDTH ) ), - a100Btn ( this, SVX_RES( BTN_100 ) ), - aUserBtn ( this, SVX_RES( BTN_USER ) ), - aUserEdit ( this, SVX_RES( ED_USER ) ), - - aViewLayoutFl ( this, SVX_RES( FL_VIEWLAYOUT ) ), - aAutomaticBtn ( this, SVX_RES( BTN_AUTOMATIC ) ), - aSingleBtn ( this, SVX_RES( BTN_SINGLE ) ), - aColumnsBtn ( this, SVX_RES( BTN_COLUMNS ) ), - aColumnsEdit ( this, SVX_RES( ED_COLUMNS ) ), - aBookModeChk ( this, SVX_RES( CHK_BOOK ) ), - - aBottomFl ( this, SVX_RES( FL_BOTTOM ) ), - aOKBtn ( this, SVX_RES( BTN_ZOOM_OK ) ), - aCancelBtn ( this, SVX_RES( BTN_ZOOM_CANCEL ) ), - aHelpBtn ( this, SVX_RES( BTN_ZOOM_HELP ) ), - -#if !TEST_LAYOUT - rSet ( rCoreSet ), -#endif /* !TEST_LAYOUT */ - pOutSet ( NULL ), - bModified ( FALSE ) - -{ -#if ENABLE_LAYOUT - SetHelpId (SID_ATTR_ZOOM); -#endif /* ENABLE_LAYOUT */ - Link aLink = LINK( this, SvxZoomDialog, UserHdl ); - a100Btn.SetClickHdl( aLink ); - aOptimalBtn.SetClickHdl( aLink ); - aPageWidthBtn.SetClickHdl( aLink ); - aWholePageBtn.SetClickHdl( aLink ); - aUserBtn.SetClickHdl( aLink ); - - Link aViewLayoutLink = LINK( this, SvxZoomDialog, ViewLayoutUserHdl ); - aAutomaticBtn.SetClickHdl( aViewLayoutLink ); - aSingleBtn.SetClickHdl( aViewLayoutLink ); - aColumnsBtn.SetClickHdl( aViewLayoutLink ); - - Link aViewLayoutSpinLink = LINK( this, SvxZoomDialog, ViewLayoutSpinHdl ); - aColumnsEdit.SetModifyHdl( aViewLayoutSpinLink ); - - Link aViewLayoutCheckLink = LINK( this, SvxZoomDialog, ViewLayoutCheckHdl ); - aBookModeChk.SetClickHdl( aViewLayoutCheckLink ); - - aOKBtn.SetClickHdl( LINK( this, SvxZoomDialog, OKHdl ) ); - aUserEdit.SetModifyHdl( LINK( this, SvxZoomDialog, SpinHdl ) ); - - // Default-Werte - USHORT nValue = 100; - USHORT nMin = 10; - USHORT nMax = 1000; - -#if !TEST_LAYOUT - // ggf. erst den alten Wert besorgen - const SfxUInt16Item* pOldUserItem = 0; - SfxObjectShell* pSh = SfxObjectShell::Current(); - - if ( pSh ) - pOldUserItem = (const SfxUInt16Item*)pSh->GetItem( SID_ATTR_ZOOM_USER ); - - if ( pOldUserItem ) - nValue = pOldUserItem->GetValue(); - - // UserEdit initialisieren - if ( nMin > nValue ) - nMin = nValue; - if ( nMax < nValue ) - nMax = nValue; -#endif /* !TEST_LAYOUT */ - aUserEdit.SetMin( nMin ); - aUserEdit.SetFirst( nMin ); - aUserEdit.SetMax( nMax ); - aUserEdit.SetLast( nMax ); - aUserEdit.SetValue( nValue ); - -#if TEST_LAYOUT - USHORT nZoom = 100; - SetFactor( nZoom ); -#else /* !TEST_LAYOUT */ - const SfxPoolItem& rItem = rSet.Get( rSet.GetPool()->GetWhich( SID_ATTR_ZOOM ) ); - - if ( rItem.ISA(SvxZoomItem) ) - { - const SvxZoomItem& rZoomItem = (const SvxZoomItem&)rItem; - const USHORT nZoom = rZoomItem.GetValue(); - const SvxZoomType eType = rZoomItem.GetType(); - const USHORT nValSet = rZoomItem.GetValueSet(); - USHORT nBtnId = 0; - - switch ( eType ) - { - case SVX_ZOOM_OPTIMAL: - nBtnId = ZOOMBTN_OPTIMAL; - break; - case SVX_ZOOM_PAGEWIDTH: - nBtnId = ZOOMBTN_PAGEWIDTH; - break; - case SVX_ZOOM_WHOLEPAGE: - nBtnId = ZOOMBTN_WHOLEPAGE; - break; - case SVX_ZOOM_PERCENT: - break; - case SVX_ZOOM_PAGEWIDTH_NOBORDER: - break; - } - - if ( !(SVX_ZOOM_ENABLE_100 & nValSet) ) - a100Btn.Disable(); - if ( !(SVX_ZOOM_ENABLE_OPTIMAL & nValSet) ) - aOptimalBtn.Disable(); - if ( !(SVX_ZOOM_ENABLE_PAGEWIDTH & nValSet) ) - aPageWidthBtn.Disable(); - if ( !(SVX_ZOOM_ENABLE_WHOLEPAGE & nValSet) ) - aWholePageBtn.Disable(); - SetFactor( nZoom, nBtnId ); - } - else - { - const USHORT nZoom = ( (const SfxUInt16Item&)rItem ).GetValue(); - SetFactor( nZoom ); - } - - const SfxPoolItem* pViewLayoutItem = 0; - if ( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_VIEWLAYOUT, FALSE, &pViewLayoutItem ) ) - { - const USHORT nColumns = static_cast(pViewLayoutItem)->GetValue(); - const bool bBookMode = static_cast(pViewLayoutItem)->IsBookMode(); - - if ( 0 == nColumns ) - { - aAutomaticBtn.Check(); - aColumnsEdit.SetValue( 2 ); - aColumnsEdit.Disable(); - aBookModeChk.Disable(); - } - else if ( 1 == nColumns) - { - aSingleBtn.Check(); - aColumnsEdit.SetValue( 2 ); - aColumnsEdit.Disable(); - aBookModeChk.Disable(); - } - else - { - aColumnsBtn.Check(); - if ( !bBookMode ) - { - aColumnsEdit.SetValue( nColumns ); - if ( 0 != nColumns % 2 ) - aBookModeChk.Disable(); - } - else - { - aColumnsEdit.SetValue( nColumns ); - aBookModeChk.Check(); - } - } - } - else - { - // hide view layout related controls: - aViewLayoutFl.Disable(); - aAutomaticBtn.Disable(); - aSingleBtn.Disable(); - aColumnsBtn.Disable(); - aColumnsEdit.Disable(); - aBookModeChk.Disable(); - } -#endif /* !TEST_LAYOUT */ - - FreeResource(); -} - -// ----------------------------------------------------------------------- - -SvxZoomDialog::~SvxZoomDialog() -{ - delete pOutSet; - pOutSet = 0; -} - -// ----------------------------------------------------------------------- - -USHORT* SvxZoomDialog::GetRanges() -{ - return pRanges; -} - -// ----------------------------------------------------------------------- - -IMPL_LINK( SvxZoomDialog, UserHdl, RadioButton *, pBtn ) -{ -#if TEST_LAYOUT - fprintf( stderr, "SvxZoomDialog::UserHdl\n" ); -#endif /* TEST_LAYOUT */ - bModified |= TRUE; - - if ( pBtn == &aUserBtn ) - { - aUserEdit.Enable(); - aUserEdit.GrabFocus(); - } - else - aUserEdit.Disable(); - return 0; -} - -// ----------------------------------------------------------------------- - -IMPL_LINK( SvxZoomDialog, SpinHdl, MetricField *, EMPTYARG ) -{ - if ( !aUserBtn.IsChecked() ) - return 0; - bModified |= TRUE; - return 0; -} - -// ----------------------------------------------------------------------- - -IMPL_LINK( SvxZoomDialog, ViewLayoutUserHdl, RadioButton *, pBtn ) -{ - bModified |= TRUE; - - if ( pBtn == &aAutomaticBtn ) - { - aColumnsEdit.Disable(); - aBookModeChk.Disable(); - } - else if ( pBtn == &aSingleBtn ) - { - aColumnsEdit.Disable(); - aBookModeChk.Disable(); - } - else if ( pBtn == &aColumnsBtn ) - { - aColumnsEdit.Enable(); - aColumnsEdit.GrabFocus(); - if ( 0 == aColumnsEdit.GetValue() % 2 ) - aBookModeChk.Enable(); - } - else - { - OSL_FAIL( "Wrong Button" ); - return 0; - } - - return 0; -} - -// ----------------------------------------------------------------------- - -IMPL_LINK( SvxZoomDialog, ViewLayoutSpinHdl, MetricField *, pEdt ) -{ - if ( pEdt == &aColumnsEdit && !aColumnsBtn.IsChecked() ) - return 0; - - if ( 0 == aColumnsEdit.GetValue() % 2 ) - aBookModeChk.Enable(); - else - { - aBookModeChk.Check( sal_False ); - aBookModeChk.Disable(); - } - - bModified |= TRUE; - - return 0; -} - -// ----------------------------------------------------------------------- - -IMPL_LINK( SvxZoomDialog, ViewLayoutCheckHdl, CheckBox *, pChk ) -{ - if ( pChk == &aBookModeChk && !aColumnsBtn.IsChecked() ) - return 0; - - bModified |= TRUE; - - return 0; -} - -// ----------------------------------------------------------------------- - -IMPL_LINK( SvxZoomDialog, OKHdl, Button *, pBtn ) -{ - if ( bModified || &aOKBtn != pBtn ) - { -#if TEST_LAYOUT - SvxZoomItem aZoomItem; - SvxViewLayoutItem aViewLayoutItem; -#else /* !TEST_LAYOUT */ - SvxZoomItem aZoomItem( SVX_ZOOM_PERCENT, 0, rSet.GetPool()->GetWhich( SID_ATTR_ZOOM ) ); - SvxViewLayoutItem aViewLayoutItem( 0, false, rSet.GetPool()->GetWhich( SID_ATTR_VIEWLAYOUT ) ); -#endif /* !TEST_LAYOUT */ - - if ( &aOKBtn == pBtn ) - { - USHORT nFactor = GetFactor(); - - if ( SPECIAL_FACTOR == nFactor ) - { - if ( aOptimalBtn.IsChecked() ) - aZoomItem.SetType( SVX_ZOOM_OPTIMAL ); - else if ( aPageWidthBtn.IsChecked() ) - aZoomItem.SetType( SVX_ZOOM_PAGEWIDTH ); - else if ( aWholePageBtn.IsChecked() ) - aZoomItem.SetType( SVX_ZOOM_WHOLEPAGE ); - } - else - aZoomItem.SetValue( nFactor ); - - if ( aAutomaticBtn.IsChecked() ) - { - aViewLayoutItem.SetValue( 0 ); - aViewLayoutItem.SetBookMode( false ); - } - if ( aSingleBtn.IsChecked() ) - { - aViewLayoutItem.SetValue( 1 ); - aViewLayoutItem.SetBookMode( false ); - } - else if ( aColumnsBtn.IsChecked() ) - { - aViewLayoutItem.SetValue( static_cast(aColumnsEdit.GetValue()) ); - aViewLayoutItem.SetBookMode( aBookModeChk.IsChecked() ); - } - } - else - { - OSL_FAIL( "Wrong Button" ); - return 0; - } -#if !TEST_LAYOUT - pOutSet = new SfxItemSet( rSet ); - pOutSet->Put( aZoomItem ); - - // don't set attribute in case the whole viewlayout stuff is disabled: - if ( aViewLayoutFl.IsEnabled() ) - pOutSet->Put( aViewLayoutItem ); - - // Wert aus dem UserEdit "uber den Dialog hinaus merken - SfxObjectShell* pSh = SfxObjectShell::Current(); - - if ( pSh ) - pSh->PutItem( SfxUInt16Item( SID_ATTR_ZOOM_USER, - (UINT16)aUserEdit.GetValue() ) ); -#endif /* !TEST_LAYOUT */ - EndDialog( RET_OK ); - } - else - EndDialog( RET_CANCEL ); - return 0; -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/workben/layout/zoom.hrc b/toolkit/workben/layout/zoom.hrc deleted file mode 100644 index 49412ad085f0..000000000000 --- a/toolkit/workben/layout/zoom.hrc +++ /dev/null @@ -1,53 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _SVX_ZOOM_HRC -#define _SVX_ZOOM_HRC - -// defines ------------------------------------------------------------------ - -#define FL_ZOOM 14 -#define BTN_OPTIMAL 15 -#define BTN_WHOLE_PAGE 16 -#define BTN_PAGE_WIDTH 17 -#define BTN_100 18 -#define BTN_USER 19 -#define ED_USER 20 - -#define FL_VIEWLAYOUT 21 -#define BTN_AUTOMATIC 22 -#define BTN_SINGLE 23 -#define BTN_COLUMNS 24 -#define ED_COLUMNS 25 -#define CHK_BOOK 26 - -#define FL_BOTTOM 27 -#define BTN_ZOOM_OK 28 -#define BTN_ZOOM_CANCEL 29 -#define BTN_ZOOM_HELP 30 - -#endif - diff --git a/toolkit/workben/layout/zoom.hxx b/toolkit/workben/layout/zoom.hxx deleted file mode 100644 index 0fab50eb1ced..000000000000 --- a/toolkit/workben/layout/zoom.hxx +++ /dev/null @@ -1,121 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _SVX_ZOOM_HXX -#define _SVX_ZOOM_HXX - -// include --------------------------------------------------------------- - -#include -#include -#include -#include -#include - -// define ---------------------------------------------------------------- -/* CHINA001 -#define ZOOMBTN_OPTIMAL ((USHORT)0x0001) -#define ZOOMBTN_PAGEWIDTH ((USHORT)0x0002) -#define ZOOMBTN_WHOLEPAGE ((USHORT)0x0004) -*/ -#include "zoom_def.hxx" -// class SvxZoomDialog --------------------------------------------------- -/* - {k:\svx\prototyp\dialog\zoom.bmp} - - [Beschreibung] - Mit diesem Dialog wird ein Zoom-Faktor eingestellt. - - [Items] - SvxZoomItem -*/ - -#include - -class SvxZoomDialog : public SfxModalDialog -{ -private: - FixedLine aZoomFl; - RadioButton aOptimalBtn; - RadioButton aWholePageBtn; - RadioButton aPageWidthBtn; - RadioButton a100Btn; - RadioButton aUserBtn; - MetricField aUserEdit; - - FixedLine aViewLayoutFl; - RadioButton aAutomaticBtn; - RadioButton aSingleBtn; - RadioButton aColumnsBtn; - MetricField aColumnsEdit; - CheckBox aBookModeChk; - - FixedLine aBottomFl; - OKButton aOKBtn; - CancelButton aCancelBtn; - HelpButton aHelpBtn; - -#if !TEST_LAYOUT - const SfxItemSet& rSet; -#endif /* !TEST_LAYOUT */ - SfxItemSet* pOutSet; - BOOL bModified; - -#ifdef _SVX_ZOOM_CXX - DECL_LINK( UserHdl, RadioButton* ); - DECL_LINK( SpinHdl, MetricField* ); - DECL_LINK( ViewLayoutUserHdl, RadioButton* ); - DECL_LINK( ViewLayoutSpinHdl, MetricField* ); - DECL_LINK( ViewLayoutCheckHdl, CheckBox* ); - DECL_LINK( OKHdl, Button* ); -#endif - -public: -#if TEST_LAYOUT - SvxZoomDialog( Window* pParent ); -#else /* !TEST_LAYOUT */ - SvxZoomDialog( Window* pParent, const SfxItemSet& rCoreSet ); -#endif /* !TEST_LAYOUT */ - ~SvxZoomDialog(); - - static USHORT* GetRanges(); - const SfxItemSet* GetOutputItemSet() const { return pOutSet; } - - USHORT GetFactor() const; - void SetFactor( USHORT nNewFactor, USHORT nBtnId = 0 ); - - void SetButtonText( USHORT nBtnId, const String& aNewTxt ); - void HideButton( USHORT nBtnId ); - void SetLimits( USHORT nMin, USHORT nMax ); - void SetSpinSize( USHORT nNewSpin ); -}; - -#include - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/workben/layout/zoom.xml b/toolkit/workben/layout/zoom.xml deleted file mode 100644 index 5cc376168a27..000000000000 --- a/toolkit/workben/layout/zoom.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/toolkit/workben/layout/zoom_def.hxx b/toolkit/workben/layout/zoom_def.hxx deleted file mode 100644 index 84b2db945a6e..000000000000 --- a/toolkit/workben/layout/zoom_def.hxx +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef _SVX_ZOOM_DEF_HXX -#define _SVX_ZOOM_DEF_HXX - -#define ZOOMBTN_OPTIMAL ((USHORT)0x0001) -#define ZOOMBTN_PAGEWIDTH ((USHORT)0x0002) -#define ZOOMBTN_WHOLEPAGE ((USHORT)0x0004) - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/workben/no_localization b/toolkit/workben/no_localization deleted file mode 100644 index 3ce3aa0ec048..000000000000 --- a/toolkit/workben/no_localization +++ /dev/null @@ -1 +0,0 @@ -Touch me to prevent that the localisation process extracts strings #i85733# diff --git a/toolkit/workben/unodialog.cxx b/toolkit/workben/unodialog.cxx deleted file mode 100644 index 4652457766c2..000000000000 --- a/toolkit/workben/unodialog.cxx +++ /dev/null @@ -1,270 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_toolkit.hxx" -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#include -#include -#include - -#include // InitExtToolkit -#include - -#include -#include -#include - -#include -#include - - -using namespace ::com::sun::star; -using namespace ::com::sun::star::connection; -using namespace ::rtl; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::registry; -using namespace ::com::sun::star::lang; - - - -::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > createApplicationServiceManager() -{ - try - { - ::rtl::OUString localRegistry = ::comphelper::getPathToUserRegistry(); - ::rtl::OUString systemRegistry = ::comphelper::getPathToSystemRegistry(); - - Reference< XSimpleRegistry > xLocalRegistry( ::cppu::createSimpleRegistry() ); - Reference< XSimpleRegistry > xSystemRegistry( ::cppu::createSimpleRegistry() ); - if ( xLocalRegistry.is() && (localRegistry.getLength() > 0) ) - { - try - { - xLocalRegistry->open( localRegistry, sal_False, sal_True); - } - catch ( InvalidRegistryException& ) - { - } - - if ( !xLocalRegistry->isValid() ) - xLocalRegistry->open(localRegistry, sal_True, sal_True); - } - - if ( xSystemRegistry.is() && (systemRegistry.getLength() > 0) ) - xSystemRegistry->open( systemRegistry, sal_True, sal_False); - - if ( (xLocalRegistry.is() && xLocalRegistry->isValid()) && - (xSystemRegistry.is() && xSystemRegistry->isValid()) ) - { - Reference < XSimpleRegistry > xReg( ::cppu::createNestedRegistry() ); - Sequence< Any > seqAnys(2); - seqAnys[0] <<= xLocalRegistry ; - seqAnys[1] <<= xSystemRegistry ; - Reference< XInitialization > xInit( xReg, UNO_QUERY ); - xInit->initialize( seqAnys ); - - Reference< XComponentContext > xContext( ::cppu::bootstrap_InitialComponentContext( xReg ) ); - return Reference< XMultiServiceFactory >( xContext->getServiceManager(), UNO_QUERY ); - } - } - catch( ::com::sun::star::uno::Exception& ) - { - } - - return ::cppu::createServiceFactory(); -} - - -// ----------------------------------------------------------------------- -void Main( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & ); - -SAL_IMPLEMENT_MAIN() -{ - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xMSF = createApplicationServiceManager(); - //SVInit( xMSF ); - ::Main( xMSF ); - //SVDeinit(); - return NULL; -} - -/* -class MyApp : public Application -{ -public: - void Main() - { - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xMSF = createApplicationServiceManager(); - ::Main( xMSF ); - } -}; - -MyApp aMyApp; -*/ - - -class MyWin : public WorkWindow -{ -private: - uno::Reference< awt::XView > mxView; - -public: - MyWin() : WorkWindow( NULL, WB_APP|WB_STDWORK ) {;} - void Paint( const Rectangle& r ); - void SetXView( uno::Reference< awt::XView > xV ) { mxView = xV; } -}; - - -// ----------------------------------------------------------------------- - -void Main( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & xMSF ) -{ - ::comphelper::setProcessServiceFactory( xMSF ); - - //uno::Reference< awt::XToolkit> xToolkit( xMSF->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.ExtToolkit" ) ) ), uno::UNO_QUERY ); - uno::Reference< awt::XToolkit> xToolkit( xMSF->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.Toolkit" ) ) ), uno::UNO_QUERY ); - - // Create a DialogModel - uno::Reference< container::XNameContainer > xC( xMSF->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ) ), uno::UNO_QUERY ); - uno::Reference< lang::XMultiServiceFactory > xModFact( xC, uno::UNO_QUERY ); - - // Create a ButtonModel - uno::Reference< awt::XControlModel > xCtrl1( xModFact->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlButtonModel" ) ) ), uno::UNO_QUERY ); - uno::Reference< beans::XPropertySet > xPSet( xCtrl1, uno::UNO_QUERY ); - uno::Any aValue; - aValue <<= (sal_Int32) 10; - xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "PositionX" ) ), aValue ); - aValue <<= (sal_Int32) 10; - xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "PositionY" ) ), aValue ); - aValue <<= (sal_Int32) 40; - xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Width" ) ), aValue ); - aValue <<= (sal_Int32) 12; - xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Height" ) ), aValue ); - aValue <<= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Test!" ) ); - xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Label" ) ), aValue ); - uno::Any aAny; - aAny <<= xCtrl1; - xC->insertByName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Control1" ) ), aAny ); - - uno::Reference< beans::XPropertySet > xDlgPSet( xC, uno::UNO_QUERY ); - aValue <<= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Test-Dialog" ) ); - xDlgPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Title" ) ), aValue ); - aValue <<= (sal_Int32) 200; - xDlgPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Width" ) ), aValue ); - aValue <<= (sal_Int32) 200; - xDlgPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Height" ) ), aValue ); - - // Create a Dialog - uno::Reference< awt::XControl > xDlg( xMSF->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialog" ) ) ), uno::UNO_QUERY ); - uno::Reference< awt::XControlModel > xDlgMod( xC, uno::UNO_QUERY ); - xDlg->setModel( xDlgMod ); - - // Create a EditModel - uno::Reference< awt::XControlModel > xCtrl2( xModFact->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlEditModel" ) ) ), uno::UNO_QUERY ); - xPSet = uno::Reference< beans::XPropertySet >( xCtrl2, uno::UNO_QUERY ); - aValue <<= (sal_Int32) 10; - xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "PositionX" ) ), aValue ); - aValue <<= (sal_Int32) 40; - xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "PositionY" ) ), aValue ); - aValue <<= (sal_Int32) 80; - xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Width" ) ), aValue ); - aValue <<= (sal_Int32) 12; - xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Height" ) ), aValue ); - aValue <<= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Text..." ) ); - xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Text" ) ), aValue ); - aAny <<= xCtrl2; - xC->insertByName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Control2" ) ), aAny ); - - // test if listener works... - aValue <<= (sal_Int32) 20; - xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "PositionX" ) ), aValue ); - - MyWin * pWindow; - ::SolarMutexGuard aVclGuard; - - pWindow = new MyWin(); - pWindow->Show(); - - xDlg->setDesignMode( sal_True ); - - uno::Reference< awt::XWindow > xWindow( xDlg, uno::UNO_QUERY ); - xWindow->setVisible( sal_False ); - - xDlg->createPeer( xToolkit, pWindow->GetComponentInterface() ); - - uno::Reference< awt::XView > xView( xDlg, uno::UNO_QUERY ); - pWindow->SetXView( xView ); - - uno::Reference< awt::XDialog > xD( xDlg, uno::UNO_QUERY ); - - //static BOOL bExecute = FALSE; - //if ( bExecute ) - xD->execute(); - //Execute(); - Reference< XComponent > xDT( xD, uno::UNO_QUERY ); - xDT->dispose(); - delete pWindow; - - Reference< XComponent > xT( xToolkit, uno::UNO_QUERY ); - xT->dispose(); - - Reference< beans::XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), UNO_QUERY ); - if (xProps.is()) - { - try - { - Reference< lang::XComponent > xComp; - if (xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("DefaultContext") ) ) >>= xComp) - { - xComp->dispose(); - } - } - catch (beans::UnknownPropertyException &) - { - } - } -} - -void MyWin::Paint( const Rectangle& r ) -{ - static BOOL bDraw = TRUE; - if ( bDraw && mxView.is() ) - mxView->draw( 50, 50 ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/unusedcode.easy b/unusedcode.easy index 3baabe9eb5f7..a8cece30ad3f 100644 --- a/unusedcode.easy +++ b/unusedcode.easy @@ -2136,223 +2136,6 @@ graphite2::TtfUtil::GlyfLookup(unsigned short, void const*, void const*, unsigne jfw_plugin::VendorBase::createInstance() jfw_plugin::VendorBase::getJavaExePaths(int*) jvmaccess::ClassPath::doLoadClass(com::sun::star::uno::Reference const&, void*, rtl::OUString const&, rtl::OUString const&) -layout::AdvancedButton::AddAdvanced(layout::Window*) -layout::AdvancedButton::AddSimple(layout::Window*) -layout::AdvancedButton::AdvancedButton(layout::Context*, char const*, unsigned int) -layout::AdvancedButton::AdvancedButton(layout::Window*, ResId const&) -layout::AdvancedButton::AdvancedButton(layout::Window*, long) -layout::AdvancedButton::RemoveAdvanced(layout::Window*) -layout::AdvancedButton::RemoveSimple(layout::Window*) -layout::AdvancedButton::SetDelta(int) -layout::ApplyButton::ApplyButton(layout::Context*, char const*, unsigned int) -layout::ApplyButton::ApplyButton(layout::Window*, ResId const&) -layout::ApplyButton::ApplyButton(layout::Window*, long) -layout::Box::Add(layout::Container*, bool, bool, int) -layout::Box::Add(layout::Window*, bool, bool, int) -layout::Button::Button(layout::Context*, char const*, unsigned int) -layout::Button::Button(layout::Window*, ResId const&) -layout::Button::Button(layout::Window*, long) -layout::Button::GetClickHdl() -layout::Button::SetClickHdl(Link const&) -layout::Button::SetImageAlign(ImageAlign) -layout::Button::SetModeImage(Image const&) -layout::Button::SetModeImage(layout::Image const&) -layout::CancelButton::CancelButton(layout::Window*, ResId const&) -layout::CancelButton::CancelButton(layout::Window*, long) -layout::CheckBox::Check(bool) -layout::CheckBox::CheckBox(layout::Context*, char const*, unsigned int) -layout::CheckBox::CheckBox(layout::Window*, ResId const&) -layout::CheckBox::CheckBox(layout::Window*, long) -layout::CheckBox::IsChecked() const -layout::ComboBox::Clear() -layout::ComboBox::ComboBox(layout::Context*, char const*, unsigned int) -layout::ComboBox::ComboBox(layout::Window*, ResId const&) -layout::ComboBox::ComboBox(layout::Window*, long) -layout::ComboBox::EnableAutocomplete(bool, bool) -layout::ComboBox::GetEntry(unsigned short) const -layout::ComboBox::GetEntryCount() const -layout::ComboBox::InsertEntry(String const&, unsigned short) -layout::ComboBox::RemoveEntry(String const&) -layout::ComboBox::RemoveEntry(unsigned short) -layout::ComboBox::SetClickHdl(Link const&) -layout::ComboBox::SetSelectHdl(Link const&) -layout::Container::Add(layout::Container*) -layout::Container::Add(layout::Window*) -layout::Container::Clear() -layout::Container::Hide() -layout::Container::Remove(layout::Container*) -layout::Container::Remove(layout::Window*) -layout::Container::Show() -layout::Context::getRoot() -layout::Context::getToplevel() -layout::Context::setToplevel(com::sun::star::uno::Reference) -layout::Control::GetGetFocusHdl() -layout::Control::GetLoseFocusHdl() -layout::Dialog::Close() -layout::Dialog::Dialog(layout::Window*, char const*, char const*, unsigned int) -layout::Dialog::Initialize(SfxChildWinInfo*) -layout::Dialog::Notify(NotifyEvent&) -layout::Dialog::SetText(rtl::OUString const&) -layout::Edit::Edit(layout::Context*, char const*, unsigned int) -layout::Edit::Edit(layout::Window*, ResId const&) -layout::Edit::Edit(layout::Window*, long) -layout::Edit::GetText() const -layout::Edit::SetSelection(Selection const&) -layout::Edit::SetText(rtl::OUString const&) -layout::ErrorBox::ErrorBox(Window*, char const*, char const*, char const*, rtl::OString const&, char const*, char const*) -layout::ErrorBox::ErrorBox(Window*, long, char const*, char const*, char const*, rtl::OString const&, char const*, char const*) -layout::ErrorBox::ErrorBox(Window*, long, rtl::OUString const&, rtl::OUString, rtl::OUString, rtl::OString const&, char const*, char const*) -layout::ErrorBox::ErrorBox(Window*, rtl::OUString const&, rtl::OUString, rtl::OUString, rtl::OString const&, char const*, char const*) -layout::FixedImage::FixedImage(layout::Window*, ResId const&) -layout::FixedImage::FixedImage(layout::Window*, long) -layout::FixedImage::setImage(Image const&) -layout::FixedInfo::FixedInfo(layout::Context*, char const*, unsigned int) -layout::FixedInfo::FixedInfo(layout::Window*, ResId const&) -layout::FixedInfo::FixedInfo(layout::Window*, long) -layout::FixedLine::FixedLine(layout::Context*, char const*, unsigned int) -layout::FixedLine::FixedLine(layout::Window*, ResId const&) -layout::FixedLine::FixedLine(layout::Window*, long) -layout::FixedLine::IsEnabled() const -layout::FixedText::FixedText(layout::Window*, ResId const&) -layout::FixedText::FixedText(layout::Window*, long) -layout::HBox::HBox(int, bool) -layout::HBox::HBox(layout::Context const*, char const*) -layout::HelpButton::HelpButton(layout::Window*, ResId const&) -layout::HelpButton::HelpButton(layout::Window*, long) -layout::IgnoreButton::IgnoreButton(layout::Window*, ResId const&) -layout::IgnoreButton::IgnoreButton(layout::Window*, long) -layout::Image::Image(char const*) -layout::Image::~Image() -layout::ImageButton::ImageButton(layout::Context*, char const*, unsigned int) -layout::ImageButton::ImageButton(layout::Window*, ResId const&) -layout::ImageButton::ImageButton(layout::Window*, long) -layout::InPlug::InPlug(Window*, char const*, char const*, unsigned int) -layout::InPlug::InPlug(layout::Window*, char const*, char const*, unsigned int) -layout::InfoBox::InfoBox(Window*, char const*, char const*, char const*, rtl::OString const&, char const*, char const*) -layout::InfoBox::InfoBox(Window*, long, char const*, char const*, char const*, rtl::OString const&, char const*, char const*) -layout::InfoBox::InfoBox(Window*, long, rtl::OUString const&, rtl::OUString, rtl::OUString, rtl::OString const&, char const*, char const*) -layout::InfoBox::InfoBox(Window*, rtl::OUString const&, rtl::OUString, rtl::OUString, rtl::OString const&, char const*, char const*) -layout::ListBox::Clear() -layout::ListBox::GetClickHdl() -layout::ListBox::GetDoubleClickHdl() -layout::ListBox::GetEntryCount() const -layout::ListBox::GetEntryData(unsigned short) const -layout::ListBox::GetSelectEntry(unsigned short) const -layout::ListBox::GetSelectEntryCount() const -layout::ListBox::GetSelectHdl() -layout::ListBox::InsertEntry(String const&, unsigned short) -layout::ListBox::ListBox(layout::Context*, char const*, unsigned int) -layout::ListBox::ListBox(layout::Window*, ResId const&) -layout::ListBox::ListBox(layout::Window*, long) -layout::ListBox::RemoveEntry(String const&) -layout::ListBox::RemoveEntry(unsigned short) -layout::ListBox::SelectEntry(String const&, bool) -layout::ListBox::SetClickHdl(Link const&) -layout::ListBox::SetDoubleClickHdl(Link const&) -layout::ListBox::SetEntryData(unsigned short, void*) -layout::ListBox::SetSelectHdl(Link const&) -layout::LocalizedString::GetToken(unsigned short, char) -layout::LocalizedString::LocalizedString(layout::Context*, char const*) -layout::MetricField::MetricField(layout::Context*, char const*, unsigned int) -layout::MetricField::MetricField(layout::Window*, long) -layout::MetricFormatter::GetValue(FieldUnit) const -layout::MetricFormatter::SetFirst(long, FieldUnit) -layout::MetricFormatter::SetLast(long, FieldUnit) -layout::MetricFormatter::SetMax(long, FieldUnit) -layout::MetricFormatter::SetMin(long, FieldUnit) -layout::MetricFormatter::SetSpinSize(long) -layout::MetricFormatter::SetValue(long, FieldUnit) -layout::MoreButton::AddWindow(layout::Window*) -layout::MoreButton::GetLessText() const -layout::MoreButton::GetMoreText() const -layout::MoreButton::MoreButton(layout::Context*, char const*, unsigned int) -layout::MoreButton::MoreButton(layout::Window*, ResId const&) -layout::MoreButton::MoreButton(layout::Window*, long) -layout::MoreButton::RemoveWindow(layout::Window*) -layout::MoreButton::SetLessText(rtl::OUString const&) -layout::MoreButton::SetMoreText(rtl::OUString const&) -layout::MultiLineEdit::MultiLineEdit(layout::Context*, char const*, unsigned int) -layout::MultiLineEdit::MultiLineEdit(layout::Window*, ResId const&) -layout::MultiLineEdit::MultiLineEdit(layout::Window*, long) -layout::MultiListBox::MultiListBox(layout::Context*, char const*, unsigned int) -layout::MultiListBox::MultiListBox(layout::Window*, ResId const&) -layout::MultiListBox::MultiListBox(layout::Window*, long) -layout::NoButton::NoButton(layout::Window*, ResId const&) -layout::NoButton::NoButton(layout::Window*, long) -layout::NumericField::NumericField(layout::Context*, char const*, unsigned int) -layout::NumericField::NumericField(layout::Window*, long) -layout::NumericFormatter::GetValue() const -layout::NumericFormatter::SetFirst(long) -layout::NumericFormatter::SetLast(long) -layout::NumericFormatter::SetMax(long) -layout::NumericFormatter::SetMin(long) -layout::NumericFormatter::SetSpinSize(long) -layout::NumericFormatter::SetValue(long) -layout::OKButton::OKButton(layout::Context*, char const*, unsigned int) -layout::OKButton::OKButton(layout::Window*, ResId const&) -layout::OKButton::OKButton(layout::Window*, long) -layout::Plugin::Plugin(layout::Context*, char const*, Control*) -layout::ProgressBar::GetValue() -layout::ProgressBar::ProgressBar(layout::Context*, char const*, unsigned int) -layout::ProgressBar::ProgressBar(layout::Window*, ResId const&) -layout::ProgressBar::ProgressBar(layout::Window*, long) -layout::ProgressBar::SetBackgroundColor(int) -layout::ProgressBar::SetForegroundColor(int) -layout::ProgressBar::SetRange(int, int) -layout::ProgressBar::SetValue(int) -layout::PushButton::IsChecked() const -layout::PushButton::PushButton(layout::Context*, char const*, unsigned int) -layout::PushButton::PushButton(layout::Window*, ResId const&) -layout::PushButton::PushButton(layout::Window*, long) -layout::PushButton::Toggle() -layout::QueryBox::QueryBox(Window*, char const*, char const*, char const*, rtl::OString const&, char const*, char const*) -layout::QueryBox::QueryBox(Window*, long, char const*, char const*, char const*, rtl::OString const&, char const*, char const*) -layout::QueryBox::QueryBox(Window*, long, rtl::OUString const&, rtl::OUString, rtl::OUString, rtl::OString const&, char const*, char const*) -layout::QueryBox::QueryBox(Window*, rtl::OUString const&, rtl::OUString, rtl::OUString, rtl::OString const&, char const*, char const*) -layout::RadioButton::Check(bool) -layout::RadioButton::GetVCLXRadioButton() const -layout::RadioButton::IsChecked() const -layout::RadioButton::RadioButton(layout::Context*, char const*, unsigned int) -layout::RadioButton::RadioButton(layout::Window*, ResId const&) -layout::RadioButton::RadioButton(layout::Window*, long) -layout::ResetButton::ResetButton(layout::Context*, char const*, unsigned int) -layout::ResetButton::ResetButton(layout::Window*, ResId const&) -layout::ResetButton::ResetButton(layout::Window*, long) -layout::RetryButton::RetryButton(layout::Window*, ResId const&) -layout::RetryButton::RetryButton(layout::Window*, long) -layout::SpinField::SpinField(layout::Context*, char const*, unsigned int) -layout::SpinField::SpinField(layout::Window*, ResId const&) -layout::SpinField::SpinField(layout::Window*, long) -layout::TabControl::GetActivatePageHdl() const -layout::TabControl::GetCurPageId() const -layout::TabControl::GetDeactivatePageHdl() const -layout::TabControl::GetPageCount() const -layout::TabControl::GetPageId(unsigned short) const -layout::TabControl::GetPagePos(unsigned short) const -layout::TabControl::GetTabPage(unsigned short) const -layout::TabControl::GetTabPageSizePixel() const -layout::TabControl::GetVCLXTabControl() const -layout::TabControl::InsertPage(unsigned short, rtl::OUString const&, unsigned short) -layout::TabControl::RemovePage(unsigned short) -layout::TabControl::SetTabPage(unsigned short, TabPage*) -layout::TabControl::SetTabPageSizePixel(Size const&) -layout::TabControl::TabControl(layout::Context*, char const*, unsigned int) -layout::TabControl::TabControl(layout::Window*, ResId const&) -layout::TabControl::TabControl(layout::Window*, long) -layout::TabPage::TabPage(Window*, char const*, char const*, unsigned int) -layout::TabPage::TabPage(layout::Window*, char const*, char const*, unsigned int) -layout::Table::Add(layout::Container*, bool, bool, int, int) -layout::Table::Add(layout::Window*, bool, bool, int, int) -layout::Table::Table(int, int) -layout::Table::Table(layout::Context const*, char const*) -layout::VBox::VBox(int, bool) -layout::VBox::VBox(layout::Context const*, char const*) -layout::WarningBox::WarningBox(Window*, char const*, char const*, char const*, rtl::OString const&, char const*, char const*) -layout::WarningBox::WarningBox(Window*, long, char const*, char const*, char const*, rtl::OString const&, char const*, char const*) -layout::WarningBox::WarningBox(Window*, long, rtl::OUString const&, rtl::OUString, rtl::OUString, rtl::OString const&, char const*, char const*) -layout::WarningBox::WarningBox(Window*, rtl::OUString const&, rtl::OUString, rtl::OUString, rtl::OString const&, char const*, char const*) -layout::YesButton::YesButton(layout::Window*, ResId const&) -layout::YesButton::YesButton(layout::Window*, long) layoutimpl::LayoutRoot::addItem(rtl::OUString const&, com::sun::star::uno::Reference const&) layoutimpl::VCLXTabControl::AddChild(com::sun::star::uno::Reference const&) layoutimpl::WidgetFactory::sfx2CreateWindow(VCLXWindow**, Window*, rtl::OUString const&, long&) -- cgit From b2e0b5f3f5b9a4c6b8483e6fb9855054c84aab92 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Wed, 2 Nov 2011 14:55:17 +0100 Subject: use SAL_N_ELEMENTS --- vcl/inc/unx/salunx.h | 3 --- vcl/unx/generic/app/saldata.cxx | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/vcl/inc/unx/salunx.h b/vcl/inc/unx/salunx.h index e4150f0f7467..5082519b334d 100644 --- a/vcl/inc/unx/salunx.h +++ b/vcl/inc/unx/salunx.h @@ -33,9 +33,6 @@ #include #include -// -=-= #defines -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -#define capacityof(a) (sizeof(a)/sizeof(*a)) - // -=-= inlines =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= inline long Divide( long nDividend, long nDivisor ) { return (nDividend + nDivisor/2) / nDivisor; } diff --git a/vcl/unx/generic/app/saldata.cxx b/vcl/unx/generic/app/saldata.cxx index 8eb660202483..3f88f359f575 100644 --- a/vcl/unx/generic/app/saldata.cxx +++ b/vcl/unx/generic/app/saldata.cxx @@ -513,7 +513,7 @@ static void PrintXError( Display *pDisplay, XErrorEvent *pEvent ) XGetErrorText( pDisplay, pEvent->error_code, msg, sizeof( msg ) ); #endif std::fprintf( stderr, "X-Error: %s\n", msg ); - if( pEvent->request_code < capacityof( XRequest ) ) + if( pEvent->request_code < SAL_N_ELEMENTS( XRequest ) ) { const char* pName = XRequest[pEvent->request_code]; if( !pName ) -- cgit From fd886cdc6a8c047a9fb1bd10a00f901b4adb525e Mon Sep 17 00:00:00 2001 From: Cédric Bosdonnat Date: Mon, 31 Oct 2011 17:39:16 +0100 Subject: n#693238: fixed docx import of tabs set after the end margin Added a new compatibility option to keep the previous behavior, but changed the default to avoid lines insertion for tabs when there are tab stops set beyond the end margin --- sw/inc/IDocumentSettingAccess.hxx | 3 ++- sw/inc/doc.hxx | 1 + sw/source/core/doc/doc.cxx | 5 +++++ sw/source/core/doc/docnew.cxx | 1 + sw/source/core/text/inftxt.cxx | 5 +++-- sw/source/core/text/inftxt.hxx | 4 ++++ sw/source/core/text/itrform2.cxx | 3 +++ sw/source/core/text/portab.hxx | 8 +++++--- sw/source/core/text/txttab.cxx | 18 +++++++++++++----- sw/source/filter/ww8/ww8par.cxx | 1 + sw/source/filter/xml/xmlimp.cxx | 10 ++++++++++ sw/source/ui/uno/SwXDocumentSettings.cxx | 16 +++++++++++++++- 12 files changed, 63 insertions(+), 12 deletions(-) diff --git a/sw/inc/IDocumentSettingAccess.hxx b/sw/inc/IDocumentSettingAccess.hxx index 1dd769912c06..50e80967c5ee 100644 --- a/sw/inc/IDocumentSettingAccess.hxx +++ b/sw/inc/IDocumentSettingAccess.hxx @@ -79,9 +79,10 @@ namespace com { namespace sun { namespace star { namespace i18n { struct Forbidd PROTECT_FORM, // #i89181# TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST, - INVERT_BORDER_SPACING, + INVERT_BORDER_SPACING, COLLAPSE_EMPTY_CELL_PARA, SMALL_CAPS_PERCENTAGE_66, + TAB_OVERFLOW, // COMPATIBILITY FLAGS END BROWSE_MODE, diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index 3461e6d10b43..656b0b7eb8fe 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -579,6 +579,7 @@ private: bool mbCollapseEmptyCellPara : 1; bool mbTabAtLeftIndentForParagraphsInList; // #i89181# - see above bool mbSmallCapsPercentage66; + bool mbTabOverflow; bool mbLastBrowseMode : 1; diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index aef0e49db0ff..c5128627cf08 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -202,6 +202,7 @@ bool SwDoc::get(/*[in]*/ DocumentSettingId id) const case INVERT_BORDER_SPACING: return mbInvertBorderSpacing; case COLLAPSE_EMPTY_CELL_PARA: return mbCollapseEmptyCellPara; case SMALL_CAPS_PERCENTAGE_66: return mbSmallCapsPercentage66; + case TAB_OVERFLOW: return mbTabOverflow; case BROWSE_MODE: return mbLastBrowseMode; // Attention: normally the ViewShell has to be asked! case HTML_MODE: return mbHTMLMode; @@ -336,6 +337,10 @@ void SwDoc::set(/*[in]*/ DocumentSettingId id, /*[in]*/ bool value) case SMALL_CAPS_PERCENTAGE_66: mbSmallCapsPercentage66 = value; break; + + case TAB_OVERFLOW: + mbTabOverflow = value; + break; // COMPATIBILITY FLAGS END case BROWSE_MODE: //can be used temporary (load/save) when no ViewShell is avaiable diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index aa8aa3a85bfd..f8a0ce293d11 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -357,6 +357,7 @@ SwDoc::SwDoc() mbInvertBorderSpacing = false; // hidden mbCollapseEmptyCellPara = true; // hidden mbSmallCapsPercentage66 = false; // hidden + mbTabOverflow = true; // // COMPATIBILITY FLAGS END diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx index a76d74689188..5d84e848b363 100644 --- a/sw/source/core/text/inftxt.cxx +++ b/sw/source/core/text/inftxt.cxx @@ -1459,7 +1459,7 @@ void SwTxtFormatInfo::Init() // Nicht initialisieren: pRest, nLeft, nRight, nFirst, nRealWidth X(0); bArrowDone = bFull = bFtnDone = bErgoDone = bNumDone = bNoEndHyph = - bNoMidHyph = bStop = bNewLine = bUnderFlow = sal_False; + bNoMidHyph = bStop = bNewLine = bUnderFlow = bTabOverflow = sal_False; // generally we do not allow number portions in follows, except... if ( GetTxtFrm()->IsFollow() ) @@ -1501,7 +1501,8 @@ void SwTxtFormatInfo::Init() * --------------------------------------------------*/ SwTxtFormatInfo::SwTxtFormatInfo( const SwTxtFormatInfo& rInf, - SwLineLayout& rLay, SwTwips nActWidth ) : SwTxtPaintInfo( rInf ) + SwLineLayout& rLay, SwTwips nActWidth ) : SwTxtPaintInfo( rInf ), + bTabOverflow( sal_False ) { pRoot = &rLay; pLast = &rLay; diff --git a/sw/source/core/text/inftxt.hxx b/sw/source/core/text/inftxt.hxx index b549cf42e336..b056612f8284 100644 --- a/sw/source/core/text/inftxt.hxx +++ b/sw/source/core/text/inftxt.hxx @@ -565,6 +565,7 @@ class SwTxtFormatInfo : public SwTxtPaintInfo sal_Bool bFakeLineStart: 1; // String has been replaced by field portion // info structure only pretends that we are at // the beginning of a line + sal_Bool bTabOverflow; // Tabs are expanding after the end margin xub_Unicode cTabDecimal; // das _aktuelle_ Dezimalzeichen xub_Unicode cHookChar; // fuer Tabs in Feldern etc. @@ -734,6 +735,9 @@ public: // friend ostream &operator<<( ostream &rOS, const SwTxtFormatInfo &rInf ); friend SvStream &operator<<( SvStream &rOS, const SwTxtFormatInfo &rInf ); + + inline void SetTabOverflow( sal_Bool bOverflow ) { bTabOverflow = bOverflow; } + inline sal_Bool IsTabOverflow( ) { return bTabOverflow; } }; /************************************************************************* diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx index 965d73e09420..a507526b4188 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -738,6 +738,9 @@ void SwTxtFormatter::BuildPortions( SwTxtFormatInfo &rInf ) // 3260, 3860: Fly auf jeden Fall loeschen! ClearFly( rInf ); + + // Reinit the tab overflow flag after the line + rInf.SetTabOverflow( sal_False ); } /************************************************************************* diff --git a/sw/source/core/text/portab.hxx b/sw/source/core/text/portab.hxx index 3cda7b9d1f96..bb5fe9d03968 100644 --- a/sw/source/core/text/portab.hxx +++ b/sw/source/core/text/portab.hxx @@ -38,17 +38,19 @@ class SwTabPortion : public SwFixPortion { const KSHORT nTabPos; const xub_Unicode cFill; + const bool bAutoTabStop; // Das Format() verzweigt entweder in Pre- oder PostFormat() sal_Bool PreFormat( SwTxtFormatInfo &rInf ); public: - SwTabPortion( const KSHORT nTabPos, const xub_Unicode cFill = '\0' ); + SwTabPortion( const KSHORT nTabPos, const xub_Unicode cFill = '\0', const bool bAutoTab = true ); virtual void Paint( const SwTxtPaintInfo &rInf ) const; virtual sal_Bool Format( SwTxtFormatInfo &rInf ); virtual void FormatEOL( SwTxtFormatInfo &rInf ); sal_Bool PostFormat( SwTxtFormatInfo &rInf ); inline sal_Bool IsFilled() const { return 0 != cFill; } inline KSHORT GetTabPos() const { return nTabPos; } + inline sal_Bool IsAutoTabStop() const { return bAutoTabStop; } // Accessibility: pass information about this portion to the PortionHandler virtual void HandlePortion( SwPortionHandler& rPH ) const; @@ -63,8 +65,8 @@ public: class SwTabLeftPortion : public SwTabPortion { public: - inline SwTabLeftPortion( const KSHORT nTabPosVal, const xub_Unicode cFillChar='\0' ) - : SwTabPortion( nTabPosVal, cFillChar ) + inline SwTabLeftPortion( const KSHORT nTabPosVal, const xub_Unicode cFillChar='\0', bool bAutoTab = true ) + : SwTabPortion( nTabPosVal, cFillChar, bAutoTab ) { SetWhichPor( POR_TABLEFT ); } OUTPUT_OPERATOR }; diff --git a/sw/source/core/text/txttab.cxx b/sw/source/core/text/txttab.cxx index 7ed18741304d..d237873749fc 100644 --- a/sw/source/core/text/txttab.cxx +++ b/sw/source/core/text/txttab.cxx @@ -94,6 +94,7 @@ SwTabPortion *SwTxtFormatter::NewTabPortion( SwTxtFormatInfo &rInf, bool bAuto ) SvxTabAdjust eAdj; KSHORT nNewTabPos; + bool bAutoTabStop = true; { const bool bRTL = pFrm->IsRightToLeft(); // #i24363# tab stops relative to indent @@ -177,6 +178,7 @@ SwTabPortion *SwTxtFormatter::NewTabPortion( SwTxtFormatInfo &rInf, bool bAuto ) //calculate default tab position of default tabs in negative indent nNextPos = ( nSearchPos / nNextPos ) * nNextPos; } + bAutoTabStop = false; } else { @@ -312,7 +314,7 @@ SwTabPortion *SwTxtFormatter::NewTabPortion( SwTxtFormatInfo &rInf, bool bAuto ) { OSL_ENSURE( SVX_TAB_ADJUST_LEFT == eAdj || SVX_TAB_ADJUST_DEFAULT == eAdj, "+SwTxtFormatter::NewTabPortion: unknown adjustment" ); - pTabPor = new SwTabLeftPortion( nNewTabPos, cFill ); + pTabPor = new SwTabLeftPortion( nNewTabPos, cFill, bAutoTabStop ); break; } } @@ -333,8 +335,8 @@ SwTabPortion *SwTxtFormatter::NewTabPortion( SwTxtFormatInfo &rInf, bool bAuto ) // Die Basisklasse wird erstmal ohne alles initialisiert. -SwTabPortion::SwTabPortion( const KSHORT nTabPosition, const xub_Unicode cFillChar ) - : SwFixPortion( 0, 0 ), nTabPos(nTabPosition), cFill(cFillChar) +SwTabPortion::SwTabPortion( const KSHORT nTabPosition, const xub_Unicode cFillChar, const bool bAutoTab ) + : SwFixPortion( 0, 0 ), nTabPos(nTabPosition), cFill(cFillChar), bAutoTabStop( bAutoTab ) { nLineLength = 1; #if OSL_DEBUG_LEVEL > 1 @@ -388,6 +390,7 @@ sal_Bool SwTabPortion::PreFormat( SwTxtFormatInfo &rInf ) Fix( static_cast(rInf.X()) ); const bool bTabCompat = rInf.GetTxtFrm()->GetTxtNode()->getIDocumentSettingAccess()->get(IDocumentSettingAccess::TAB_COMPAT); + const bool bTabOverflow = rInf.GetTxtFrm()->GetTxtNode()->getIDocumentSettingAccess()->get(IDocumentSettingAccess::TAB_OVERFLOW); // Die Mindestbreite eines Tabs ist immer mindestens ein Blank // #i37686# In compatibility mode, the minimum width @@ -419,7 +422,7 @@ sal_Bool SwTabPortion::PreFormat( SwTxtFormatInfo &rInf ) // 1. Minmal width does not fit to line anymore. // 2. An underflow event was called for the tab portion. sal_Bool bFull = ( bTabCompat && rInf.IsUnderFlow() ) || - rInf.Width() <= rInf.X() + PrtWidth(); + ( rInf.Width() <= rInf.X() + PrtWidth() && rInf.X() <= rInf.Width() ) ; // #95477# Rotated tab stops get the width of one blank const sal_uInt16 nDir = rInf.GetFont()->GetOrientation( rInf.GetTxtFrm()->IsVertical() ); @@ -447,10 +450,15 @@ sal_Bool SwTabPortion::PreFormat( SwTxtFormatInfo &rInf ) // In tabulator compatibility mode, we reset the bFull flag // if the tabulator is at the end of the paragraph and the // tab stop position is outside the frame: + bool bAtParaEnd = rInf.GetIdx() + GetLen() == rInf.GetTxt().Len(); if ( bFull && bTabCompat && - rInf.GetIdx() + GetLen() == rInf.GetTxt().Len() && + ( bTabOverflow && ( rInf.IsTabOverflow() || !IsAutoTabStop() ) || bAtParaEnd ) && GetTabPos() >= rInf.GetTxtFrm()->Frm().Width() ) + { bFull = sal_False; + if ( bTabOverflow && !IsAutoTabStop() ) + rInf.SetTabOverflow( sal_True ); + } break; } diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 2876172ec21b..0f8f732fe21c 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -1579,6 +1579,7 @@ void SwWW8ImplReader::ImportDop() rDoc.set(IDocumentSettingAccess::INVERT_BORDER_SPACING, true); rDoc.set(IDocumentSettingAccess::COLLAPSE_EMPTY_CELL_PARA, true); + rDoc.set(IDocumentSettingAccess::TAB_OVERFLOW, true); // // COMPATIBILITY FLAGS END diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx index f47c9df7c9a0..06b95b30a963 100644 --- a/sw/source/filter/xml/xmlimp.cxx +++ b/sw/source/filter/xml/xmlimp.cxx @@ -1191,6 +1191,7 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC aSet.insert(String("PrinterIndependentLayout", RTL_TEXTENCODING_ASCII_US)); aSet.insert(String("PrintEmptyPages", RTL_TEXTENCODING_ASCII_US)); aSet.insert(String("SmallCapsPercentage66", RTL_TEXTENCODING_ASCII_US)); + aSet.insert(String("TabOverflow", RTL_TEXTENCODING_ASCII_US)); sal_Int32 nCount = aConfigProps.getLength(); const PropertyValue* pValues = aConfigProps.getConstArray(); @@ -1220,6 +1221,7 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC bool bUnixForceZeroExtLeading = false; bool bUseOldPrinterMetrics = false; bool bSmallCapsPercentage66 = false; + bool bTabOverflow = false; OUString sRedlineProtectionKey( RTL_CONSTASCII_USTRINGPARAM( "RedlineProtectionKey" ) ); @@ -1289,6 +1291,8 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC bUseOldPrinterMetrics = true; else if( pValues->Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("SmallCapsPercentage66")) ) bSmallCapsPercentage66 = true; + else if( pValues->Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("TabOverflow")) ) + bTabOverflow = true; } catch( Exception& ) { @@ -1442,6 +1446,12 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC OUString( RTL_CONSTASCII_USTRINGPARAM("SmallCapsPercentage66") ), makeAny( true ) ); } + if ( !bTabOverflow ) + { + xProps->setPropertyValue( + OUString( RTL_CONSTASCII_USTRINGPARAM("TabOverflow") ), makeAny( false ) ); + } + Reference < XTextDocument > xTextDoc( GetModel(), UNO_QUERY ); Reference < XText > xText = xTextDoc->getText(); Reference xTextTunnel( xText, UNO_QUERY); diff --git a/sw/source/ui/uno/SwXDocumentSettings.cxx b/sw/source/ui/uno/SwXDocumentSettings.cxx index b3dbea127dfe..0d42d120c3c6 100644 --- a/sw/source/ui/uno/SwXDocumentSettings.cxx +++ b/sw/source/ui/uno/SwXDocumentSettings.cxx @@ -123,7 +123,8 @@ enum SwDocumentSettingsPropertyHandles HANDLE_MATH_BASELINE_ALIGNMENT, HANDLE_INVERT_BORDER_SPACING, HANDLE_COLLAPSE_EMPTY_CELL_PARA, - HANDLE_SMALL_CAPS_PERCENTAGE_66 + HANDLE_SMALL_CAPS_PERCENTAGE_66, + HANDLE_TAB_OVERFLOW }; MasterPropertySetInfo * lcl_createSettingsInfo() @@ -182,6 +183,7 @@ MasterPropertySetInfo * lcl_createSettingsInfo() { RTL_CONSTASCII_STRINGPARAM("InvertBorderSpacing"), HANDLE_INVERT_BORDER_SPACING, CPPUTYPE_BOOLEAN, 0, 0}, { RTL_CONSTASCII_STRINGPARAM("CollapseEmptyCellPara"), HANDLE_COLLAPSE_EMPTY_CELL_PARA, CPPUTYPE_BOOLEAN, 0, 0}, { RTL_CONSTASCII_STRINGPARAM("SmallCapsPercentage66"), HANDLE_SMALL_CAPS_PERCENTAGE_66, CPPUTYPE_BOOLEAN, 0, 0}, + { RTL_CONSTASCII_STRINGPARAM("TabOverflow"), HANDLE_TAB_OVERFLOW, CPPUTYPE_BOOLEAN, 0, 0}, /* * As OS said, we don't have a view when we need to set this, so I have to * find another solution before adding them to this property set - MTG @@ -709,6 +711,12 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf mpDoc->set(IDocumentSettingAccess::SMALL_CAPS_PERCENTAGE_66, bTmp); } break; + case HANDLE_TAB_OVERFLOW: + { + sal_Bool bTmp = *(sal_Bool*)rValue.getValue(); + mpDoc->set(IDocumentSettingAccess::TAB_OVERFLOW, bTmp); + } + break; default: throw UnknownPropertyException(); } @@ -1059,6 +1067,12 @@ void SwXDocumentSettings::_getSingleValue( const comphelper::PropertyInfo & rInf rValue.setValue( &bTmp, ::getBooleanCppuType() ); } break; + case HANDLE_TAB_OVERFLOW: + { + sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::TAB_OVERFLOW ); + rValue.setValue( &bTmp, ::getBooleanCppuType() ); + } + break; default: throw UnknownPropertyException(); } -- cgit From 8c0847593abd84d4f6c2bcf8f243202ae876dc57 Mon Sep 17 00:00:00 2001 From: Cédric Bosdonnat Date: Wed, 2 Nov 2011 14:41:05 +0100 Subject: n#715115: WW8 numbering levels: use the WW6 indent if legacy flag is set --- sw/source/filter/ww8/ww8par3.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx index 1b38b33ead64..cb01a45ed91a 100644 --- a/sw/source/filter/ww8/ww8par3.cxx +++ b/sw/source/filter/ww8/ww8par3.cxx @@ -906,7 +906,10 @@ bool WW8ListManager::ReadLVL(SwNumFmt& rNumFmt, SfxItemSet*& rpItemSet, { rNumFmt.SetIndentAt( aLVL.nDxaLeft ); rNumFmt.SetFirstLineIndent(aLVL.nDxaLeft1); - rNumFmt.SetListtabPos( nTabPos ); + if ( !aLVL.bV6 ) + rNumFmt.SetListtabPos( nTabPos ); + else + rNumFmt.SetListtabPos( aLVL.nV6Indent ); SvxNumberFormat::SvxNumLabelFollowedBy eNumLabelFollowedBy = SvxNumberFormat::LISTTAB; switch ( ixchFollow ) { -- cgit From 0c9d2b9cb3f1b5bac034ccfee0eb83aa2182f2cf Mon Sep 17 00:00:00 2001 From: Joseph Powers Date: Wed, 2 Nov 2011 06:39:08 -0700 Subject: precompiled_cli_ure.hxx is empty, so just remove it --- cli_ure/inc/pch/precompiled_cli_ure.cxx | 31 ------------------------ cli_ure/inc/pch/precompiled_cli_ure.hxx | 34 --------------------------- cli_ure/source/climaker/climaker_app.cxx | 3 --- cli_ure/source/climaker/climaker_emit.cxx | 3 --- cli_ure/source/native/assembly.cxx | 3 --- cli_ure/source/uno_bridge/cli_bridge.cxx | 3 --- cli_ure/source/uno_bridge/cli_data.cxx | 3 --- cli_ure/source/uno_bridge/cli_environment.cxx | 3 --- cli_ure/source/uno_bridge/cli_proxy.cxx | 2 -- cli_ure/source/uno_bridge/cli_uno.cxx | 3 --- 10 files changed, 88 deletions(-) delete mode 100644 cli_ure/inc/pch/precompiled_cli_ure.cxx delete mode 100644 cli_ure/inc/pch/precompiled_cli_ure.hxx diff --git a/cli_ure/inc/pch/precompiled_cli_ure.cxx b/cli_ure/inc/pch/precompiled_cli_ure.cxx deleted file mode 100644 index e11d2045be2d..000000000000 --- a/cli_ure/inc/pch/precompiled_cli_ure.cxx +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "precompiled_cli_ure.hxx" - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cli_ure/inc/pch/precompiled_cli_ure.hxx b/cli_ure/inc/pch/precompiled_cli_ure.hxx deleted file mode 100644 index 59c8eb0fd6a9..000000000000 --- a/cli_ure/inc/pch/precompiled_cli_ure.hxx +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): Generated on 2006-09-01 17:49:33.514782 - -#ifdef PRECOMPILED_HEADERS -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cli_ure/source/climaker/climaker_app.cxx b/cli_ure/source/climaker/climaker_app.cxx index 3d34498c0f2f..b7f5db1de782 100644 --- a/cli_ure/source/climaker/climaker_app.cxx +++ b/cli_ure/source/climaker/climaker_app.cxx @@ -26,9 +26,6 @@ * ************************************************************************/ -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_cli_ure.hxx" - #include #include #include diff --git a/cli_ure/source/climaker/climaker_emit.cxx b/cli_ure/source/climaker/climaker_emit.cxx index 5415d8f3342b..d7d20e405f9b 100644 --- a/cli_ure/source/climaker/climaker_emit.cxx +++ b/cli_ure/source/climaker/climaker_emit.cxx @@ -26,9 +26,6 @@ * ************************************************************************/ -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_cli_ure.hxx" - #include "climaker_share.h" #include "rtl/string.hxx" diff --git a/cli_ure/source/native/assembly.cxx b/cli_ure/source/native/assembly.cxx index 5efc4af891fc..e15bd8c245a0 100644 --- a/cli_ure/source/native/assembly.cxx +++ b/cli_ure/source/native/assembly.cxx @@ -26,9 +26,6 @@ * ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_cli_ure.hxx" #using [assembly:System::Reflection::AssemblyProduct( "CLI-UNO Language Binding" )]; diff --git a/cli_ure/source/uno_bridge/cli_bridge.cxx b/cli_ure/source/uno_bridge/cli_bridge.cxx index 6f6f16978864..dd3f03ef8e26 100644 --- a/cli_ure/source/uno_bridge/cli_bridge.cxx +++ b/cli_ure/source/uno_bridge/cli_bridge.cxx @@ -26,9 +26,6 @@ * ************************************************************************/ -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_cli_ure.hxx" - #include //ToDo: remove when build with .NET 2 #pragma warning(push, 1) diff --git a/cli_ure/source/uno_bridge/cli_data.cxx b/cli_ure/source/uno_bridge/cli_data.cxx index 30dce98d5332..a8a7efabc391 100644 --- a/cli_ure/source/uno_bridge/cli_data.cxx +++ b/cli_ure/source/uno_bridge/cli_data.cxx @@ -26,9 +26,6 @@ * ************************************************************************/ -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_cli_ure.hxx" - #pragma warning(push, 1) #include "windows.h" #pragma warning(pop) diff --git a/cli_ure/source/uno_bridge/cli_environment.cxx b/cli_ure/source/uno_bridge/cli_environment.cxx index 213cfc9ae5dd..87f7286635cd 100644 --- a/cli_ure/source/uno_bridge/cli_environment.cxx +++ b/cli_ure/source/uno_bridge/cli_environment.cxx @@ -26,9 +26,6 @@ * ************************************************************************/ -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_cli_ure.hxx" - #include "Cli_environment.h" #using diff --git a/cli_ure/source/uno_bridge/cli_proxy.cxx b/cli_ure/source/uno_bridge/cli_proxy.cxx index eedd20d5df5f..9be5afe2e7da 100644 --- a/cli_ure/source/uno_bridge/cli_proxy.cxx +++ b/cli_ure/source/uno_bridge/cli_proxy.cxx @@ -26,8 +26,6 @@ * ************************************************************************/ -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_cli_ure.hxx" #include "typelib/typedescription.h" #include "rtl/ustrbuf.hxx" #include "com/sun/star/uno/RuntimeException.hpp" diff --git a/cli_ure/source/uno_bridge/cli_uno.cxx b/cli_ure/source/uno_bridge/cli_uno.cxx index 3e5b709bd313..a40065cb53c9 100644 --- a/cli_ure/source/uno_bridge/cli_uno.cxx +++ b/cli_ure/source/uno_bridge/cli_uno.cxx @@ -26,9 +26,6 @@ * ************************************************************************/ -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_cli_ure.hxx" - #include #include "rtl/ustrbuf.hxx" #include "cli_base.h" -- cgit From 12402e2cfdacf9a77af390e51ce12a4a6025f286 Mon Sep 17 00:00:00 2001 From: Matt Pratt Date: Tue, 1 Nov 2011 22:47:33 -0600 Subject: Resolves: #i46785# Word count dialog modeless --- sw/Library_sw.mk | 1 + sw/inc/swabstdlg.hxx | 12 ++++-- sw/source/ui/app/swmodule.cxx | 2 + sw/source/ui/dialog/swdlgfact.cxx | 45 ++++++++++++++++------ sw/source/ui/dialog/swdlgfact.hxx | 15 +++++--- sw/source/ui/dialog/wordcountdialog.cxx | 56 +++++++++++++++++++++++++++- sw/source/ui/dialog/wordcountdialog.hrc | 1 + sw/source/ui/dialog/wordcountdialog.src | 12 +++++- sw/source/ui/dialog/wordcountwrapper.cxx | 64 ++++++++++++++++++++++++++++++++ sw/source/ui/docvw/edtwin.cxx | 16 ++++++++ sw/source/ui/inc/wordcountdialog.hxx | 38 ++++++++++++++++++- sw/source/ui/shells/annotsh.cxx | 23 ++++-------- sw/source/ui/shells/drawsh.cxx | 22 ++++------- sw/source/ui/shells/drwtxtex.cxx | 22 ++++------- sw/source/ui/shells/frmsh.cxx | 22 ++++------- sw/source/ui/shells/textsh.cxx | 1 + sw/source/ui/shells/textsh1.cxx | 24 +++++------- 17 files changed, 280 insertions(+), 96 deletions(-) create mode 100644 sw/source/ui/dialog/wordcountwrapper.cxx diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk index b2ce776cd635..a8ee38387d4b 100644 --- a/sw/Library_sw.mk +++ b/sw/Library_sw.mk @@ -615,6 +615,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\ sw/source/ui/frmdlg/frmmgr \ sw/source/ui/globdoc/globdoc \ sw/source/ui/index/idxmrk \ + sw/source/ui/dialog/wordcountwrapper \ sw/source/ui/index/toxmgr \ sw/source/ui/lingu/hhcwrp \ sw/source/ui/lingu/hyp \ diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx index 9a685db6b506..2c6045ca1e87 100644 --- a/sw/inc/swabstdlg.hxx +++ b/sw/inc/swabstdlg.hxx @@ -200,10 +200,11 @@ public: virtual void SetSectionData(SwSectionData const& rSect) = 0; }; -class AbstractSwWordCountDialog : public VclAbstractDialog +class AbstractSwWordCountFloatDlg : public VclAbstractDialog { public: - virtual void SetValues(const SwDocStat& rCurrent, const SwDocStat& rDoc) = 0; + virtual void UpdateCounts() = 0; + virtual Window * GetWindow() = 0; //this method is added for return a Window type pointer }; class AbstractSwInsertAbstractDlg : public VclAbstractDialog // add for SwInsertAbstractDlg @@ -353,7 +354,12 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _rxFrame, sal_uInt32 nResId ) = 0; - virtual AbstractSwWordCountDialog* CreateSwWordCountDialog( Window* pWindow ) = 0; + virtual AbstractSwWordCountFloatDlg* CreateSwWordCountDialog(int nResId, + SfxBindings* pBindings, + SfxChildWindow* pChild, + Window *pParent, + SfxChildWinInfo* pInfo) = 0; + virtual AbstractSwInsertAbstractDlg * CreateSwInsertAbstractDlg ( Window* pParent, int nResId) = 0; // add for SwInsertAbstractDlg virtual AbstractSwAsciiFilterDlg* CreateSwAsciiFilterDlg ( Window* pParent, SwDocShell& rDocSh, SvStream* pStream, int nResId ) = 0;// add for SwAsciiFilterDlg diff --git a/sw/source/ui/app/swmodule.cxx b/sw/source/ui/app/swmodule.cxx index 4a663622a10b..e1bdf64e8797 100644 --- a/sw/source/ui/app/swmodule.cxx +++ b/sw/source/ui/app/swmodule.cxx @@ -122,6 +122,7 @@ #include #include #include +#include #include #include #include @@ -397,6 +398,7 @@ void SwDLL::RegisterControls() SwMailMergeChildWindow::RegisterChildWindow( sal_False, pMod ); SwInsertIdxMarkWrapper::RegisterChildWindow( sal_False, pMod ); SwInsertAuthMarkWrapper::RegisterChildWindow( sal_False, pMod ); + SwWordCountWrapper::RegisterChildWindow( sal_False, pMod ); SvxRubyChildWindow::RegisterChildWindow( sal_False, pMod); SwSpellDialogChildWindow::RegisterChildWindow(sal_False, pMod); diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx index 03b5b0c3978a..a46d03b57528 100644 --- a/sw/source/ui/dialog/swdlgfact.cxx +++ b/sw/source/ui/dialog/swdlgfact.cxx @@ -112,7 +112,7 @@ using namespace ::com::sun::star; -IMPL_ABSTDLG_BASE(AbstractSwWordCountDialog_Impl); +IMPL_ABSTDLG_BASE(AbstractSwWordCountFloatDlg_Impl); IMPL_ABSTDLG_BASE(AbstractSwInsertAbstractDlg_Impl); IMPL_ABSTDLG_BASE(AbstractSfxDialog_Impl); IMPL_ABSTDLG_BASE(AbstractSwAsciiFilterDlg_Impl); @@ -175,11 +175,6 @@ String AbstractTabDialog_Impl::GetText() const return pDlg->GetText(); } -void AbstractSwWordCountDialog_Impl::SetValues(const SwDocStat& rCurrent, const SwDocStat& rDoc) -{ - pDlg->SetValues(rCurrent, rDoc); -} - sal_uInt8 AbstractSwInsertAbstractDlg_Impl::GetLevel() const { return pDlg->GetLevel(); @@ -572,6 +567,18 @@ Window* AbstractAuthMarkFloatDlg_Impl::GetWindow() return (Window*)pDlg; } + +Window* AbstractSwWordCountFloatDlg_Impl::GetWindow() +{ + return (Window*)pDlg; +} + +void AbstractSwWordCountFloatDlg_Impl::UpdateCounts() +{ + pDlg->UpdateCounts(); +} + + AbstractMailMergeWizard_Impl::~AbstractMailMergeWizard_Impl() { delete pDlg; @@ -624,12 +631,6 @@ sal_uInt16 AbstractMailMergeWizard_Impl::GetRestartPage() const return pDlg->GetRestartPage(); } -AbstractSwWordCountDialog* SwAbstractDialogFactory_Impl::CreateSwWordCountDialog(Window* pParent) -{ - SwWordCountDialog* pDlg = new SwWordCountDialog( pParent ); - return new AbstractSwWordCountDialog_Impl( pDlg ); -} - AbstractSwInsertAbstractDlg * SwAbstractDialogFactory_Impl::CreateSwInsertAbstractDlg( Window* pParent, int nResId ) { @@ -1546,6 +1547,26 @@ AbstractMarkFloatDlg * SwAbstractDialogFactory_Impl::CreateAuthMarkFloatDlg( int return 0; } +AbstractSwWordCountFloatDlg * SwAbstractDialogFactory_Impl::CreateSwWordCountDialog( int nResId, + SfxBindings* pBindings, + SfxChildWindow* pChild, + Window *pParent, + SfxChildWinInfo* pInfo ) +{ + SwWordCountFloatDlg* pDlg=NULL; + switch ( nResId ) + { + case DLG_WORDCOUNT : + pDlg = new SwWordCountFloatDlg( pBindings, pChild, pParent, pInfo ); + break; + default: + break; + } + if ( pDlg ) + return new AbstractSwWordCountFloatDlg_Impl( pDlg ); + return 0; +} + //add for SwIndexMarkModalDlg begin VclAbstractDialog * SwAbstractDialogFactory_Impl::CreateIndexMarkModalDlg( int nResId, Window *pParent, SwWrtShell& rSh, SwTOXMark* pCurTOXMark ) //add for SwIndexMarkModalDlg diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx index b4ee0910b7e8..66ee0aba9167 100644 --- a/sw/source/ui/dialog/swdlgfact.hxx +++ b/sw/source/ui/dialog/swdlgfact.hxx @@ -76,11 +76,12 @@ short Class::Execute() \ return pDlg->Execute(); \ } - -class AbstractSwWordCountDialog_Impl : public AbstractSwWordCountDialog +class SwWordCountFloatDlg; +class AbstractSwWordCountFloatDlg_Impl : public AbstractSwWordCountFloatDlg { - DECL_ABSTDLG_BASE(AbstractSwWordCountDialog_Impl,SwWordCountDialog) - void SetValues(const SwDocStat& rCurrent, const SwDocStat& rDoc); + DECL_ABSTDLG_BASE(AbstractSwWordCountFloatDlg_Impl,SwWordCountFloatDlg) + virtual void UpdateCounts(); + virtual Window * GetWindow(); //this method is added for return a Window type pointer }; //add for SwInsertAbstractDlg begin @@ -437,7 +438,11 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _rxFrame, sal_uInt32 nResId ); - virtual AbstractSwWordCountDialog* CreateSwWordCountDialog(Window* pParent); + virtual AbstractSwWordCountFloatDlg* CreateSwWordCountDialog(int nResId, + SfxBindings* pBindings, + SfxChildWindow* pChild, + Window *pParent, + SfxChildWinInfo* pInfo); virtual AbstractSwInsertAbstractDlg * CreateSwInsertAbstractDlg( Window* pParent,int nResId ); virtual AbstractSwAsciiFilterDlg* CreateSwAsciiFilterDlg ( Window* pParent, SwDocShell& rDocSh, SvStream* pStream, int nResId ); //add for SwAsciiFilterDlg diff --git a/sw/source/ui/dialog/wordcountdialog.cxx b/sw/source/ui/dialog/wordcountdialog.cxx index 4a98a4e19294..2ff37eda90b9 100644 --- a/sw/source/ui/dialog/wordcountdialog.cxx +++ b/sw/source/ui/dialog/wordcountdialog.cxx @@ -34,10 +34,16 @@ #include #include #include - #include #include #include +#include +#include "vcl/msgbox.hxx" // RET_CANCEL +#include +#include +#include +#include +#include #if ENABLE_LAYOUT #undef SW_RES @@ -49,7 +55,7 @@ #endif /* ENABLE_LAYOUT */ SwWordCountDialog::SwWordCountDialog(Window* pParent) : - SfxModalDialog(pParent, SW_RES(DLG_WORDCOUNT)), + Window(pParent, SW_RES(WINDOW_DLG)), #if defined _MSC_VER #pragma warning (disable : 4355) #endif @@ -79,10 +85,23 @@ SwWordCountDialog::SwWordCountDialog(Window* pParent) : SetHelpId (HID_DLG_WORDCOUNT); #endif /* ENABLE_LAYOUT */ FreeResource(); + + aOK.SetClickHdl(LINK(this,SwWordCountDialog, OkHdl)); +} + +IMPL_LINK( SwWordCountDialog, OkHdl, void*, EMPTYARG ) +{ + SfxViewFrame* pVFrame = ::GetActiveView()->GetViewFrame(); + if (pVFrame != NULL) + { + pVFrame->ToggleChildWindow(FN_WORDCOUNT_DIALOG); + } + return 0; } SwWordCountDialog::~SwWordCountDialog() { + ViewShell::SetCareWin( 0 ); } void SwWordCountDialog::SetValues(const SwDocStat& rCurrent, const SwDocStat& rDoc) @@ -95,4 +114,37 @@ void SwWordCountDialog::SetValues(const SwDocStat& rCurrent, const SwDocStat& r aDocCharacterExcludingSpacesFI.SetText( String::CreateFromInt32(rDoc.nCharExcludingSpaces )); } + +SwWordCountFloatDlg::SwWordCountFloatDlg(SfxBindings* _pBindings, + SfxChildWindow* pChild, + Window *pParent, + SfxChildWinInfo* pInfo) + : SfxModelessDialog(_pBindings, pChild, pParent, SW_RES(DLG_WORDCOUNT)), + aDlg(this) +{ + FreeResource(); + Initialize(pInfo); +} + +void SwWordCountFloatDlg::Activate() +{ + SfxModelessDialog::Activate(); + aDlg.Activate(); +} + +void SwWordCountFloatDlg::UpdateCounts() +{ + SwWrtShell &rSh = ::GetActiveView()->GetWrtShell(); + SwDocStat aCurrCnt; + SwDocStat aDocStat; + { + SwWait aWait( *::GetActiveView()->GetDocShell(), sal_True ); + rSh.StartAction(); + rSh.CountWords( aCurrCnt ); + aDocStat = rSh.GetUpdatedDocStat(); + rSh.EndAction(); + } + aDlg.SetValues(aCurrCnt, aDocStat); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/dialog/wordcountdialog.hrc b/sw/source/ui/dialog/wordcountdialog.hrc index af6f3a79c76c..0db5c87b970f 100644 --- a/sw/source/ui/dialog/wordcountdialog.hrc +++ b/sw/source/ui/dialog/wordcountdialog.hrc @@ -43,5 +43,6 @@ #define FL_BOTTOM 15 #define PB_OK 16 #define PB_HELP 17 +#define WINDOW_DLG 18 #endif diff --git a/sw/source/ui/dialog/wordcountdialog.src b/sw/source/ui/dialog/wordcountdialog.src index 767913a0e5c9..a324c45d4d2b 100644 --- a/sw/source/ui/dialog/wordcountdialog.src +++ b/sw/source/ui/dialog/wordcountdialog.src @@ -27,7 +27,7 @@ #include #include #include -ModalDialog DLG_WORDCOUNT +ModelessDialog DLG_WORDCOUNT { HelpID = HID_DLG_WORDCOUNT ; OutputSize = TRUE ; @@ -36,6 +36,15 @@ ModalDialog DLG_WORDCOUNT Text [ en-US ] = "Word Count" ; Moveable = TRUE ; + Closeable = TRUE; + Sizeable = FALSE ; + Hide = TRUE ; + + Window WINDOW_DLG + { + Pos = MAP_APPFONT ( 0 , 0 ) ; + Size = MAP_APPFONT ( 170 , 132 ) ; + FixedLine FL_CURRENT { Pos = MAP_APPFONT ( 6 , 3 ) ; @@ -136,4 +145,5 @@ ModalDialog DLG_WORDCOUNT Pos = MAP_APPFONT ( 114 , 112 ) ; Size = MAP_APPFONT ( 50 , 14 ) ; }; + }; }; diff --git a/sw/source/ui/dialog/wordcountwrapper.cxx b/sw/source/ui/dialog/wordcountwrapper.cxx new file mode 100644 index 000000000000..764f9f9f910c --- /dev/null +++ b/sw/source/ui/dialog/wordcountwrapper.cxx @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Initial Developer of the Original Code is + * Matt Pratt + * Portions created by the Initial Developer are Copyright (C) 2011 the + * Initial Developer. All Rights Reserved. + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 3 or later (the "GPLv3+"), or + * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), + * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable + * instead of those above. + */ +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sw.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include + +SFX_IMPL_CHILDWINDOW(SwWordCountWrapper, FN_WORDCOUNT_DIALOG) + +SwWordCountWrapper::SwWordCountWrapper( Window *pParentWindow, + sal_uInt16 nId, + SfxBindings* pBindings, + SfxChildWinInfo* pInfo ) : + SfxChildWindow(pParentWindow, nId) +{ + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!"); + pAbstDlg = pFact->CreateSwWordCountDialog( DLG_WORDCOUNT, pBindings, this, pParentWindow, pInfo ); + OSL_ENSURE(pAbstDlg, "Dialog contruction faiedl!"); + pWindow = pAbstDlg->GetWindow(); + + eChildAlignment = SFX_ALIGN_NOALIGNMENT; +} + +SfxChildWinInfo SwWordCountWrapper::GetInfo() const +{ + SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); + return aInfo; +} + +void SwWordCountWrapper::UpdateCounts() +{ + pAbstDlg->UpdateCounts(); +} diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx index 05991767b88c..f18433c4b929 100644 --- a/sw/source/ui/docvw/edtwin.cxx +++ b/sw/source/ui/docvw/edtwin.cxx @@ -134,6 +134,9 @@ #include "formatclipboard.hxx" #include #include +#include +#include +#include #include #include @@ -2602,6 +2605,12 @@ KEYINPUT_CHECKTABLE_INSDEL: ShowAutoTextCorrectQuickHelp(sWord, pACfg, pACorr); } } + + // get the word count dialog to update itself + SwWordCountWrapper *pWrdCnt = (SwWordCountWrapper*)GetView().GetViewFrame()->GetChildWindow(SwWordCountWrapper::GetChildWindowId()); + if (pWrdCnt) + pWrdCnt->UpdateCounts(); + } /*-------------------------------------------------------------------- @@ -3668,6 +3677,13 @@ void SwEditWin::MouseMove(const MouseEvent& _rMEvt) } return; } + + { + SwWordCountWrapper *pWrdCnt = (SwWordCountWrapper*)GetView().GetViewFrame()->GetChildWindow(SwWordCountWrapper::GetChildWindowId()); + if (pWrdCnt) + pWrdCnt->UpdateCounts(); + } + case MOUSE_LEFT + KEY_SHIFT: case MOUSE_LEFT + KEY_SHIFT + KEY_MOD1: if ( !bMBPressed ) diff --git a/sw/source/ui/inc/wordcountdialog.hxx b/sw/source/ui/inc/wordcountdialog.hxx index 5c6dbabea04f..d4c996cba40e 100644 --- a/sw/source/ui/inc/wordcountdialog.hxx +++ b/sw/source/ui/inc/wordcountdialog.hxx @@ -33,7 +33,12 @@ #include #include struct SwDocStat; -class SwWordCountDialog : public SfxModalDialog +#include +#include "swabstdlg.hxx" + +class SwWrtShell; + +class SwWordCountDialog : public Window { FixedLine aCurrentFL; FixedText aCurrentWordFT; @@ -56,11 +61,42 @@ class SwWordCountDialog : public SfxModalDialog OKButton aOK; HelpButton aHelp; + void InitControls(); + public: SwWordCountDialog(Window* pParent); ~SwWordCountDialog(); void SetValues(const SwDocStat& rCurrent, const SwDocStat& rDoc); + + SW_DLLPRIVATE DECL_LINK( OkHdl, void* ); +}; + +class SwWordCountFloatDlg : public SfxModelessDialog +{ + SwWordCountDialog aDlg; + virtual void Activate(); + public: + SwWordCountFloatDlg( SfxBindings* pBindings, + SfxChildWindow* pChild, + Window *pParent, + SfxChildWinInfo* pInfo); + void UpdateCounts(); +}; + +class SwWordCountWrapper : public SfxChildWindow +{ + AbstractSwWordCountFloatDlg* pAbstDlg; +protected: + SwWordCountWrapper( Window *pParentWindow, + sal_uInt16 nId, + SfxBindings* pBindings, + SfxChildWinInfo* pInfo ); + + SFX_DECL_CHILDWINDOW(SwWordCountWrapper); + +public: + void UpdateCounts(); }; #include diff --git a/sw/source/ui/shells/annotsh.cxx b/sw/source/ui/shells/annotsh.cxx index 8b03568dac8e..cf38a168e88e 100644 --- a/sw/source/ui/shells/annotsh.cxx +++ b/sw/source/ui/shells/annotsh.cxx @@ -410,23 +410,16 @@ void SwAnnotationShell::Exec( SfxRequest &rReq ) break; case FN_WORDCOUNT_DIALOG: { - SwWrtShell &rSh = rView.GetWrtShell(); - SwDocStat aCurr; - SwDocStat aDocStat; + SfxViewFrame* pVFrame = GetView().GetViewFrame(); + if (pVFrame != NULL) { - SwWait aWait( *rView.GetDocShell(), sal_True ); - rSh.StartAction(); - rSh.CountWords( aCurr ); - aDocStat = rSh.GetUpdatedDocStat(); - rSh.EndAction(); - } + pVFrame->ToggleChildWindow(FN_WORDCOUNT_DIALOG); + Invalidate(rReq.GetSlot()); - SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); - OSL_ENSURE(pFact, "Dialogdiet fail!"); - AbstractSwWordCountDialog* pDialog = pFact->CreateSwWordCountDialog( rView.GetWindow() ); - pDialog->SetValues(aCurr, aDocStat ); - pDialog->Execute(); - delete pDialog; + SwWordCountWrapper *pWrdCnt = (SwWordCountWrapper*)pVFrame->GetChildWindow(SwWordCountWrapper::GetChildWindowId()); + if (pWrdCnt) + pWrdCnt->UpdateCounts(); + } } break; case SID_CHAR_DLG: diff --git a/sw/source/ui/shells/drawsh.cxx b/sw/source/ui/shells/drawsh.cxx index 695dddc69013..7dc94e01aefc 100644 --- a/sw/source/ui/shells/drawsh.cxx +++ b/sw/source/ui/shells/drawsh.cxx @@ -232,22 +232,16 @@ void SwDrawShell::Execute(SfxRequest &rReq) break; case FN_WORDCOUNT_DIALOG: { - SwDocStat aCurr; - SwDocStat aDocStat; + SfxViewFrame* pVFrame = GetView().GetViewFrame(); + if (pVFrame != NULL) { - SwWait aWait( *GetView().GetDocShell(), sal_True ); - rSh.StartAction(); - rSh.CountWords( aCurr ); - aDocStat = rSh.GetUpdatedDocStat(); - rSh.EndAction(); - } + pVFrame->ToggleChildWindow(FN_WORDCOUNT_DIALOG); + Invalidate(rReq.GetSlot()); - SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); - OSL_ENSURE(pFact, "Dialogdiet fail!"); - AbstractSwWordCountDialog* pDialog = pFact->CreateSwWordCountDialog( GetView().GetWindow() ); - pDialog->SetValues(aCurr, aDocStat ); - pDialog->Execute(); - delete pDialog; + SwWordCountWrapper *pWrdCnt = (SwWordCountWrapper*)pVFrame->GetChildWindow(SwWordCountWrapper::GetChildWindowId()); + if (pWrdCnt) + pWrdCnt->UpdateCounts(); + } } break; case SID_EXTRUSION_TOOGLE: diff --git a/sw/source/ui/shells/drwtxtex.cxx b/sw/source/ui/shells/drwtxtex.cxx index 47a6b1a6caf2..b21da6dd7333 100644 --- a/sw/source/ui/shells/drwtxtex.cxx +++ b/sw/source/ui/shells/drwtxtex.cxx @@ -346,22 +346,16 @@ void SwDrawTextShell::Execute( SfxRequest &rReq ) break; case FN_WORDCOUNT_DIALOG: { - SwDocStat aCurr; - SwDocStat aDocStat; + SfxViewFrame* pVFrame = GetView().GetViewFrame(); + if (pVFrame != NULL) { - SwWait aWait( *GetView().GetDocShell(), sal_True ); - rSh.StartAction(); - rSh.CountWords( aCurr ); - aDocStat = rSh.GetUpdatedDocStat(); - rSh.EndAction(); - } + pVFrame->ToggleChildWindow(FN_WORDCOUNT_DIALOG); + Invalidate(rReq.GetSlot()); - SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); - OSL_ENSURE(pFact, "Dialogdiet fail!"); - AbstractSwWordCountDialog* pDialog = pFact->CreateSwWordCountDialog( GetView().GetWindow() ); - pDialog->SetValues(aCurr, aDocStat ); - pDialog->Execute(); - delete pDialog; + SwWordCountWrapper *pWrdCnt = (SwWordCountWrapper*)pVFrame->GetChildWindow(SwWordCountWrapper::GetChildWindowId()); + if (pWrdCnt) + pWrdCnt->UpdateCounts(); + } } break; case SID_PARA_DLG: diff --git a/sw/source/ui/shells/frmsh.cxx b/sw/source/ui/shells/frmsh.cxx index ce35e494febc..6eb2ea712bc5 100644 --- a/sw/source/ui/shells/frmsh.cxx +++ b/sw/source/ui/shells/frmsh.cxx @@ -418,22 +418,16 @@ void SwFrameShell::Execute(SfxRequest &rReq) break; case FN_WORDCOUNT_DIALOG: { - SwDocStat aCurr; - SwDocStat aDocStat; + SfxViewFrame* pVFrame = GetView().GetViewFrame(); + if (pVFrame != NULL) { - SwWait aWait( *GetView().GetDocShell(), sal_True ); - rSh.StartAction(); - rSh.CountWords( aCurr ); - aDocStat = rSh.GetUpdatedDocStat(); - rSh.EndAction(); - } + pVFrame->ToggleChildWindow(FN_WORDCOUNT_DIALOG); + Invalidate(rReq.GetSlot()); - SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); - OSL_ENSURE(pFact, "Dialogdiet fail!"); - AbstractSwWordCountDialog* pDialog = pFact->CreateSwWordCountDialog( GetView().GetWindow() ); - pDialog->SetValues(aCurr, aDocStat ); - pDialog->Execute(); - delete pDialog; + SwWordCountWrapper *pWrdCnt = (SwWordCountWrapper*)pVFrame->GetChildWindow(SwWordCountWrapper::GetChildWindowId()); + if (pWrdCnt) + pWrdCnt->UpdateCounts(); + } } break; default: bMore = sal_True; diff --git a/sw/source/ui/shells/textsh.cxx b/sw/source/ui/shells/textsh.cxx index 5835e5c169b4..f379a6118d38 100644 --- a/sw/source/ui/shells/textsh.cxx +++ b/sw/source/ui/shells/textsh.cxx @@ -137,6 +137,7 @@ SFX_IMPL_INTERFACE(SwTextShell, SwBaseShell, SW_RES(STR_SHELLNAME_TEXT)) SFX_CHILDWINDOW_REGISTRATION(FN_INSERT_IDX_ENTRY_DLG); SFX_CHILDWINDOW_REGISTRATION(FN_INSERT_AUTH_ENTRY_DLG); SFX_CHILDWINDOW_REGISTRATION(SID_RUBY_DIALOG); + SFX_CHILDWINDOW_REGISTRATION(FN_WORDCOUNT_DIALOG); } TYPEINIT1(SwTextShell,SwBaseShell) diff --git a/sw/source/ui/shells/textsh1.cxx b/sw/source/ui/shells/textsh1.cxx index 9fdb4b46a907..aeda86e135e7 100644 --- a/sw/source/ui/shells/textsh1.cxx +++ b/sw/source/ui/shells/textsh1.cxx @@ -124,6 +124,7 @@ #include #include #include +#include using namespace ::com::sun::star; @@ -1287,23 +1288,16 @@ void SwTextShell::Execute(SfxRequest &rReq) break; case FN_WORDCOUNT_DIALOG: { - SwWrtShell &rSh = GetShell(); - SwDocStat aCurr; - SwDocStat aDocStat; + SfxViewFrame* pVFrame = GetView().GetViewFrame(); + if (pVFrame != NULL) { - SwWait aWait( *GetView().GetDocShell(), sal_True ); - rSh.StartAction(); - rSh.CountWords( aCurr ); - aDocStat = rSh.GetUpdatedDocStat(); - rSh.EndAction(); - } + pVFrame->ToggleChildWindow(FN_WORDCOUNT_DIALOG); + Invalidate(rReq.GetSlot()); - SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); - OSL_ENSURE(pFact, "Dialogdiet fail!"); - AbstractSwWordCountDialog* pDialog = pFact->CreateSwWordCountDialog( GetView().GetWindow() ); - pDialog->SetValues(aCurr, aDocStat ); - pDialog->Execute(); - delete pDialog; + SwWordCountWrapper *pWrdCnt = (SwWordCountWrapper*)pVFrame->GetChildWindow(SwWordCountWrapper::GetChildWindowId()); + if (pWrdCnt) + pWrdCnt->UpdateCounts(); + } } break; default: -- cgit From 555c89db131240641cb01c7c8caa239d1621df84 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 2 Nov 2011 14:50:28 +0000 Subject: fix this to build --- sw/source/ui/dialog/wordcountwrapper.cxx | 1 - sw/source/ui/shells/annotsh.cxx | 4 +++- sw/source/ui/shells/drawsh.cxx | 1 + sw/source/ui/shells/drwtxtex.cxx | 1 + sw/source/ui/shells/frmsh.cxx | 2 ++ 5 files changed, 7 insertions(+), 2 deletions(-) diff --git a/sw/source/ui/dialog/wordcountwrapper.cxx b/sw/source/ui/dialog/wordcountwrapper.cxx index 764f9f9f910c..ddecf5a0e96c 100644 --- a/sw/source/ui/dialog/wordcountwrapper.cxx +++ b/sw/source/ui/dialog/wordcountwrapper.cxx @@ -32,7 +32,6 @@ #include #include #include -#include #include SFX_IMPL_CHILDWINDOW(SwWordCountWrapper, FN_WORDCOUNT_DIALOG) diff --git a/sw/source/ui/shells/annotsh.cxx b/sw/source/ui/shells/annotsh.cxx index cf38a168e88e..6aada30c4655 100644 --- a/sw/source/ui/shells/annotsh.cxx +++ b/sw/source/ui/shells/annotsh.cxx @@ -131,6 +131,8 @@ #include +#include + using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; @@ -410,7 +412,7 @@ void SwAnnotationShell::Exec( SfxRequest &rReq ) break; case FN_WORDCOUNT_DIALOG: { - SfxViewFrame* pVFrame = GetView().GetViewFrame(); + SfxViewFrame* pVFrame = rView.GetViewFrame(); if (pVFrame != NULL) { pVFrame->ToggleChildWindow(FN_WORDCOUNT_DIALOG); diff --git a/sw/source/ui/shells/drawsh.cxx b/sw/source/ui/shells/drawsh.cxx index 7dc94e01aefc..56e0a42515e7 100644 --- a/sw/source/ui/shells/drawsh.cxx +++ b/sw/source/ui/shells/drawsh.cxx @@ -70,6 +70,7 @@ #include #include "swslots.hxx" #include "swabstdlg.hxx" +#include #include "misc.hrc" using namespace ::com::sun::star; diff --git a/sw/source/ui/shells/drwtxtex.cxx b/sw/source/ui/shells/drwtxtex.cxx index b21da6dd7333..dcbdd6f5f5d2 100644 --- a/sw/source/ui/shells/drwtxtex.cxx +++ b/sw/source/ui/shells/drwtxtex.cxx @@ -101,6 +101,7 @@ #include #include #include +#include #include "swabstdlg.hxx" #include "chrdlg.hrc" diff --git a/sw/source/ui/shells/frmsh.cxx b/sw/source/ui/shells/frmsh.cxx index 6eb2ea712bc5..12efea78a63d 100644 --- a/sw/source/ui/shells/frmsh.cxx +++ b/sw/source/ui/shells/frmsh.cxx @@ -95,6 +95,8 @@ #include #include +#include + using ::editeng::SvxBorderLine; using namespace ::com::sun::star; using namespace ::com::sun::star::uno; -- cgit From 2ab818f8e9822ff027ad6c90e7b6fb1f4c089f9f Mon Sep 17 00:00:00 2001 From: Ivan Timofeev Date: Wed, 2 Nov 2011 15:55:28 +0100 Subject: Fix i#89051: Move the point you've just inserted, not the previous one. --- svx/source/svdraw/svdmrkv.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx index becc523e27e1..9dd2e62444b5 100644 --- a/svx/source/svdraw/svdmrkv.cxx +++ b/svx/source/svdraw/svdmrkv.cxx @@ -802,12 +802,12 @@ void SdrMarkView::SetMarkHandles() // Drehpunkt/Spiegelachse AddDragModeHdl(eDragMode); - // add custom handles (used by other apps, e.g. AnchorPos) - AddCustomHdl(); - // sort handles aHdl.Sort(); + // add custom handles (used by other apps, e.g. AnchorPos) + AddCustomHdl(); + // #105722# try to restore focus handle index from remembered values if(bSaveOldFocus) { -- cgit From 208c9648ec31ccf27edddc2f5dbfd1387a445fdb Mon Sep 17 00:00:00 2001 From: Cédric Bosdonnat Date: Wed, 2 Nov 2011 16:20:46 +0100 Subject: n#693238: fixed parentheses warning --- sw/source/core/text/txttab.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sw/source/core/text/txttab.cxx b/sw/source/core/text/txttab.cxx index d237873749fc..341bde27d0c5 100644 --- a/sw/source/core/text/txttab.cxx +++ b/sw/source/core/text/txttab.cxx @@ -452,7 +452,7 @@ sal_Bool SwTabPortion::PreFormat( SwTxtFormatInfo &rInf ) // tab stop position is outside the frame: bool bAtParaEnd = rInf.GetIdx() + GetLen() == rInf.GetTxt().Len(); if ( bFull && bTabCompat && - ( bTabOverflow && ( rInf.IsTabOverflow() || !IsAutoTabStop() ) || bAtParaEnd ) && + ( ( bTabOverflow && ( rInf.IsTabOverflow() || !IsAutoTabStop() ) ) || bAtParaEnd ) && GetTabPos() >= rInf.GetTxtFrm()->Frm().Width() ) { bFull = sal_False; -- cgit From dbfa9d4f87b660251ccfe9b854e614abafcb684b Mon Sep 17 00:00:00 2001 From: Laurent Godard Date: Mon, 31 Oct 2011 17:24:49 +0100 Subject: calc big file : refactor loading to avoid unecessary tests create ScDocument::AppendTabOnLoad do not test if named ranges exist on file load --- sc/inc/document.hxx | 3 +++ sc/source/core/data/document.cxx | 11 +++++++++++ sc/source/filter/xml/xmlimprt.cxx | 3 +-- sc/source/filter/xml/xmlsubti.cxx | 18 ++---------------- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index a7ae1c3bb576..582901cc72e4 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -575,6 +575,9 @@ public: SC_DLLPUBLIC void CreateValidTabName(String& rName) const; SC_DLLPUBLIC void CreateValidTabName(rtl::OUString& rName) const; SC_DLLPUBLIC void CreateValidTabNames(std::vector& aNames, SCTAB nCount) const; + + void AppendTabOnLoad(const rtl::OUString& rName); + SC_DLLPUBLIC sal_Bool InsertTab( SCTAB nPos, const String& rName, sal_Bool bExternalDocument = false ); SC_DLLPUBLIC bool InsertTabs( SCTAB nPos, const std::vector& rNames, diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index b9526d31f272..196bc17fae9b 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -401,6 +401,17 @@ void ScDocument::CreateValidTabNames(std::vector& aNames, SCTAB n } } +void ScDocument::AppendTabOnLoad(const rtl::OUString& rName) +{ + SCTAB nTabCount = static_cast(maTabs.size()); + + if (ValidTab(nTabCount) && ValidNewTabName(rName)) + { + maTabs.push_back( new ScTable(this, nTabCount, rName) ); + maTabs[nTabCount]->SetCodeName( rName ); + } +} + sal_Bool ScDocument::InsertTab( SCTAB nPos, const String& rName, sal_Bool bExternalDocument ) diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx index 7e6d98a97615..3beef270d01d 100644 --- a/sc/source/filter/xml/xmlimprt.cxx +++ b/sc/source/filter/xml/xmlimprt.cxx @@ -2782,8 +2782,7 @@ public: if ( nUnoType & sheet::NamedRangeFlag::COLUMN_HEADER ) nNewType |= RT_COLHEADER; if ( nUnoType & sheet::NamedRangeFlag::ROW_HEADER ) nNewType |= RT_ROWHEADER; - - if (mpDoc && !mrRangeName.findByName(r.sName)) + if (mpDoc) { // Insert a new name. ScAddress aPos; diff --git a/sc/source/filter/xml/xmlsubti.cxx b/sc/source/filter/xml/xmlsubti.cxx index 12d9cad96c88..04f9a8e5daac 100644 --- a/sc/source/filter/xml/xmlsubti.cxx +++ b/sc/source/filter/xml/xmlsubti.cxx @@ -192,22 +192,8 @@ void ScMyTables::NewSheet(const rtl::OUString& sTableName, const rtl::OUString& { if (nCurrentSheet > 0) { - try - { - xSheets->insertNewByName(sTableName, nCurrentSheet); - } - catch ( uno::RuntimeException& ) - { - ScDocument *pDoc = ScXMLConverter::GetScDocument(rImport.GetModel()); - if (pDoc) - { - ScXMLImport::MutexGuard aGuard(rImport); - String sTabName(String::CreateFromAscii("Table")); - pDoc->CreateValidTabName(sTabName); - rtl::OUString sOUTabName(sTabName); - xSheets->insertNewByName(sOUTabName, nCurrentSheet); - } - } + ScDocument *pDoc = ScXMLConverter::GetScDocument(rImport.GetModel()); + pDoc->AppendTabOnLoad(sTableName); } uno::Reference xIndex( xSheets, uno::UNO_QUERY ); if ( xIndex.is() ) -- cgit From 0cbcb89fde8cc81db499bc1e388fd53ef6fa3c3f Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 2 Nov 2011 16:03:13 +0000 Subject: update word count dialog when selection is completed or invalidated --- sw/source/ui/wrtsh/select.cxx | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/sw/source/ui/wrtsh/select.cxx b/sw/source/ui/wrtsh/select.cxx index d0c10642c358..9583155aca89 100644 --- a/sw/source/ui/wrtsh/select.cxx +++ b/sw/source/ui/wrtsh/select.cxx @@ -50,6 +50,7 @@ #include #include #include +#include #if OSL_DEBUG_LEVEL > 1 #include @@ -70,6 +71,9 @@ void SwWrtShell::Invalidate() // to avoid making the slot volatile, invalidate it everytime if something could have been changed // this is still much cheaper than asking for the state every 200 ms (and avoid background processing) GetView().GetViewFrame()->GetBindings().Invalidate( FN_STAT_SELMODE ); + SwWordCountWrapper *pWrdCnt = (SwWordCountWrapper*)GetView().GetViewFrame()->GetChildWindow(SwWordCountWrapper::GetChildWindowId()); + if (pWrdCnt) + pWrdCnt->UpdateCounts(); } sal_Bool SwWrtShell::SelNearestWrd() @@ -419,14 +423,19 @@ void SwWrtShell::SttSelect() void SwWrtShell::EndSelect() { - if(!bInSelect || bExtMode) - return; - bInSelect = sal_False; - (this->*fnLeaveSelect)(0,sal_False); - if(!bAddMode) { - fnSetCrsr = &SwWrtShell::SetCrsrKillSel; - fnKillSel = &SwWrtShell::ResetSelect; + if(bInSelect && !bExtMode) + { + bInSelect = sal_False; + (this->*fnLeaveSelect)(0,sal_False); + if(!bAddMode) + { + fnSetCrsr = &SwWrtShell::SetCrsrKillSel; + fnKillSel = &SwWrtShell::ResetSelect; + } } + SwWordCountWrapper *pWrdCnt = (SwWordCountWrapper*)GetView().GetViewFrame()->GetChildWindow(SwWordCountWrapper::GetChildWindowId()); + if (pWrdCnt) + pWrdCnt->UpdateCounts(); } /* Methode, um eine bestehende wortweise oder zeilenweise Selektion * zu erweitern. -- cgit From da0bd7a50139b06e14c1917af044b37d10ebaf4f Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 2 Nov 2011 16:03:45 +0000 Subject: drop freshly unused methods --- unotools/inc/unotools/lingucfg.hxx | 1 - unotools/source/config/lingucfg.cxx | 15 --------------- vcl/inc/vcl/button.hxx | 1 - vcl/source/control/button.cxx | 6 ------ 4 files changed, 23 deletions(-) diff --git a/unotools/inc/unotools/lingucfg.hxx b/unotools/inc/unotools/lingucfg.hxx index 4ae102007dde..668cb267107b 100644 --- a/unotools/inc/unotools/lingucfg.hxx +++ b/unotools/inc/unotools/lingucfg.hxx @@ -225,7 +225,6 @@ public: std::vector< SvtLinguConfigDictionaryEntry > GetActiveDictionariesByFormat( const rtl::OUString &rFormatName ); // functions returning file URLs to the respective images (if found) and empty string otherwise - ::rtl::OUString GetSpellAndGrammarDialogImage( const ::rtl::OUString &rServiceImplName ) const; ::rtl::OUString GetSpellAndGrammarContextSuggestionImage( const ::rtl::OUString &rServiceImplName ) const; ::rtl::OUString GetSpellAndGrammarContextDictionaryImage( const ::rtl::OUString &rServiceImplName ) const; ::rtl::OUString GetThesaurusDialogImage( const ::rtl::OUString &rServiceImplName ) const; diff --git a/unotools/source/config/lingucfg.cxx b/unotools/source/config/lingucfg.cxx index cc08afdc934f..fcf9f7653c30 100644 --- a/unotools/source/config/lingucfg.cxx +++ b/unotools/source/config/lingucfg.cxx @@ -1253,21 +1253,6 @@ rtl::OUString SvtLinguConfig::GetVendorImageUrl_Impl( } -rtl::OUString SvtLinguConfig::GetSpellAndGrammarDialogImage( - const rtl::OUString &rServiceImplName -) const -{ - rtl::OUString aRes; - if (rServiceImplName.getLength() > 0) - { - rtl::OUString aImageName( A2OU( "SpellAndGrammarDialogImage" )); - rtl::OUString aPath( GetVendorImageUrl_Impl( rServiceImplName, aImageName ) ); - aRes = aPath; - } - return aRes; -} - - rtl::OUString SvtLinguConfig::GetSpellAndGrammarContextSuggestionImage( const rtl::OUString &rServiceImplName ) const diff --git a/vcl/inc/vcl/button.hxx b/vcl/inc/vcl/button.hxx index 32227345fb89..b2b812c03f53 100644 --- a/vcl/inc/vcl/button.hxx +++ b/vcl/inc/vcl/button.hxx @@ -94,7 +94,6 @@ public: void EnableTextDisplay( sal_Bool bEnable ); void SetFocusRect( const Rectangle& rFocusRect ); - void SetSmallSymbol (bool bSmall=true); bool IsSmallSymbol () const; }; diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx index 52eb43ee56ad..c5e1a46a933e 100644 --- a/vcl/source/control/button.cxx +++ b/vcl/source/control/button.cxx @@ -620,12 +620,6 @@ void Button::EnableTextDisplay( sal_Bool bEnable ) mpButtonData->mnButtonState |= BUTTON_DRAW_NOTEXT; } -// ----------------------------------------------------------------------- -void Button::SetSmallSymbol (bool small) -{ - ImplSetSmallSymbol (small); -} - bool Button::IsSmallSymbol () const { return mpButtonData->mbSmallSymbol; -- cgit From 8fa8a59cad3970bbe68724fbbb93797fb5786c37 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 2 Nov 2011 16:03:57 +0000 Subject: update unused list --- unusedcode.easy | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/unusedcode.easy b/unusedcode.easy index a8cece30ad3f..e895bbc097e9 100644 --- a/unusedcode.easy +++ b/unusedcode.easy @@ -487,8 +487,6 @@ ScInputBarGroup::LinkStubImpl_ScrollHdl(void*, void*) ScJobSetup::ScJobSetup(SfxPrinter*) ScLeftFooterEditPage::GetRanges() ScLeftHeaderEditPage::GetRanges() -ScMacrosTest::testStarBasic() -ScMacrosTest::testVba() ScMatrix::CalcOffset(unsigned long, unsigned long) const ScMultiTextWnd::GetLineCount() ScMyCellInfo::ScMyCellInfo() @@ -1269,6 +1267,7 @@ VCLUnoHelper::CreatePointer() VCLXDevice::IsCreatedWithToolkit() const VCLXPrinterServer::getImplementationId() VCLXPrinterServer::getTypes() +VCLXRadioButton::getFirstActionListener() VbaFontBase::getUnderline() VbaFontBase::setUnderline(com::sun::star::uno::Any const&) VbaFoundFilesEnum::SetFileList(com::sun::star::uno::Sequence&) @@ -2136,7 +2135,40 @@ graphite2::TtfUtil::GlyfLookup(unsigned short, void const*, void const*, unsigne jfw_plugin::VendorBase::createInstance() jfw_plugin::VendorBase::getJavaExePaths(int*) jvmaccess::ClassPath::doLoadClass(com::sun::star::uno::Reference const&, void*, rtl::OUString const&, rtl::OUString const&) +layout::Box::Box(layout::Context const*, char const*) +layout::Box::Box(rtl::OUString const&, int, bool) +layout::Box::setProps(com::sun::star::uno::Reference, bool, bool, int) +layout::Button::GetButton() const +layout::Container::ShowAll(bool) +layout::ControlImpl::GetGetFocusHdl() +layout::ControlImpl::GetLoseFocusHdl() +layout::Dialog::GetDialog() const +layout::Edit::GetEdit() const +layout::ErrorBox::ErrorBox(Window*, char const*, char const*, char const*, rtl::OString const&, char const*, char const*) +layout::ErrorBox::ErrorBox(Window*, long, char const*, char const*, char const*, rtl::OString const&, char const*, char const*) +layout::ErrorBox::ErrorBox(Window*, long, rtl::OUString const&, rtl::OUString, rtl::OUString, rtl::OString const&, char const*, char const*) +layout::ErrorBox::ErrorBox(Window*, rtl::OUString const&, rtl::OUString, rtl::OUString, rtl::OString const&, char const*, char const*) +layout::InfoBox::InfoBox(Window*, char const*, char const*, char const*, rtl::OString const&, char const*, char const*) +layout::InfoBox::InfoBox(Window*, long, char const*, char const*, char const*, rtl::OString const&, char const*, char const*) +layout::InfoBox::InfoBox(Window*, long, rtl::OUString const&, rtl::OUString, rtl::OUString, rtl::OString const&, char const*, char const*) +layout::InfoBox::InfoBox(Window*, rtl::OUString const&, rtl::OUString, rtl::OUString, rtl::OString const&, char const*, char const*) +layout::ListBox::GetEntry(unsigned short) const +layout::ListBox::GetEntryPos(String const&) const +layout::ListBox::GetSelectEntryPos(unsigned short) const +layout::ListBox::SelectEntryPos(unsigned short, bool) +layout::MetricFormatter::MetricFormatter(layout::FormatterBaseImpl*) +layout::MetricFormatter::getFormatImpl() const +layout::NumericFormatter::NumericFormatter(layout::FormatterBaseImpl*) +layout::NumericFormatter::getFormatImpl() const +layout::PushButton::Check(bool) +layout::PushButton::GetPushButton() const +layout::TabControl::SetCurPageId(unsigned short) +layout::Table::setProps(com::sun::star::uno::Reference, bool, bool, int, int) +layout::Window::CreatePeer(layout::Window*, long, char const*) +layout::Window::getContext() +layout::WindowImpl::getProperty(char const*) layoutimpl::LayoutRoot::addItem(rtl::OUString const&, com::sun::star::uno::Reference const&) +layoutimpl::VCLXPlugin::SetPlugin(Control*) layoutimpl::VCLXTabControl::AddChild(com::sun::star::uno::Reference const&) layoutimpl::WidgetFactory::sfx2CreateWindow(VCLXWindow**, Window*, rtl::OUString const&, long&) layoutimpl::getParent(com::sun::star::uno::Reference) -- cgit From 4ab6d2841dc47219d443e18f007f7b9893705966 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 2 Nov 2011 17:39:07 +0200 Subject: Pointless to check for "executability" of gdiplus.dll here --- post_download.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/post_download.in b/post_download.in index 7c5d07f08dcc..6025d38579db 100644 --- a/post_download.in +++ b/post_download.in @@ -50,7 +50,7 @@ dnl Windows builds need gdiplus.dll in external/gdiplus/ dnl =================================================================== if test "$_os" = "WINNT"; then AC_MSG_CHECKING([for gdiplus.dll]) - if test -x ./external/gdiplus/gdiplus.dll; then + if test -f ./external/gdiplus/gdiplus.dll; then AC_MSG_RESULT([found]) else AC_MSG_ERROR([gdiplus.dll is missing in external/gdiplus/. -- cgit From 8524330a746da6bd26ca5676b48cdce6bb722380 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Wed, 2 Nov 2011 16:57:23 +0100 Subject: Simplify addition of optional components to URE_MORE_{SERVICES,TYPES}. Those bootstrap variables now support * syntax to include all files (non- recursively) contained in the directory denoted by XXX. Optional components can put their data simply into program/services/ and program/types/. --- cppuhelper/source/bootstrap.cxx | 163 ++++++++++++++++++++++++++++---------- scp2/source/ooo/common_brand.scp | 4 +- scp2/source/ooo/directory_ooo.scp | 10 +++ scp2/source/ooo/file_ooo.scp | 6 +- ure/source/README | 5 ++ 5 files changed, 140 insertions(+), 48 deletions(-) diff --git a/cppuhelper/source/bootstrap.cxx b/cppuhelper/source/bootstrap.cxx index 90a16af1be41..7aefa0b26b59 100644 --- a/cppuhelper/source/bootstrap.cxx +++ b/cppuhelper/source/bootstrap.cxx @@ -75,6 +75,8 @@ using namespace ::osl; using namespace ::com::sun::star; using namespace ::com::sun::star::uno; +namespace css = com::sun::star; + namespace cppu { @@ -198,6 +200,105 @@ OUString findBootstrapArgument( return result; } +css::uno::Reference< css::registry::XSimpleRegistry > readRdbFile( + rtl::OUString const & url, bool fatalErrors, + css::uno::Reference< css::registry::XSimpleRegistry > const & lastRegistry, + css::uno::Reference< css::lang::XSingleServiceFactory > const & + simpleRegistryFactory, + css::uno::Reference< css::lang::XSingleServiceFactory > const & + nestedRegistryFactory) +{ + OSL_ASSERT(simpleRegistryFactory.is() && nestedRegistryFactory.is()); + try { + css::uno::Reference< css::registry::XSimpleRegistry > simple( + simpleRegistryFactory->createInstance(), css::uno::UNO_QUERY_THROW); + simple->open(url, true, false); + if (lastRegistry.is()) { + css::uno::Reference< css::registry::XSimpleRegistry > nested( + nestedRegistryFactory->createInstance(), + css::uno::UNO_QUERY_THROW); + css::uno::Sequence< css::uno::Any > args(2); + args[0] <<= lastRegistry; + args[1] <<= simple; + css::uno::Reference< css::lang::XInitialization >( + nested, css::uno::UNO_QUERY_THROW)-> + initialize(args); + return nested; + } else { + return simple; + } + } catch (css::registry::InvalidRegistryException & e) { + (void) e; // avoid warnings + OSL_TRACE( + OSL_LOG_PREFIX "warning, could not open \"%s\": \"%s\"", + rtl::OUStringToOString(url, RTL_TEXTENCODING_UTF8).getStr(), + rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr()); + if (fatalErrors) { + throw; + } + return lastRegistry; + } +} + +Reference< registry::XSimpleRegistry > readRdbDirectory( + rtl::OUString const & url, bool fatalErrors, + css::uno::Reference< css::registry::XSimpleRegistry > const & lastRegistry, + css::uno::Reference< css::lang::XSingleServiceFactory > const & + simpleRegistryFactory, + css::uno::Reference< css::lang::XSingleServiceFactory > const & + nestedRegistryFactory) +{ + OSL_ASSERT(simpleRegistryFactory.is() && nestedRegistryFactory.is()); + osl::Directory dir(url); + switch (dir.open()) { + case osl::FileBase::E_None: + break; + case osl::FileBase::E_NOENT: + if (!fatalErrors) { + return lastRegistry; + } + // fall through + default: + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("cannot open directory ")) + + url), + css::uno::Reference< css::uno::XInterface >()); + } + for (css::uno::Reference< css::registry::XSimpleRegistry > last( + lastRegistry);;) + { + osl::DirectoryItem i; + switch (dir.getNextItem(i, SAL_MAX_UINT32)) { + case osl::FileBase::E_None: + break; + case osl::FileBase::E_NOENT: + return last; + default: + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("cannot iterate directory ")) + + url), + css::uno::Reference< css::uno::XInterface >()); + } + osl::FileStatus stat( + osl_FileStatus_Mask_Type | osl_FileStatus_Mask_FileName | + osl_FileStatus_Mask_FileURL); + if (i.getFileStatus(stat) != osl::FileBase::E_None) { + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("cannot stat in directory ")) + + url), + css::uno::Reference< css::uno::XInterface >()); + } + if (stat.getFileType() != osl::FileStatus::Directory) { //TODO: symlinks + last = readRdbFile( + stat.getFileURL(), fatalErrors, last, simpleRegistryFactory, + nestedRegistryFactory); + } + } +} + Reference< registry::XSimpleRegistry > nestRegistries( const OUString &baseDir, const Reference< lang::XSingleServiceFactory > & xSimRegFac, @@ -238,54 +339,30 @@ Reference< registry::XSimpleRegistry > nestRegistries( OUString rdb_name = (index == -1) ? csl_rdbs : csl_rdbs.copy(0, index); csl_rdbs = (index == -1) ? OUString() : csl_rdbs.copy(index + 1); - if (! rdb_name.getLength()) + if (rdb_name.isEmpty()) { continue; + } - bool optional = ('?' == rdb_name[ 0 ]); - if (optional) - rdb_name = rdb_name.copy( 1 ); - - try - { - Reference simpleRegistry( - xSimRegFac->createInstance(), UNO_QUERY_THROW ); - - osl::FileBase::getAbsoluteFileURL(baseDir, rdb_name, rdb_name); - simpleRegistry->open(rdb_name, sal_True, sal_False); - - if(lastRegistry.is()) - { - Reference< registry::XSimpleRegistry > nestedRegistry( - xNesRegFac->createInstance(), UNO_QUERY ); - Reference< lang::XInitialization > nestedRegistry_xInit( - nestedRegistry, UNO_QUERY ); - - Sequence aArgs(2); - aArgs[0] <<= lastRegistry; - aArgs[1] <<= simpleRegistry; - - nestedRegistry_xInit->initialize(aArgs); - - lastRegistry = nestedRegistry; - } - else - lastRegistry = simpleRegistry; + bool fatalErrors = !bFallenBack; + if (rdb_name[0] == '?') { + rdb_name = rdb_name.copy(1); + fatalErrors = false; } - catch(registry::InvalidRegistryException & e) - { - (void) e; // avoid warnings - OSL_TRACE( - OSL_LOG_PREFIX "warning, could not open \"%s\": \"%s\"", - OUStringToOString(rdb_name, RTL_TEXTENCODING_UTF8).getStr(), - OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr()); - if (! optional) - { - // if a registry was explicitly given, the exception shall fly - if( ! bFallenBack ) - throw; - } + bool directory = rdb_name.getLength() >= 3 && rdb_name[0] == '<' && + rdb_name[rdb_name.getLength() - 2] == '>' && + rdb_name[rdb_name.getLength() -1] == '*'; + if (directory) { + rdb_name = rdb_name.copy(1, rdb_name.getLength() - 3); } + + osl::FileBase::getAbsoluteFileURL(baseDir, rdb_name, rdb_name); + + lastRegistry = directory + ? readRdbDirectory( + rdb_name, fatalErrors, lastRegistry, xSimRegFac, xNesRegFac) + : readRdbFile( + rdb_name, fatalErrors, lastRegistry, xSimRegFac, xNesRegFac); } while(index != -1 && csl_rdbs.getLength()); // are there more rdbs in list? diff --git a/scp2/source/ooo/common_brand.scp b/scp2/source/ooo/common_brand.scp index 9b75f369d578..710cdb8863ad 100644 --- a/scp2/source/ooo/common_brand.scp +++ b/scp2/source/ooo/common_brand.scp @@ -1168,7 +1168,7 @@ ProfileItem gid_Brand_Profileitem_Fundamental_Ure_More_Types ProfileID = gid_Brand_Profile_Fundamental_Ini; Section = "Bootstrap"; Key = "URE_MORE_TYPES"; - Value = "$ORIGIN/offapi.rdb $ORIGIN/oovbaapi.rdb ${${$ORIGIN/" PROFILENAME(uno) ":PKG_UserUnoFile}:UNO_TYPES} ${${$ORIGIN/" PROFILENAME(uno) ":PKG_SharedUnoFile}:UNO_TYPES} ${${$ORIGIN/" PROFILENAME(uno) ":PKG_BundledUnoFile}:UNO_TYPES}"; + Value = "<$ORIGIN/types>* ${${$ORIGIN/" PROFILENAME(uno) ":PKG_UserUnoFile}:UNO_TYPES} ${${$ORIGIN/" PROFILENAME(uno) ":PKG_SharedUnoFile}:UNO_TYPES} ${${$ORIGIN/" PROFILENAME(uno) ":PKG_BundledUnoFile}:UNO_TYPES}"; End ProfileItem gid_Brand_Profileitem_Fundamental_Ure_More_Services @@ -1176,7 +1176,7 @@ ProfileItem gid_Brand_Profileitem_Fundamental_Ure_More_Services ProfileID = gid_Brand_Profile_Fundamental_Ini; Section = "Bootstrap"; Key = "URE_MORE_SERVICES"; - Value = "${${$ORIGIN/" PROFILENAME(uno) ":PKG_UserUnoFile}:UNO_SERVICES} ${${$ORIGIN/" PROFILENAME(uno) ":PKG_SharedUnoFile}:UNO_SERVICES} ${${$ORIGIN/" PROFILENAME(uno) ":PKG_BundledUnoFile}:UNO_SERVICES} $ORIGIN/services.rdb"; + Value = "${${$ORIGIN/" PROFILENAME(uno) ":PKG_UserUnoFile}:UNO_SERVICES} ${${$ORIGIN/" PROFILENAME(uno) ":PKG_SharedUnoFile}:UNO_SERVICES} ${${$ORIGIN/" PROFILENAME(uno) ":PKG_BundledUnoFile}:UNO_SERVICES} <$ORIGIN/services>*"; End ProfileItem gid_Brand_Profileitem_Fundamental_Ure_More_Java_Types diff --git a/scp2/source/ooo/directory_ooo.scp b/scp2/source/ooo/directory_ooo.scp index a25b2d7f67e4..afd11a98c910 100644 --- a/scp2/source/ooo/directory_ooo.scp +++ b/scp2/source/ooo/directory_ooo.scp @@ -1435,3 +1435,13 @@ Directory gid_Dir_Template_Common_Presnt ParentID = gid_Dir_Template_Common; DosName = "presnt"; End + +Directory gid_Brand_Dir_Program_Services + ParentID = gid_Brand_Dir_Program; + DosName = "services"; +End + +Directory gid_Brand_Dir_Program_Types + ParentID = gid_Brand_Dir_Program; + DosName = "types"; +End diff --git a/scp2/source/ooo/file_ooo.scp b/scp2/source/ooo/file_ooo.scp index 34ed8a90a9a1..a8e0d88ebc47 100644 --- a/scp2/source/ooo/file_ooo.scp +++ b/scp2/source/ooo/file_ooo.scp @@ -629,14 +629,14 @@ End File gid_File_Rdb_Offapi TXT_FILE_BODY; - Dir = gid_Brand_Dir_Program; + Dir = gid_Brand_Dir_Program_Types; Styles = (PACKED); Name = "offapi.rdb"; End File gid_File_Rdb_TypesVba TXT_FILE_BODY; - Dir = gid_Brand_Dir_Program; + Dir = gid_Brand_Dir_Program_Types; Styles = (PACKED, OVERWRITE); Name = "oovbaapi.rdb"; End @@ -1142,7 +1142,7 @@ End File gid_Starregistry_Services_Rdb TXT_FILE_BODY; Name = "services.rdb"; - Dir = gid_Brand_Dir_Program; + Dir = gid_Brand_Dir_Program_Services; Styles = (PACKED); End diff --git a/ure/source/README b/ure/source/README index 64fa40bdb169..1463e04fdbbb 100644 --- a/ure/source/README +++ b/ure/source/README @@ -273,6 +273,11 @@ types.rdb and services.rdb files. That is, you cannot store additional types.rdb and services.rdb files in a Documents and Settings\All Users\Application Data\URE directory. +URE_MORE_TYPES and URE_MORE_SERVICES each contain zero or more space-separated +URI descriptors. A URI descriptor is either a URI (denoting an individual file) +or a URI embeded in "<" and ">*" (denoting all the files contained non- +recursively within the directory denoted by the given URI). + The Java UNO environment needs type information in the form of Java class files instead of rdb files. Additional types are searched for in any URLs listed in the public deployment variable URE_MORE_JAVA_TYPES. -- cgit From b5ec39a65e8b5d78f9f58bc179e9130c81ec347a Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Wed, 2 Nov 2011 17:01:25 +0100 Subject: Make .hpp/.hdl more robust against accidental include of .hdl instead of .hpp. .hdl failed to declare the inline cppu_detail_getUnoType functions defined in .hpp, which if client code only includes .hdl instead of .hpp could lead to runtime failures, now leads to compiler warnings. --- codemaker/source/cppumaker/cpputype.cxx | 169 ++++++++++---------------------- codemaker/source/cppumaker/cpputype.hxx | 17 ++-- 2 files changed, 61 insertions(+), 125 deletions(-) diff --git a/codemaker/source/cppumaker/cpputype.cxx b/codemaker/source/cppumaker/cpputype.cxx index 5b87cc095483..e1a524feb410 100644 --- a/codemaker/source/cppumaker/cpputype.cxx +++ b/codemaker/source/cppumaker/cpputype.cxx @@ -125,6 +125,10 @@ void CppuType::addGetCppuTypeIncludes(codemaker::cppumaker::Includes & includes) } } +void CppuType::dumpDeclaration(FileStream &) throw (CannotDumpException) { + OSL_ASSERT(false); +} + bool CppuType::dumpFiles(CppuOptions * options, rtl::OString const & outPath) { return dumpFile(options, ".hdl", m_typeName, outPath) && dumpFile(options, ".hpp", m_typeName, outPath); @@ -433,6 +437,42 @@ void CppuType::dumpInitializer( out << ")"; } +void CppuType::dumpHFileContent( + FileStream & out, codemaker::cppumaker::Includes & includes) +{ + addDefaultHIncludes(includes); + dumpHeaderDefine(out, "HDL"); + out << "\n"; + includes.dump(out, 0); + out << ("\nnamespace com { namespace sun { namespace star { namespace uno" + " { class Type; } } } }\n\n"); + if (codemaker::cppumaker::dumpNamespaceOpen(out, m_typeName, false)) { + out << "\n"; + } + dumpDeclaration(out); + if (!(m_typeName.equalsL( + RTL_CONSTASCII_STRINGPARAM("com/sun/star/uno/XInterface")) || + m_typeName.equalsL( + RTL_CONSTASCII_STRINGPARAM("com/sun/star/uno/Exception")) || + isPolymorphic())) + { + out << "\n" << indent() + << ("inline ::com::sun::star::uno::Type const &" + " cppu_detail_getUnoType("); + dumpType(out, m_typeName, false, false, true); + out << " const *);\n"; + } + if (codemaker::cppumaker::dumpNamespaceClose(out, m_typeName, false)) { + out << "\n"; + } + out << "\n"; + dumpTemplateHead(out); + out << "inline ::com::sun::star::uno::Type const & SAL_CALL getCppuType("; + dumpType(out, m_typeName, true); + dumpTemplateParameters(out); + out << " *) SAL_THROW(());\n\n#endif\n"; +} + void CppuType::dumpGetCppuType(FileStream & out) { if (m_typeName.equals("com/sun/star/uno/XInterface")) { out << indent() @@ -1268,34 +1308,14 @@ sal_Bool InterfaceType::dumpHFile( FileStream& o, codemaker::cppumaker::Includes & includes) throw( CannotDumpException ) { - OString headerDefine(dumpHeaderDefine(o, "HDL")); - o << "\n"; - - addDefaultHIncludes(includes); if (m_reader.getMethodCount() != 0) { includes.add("com/sun/star/uno/RuntimeException"); } - includes.dump(o, 0); - o << ("\nnamespace com { namespace sun { namespace star { namespace uno {\n" - "class Type;\n} } } }\n\n"); - - if (codemaker::cppumaker::dumpNamespaceOpen(o, m_typeName, false)) { - o << "\n"; - } - dumpDeclaration(o); - if (codemaker::cppumaker::dumpNamespaceClose(o, m_typeName, false)) { - o << "\n"; - } - - o << "\ninline const ::com::sun::star::uno::Type& SAL_CALL getCppuType( "; - dumpType(o, m_typeName, sal_True, sal_False); - o << "* ) SAL_THROW( () );\n\n"; - - o << "#endif // "<< headerDefine << "\n"; + dumpHFileContent(o, includes); return sal_True; } -sal_Bool InterfaceType::dumpDeclaration(FileStream& o) +void InterfaceType::dumpDeclaration(FileStream& o) throw( CannotDumpException ) { // rtl::OString cppName(translateUnoToCppIdentifier( @@ -1323,8 +1343,6 @@ sal_Bool InterfaceType::dumpDeclaration(FileStream& o) dec(); o << "};\n\n"; - - return sal_True; } sal_Bool InterfaceType::dumpHxxFile( @@ -2283,7 +2301,7 @@ sal_Bool ConstantsType::dumpHFile( return sal_True; } -sal_Bool ConstantsType::dumpDeclaration(FileStream& o) +void ConstantsType::dumpDeclaration(FileStream& o) throw( CannotDumpException ) { sal_uInt16 fieldCount = m_reader.getFieldCount(); @@ -2302,8 +2320,6 @@ sal_Bool ConstantsType::dumpDeclaration(FileStream& o) dumpConstantValue(o, i); o << ";\n"; } - - return sal_True; } sal_Bool ConstantsType::hasConstants() @@ -2395,38 +2411,11 @@ sal_Bool StructureType::dumpHFile( FileStream& o, codemaker::cppumaker::Includes & includes) throw( CannotDumpException ) { - OString headerDefine(dumpHeaderDefine(o, "HDL")); - o << "\n"; - - addDefaultHIncludes(includes); - includes.dump(o, 0); - o << "\n"; - - if (codemaker::cppumaker::dumpNamespaceOpen(o, m_typeName, false)) { - o << "\n"; - } - - dumpDeclaration(o); - - if (codemaker::cppumaker::dumpNamespaceClose(o, m_typeName, false)) { - o << "\n"; - } - - o << "\nnamespace com { namespace sun { namespace star { namespace uno {\n" - << "class Type;\n} } } }\n\n"; - - dumpTemplateHead(o); - o << "inline const ::com::sun::star::uno::Type& SAL_CALL getCppuType( "; - dumpType(o, m_typeName, sal_True, sal_False); - dumpTemplateParameters(o); - o << "* );\n\n"; - - o << "#endif // "<< headerDefine << "\n"; - + dumpHFileContent(o, includes); return sal_True; } -sal_Bool StructureType::dumpDeclaration(FileStream& o) +void StructureType::dumpDeclaration(FileStream& o) throw( CannotDumpException ) { o << "\n#ifdef SAL_W32\n" @@ -2508,8 +2497,6 @@ sal_Bool StructureType::dumpDeclaration(FileStream& o) o << "#ifdef SAL_W32\n" << "# pragma pack(pop)\n" << "#endif\n\n"; - - return sal_True; } sal_Bool StructureType::dumpHxxFile( @@ -3177,36 +3164,11 @@ sal_Bool ExceptionType::dumpHFile( FileStream& o, codemaker::cppumaker::Includes & includes) throw( CannotDumpException ) { - OString headerDefine(dumpHeaderDefine(o, "HDL")); - o << "\n"; - - addDefaultHIncludes(includes); - includes.dump(o, 0); - o << "\n"; - - if (codemaker::cppumaker::dumpNamespaceOpen(o, m_typeName, false)) { - o << "\n"; - } - - dumpDeclaration(o); - - if (codemaker::cppumaker::dumpNamespaceClose(o, m_typeName, false)) { - o << "\n"; - } - - o << "\nnamespace com { namespace sun { namespace star { namespace uno {\n" - << "class Type;\n} } } }\n\n"; - - o << "inline const ::com::sun::star::uno::Type& SAL_CALL getCppuType( "; - dumpType(o, m_typeName, sal_True, sal_False); - o << "* ) SAL_THROW( () );\n\n"; - - o << "#endif // "<< headerDefine << "\n"; - + dumpHFileContent(o, includes); return sal_True; } -sal_Bool ExceptionType::dumpDeclaration(FileStream& o) +void ExceptionType::dumpDeclaration(FileStream& o) throw( CannotDumpException ) { o << "\nclass CPPU_GCC_DLLPUBLIC_EXPORT " << m_name; @@ -3291,8 +3253,6 @@ sal_Bool ExceptionType::dumpDeclaration(FileStream& o) dec(); o << "};\n\n"; - - return sal_True; } sal_Bool ExceptionType::dumpHxxFile( @@ -3558,36 +3518,11 @@ sal_Bool EnumType::dumpHFile( FileStream& o, codemaker::cppumaker::Includes & includes) throw( CannotDumpException ) { - OString headerDefine(dumpHeaderDefine(o, "HDL")); - o << "\n"; - - addDefaultHIncludes(includes); - includes.dump(o, 0); - o << "\n"; - - if (codemaker::cppumaker::dumpNamespaceOpen(o, m_typeName, false)) { - o << "\n"; - } - - dumpDeclaration(o); - - if (codemaker::cppumaker::dumpNamespaceClose(o, m_typeName, false)) { - o << "\n"; - } - - o << "\nnamespace com { namespace sun { namespace star { namespace uno {\n" - << "class Type;\n} } } }\n\n"; - - o << "inline const ::com::sun::star::uno::Type& SAL_CALL getCppuType( "; - dumpType(o, m_typeName, sal_True, sal_False); - o << "* ) SAL_THROW( () );\n\n"; - - o << "#endif // "<< headerDefine << "\n"; - + dumpHFileContent(o, includes); return sal_True; } -sal_Bool EnumType::dumpDeclaration(FileStream& o) +void EnumType::dumpDeclaration(FileStream& o) throw( CannotDumpException ) { o << "\nenum " << m_name << "\n{\n"; @@ -3621,8 +3556,6 @@ sal_Bool EnumType::dumpDeclaration(FileStream& o) dec(); o << "};\n\n"; - - return sal_True; } sal_Bool EnumType::dumpHxxFile( @@ -3800,7 +3733,7 @@ sal_Bool TypeDefType::dumpHFile( return sal_True; } -sal_Bool TypeDefType::dumpDeclaration(FileStream& o) +void TypeDefType::dumpDeclaration(FileStream& o) throw( CannotDumpException ) { o << "\ntypedef "; @@ -3809,8 +3742,6 @@ sal_Bool TypeDefType::dumpDeclaration(FileStream& o) rtl::OUStringToOString( m_reader.getSuperTypeName(0), RTL_TEXTENCODING_UTF8)); o << " " << m_name << ";\n\n"; - - return sal_True; } sal_Bool TypeDefType::dumpHxxFile( diff --git a/codemaker/source/cppumaker/cpputype.hxx b/codemaker/source/cppumaker/cpputype.hxx index 2823e9c30159..c33a0f06e860 100644 --- a/codemaker/source/cppumaker/cpputype.hxx +++ b/codemaker/source/cppumaker/cpputype.hxx @@ -110,6 +110,8 @@ protected: codemaker::cpp::IdentifierTranslationMode isGlobal() const; + virtual void dumpDeclaration(FileStream & out) throw (CannotDumpException); + virtual void addSpecialDependencies() {} virtual bool dumpFiles(CppuOptions * options, rtl::OString const & outPath); @@ -139,6 +141,9 @@ protected: void dumpInitializer( FileStream & out, bool parameterized, rtl::OUString const & type) const; + void dumpHFileContent( + FileStream & out, codemaker::cppumaker::Includes & includes); + protected: sal_uInt32 m_inheritedMemberCount; @@ -165,7 +170,7 @@ public: virtual ~InterfaceType(); - sal_Bool dumpDeclaration(FileStream& o) throw( CannotDumpException ); + virtual void dumpDeclaration(FileStream& o) throw( CannotDumpException ); sal_Bool dumpHFile(FileStream& o, codemaker::cppumaker::Includes & includes) throw( CannotDumpException ); sal_Bool dumpHxxFile(FileStream& o, codemaker::cppumaker::Includes & includes) throw( CannotDumpException ); @@ -227,7 +232,7 @@ public: virtual sal_Bool dump(CppuOptions* pOptions) throw( CannotDumpException ); - sal_Bool dumpDeclaration(FileStream& o) throw( CannotDumpException ); + virtual void dumpDeclaration(FileStream& o) throw( CannotDumpException ); sal_Bool dumpHFile(FileStream& o, codemaker::cppumaker::Includes & includes) throw( CannotDumpException ); sal_Bool dumpHxxFile(FileStream& o, codemaker::cppumaker::Includes & includes) throw( CannotDumpException ); sal_Bool hasConstants(); @@ -255,7 +260,7 @@ public: virtual ~StructureType(); - sal_Bool dumpDeclaration(FileStream& o) throw( CannotDumpException ); + virtual void dumpDeclaration(FileStream& o) throw( CannotDumpException ); sal_Bool dumpHFile(FileStream& o, codemaker::cppumaker::Includes & includes) throw( CannotDumpException ); sal_Bool dumpHxxFile(FileStream& o, codemaker::cppumaker::Includes & includes) throw( CannotDumpException ); @@ -293,7 +298,7 @@ public: virtual ~ExceptionType(); - sal_Bool dumpDeclaration(FileStream& o) throw( CannotDumpException ); + virtual void dumpDeclaration(FileStream& o) throw( CannotDumpException ); sal_Bool dumpHFile(FileStream& o, codemaker::cppumaker::Includes & includes) throw( CannotDumpException ); sal_Bool dumpHxxFile(FileStream& o, codemaker::cppumaker::Includes & includes) throw( CannotDumpException ); @@ -309,7 +314,7 @@ public: virtual ~EnumType(); - sal_Bool dumpDeclaration(FileStream& o) throw( CannotDumpException ); + virtual void dumpDeclaration(FileStream& o) throw( CannotDumpException ); sal_Bool dumpHFile(FileStream& o, codemaker::cppumaker::Includes & includes) throw( CannotDumpException ); sal_Bool dumpHxxFile(FileStream& o, codemaker::cppumaker::Includes & includes) throw( CannotDumpException ); @@ -326,7 +331,7 @@ public: virtual ~TypeDefType(); - sal_Bool dumpDeclaration(FileStream& o) throw( CannotDumpException ); + virtual void dumpDeclaration(FileStream& o) throw( CannotDumpException ); sal_Bool dumpHFile(FileStream& o, codemaker::cppumaker::Includes & includes) throw( CannotDumpException ); sal_Bool dumpHxxFile(FileStream& o, codemaker::cppumaker::Includes & includes) throw( CannotDumpException ); }; -- cgit From f6f5c89259867b5aeb86d5509f826da949d122c4 Mon Sep 17 00:00:00 2001 From: Tomas Chvatal Date: Wed, 2 Nov 2011 17:36:27 +0100 Subject: Rename --enable-nss-module to --with-system-nss + introduce --enable-xmlsec. This also finishes the uncoupling of NSS from the --with-system-mozilla. --- configure.in | 77 ++++++++++++++------------------------ libxmlsec/makefile.mk | 8 ++-- moz/extractfiles.mk | 18 ++++----- moz/makefile.mk | 2 +- nss/makefile.mk | 4 +- nss/readme.txt | 2 +- set_soenv.in | 10 ++--- xmlsecurity/Library_xsec_xmlsec.mk | 11 ++---- xmlsecurity/Module_xmlsecurity.mk | 2 +- 9 files changed, 55 insertions(+), 79 deletions(-) diff --git a/configure.in b/configure.in index a260a0a775fd..b69aeb63f802 100644 --- a/configure.in +++ b/configure.in @@ -361,10 +361,10 @@ AC_ARG_ENABLE(build-mozilla, the Mozilla source code but take precompiled zips.]), ,) -AC_ARG_ENABLE(nss-module, - AS_HELP_STRING([--disable-nss-module], - [Whether to use provided NSS module.]), -,enable_nss_module=yes) +AC_ARG_ENABLE(xmlsec, + AS_HELP_STRING([--disable-xmlsec], + [Whether to enable XMLsec for open document signing.]), +) AC_ARG_ENABLE(kde, AS_HELP_STRING([--enable-kde], @@ -643,6 +643,11 @@ AC_ARG_WITH(system-cairo, [Use Cairo libraries already on system.]), ,) +AC_ARG_WITH(system-nss, + AS_HELP_STRING([--with-system-nss], + [Use NSS/nspr libraries already on system.]), +,) + AC_ARG_WITH(mozilla-version, AS_HELP_STRING([--with-mozilla-version], [Choose which version of Mozilla to use while building Mozilla. @@ -5723,11 +5728,14 @@ else fi AC_MSG_CHECKING([whether to build XML Security support]) -if test "$enable_nss_module" = "no"; then - AC_MSG_RESULT([no, NSS disabled]) +if test "$enable_xmlsec" = "no"; then + AC_MSG_RESULT([no]) + ENABLE_XMLSEC=no else + ENABLE_XMLSEC=yes AC_MSG_RESULT([yes]) fi +AC_SUBST(ENABLE_XMLSEC) AC_MSG_CHECKING([whether to build LDAP configuration backend]) if test -z "$enable_ldap" || test "$enable_ldap" = "yes"; then @@ -5776,8 +5784,6 @@ AC_MSG_CHECKING([which Mozilla to use]) if test -n "$with_system_mozilla" && test "$with_system_mozilla" != "no"; then AC_MSG_RESULT([external]) SYSTEM_MOZILLA=YES - ENABLE_NSS_MODULE=NO - enable_nss_module=no AC_MSG_CHECKING([which Mozilla flavour to use]) if test -n "$with_system_mozilla" && test "$with_system_mozilla" = "libxul"; then MOZ_FLAVOUR=libxul @@ -5795,22 +5801,6 @@ if test -n "$with_system_mozilla" && test "$with_system_mozilla" != "no"; then tmp=`echo $MOZ_FLAVOUR | $PERL -e 'print ucfirst();'` AC_MSG_RESULT($tmp) - PKG_CHECK_MODULES( MOZ_NSS, nss, STANDALONENSS="TRUE", STANDALONENSS="" ) - if test -z "$STANDALONENSS"; then - PKG_CHECK_MODULES( MOZ_NSS, $MOZ_FLAVOUR-nss ) - else - NSS_LIB="-L`$PKG_CONFIG --variable=libdir nss`" - AC_SUBST(NSS_LIB) - fi - - if $PKG_CONFIG --exists nspr ; then - PKG_CHECK_MODULES( MOZ_NSPR, nspr ) - NSPR_LIB="-L`$PKG_CONFIG --variable=libdir nspr`" - AC_SUBST(NSPR_LIB) - else - PKG_CHECK_MODULES( MOZ_NSPR, $MOZ_FLAVOUR-nspr ) - fi - if test "$MOZ_FLAVOUR" != "libxul"; then PKG_CHECK_MODULES( MOZILLAXPCOM, $MOZ_FLAVOUR-xpcom, HASXPCOM="TRUE", HASXPCOM="" ) MOZ_INC=`$PKG_CONFIG --variable=includedir $MOZ_FLAVOUR-xpcom` @@ -5829,19 +5819,6 @@ if test -n "$with_system_mozilla" && test "$with_system_mozilla" != "no"; then fi fi - save_CPPFLAGS="$CPPFLAGS" - save_LDFLAGS="$LDFLAGS" - save_LIBS="$LIBS" - CPPFLAGS="$CPPFLAGS $MOZ_NSS_CFLAGS" - LDFLAGS="$LDFLAGS $MOZ_NSS_LIBS" - AC_CHECK_LIB(nss3, PK11_GetCertFromPrivateKey, [], - [AC_MSG_ERROR(PK11_GetCertFromPrivateKey missing but needed. -See https://bugzilla.mozilla.org/show_bug.cgi?id=262274. -Fixed since nss 3.9.3 (contained by e.g. mozilla >= 1.7.5))], []) - LDFLAGS="$save_LDFLAGS" - CPPFLAGS="$save_CPPFLAGS" - LIBS="$save_LIBS" - MOZ_LIB_XPCOM=$MOZILLAXPCOM_LIBS if test "$WITH_LDAP" != "NO" && test "$WITH_OPENLDAP" != "YES"; then AC_MSG_CHECKING([whether $tmp was compiled with --enable-ldap]) @@ -6001,18 +5978,22 @@ AC_SUBST(MOZ_FLAVOUR) AC_SUBST(MOZ_INC) AC_SUBST(MOZ_LIB) AC_SUBST(MOZ_LIB_XPCOM) -AC_SUBST(MOZ_NSPR_CFLAGS) -AC_SUBST(MOZ_NSS_CFLAGS) AC_SUBST(MOZ_LDAP_CFLAGS) dnl =================================================================== -dnl Check for system NSS +dnl Check for system NSS only with xmlsec or mozilla build enabled dnl =================================================================== -AC_MSG_CHECKING([whether to build provided NSS module]) -if test "$enable_nss_module" != "no"; then - ENABLE_NSS_MODULE="YES" +if test "x$enable_xmlsec" != "xno" -o "x$enable_mozilla" = "xyes"; then +AC_MSG_CHECKING([which NSS to use]) +if test -n "$with_system_nss" -o -n "$with_system_headers" && \ + test "$with_system_nss" != "no"; then + AC_MSG_RESULT([external]) + SYSTEM_NSS="YES" + PKG_CHECK_MODULES(NSS, nss >= 3.9.3 nspr >= 4.8) +else + SYSTEM_NSS="NO" BUILD_TYPE="$BUILD_TYPE NSS" - AC_MSG_RESULT([yes]) + AC_MSG_RESULT([internal]) if test "$build_os" = "cygwin"; then AC_MSG_CHECKING([for Mozilla build tooling]) if test -z "$MOZILLABUILD" ; then @@ -6036,11 +6017,11 @@ from http://ftp.mozilla.org/pub/mozilla.org/mozilla/libraries/win32]) fi fi fi -else - ENABLE_NSS_MODULE="NO" - AC_MSG_RESULT([no]) fi -AC_SUBST(ENABLE_NSS_MODULE) +fi +AC_SUBST(SYSTEM_NSS) +AC_SUBST(NSS_CFLAGS) +AC_SUBST(NSS_LIBS) dnl =================================================================== dnl Check for system sane diff --git a/libxmlsec/makefile.mk b/libxmlsec/makefile.mk index 3ef990f16213..5388580fd960 100644 --- a/libxmlsec/makefile.mk +++ b/libxmlsec/makefile.mk @@ -35,9 +35,9 @@ EXTERNAL_WARNINGS_NOT_ERRORS := TRUE .INCLUDE : settings.mk -.IF "$(ENABLE_NSS_MODULE)" == "NO" && "$(SYSTEM_MOZILLA)" != "YES" +.IF "$(ENABLE_XMLSEC)" == "NO" @all: - @echo "NSS module disabled => no libxmlsec...." + @echo "XMLSec module disabled" .ENDIF # --- Files -------------------------------------------------------- @@ -100,7 +100,7 @@ CONFIGURE_DIR= CONFIGURE_ACTION=.$/configure CONFIGURE_FLAGS=--with-libxslt=no --with-openssl=no --with-gnutls=no --with-mozilla_ver=1.7.5 --enable-mscrypto --disable-crypto-dl --build=i586-pc-mingw32 --host=i586-pc-mingw32 CC="$(xmlsec_CC)" LDFLAGS="-no-undefined -L$(ILIB:s/;/ -L/)" LIBS="$(xmlsec_LIBS)" LIBXML2LIB=$(LIBXML2LIB) ZLIB3RDLIB=$(ZLIB3RDLIB) OBJDUMP="$(WRAPCMD) objdump" -.IF "$(SYSTEM_MOZILLA)" != "YES" +.IF "$(SYSTEM_NSS)" != "YES" CONFIGURE_FLAGS+=--enable-pkgconfig=no .ENDIF BUILD_ACTION=$(GNUMAKE) -j$(EXTMAXPROCESS) @@ -160,7 +160,7 @@ CONFIGURE_FLAGS=--with-pic --disable-shared --disable-crypto-dl --with-libxslt=n # --with-nss or parse -pkg-config --libs / cflags mozilla-nss since # the lib may a) be in /usr/lib (Debian) and be not in $with_nss/include # $with_nss/lib. -.IF "$(SYSTEM_MOZILLA)" != "YES" +.IF "$(SYSTEM_NSS)" != "YES" CONFIGURE_FLAGS+=--enable-pkgconfig=no .ENDIF BUILD_ACTION=$(GNUMAKE) -j$(EXTMAXPROCESS) diff --git a/moz/extractfiles.mk b/moz/extractfiles.mk index 4741ff43bdef..793c281b68a4 100644 --- a/moz/extractfiles.mk +++ b/moz/extractfiles.mk @@ -35,7 +35,7 @@ INCLUDE_DIR=$(INCCOM) #If we build the NSS module then we do not need the old nss libs from here -.IF "$(ENABLE_NSS_MODULE)"=="YES" +.IF "$(SYSTEM_NSS)"=="NO" .IF "$(OS)" == "SOLARIS" @@ -95,7 +95,7 @@ BIN_RUNTIMELIST= \ softokn3 \ smime3 \ $(FREEBL_LIB) -.ENDIF # "$(ENABLE_NSS_MODULE)"=="YES" +.ENDIF # "$(SYSTEM_NSS)"=="NO" .IF "$(GUI)"=="WNT" BIN_RUNTIMELIST+= \ @@ -164,7 +164,7 @@ DEFAULTS_RUNTIMELIST= \ greprefs$/all.js \ greprefs$/security-prefs.js -.IF "$(ENABLE_NSS_MODULE)"=="YES" +.IF "$(SYSTEM_NSS)"=="NO" #These headers come from the separate NSS module if enabled NSS_INCLUDE_LIST= @@ -205,7 +205,7 @@ LIBLIST= \ .ENDIF -.ELSE # .IF"$(ENABLE_NSS_MODULE)"=="YES" +.ELSE # .IF"$(SYSTEM_NSS)"=="NO" .IF "$(GUI)"=="WNT" .IF "$(COM)"=="GCC" @@ -258,7 +258,7 @@ LIBLIST= \ libsmime3$(DLLPOST) .ENDIF -.ENDIF # .IF "$(ENABLE_NSS_MODULE)"=="YES" +.ENDIF # .IF "$(SYSTEM_NSS)"=="NO" INCLUDE_PATH=$(MOZ_DIST_DIR)$/include$/ PUBLIC_PATH=$(MOZ_DIST_DIR)$/public$/ @@ -301,14 +301,14 @@ $(MISC)$/build$/so_moz_runtime_files: $(OUT)$/bin$/mozruntime.zip $(foreach,file,$(BIN_RUNTIMELIST) $(COPY) $(MOZ_BIN_DIR)$/$(DLLPRE)$(file)$(DLLPOST) \ $(LIB_DIR)$/$(DLLPRE)$(file)$(DLLPOST) &&) \ echo >& $(NULLDEV) -.IF "$(ENABLE_NSS_MODULE)" == "YES" +.IF "$(SYSTEM_NSS)" == "NO" # We add the libraries from the separate nss module $(foreach,file,$(NSS_MODULE_RUNTIME_LIST) $(COPY) $(SOLARLIBDIR)$/$(file:d:d)/$(DLLPRE)$(file:f)$(DLLPOST) \ $(RUNTIME_DIR)$/$(DLLPRE)$(file:f)$(DLLPOST) &&) \ echo >& $(NULLDEV) .ENDIF .ELSE # .IF "$(GUI)" == "UNX" -.IF "$(ENABLE_NSS_MODULE)" == "YES" +.IF "$(SYSTEM_NSS)" == "NO" # We add the libraries from the separate nss module $(foreach,file,$(NSS_MODULE_RUNTIME_LIST) $(COPY) $(SOLARBINDIR)$/$(DLLPRE)$(file)$(DLLPOST) \ $(RUNTIME_DIR)$/$(DLLPRE)$(file)$(DLLPOST) &&) \ @@ -407,7 +407,7 @@ $(MISC)$/build$/so_moz_include_files: $(INCCOM)$/nsBuildID.h chmod -R 775 $(INCCOM) .ENDIF $(TOUCH) $@ -.IF "$(ENABLE_NSS_MODULE)"=="YES" +.IF "$(SYSTEM_NSS)"=="NO" +$(foreach,dir,$(NSS_INCLUDE_LIST) $(RENAME:s/+//) $(INCLUDE_DIR)$/$(dir) $(INCLUDE_DIR)$/$(dir)_remove_me &&) echo >& $(NULLDEV) $(foreach,dir,$(NSS_INCLUDE_LIST) rm -rf $(INCLUDE_DIR)$/$(dir)_remove_me &&) echo >& $(NULLDEV) -$(MKDIR) $(OUT)$/inc.nss @@ -463,6 +463,6 @@ $(MISC)$/CREATETARBALL: extract_mozab_files .ENDIF cd $(LB) && zip -r ..$/zipped$/$(MOZTARGET)lib.zip * cd $(INCCOM) && zip -r ..$/zipped$/$(MOZTARGET)inc.zip * -.IF "$(ENABLE_NSS_MODULE)"=="YES" +.IF "$(SYSTEM_NSS)"=="NO" cd $(OUT)$/inc.nss && zip -r ..$/zipped$/$(MOZTARGET)inc.zip * .ENDIF diff --git a/moz/makefile.mk b/moz/makefile.mk index 020fa693208a..4487bc11004c 100644 --- a/moz/makefile.mk +++ b/moz/makefile.mk @@ -150,7 +150,7 @@ MOZILLA_CONFIGURE_FLAGS += --disable-tests \ --disable-pango \ --enable-extensions="pref" -.IF "$(ENABLE_NSS_MODULE)"=="YES" +.IF "$(SYSTEM_NSS)"=="NO" MOZILLA_CONFIGURE_FLAGS += \ --with-nss-prefix=$(OUTDIR) \ diff --git a/nss/makefile.mk b/nss/makefile.mk index 9fdc9e601074..bc7b827be1ae 100644 --- a/nss/makefile.mk +++ b/nss/makefile.mk @@ -36,9 +36,9 @@ TARGET=nss # --- Files -------------------------------------------------------- -.IF "$(ENABLE_NSS_MODULE)"!="YES" +.IF "$(SYSTEM_NSS)"=="YES" all: - @echo "NSS will not be built. ENABLE_NSS_MODULE is '$(ENABLE_NSS_MODULE)'" + @echo "NSS will not be built. Using system one instead." .ENDIF VER_MAJOR=3 diff --git a/nss/readme.txt b/nss/readme.txt index df65908204c4..21d7d5487221 100755 --- a/nss/readme.txt +++ b/nss/readme.txt @@ -4,7 +4,7 @@ nss containes the security libraries which are also part of moz. However nss is meant to be more current, that is it to be updated more often. This should be easier than doing this with moz. -If nss is build depends on an environment variable (ENABLE_NSS_MODULE=YES) which +If nss is build depends on an environment variable (SYSTEM_NSS=NO) which is per default set to YES. In this case nss is build before moz. The nss libraries/lib files/headers built in moz are then not delivered. Otherwise they would overwrite those from nss. That is, the nss libraries build in moz are diff --git a/set_soenv.in b/set_soenv.in index 2505e193e8f0..6a97b454a1cc 100755 --- a/set_soenv.in +++ b/set_soenv.in @@ -1476,7 +1476,7 @@ ToFile( "BUILD_MOZAB", "@BUILD_MOZAB@", "e" ); ToFile( "PREBUILD_MOZAB", $PREBUILD_MOZAB, "e" ); ToFile( "MOZILLA_VERSION", $MOZILLA_VERSION, "e" ); ToFile( "DEFAULT_MOZILLA_TOOLKIT", $MOZILLA_TOOLKIT, "e" ); -ToFile( "ENABLE_NSS_MODULE", "@ENABLE_NSS_MODULE@", "e" ); +ToFile( "SYSTEM_NSS", "@SYSTEM_NSS@", "e" ); ToFile( "MOZILLABUILD", "@MOZILLABUILD@", "e" ); ToFile( "BUILD_VER_STRING", "@BUILD_VER_STRING@", "e" ); if ($platform =~ m/linux/ && $platform =~ m/powerpc/) { @@ -1807,19 +1807,17 @@ ToFile( "DICT_SYSTEM_DIR", "@DICT_SYSTEM_DIR@", "e"); ToFile( "HYPH_SYSTEM_DIR", "@HYPH_SYSTEM_DIR@", "e"); ToFile( "THES_SYSTEM_DIR", "@THES_SYSTEM_DIR@", "e"); ToFile( "ENABLE_LOCKDOWN", "@ENABLE_LOCKDOWN@", "e" ); +ToFile( "ENABLE_XMLSEC", "@ENABLE_XMLSEC@", "e" ); ToFile( "WITH_LDAP", "@WITH_LDAP@", "e" ); ToFile( "WITH_OPENLDAP", "@WITH_OPENLDAP@", "e" ); ToFile( "WITH_MOZILLA", "@WITH_MOZILLA@", "e" ); ToFile( "SYSTEM_MOZILLA", "@SYSTEM_MOZILLA@", "e" ); ToFile( "MOZ_FLAVOUR", "@MOZ_FLAVOUR@", "e" ); -ToFile( "NSPR_LIB", "@NSPR_LIB@", "e" ); -ToFile( "NSS_LIB", "@NSS_LIB@", "e" ); +ToFile( "NSS_LIBS", "@NSS_LIBS@", "e" ); +ToFile( "NSS_CFLAGS", "@NSS_CFLAGS@", "e" ); ToFile( "MOZ_INC", "@MOZ_INC@", "e" ); ToFile( "MOZ_LIB", "@MOZ_LIB@", "e" ); ToFile( "MOZ_LIB_XPCOM", "@MOZ_LIB_XPCOM@", "e" ); -ToFile( "MOZ_NSPR_CFLAGS", "@MOZ_NSPR_CFLAGS@", "e" ); -ToFile( "MOZ_NSS_CFLAGS", "@MOZ_NSS_CFLAGS@", "e" ); -ToFile( "MOZ_NSS_LIBS", "@MOZ_NSS_LIBS@", "e" ); ToFile( "MOZ_LDAP_CFLAGS", "@MOZ_LDAP_CFLAGS@", "e" ); ToFile( "OOOP_GALLERY_PACK", "@OOOP_GALLERY_PACK@","e" ); ToFile( "OOOP_TEMPLATES_PACK", "@OOOP_TEMPLATES_PACK@","e" ); diff --git a/xmlsecurity/Library_xsec_xmlsec.mk b/xmlsecurity/Library_xsec_xmlsec.mk index f51fd9d9143c..90dcad0ee939 100644 --- a/xmlsecurity/Library_xsec_xmlsec.mk +++ b/xmlsecurity/Library_xsec_xmlsec.mk @@ -148,12 +148,11 @@ $(eval $(call gb_Library_add_exception_objects,xsec_xmlsec,\ endif # ifeq ($(GUI),WNT) -ifeq ($(SYSTEM_MOZILLA),YES) +ifeq ($(SYSTEM_NSS),YES) $(eval $(call gb_Library_set_include,xsec_xmlsec,\ $$(INCLUDE) \ - $(MOZ_NSPR_CFLAGS) \ - $(MOZ_NSS_CFLAGS) \ + $(NSS_CFLAGS) \ )) $(eval $(call gb_Library_add_defs,xsec_xmlsec,\ @@ -161,9 +160,7 @@ $(eval $(call gb_Library_add_defs,xsec_xmlsec,\ )) $(eval $(call gb_Library_add_libs,xsec_xmlsec,\ - $(NSPR_LIB) \ - $(NSS_LIB) \ - $(MOZ_NSS_LIBS) \ + $(NSS_LIBS) \ )) else @@ -179,7 +176,7 @@ $(eval $(call gb_Library_add_linked_libs,xsec_xmlsec,\ nss3 \ )) -endif # ifeq ($(SYSTEM_MOZILLA),YES) +endif # ifeq ($(SYSTEM_NSS),YES) ifeq ($(OS),SOLARIS) $(eval $(call gb_Library_add_linked_libs,xsec_xmlsec,\ diff --git a/xmlsecurity/Module_xmlsecurity.mk b/xmlsecurity/Module_xmlsecurity.mk index b32ff3b8fbbe..2e6e8d9bb571 100644 --- a/xmlsecurity/Module_xmlsecurity.mk +++ b/xmlsecurity/Module_xmlsecurity.mk @@ -32,7 +32,7 @@ $(eval $(call gb_Module_add_targets,xmlsecurity,\ AllLangResTarget_xsec \ Library_xmlsecurity \ Library_xsec_fw \ - $(if $(filter YES,$(ENABLE_NSS_MODULE) $(SYSTEM_MOZILLA)),Library_xsec_xmlsec) \ + Library_xsec_xmlsec \ )) # failing -- cgit