Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
76eac882
Kaydet (Commit)
76eac882
authored
Ock 19, 2011
tarafından
Michael Stahl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
xmlfix3: unoxml: CDocumentBuilder cleanup
üst
75b70f14
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
39 deletions
+25
-39
documentbuilder.cxx
unoxml/source/dom/documentbuilder.cxx
+25
-39
No files found.
unoxml/source/dom/documentbuilder.cxx
Dosyayı görüntüle @
76eac882
...
...
@@ -34,6 +34,7 @@
#include <libxml/xmlerror.h>
#include <libxml/tree.h>
#include <boost/shared_ptr.hpp>
#include <rtl/alloc.h>
#include <rtl/memory.h>
...
...
@@ -62,21 +63,6 @@ using ::com::sun::star::task::XInteractionHandler;
namespace
DOM
{
extern
"C"
{
//char *strdup(const char *s);
/*
static char* strdupfunc(const char* s)
{
sal_Int32 len = 0;
while (s[len] != '\0') len++;
char *newStr = (char*)rtl_allocateMemory(len+1);
if (newStr != NULL)
rtl_copyMemory(newStr, s, len+1);
return newStr;
}
*/
}
class
CDefaultEntityResolver
:
public
cppu
::
WeakImplHelper1
<
XEntityResolver
>
{
...
...
@@ -118,7 +104,6 @@ namespace DOM
Reference
<
XInterface
>
CDocumentBuilder
::
_getInstance
(
const
Reference
<
XMultiServiceFactory
>&
rSMgr
)
{
// XXX
return
static_cast
<
XDocumentBuilder
*
>
(
new
CDocumentBuilder
(
rSMgr
));
}
...
...
@@ -324,7 +309,6 @@ namespace DOM
void
throwEx
(
xmlParserCtxtPtr
ctxt
)
{
OUString
msg
=
make_error_message
(
ctxt
);
xmlFreeParserCtxt
(
ctxt
);
com
::
sun
::
star
::
xml
::
sax
::
SAXParseException
saxex
;
saxex
.
Message
=
msg
;
saxex
.
LineNumber
=
static_cast
<
sal_Int32
>
(
ctxt
->
lastError
.
line
);
...
...
@@ -343,14 +327,15 @@ namespace DOM
xmlCharEncoding enc = xmlParseCharEncoding(encstr);
*/
xmlParserCtxtPtr
ctxt
=
xmlNewParserCtxt
();
::
boost
::
shared_ptr
<
xmlParserCtxt
>
const
pContext
(
xmlNewParserCtxt
(),
xmlFreeParserCtxt
);
// register error functions to prevent errors being printed
// on the console
ct
xt
->
_private
=
this
;
ct
xt
->
sax
->
error
=
error_func
;
ct
xt
->
sax
->
warning
=
warning_func
;
ct
xt
->
sax
->
resolveEntity
=
resolve_func
;
pConte
xt
->
_private
=
this
;
pConte
xt
->
sax
->
error
=
error_func
;
pConte
xt
->
sax
->
warning
=
warning_func
;
pConte
xt
->
sax
->
resolveEntity
=
resolve_func
;
// IO context struct
context_t
c
;
...
...
@@ -359,13 +344,12 @@ namespace DOM
// we did not open the stream, thus we do not close it.
c
.
close
=
false
;
c
.
freeOnClose
=
false
;
xmlDocPtr
pDoc
=
xmlCtxtReadIO
(
ctxt
,
xmlIO_read_func
,
xmlIO_close_func
,
&
c
,
0
,
0
,
0
);
xmlDocPtr
const
pDoc
=
xmlCtxtReadIO
(
pContext
.
get
()
,
xmlIO_read_func
,
xmlIO_close_func
,
&
c
,
0
,
0
,
0
);
if
(
pDoc
==
0
)
{
throwEx
(
ctxt
);
throwEx
(
pContext
.
get
()
);
}
xmlFreeParserCtxt
(
ctxt
);
Reference
<
XDocument
>
const
xRet
(
CDocument
::
CreateCDocument
(
pDoc
).
get
());
return
xRet
;
...
...
@@ -385,15 +369,17 @@ namespace DOM
}
// set up parser context
xmlParserCtxtPtr
ctxt
=
xmlNewParserCtxt
();
::
boost
::
shared_ptr
<
xmlParserCtxt
>
const
pContext
(
xmlNewParserCtxt
(),
xmlFreeParserCtxt
);
// register error functions to prevent errors being printed
// on the console
ct
xt
->
_private
=
this
;
ct
xt
->
sax
->
error
=
error_func
;
ct
xt
->
sax
->
warning
=
warning_func
;
pConte
xt
->
_private
=
this
;
pConte
xt
->
sax
->
error
=
error_func
;
pConte
xt
->
sax
->
warning
=
warning_func
;
// setup entity resolver binding(s)
ct
xt
->
sax
->
resolveEntity
=
resolve_func
;
pConte
xt
->
sax
->
resolveEntity
=
resolve_func
;
xmlSetExternalEntityLoader
(
external_entity_loader
);
// if an input stream is provided, use it
...
...
@@ -408,19 +394,19 @@ namespace DOM
{
::
osl
::
MutexGuard
const
g
(
m_Mutex
);
xmlParserCtxtPtr
ctxt
=
xmlNewParserCtxt
();
ctxt
->
_private
=
this
;
ctxt
->
sax
->
error
=
error_func
;
ctxt
->
sax
->
warning
=
warning_func
;
ctxt
->
sax
->
resolveEntity
=
resolve_func
;
::
boost
::
shared_ptr
<
xmlParserCtxt
>
const
pContext
(
xmlNewParserCtxt
(),
xmlFreeParserCtxt
);
pContext
->
_private
=
this
;
pContext
->
sax
->
error
=
error_func
;
pContext
->
sax
->
warning
=
warning_func
;
pContext
->
sax
->
resolveEntity
=
resolve_func
;
// xmlSetExternalEntityLoader(external_entity_loader);
OString
oUri
=
OUStringToOString
(
sUri
,
RTL_TEXTENCODING_UTF8
);
char
*
uri
=
(
char
*
)
oUri
.
getStr
();
xmlDocPtr
pDoc
=
xmlCtxtReadFile
(
ctxt
,
uri
,
0
,
0
);
xmlDocPtr
pDoc
=
xmlCtxtReadFile
(
pContext
.
get
()
,
uri
,
0
,
0
);
if
(
pDoc
==
0
)
{
throwEx
(
ctxt
);
throwEx
(
pContext
.
get
()
);
}
xmlFreeParserCtxt
(
ctxt
);
Reference
<
XDocument
>
const
xRet
(
CDocument
::
CreateCDocument
(
pDoc
).
get
());
return
xRet
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment