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
ac6cc1ec
Commit
ac6cc1ec
authored
Feb 01, 2017
by
ElenaSubbotina
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pptx file with wrong rels
parent
a1846da0
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
101 additions
and
87 deletions
+101
-87
ASCOfficePPTXFile/PPTXFormat/FileContainer.cpp
ASCOfficePPTXFile/PPTXFormat/FileContainer.cpp
+78
-4
ASCOfficePPTXFile/PPTXFormat/FileContainer.h
ASCOfficePPTXFile/PPTXFormat/FileContainer.h
+1
-0
ASCOfficePPTXFile/PPTXFormat/FileFactory.cpp
ASCOfficePPTXFile/PPTXFormat/FileFactory.cpp
+5
-65
ASCOfficeRtfFile/RtfFormatTest/RtfFormatTest.sln
ASCOfficeRtfFile/RtfFormatTest/RtfFormatTest.sln
+17
-18
No files found.
ASCOfficePPTXFile/PPTXFormat/FileContainer.cpp
View file @
ac6cc1ec
...
...
@@ -42,11 +42,49 @@
#include "../../Common/DocxFormat/Source/DocxFormat/ContentTypes.h"
#include "../../Common/DocxFormat/Source/DocxFormat/External/HyperLink.h"
#include "../../Common/DocxFormat/Source/DocxFormat/FileTypes.h"
#include "../../DesktopEditor/common/Directory.h"
#include <map>
namespace
PPTX
{
static
std
::
wstring
arDefDirectories
[
9
][
2
]
=
//in ppt Directory
{
{
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide"
,
L"slides"
},
{
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout"
,
L"slideLayouts"
},
{
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster"
,
L"slideMasters"
},
{
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide"
,
L"notesSlides"
},
{
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster"
,
L"notesMasters"
},
{
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/handoutMaster"
,
L"handoutMasters"
},
{
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments"
,
L"comments"
},
{
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/commentAuthors"
,
L""
},
{
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme"
,
L"theme"
},
};
static
std
::
wstring
FindFileInDirectory
(
std
::
wstring
directory
,
std
::
wstring
filename
)
{
if
(
directory
.
empty
())
return
L""
;
if
(
directory
[
directory
.
length
()
-
1
]
==
FILE_SEPARATOR_CHAR
)
directory
=
directory
.
substr
(
0
,
directory
.
length
()
-
1
);
int
pos_ppt
=
directory
.
rfind
(
L"ppt"
);
if
(
pos_ppt
>=
0
)
{
directory
=
directory
.
substr
(
0
,
pos_ppt
-
1
);
//root directory
}
CArray
<
std
::
wstring
>
arrFiles
=
NSDirectory
::
GetFiles
(
directory
,
true
);
for
(
int
i
=
0
;
i
<
arrFiles
.
GetCount
();
i
++
)
{
if
(
std
::
wstring
::
npos
!=
arrFiles
[
i
].
find
(
filename
))
{
return
arrFiles
[
i
];
}
}
return
L""
;
}
void
FileContainer
::
read
(
const
OOX
::
CPath
&
filename
)
{
//not implement FileContainer.read
...
...
@@ -70,6 +108,39 @@ namespace PPTX
read
(
rels
,
path
,
map
,
Event
);
}
OOX
::
CPath
FileContainer
::
CorrectPathRels
(
const
OOX
::
CPath
&
path
,
OOX
::
Rels
::
CRelationShip
*
relation
)
{
OOX
::
CPath
filename
=
path
/
relation
->
Target
();
if
(
NSFile
::
CFileBinary
::
Exists
(
filename
.
GetPath
())
==
true
)
return
filename
;
//file_1_ (1).pptx
std
::
wstring
strDefDirectory
;
for
(
int
i
=
0
;
i
<
9
;
i
++
)
{
if
(
relation
->
Type
()
==
arDefDirectories
[
i
][
0
])
{
strDefDirectory
=
arDefDirectories
[
i
][
1
];
break
;
}
}
OOX
::
CPath
new_filename
=
strDefDirectory
+
FILE_SEPARATOR_STR
+
relation
->
Filename
().
GetFilename
();
filename
=
path
/
new_filename
;
if
(
NSFile
::
CFileBinary
::
Exists
(
filename
.
GetPath
())
==
false
)
{
filename
=
FindFileInDirectory
(
path
.
GetPath
(),
relation
->
Filename
().
GetFilename
());
// find true path by filename
if
(
NSFile
::
CFileBinary
::
Exists
(
filename
.
GetPath
())
==
false
)
return
filename
;
}
*
relation
=
OOX
::
Rels
::
CRelationShip
(
relation
->
rId
(),
relation
->
Type
(),
filename
);
return
filename
;
}
void
FileContainer
::
read
(
const
OOX
::
CRels
&
rels
,
const
OOX
::
CPath
&
path
,
FileMap
&
map
,
IPPTXEvent
*
Event
)
{
bool
bIsSlide
=
false
;
...
...
@@ -82,7 +153,8 @@ namespace PPTX
for
(
size_t
i
=
0
;
i
<
nCount
;
++
i
)
{
OOX
::
Rels
::
CRelationShip
*
pRelation
=
rels
.
m_arrRelations
[
i
];
OOX
::
CPath
normPath
=
path
/
pRelation
->
Target
();
OOX
::
CPath
normPath
=
CorrectPathRels
(
path
,
pRelation
);
std
::
map
<
std
::
wstring
,
smart_ptr
<
OOX
::
File
>>::
const_iterator
pPair
=
map
.
find
(
normPath
);
...
...
@@ -112,7 +184,7 @@ namespace PPTX
{
long
percent
=
Event
->
GetPercent
();
smart_ptr
<
OOX
::
File
>
file
=
PPTX
::
FileFactory
::
CreateFilePPTX
(
p
ath
,
*
pRelation
,
map
);
smart_ptr
<
OOX
::
File
>
file
=
PPTX
::
FileFactory
::
CreateFilePPTX
(
normP
ath
,
*
pRelation
,
map
);
if
(
file
.
IsInit
()
==
false
)
continue
;
...
...
@@ -228,7 +300,9 @@ namespace PPTX
{
OOX
::
Rels
::
CRelationShip
*
pRelation
=
rels
.
m_arrRelations
[
i
];
smart_ptr
<
OOX
::
File
>
_file
=
PPTX
::
FileFactory
::
CreateFilePPTX_OnlyMedia
(
path
,
*
pRelation
);
OOX
::
CPath
normPath
=
CorrectPathRels
(
path
,
pRelation
);
smart_ptr
<
OOX
::
File
>
_file
=
PPTX
::
FileFactory
::
CreateFilePPTX_OnlyMedia
(
normPath
,
*
pRelation
);
Add
(
pRelation
->
rId
(),
_file
);
}
}
...
...
ASCOfficePPTXFile/PPTXFormat/FileContainer.h
View file @
ac6cc1ec
...
...
@@ -64,6 +64,7 @@ namespace PPTX
void
write
(
OOX
::
CRels
&
rels
,
const
OOX
::
CPath
&
current
,
const
OOX
::
CPath
&
directory
,
OOX
::
CContentTypes
&
content
)
const
;
void
WrittenSetFalse
();
OOX
::
CPath
CorrectPathRels
(
const
OOX
::
CPath
&
path
,
OOX
::
Rels
::
CRelationShip
*
relation
);
long
m_lPercent
;
bool
m_bCancelled
;
...
...
ASCOfficePPTXFile/PPTXFormat/FileFactory.cpp
View file @
ac6cc1ec
...
...
@@ -69,76 +69,16 @@
#include "FileMap.h"
#include "../../DesktopEditor/common/Directory.h"
namespace
PPTX
{
static
std
::
wstring
arDefDirectories
[
8
][
2
]
=
//in ppt Directory
{
{
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide"
,
L"slides"
},
{
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout"
,
L"slideLayouts"
},
{
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster"
,
L"slideMasters"
},
{
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide"
,
L"notesSlides"
},
{
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster"
,
L"notesMasters"
},
{
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/handoutMaster"
,
L"handoutMasters"
},
{
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments"
,
L"comments"
},
{
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/commentAuthors"
,
L""
}
};
static
std
::
wstring
FindFileInDirectory
(
std
::
wstring
directory
,
std
::
wstring
filename
)
{
if
(
directory
.
empty
())
return
L""
;
if
(
directory
[
directory
.
length
()
-
1
]
==
FILE_SEPARATOR_CHAR
)
directory
.
substr
(
0
,
directory
.
length
()
-
1
);
CArray
<
std
::
wstring
>
arrFiles
=
NSDirectory
::
GetFiles
(
directory
,
true
);
for
(
int
i
=
0
;
i
<
arrFiles
.
GetCount
();
i
++
)
{
if
(
std
::
wstring
::
npos
!=
arrFiles
[
i
].
find
(
filename
))
const
smart_ptr
<
OOX
::
File
>
FileFactory
::
CreateFilePPTX
(
const
OOX
::
CPath
&
filename
,
OOX
::
Rels
::
CRelationShip
&
relation
,
FileMap
&
map
)
{
return
arrFiles
[
i
].
substr
(
directory
.
length
()
+
1
);
}
}
return
L""
;
}
const
smart_ptr
<
OOX
::
File
>
FileFactory
::
CreateFilePPTX
(
const
OOX
::
CPath
&
path
,
OOX
::
Rels
::
CRelationShip
&
relation
,
FileMap
&
map
)
{
OOX
::
CPath
filename
=
path
/
relation
.
Filename
();
if
(
NSFile
::
CFileBinary
::
Exists
(
filename
.
GetPath
())
==
false
)
{
//file_1_ (1).pptx
std
::
wstring
strDefDirectory
;
for
(
int
i
=
0
;
i
<
8
;
i
++
)
{
if
(
relation
.
Type
()
==
arDefDirectories
[
i
][
0
])
{
strDefDirectory
=
arDefDirectories
[
i
][
1
];
break
;
}
}
OOX
::
CPath
new_filename
=
strDefDirectory
+
FILE_SEPARATOR_STR
+
relation
.
Filename
().
GetFilename
();
filename
=
path
/
new_filename
;
if
(
NSFile
::
CFileBinary
::
Exists
(
filename
.
GetPath
())
==
false
)
{
new_filename
=
FindFileInDirectory
(
path
.
GetPath
(),
relation
.
Filename
().
GetFilename
());
// find true path by filename
filename
=
path
/
new_filename
;
if
(
NSFile
::
CFileBinary
::
Exists
(
filename
.
GetPath
())
==
false
)
return
smart_ptr
<
OOX
::
File
>
(
NULL
);
}
relation
=
OOX
::
Rels
::
CRelationShip
(
relation
.
rId
(),
relation
.
Type
(),
new_filename
);
}
if
(
relation
.
Type
()
==
OOX
::
Presentation
::
FileTypes
::
App
)
return
smart_ptr
<
OOX
::
File
>
(
new
PPTX
::
App
(
filename
,
map
));
else
if
(
relation
.
Type
()
==
OOX
::
Presentation
::
FileTypes
::
Core
)
...
...
@@ -202,7 +142,7 @@ namespace PPTX
return
smart_ptr
<
OOX
::
File
>
(
new
OOX
::
UnknowTypeFile
());
}
const
smart_ptr
<
OOX
::
File
>
FileFactory
::
CreateFilePPTX_OnlyMedia
(
const
OOX
::
CPath
&
path
,
OOX
::
Rels
::
CRelationShip
&
relation
)
const
smart_ptr
<
OOX
::
File
>
FileFactory
::
CreateFilePPTX_OnlyMedia
(
const
OOX
::
CPath
&
norm_filename
,
OOX
::
Rels
::
CRelationShip
&
relation
)
{
bool
bIsDownload
=
false
;
std
::
wstring
strFile
=
relation
.
Filename
().
GetPath
();
...
...
@@ -216,7 +156,7 @@ namespace PPTX
if
(
0
==
n1
||
0
==
n2
||
0
==
n3
||
0
==
n4
)
bIsDownload
=
true
;
OOX
::
CPath
filename
=
path
/
relation
.
Filename
()
;
OOX
::
CPath
filename
=
norm_filename
;
if
(
bIsDownload
)
filename
=
relation
.
Filename
();
...
...
ASCOfficeRtfFile/RtfFormatTest/RtfFormatTest.sln
View file @
ac6cc1ec
...
...
@@ -3,7 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RtfFormatLib", "..\RtfFormatLib\Win32\RtfFormatLib.vcproj", "{AF2D00A7-A351-4700-AE88-C1D9ADE29345}"
ProjectSection(ProjectDependencies) = postProject
{A100103A-353E-45E8-A9B8-90B87CC5C0B0} = {A100103A-353E-45E8-A9B8-90B87CC5C0B0}
{9CAA294E-58C3-4CEB-ABA0-CB9786CA5540} = {9CAA294E-58C3-4CEB-ABA0-CB9786CA5540}
EndProjectSection
EndProject
...
...
@@ -14,21 +13,21 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DocxFormat", "..\..\Common\
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "raster", "..\..\DesktopEditor\raster\raster_vs2005.vcproj", "{9CAA294E-58C3-4CEB-ABA0-CB9786CA5540}"
ProjectSection(ProjectDependencies) = postProject
{0588563C-F05C-428C-B21A-DD74756628B3} = {0588563C-F05C-428C-B21A-DD74756628B3}
{BC52A07C-A797-423D-8C4F-8678805BBB36} = {BC52A07C-A797-423D-8C4F-8678805BBB36}
{0588563C-F05C-428C-B21A-DD74756628B3} = {0588563C-F05C-428C-B21A-DD74756628B3}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cximage", "..\..\DesktopEditor\cximage\CxImage\cximage_vs2005.vcproj", "{BC52A07C-A797-423D-8C4F-8678805BBB36}"
ProjectSection(ProjectDependencies) = postProject
{43A0E60E-5C4A-4C09-A29B-7683F503BBD7} = {43A0E60E-5C4A-4C09-A29B-7683F503BBD7}
{764C3A2D-FB0F-428E-B1C7-62D1DD2CE239} = {764C3A2D-FB0F-428E-B1C7-62D1DD2CE239}
{DF861D33-9BC1-418C-82B1-581F590FE169} = {DF861D33-9BC1-418C-82B1-581F590FE169}
{0588563C-F05C-428C-B21A-DD74756628B3} = {0588563C-F05C-428C-B21A-DD74756628B3}
{40A69F40-063E-43FD-8543-455495D8733E} = {40A69F40-063E-43FD-8543-455495D8733E}
{9A037A69-D1DF-4505-AB2A-6CB3641C476E} = {9A037A69-D1DF-4505-AB2A-6CB3641C476E}
{EE1B576A-07C5-4ACC-920F-81C41DD0C8C1} = {EE1B576A-07C5-4ACC-920F-81C41DD0C8C1}
{FFDA5DA1-BB65-4695-B678-BE59B4A1355D} = {FFDA5DA1-BB65-4695-B678-BE59B4A1355D}
{818753F2-DBB9-4D3B-898A-A604309BE470} = {818753F2-DBB9-4D3B-898A-A604309BE470}
{FFDA5DA1-BB65-4695-B678-BE59B4A1355D} = {FFDA5DA1-BB65-4695-B678-BE59B4A1355D}
{EE1B576A-07C5-4ACC-920F-81C41DD0C8C1} = {EE1B576A-07C5-4ACC-920F-81C41DD0C8C1}
{9A037A69-D1DF-4505-AB2A-6CB3641C476E} = {9A037A69-D1DF-4505-AB2A-6CB3641C476E}
{40A69F40-063E-43FD-8543-455495D8733E} = {40A69F40-063E-43FD-8543-455495D8733E}
{0588563C-F05C-428C-B21A-DD74756628B3} = {0588563C-F05C-428C-B21A-DD74756628B3}
{DF861D33-9BC1-418C-82B1-581F590FE169} = {DF861D33-9BC1-418C-82B1-581F590FE169}
{764C3A2D-FB0F-428E-B1C7-62D1DD2CE239} = {764C3A2D-FB0F-428E-B1C7-62D1DD2CE239}
{43A0E60E-5C4A-4C09-A29B-7683F503BBD7} = {43A0E60E-5C4A-4C09-A29B-7683F503BBD7}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jasper", "..\..\DesktopEditor\cximage\jasper\jasper_vs2005.vcproj", "{FFDA5DA1-BB65-4695-B678-BE59B4A1355D}"
...
...
@@ -53,15 +52,15 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OfficeUtilsLib", "..\..\Off
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RtfFormatTest", "RtfFormatTest.vcproj", "{0F49D5D1-A8D3-4F97-8BC1-E2F65BB00C10}"
ProjectSection(ProjectDependencies) = postProject
{21663823-DE45-479B-91D0-B4FEF4916EF0} = {21663823-DE45-479B-91D0-B4FEF4916EF0}
{F8274B05-168E-4D6E-B843-AA7510725363} = {F8274B05-168E-4D6E-B843-AA7510725363}
{C739151F-5384-41DF-A1A6-F089E2C1AD56} = {C739151F-5384-41DF-A1A6-F089E2C1AD56}
{37CA072A-5BDE-498B-B3A7-5E404F5F9BF2} = {37CA072A-5BDE-498B-B3A7-5E404F5F9BF2}
{A100103A-353E-45E8-A9B8-90B87CC5C0B0} = {A100103A-353E-45E8-A9B8-90B87CC5C0B0}
{617F9069-5E37-4B80-9A3A-E77AFC4CC7AD} = {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}
{36636678-AE25-4BE6-9A34-2561D1BCF302} = {36636678-AE25-4BE6-9A34-2561D1BCF302}
{AF2D00A7-A351-4700-AE88-C1D9ADE29345} = {AF2D00A7-A351-4700-AE88-C1D9ADE29345}
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B} = {78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}
{AF2D00A7-A351-4700-AE88-C1D9ADE29345} = {AF2D00A7-A351-4700-AE88-C1D9ADE29345}
{36636678-AE25-4BE6-9A34-2561D1BCF302} = {36636678-AE25-4BE6-9A34-2561D1BCF302}
{617F9069-5E37-4B80-9A3A-E77AFC4CC7AD} = {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}
{A100103A-353E-45E8-A9B8-90B87CC5C0B0} = {A100103A-353E-45E8-A9B8-90B87CC5C0B0}
{37CA072A-5BDE-498B-B3A7-5E404F5F9BF2} = {37CA072A-5BDE-498B-B3A7-5E404F5F9BF2}
{C739151F-5384-41DF-A1A6-F089E2C1AD56} = {C739151F-5384-41DF-A1A6-F089E2C1AD56}
{F8274B05-168E-4D6E-B843-AA7510725363} = {F8274B05-168E-4D6E-B843-AA7510725363}
{21663823-DE45-479B-91D0-B4FEF4916EF0} = {21663823-DE45-479B-91D0-B4FEF4916EF0}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PPTXFormat", "..\..\ASCOfficePPTXFile\PPTXLib\PPTXFormat.vcproj", "{36636678-AE25-4BE6-9A34-2561D1BCF302}"
...
...
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