Kaydet (Commit) f461a9b0 authored tarafından Joseph Powers's avatar Joseph Powers

Remove DECLARE_LIST( XMLAttributeList, XMLAttribute * )

üst 5be744ad
...@@ -64,7 +64,6 @@ using namespace std; ...@@ -64,7 +64,6 @@ using namespace std;
#define MAX_LANGUAGES 99 #define MAX_LANGUAGES 99
//#define TESTDRIVER /* use xml2gsi testclass */
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
/** Holds data of Attributes /** Holds data of Attributes
...@@ -96,7 +95,7 @@ public: ...@@ -96,7 +95,7 @@ public:
} }
}; };
DECLARE_LIST( XMLAttributeList, XMLAttribute * ) typedef ::std::vector< XMLAttribute* > XMLAttributeList;
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
......
...@@ -57,11 +57,11 @@ interestingAttributes( XMLAttributeList* lst ) ...@@ -57,11 +57,11 @@ interestingAttributes( XMLAttributeList* lst )
{ {
std::vector<XMLAttribute*> interesting; std::vector<XMLAttribute*> interesting;
if ( lst ) if ( lst )
for ( ULONG i = 0; i < lst->Count(); i++ ) for ( size_t i = 0; i < lst->size(); i++ )
if ( lst->GetObject( i )->Equals( STRING( "id" ) ) ) if ( (*lst)[ i ]->Equals( STRING( "id" ) ) )
interesting.insert( interesting.begin(), lst->GetObject( i ) ); interesting.insert( interesting.begin(), (*lst)[ i ] );
else if ( ! BSTRING( *lst->GetObject( i ) ).CompareTo( "_", 1 ) ) else if ( ! BSTRING( *(*lst)[ i ]).CompareTo( "_", 1 ) )
interesting.push_back( lst->GetObject( i ) ); interesting.push_back( (*lst)[ i ] );
return interesting; return interesting;
} }
......
...@@ -166,9 +166,9 @@ void TranslateLayout::ParseCommandLine() ...@@ -166,9 +166,9 @@ void TranslateLayout::ParseCommandLine()
static XMLAttribute* static XMLAttribute*
findAttribute( XMLAttributeList* lst, String const& name ) findAttribute( XMLAttributeList* lst, String const& name )
{ {
for ( ULONG i = 0; i < lst->Count(); i++ ) for ( size_t i = 0; i < lst->size(); i++ )
if ( lst->GetObject( i )->Equals( name ) ) if ( (*lst)[ i ]->Equals( name ) )
return lst->GetObject( i ); return (*lst)[ i ];
return 0; return 0;
} }
...@@ -177,7 +177,17 @@ translateAttribute( XMLAttributeList* lst, ...@@ -177,7 +177,17 @@ translateAttribute( XMLAttributeList* lst,
String const& name, String const& translation ) String const& name, String const& translation )
{ {
if ( XMLAttribute* a = findAttribute( lst, name ) ) if ( XMLAttribute* a = findAttribute( lst, name ) )
return lst->Replace ( new XMLAttribute( name.Copy( 1 ), translation ), a ); {
for ( XMLAttributeList::iterator it = lst->begin(); it < lst->end(); ++it )
{
if ( *it == a )
{
delete *it;
*it = new XMLAttribute( name.Copy( 1 ), translation );
return *it;
}
}
}
return 0; return 0;
} }
......
...@@ -240,8 +240,8 @@ XMLElement *XMLParentNode::GetChildElement( XMLElement *pRefElement ) ...@@ -240,8 +240,8 @@ XMLElement *XMLParentNode::GetChildElement( XMLElement *pRefElement )
return ( XMLElement * ) pChild; return ( XMLElement * ) pChild;
BOOL bMatch = FALSE; BOOL bMatch = FALSE;
for ( ULONG j = 0; j < pList->Count() && bMatch; j++ ) { for ( size_t j = 0; j < pList->size() && bMatch; j++ ) {
XMLAttribute *pAttribute = pList->GetObject( j ); XMLAttribute *pAttribute = (*pList)[ j ];
XMLAttribute *pCandidate = XMLAttribute *pCandidate =
(( XMLElement * ) pChild )->GetAttribute( (( XMLElement * ) pChild )->GetAttribute(
*pAttribute ); *pAttribute );
...@@ -278,7 +278,6 @@ BOOL XMLFile::Write( ByteString &aFilename ) ...@@ -278,7 +278,6 @@ BOOL XMLFile::Write( ByteString &aFilename )
if( !aFStream ) // From time to time the stream can not be opened the first time on NFS volumes, if( !aFStream ) // From time to time the stream can not be opened the first time on NFS volumes,
{ // I wasn't able to track this down. I think this is an NFS issue ..... { // I wasn't able to track this down. I think this is an NFS issue .....
//cerr << "ERROR: - helpex - Can't write to tempfile " << aFilename.GetBuffer() << " No#" << x << "\n";
TimeValue aTime; TimeValue aTime;
aTime.Seconds = 3; aTime.Seconds = 3;
aTime.Nanosec = 0; aTime.Nanosec = 0;
...@@ -298,7 +297,6 @@ BOOL XMLFile::Write( ByteString &aFilename ) ...@@ -298,7 +297,6 @@ BOOL XMLFile::Write( ByteString &aFilename )
if( aFileStat.GetSize() < 1 ) if( aFileStat.GetSize() < 1 )
{ {
//retry //retry
//cerr << "WARNING: - helpex - Can't create file " << aFilename.GetBuffer() << " No#" << x << "\n";
aTarget.Kill(); aTarget.Kill();
} }
else else
...@@ -344,13 +342,13 @@ BOOL XMLFile::Write( ofstream &rStream , XMLNode *pCur ) ...@@ -344,13 +342,13 @@ BOOL XMLFile::Write( ofstream &rStream , XMLNode *pCur )
rStream << "<"; rStream << "<";
WriteString( rStream, pElement->GetName()); WriteString( rStream, pElement->GetName());
if ( pElement->GetAttributeList()) if ( pElement->GetAttributeList())
for ( ULONG j = 0; j < pElement->GetAttributeList()->Count(); j++ ) { for ( size_t j = 0; j < pElement->GetAttributeList()->size(); j++ ) {
rStream << " "; rStream << " ";
String sData(*pElement->GetAttributeList()->GetObject( j )); String sData(* (*pElement->GetAttributeList())[ j ] );
xmlutil.QuotHTML( sData ); xmlutil.QuotHTML( sData );
WriteString( rStream , sData ); WriteString( rStream , sData );
rStream << "=\""; rStream << "=\"";
sData=pElement->GetAttributeList()->GetObject( j )->GetValue(); sData = (*pElement->GetAttributeList())[ j ]->GetValue();
xmlutil.QuotHTML( sData ); xmlutil.QuotHTML( sData );
WriteString( rStream , sData ); WriteString( rStream , sData );
rStream << "\""; rStream << "\"";
...@@ -410,12 +408,12 @@ void XMLFile::Print( XMLNode *pCur, USHORT nLevel ) ...@@ -410,12 +408,12 @@ void XMLFile::Print( XMLNode *pCur, USHORT nLevel )
fprintf( stdout, "<%s", ByteString( pElement->GetName(), RTL_TEXTENCODING_UTF8 ).GetBuffer()); fprintf( stdout, "<%s", ByteString( pElement->GetName(), RTL_TEXTENCODING_UTF8 ).GetBuffer());
if ( pElement->GetAttributeList()) if ( pElement->GetAttributeList())
for ( ULONG j = 0; j < pElement->GetAttributeList()->Count(); j++ ){ for ( size_t j = 0; j < pElement->GetAttributeList()->size(); j++ ){
ByteString aAttrName( *pElement->GetAttributeList()->GetObject( j ), RTL_TEXTENCODING_UTF8 ); ByteString aAttrName( *(*pElement->GetAttributeList())[ j ], RTL_TEXTENCODING_UTF8 );
if( !aAttrName.EqualsIgnoreCaseAscii( XML_LANG ) ) { if( !aAttrName.EqualsIgnoreCaseAscii( XML_LANG ) ) {
fprintf( stdout, " %s=\"%s\"", fprintf( stdout, " %s=\"%s\"",
aAttrName.GetBuffer(), aAttrName.GetBuffer(),
ByteString( pElement->GetAttributeList()->GetObject( j )->GetValue(), ByteString( (*pElement->GetAttributeList())[ j ]->GetValue(),
RTL_TEXTENCODING_UTF8 ).GetBuffer()); RTL_TEXTENCODING_UTF8 ).GetBuffer());
} }
} }
...@@ -470,7 +468,6 @@ XMLFile::XMLFile( const String &rFileName ) // the file name, empty if created f ...@@ -470,7 +468,6 @@ XMLFile::XMLFile( const String &rFileName ) // the file name, empty if created f
XMLStrings ( NULL ) XMLStrings ( NULL )
{ {
// nodes_localize.insert( TagMap::value_type(ByteString(String::CreateFromAscii("bookmark_value"),RTL_TEXTENCODING_ASCII_US) , TRUE) );
nodes_localize.insert( TagMap::value_type(ByteString(String::CreateFromAscii("bookmark"),RTL_TEXTENCODING_ASCII_US) , TRUE) ); nodes_localize.insert( TagMap::value_type(ByteString(String::CreateFromAscii("bookmark"),RTL_TEXTENCODING_ASCII_US) , TRUE) );
nodes_localize.insert( TagMap::value_type(ByteString(String::CreateFromAscii("variable"),RTL_TEXTENCODING_ASCII_US) , TRUE) ); nodes_localize.insert( TagMap::value_type(ByteString(String::CreateFromAscii("variable"),RTL_TEXTENCODING_ASCII_US) , TRUE) );
nodes_localize.insert( TagMap::value_type(ByteString(String::CreateFromAscii("paragraph"),RTL_TEXTENCODING_ASCII_US) , TRUE) ); nodes_localize.insert( TagMap::value_type(ByteString(String::CreateFromAscii("paragraph"),RTL_TEXTENCODING_ASCII_US) , TRUE) );
...@@ -518,13 +515,13 @@ void XMLFile::InsertL10NElement( XMLElement* pElement ){ ...@@ -518,13 +515,13 @@ void XMLFile::InsertL10NElement( XMLElement* pElement ){
LangHashMap* elem; LangHashMap* elem;
if( pElement->GetAttributeList() != NULL ){ if( pElement->GetAttributeList() != NULL ){
for ( ULONG j = 0; j < pElement->GetAttributeList()->Count(); j++ ){ for ( size_t j = 0; j < pElement->GetAttributeList()->size(); j++ ){
tmpStr=ByteString( *pElement->GetAttributeList()->GetObject( j ),RTL_TEXTENCODING_UTF8 ); tmpStr=ByteString( *(*pElement->GetAttributeList())[ j ], RTL_TEXTENCODING_UTF8 );
if( tmpStr.CompareTo(ID)==COMPARE_EQUAL ){ // Get the "id" Attribute if( tmpStr.CompareTo(ID)==COMPARE_EQUAL ){ // Get the "id" Attribute
id = ByteString( pElement->GetAttributeList()->GetObject( j )->GetValue(),RTL_TEXTENCODING_UTF8 ); id = ByteString( (*pElement->GetAttributeList())[ j ]->GetValue(),RTL_TEXTENCODING_UTF8 );
} }
if( tmpStr.CompareTo( XML_LANG ) == COMPARE_EQUAL ){ // Get the "xml-lang" Attribute if( tmpStr.CompareTo( XML_LANG ) == COMPARE_EQUAL ){ // Get the "xml-lang" Attribute
language = ByteString( pElement->GetAttributeList()->GetObject( j )->GetValue(),RTL_TEXTENCODING_UTF8 ); language = ByteString( (*pElement->GetAttributeList())[ j ]->GetValue(),RTL_TEXTENCODING_UTF8 );
} }
} }
...@@ -646,20 +643,19 @@ void XMLFile::SearchL10NElements( XMLParentNode *pCur , int pos) ...@@ -646,20 +643,19 @@ void XMLFile::SearchL10NElements( XMLParentNode *pCur , int pos)
ByteString sName(pElement->GetName(),RTL_TEXTENCODING_ASCII_US); ByteString sName(pElement->GetName(),RTL_TEXTENCODING_ASCII_US);
ByteString language,tmpStrVal,oldref; ByteString language,tmpStrVal,oldref;
if ( pElement->GetAttributeList()){ if ( pElement->GetAttributeList()){
for ( ULONG j = 0 , cnt = pElement->GetAttributeList()->Count(); j < cnt && bInsert; j++ ){ for ( size_t j = 0 , cnt = pElement->GetAttributeList()->size(); j < cnt && bInsert; j++ ){
const ByteString tmpStr( *pElement->GetAttributeList()->GetObject( j ),RTL_TEXTENCODING_UTF8 ); const ByteString tmpStr( *(*pElement->GetAttributeList())[ j ],RTL_TEXTENCODING_UTF8 );
if( tmpStr.CompareTo(THEID)==COMPARE_EQUAL ){ // Get the "id" Attribute if( tmpStr.CompareTo(THEID)==COMPARE_EQUAL ){ // Get the "id" Attribute
tmpStrVal=ByteString( pElement->GetAttributeList()->GetObject( j )->GetValue(),RTL_TEXTENCODING_UTF8 ); tmpStrVal=ByteString( (*pElement->GetAttributeList())[ j ]->GetValue(),RTL_TEXTENCODING_UTF8 );
//printf("Checking id = %s\n",tmpStrVal.GetBuffer() );
} }
if( tmpStr.CompareTo(LOCALIZE)==COMPARE_EQUAL ){ // Get the "localize" Attribute if( tmpStr.CompareTo(LOCALIZE)==COMPARE_EQUAL ){ // Get the "localize" Attribute
bInsert=false; bInsert=false;
} }
if( tmpStr.CompareTo(XML_LANG)==COMPARE_EQUAL ){ // Get the "xml-lang" Attribute if( tmpStr.CompareTo(XML_LANG)==COMPARE_EQUAL ){ // Get the "xml-lang" Attribute
language=ByteString( pElement->GetAttributeList()->GetObject( j )->GetValue(),RTL_TEXTENCODING_UTF8 ); language=ByteString( (*pElement->GetAttributeList())[ j ]->GetValue(),RTL_TEXTENCODING_UTF8 );
} }
if( tmpStr.CompareTo(OLDREF)==COMPARE_EQUAL ){ // Get the "oldref" Attribute if( tmpStr.CompareTo(OLDREF)==COMPARE_EQUAL ){ // Get the "oldref" Attribute
oldref=ByteString( pElement->GetAttributeList()->GetObject( j )->GetValue(),RTL_TEXTENCODING_UTF8 ); oldref=ByteString( (*pElement->GetAttributeList())[ j ]->GetValue(),RTL_TEXTENCODING_UTF8 );
} }
} }
pElement->SetLanguageId ( language ); pElement->SetLanguageId ( language );
...@@ -720,10 +716,10 @@ bool XMLFile::CheckExportStatus( XMLParentNode *pCur ) ...@@ -720,10 +716,10 @@ bool XMLFile::CheckExportStatus( XMLParentNode *pCur )
ByteString sName(pElement->GetName(),RTL_TEXTENCODING_ASCII_US); ByteString sName(pElement->GetName(),RTL_TEXTENCODING_ASCII_US);
if( sName.EqualsIgnoreCaseAscii( TOPIC ) ){ if( sName.EqualsIgnoreCaseAscii( TOPIC ) ){
if ( pElement->GetAttributeList()){ if ( pElement->GetAttributeList()){
for ( ULONG j = 0 , cnt = pElement->GetAttributeList()->Count(); j < cnt && bInsert; j++ ){ for ( size_t j = 0 , cnt = pElement->GetAttributeList()->size(); j < cnt && bInsert; j++ ){
const ByteString tmpStr( *pElement->GetAttributeList()->GetObject( j ),RTL_TEXTENCODING_UTF8 ); const ByteString tmpStr( *(*pElement->GetAttributeList())[ j ],RTL_TEXTENCODING_UTF8 );
if( tmpStr.EqualsIgnoreCaseAscii( STATUS ) ){ if( tmpStr.EqualsIgnoreCaseAscii( STATUS ) ){
ByteString tmpStrVal=ByteString( pElement->GetAttributeList()->GetObject( j )->GetValue(),RTL_TEXTENCODING_UTF8 ); ByteString tmpStrVal=ByteString( (*pElement->GetAttributeList())[ j ]->GetValue(),RTL_TEXTENCODING_UTF8 );
if( !tmpStrVal.EqualsIgnoreCaseAscii( PUBLISH ) && if( !tmpStrVal.EqualsIgnoreCaseAscii( PUBLISH ) &&
!tmpStrVal.EqualsIgnoreCaseAscii( DEPRECATED )){ !tmpStrVal.EqualsIgnoreCaseAscii( DEPRECATED )){
bStatusExport = false; bStatusExport = false;
...@@ -769,8 +765,8 @@ XMLElement::XMLElement(const XMLElement& obj) ...@@ -769,8 +765,8 @@ XMLElement::XMLElement(const XMLElement& obj)
{ {
if ( obj.pAttributes ){ if ( obj.pAttributes ){
pAttributes = new XMLAttributeList(); pAttributes = new XMLAttributeList();
for ( ULONG i = 0; i < obj.pAttributes->Count(); i++ ) for ( size_t i = 0; i < obj.pAttributes->size(); i++ )
AddAttribute( *obj.pAttributes->GetObject( i ) , obj.pAttributes->GetObject( i )->GetValue() ); AddAttribute( *(*obj.pAttributes)[ i ], (*obj.pAttributes)[ i ]->GetValue() );
} }
} }
...@@ -789,14 +785,14 @@ XMLElement& XMLElement::operator=(const XMLElement& obj){ ...@@ -789,14 +785,14 @@ XMLElement& XMLElement::operator=(const XMLElement& obj){
nPos =obj.nPos; nPos =obj.nPos;
if ( pAttributes ){ if ( pAttributes ){
for ( ULONG i = 0; i < pAttributes->Count(); i++ ) for ( size_t i = 0; i < pAttributes->size(); i++ )
delete pAttributes->GetObject( i ); delete (*pAttributes)[ i ];
delete pAttributes; delete pAttributes;
} }
if ( obj.pAttributes ){ if ( obj.pAttributes ){
pAttributes =new XMLAttributeList(); pAttributes =new XMLAttributeList();
for ( ULONG i = 0; i < obj.pAttributes->Count(); i++ ) for ( size_t i = 0; i < obj.pAttributes->size(); i++ )
AddAttribute( *obj.pAttributes->GetObject( i ) , obj.pAttributes->GetObject( i )->GetValue() ); AddAttribute( *(*obj.pAttributes)[ i ], (*obj.pAttributes)[ i ]->GetValue() );
} }
} }
return *this; return *this;
...@@ -808,7 +804,7 @@ void XMLElement::AddAttribute( const String &rAttribute, const String &rValue ) ...@@ -808,7 +804,7 @@ void XMLElement::AddAttribute( const String &rAttribute, const String &rValue )
{ {
if ( !pAttributes ) if ( !pAttributes )
pAttributes = new XMLAttributeList(); pAttributes = new XMLAttributeList();
pAttributes->Insert( new XMLAttribute( rAttribute, rValue ), LIST_APPEND ); pAttributes->push_back( new XMLAttribute( rAttribute, rValue ) );
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -817,9 +813,9 @@ void XMLElement::ChangeLanguageTag( const String &rValue ){ ...@@ -817,9 +813,9 @@ void XMLElement::ChangeLanguageTag( const String &rValue ){
static const String rName = String::CreateFromAscii("xml-lang"); static const String rName = String::CreateFromAscii("xml-lang");
SetLanguageId( ByteString(rValue,RTL_TEXTENCODING_UTF8) ); SetLanguageId( ByteString(rValue,RTL_TEXTENCODING_UTF8) );
if ( pAttributes ){ if ( pAttributes ){
for ( ULONG i = 0; i < pAttributes->Count(); i++ ){ for ( size_t i = 0; i < pAttributes->size(); i++ ){
if ( *pAttributes->GetObject( i ) == rName ){ if ( *(*pAttributes)[ i ] == rName ){
pAttributes->GetObject( i )->setValue(rValue); (*pAttributes)[ i ]->setValue(rValue);
} }
} }
} }
...@@ -846,9 +842,9 @@ XMLAttribute *XMLElement::GetAttribute( const String &rName ) ...@@ -846,9 +842,9 @@ XMLAttribute *XMLElement::GetAttribute( const String &rName )
/*****************************************************************************/ /*****************************************************************************/
{ {
if ( pAttributes ) if ( pAttributes )
for ( ULONG i = 0; i < pAttributes->Count(); i++ ) for ( size_t i = 0; i < pAttributes->size(); i++ )
if ( *pAttributes->GetObject( i ) == rName ) if ( *(*pAttributes)[ i ] == rName )
return pAttributes->GetObject( i ); return (*pAttributes)[ i ];
return NULL; return NULL;
} }
...@@ -858,8 +854,8 @@ XMLElement::~XMLElement() ...@@ -858,8 +854,8 @@ XMLElement::~XMLElement()
/*****************************************************************************/ /*****************************************************************************/
{ {
if ( pAttributes ) { if ( pAttributes ) {
for ( ULONG i = 0; i < pAttributes->Count(); i++ ) for ( size_t i = 0; i < pAttributes->size(); i++ )
delete pAttributes->GetObject( i ); delete (*pAttributes)[ i ];
delete pAttributes; delete pAttributes;
pAttributes = NULL; pAttributes = NULL;
...@@ -924,15 +920,15 @@ void XMLElement::Print(XMLNode *pCur, OUStringBuffer& buffer , bool rootelement ...@@ -924,15 +920,15 @@ void XMLElement::Print(XMLNode *pCur, OUStringBuffer& buffer , bool rootelement
buffer.append( OUString(RTL_CONSTASCII_USTRINGPARAM("\\<")) ); buffer.append( OUString(RTL_CONSTASCII_USTRINGPARAM("\\<")) );
buffer.append( pElement->GetName() ); buffer.append( pElement->GetName() );
if ( pElement->GetAttributeList()){ if ( pElement->GetAttributeList()){
for ( ULONG j = 0; j < pElement->GetAttributeList()->Count(); j++ ){ for ( size_t j = 0; j < pElement->GetAttributeList()->size(); j++ ){
OUString aAttrName( *pElement->GetAttributeList()->GetObject( j ) ); OUString aAttrName( *(*pElement->GetAttributeList())[ j ] );
if( !aAttrName.equalsIgnoreAsciiCase( XML_LANG ) ) { if( !aAttrName.equalsIgnoreAsciiCase( XML_LANG ) ) {
buffer.append( OUString(RTL_CONSTASCII_USTRINGPARAM(" ")) ); buffer.append( OUString(RTL_CONSTASCII_USTRINGPARAM(" ")) );
buffer.append( aAttrName ); buffer.append( aAttrName );
buffer.append( OUString(RTL_CONSTASCII_USTRINGPARAM("=")) ); buffer.append( OUString(RTL_CONSTASCII_USTRINGPARAM("=")) );
buffer.append( OUString(RTL_CONSTASCII_USTRINGPARAM("\\\"")) ); buffer.append( OUString(RTL_CONSTASCII_USTRINGPARAM("\\\"")) );
buffer.append( pElement->GetAttributeList()->GetObject( j )->GetValue() ); buffer.append( (*pElement->GetAttributeList())[ j ]->GetValue() );
buffer.append( OUString(RTL_CONSTASCII_USTRINGPARAM("\\\"")) ); buffer.append( OUString(RTL_CONSTASCII_USTRINGPARAM("\\\"")) );
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment