Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
fairblue
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hosting
chat
fairblue
Commits
db413c59
Unverified
Commit
db413c59
authored
4 years ago
by
Tiago D J
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Update OfficeToPdfConversionService.java
parent
38b51ea3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bbb-common-web/src/main/java/org/bigbluebutton/presentation/imp/OfficeToPdfConversionService.java
+6
-19
6 additions, 19 deletions
...button/presentation/imp/OfficeToPdfConversionService.java
with
6 additions
and
19 deletions
bbb-common-web/src/main/java/org/bigbluebutton/presentation/imp/OfficeToPdfConversionService.java
+
6
−
19
View file @
db413c59
...
...
@@ -16,13 +16,10 @@
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*
*/
package
org.bigbluebutton.presentation.imp
;
import
java.io.File
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.bigbluebutton.presentation.ConversionMessageConstants
;
import
org.bigbluebutton.presentation.SupportedFileTypes
;
import
org.bigbluebutton.presentation.UploadedPresentation
;
...
...
@@ -32,18 +29,19 @@ import org.jodconverter.local.LocalConverter;
import
org.jodconverter.local.office.LocalOfficeManager
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
com.sun.star.document.UpdateDocMode
;
import
com.google.gson.Gson
;
public
class
OfficeToPdfConversionService
{
private
static
Logger
log
=
LoggerFactory
.
getLogger
(
OfficeToPdfConversionService
.
class
);
private
OfficeDocumentValidator2
officeDocumentValidator
;
private
final
OfficeManager
officeManager
;
private
final
LocalConverter
documentConverter
;
private
boolean
skipOfficePrecheck
=
false
;
public
OfficeToPdfConversionService
()
throws
OfficeException
{
final
Map
<
String
,
Object
>
loadProperties
=
new
HashMap
<>();
loadProperties
.
put
(
"Hidden"
,
true
);
loadProperties
.
put
(
"ReadOnly"
,
true
);
loadProperties
.
put
(
"UpdateDocMode"
,
UpdateDocMode
.
NO_UPDATE
);
officeManager
=
LocalOfficeManager
.
builder
()
.
portNumbers
(
8100
,
8101
,
8102
,
8103
,
8104
)
...
...
@@ -51,10 +49,10 @@ public class OfficeToPdfConversionService {
documentConverter
=
LocalConverter
.
builder
()
.
officeManager
(
officeManager
)
.
loadProperties
(
loadProperties
)
.
filterChain
(
new
OfficeDocumentConversionFilter
())
.
build
();
}
/*
* Convert the Office document to PDF. If successful, update
* UploadPresentation.uploadedFile with the new PDF out and
...
...
@@ -74,7 +72,6 @@ public class OfficeToPdfConversionService {
Gson
gson
=
new
Gson
();
String
logStr
=
gson
.
toJson
(
logData
);
log
.
warn
(
" --analytics-- data={}"
,
logStr
);
pres
.
setConversionStatus
(
ConversionMessageConstants
.
OFFICE_DOC_CONVERSION_INVALID_KEY
);
return
pres
;
}
...
...
@@ -89,7 +86,6 @@ public class OfficeToPdfConversionService {
Gson
gson
=
new
Gson
();
String
logStr
=
gson
.
toJson
(
logData
);
log
.
info
(
" --analytics-- data={}"
,
logStr
);
makePdfTheUploadedFileAndSetStepAsSuccess
(
pres
,
pdfOutput
);
}
else
{
Map
<
String
,
Object
>
logData
=
new
HashMap
<>();
...
...
@@ -107,37 +103,30 @@ public class OfficeToPdfConversionService {
}
return
pres
;
}
public
void
initialize
(
UploadedPresentation
pres
)
{
pres
.
setConversionStatus
(
ConversionMessageConstants
.
OFFICE_DOC_CONVERSION_FAILED_KEY
);
}
private
File
setupOutputPdfFile
(
UploadedPresentation
pres
)
{
File
presentationFile
=
pres
.
getUploadedFile
();
String
filenameWithoutExt
=
presentationFile
.
getAbsolutePath
().
substring
(
0
,
presentationFile
.
getAbsolutePath
().
lastIndexOf
(
'.'
));
return
new
File
(
filenameWithoutExt
+
".pdf"
);
}
private
boolean
convertOfficeDocToPdf
(
UploadedPresentation
pres
,
File
pdfOutput
)
{
Office2PdfPageConverter
converter
=
new
Office2PdfPageConverter
();
return
converter
.
convert
(
pres
.
getUploadedFile
(),
pdfOutput
,
0
,
pres
,
documentConverter
);
}
private
void
makePdfTheUploadedFileAndSetStepAsSuccess
(
UploadedPresentation
pres
,
File
pdf
)
{
pres
.
setUploadedFile
(
pdf
);
pres
.
setConversionStatus
(
ConversionMessageConstants
.
OFFICE_DOC_CONVERSION_SUCCESS_KEY
);
}
public
void
setOfficeDocumentValidator
(
OfficeDocumentValidator2
v
)
{
officeDocumentValidator
=
v
;
}
public
void
setSkipOfficePrecheck
(
boolean
skipOfficePrecheck
)
{
this
.
skipOfficePrecheck
=
skipOfficePrecheck
;
}
public
void
start
()
{
try
{
officeManager
.
start
();
...
...
@@ -145,13 +134,11 @@ public class OfficeToPdfConversionService {
log
.
error
(
"Could not start Office Manager"
,
e
);
}
}
public
void
stop
()
{
try
{
officeManager
.
stop
();
}
catch
(
OfficeException
e
)
{
log
.
error
(
"Could not stop Office Manager"
,
e
);
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment