Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
onlyoffice_core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
onlyoffice_core
Commits
db202320
Commit
db202320
authored
Dec 08, 2016
by
ElenaSubbotina
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OdfFormatReader - presentation - support convert ole objects (and other embedded)
parent
56ecea3f
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
376 additions
and
319 deletions
+376
-319
ASCOfficeOdfFile/src/docx/oox_drawing.cpp
ASCOfficeOdfFile/src/docx/oox_drawing.cpp
+6
-6
ASCOfficeOdfFile/src/docx/oox_package.cpp
ASCOfficeOdfFile/src/docx/oox_package.cpp
+6
-2
ASCOfficeOdfFile/src/docx/pptx_conversion_context.cpp
ASCOfficeOdfFile/src/docx/pptx_conversion_context.cpp
+4
-4
ASCOfficeOdfFile/src/docx/pptx_drawing.cpp
ASCOfficeOdfFile/src/docx/pptx_drawing.cpp
+53
-5
ASCOfficeOdfFile/src/docx/pptx_package.cpp
ASCOfficeOdfFile/src/docx/pptx_package.cpp
+103
-114
ASCOfficeOdfFile/src/docx/pptx_package.h
ASCOfficeOdfFile/src/docx/pptx_package.h
+1
-0
ASCOfficeOdfFile/src/docx/pptx_slide_context.cpp
ASCOfficeOdfFile/src/docx/pptx_slide_context.cpp
+72
-82
ASCOfficeOdfFile/src/docx/pptx_slide_context.h
ASCOfficeOdfFile/src/docx/pptx_slide_context.h
+1
-7
ASCOfficeOdfFile/src/odf/draw_frame.cpp
ASCOfficeOdfFile/src/odf/draw_frame.cpp
+92
-5
ASCOfficeOdfFile/src/odf/draw_frame.h
ASCOfficeOdfFile/src/odf/draw_frame.h
+7
-5
ASCOfficeOdfFile/src/odf/draw_frame_docx.cpp
ASCOfficeOdfFile/src/odf/draw_frame_docx.cpp
+12
-83
ASCOfficeOdfFile/src/odf/draw_frame_pptx.cpp
ASCOfficeOdfFile/src/odf/draw_frame_pptx.cpp
+19
-6
No files found.
ASCOfficeOdfFile/src/docx/oox_drawing.cpp
View file @
db202320
...
...
@@ -470,16 +470,16 @@ void _oox_drawing::serialize_xfrm(std::wostream & strm, const std::wstring & nam
CP_XML_NODE
(
L"a:off"
)
{
if
(
inGroup
)
//
if (inGroup)
{
CP_XML_ATTR
(
L"x"
,
x
);
CP_XML_ATTR
(
L"y"
,
y
);
}
else
{
CP_XML_ATTR
(
L"x"
,
0
);
CP_XML_ATTR
(
L"y"
,
0
);
}
//
else
//
{
//
CP_XML_ATTR(L"x", 0);
//
CP_XML_ATTR(L"y", 0);
//
}
}
if
(
cx
>
0
||
cy
>
0
)
...
...
ASCOfficeOdfFile/src/docx/oox_package.cpp
View file @
db202320
...
...
@@ -74,6 +74,7 @@ static std::wstring get_mime_type(const std::wstring & extension)
else
if
(
L"wav"
==
extension
)
return
L"audio/wav"
;
else
if
(
L"bin"
==
extension
)
return
L"application/vnd.openxmlformats-officedocument.oleObject"
;
else
if
(
L"xlsx"
==
extension
)
return
L"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
;
else
if
(
L"doc"
==
extension
)
return
L"application/msword"
;
else
return
L"application/octet-stream"
;
...
...
@@ -135,8 +136,8 @@ bool content_types_file::add_or_find_override(const std::wstring & fileName)
}
std
::
wstring
content_type
;
int
pos
=
fileName
.
rfind
(
L"."
);
int
pos
=
fileName
.
rfind
(
L"."
);
std
::
wstring
extension
=
pos
>=
0
?
fileName
.
substr
(
pos
+
1
)
:
L""
;
if
(
extension
==
L"xlsx"
)
...
...
@@ -362,7 +363,10 @@ void embeddings::write(const std::wstring & RootPath)
if
(
items
[
i
].
mediaInternal
&&
items
[
i
].
valid
&&
(
items
[
i
].
type
==
typeMsObject
||
items
[
i
].
type
==
typeOleObject
))
{
content_types
.
add_or_find_override
(
std
::
wstring
(
L"/word/"
)
+
items
[
i
].
outputName
);
int
pos
=
items
[
i
].
outputName
.
rfind
(
L"."
);
std
::
wstring
extension
=
pos
>=
0
?
items
[
i
].
outputName
.
substr
(
pos
+
1
)
:
L""
;
content_types
.
add_or_find_default
(
extension
);
std
::
wstring
file_name_out
=
RootPath
+
FILE_SEPARATOR_STR
+
items
[
i
].
outputName
;
...
...
ASCOfficeOdfFile/src/docx/pptx_conversion_context.cpp
View file @
db202320
...
...
@@ -514,7 +514,7 @@ void pptx_conversion_context::end_page()
}
get_slide_context
().
serialize_background
(
current_slide
().
Background
());
get_slide_context
().
serialize_objects
(
current_slide
().
Data
());
get_slide_context
().
serialize_objects
(
current_slide
().
Data
());
get_slide_context
().
serialize_animations
(
current_slide
().
Timing
());
get_slide_context
().
dump_rels
(
current_slide
().
Rels
());
//hyperlinks, mediaitems, ...
...
...
@@ -543,9 +543,9 @@ std::pair<int,int> pptx_conversion_context::add_author_comments(std::wstring aut
void
pptx_conversion_context
::
end_master
()
{
get_slide_context
().
serialize_background
(
current_master
().
Background
(),
true
);
get_slide_context
().
serialize_objects
(
current_master
().
Data
());
get_slide_context
().
serialize_HeaderFooter
(
current_master
().
DataExtra
());
get_slide_context
().
serialize_background
(
current_master
().
Background
(),
true
);
get_slide_context
().
serialize_objects
(
current_master
().
Data
());
get_slide_context
().
serialize_HeaderFooter
(
current_master
().
DataExtra
());
get_slide_context
().
dump_rels
(
current_master
().
Rels
());
//hyperlinks, mediaitems, ...
...
...
ASCOfficeOdfFile/src/docx/pptx_drawing.cpp
View file @
db202320
...
...
@@ -90,7 +90,7 @@ void pptx_serialize_image(std::wostream & strm, _pptx_drawing & val)
CP_XML_ATTR
(
L"id"
,
val
.
id
);
CP_XML_ATTR
(
L"name"
,
val
.
name
);
oox_serialize_hlink
(
CP_XML_STREAM
(),
val
.
hlinks
);
oox_serialize_hlink
(
CP_XML_STREAM
(),
val
.
hlinks
);
}
CP_XML_NODE
(
L"p:cNvPicPr"
)
...
...
@@ -218,7 +218,6 @@ void pptx_serialize_chart(std::wostream & strm, _pptx_drawing & val)
}
// p:graphicFrame
}
// CP_XML_WRITER
}
void
pptx_serialize_table
(
std
::
wostream
&
strm
,
_pptx_drawing
&
val
)
{
CP_XML_WRITER
(
strm
)
...
...
@@ -260,11 +259,55 @@ void pptx_serialize_table(std::wostream & strm, _pptx_drawing & val)
}
void
pptx_serialize_object
(
std
::
wostream
&
strm
,
_pptx_drawing
&
val
)
{
CP_XML_WRITER
(
strm
)
{
CP_XML_NODE
(
L"p:graphicFrame"
)
{
CP_XML_NODE
(
L"p:nvGraphicFramePr"
)
{
CP_XML_NODE
(
L"p:cNvPr"
)
{
CP_XML_ATTR
(
L"id"
,
val
.
id
);
CP_XML_ATTR
(
L"name"
,
val
.
name
);
}
CP_XML_NODE
(
L"p:cNvGraphicFramePr"
);
CP_XML_NODE
(
L"p:nvPr"
);
}
val
.
serialize_xfrm
(
CP_XML_STREAM
(),
L"p"
);
//oox_serialize_ln(CP_XML_STREAM(),val.additional);
CP_XML_NODE
(
L"a:graphic"
)
{
CP_XML_NODE
(
L"a:graphicData"
)
{
CP_XML_ATTR
(
L"uri"
,
L"http://schemas.openxmlformats.org/presentationml/2006/ole"
);
CP_XML_NODE
(
L"p:oleObj"
)
{
CP_XML_ATTR
(
L"r:id"
,
val
.
objectId
);
CP_XML_ATTR
(
L"progId"
,
val
.
objectProgId
);
CP_XML_ATTR
(
L"imgW"
,
val
.
cx
);
CP_XML_ATTR
(
L"imgH"
,
val
.
cy
);
CP_XML_NODE
(
L"p:embed"
);
val
.
id
=
0
;
pptx_serialize_image
(
CP_XML_STREAM
(),
val
);
}
}
}
}
// p:graphicFrame
}
// CP_XML_WRITER
}
void
_pptx_drawing
::
serialize
(
std
::
wostream
&
strm
)
{
if
(
type
==
typeShape
)
{
serialize_shape
(
strm
);
pptx_serialize_shape
(
strm
,
*
this
);
}
else
if
(
type
==
typeImage
)
{
...
...
@@ -278,6 +321,11 @@ void _pptx_drawing::serialize(std::wostream & strm)
{
pptx_serialize_table
(
strm
,
*
this
);
}
else
if
(
type
==
typeMsObject
||
type
==
typeOleObject
)
{
pptx_serialize_object
(
strm
,
*
this
);
}
}
...
...
ASCOfficeOdfFile/src/docx/pptx_package.cpp
View file @
db202320
...
...
@@ -33,10 +33,6 @@
#include "pptx_package.h"
#include "pptx_output_xml.h"
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/ref.hpp>
#include <cpdoccore/utf8cpp/utf8.h>
namespace
cpdoccore
{
...
...
@@ -99,11 +95,13 @@ void slide_content::add_rel(relationship const & r)
rels_
->
get_rels
().
add
(
r
);
}
void
slide_content
::
add_rels
(
rels
&
r
)
void
slide_content
::
add_rels
(
rels
&
_
r
)
{
BOOST_FOREACH
(
relationship
&
item
,
r
.
relationships
())
std
::
vector
<
relationship
>
&
r
=
_r
.
relationships
();
for
(
int
i
=
0
;
i
<
r
.
size
();
i
++
)
{
rels_
->
get_rels
().
add
(
item
);
rels_
->
get_rels
().
add
(
r
[
i
]
);
}
}
////////////
...
...
@@ -124,33 +122,29 @@ void slides_files::write(const std::wstring & RootPath)
content_type_content
*
contentTypes
=
this
->
get_main_document
()
->
get_content_types_file
().
content
();
static
const
std
::
wstring
kWSConType
=
L"application/vnd.openxmlformats-officedocument.presentationml.slide+xml"
;
size_t
count
=
0
;
BOOST_FOREACH
(
const
slide_content_ptr
&
item
,
slides_
)
{
if
(
item
)
for
(
int
i
=
0
;
i
<
slides_
.
size
();
i
++
)
{
count
++
;
const
std
::
wstring
fileName
=
std
::
wstring
(
L"slide"
)
+
boost
::
lexical_cast
<
std
::
wstring
>
(
count
)
+
L".xml"
;
if
(
!
slides_
[
i
])
continue
;
const
std
::
wstring
fileName
=
std
::
wstring
(
L"slide"
)
+
std
::
to_wstring
(
i
+
1
)
+
L".xml"
;
contentTypes
->
add_override
(
std
::
wstring
(
L"/ppt/slides/"
)
+
fileName
,
kWSConType
);
if
(
rels_
)
{
const
std
::
wstring
id
=
std
::
wstring
(
L"sId"
)
+
boost
::
lexical_cast
<
std
::
wstring
>
(
count
);
const
std
::
wstring
id
=
std
::
wstring
(
L"sId"
)
+
std
::
to_wstring
(
i
+
1
);
static
const
std
::
wstring
kWSRel
=
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide"
;
const
std
::
wstring
fileRef
=
std
::
wstring
(
L"slides/"
)
+
fileName
;
rels_
->
add
(
id
,
kWSRel
,
fileRef
);
}
item
->
get_rel_file
()
->
set_file_name
(
fileName
+
L".rels"
);
//внитренние релсы
slides_
[
i
]
->
get_rel_file
()
->
set_file_name
(
fileName
+
L".rels"
);
//внитренние релсы
rels_files
relFiles
;
relFiles
.
add_rel_file
(
item
->
get_rel_file
());
relFiles
.
add_rel_file
(
slides_
[
i
]
->
get_rel_file
());
relFiles
.
write
(
path
);
package
::
simple_element
(
fileName
,
item
->
str
()).
write
(
path
);
}
package
::
simple_element
(
fileName
,
slides_
[
i
]
->
str
()).
write
(
path
);
}
}
...
...
@@ -171,32 +165,28 @@ void slideMasters_files::write(const std::wstring & RootPath)
content_type_content
*
contentTypes
=
this
->
get_main_document
()
->
get_content_types_file
().
content
();
static
const
std
::
wstring
kWSConType
=
L"application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml"
;
size_t
count
=
0
;
BOOST_FOREACH
(
const
slide_content_ptr
&
item
,
slides_
)
for
(
int
i
=
0
;
i
<
slides_
.
size
();
i
++
)
{
if
(
item
)
{
count
++
;
const
std
::
wstring
fileName
=
std
::
wstring
(
L"slideMaster"
)
+
boost
::
lexical_cast
<
std
::
wstring
>
(
count
)
+
L".xml"
;
if
(
!
slides_
[
i
])
continue
;
const
std
::
wstring
fileName
=
std
::
wstring
(
L"slideMaster"
)
+
std
::
to_wstring
(
i
+
1
)
+
L".xml"
;
contentTypes
->
add_override
(
std
::
wstring
(
L"/ppt/slideMasters/"
)
+
fileName
,
kWSConType
);
if
(
rels_
)
{
const
std
::
wstring
id
=
std
::
wstring
(
L"smId"
)
+
boost
::
lexical_cast
<
std
::
wstring
>
(
count
);
const
std
::
wstring
id
=
std
::
wstring
(
L"smId"
)
+
std
::
to_wstring
(
i
+
1
);
static
const
std
::
wstring
kWSRel
=
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster"
;
const
std
::
wstring
fileRef
=
std
::
wstring
(
L"slideMasters/"
)
+
fileName
;
rels_
->
add
(
id
,
kWSRel
,
fileRef
);
}
item
->
get_rel_file
()
->
set_file_name
(
fileName
+
L".rels"
);
//внитренние релсы
slides_
[
i
]
->
get_rel_file
()
->
set_file_name
(
fileName
+
L".rels"
);
//внитренние релсы
rels_files
relFiles
;
relFiles
.
add_rel_file
(
item
->
get_rel_file
());
relFiles
.
add_rel_file
(
slides_
[
i
]
->
get_rel_file
());
relFiles
.
write
(
path
);
package
::
simple_element
(
fileName
,
item
->
str
()).
write
(
path
);
}
package
::
simple_element
(
fileName
,
slides_
[
i
]
->
str
()).
write
(
path
);
}
}
...
...
@@ -214,27 +204,23 @@ void slideLayouts_files::write(const std::wstring & RootPath)
std
::
wstring
path
=
RootPath
+
FILE_SEPARATOR_STR
+
L"slideLayouts"
;
FileSystem
::
Directory
::
CreateDirectory
(
path
.
c_str
());
size_t
count
=
0
;
BOOST_FOREACH
(
const
slide_content_ptr
&
item
,
slides_
)
for
(
int
i
=
0
;
i
<
slides_
.
size
();
i
++
)
{
if
(
item
)
{
count
++
;
const
std
::
wstring
fileName
=
std
::
wstring
(
L"slideLayout"
)
+
boost
::
lexical_cast
<
std
::
wstring
>
(
count
)
+
L".xml"
;
if
(
!
slides_
[
i
])
continue
;
const
std
::
wstring
fileName
=
std
::
wstring
(
L"slideLayout"
)
+
std
::
to_wstring
(
i
+
1
)
+
L".xml"
;
const
std
::
wstring
kWSConType
=
L"application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml"
;
content_type_content
*
contentTypes
=
get_main_document
()
->
get_content_types_file
().
content
();
contentTypes
->
add_override
(
std
::
wstring
(
L"/ppt/slideLayouts/"
)
+
fileName
,
kWSConType
);
item
->
get_rel_file
()
->
set_file_name
(
fileName
+
L".rels"
);
//внитренние релсы
slides_
[
i
]
->
get_rel_file
()
->
set_file_name
(
fileName
+
L".rels"
);
//внитренние релсы
rels_files
relFiles
;
relFiles
.
add_rel_file
(
item
->
get_rel_file
());
relFiles
.
add_rel_file
(
slides_
[
i
]
->
get_rel_file
());
relFiles
.
write
(
path
);
package
::
simple_element
(
fileName
,
item
->
str
()).
write
(
path
);
}
package
::
simple_element
(
fileName
,
slides_
[
i
]
->
str
()).
write
(
path
);
}
}
...
...
@@ -270,29 +256,25 @@ void ppt_charts_files::write(const std::wstring & RootPath)
std
::
wstring
path
=
RootPath
+
FILE_SEPARATOR_STR
+
L"charts"
;
FileSystem
::
Directory
::
CreateDirectory
(
path
.
c_str
());
size_t
count
=
0
;
BOOST_FOREACH
(
const
chart_content_ptr
&
item
,
charts_
)
{
if
(
item
)
for
(
int
i
=
0
;
i
<
charts_
.
size
();
i
++
)
{
count
++
;
const
std
::
wstring
fileName
=
std
::
wstring
(
L"chart"
)
+
boost
::
lexical_cast
<
std
::
wstring
>
(
count
)
+
L".xml"
;
if
(
!
charts_
[
i
])
continue
;
const
std
::
wstring
fileName
=
std
::
wstring
(
L"chart"
)
+
std
::
to_wstring
(
i
+
1
)
+
L".xml"
;
content_type_content
*
contentTypes
=
get_main_document
()
->
get_content_types_file
().
content
();
static
const
std
::
wstring
kWSConType
=
L"application/vnd.openxmlformats-officedocument.drawingml.chart+xml"
;
contentTypes
->
add_override
(
std
::
wstring
(
L"/ppt/charts/"
)
+
fileName
,
kWSConType
);
package
::
simple_element
(
fileName
,
item
->
str
()).
write
(
path
);
package
::
simple_element
(
fileName
,
charts_
[
i
]
->
str
()).
write
(
path
);
rels_files
relFiles
;
item
->
get_rel_file
()
->
set_file_name
(
fileName
+
L".rels"
);
charts_
[
i
]
->
get_rel_file
()
->
set_file_name
(
fileName
+
L".rels"
);
relFiles
.
add_rel_file
(
item
->
get_rel_file
());
relFiles
.
add_rel_file
(
charts_
[
i
]
->
get_rel_file
());
relFiles
.
write
(
path
);
}
}
}
///////////////////////////////////
void
ppt_themes_files
::
add_theme
(
pptx_xml_theme_ptr
theme
)
...
...
@@ -304,25 +286,20 @@ void ppt_themes_files::write(const std::wstring & RootPath)
std
::
wstring
path
=
RootPath
+
FILE_SEPARATOR_STR
+
L"theme"
;
FileSystem
::
Directory
::
CreateDirectory
(
path
.
c_str
());
size_t
count
=
0
;
BOOST_FOREACH
(
const
pptx_xml_theme_ptr
&
item
,
themes_
)
{
if
(
item
)
for
(
int
i
=
0
;
i
<
themes_
.
size
();
i
++
)
{
count
++
;
if
(
!
themes_
[
i
])
continue
;
const
std
::
wstring
fileName
=
std
::
wstring
(
L"theme"
)
+
boost
::
lexical_cast
<
std
::
wstring
>
(
count
)
+
L".xml"
;
const
std
::
wstring
fileName
=
std
::
wstring
(
L"theme"
)
+
std
::
to_wstring
(
i
+
1
)
+
L".xml"
;
const
std
::
wstring
kWSConType
=
L"application/vnd.openxmlformats-officedocument.theme+xml"
;
content_type_content
*
contentTypes
=
get_main_document
()
->
get_content_types_file
().
content
();
contentTypes
->
add_override
(
std
::
wstring
(
L"/ppt/theme/"
)
+
fileName
,
kWSConType
);
std
::
wstringstream
content
;
item
->
write_to
(
content
);
themes_
[
i
]
->
write_to
(
content
);
package
::
simple_element
(
fileName
,
content
.
str
()).
write
(
path
);
}
}
}
//////////////////////////////
ppt_comments_files_ptr
ppt_comments_files
::
create
(
const
std
::
vector
<
pptx_comment_elm
>
&
elms
)
...
...
@@ -335,14 +312,14 @@ void ppt_comments_files::write(const std::wstring & RootPath)
std
::
wstring
comm_path
=
RootPath
+
FILE_SEPARATOR_STR
+
L"comments"
;
FileSystem
::
Directory
::
CreateDirectory
(
comm_path
.
c_str
());
BOOST_FOREACH
(
pptx_comment_elm
const
&
e
,
comments_
)
for
(
int
i
=
0
;
i
<
comments_
.
size
();
i
++
)
{
content_type_content
*
contentTypes
=
get_main_document
()
->
get_content_types_file
().
content
();
static
const
std
::
wstring
kWSConType
=
L"application/vnd.openxmlformats-officedocument.presentationml.comments+xml"
;
contentTypes
->
add_override
(
std
::
wstring
(
L"/ppt/comments/"
)
+
e
.
filename
,
kWSConType
);
contentTypes
->
add_override
(
std
::
wstring
(
L"/ppt/comments/"
)
+
comments_
[
i
]
.
filename
,
kWSConType
);
package
::
simple_element
(
e
.
filename
,
e
.
content
).
write
(
comm_path
);
package
::
simple_element
(
comments_
[
i
].
filename
,
comments_
[
i
]
.
content
).
write
(
comm_path
);
}
}
////////////////////////////////////////////
...
...
@@ -385,6 +362,11 @@ void ppt_files::write(const std::wstring & RootPath)
{
media_
->
set_main_document
(
get_main_document
());
media_
->
write
(
path
);
}
if
(
embeddings_
)
{
embeddings_
->
set_main_document
(
get_main_document
());
embeddings_
->
write
(
path
);
}
{
charts_files_
.
set_main_document
(
get_main_document
());
...
...
@@ -440,7 +422,14 @@ void ppt_files::add_slideMaster(slide_content_ptr slide)
void
ppt_files
::
set_media
(
mediaitems
&
_Mediaitems
,
CApplicationFonts
*
pAppFonts
)
{
if
(
_Mediaitems
.
count_image
+
_Mediaitems
.
count_media
>
0
)
{
media_
=
element_ptr
(
new
media
(
_Mediaitems
,
pAppFonts
)
);
}
if
(
_Mediaitems
.
count_object
>
0
)
{
embeddings_
=
element_ptr
(
new
embeddings
(
_Mediaitems
)
);
}
}
void
ppt_files
::
set_authors_comments
(
pptx_xml_authors_comments_ptr
&
authors_comments
)
{
...
...
ASCOfficeOdfFile/src/docx/pptx_package.h
View file @
db202320
...
...
@@ -238,6 +238,7 @@ private:
element_ptr
comments_
;
element_ptr
media_
;
element_ptr
embeddings_
;
};
// xlsx_document
...
...
ASCOfficeOdfFile/src/docx/pptx_slide_context.cpp
View file @
db202320
...
...
@@ -134,13 +134,45 @@ public:
}
std
::
wstring
odfPacket_
;
void
process_drawings
();
private:
void
process_common_properties
(
drawing_object_description
&
obj
,
_pptx_drawing
&
drawing
);
void
process_shape
(
drawing_object_description
&
obj
,
_pptx_drawing
&
drawing
);
void
process_image
(
drawing_object_description
&
obj
,
_pptx_drawing
&
drawing
);
void
process_chart
(
drawing_object_description
&
obj
,
_pptx_drawing
&
drawing
);
void
process_table
(
drawing_object_description
&
obj
,
_pptx_drawing
&
drawing
);
void
process_object
(
drawing_object_description
&
obj
,
_pptx_drawing
&
drawing
);
size_t
rId_
;
mediaitems
mediaitems_
;
pptx_drawings_ptr
pptx_drawings_
;
};
void
pptx_slide_context
::
Impl
::
process_drawings
()
{
for
(
int
i
=
0
;
i
<
objects_
.
size
();
i
++
)
{
_pptx_drawing
drawing
=
_pptx_drawing
();
drawing
.
type
=
objects_
[
i
].
type_
;
drawing
.
name
=
objects_
[
i
].
name_
;
drawing
.
id
=
next_rId
();
process_common_properties
(
objects_
[
i
],
drawing
);
switch
(
objects_
[
i
].
type_
)
{
case
typeImage
:
process_image
(
objects_
[
i
],
drawing
);
break
;
case
typeChart
:
process_chart
(
objects_
[
i
],
drawing
);
break
;
case
typeShape
:
process_shape
(
objects_
[
i
],
drawing
);
break
;
case
typeTable
:
process_table
(
objects_
[
i
],
drawing
);
break
;
case
typeMsObject
:
case
typeOleObject
:
process_object
(
objects_
[
i
],
drawing
);
break
;
}
}
}
pptx_slide_context
::
pptx_slide_context
(
pptx_conversion_context
&
Context
)
:
impl_
(
new
pptx_slide_context
::
Impl
(
Context
.
root
()
->
get_folder
()))
...
...
@@ -192,11 +224,10 @@ void pptx_slide_context::set_transitionSpeed(std::wstring val)
void
pptx_slide_context
::
default_set
()
{
impl_
->
object_description_
.
xlink_href_
=
L""
;
impl_
->
object_description_
.
name_
=
L""
;
impl_
->
object_description_
.
descriptor_
=
L""
;
impl_
->
object_description_
.
anchor_
=
L""
;
impl_
->
object_description_
.
additional_
.
clear
();
impl_
->
object_description_
.
anchor_
=
L""
;
impl_
->
object_description_
.
clipping_string_
=
L""
;
impl_
->
object_description_
.
svg_rect_
=
boost
::
none
;
...
...
@@ -347,7 +378,12 @@ void pptx_slide_context::set_text_box()
impl_
->
object_description_
.
type_
=
typeShape
;
impl_
->
object_description_
.
shape_type_
=
2
;
//2,3...
}
void
pptx_slide_context
::
set_object
(
const
std
::
wstring
&
path
,
const
std
::
wstring
&
progId
)
{
impl_
->
object_description_
.
type_
=
typeMsObject
;
impl_
->
object_description_
.
xlink_href_
=
path
;
impl_
->
object_description_
.
descriptor_
=
progId
;
}
void
pptx_slide_context
::
set_ole_object
(
const
std
::
wstring
&
path
,
const
std
::
wstring
&
progId
)
{
impl_
->
object_description_
.
type_
=
typeOleObject
;
...
...
@@ -407,32 +443,13 @@ bool pptx_slide_context::empty() const
void
pptx_slide_context
::
process_drawings
()
{
for
(
int
i
=
0
;
i
<
impl_
->
objects_
.
size
();
i
++
)
{
switch
(
impl_
->
objects_
[
i
].
type_
)
{
case
typeImage
:
process_image
(
impl_
->
objects_
[
i
]);
break
;
case
typeChart
:
process_chart
(
impl_
->
objects_
[
i
]);
break
;
case
typeShape
:
process_shape
(
impl_
->
objects_
[
i
]);
break
;
case
typeTable
:
process_table
(
impl_
->
objects_
[
i
]);
break
;
case
typeMsObject
:
case
typeOleObject
:
process_object
(
impl_
->
objects_
[
i
]);
break
;
}
}
return
impl_
->
process_drawings
();
}
void
pptx_slide_context
::
process_image
(
drawing_object_description
&
pic
)
void
pptx_slide_context
::
Impl
::
process_image
(
drawing_object_description
&
pic
,
_pptx_drawing
&
drawing
)
{
int
pos_replaicement
=
0
,
pos_preview
=
0
;
_pptx_drawing
drawing
=
_pptx_drawing
();
drawing
.
type
=
pic
.
type_
;
drawing
.
name
=
pic
.
name_
;
drawing
.
id
=
impl_
->
next_rId
();
process_common_properties
(
pic
,
drawing
);
drawing
.
fill
.
bitmap
=
oox_bitmap_fill
::
create
();
drawing
.
fill
.
type
=
2
;
...
...
@@ -444,7 +461,7 @@ void pptx_slide_context::process_image(drawing_object_description& pic)
drawing
.
sub_type
=
2
;
//rect
}
std
::
wstring
fileName
=
impl_
->
odfPacket_
+
FILE_SEPARATOR_STR
+
pic
.
xlink_href_
;
std
::
wstring
fileName
=
odfPacket_
+
FILE_SEPARATOR_STR
+
pic
.
xlink_href_
;
drawing
.
fill
.
bitmap
->
bCrop
=
odf_reader
::
parse_clipping
(
pic
.
clipping_string_
,
fileName
,
drawing
.
fill
.
bitmap
->
cropRect
,
NULL
);
drawing
.
fill
.
bitmap
->
bStretch
=
true
;
...
...
@@ -452,78 +469,53 @@ void pptx_slide_context::process_image(drawing_object_description& pic)
std
::
wstring
ref
;
/// это ссылка на выходной внешний объект
bool
isMediaInternal
=
false
;
drawing
.
fill
.
bitmap
->
rId
=
impl_
->
get_mediaitems
().
add_or_find
(
pic
.
xlink_href_
,
typeImage
,
isMediaInternal
,
ref
);
drawing
.
fill
.
bitmap
->
rId
=
get_mediaitems
().
add_or_find
(
pic
.
xlink_href_
,
typeImage
,
isMediaInternal
,
ref
);
if
(
drawing
.
type
==
typeShape
)
{
impl_
->
add_additional_rels
(
isMediaInternal
,
drawing
.
fill
.
bitmap
->
rId
,
ref
,
typeImage
);
//собственно это не объект, а доп рел и ref объекта
add_additional_rels
(
isMediaInternal
,
drawing
.
fill
.
bitmap
->
rId
,
ref
,
typeImage
);
//собственно это не объект, а доп рел и ref объекта
isMediaInternal
=
true
;
std
::
wstring
rId
=
impl_
->
get_mediaitems
().
add_or_find
(
L""
,
typeShape
,
isMediaInternal
,
ref
);
impl_
->
add_drawing
(
drawing
,
isMediaInternal
,
rId
,
ref
,
typeShape
);
//объект
std
::
wstring
rId
=
get_mediaitems
().
add_or_find
(
L""
,
typeShape
,
isMediaInternal
,
ref
);
add_drawing
(
drawing
,
isMediaInternal
,
rId
,
ref
,
typeShape
);
//объект
}
else
if
(
!
drawing
.
fill
.
bitmap
->
rId
.
empty
())
{
impl_
->
add_drawing
(
drawing
,
isMediaInternal
,
drawing
.
fill
.
bitmap
->
rId
,
ref
,
drawing
.
type
);
//объект
add_drawing
(
drawing
,
isMediaInternal
,
drawing
.
fill
.
bitmap
->
rId
,
ref
,
drawing
.
type
);
//объект
}
}
void
pptx_slide_context
::
process_chart
(
drawing_object_description
&
obj
)
void
pptx_slide_context
::
Impl
::
process_chart
(
drawing_object_description
&
obj
,
_pptx_drawing
&
drawing
)
{
_pptx_drawing
drawing
=
_pptx_drawing
();
drawing
.
type
=
obj
.
type_
;
drawing
.
name
=
obj
.
name_
;
drawing
.
id
=
impl_
->
next_rId
();
process_common_properties
(
obj
,
drawing
);
////////////////////////////////////////////////////////////////
std
::
wstring
ref
;
bool
isMediaInternal
=
true
;
drawing
.
objectId
=
impl_
->
get_mediaitems
().
add_or_find
(
obj
.
xlink_href_
,
obj
.
type_
,
isMediaInternal
,
ref
);
impl_
->
add_drawing
(
drawing
,
isMediaInternal
,
drawing
.
objectId
,
ref
,
drawing
.
type
);
drawing
.
objectId
=
get_mediaitems
().
add_or_find
(
obj
.
xlink_href_
,
obj
.
type_
,
isMediaInternal
,
ref
);
add_drawing
(
drawing
,
isMediaInternal
,
drawing
.
objectId
,
ref
,
drawing
.
type
);
}
void
pptx_slide_context
::
process_table
(
drawing_object_description
&
obj
)
void
pptx_slide_context
::
Impl
::
process_table
(
drawing_object_description
&
obj
,
_pptx_drawing
&
drawing
)
{
_pptx_drawing
drawing
=
_pptx_drawing
();
drawing
.
type
=
obj
.
type_
;
drawing
.
name
=
obj
.
name_
;
drawing
.
id
=
impl_
->
next_rId
();
process_common_properties
(
obj
,
drawing
);
////////////////////////////////////////////////////////////////
std
::
wstring
ref
;
bool
isMediaInternal
=
true
;
std
::
wstring
rId
=
impl_
->
get_mediaitems
().
add_or_find
(
L""
,
obj
.
type_
,
isMediaInternal
,
ref
);
std
::
wstring
rId
=
get_mediaitems
().
add_or_find
(
L""
,
obj
.
type_
,
isMediaInternal
,
ref
);
impl_
->
add_drawing
(
drawing
,
isMediaInternal
,
rId
,
ref
,
drawing
.
type
);
add_drawing
(
drawing
,
isMediaInternal
,
rId
,
ref
,
drawing
.
type
);
}
void
pptx_slide_context
::
process_shape
(
drawing_object_description
&
obj
)
void
pptx_slide_context
::
Impl
::
process_shape
(
drawing_object_description
&
obj
,
_pptx_drawing
&
drawing
)
{
int
PlaceHolderIndex
=
1
;
_pptx_drawing
drawing
=
_pptx_drawing
();
drawing
.
type
=
obj
.
type_
;
drawing
.
name
=
obj
.
name_
;
drawing
.
id
=
impl_
->
next_rId
();
process_common_properties
(
obj
,
drawing
);
std
::
wstring
ref
;
bool
isMediaInternal
=
true
;
if
(
drawing
.
fill
.
bitmap
)
{
drawing
.
fill
.
bitmap
->
rId
=
impl_
->
get_mediaitems
().
add_or_find
(
drawing
.
fill
.
bitmap
->
xlink_href_
,
typeImage
,
isMediaInternal
,
ref
);
impl_
->
add_additional_rels
(
isMediaInternal
,
drawing
.
fill
.
bitmap
->
rId
,
ref
,
typeImage
);
drawing
.
fill
.
bitmap
->
rId
=
get_mediaitems
().
add_or_find
(
drawing
.
fill
.
bitmap
->
xlink_href_
,
typeImage
,
isMediaInternal
,
ref
);
add_additional_rels
(
isMediaInternal
,
drawing
.
fill
.
bitmap
->
rId
,
ref
,
typeImage
);
}
std
::
wstring
rId
=
impl_
->
get_mediaitems
().
add_or_find
(
L""
,
typeShape
,
isMediaInternal
,
ref
);
std
::
wstring
rId
=
get_mediaitems
().
add_or_find
(
L""
,
typeShape
,
isMediaInternal
,
ref
);
////////////////////////////////////////////////////////////////
_CP_OPT
(
std
::
wstring
)
sPlaceHolderType
;
...
...
@@ -539,29 +531,27 @@ void pptx_slide_context::process_shape(drawing_object_description & obj)
drawing
.
sub_type
=
obj
.
shape_type_
;
impl_
->
add_drawing
(
drawing
,
isMediaInternal
,
rId
,
ref
,
typeShape
);
add_drawing
(
drawing
,
isMediaInternal
,
rId
,
ref
,
typeShape
);
}
void
pptx_slide_context
::
process_object
(
drawing_object_description
&
obj
)
void
pptx_slide_context
::
Impl
::
process_object
(
drawing_object_description
&
obj
,
_pptx_drawing
&
drawing
)
{
_pptx_drawing
drawing
=
_pptx_drawing
();
drawing
.
type
=
obj
.
type_
;
drawing
.
name
=
obj
.
name_
;
drawing
.
id
=
impl_
->
next_rId
();
process_common_properties
(
obj
,
drawing
);
////////////////////////////////////////////////////////////////
std
::
wstring
ref
;
bool
isMediaInternal
=
true
;
drawing
.
objectId
=
impl_
->
get_mediaitems
().
add_or_find
(
obj
.
xlink_href_
,
obj
.
type_
,
isMediaInternal
,
ref
);
drawing
.
objectId
=
get_mediaitems
().
add_or_find
(
obj
.
xlink_href_
,
obj
.
type_
,
isMediaInternal
,
ref
);
drawing
.
objectProgId
=
obj
.
descriptor_
;
impl_
->
add_drawing
(
drawing
,
isMediaInternal
,
drawing
.
objectId
,
ref
,
drawing
.
type
);
add_drawing
(
drawing
,
isMediaInternal
,
drawing
.
objectId
,
ref
,
drawing
.
type
);
if
(
drawing
.
fill
.
bitmap
)
{
drawing
.
fill
.
bitmap
->
rId
=
get_mediaitems
().
add_or_find
(
drawing
.
fill
.
bitmap
->
xlink_href_
,
typeImage
,
isMediaInternal
,
ref
);
add_additional_rels
(
isMediaInternal
,
drawing
.
fill
.
bitmap
->
rId
,
ref
,
typeImage
);
}
}
void
pptx_slide_context
::
process_common_properties
(
drawing_object_description
&
pic
,
_pptx_drawing
&
drawing
)
void
pptx_slide_context
::
Impl
::
process_common_properties
(
drawing_object_description
&
pic
,
_pptx_drawing
&
drawing
)
{
if
(
pic
.
svg_rect_
)
{
...
...
ASCOfficeOdfFile/src/docx/pptx_slide_context.h
View file @
db202320
...
...
@@ -80,6 +80,7 @@ public:
void
start_frame
();
void
set_image
(
std
::
wstring
const
&
path
);
void
set_chart
(
std
::
wstring
const
&
path
);
void
set_object
(
const
std
::
wstring
&
path
,
const
std
::
wstring
&
progId
);
void
set_ole_object
(
const
std
::
wstring
&
path
,
const
std
::
wstring
&
progId
);
void
set_text_box
();
void
end_frame
();
...
...
@@ -118,15 +119,8 @@ public:
void
set_page_number
();
void
set_date_time
();
private:
void
process_common_properties
(
drawing_object_description
&
obj
,
_pptx_drawing
&
drawing
);
void
default_set
();
void
process_shape
(
drawing_object_description
&
obj
);
void
process_image
(
drawing_object_description
&
obj
);
void
process_chart
(
drawing_object_description
&
obj
);
void
process_table
(
drawing_object_description
&
obj
);
void
process_object
(
drawing_object_description
&
obj
);
int
hlinks_size_
;
class
Impl
;
...
...
ASCOfficeOdfFile/src/odf/draw_frame.cpp
View file @
db202320
...
...
@@ -36,7 +36,6 @@
#include <sstream>
#include <string>
#include <boost/foreach.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/regex.hpp>
...
...
@@ -48,16 +47,20 @@
#include "style_graphic_properties.h"
#include "odfcontext.h"
#include "../docx/xlsx_package.h"
#include "../docx/docx_package.h"
#include "../docx/pptx_package.h"
#include "datatypes/length.h"
#include "datatypes/borderstyle.h"
#include "../../../OfficeUtils/src/OfficeUtils.h"
#include "../../../Common/3dParty/pole/pole.h"
namespace
cpdoccore
{
namespace
odf_reader
{
/// draw-image-attlist
// draw-image-attlist
void
draw_image_attlist
::
add_attributes
(
const
xml
::
attributes_wc_ptr
&
Attributes
)
{
CP_APPLY_ATTR
(
L"draw:filter-name"
,
draw_filter_name_
);
...
...
@@ -283,5 +286,89 @@ void draw_object_ole::add_child_element( xml::sax * Reader, const std::wstring &
CP_NOT_APPLICABLE_ELM
();
}
std
::
wstring
draw_object_ole
::
detectObject
(
const
std
::
wstring
&
fileName
)
{
POLE
::
Storage
*
storage
=
new
POLE
::
Storage
(
fileName
.
c_str
());
if
(
storage
==
NULL
)
return
L""
;
if
(
storage
->
open
(
false
,
false
)
==
false
)
{
delete
storage
;
return
L""
;
}
std
::
wstring
prog
;
POLE
::
Stream
*
pStream
=
new
POLE
::
Stream
(
storage
,
"CompObj"
);
if
((
pStream
)
&&
(
pStream
->
size
()
>
28
))
{
//skip the CompObjHeader
pStream
->
seek
(
28
);
int
sz_obj
=
pStream
->
size
()
-
28
;
std
::
vector
<
std
::
string
>
str
;
while
(
sz_obj
>
0
)
{
_UINT32
sz
=
0
;
pStream
->
read
((
unsigned
char
*
)
&
sz
,
4
);
sz_obj
-=
4
;
if
(
sz
>
sz_obj
)
break
;
unsigned
char
*
data
=
new
unsigned
char
[
sz
];
pStream
->
read
(
data
,
sz
);
str
.
push_back
(
std
::
string
((
char
*
)
data
,
sz
));
delete
[]
data
;
sz_obj
-=
sz
;
}
if
(
!
str
.
empty
())
{
prog
=
std
::
wstring
(
str
.
back
().
begin
(),
str
.
back
().
end
());
}
delete
pStream
;
}
delete
storage
;
return
prog
;
}
std
::
wstring
draw_object
::
office_convert
(
odf_document
*
odfDocument
,
int
type
)
{
std
::
wstring
href_result
;
std
::
wstring
folderPath
=
odfDocument
->
get_folder
();
std
::
wstring
objectOutPath
=
FileSystem
::
Directory
::
CreateDirectoryWithUniqueName
(
folderPath
);
if
(
type
==
2
)
{
oox
::
package
::
xlsx_document
outputXlsx
;
oox
::
xlsx_conversion_context
conversionXlsxContext
(
odfDocument
);
conversionXlsxContext
.
set_output_document
(
&
outputXlsx
);
//conversionContext.set_font_directory (fontsPath);
if
(
odfDocument
->
xlsx_convert
(
conversionXlsxContext
))
{
outputXlsx
.
write
(
objectOutPath
);
href_result
=
common_xlink_attlist_
.
href_
.
get_value_or
(
L"Object"
);
int
pos
=
href_result
.
find
(
L"./"
);
if
(
pos
>=
0
)
href_result
=
href_result
.
substr
(
2
);
href_result
=
L"xlsx"
+
href_result
+
L".xlsx"
;
}
}
if
(
!
href_result
.
empty
())
{
std
::
wstring
temp_file
=
folderPath
+
FILE_SEPARATOR_STR
+
href_result
;
COfficeUtils
oCOfficeUtils
(
NULL
);
oCOfficeUtils
.
CompressFileOrDirectory
(
objectOutPath
.
c_str
(),
temp_file
.
c_str
(),
-
1
);
}
FileSystem
::
Directory
::
DeleteDirectory
(
objectOutPath
);
return
href_result
;
}
}
}
ASCOfficeOdfFile/src/odf/draw_frame.h
View file @
db202320
...
...
@@ -292,16 +292,18 @@ public:
static
const
ElementType
type
=
typeDrawObject
;
CPDOCCORE_DEFINE_VISITABLE
();
virtual
void
docx_convert
(
oox
::
docx_conversion_context
&
Context
);
virtual
void
xlsx_convert
(
oox
::
xlsx_conversion_context
&
Context
);
virtual
void
pptx_convert
(
oox
::
pptx_conversion_context
&
Context
);
virtual
void
docx_convert
(
oox
::
docx_conversion_context
&
Context
);
virtual
void
xlsx_convert
(
oox
::
xlsx_conversion_context
&
Context
);
virtual
void
pptx_convert
(
oox
::
pptx_conversion_context
&
Context
);
draw_object_attlist
draw_object_attlist_
;
odf_types
::
common_xlink_attlist
common_xlink_attlist_
;
private:
virtual
void
add_attributes
(
const
xml
::
attributes_wc_ptr
&
Attributes
);
virtual
void
add_child_element
(
xml
::
sax
*
Reader
,
const
std
::
wstring
&
Ns
,
const
std
::
wstring
&
Name
);
virtual
void
add_attributes
(
const
xml
::
attributes_wc_ptr
&
Attributes
);
virtual
void
add_child_element
(
xml
::
sax
*
Reader
,
const
std
::
wstring
&
Ns
,
const
std
::
wstring
&
Name
);
std
::
wstring
office_convert
(
odf_document
*
odfDocument
,
int
type
);
};
CP_REGISTER_OFFICE_ELEMENT2
(
draw_object
);
...
...
ASCOfficeOdfFile/src/odf/draw_frame_docx.cpp
View file @
db202320
...
...
@@ -49,7 +49,6 @@
#include "draw_common.h"
#include "../docx/docx_drawing.h"
#include "../docx/xlsx_package.h"
#include "chart_build_oox.h"
#include "calcs_styles.h"
...
...
@@ -57,9 +56,6 @@
#include "datatypes/length.h"
#include "datatypes/borderstyle.h"
#include "../../../OfficeUtils/src/OfficeUtils.h"
#include "../../../Common/3dParty/pole/pole.h"
namespace
cpdoccore
{
using
namespace
odf_types
;
...
...
@@ -1511,47 +1507,26 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
}
Context
.
get_drawing_context
().
clear_stream_frame
();
}
if
(
objectBuild
.
object_type_
==
4
)
//embedded sheet
else
if
(
objectBuild
.
object_type_
==
4
)
//embedded sheet
{
bool
&
use_image_replace
=
Context
.
get_drawing_context
().
get_use_image_replace
();
use_image_replace
=
true
;
oox
::
package
::
xlsx_document
outputXlsx
;
oox
::
xlsx_conversion_context
conversionXlsxContext
(
&
objectSubDoc
);
conversionXlsxContext
.
set_output_document
(
&
outputXlsx
);
//conversionContext.set_font_directory (fontsPath);
std
::
wstring
href_new
=
office_convert
(
&
objectSubDoc
,
2
);
if
(
objectSubDoc
.
xlsx_convert
(
conversionXlsxContext
))
if
(
!
href_new
.
empty
(
))
{
drawing
->
type
=
oox
::
typeMsObject
;
std
::
wstring
objectXlsxPath
=
FileSystem
::
Directory
::
CreateDirectoryWithUniqueName
(
folderPath
);
outputXlsx
.
write
(
objectXlsxPath
);
href
=
Context
.
get_drawing_context
().
get_current_object_name
()
+
L".xlsx"
;
std
::
wstring
temp_file
=
folderPath
+
FILE_SEPARATOR_STR
+
href
;
COfficeUtils
oCOfficeUtils
(
NULL
);
oCOfficeUtils
.
CompressFileOrDirectory
(
objectXlsxPath
.
c_str
(),
temp_file
.
c_str
(),
-
1
);
FileSystem
::
Directory
::
DeleteDirectory
(
objectXlsxPath
);
bool
isMediaInternal
=
true
;
drawing
->
objectId
=
Context
.
add_mediaitem
(
href
,
drawing
->
type
,
isMediaInternal
,
temp_file
);
href
+=
FILE_SEPARATOR_STR
+
href_new
;
drawing
->
objectId
=
Context
.
add_mediaitem
(
href
,
drawing
->
type
,
isMediaInternal
,
href
);
drawing
->
objectProgId
=
L"Excel.Sheet.12"
;
}
else
{
objectBuild
.
object_type_
=
0
;
}
}
if
(
objectBuild
.
object_type_
==
0
)
else
{
//замещающая картинка(если она конечно присутствует)
bool
&
use_image_replace
=
Context
.
get_drawing_context
().
get_use_image_replace
();
use_image_replace
=
true
;
}
...
...
@@ -1588,51 +1563,5 @@ void draw_object_ole::docx_convert(oox::docx_conversion_context & Context)
drawing
->
objectProgId
=
detectObject
(
objectPath
);
}
std
::
wstring
draw_object_ole
::
detectObject
(
const
std
::
wstring
&
fileName
)
{
POLE
::
Storage
*
storage
=
new
POLE
::
Storage
(
fileName
.
c_str
());
if
(
storage
==
NULL
)
return
L""
;
if
(
storage
->
open
(
false
,
false
)
==
false
)
{
delete
storage
;
return
L""
;
}
std
::
wstring
prog
;
POLE
::
Stream
*
pStream
=
new
POLE
::
Stream
(
storage
,
"CompObj"
);
if
((
pStream
)
&&
(
pStream
->
size
()
>
28
))
{
//skip the CompObjHeader
pStream
->
seek
(
28
);
int
sz_obj
=
pStream
->
size
()
-
28
;
std
::
vector
<
std
::
string
>
str
;
while
(
sz_obj
>
0
)
{
_UINT32
sz
=
0
;
pStream
->
read
((
unsigned
char
*
)
&
sz
,
4
);
sz_obj
-=
4
;
if
(
sz
>
sz_obj
)
break
;
unsigned
char
*
data
=
new
unsigned
char
[
sz
];
pStream
->
read
(
data
,
sz
);
str
.
push_back
(
std
::
string
((
char
*
)
data
,
sz
));
delete
[]
data
;
sz_obj
-=
sz
;
}
if
(
!
str
.
empty
())
{
prog
=
std
::
wstring
(
str
.
back
().
begin
(),
str
.
back
().
end
());
}
delete
pStream
;
}
delete
storage
;
return
prog
;
}
}
}
ASCOfficeOdfFile/src/odf/draw_frame_pptx.cpp
View file @
db202320
...
...
@@ -61,6 +61,8 @@
#include "datatypes/length.h"
#include "datatypes/borderstyle.h"
#include "../../../OfficeUtils/src/OfficeUtils.h"
namespace
cpdoccore
{
using
namespace
odf_types
;
...
...
@@ -262,11 +264,9 @@ void draw_text_box::pptx_convert(oox::pptx_conversion_context & Context)
void
draw_object
::
pptx_convert
(
oox
::
pptx_conversion_context
&
Context
)
{
try
{
const
std
::
wstring
href
=
common_xlink_attlist_
.
href_
.
get_value_or
(
L""
);
odf_reader
::
odf_document
*
odf_reader
=
Context
.
root
();
std
::
wstring
folderPath
=
odf_reader
->
get_folder
();
std
::
wstring
href
=
common_xlink_attlist_
.
href_
.
get_value_or
(
L""
);
std
::
wstring
folderPath
=
Context
.
root
()
->
get_folder
();
std
::
wstring
objectPath
=
folderPath
+
FILE_SEPARATOR_STR
+
href
;
//normalize path ??? todooo
...
...
@@ -339,6 +339,19 @@ void draw_object::pptx_convert(oox::pptx_conversion_context & Context)
Context
.
get_slide_context
().
set_property
(
_property
(
L"text-content"
,
text_content
));
}
}
else
if
(
objectBuild
.
object_type_
==
4
)
//embedded sheet
{
Context
.
get_slide_context
().
set_use_image_replacement
();
std
::
wstring
href_new
=
office_convert
(
&
objectSubDoc
,
2
);
if
(
!
href_new
.
empty
())
{
bool
isMediaInternal
=
true
;
href
+=
FILE_SEPARATOR_STR
+
href_new
;
Context
.
get_slide_context
().
set_object
(
href
,
L"Excel.Sheet.12"
);
}
}
else
{
//замещающая картинка(если она конечно присутствует)
...
...
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