1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
15 const OString
& rText
, const OString
& rUnEscaped
, const OString
& rEscaped
)
17 assert( rEscaped
.getLength() == 2*rUnEscaped
.getLength() );
18 OStringBuffer sReturn
;
19 for ( sal_Int32 nIndex
= 0; nIndex
< rText
.getLength(); ++nIndex
)
21 sal_Int32 nUnEscapedOne
= rUnEscaped
.indexOf(rText
[nIndex
]);
22 if( nUnEscapedOne
!= -1 )
24 sReturn
.append(rEscaped
.copy(nUnEscapedOne
*2,2));
27 sReturn
.append(rText
[nIndex
]);
29 return sReturn
.makeStringAndClear();
34 const OString
& rText
, const OString
& rEscaped
, const OString
& rUnEscaped
)
36 assert( rEscaped
.getLength() == 2*rUnEscaped
.getLength() );
37 OStringBuffer sReturn
;
38 const sal_Int32 nLength
= rText
.getLength();
39 for ( sal_Int32 nIndex
= 0; nIndex
< nLength
; ++nIndex
)
41 if( rText
[nIndex
] == '\\' && nIndex
+1 < nLength
)
43 sal_Int32 nEscapedOne
= rEscaped
.indexOf(rText
.copy(nIndex
,2));
44 if( nEscapedOne
!= -1 )
46 sReturn
.append(rUnEscaped
[nEscapedOne
/2]);
51 sReturn
.append(rText
[nIndex
]);
55 sReturn
.append(rText
[nIndex
]);
57 return sReturn
.makeStringAndClear();
61 OString
QuotHTML(const OString
&rString
)
63 OStringBuffer sReturn
;
64 for (sal_Int32 i
= 0; i
< rString
.getLength(); ++i
)
69 sReturn
.append("<");
72 sReturn
.append(">");
75 sReturn
.append(""");
78 sReturn
.append("'");
81 if (rString
.match("&", i
))
84 sReturn
.append("&");
87 sReturn
.append(rString
[i
]);
91 return sReturn
.makeStringAndClear();
94 OString
UnQuotHTML( const OString
& rString
)
96 OStringBuffer sReturn
;
97 for (sal_Int32 i
= 0; i
!= rString
.getLength();) {
98 if (rString
.match("&", i
)) {
100 i
+= RTL_CONSTASCII_LENGTH("&");
101 } else if (rString
.match("<", i
)) {
103 i
+= RTL_CONSTASCII_LENGTH("<");
104 } else if (rString
.match(">", i
)) {
106 i
+= RTL_CONSTASCII_LENGTH(">");
107 } else if (rString
.match(""", i
)) {
109 i
+= RTL_CONSTASCII_LENGTH(""");
110 } else if (rString
.match("'", i
)) {
111 sReturn
.append('\'');
112 i
+= RTL_CONSTASCII_LENGTH("'");
114 sReturn
.append(rString
[i
]);
118 return sReturn
.makeStringAndClear();
121 bool isWellFormedXML( OString
const & text
)
129 content
+= "</root>";
130 doc
= xmlParseMemory(content
.getStr(),(int)content
.getLength());
139 //Convert xmlChar* to OString
140 OString
xmlStrToOString( const xmlChar
* pString
)
142 xmlChar
* pTemp
= xmlStrdup( pString
);
144 static_cast<OString
>(reinterpret_cast<sal_Char
*>( pTemp
));
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */