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
5c1c0a4e
Kaydet (Commit)
5c1c0a4e
authored
Mar 07, 2013
tarafından
Luboš Luňák
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
function for duplicated code
Change-Id: If9d6a163abb5a1cbd64838ca005b14dcd51c4588
üst
45961203
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
63 additions
and
79 deletions
+63
-79
log-areas.dox
sal/inc/sal/log-areas.dox
+1
-0
embeddedfontshelper.hxx
vcl/inc/vcl/embeddedfontshelper.hxx
+15
-0
embeddedfontshelper.cxx
vcl/source/gdi/embeddedfontshelper.cxx
+41
-0
FontTable.cxx
writerfilter/source/dmapper/FontTable.cxx
+4
-51
XMLFontStylesContext.cxx
xmloff/source/style/XMLFontStylesContext.cxx
+2
-28
No files found.
sal/inc/sal/log-areas.dox
Dosyayı görüntüle @
5c1c0a4e
...
@@ -236,6 +236,7 @@ certain functionality.
...
@@ -236,6 +236,7 @@ certain functionality.
@li @c vcl.atsui - ATSUI (obsolete) -using code for Mac OS X
@li @c vcl.atsui - ATSUI (obsolete) -using code for Mac OS X
@li @c vcl.control
@li @c vcl.control
@li @c vcl.coretext - CoreText-using code for Mac OS X and iOS
@li @c vcl.coretext - CoreText-using code for Mac OS X and iOS
@li @c vcl.fonts - font-specific code
@li @c vcl.gdi - the GDI part of VCL, devices, bitmaps, etc.
@li @c vcl.gdi - the GDI part of VCL, devices, bitmaps, etc.
@li @c vcl.gtk - Gtk+ 2/3 plugin
@li @c vcl.gtk - Gtk+ 2/3 plugin
@li @c vcl.layout - Widget layout
@li @c vcl.layout - Widget layout
...
...
vcl/inc/vcl/embeddedfontshelper.hxx
Dosyayı görüntüle @
5c1c0a4e
...
@@ -12,8 +12,11 @@
...
@@ -12,8 +12,11 @@
#include <vcl/dllapi.h>
#include <vcl/dllapi.h>
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <rtl/ustring.hxx>
#include <rtl/ustring.hxx>
#include <tools/fontenum.hxx>
#include <tools/fontenum.hxx>
#include <vector>
/**
/**
Helper functions for handling embedded fonts in documents.
Helper functions for handling embedded fonts in documents.
...
@@ -27,6 +30,18 @@ public:
...
@@ -27,6 +30,18 @@ public:
*/
*/
static
OUString
fontFileUrl
(
const
OUString
&
familyName
,
FontFamily
family
,
FontItalic
italic
,
static
OUString
fontFileUrl
(
const
OUString
&
familyName
,
FontFamily
family
,
FontItalic
italic
,
FontWeight
weight
,
FontPitch
pitch
,
rtl_TextEncoding
encoding
);
FontWeight
weight
,
FontPitch
pitch
,
rtl_TextEncoding
encoding
);
/**
Reads a font from the input stream, saves it to a temporary font file and activates the font.
@param stream stream of font data
@param fontName name of the font (e.g. 'Times New Roman')
@param extra additional text to use for name (e.g. to distinguish regular from bold, italic,...), "?" for unique
@param key key to xor the data with, from the start until the key's length (not repeated)
*/
static
bool
addEmbeddedFont
(
com
::
sun
::
star
::
uno
::
Reference
<
com
::
sun
::
star
::
io
::
XInputStream
>
stream
,
const
OUString
&
fontName
,
const
char
*
extra
,
std
::
vector
<
unsigned
char
>
key
=
std
::
vector
<
unsigned
char
>
());
/**
/**
Returns an URL for a file where to store contents of a given temporary font.
Returns an URL for a file where to store contents of a given temporary font.
The file may or not may not exist yet, and will be cleaned up automatically as appropriate.
The file may or not may not exist yet, and will be cleaned up automatically as appropriate.
...
...
vcl/source/gdi/embeddedfontshelper.cxx
Dosyayı görüntüle @
5c1c0a4e
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
#include <outfont.hxx>
#include <outfont.hxx>
#include <salgdi.hxx>
#include <salgdi.hxx>
using
namespace
com
::
sun
::
star
;
using
namespace
vcl
;
using
namespace
vcl
;
static
void
clearDir
(
const
OUString
&
path
)
static
void
clearDir
(
const
OUString
&
path
)
...
@@ -49,6 +50,46 @@ void EmbeddedFontsHelper::clearTemporaryFontFiles()
...
@@ -49,6 +50,46 @@ void EmbeddedFontsHelper::clearTemporaryFontFiles()
clearDir
(
path
+
"fromsystem/"
);
clearDir
(
path
+
"fromsystem/"
);
}
}
bool
EmbeddedFontsHelper
::
addEmbeddedFont
(
uno
::
Reference
<
io
::
XInputStream
>
stream
,
const
OUString
&
fontName
,
const
char
*
extra
,
std
::
vector
<
unsigned
char
>
key
)
{
OUString
fileUrl
=
EmbeddedFontsHelper
::
fileUrlForTemporaryFont
(
fontName
,
extra
);
osl
::
File
file
(
fileUrl
);
switch
(
file
.
open
(
osl_File_OpenFlag_Create
|
osl_File_OpenFlag_Write
))
{
case
osl
:
:
File
::
E_None
:
break
;
// ok
case
osl
:
:
File
::
E_EXIST
:
return
true
;
// Assume it's already been added correctly.
default
:
SAL_WARN
(
"vcl.fonts"
,
"Cannot open file for temporary font"
);
return
false
;
}
size_t
keyPos
=
0
;
for
(;;)
{
uno
::
Sequence
<
sal_Int8
>
buffer
;
int
read
=
stream
->
readBytes
(
buffer
,
1024
);
for
(
int
pos
=
0
;
pos
<
read
&&
keyPos
<
key
.
size
();
++
pos
)
buffer
[
pos
]
^=
key
[
keyPos
++
];
sal_uInt64
dummy
;
if
(
read
>
0
)
file
.
write
(
buffer
.
getConstArray
(),
read
,
dummy
);
if
(
read
<
1024
)
break
;
}
if
(
file
.
close
()
!=
osl
::
File
::
E_None
)
{
SAL_WARN
(
"vcl.fonts"
,
"Writing temporary font file failed"
);
osl
::
File
::
remove
(
fileUrl
);
return
false
;
}
EmbeddedFontsHelper
::
activateFont
(
fontName
,
fileUrl
);
return
true
;
}
OUString
EmbeddedFontsHelper
::
fileUrlForTemporaryFont
(
const
OUString
&
fontName
,
const
char
*
extra
)
OUString
EmbeddedFontsHelper
::
fileUrlForTemporaryFont
(
const
OUString
&
fontName
,
const
char
*
extra
)
{
{
OUString
path
=
"${$BRAND_BASE_DIR/program/"
SAL_CONFIGFILE
(
"bootstrap"
)
"::UserInstallation}"
;
OUString
path
=
"${$BRAND_BASE_DIR/program/"
SAL_CONFIGFILE
(
"bootstrap"
)
"::UserInstallation}"
;
...
...
writerfilter/source/dmapper/FontTable.cxx
Dosyayı görüntüle @
5c1c0a4e
...
@@ -251,35 +251,12 @@ EmbeddedFontHandler::~EmbeddedFontHandler()
...
@@ -251,35 +251,12 @@ EmbeddedFontHandler::~EmbeddedFontHandler()
{
{
if
(
!
inputStream
.
is
())
if
(
!
inputStream
.
is
())
return
;
return
;
OUString
fileUrl
=
EmbeddedFontsHelper
::
fileUrlForTemporaryFont
(
fontName
,
style
);
std
::
vector
<
unsigned
char
>
key
(
32
);
osl
::
File
file
(
fileUrl
);
switch
(
file
.
open
(
osl_File_OpenFlag_Create
|
osl_File_OpenFlag_Write
))
{
case
osl
:
:
File
::
E_None
:
break
;
// ok
case
osl
:
:
File
::
E_EXIST
:
return
;
// Assume it's already been added correctly.
default
:
SAL_WARN
(
"writerfilter"
,
"Cannot open file for temporary font"
);
inputStream
->
closeInput
();
return
;
}
if
(
!
fontKey
.
isEmpty
())
if
(
!
fontKey
.
isEmpty
())
{
// unobfuscate
{
// key for unobfuscating
uno
::
Sequence
<
sal_Int8
>
buffer
;
int
read
=
inputStream
->
readBytes
(
buffer
,
32
);
if
(
read
<
32
)
{
SAL_WARN
(
"writerfilter"
,
"Embedded font too small"
);
inputStream
->
closeInput
();
file
.
close
();
osl
::
File
::
remove
(
fileUrl
);
return
;
}
// 1 3 5 7 10 2 5 7 20 2 5 7 9 1 3 5
// 1 3 5 7 10 2 5 7 20 2 5 7 9 1 3 5
// {62E79491-959F-41E9-B76B-6B32631DEA5C}
// {62E79491-959F-41E9-B76B-6B32631DEA5C}
static
const
int
pos
[
16
]
=
{
35
,
33
,
31
,
29
,
27
,
25
,
22
,
20
,
17
,
15
,
12
,
10
,
7
,
5
,
3
,
1
};
static
const
int
pos
[
16
]
=
{
35
,
33
,
31
,
29
,
27
,
25
,
22
,
20
,
17
,
15
,
12
,
10
,
7
,
5
,
3
,
1
};
char
key
[
16
];
for
(
int
i
=
0
;
for
(
int
i
=
0
;
i
<
16
;
i
<
16
;
++
i
)
++
i
)
...
@@ -290,35 +267,11 @@ EmbeddedFontHandler::~EmbeddedFontHandler()
...
@@ -290,35 +267,11 @@ EmbeddedFontHandler::~EmbeddedFontHandler()
assert
((
v2
>=
'0'
&&
v2
<=
'9'
)
||
(
v2
>=
'A'
&&
v2
<=
'F'
));
assert
((
v2
>=
'0'
&&
v2
<=
'9'
)
||
(
v2
>=
'A'
&&
v2
<=
'F'
));
int
val
=
(
v1
-
(
v1
<=
'9'
?
'0'
:
'A'
-
10
))
*
16
+
v2
-
(
v2
<=
'9'
?
'0'
:
'A'
-
10
);
int
val
=
(
v1
-
(
v1
<=
'9'
?
'0'
:
'A'
-
10
))
*
16
+
v2
-
(
v2
<=
'9'
?
'0'
:
'A'
-
10
);
key
[
i
]
=
val
;
key
[
i
]
=
val
;
key
[
i
+
16
]
=
val
;
}
}
for
(
int
i
=
0
;
i
<
16
;
++
i
)
{
buffer
[
i
]
^=
key
[
i
];
buffer
[
i
+
16
]
^=
key
[
i
];
}
sal_uInt64
dummy
;
file
.
write
(
buffer
.
getConstArray
(),
32
,
dummy
);
}
for
(;;)
{
uno
::
Sequence
<
sal_Int8
>
buffer
;
int
read
=
inputStream
->
readBytes
(
buffer
,
1024
);
sal_uInt64
dummy
;
if
(
read
>
0
)
file
.
write
(
buffer
.
getConstArray
(),
read
,
dummy
);
if
(
read
<
1024
)
break
;
}
}
EmbeddedFontsHelper
::
addEmbeddedFont
(
inputStream
,
fontName
,
style
,
key
);
inputStream
->
closeInput
();
inputStream
->
closeInput
();
if
(
file
.
close
()
!=
osl
::
File
::
E_None
)
{
SAL_WARN
(
"writerfilter"
,
"Writing temporary font file failed"
);
osl
::
File
::
remove
(
fileUrl
);
return
;
}
EmbeddedFontsHelper
::
activateFont
(
fontName
,
fileUrl
);
}
}
void
EmbeddedFontHandler
::
lcl_attribute
(
Id
name
,
Value
&
val
)
void
EmbeddedFontHandler
::
lcl_attribute
(
Id
name
,
Value
&
val
)
...
...
xmloff/source/style/XMLFontStylesContext.cxx
Dosyayı görüntüle @
5c1c0a4e
...
@@ -252,38 +252,12 @@ void XMLFontStyleContextFontFaceUri::handleEmbeddedFont( const OUString& url )
...
@@ -252,38 +252,12 @@ void XMLFontStyleContextFontFaceUri::handleEmbeddedFont( const OUString& url )
if
(
url
.
indexOf
(
'/'
)
>
-
1
)
// TODO what if more levels?
if
(
url
.
indexOf
(
'/'
)
>
-
1
)
// TODO what if more levels?
storage
.
set
(
storage
->
openStorageElement
(
url
.
copy
(
0
,
url
.
indexOf
(
'/'
)),
storage
.
set
(
storage
->
openStorageElement
(
url
.
copy
(
0
,
url
.
indexOf
(
'/'
)),
::
embed
::
ElementModes
::
READ
),
uno
::
UNO_QUERY_THROW
);
::
embed
::
ElementModes
::
READ
),
uno
::
UNO_QUERY_THROW
);
OUString
fileUrl
=
EmbeddedFontsHelper
::
fileUrlForTemporaryFont
(
fontName
,
"?"
);
osl
::
File
file
(
fileUrl
);
switch
(
file
.
open
(
osl_File_OpenFlag_Create
|
osl_File_OpenFlag_Write
))
{
case
osl
:
:
File
::
E_None
:
break
;
// ok
default
:
SAL_WARN
(
"xmloff"
,
"Cannot open file for temporary font"
);
return
;
}
uno
::
Reference
<
io
::
XInputStream
>
inputStream
;
uno
::
Reference
<
io
::
XInputStream
>
inputStream
;
inputStream
.
set
(
storage
->
openStreamElement
(
url
.
copy
(
url
.
indexOf
(
'/'
)
+
1
),
::
embed
::
ElementModes
::
READ
),
inputStream
.
set
(
storage
->
openStreamElement
(
url
.
copy
(
url
.
indexOf
(
'/'
)
+
1
),
::
embed
::
ElementModes
::
READ
),
UNO_QUERY_THROW
);
UNO_QUERY_THROW
);
for
(;;)
if
(
EmbeddedFontsHelper
::
addEmbeddedFont
(
inputStream
,
fontName
,
"?"
))
{
GetImport
().
NotifyEmbeddedFontRead
();
uno
::
Sequence
<
sal_Int8
>
buffer
;
int
read
=
inputStream
->
readBytes
(
buffer
,
1024
);
sal_uInt64
dummy
;
if
(
read
>
0
)
file
.
write
(
buffer
.
getConstArray
(),
read
,
dummy
);
if
(
read
<
1024
)
break
;
}
inputStream
->
closeInput
();
inputStream
->
closeInput
();
if
(
file
.
close
()
!=
osl
::
File
::
E_None
)
{
SAL_WARN
(
"xmloff"
,
"Writing temporary font file failed"
);
osl
::
File
::
remove
(
fileUrl
);
return
;
}
EmbeddedFontsHelper
::
activateFont
(
fontName
,
fileUrl
);
GetImport
().
NotifyEmbeddedFontRead
();
}
}
else
else
SAL_WARN
(
"xmloff"
,
"External URL for font file not handled."
);
SAL_WARN
(
"xmloff"
,
"External URL for font file not handled."
);
...
...
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