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
8ba3116a
Kaydet (Commit)
8ba3116a
authored
Haz 17, 2014
tarafından
Andrzej Hunt
Kaydeden (comit)
Michael Meeks
Haz 17, 2014
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
LOK: Split into instance and class.
Change-Id: I2b6f33eaf12343c7da1328a932eb703bb4e4ef6f
üst
5df0bfdd
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
28 deletions
+61
-28
init.cxx
desktop/source/lib/init.cxx
+34
-10
LibreOfficeKit.h
include/LibreOfficeKit/LibreOfficeKit.h
+15
-2
LibreOfficeKit.hxx
include/LibreOfficeKit/LibreOfficeKit.hxx
+8
-12
shim.c
libreofficekit/source/shim.c
+1
-1
libtest.cxx
smoketest/libtest.cxx
+3
-3
No files found.
desktop/source/lib/init.cxx
Dosyayı görüntüle @
8ba3116a
...
@@ -13,6 +13,9 @@
...
@@ -13,6 +13,9 @@
#include <string.h>
#include <string.h>
#include <stdlib.h>
#include <stdlib.h>
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
#include <LibreOfficeKit/LibreOfficeKit.h>
#include <LibreOfficeKit/LibreOfficeKit.h>
#include <tools/errinf.hxx>
#include <tools/errinf.hxx>
...
@@ -42,10 +45,14 @@
...
@@ -42,10 +45,14 @@
using
namespace
css
;
using
namespace
css
;
using
namespace
utl
;
using
namespace
utl
;
using
namespace
boost
;
struct
LibLODocument_Impl
;
struct
LibLODocument_Impl
;
struct
LibLibreOffice_Impl
;
struct
LibLibreOffice_Impl
;
static
LibLibreOffice_Impl
*
gImpl
=
NULL
;
static
LibLibreOffice_Impl
*
gImpl
=
NULL
;
static
weak_ptr
<
LibreOfficeKitClass
>
gOfficeClass
;
static
weak_ptr
<
LibreOfficeKitDocumentClass
>
gDocumentClass
;
typedef
struct
typedef
struct
{
{
...
@@ -151,15 +158,24 @@ static int doc_saveAsWithOptions(LibreOfficeKitDocument* pThis, const char* pUr
...
@@ -151,15 +158,24 @@ static int doc_saveAsWithOptions(LibreOfficeKitDocument* pThis, const char* pUr
struct
LibLODocument_Impl
:
public
_LibreOfficeKitDocument
struct
LibLODocument_Impl
:
public
_LibreOfficeKitDocument
{
{
uno
::
Reference
<
css
::
lang
::
XComponent
>
mxComponent
;
uno
::
Reference
<
css
::
lang
::
XComponent
>
mxComponent
;
shared_ptr
<
LibreOfficeKitDocumentClass
>
m_pDocumentClass
;
LibLODocument_Impl
(
const
uno
::
Reference
<
css
::
lang
::
XComponent
>
&
xComponent
)
:
LibLODocument_Impl
(
const
uno
::
Reference
<
css
::
lang
::
XComponent
>
&
xComponent
)
:
mxComponent
(
xComponent
)
mxComponent
(
xComponent
)
{
{
nSize
=
sizeof
(
LibreOfficeKitDocument
);
if
(
!
(
m_pDocumentClass
=
gDocumentClass
.
lock
()))
{
m_pDocumentClass
.
reset
(
new
LibreOfficeKitDocumentClass
);
m_pDocumentClass
->
nSize
=
sizeof
(
LibreOfficeKitDocument
);
m_pDocumentClass
->
destroy
=
doc_destroy
;
m_pDocumentClass
->
saveAs
=
doc_saveAs
;
m_pDocumentClass
->
saveAsWithOptions
=
doc_saveAsWithOptions
;
destroy
=
doc_destroy
;
gDocumentClass
=
m_pDocumentClass
;
saveAs
=
doc_saveAs
;
}
saveAsWithOptions
=
doc_saveAsWithOptions
;
pClass
=
m_pDocumentClass
.
get
()
;
}
}
~
LibLODocument_Impl
()
~
LibLODocument_Impl
()
...
@@ -182,15 +198,23 @@ static char * lo_getError (LibreOfficeKit* pThis);
...
@@ -182,15 +198,23 @@ static char * lo_getError (LibreOfficeKit* pThis);
struct
LibLibreOffice_Impl
:
public
_LibreOfficeKit
struct
LibLibreOffice_Impl
:
public
_LibreOfficeKit
{
{
OUString
maLastExceptionMsg
;
OUString
maLastExceptionMsg
;
shared_ptr
<
LibreOfficeKitClass
>
m_pOfficeClass
;
LibLibreOffice_Impl
()
LibLibreOffice_Impl
()
{
{
nSize
=
sizeof
(
LibreOfficeKit
);
if
(
!
(
m_pOfficeClass
=
gOfficeClass
.
lock
()))
{
m_pOfficeClass
.
reset
(
new
LibreOfficeKitClass
);
m_pOfficeClass
->
nSize
=
sizeof
(
LibreOfficeKitClass
);
m_pOfficeClass
->
destroy
=
lo_destroy
;
m_pOfficeClass
->
initialize
=
lo_initialize
;
m_pOfficeClass
->
documentLoad
=
lo_documentLoad
;
m_pOfficeClass
->
getError
=
lo_getError
;
gOfficeClass
=
m_pOfficeClass
;
}
destroy
=
lo_destroy
;
pClass
=
m_pOfficeClass
.
get
();
initialize
=
lo_initialize
;
documentLoad
=
lo_documentLoad
;
getError
=
lo_getError
;
}
}
};
};
...
@@ -416,7 +440,7 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath)
...
@@ -416,7 +440,7 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath)
return
bInitialized
;
return
bInitialized
;
}
}
SAL_DLLPUBLIC_EXPORT
LibreOfficeKit
*
lib
libreoffice
_hook
(
void
)
SAL_DLLPUBLIC_EXPORT
LibreOfficeKit
*
lib
reofficekit
_hook
(
void
)
{
{
if
(
!
gImpl
)
if
(
!
gImpl
)
{
{
...
...
include/LibreOfficeKit/LibreOfficeKit.h
Dosyayı görüntüle @
8ba3116a
...
@@ -18,16 +18,24 @@ extern "C"
...
@@ -18,16 +18,24 @@ extern "C"
#endif
#endif
typedef
struct
_LibreOfficeKit
LibreOfficeKit
;
typedef
struct
_LibreOfficeKit
LibreOfficeKit
;
typedef
struct
_LibreOfficeKitClass
LibreOfficeKitClass
;
typedef
struct
_LibreOfficeKitDocument
LibreOfficeKitDocument
;
typedef
struct
_LibreOfficeKitDocument
LibreOfficeKitDocument
;
typedef
struct
_LibreOfficeKitDocumentClass
LibreOfficeKitDocumentClass
;
// Do we have an extended member in this struct ?
// Do we have an extended member in this struct ?
#define LIBREOFFICEKIT_HAS_MEMBER(strct,member,nSize) \
#define LIBREOFFICEKIT_HAS_MEMBER(strct,member,nSize) \
((((size_t)((unsigned char *)&((strct *) 0)->member) + \
((((size_t)((unsigned char *)&((strct *) 0)->member) + \
sizeof ((strct *) 0)->member)) <= (nSize))
sizeof ((strct *) 0)->member)) <= (nSize))
#define LIBREOFFICEKIT_HAS(pKit,member) LIBREOFFICEKIT_HAS_MEMBER(LibreOfficeKit
,member,(pKit)
->nSize)
#define LIBREOFFICEKIT_HAS(pKit,member) LIBREOFFICEKIT_HAS_MEMBER(LibreOfficeKit
Class,member,(pKit)->pClass
->nSize)
struct
_LibreOfficeKit
struct
_LibreOfficeKit
{
LibreOfficeKitClass
*
pClass
;
};
struct
_LibreOfficeKitClass
{
{
size_t
nSize
;
size_t
nSize
;
...
@@ -37,9 +45,14 @@ struct _LibreOfficeKit
...
@@ -37,9 +45,14 @@ struct _LibreOfficeKit
char
*
(
*
getError
)
(
LibreOfficeKit
*
pThis
);
char
*
(
*
getError
)
(
LibreOfficeKit
*
pThis
);
};
};
#define LIBREOFFICEKIT_DOCUMENT_HAS(pDoc,member) LIBREOFFICEKIT_HAS_MEMBER(LibreOfficeKitDocument
,member,(pDoc)
->nSize)
#define LIBREOFFICEKIT_DOCUMENT_HAS(pDoc,member) LIBREOFFICEKIT_HAS_MEMBER(LibreOfficeKitDocument
Class,member,(pDoc)->pClass
->nSize)
struct
_LibreOfficeKitDocument
struct
_LibreOfficeKitDocument
{
LibreOfficeKitDocumentClass
*
pClass
;
};
struct
_LibreOfficeKitDocumentClass
{
{
size_t
nSize
;
size_t
nSize
;
...
...
include/LibreOfficeKit/LibreOfficeKit.hxx
Dosyayı görüntüle @
8ba3116a
...
@@ -33,22 +33,18 @@ public:
...
@@ -33,22 +33,18 @@ public:
inline
~
Document
()
inline
~
Document
()
{
{
mpDoc
->
destroy
(
mpDoc
);
mpDoc
->
pClass
->
destroy
(
mpDoc
);
}
}
// Save as the given format, if format is NULL sniff from ext'n
// Save as the given format, if format is NULL sniff from ext'n
inline
bool
saveAs
(
const
char
*
pUrl
,
const
char
*
pFormat
=
NULL
)
inline
bool
saveAs
(
const
char
*
pUrl
,
const
char
*
pFormat
=
NULL
)
{
{
return
mpDoc
->
saveAs
(
mpDoc
,
pUrl
,
pFormat
);
return
mpDoc
->
pClass
->
saveAs
(
mpDoc
,
pUrl
,
pFormat
);
}
}
inline
bool
saveAsWithOptions
(
const
char
*
pUrl
,
const
char
*
pFormat
=
NULL
,
const
char
*
pFilterOptions
=
NULL
)
inline
bool
saveAsWithOptions
(
const
char
*
pUrl
,
const
char
*
pFormat
=
NULL
,
const
char
*
pFilterOptions
=
NULL
)
{
{
// available since LibreOffice 4.3
return
mpDoc
->
pClass
->
saveAsWithOptions
(
mpDoc
,
pUrl
,
pFormat
,
pFilterOptions
);
if
(
!
LIBREOFFICEKIT_DOCUMENT_HAS
(
mpDoc
,
saveAsWithOptions
))
return
false
;
return
mpDoc
->
saveAsWithOptions
(
mpDoc
,
pUrl
,
pFormat
,
pFilterOptions
);
}
}
inline
LibreOfficeKitDocument
*
get
()
{
return
mpDoc
;
}
inline
LibreOfficeKitDocument
*
get
()
{
return
mpDoc
;
}
};
};
...
@@ -65,17 +61,17 @@ public:
...
@@ -65,17 +61,17 @@ public:
inline
~
Office
()
inline
~
Office
()
{
{
mpThis
->
destroy
(
mpThis
);
mpThis
->
pClass
->
destroy
(
mpThis
);
}
}
inline
bool
initialize
(
const
char
*
pInstallPath
)
inline
bool
initialize
(
const
char
*
pInstallPath
)
{
{
return
mpThis
->
initialize
(
mpThis
,
pInstallPath
);
return
mpThis
->
pClass
->
initialize
(
mpThis
,
pInstallPath
);
}
}
inline
Document
*
documentLoad
(
const
char
*
pUrl
)
inline
Document
*
documentLoad
(
const
char
*
pUrl
)
{
{
LibreOfficeKitDocument
*
pDoc
=
mpThis
->
documentLoad
(
mpThis
,
pUrl
);
LibreOfficeKitDocument
*
pDoc
=
mpThis
->
pClass
->
documentLoad
(
mpThis
,
pUrl
);
if
(
pDoc
==
NULL
)
if
(
pDoc
==
NULL
)
return
NULL
;
return
NULL
;
return
new
Document
(
pDoc
);
return
new
Document
(
pDoc
);
...
@@ -84,14 +80,14 @@ public:
...
@@ -84,14 +80,14 @@ public:
// return the last error as a string, free me.
// return the last error as a string, free me.
inline
char
*
getError
()
inline
char
*
getError
()
{
{
return
mpThis
->
getError
(
mpThis
);
return
mpThis
->
pClass
->
getError
(
mpThis
);
}
}
};
};
inline
Office
*
lok_cpp_init
(
const
char
*
pInstallPath
)
inline
Office
*
lok_cpp_init
(
const
char
*
pInstallPath
)
{
{
LibreOfficeKit
*
pThis
=
lok_init
(
pInstallPath
);
LibreOfficeKit
*
pThis
=
lok_init
(
pInstallPath
);
if
(
pThis
==
NULL
||
pThis
->
nSize
==
0
)
if
(
pThis
==
NULL
||
pThis
->
pClass
->
nSize
==
0
)
return
NULL
;
return
NULL
;
return
new
::
lok
::
Office
(
pThis
);
return
new
::
lok
::
Office
(
pThis
);
}
}
...
...
libreofficekit/source/shim.c
Dosyayı görüntüle @
8ba3116a
...
@@ -50,7 +50,7 @@ SAL_DLLPUBLIC_EXPORT LibreOfficeKit *lok_init( const char *install_path )
...
@@ -50,7 +50,7 @@ SAL_DLLPUBLIC_EXPORT LibreOfficeKit *lok_init( const char *install_path )
return
NULL
;
return
NULL
;
}
}
pSym
=
(
HookFunction
*
)
dlsym
(
dlhandle
,
"lib
libreoffice
_hook"
);
pSym
=
(
HookFunction
*
)
dlsym
(
dlhandle
,
"lib
reofficekit
_hook"
);
if
(
!
pSym
)
{
if
(
!
pSym
)
{
fprintf
(
stderr
,
"failed to find hook in library '%s'
\n
"
,
imp_lib
);
fprintf
(
stderr
,
"failed to find hook in library '%s'
\n
"
,
imp_lib
);
dlclose
(
dlhandle
);
dlclose
(
dlhandle
);
...
...
smoketest/libtest.cxx
Dosyayı görüntüle @
8ba3116a
...
@@ -79,9 +79,9 @@ int main (int argc, char **argv)
...
@@ -79,9 +79,9 @@ int main (int argc, char **argv)
if
(
!
LIBREOFFICEKIT_DOCUMENT_HAS
(
pDocument
->
get
(),
saveAsWithOptions
))
if
(
!
LIBREOFFICEKIT_DOCUMENT_HAS
(
pDocument
->
get
(),
saveAsWithOptions
))
{
{
fprintf
(
stderr
,
"using obsolete LibreOffice %"
SAL_PRI_SIZET
"d + %"
SAL_PRI_SIZET
"d vs. %"
SAL_PRI_SIZET
"d
\n
"
,
fprintf
(
stderr
,
"using obsolete LibreOffice %"
SAL_PRI_SIZET
"d + %"
SAL_PRI_SIZET
"d vs. %"
SAL_PRI_SIZET
"d
\n
"
,
(
size_t
)((
unsigned
char
*
)
&
((
LibreOfficeKitDocument
*
)
0
)
->
saveAsWithOptions
),
(
size_t
)((
unsigned
char
*
)
&
((
LibreOfficeKitDocument
Class
*
)
0
)
->
saveAsWithOptions
),
sizeof
((
LibreOfficeKitDocument
*
)
0
)
->
saveAsWithOptions
,
sizeof
((
LibreOfficeKitDocument
Class
*
)
0
)
->
saveAsWithOptions
,
pDocument
->
get
()
->
nSize
);
pDocument
->
get
()
->
pClass
->
nSize
);
return
-
1
;
return
-
1
;
}
}
...
...
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