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
244d549c
Commit
244d549c
authored
Oct 03, 2017
by
Oleg Korshul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--save-use-only-names mode
parent
7a27150d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
101 additions
and
2 deletions
+101
-2
DesktopEditor/doctrenderer/docbuilder_p.h
DesktopEditor/doctrenderer/docbuilder_p.h
+77
-2
DesktopEditor/doctrenderer/doctrenderer.pro
DesktopEditor/doctrenderer/doctrenderer.pro
+24
-0
No files found.
DesktopEditor/doctrenderer/docbuilder_p.h
View file @
244d549c
...
...
@@ -56,6 +56,10 @@
#include <stdio.h>
#endif
#ifdef BUIDLER_OPEN_DOWNLOAD_ENABLED
#include "../../Common/FileDownloader/FileDownloader.h"
#endif
template
<
typename
T
>
class
CScopeWrapper
{
...
...
@@ -558,6 +562,8 @@ namespace NSDoctRenderer
bool
m_bIsCacheScript
;
std
::
wstring
m_sFolderForSaveOnlyUseNames
;
std
::
string
m_sGlobalVariable
;
bool
m_bIsGlobalVariableUse
;
public:
...
...
@@ -851,6 +857,64 @@ namespace NSDoctRenderer
#endif
}
void
MoveFileOpen
(
const
std
::
wstring
&
from
,
const
std
::
wstring
&
to
)
{
#ifdef BUIDLER_OPEN_DOWNLOAD_ENABLED
int
n1
=
(
int
)
from
.
find
(
L"www"
);
int
n2
=
(
int
)
from
.
find
(
L"http"
);
int
n3
=
(
int
)
from
.
find
(
L"ftp"
);
int
n4
=
(
int
)
from
.
find
(
L"https"
);
//если nI сранивать не с 0, то будут проблемы
//потому что в инсталяции мы кладем файлы в /var/www...
if
(
0
==
n1
||
0
==
n2
||
0
==
n3
||
0
==
n4
)
{
CFileDownloader
oDownloader
(
from
,
false
);
oDownloader
.
SetFilePath
(
to
);
if
(
oDownloader
.
DownloadSync
())
return
;
}
#endif
#ifdef BUIDLER_OPEN_BASE64_ENABLED
if
(
0
==
from
.
find
(
L"data:"
))
{
std
::
wstring
::
size_type
findBase64
=
from
.
find
(
L"base64,"
);
if
(
std
::
wstring
::
npos
!=
findBase64
)
{
int
nStartBase64
=
(
int
)
findBase64
;
if
(
50
>
nStartBase64
)
{
nStartBase64
+=
7
;
const
wchar_t
*
pStart
=
from
.
c_str
()
+
nStartBase64
;
int
nDataLen
=
(
int
)
from
.
length
()
-
nStartBase64
;
std
::
string
sBase64
=
NSFile
::
CUtf8Converter
::
GetUtf8StringFromUnicode2
(
pStart
,
(
LONG
)
nDataLen
,
false
);
BYTE
*
pDataDst
=
NULL
;
int
nDataDstLen
=
0
;
if
(
NSFile
::
CBase64Converter
::
Decode
(
sBase64
.
c_str
(),
(
int
)
sBase64
.
length
(),
pDataDst
,
nDataLen
))
{
NSFile
::
CFileBinary
oFileDst
;
if
(
oFileDst
.
CreateFileW
(
to
))
{
oFileDst
.
WriteFile
(
pDataDst
,
(
DWORD
)
nDataDstLen
);
oFileDst
.
CloseFile
();
RELEASEARRAYOBJECTS
(
pDataDst
);
return
;
}
RELEASEARRAYOBJECTS
(
pDataDst
);
}
}
}
}
#endif
NSFile
::
CFileBinary
::
Copy
(
from
,
to
);
}
int
OpenFile
(
const
std
::
wstring
&
path
,
const
std
::
wstring
&
params
)
{
Init
();
...
...
@@ -861,7 +925,7 @@ namespace NSDoctRenderer
NSDirectory
::
CreateDirectory
(
m_sFileDir
+
L"/changes"
);
std
::
wstring
sFileCopy
=
m_sFileDir
+
L"/origin."
+
NSCommon
::
GetFileExtention
(
path
);
NSFile
::
CFileBinary
::
Copy
(
path
,
sFileCopy
);
MoveFileOpen
(
path
,
sFileCopy
);
COfficeFileFormatChecker
oChecker
;
if
(
!
oChecker
.
isOfficeFile
(
path
))
...
...
@@ -1054,7 +1118,16 @@ namespace NSDoctRenderer
NSStringUtils
::
CStringBuilder
oBuilder
;
std
::
wstring
_path
=
path
;
std
::
wstring
sDstFileDir
=
NSCommon
::
GetDirectoryName
(
_path
);
if
(
!
m_sFolderForSaveOnlyUseNames
.
empty
())
{
_path
=
m_sFolderForSaveOnlyUseNames
;
wchar_t
last
=
m_sFolderForSaveOnlyUseNames
.
c_str
()[
m_sFolderForSaveOnlyUseNames
.
length
()
-
1
];
if
(
last
!=
'/'
&&
last
!=
'\\'
)
_path
+=
L"/"
;
_path
+=
NSCommon
::
GetFileName
(
path
);
}
std
::
wstring
sDstFileDir
=
NSCommon
::
GetDirectoryName
(
_path
);
if
((
sDstFileDir
!=
_path
)
&&
!
NSDirectory
::
Exists
(
sDstFileDir
))
NSDirectory
::
CreateDirectories
(
sDstFileDir
);
...
...
@@ -1642,6 +1715,8 @@ namespace NSDoctRenderer
m_pInternal
->
m_oParams
.
m_sWorkDir
=
std
::
wstring
(
value
);
else
if
(
sParam
==
"--cache-scripts"
)
m_pInternal
->
m_bIsCacheScript
=
(
std
::
wstring
(
value
)
==
L"true"
);
else
if
(
sParam
==
"--save-use-only-names"
)
m_pInternal
->
m_sFolderForSaveOnlyUseNames
=
std
::
wstring
(
value
);
else
if
(
sParam
==
"--argument"
)
{
std
::
wstring
sArg
(
value
);
...
...
DesktopEditor/doctrenderer/doctrenderer.pro
View file @
244d549c
...
...
@@ -44,3 +44,27 @@ unix {
target
.
path
=
/
usr
/
lib
INSTALLS
+=
target
}
#
downloader
DEFINES
+=
BUIDLER_OPEN_DOWNLOAD_ENABLED
DEFINES
+=
BUIDLER_OPEN_BASE64_ENABLED
HEADERS
+=
..
/../
Common
/
FileDownloader
/
FileDownloader
.
h
core_windows
{
SOURCES
+=
\
..
/../
Common
/
FileDownloader
/
FileDownloader_win
.
cpp
LIBS
+=
-
lurlmon
}
core_linux
{
SOURCES
+=
\
..
/../
Common
/
FileDownloader
/
FileDownloader_curl
.
cpp
LIBS
+=
-
lcurl
}
core_mac
{
OBJECTIVE_SOURCES
+=
\
..
/../
Common
/
FileDownloader
/
FileDownloader_mac
.
mm
LIBS
+=
-
framework
AppKit
}
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