Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
P
PDF Viewer Scanner White ago
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
kuxulei
PDF Viewer Scanner White ago
Commits
2327df15
Commit
2327df15
authored
Sep 29, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
9e47eb95
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
356 additions
and
442 deletions
+356
-442
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+1
-0
ExcelActivity.kt
.../pdfviewerscannerwhite/ui/document/excel/ExcelActivity.kt
+1
-2
PptActivity.kt
...base/pdfviewerscannerwhite/ui/document/ppt/PptActivity.kt
+1
-2
WordActivity.kt
...se/pdfviewerscannerwhite/ui/document/word/WordActivity.kt
+23
-20
MainActivity.kt
...va/com/base/pdfviewerscannerwhite/ui/main/MainActivity.kt
+10
-0
DocViewerActivity.kt
...ary/src/main/java/com/cherry/lib/doc/DocViewerActivity.kt
+1
-4
IOffice.java
library/src/main/java/com/cherry/lib/doc/office/IOffice.java
+5
-3
APageListView.java
...y/lib/doc/office/system/beans/pagelist/APageListView.java
+2
-1
PrintWord.java
.../java/com/cherry/lib/doc/office/wp/control/PrintWord.java
+2
-0
WPControl.java
.../java/com/cherry/lib/doc/office/wp/control/WPControl.java
+194
-279
Word.java
.../main/java/com/cherry/lib/doc/office/wp/control/Word.java
+17
-3
LayoutKit.java
...ain/java/com/cherry/lib/doc/office/wp/view/LayoutKit.java
+11
-2
PageRoot.java
...main/java/com/cherry/lib/doc/office/wp/view/PageRoot.java
+86
-122
WPLayouter.java
...in/java/com/cherry/lib/doc/office/wp/view/WPLayouter.java
+1
-1
DocView.kt
library/src/main/java/com/cherry/lib/doc/widget/DocView.kt
+1
-3
No files found.
app/src/main/AndroidManifest.xml
View file @
2327df15
...
@@ -61,6 +61,7 @@
...
@@ -61,6 +61,7 @@
<activity
<activity
android:name=
".ui.document.word.WordActivity"
android:name=
".ui.document.word.WordActivity"
android:exported=
"false"
android:exported=
"false"
android:launchMode=
"singleTop"
android:screenOrientation=
"portrait"
android:screenOrientation=
"portrait"
android:theme=
"@style/Theme.PDFViewerScannerWhite"
android:theme=
"@style/Theme.PDFViewerScannerWhite"
tools:ignore=
"DiscouragedApi,LockedOrientationActivity"
/>
tools:ignore=
"DiscouragedApi,LockedOrientationActivity"
/>
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/ui/document/excel/ExcelActivity.kt
View file @
2327df15
...
@@ -261,11 +261,10 @@ class ExcelActivity : BaseActivity<ActivityExcelBinding>() {
...
@@ -261,11 +261,10 @@ class ExcelActivity : BaseActivity<ActivityExcelBinding>() {
fileType
=
intent
?.
getIntExtra
(
Constant
.
INTENT_TYPE_KEY
,
-
1
)
?:
-
1
fileType
=
intent
?.
getIntExtra
(
Constant
.
INTENT_TYPE_KEY
,
-
1
)
?:
-
1
engine
=
intent
?.
getIntExtra
(
Constant
.
INTENT_ENGINE_KEY
,
DocEngine
.
INTERNAL
.
value
)
?:
DocEngine
.
INTERNAL
.
value
engine
=
intent
?.
getIntExtra
(
Constant
.
INTENT_ENGINE_KEY
,
DocEngine
.
INTERNAL
.
value
)
?:
DocEngine
.
INTERNAL
.
value
binding
.
mDocView
.
openDoc
(
this
,
pathOrUri
,
docSourceType
,
fileType
,
false
,
DocEngine
.
values
().
first
{
it
.
value
==
engine
}
)
binding
.
mDocView
.
openDoc
(
this
,
pathOrUri
,
docSourceType
,
fileType
,
false
)
LogEx
.
logDebug
(
TAG
,
"initData-pathOrUri = $pathOrUri"
)
LogEx
.
logDebug
(
TAG
,
"initData-pathOrUri = $pathOrUri"
)
LogEx
.
logDebug
(
TAG
,
"initData-docSourceType = $docSourceType"
)
LogEx
.
logDebug
(
TAG
,
"initData-docSourceType = $docSourceType"
)
LogEx
.
logDebug
(
TAG
,
"initData-fileType = $fileType"
)
LogEx
.
logDebug
(
TAG
,
"initData-fileType = $fileType"
)
LogEx
.
logDebug
(
TAG
,
"initData-engine = $engine"
)
}
}
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/ui/document/ppt/PptActivity.kt
View file @
2327df15
...
@@ -107,11 +107,10 @@ class PptActivity : BaseActivity<ActivityPptBinding>() {
...
@@ -107,11 +107,10 @@ class PptActivity : BaseActivity<ActivityPptBinding>() {
fileType
=
intent
?.
getIntExtra
(
Constant
.
INTENT_TYPE_KEY
,
-
1
)
?:
-
1
fileType
=
intent
?.
getIntExtra
(
Constant
.
INTENT_TYPE_KEY
,
-
1
)
?:
-
1
engine
=
intent
?.
getIntExtra
(
Constant
.
INTENT_ENGINE_KEY
,
DocEngine
.
INTERNAL
.
value
)
?:
DocEngine
.
INTERNAL
.
value
engine
=
intent
?.
getIntExtra
(
Constant
.
INTENT_ENGINE_KEY
,
DocEngine
.
INTERNAL
.
value
)
?:
DocEngine
.
INTERNAL
.
value
binding
.
mDocView
.
openDoc
(
this
,
pathOrUri
,
docSourceType
,
fileType
,
false
,
DocEngine
.
values
().
first
{
it
.
value
==
engine
}
)
binding
.
mDocView
.
openDoc
(
this
,
pathOrUri
,
docSourceType
,
fileType
,
false
)
LogEx
.
logDebug
(
TAG
,
"initData-docUrl = $pathOrUri"
)
LogEx
.
logDebug
(
TAG
,
"initData-docUrl = $pathOrUri"
)
LogEx
.
logDebug
(
TAG
,
"initData-docSourceType = $docSourceType"
)
LogEx
.
logDebug
(
TAG
,
"initData-docSourceType = $docSourceType"
)
LogEx
.
logDebug
(
TAG
,
"initData-fileType = $fileType"
)
LogEx
.
logDebug
(
TAG
,
"initData-fileType = $fileType"
)
LogEx
.
logDebug
(
TAG
,
"initData-engine = $engine"
)
}
}
private
fun
showTopLayout
()
{
private
fun
showTopLayout
()
{
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/ui/document/word/WordActivity.kt
View file @
2327df15
...
@@ -69,13 +69,11 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
...
@@ -69,13 +69,11 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
LogEx
.
logDebug
(
TAG
,
"show"
)
LogEx
.
logDebug
(
TAG
,
"show"
)
}
}
}
}
}
}
private
fun
setVerticalSeekbar
(
current
:
Int
,
max
:
Int
)
{
private
fun
setVerticalSeekbar
(
current
:
Int
,
max
:
Int
)
{
binding
.
verticalSeekbar
.
showThumb
=
true
binding
.
verticalSeekbar
.
showThumb
=
true
binding
.
verticalSeekbar
.
thumbContainerColor
=
Color
.
TRANSPARENT
binding
.
verticalSeekbar
.
thumbContainerColor
=
Color
.
TRANSPARENT
binding
.
verticalSeekbar
.
thumbPlaceholderDrawable
=
binding
.
verticalSeekbar
.
thumbPlaceholderDrawable
=
ContextCompat
.
getDrawable
(
this
,
R
.
mipmap
.
fanye
)
ContextCompat
.
getDrawable
(
this
,
R
.
mipmap
.
fanye
)
if
(
binding
.
verticalSeekbar
.
maxValue
!=
max
-
1
)
{
if
(
binding
.
verticalSeekbar
.
maxValue
!=
max
-
1
)
{
...
@@ -93,6 +91,7 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
...
@@ -93,6 +91,7 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
cancelSearchUI
()
cancelSearchUI
()
return
@addCallback
return
@addCallback
}
}
LogEx
.
logDebug
(
TAG
,
"finishToMain"
)
finishToMain
()
finishToMain
()
}
}
binding
.
flFanhui
.
setOnClickListener
{
binding
.
flFanhui
.
setOnClickListener
{
...
@@ -103,11 +102,11 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
...
@@ -103,11 +102,11 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
}
}
binding
.
ivMore
.
setOnClickListener
{
binding
.
ivMore
.
setOnClickListener
{
showDocumentMore
(
wordDocumentBean
,
totalPageNumber
-
1
)
{
pageIndex
->
showDocumentMore
(
wordDocumentBean
,
totalPageNumber
-
1
)
{
pageIndex
->
val
wpControl
:
WPControl
=
(
binding
.
mDocView
.
iOffice
?.
control
?.
appControl
as
WPControl
)
val
wpControl
:
WPControl
?
=
(
binding
.
mDocView
.
iOffice
?.
control
?.
appControl
as
WPControl
?
)
if
(
pageIndex
>
currentPageNumber
)
{
if
(
pageIndex
>
currentPageNumber
)
{
wpControl
.
wpView
.
showPage
(
pageIndex
,
APP_PAGE_DOWN_ID
)
wpControl
?.
wpView
?
.
showPage
(
pageIndex
,
APP_PAGE_DOWN_ID
)
}
else
{
}
else
{
wpControl
.
wpView
.
showPage
(
pageIndex
,
APP_PAGE_UP_ID
)
wpControl
?.
wpView
?
.
showPage
(
pageIndex
,
APP_PAGE_UP_ID
)
}
}
// wpControl.actionEvent(APP_PAGE_UP_ID, null)
// wpControl.actionEvent(APP_PAGE_UP_ID, null)
}
}
...
@@ -120,8 +119,8 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
...
@@ -120,8 +119,8 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
binding
.
tvPageCount
.
visibility
=
View
.
VISIBLE
binding
.
tvPageCount
.
visibility
=
View
.
VISIBLE
haveSearchResult
=
false
haveSearchResult
=
false
hideBottomLayout
()
hideBottomLayout
()
val
wpControl
:
WPControl
=
(
binding
.
mDocView
.
iOffice
?.
control
?.
appControl
as
WPControl
)
val
wpControl
:
WPControl
?
=
(
binding
.
mDocView
.
iOffice
?.
control
?.
appControl
as
WPControl
?
)
(
wpControl
.
find
as
WPFind
)
.
resetSearchResult
()
(
wpControl
?.
find
as
WPFind
?)
?
.
resetSearchResult
()
}
}
binding
.
editSearch
.
setOnEditorActionListener
{
v
,
actionId
,
event
->
binding
.
editSearch
.
setOnEditorActionListener
{
v
,
actionId
,
event
->
...
@@ -133,23 +132,23 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
...
@@ -133,23 +132,23 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
false
false
}
}
binding
.
flPre
.
setOnClickListener
{
binding
.
flPre
.
setOnClickListener
{
val
wpControl
:
WPControl
=
(
binding
.
mDocView
.
iOffice
?.
control
?.
appControl
as
WPControl
)
val
wpControl
:
WPControl
?
=
(
binding
.
mDocView
.
iOffice
?.
control
?.
appControl
as
WPControl
?
)
(
wpControl
.
find
as
WPFind
)
.
findBackward
()
(
wpControl
?.
find
as
WPFind
?)
?
.
findBackward
()
}
}
binding
.
flNext
.
setOnClickListener
{
binding
.
flNext
.
setOnClickListener
{
val
wpControl
:
WPControl
=
(
binding
.
mDocView
.
iOffice
?.
control
?.
appControl
as
WPControl
)
val
wpControl
:
WPControl
?
=
(
binding
.
mDocView
.
iOffice
?.
control
?.
appControl
as
WPControl
?
)
(
wpControl
.
find
as
WPFind
).
findForward
()
(
wpControl
?
.
find
as
WPFind
).
findForward
()
}
}
binding
.
verticalSeekbar
.
setOnReleaseListener
{
progress
->
binding
.
verticalSeekbar
.
setOnReleaseListener
{
progress
->
val
wpControl
:
WPControl
=
(
binding
.
mDocView
.
iOffice
?.
control
?.
appControl
as
WPControl
)
val
wpControl
:
WPControl
?
=
(
binding
.
mDocView
.
iOffice
?.
control
?.
appControl
as
WPControl
?
)
LogEx
.
logDebug
(
TAG
,
"progress=$progress"
)
LogEx
.
logDebug
(
TAG
,
"progress=$progress"
)
val
pageIndex
=
totalPageNumber
-
1
-
progress
val
pageIndex
=
totalPageNumber
-
1
-
progress
if
(
progress
>
currentPageNumber
)
{
if
(
progress
>
currentPageNumber
)
{
wpControl
.
wpView
.
showPage
(
pageIndex
,
APP_PAGE_DOWN_ID
)
wpControl
?.
wpView
?
.
showPage
(
pageIndex
,
APP_PAGE_DOWN_ID
)
}
else
{
}
else
{
wpControl
.
wpView
.
showPage
(
pageIndex
,
APP_PAGE_UP_ID
)
wpControl
?.
wpView
?
.
showPage
(
pageIndex
,
APP_PAGE_UP_ID
)
}
}
}
}
}
}
...
@@ -160,10 +159,10 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
...
@@ -160,10 +159,10 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
if
(
text
.
isNullOrEmpty
())
{
if
(
text
.
isNullOrEmpty
())
{
return
return
}
}
val
wpControl
:
WPControl
=
(
binding
.
mDocView
.
iOffice
?.
control
?.
appControl
as
WPControl
)
val
wpControl
:
WPControl
?
=
(
binding
.
mDocView
.
iOffice
?.
control
?.
appControl
as
WPControl
?
)
val
flag
=
(
wpControl
.
find
as
WPFind
)
.
find
(
text
.
toString
())
val
flag
=
(
wpControl
?.
find
as
WPFind
?)
?
.
find
(
text
.
toString
())
haveSearchResult
=
flag
haveSearchResult
=
flag
?:
false
if
(
flag
)
{
if
(
flag
==
true
)
{
hideKeyboard
(
binding
.
editSearch
)
hideKeyboard
(
binding
.
editSearch
)
showBottomLayout
()
showBottomLayout
()
}
else
{
}
else
{
...
@@ -291,7 +290,7 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
...
@@ -291,7 +290,7 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
fileType
=
intent
?.
getIntExtra
(
Constant
.
INTENT_TYPE_KEY
,
-
1
)
?:
-
1
fileType
=
intent
?.
getIntExtra
(
Constant
.
INTENT_TYPE_KEY
,
-
1
)
?:
-
1
engine
=
intent
?.
getIntExtra
(
Constant
.
INTENT_ENGINE_KEY
,
DocEngine
.
INTERNAL
.
value
)
?:
DocEngine
.
INTERNAL
.
value
engine
=
intent
?.
getIntExtra
(
Constant
.
INTENT_ENGINE_KEY
,
DocEngine
.
INTERNAL
.
value
)
?:
DocEngine
.
INTERNAL
.
value
binding
.
mDocView
.
openDoc
(
this
,
pathOrUri
,
docSourceType
,
fileType
,
false
,
DocEngine
.
values
().
first
{
it
.
value
==
engine
}
)
binding
.
mDocView
.
openDoc
(
this
,
pathOrUri
,
docSourceType
,
fileType
,
false
)
LogEx
.
logDebug
(
TAG
,
"initData-docUrl = $pathOrUri"
)
LogEx
.
logDebug
(
TAG
,
"initData-docUrl = $pathOrUri"
)
LogEx
.
logDebug
(
TAG
,
"initData-docSourceType = $docSourceType"
)
LogEx
.
logDebug
(
TAG
,
"initData-docSourceType = $docSourceType"
)
LogEx
.
logDebug
(
TAG
,
"initData-fileType = $fileType"
)
LogEx
.
logDebug
(
TAG
,
"initData-fileType = $fileType"
)
...
@@ -317,4 +316,8 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
...
@@ -317,4 +316,8 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
}
}
}
}
override
fun
onDestroy
()
{
super
.
onDestroy
()
}
}
}
\ No newline at end of file
app/src/main/java/com/base/pdfviewerscannerwhite/ui/main/MainActivity.kt
View file @
2327df15
...
@@ -3,6 +3,7 @@ package com.base.pdfviewerscannerwhite.ui.main
...
@@ -3,6 +3,7 @@ package com.base.pdfviewerscannerwhite.ui.main
import
android.app.Activity
import
android.app.Activity
import
android.content.Intent
import
android.content.Intent
import
android.net.Uri
import
android.net.Uri
import
android.os.Bundle
import
android.view.View
import
android.view.View
import
androidx.activity.OnBackPressedCallback
import
androidx.activity.OnBackPressedCallback
import
androidx.fragment.app.Fragment
import
androidx.fragment.app.Fragment
...
@@ -23,10 +24,12 @@ import com.base.pdfviewerscannerwhite.ui.view.DialogView.showDeleteDialog
...
@@ -23,10 +24,12 @@ import com.base.pdfviewerscannerwhite.ui.view.DialogView.showDeleteDialog
import
com.base.pdfviewerscannerwhite.ui.view.DialogView.showStoragePermission
import
com.base.pdfviewerscannerwhite.ui.view.DialogView.showStoragePermission
import
com.base.pdfviewerscannerwhite.ui.view.PdfDialog.showPdfPwdDialog
import
com.base.pdfviewerscannerwhite.ui.view.PdfDialog.showPdfPwdDialog
import
com.base.pdfviewerscannerwhite.utils.IntentShareUtils.shareMutDocuments
import
com.base.pdfviewerscannerwhite.utils.IntentShareUtils.shareMutDocuments
import
com.base.pdfviewerscannerwhite.utils.LogEx
import
com.base.pdfviewerscannerwhite.utils.PermissionUtils.checkStorePermission
import
com.base.pdfviewerscannerwhite.utils.PermissionUtils.checkStorePermission
class
MainActivity
:
BaseActivity
<
ActivityMain2Binding
>(),
MainView
{
class
MainActivity
:
BaseActivity
<
ActivityMain2Binding
>(),
MainView
{
private
val
TAG
=
"MainActivity"
lateinit
var
mainPresenter
:
MainPresenter
lateinit
var
mainPresenter
:
MainPresenter
override
val
binding
:
ActivityMain2Binding
by
lazy
{
override
val
binding
:
ActivityMain2Binding
by
lazy
{
ActivityMain2Binding
.
inflate
(
layoutInflater
)
ActivityMain2Binding
.
inflate
(
layoutInflater
)
...
@@ -46,6 +49,7 @@ class MainActivity : BaseActivity<ActivityMain2Binding>(), MainView {
...
@@ -46,6 +49,7 @@ class MainActivity : BaseActivity<ActivityMain2Binding>(), MainView {
private
var
currentFragment
:
Fragment
=
documentFragment
private
var
currentFragment
:
Fragment
=
documentFragment
override
fun
initView
()
{
override
fun
initView
()
{
LogEx
.
logDebug
(
TAG
,
"initView"
)
mainPresenter
=
MainPresenter
(
this
,
this
,
lifecycleScope
)
mainPresenter
=
MainPresenter
(
this
,
this
,
lifecycleScope
)
}
}
...
@@ -61,6 +65,11 @@ class MainActivity : BaseActivity<ActivityMain2Binding>(), MainView {
...
@@ -61,6 +65,11 @@ class MainActivity : BaseActivity<ActivityMain2Binding>(), MainView {
}
}
}
}
override
fun
onSaveInstanceState
(
outState
:
Bundle
)
{
super
.
onSaveInstanceState
(
outState
)
LogEx
.
logDebug
(
TAG
,
"onSaveInstanceState"
)
}
var
isDocumentAdd
:
Boolean
=
false
var
isDocumentAdd
:
Boolean
=
false
var
isRecentAdd
:
Boolean
=
false
var
isRecentAdd
:
Boolean
=
false
var
isBookmarkAdd
:
Boolean
=
false
var
isBookmarkAdd
:
Boolean
=
false
...
@@ -92,6 +101,7 @@ class MainActivity : BaseActivity<ActivityMain2Binding>(), MainView {
...
@@ -92,6 +101,7 @@ class MainActivity : BaseActivity<ActivityMain2Binding>(), MainView {
changeTabSelect
(
it
)
changeTabSelect
(
it
)
supportFragmentManager
.
beginTransaction
().
apply
{
supportFragmentManager
.
beginTransaction
().
apply
{
if
(!
isDocumentAdd
)
{
if
(!
isDocumentAdd
)
{
add
(
R
.
id
.
fl_container
,
documentFragment
)
add
(
R
.
id
.
fl_container
,
documentFragment
)
}
}
...
...
library/src/main/java/com/cherry/lib/doc/DocViewerActivity.kt
View file @
2327df15
...
@@ -53,13 +53,10 @@ open class DocViewerActivity : AppCompatActivity() {
...
@@ -53,13 +53,10 @@ open class DocViewerActivity : AppCompatActivity() {
this
,
this
,
docUrl
,
docUrl
,
docSourceType
,
docSourceType
,
fileType
,
fileType
,
false
)
false
,
DocEngine
.
values
().
first
{
it
.
value
==
engine
})
Log
.
e
(
TAG
,
"initData-docUrl = $docUrl"
)
Log
.
e
(
TAG
,
"initData-docUrl = $docUrl"
)
Log
.
e
(
TAG
,
"initData-docSourceType = $docSourceType"
)
Log
.
e
(
TAG
,
"initData-docSourceType = $docSourceType"
)
Log
.
e
(
TAG
,
"initData-fileType = $fileType"
)
Log
.
e
(
TAG
,
"initData-fileType = $fileType"
)
Log
.
e
(
TAG
,
"initData-engine = $engine"
)
}
}
}
}
\ No newline at end of file
library/src/main/java/com/cherry/lib/doc/office/IOffice.java
View file @
2327df15
...
@@ -43,9 +43,7 @@ public abstract class IOffice implements IMainFrame {
...
@@ -43,9 +43,7 @@ public abstract class IOffice implements IMainFrame {
if
(
componentWidth
==
0
||
componentHeight
==
0
)
{
if
(
componentWidth
==
0
||
componentHeight
==
0
)
{
return
null
;
return
null
;
}
}
if
(
bitmap
==
null
if
(
bitmap
==
null
||
bitmap
.
getWidth
()
!=
componentWidth
||
bitmap
.
getHeight
()
!=
componentHeight
)
{
||
bitmap
.
getWidth
()
!=
componentWidth
||
bitmap
.
getHeight
()
!=
componentHeight
)
{
// custom picture size
// custom picture size
if
(
bitmap
!=
null
)
{
if
(
bitmap
!=
null
)
{
bitmap
.
recycle
();
bitmap
.
recycle
();
...
@@ -82,10 +80,13 @@ public abstract class IOffice implements IMainFrame {
...
@@ -82,10 +80,13 @@ public abstract class IOffice implements IMainFrame {
}
}
private
void
saveBitmapToFile
(
Bitmap
bitmap
)
{
private
void
saveBitmapToFile
(
Bitmap
bitmap
)
{
Log
.
e
(
TAG
,
"saveBitmapToFile1"
);
if
(
bitmap
==
null
)
{
if
(
bitmap
==
null
)
{
Log
.
e
(
TAG
,
"saveBitmapToFile2"
);
return
;
return
;
}
}
if
(
tempFilePath
==
null
)
{
if
(
tempFilePath
==
null
)
{
Log
.
e
(
TAG
,
"saveBitmapToFile3"
);
// 存在外部目录相册中会显示
// 存在外部目录相册中会显示
// String state = Environment.getExternalStorageState();
// String state = Environment.getExternalStorageState();
// if (Environment.MEDIA_MOUNTED.equals(state)) {
// if (Environment.MEDIA_MOUNTED.equals(state)) {
...
@@ -101,6 +102,7 @@ public abstract class IOffice implements IMainFrame {
...
@@ -101,6 +102,7 @@ public abstract class IOffice implements IMainFrame {
File
file
=
new
File
(
tempFilePath
+
File
.
separatorChar
+
"export_image.jpg"
);
File
file
=
new
File
(
tempFilePath
+
File
.
separatorChar
+
"export_image.jpg"
);
try
{
try
{
if
(
file
.
exists
())
{
if
(
file
.
exists
())
{
Log
.
e
(
TAG
,
"saveBitmapToFile4"
);
file
.
delete
();
file
.
delete
();
}
}
file
.
createNewFile
();
file
.
createNewFile
();
...
...
library/src/main/java/com/cherry/lib/doc/office/system/beans/pagelist/APageListView.java
View file @
2327df15
...
@@ -38,7 +38,6 @@ public class APageListView extends AdapterView<Adapter> {
...
@@ -38,7 +38,6 @@ public class APageListView extends AdapterView<Adapter> {
}
}
/**
/**
*
*
*/
*/
...
@@ -721,6 +720,7 @@ public class APageListView extends AdapterView<Adapter> {
...
@@ -721,6 +720,7 @@ public class APageListView extends AdapterView<Adapter> {
*
*
*/
*/
public
float
getZoom
()
{
public
float
getZoom
()
{
Log
.
e
(
"APageListView"
,
"getZoom"
);
return
zoom
;
return
zoom
;
}
}
...
@@ -728,6 +728,7 @@ public class APageListView extends AdapterView<Adapter> {
...
@@ -728,6 +728,7 @@ public class APageListView extends AdapterView<Adapter> {
*
*
*/
*/
public
float
getFitZoom
()
{
public
float
getFitZoom
()
{
Log
.
e
(
"APageListView"
,
"getFitZoom"
);
return
getFitZoom
(
0
);
return
getFitZoom
(
0
);
}
}
...
...
library/src/main/java/com/cherry/lib/doc/office/wp/control/PrintWord.java
View file @
2327df15
...
@@ -174,6 +174,7 @@ public class PrintWord extends FrameLayout implements IPageListViewListener {
...
@@ -174,6 +174,7 @@ public class PrintWord extends FrameLayout implements IPageListViewListener {
*
*
*/
*/
public
float
getZoom
()
{
public
float
getZoom
()
{
Log
.
e
(
"PrintWord"
,
"getZoom"
);
return
listView
.
getZoom
();
return
listView
.
getZoom
();
}
}
...
@@ -181,6 +182,7 @@ public class PrintWord extends FrameLayout implements IPageListViewListener {
...
@@ -181,6 +182,7 @@ public class PrintWord extends FrameLayout implements IPageListViewListener {
*
*
*/
*/
public
float
getFitZoom
()
{
public
float
getFitZoom
()
{
Log
.
e
(
"PrintWord"
,
"getFitZoom"
);
return
listView
.
getFitZoom
();
return
listView
.
getFitZoom
();
}
}
...
...
library/src/main/java/com/cherry/lib/doc/office/wp/control/WPControl.java
View file @
2327df15
/*
/*
* 文件名称: WPControl.java
* 文件名称: WPControl.java
*
*
* 编译器: android2.2
* 编译器: android2.2
* 时间: 下午1:57:55
* 时间: 下午1:57:55
*/
*/
...
@@ -32,6 +32,7 @@ import android.content.Intent;
...
@@ -32,6 +32,7 @@ import android.content.Intent;
import
android.graphics.Bitmap
;
import
android.graphics.Bitmap
;
import
android.net.Uri
;
import
android.net.Uri
;
import
android.text.ClipboardManager
;
import
android.text.ClipboardManager
;
import
android.util.Log
;
import
android.view.View
;
import
android.view.View
;
import
org.jetbrains.annotations.Nullable
;
import
org.jetbrains.annotations.Nullable
;
...
@@ -49,48 +50,43 @@ import org.jetbrains.annotations.Nullable;
...
@@ -49,48 +50,43 @@ import org.jetbrains.annotations.Nullable;
* <p>
* <p>
* 负责人: 梁金晶
* 负责人: 梁金晶
* <p>
* <p>
* 负责小组:
* 负责小组:
* <p>
* <p>
* <p>
* <p>
*/
*/
public
class
WPControl
extends
AbstractControl
public
class
WPControl
extends
AbstractControl
{
{
/**
/**
*
* @param doc
* @param doc
* @param filePath
* @param filePath
*/
*/
public
WPControl
(
IControl
mainControl
,
IDocument
doc
,
String
filePath
)
public
WPControl
(
IControl
mainControl
,
IDocument
doc
,
String
filePath
)
{
{
this
.
mainControl
=
mainControl
;
this
.
mainControl
=
mainControl
;
wpView
=
new
Word
(
mainControl
.
getMainFrame
().
getActivity
().
getApplicationContext
(),
doc
,
filePath
,
this
);
wpView
=
new
Word
(
mainControl
.
getMainFrame
().
getActivity
().
getApplicationContext
(),
doc
,
filePath
,
this
);
}
}
/**
/**
* 布局视图
* 布局视图
*
* @param x
* @param x
* @param y
* @param y
* @param w
* @param w
* @param h
* @param h
*/
*/
public
void
layoutView
(
int
x
,
int
y
,
int
w
,
int
h
)
public
void
layoutView
(
int
x
,
int
y
,
int
w
,
int
h
)
{
{
}
}
/**
/**
* action派发
* action派发
* @param actionID 动作ID
*
* @param obj 动作ID的Value
* @param actionID 动作ID
* @param obj 动作ID的Value
*/
*/
public
void
actionEvent
(
int
actionID
,
final
@Nullable
Object
obj
)
public
void
actionEvent
(
int
actionID
,
final
@Nullable
Object
obj
)
{
{
switch
(
actionID
)
{
switch
(
actionID
)
{
case
EventConstant
.
WP_SHOW_PAGE
:
case
EventConstant
.
WP_SHOW_PAGE
:
wpView
.
showPage
((
Integer
)
obj
,
EventConstant
.
WP_SHOW_PAGE
);
wpView
.
showPage
((
Integer
)
obj
,
EventConstant
.
WP_SHOW_PAGE
);
if
(
wpView
.
getCurrentRootType
()
==
WPViewConstant
.
PRINT_ROOT
)
if
(
wpView
.
getCurrentRootType
()
==
WPViewConstant
.
PRINT_ROOT
)
{
{
return
;
return
;
}
}
//
//
...
@@ -99,180 +95,147 @@ public class WPControl extends AbstractControl
...
@@ -99,180 +95,147 @@ public class WPControl extends AbstractControl
exportImage
();
exportImage
();
break
;
break
;
case
EventConstant
.
SYS_SET_PROGRESS_BAR_ID
:
case
EventConstant
.
SYS_SET_PROGRESS_BAR_ID
:
if
(
wpView
.
getParent
()
!=
null
)
if
(
wpView
.
getParent
()
!=
null
)
{
{
wpView
.
post
(
new
Runnable
()
{
wpView
.
post
(
new
Runnable
()
{
/**
/**
*
*
*/
*/
public
void
run
()
public
void
run
()
{
{
if
(!
isDispose
)
{
if
(!
isDispose
)
//getActivity().setProgressBarIndeterminateVisibility((Boolean)obj);
{
mainControl
.
getMainFrame
().
showProgressBar
((
Boolean
)
obj
);
//getActivity().setProgressBarIndeterminateVisibility((Boolean)obj);
mainControl
.
getMainFrame
().
showProgressBar
((
Boolean
)
obj
);
}
}
}
}
});
});
}
}
break
;
break
;
case
EventConstant
.
SYS_VECTORGRAPH_PROGRESS
:
case
EventConstant
.
SYS_VECTORGRAPH_PROGRESS
:
if
(
wpView
.
getParent
()
!=
null
)
if
(
wpView
.
getParent
()
!=
null
)
{
{
wpView
.
post
(
new
Runnable
()
{
wpView
.
post
(
new
Runnable
()
{
/**
/**
*
*
*/
*/
public
void
run
()
public
void
run
()
{
{
if
(!
isDispose
)
{
if
(!
isDispose
)
mainControl
.
getMainFrame
().
updateViewImages
((
List
<
Integer
>)
obj
);
{
mainControl
.
getMainFrame
().
updateViewImages
((
List
<
Integer
>)
obj
);
}
}
}
}
});
});
}
}
else
{
else
new
Thread
()
{
{
/**
new
Thread
()
*
{
*/
/**
public
void
run
()
{
*
if
(!
isDispose
)
{
*/
mainControl
.
getMainFrame
().
updateViewImages
((
List
<
Integer
>)
obj
);
public
void
run
()
}
{
}
if
(!
isDispose
)
}.
start
();
{
}
mainControl
.
getMainFrame
().
updateViewImages
((
List
<
Integer
>)
obj
);
break
;
}
}
}.
start
();
}
break
;
case
EventConstant
.
SYS_INIT_ID
:
case
EventConstant
.
SYS_INIT_ID
:
wpView
.
init
();
wpView
.
init
();
break
;
break
;
case
EventConstant
.
TEST_REPAINT_ID
:
case
EventConstant
.
TEST_REPAINT_ID
:
wpView
.
postInvalidate
();
wpView
.
postInvalidate
();
break
;
break
;
case
EventConstant
.
WP_PRINT_MODE
:
case
EventConstant
.
WP_PRINT_MODE
:
if
(
wpView
.
getCurrentRootType
()
==
WPViewConstant
.
PRINT_ROOT
)
if
(
wpView
.
getCurrentRootType
()
==
WPViewConstant
.
PRINT_ROOT
)
{
{
return
;
return
;
}
}
wpView
.
switchView
(
WPViewConstant
.
PRINT_ROOT
);
wpView
.
switchView
(
WPViewConstant
.
PRINT_ROOT
);
updateStatus
();
updateStatus
();
break
;
break
;
case
EventConstant
.
WP_SWITCH_VIEW
:
case
EventConstant
.
WP_SWITCH_VIEW
:
int
rootType
;
int
rootType
;
if
(
obj
!=
null
)
if
(
obj
!=
null
)
{
{
rootType
=
(
Integer
)
obj
;
rootType
=
(
Integer
)
obj
;
}
else
{
}
else
{
rootType
=
wpView
.
getCurrentRootType
();
rootType
=
wpView
.
getCurrentRootType
();
if
(
rootType
==
WPViewConstant
.
PAGE_ROOT
)
if
(
rootType
==
WPViewConstant
.
PAGE_ROOT
)
{
{
rootType
=
WPViewConstant
.
NORMAL_ROOT
;
rootType
=
WPViewConstant
.
NORMAL_ROOT
;
}
}
else
{
else
{
rootType
=
WPViewConstant
.
PAGE_ROOT
;
rootType
=
WPViewConstant
.
PAGE_ROOT
;
}
}
}
}
wpView
.
switchView
(
rootType
);
wpView
.
switchView
(
rootType
);
//
//
updateStatus
();
updateStatus
();
if
(
rootType
!=
WPViewConstant
.
PRINT_ROOT
)
if
(
rootType
!=
WPViewConstant
.
PRINT_ROOT
)
{
{
exportImage
();
exportImage
();
}
}
break
;
break
;
case
EventConstant
.
APP_ZOOM_ID
:
case
EventConstant
.
APP_ZOOM_ID
:
int
[]
params
=
(
int
[])
obj
;
int
[]
params
=
(
int
[])
obj
;
wpView
.
setZoom
(
params
[
0
]
/
(
float
)
MainConstant
.
STANDARD_RATE
,
params
[
1
],
params
[
2
]);
Log
.
e
(
"WPControl"
,
"actionEvent EventConstant.APP_ZOOM_ID"
);
wpView
.
setZoom
(
params
[
0
]
/
(
float
)
MainConstant
.
STANDARD_RATE
,
params
[
1
],
params
[
2
]);
wpView
.
post
(
new
Runnable
()
wpView
.
post
(
new
Runnable
()
{
{
@Override
@
Override
public
void
run
()
{
public
void
run
()
if
(!
isDispose
)
{
{
if
(!
isDispose
)
{
getMainFrame
().
changeZoom
();
getMainFrame
().
changeZoom
();
}
}
}
}
});
});
break
;
break
;
case
EventConstant
.
SYS_UPDATE_TOOLSBAR_BUTTON_STATUS
:
// 更新toolsbar button状态
case
EventConstant
.
SYS_UPDATE_TOOLSBAR_BUTTON_STATUS
:
// 更新toolsbar button状态
//
//
updateStatus
();
updateStatus
();
break
;
break
;
case
EventConstant
.
WP_SELECT_TEXT_ID
:
// 选择文本
case
EventConstant
.
WP_SELECT_TEXT_ID
:
// 选择文本
wpView
.
getStatus
().
setSelectTextStatus
(!
wpView
.
getStatus
().
isSelectTextStatus
());
wpView
.
getStatus
().
setSelectTextStatus
(!
wpView
.
getStatus
().
isSelectTextStatus
());
break
;
break
;
case
EventConstant
.
APP_INTERNET_SEARCH_ID
:
// 联网搜索
case
EventConstant
.
APP_INTERNET_SEARCH_ID
:
// 联网搜索
ControlKit
.
instance
().
internetSearch
(
wpView
);
ControlKit
.
instance
().
internetSearch
(
wpView
);
break
;
break
;
case
EventConstant
.
FILE_COPY_ID
:
//copy
case
EventConstant
.
FILE_COPY_ID
:
//copy
ClipboardManager
clip
=
(
ClipboardManager
)
getActivity
().
getSystemService
(
Context
.
CLIPBOARD_SERVICE
);
ClipboardManager
clip
=
(
ClipboardManager
)
getActivity
().
getSystemService
(
Context
.
CLIPBOARD_SERVICE
);
clip
.
setText
(
wpView
.
getHighlight
().
getSelectText
());
clip
.
setText
(
wpView
.
getHighlight
().
getSelectText
());
break
;
break
;
case
EventConstant
.
SYS_AUTO_TEST_FINISH_ID
:
// 布局完成
case
EventConstant
.
SYS_AUTO_TEST_FINISH_ID
:
// 布局完成
wpView
.
post
(
new
Runnable
()
wpView
.
post
(
new
Runnable
()
{
{
/**
/**
*
*
*/
*/
public
void
run
()
public
void
run
()
{
{
if
(!
isDispose
)
{
if
(!
isDispose
)
{
//getMainFrame().getActivity().setProgressBarIndeterminateVisibility(false);
//getMainFrame().getActivity().setProgressBarIndeterminateVisibility(false);
mainControl
.
getMainFrame
().
showProgressBar
(
false
);
mainControl
.
getMainFrame
().
showProgressBar
(
false
);
}
}
}
}
});
});
if
(
isAutoTest
())
if
(
isAutoTest
())
{
{
getMainFrame
().
getActivity
().
onBackPressed
();
getMainFrame
().
getActivity
().
onBackPressed
();
}
}
break
;
break
;
case
EventConstant
.
APP_GENERATED_PICTURE_ID
:
case
EventConstant
.
APP_GENERATED_PICTURE_ID
:
exportImage
();
exportImage
();
break
;
break
;
case
EventConstant
.
APP_PAGE_UP_ID
:
case
EventConstant
.
APP_PAGE_UP_ID
:
if
(
wpView
.
getCurrentRootType
()
==
WPViewConstant
.
NORMAL_ROOT
)
if
(
wpView
.
getCurrentRootType
()
==
WPViewConstant
.
NORMAL_ROOT
)
{
{
if
(
wpView
.
getEventManage
()
!=
null
)
{
if
(
wpView
.
getEventManage
()
!=
null
)
{
wpView
.
getEventManage
().
onScroll
(
null
,
null
,
0
,
-
wpView
.
getHeight
()
+
10
);
wpView
.
getEventManage
().
onScroll
(
null
,
null
,
0
,
-
wpView
.
getHeight
()
+
10
);
}
}
}
}
else
{
else
{
wpView
.
showPage
(
wpView
.
getCurrentPageNumber
()
-
2
,
EventConstant
.
APP_PAGE_UP_ID
);
wpView
.
showPage
(
wpView
.
getCurrentPageNumber
()
-
2
,
EventConstant
.
APP_PAGE_UP_ID
);
}
}
if
(
wpView
.
getCurrentRootType
()
==
WPViewConstant
.
PRINT_ROOT
)
if
(
wpView
.
getCurrentRootType
()
==
WPViewConstant
.
PRINT_ROOT
)
{
{
return
;
return
;
}
}
//
//
...
@@ -280,21 +243,16 @@ public class WPControl extends AbstractControl
...
@@ -280,21 +243,16 @@ public class WPControl extends AbstractControl
//
//
exportImage
();
exportImage
();
break
;
break
;
case
EventConstant
.
APP_PAGE_DOWN_ID
:
case
EventConstant
.
APP_PAGE_DOWN_ID
:
if
(
wpView
.
getCurrentRootType
()
==
WPViewConstant
.
NORMAL_ROOT
)
if
(
wpView
.
getCurrentRootType
()
==
WPViewConstant
.
NORMAL_ROOT
)
{
{
if
(
wpView
.
getEventManage
()
!=
null
)
{
if
(
wpView
.
getEventManage
()
!=
null
)
{
wpView
.
getEventManage
().
onScroll
(
null
,
null
,
0
,
wpView
.
getHeight
()
+
10
);
wpView
.
getEventManage
().
onScroll
(
null
,
null
,
0
,
wpView
.
getHeight
()
+
10
);
}
}
}
}
else
{
else
{
wpView
.
showPage
(
wpView
.
getCurrentPageNumber
(),
EventConstant
.
APP_PAGE_DOWN_ID
);
wpView
.
showPage
(
wpView
.
getCurrentPageNumber
(),
EventConstant
.
APP_PAGE_DOWN_ID
);
}
}
if
(
wpView
.
getCurrentRootType
()
==
WPViewConstant
.
PRINT_ROOT
)
if
(
wpView
.
getCurrentRootType
()
==
WPViewConstant
.
PRINT_ROOT
)
{
{
return
;
return
;
}
}
//
//
...
@@ -302,140 +260,120 @@ public class WPControl extends AbstractControl
...
@@ -302,140 +260,120 @@ public class WPControl extends AbstractControl
//
//
exportImage
();
exportImage
();
break
;
break
;
case
EventConstant
.
APP_HYPERLINK
:
//hyperlink
case
EventConstant
.
APP_HYPERLINK
:
//hyperlink
Hyperlink
link
=
((
Hyperlink
)
obj
);
Hyperlink
link
=
((
Hyperlink
)
obj
);
if
(
link
!=
null
)
if
(
link
!=
null
)
{
{
try
{
try
if
(
link
.
getLinkType
()
==
Hyperlink
.
LINK_BOOKMARK
)
{
{
if
(
link
.
getLinkType
()
==
Hyperlink
.
LINK_BOOKMARK
)
{
Bookmark
bm
=
getSysKit
().
getBookmarkManage
().
getBookmark
(
link
.
getAddress
());
Bookmark
bm
=
getSysKit
().
getBookmarkManage
().
getBookmark
(
link
.
getAddress
());
if
(
bm
!=
null
)
if
(
bm
!=
null
)
{
{
ControlKit
.
instance
().
gotoOffset
(
wpView
,
bm
.
getStart
());
ControlKit
.
instance
().
gotoOffset
(
wpView
,
bm
.
getStart
());
}
}
}
}
else
{
else
Intent
intent
=
new
Intent
(
Intent
.
ACTION_VIEW
,
Uri
.
parse
(
link
.
getAddress
()));
{
Intent
intent
=
new
Intent
(
Intent
.
ACTION_VIEW
,
Uri
.
parse
(
link
.
getAddress
()));
getMainFrame
().
getActivity
().
startActivity
(
intent
);
getMainFrame
().
getActivity
().
startActivity
(
intent
);
}
}
}
catch
(
Exception
e
)
{
}
}
catch
(
Exception
e
)
}
{
}
}
break
;
break
;
case
EventConstant
.
WP_LAYOUT_NORMAL_VIEW
:
case
EventConstant
.
WP_LAYOUT_NORMAL_VIEW
:
if
(
wpView
.
getCurrentRootType
()
==
WPViewConstant
.
NORMAL_ROOT
)
if
(
wpView
.
getCurrentRootType
()
==
WPViewConstant
.
NORMAL_ROOT
)
{
{
wpView
.
setExportImageAfterZoom
(
true
);
wpView
.
setExportImageAfterZoom
(
true
);
wpView
.
layoutNormal
();
wpView
.
layoutNormal
();
}
}
break
;
break
;
case
EventConstant
.
WP_LAYOUT_COMPLETED
:
case
EventConstant
.
WP_LAYOUT_COMPLETED
:
if
(
wpView
!=
null
)
if
(
wpView
!=
null
)
{
{
wpView
.
updateFieldText
();
wpView
.
updateFieldText
();
if
(
wpView
.
getParent
()
==
null
)
{
if
(
wpView
.
getParent
()
==
null
)
{
getMainFrame
().
completeLayout
();
getMainFrame
().
completeLayout
();
break
;
break
;
}
}
wpView
.
post
(
new
Runnable
()
wpView
.
post
(
new
Runnable
()
{
{
@Override
@
Override
public
void
run
()
{
public
void
run
()
{
getMainFrame
().
completeLayout
();
getMainFrame
().
completeLayout
();
}
}
});
});
}
}
break
;
break
;
case
EventConstant
.
APP_SET_FIT_SIZE_ID
:
case
EventConstant
.
APP_SET_FIT_SIZE_ID
:
wpView
.
setFitSize
((
Integer
)
obj
);
wpView
.
setFitSize
((
Integer
)
obj
);
break
;
break
;
case
EventConstant
.
APP_INIT_CALLOUTVIEW_ID
:
case
EventConstant
.
APP_INIT_CALLOUTVIEW_ID
:
wpView
.
getPrintWord
().
getListView
().
getCurrentPageView
().
initCalloutView
();
wpView
.
getPrintWord
().
getListView
().
getCurrentPageView
().
initCalloutView
();
break
;
break
;
default
:
default
:
break
;
break
;
}
}
}
}
/**
/**
* 得到action的状态
* 得到action的状态
*
*
* @return obj
* @return obj
*/
*/
public
@Nullable
Object
getActionValue
(
int
actionID
,
@Nullable
Object
obj
)
public
@Nullable
Object
getActionValue
(
int
actionID
,
@Nullable
Object
obj
)
{
{
switch
(
actionID
)
{
switch
(
actionID
)
{
case
EventConstant
.
APP_ZOOM_ID
:
case
EventConstant
.
APP_ZOOM_ID
:
return
wpView
.
getZoom
();
return
wpView
.
getZoom
();
case
EventConstant
.
WP_SELECT_TEXT_ID
:
case
EventConstant
.
WP_SELECT_TEXT_ID
:
return
((
Word
)
wpView
).
getStatus
().
isSelectTextStatus
();
return
((
Word
)
wpView
).
getStatus
().
isSelectTextStatus
();
case
EventConstant
.
APP_FIT_ZOOM_ID
:
case
EventConstant
.
APP_FIT_ZOOM_ID
:
return
wpView
.
getFitZoom
();
return
wpView
.
getFitZoom
();
case
EventConstant
.
APP_COUNT_PAGES_ID
:
case
EventConstant
.
APP_COUNT_PAGES_ID
:
return
wpView
.
getPageCount
();
return
wpView
.
getPageCount
();
case
EventConstant
.
APP_CURRENT_PAGE_NUMBER_ID
:
case
EventConstant
.
APP_CURRENT_PAGE_NUMBER_ID
:
return
wpView
.
getCurrentPageNumber
();
return
wpView
.
getCurrentPageNumber
();
case
EventConstant
.
WP_PAGE_TO_IMAGE
:
case
EventConstant
.
WP_PAGE_TO_IMAGE
:
return
wpView
.
pageToImage
((
Integer
)
obj
);
return
wpView
.
pageToImage
((
Integer
)
obj
);
case
EventConstant
.
APP_PAGEAREA_TO_IMAGE
:
case
EventConstant
.
APP_PAGEAREA_TO_IMAGE
:
if
(
obj
instanceof
int
[])
if
(
obj
instanceof
int
[])
{
{
int
[]
paraArr
=
(
int
[])
obj
;
int
[]
paraArr
=
(
int
[])
obj
;
if
(
paraArr
!=
null
&&
paraArr
.
length
==
7
)
{
if
(
paraArr
!=
null
&&
paraArr
.
length
==
7
)
{
return
wpView
.
pageAreaToImage
(
paraArr
[
0
],
paraArr
[
1
],
paraArr
[
2
],
paraArr
[
3
],
paraArr
[
4
],
paraArr
[
5
],
paraArr
[
6
]);
return
wpView
.
pageAreaToImage
(
paraArr
[
0
],
paraArr
[
1
],
paraArr
[
2
],
paraArr
[
3
],
paraArr
[
4
],
paraArr
[
5
],
paraArr
[
6
]);
}
}
}
}
break
;
break
;
case
EventConstant
.
APP_THUMBNAIL_ID
:
case
EventConstant
.
APP_THUMBNAIL_ID
:
if
(
obj
instanceof
Integer
)
if
(
obj
instanceof
Integer
)
{
{
return
wpView
.
getThumbnail
((
Integer
)
obj
/
(
float
)
MainConstant
.
STANDARD_RATE
);
return
wpView
.
getThumbnail
((
Integer
)
obj
/
(
float
)
MainConstant
.
STANDARD_RATE
);
}
}
break
;
break
;
case
EventConstant
.
WP_GET_PAGE_SIZE
:
case
EventConstant
.
WP_GET_PAGE_SIZE
:
return
wpView
.
getPageSize
((
Integer
)
obj
-
1
);
return
wpView
.
getPageSize
((
Integer
)
obj
-
1
);
case
EventConstant
.
WP_GET_VIEW_MODE
:
case
EventConstant
.
WP_GET_VIEW_MODE
:
return
wpView
.
getCurrentRootType
();
return
wpView
.
getCurrentRootType
();
case
EventConstant
.
APP_GET_FIT_SIZE_STATE_ID
:
case
EventConstant
.
APP_GET_FIT_SIZE_STATE_ID
:
if
(
wpView
!=
null
)
if
(
wpView
!=
null
)
{
{
return
wpView
.
getFitSizeState
();
return
wpView
.
getFitSizeState
();
}
}
break
;
break
;
case
EventConstant
.
APP_GET_SNAPSHOT_ID
:
case
EventConstant
.
APP_GET_SNAPSHOT_ID
:
if
(
wpView
!=
null
)
if
(
wpView
!=
null
)
{
{
return
wpView
.
getSnapshot
((
Bitmap
)
obj
);
return
wpView
.
getSnapshot
((
Bitmap
)
obj
);
}
}
break
;
break
;
default
:
default
:
break
;
break
;
}
}
...
@@ -443,66 +381,55 @@ public class WPControl extends AbstractControl
...
@@ -443,66 +381,55 @@ public class WPControl extends AbstractControl
}
}
/**
/**
*
*
*/
*/
private
void
exportImage
()
private
void
exportImage
()
{
{
wpView
.
post
(
new
Runnable
()
{
wpView
.
post
(
new
Runnable
()
@Override
{
public
void
run
()
{
@
Override
if
(!
isDispose
)
{
public
void
run
()
{
if
(!
isDispose
)
{
wpView
.
createPicture
();
wpView
.
createPicture
();
}
}
}
}
});
});
}
}
/**
/**
*
*
*/
*/
private
void
updateStatus
()
private
void
updateStatus
()
{
{
wpView
.
post
(
new
Runnable
()
{
wpView
.
post
(
new
Runnable
()
@Override
{
public
void
run
()
{
@
Override
if
(!
isDispose
)
{
public
void
run
()
{
if
(!
isDispose
)
{
getMainFrame
().
updateToolsbarStatus
();
getMainFrame
().
updateToolsbarStatus
();
}
}
}
}
});
});
}
}
/**
/**
* current view index
* current view index
*
* @return
* @return
*/
*/
public
int
getCurrentViewIndex
()
public
int
getCurrentViewIndex
()
{
{
return
wpView
.
getCurrentPageNumber
();
return
wpView
.
getCurrentPageNumber
();
}
}
/**
/**
*
*
*/
*/
public
View
getView
()
public
View
getView
()
{
{
return
wpView
;
return
wpView
;
}
}
/**
/**
*
*
*/
*/
public
Dialog
getDialog
(
Activity
activity
,
int
id
)
public
Dialog
getDialog
(
Activity
activity
,
int
id
)
{
{
switch
(
id
)
{
switch
(
id
)
{
case
DialogConstant
.
ENCODING_DIALOG_ID
:
// 文本文本编码格式对话框
case
DialogConstant
.
ENCODING_DIALOG_ID
:
// 文本文本编码格式对话框
Vector
<
Object
>
vector
=
new
Vector
<
Object
>();
Vector
<
Object
>
vector
=
new
Vector
<
Object
>();
vector
.
add
(
wpView
.
getFilePath
());
vector
.
add
(
wpView
.
getFilePath
());
...
@@ -514,88 +441,76 @@ public class WPControl extends AbstractControl
...
@@ -514,88 +441,76 @@ public class WPControl extends AbstractControl
}
}
return
null
;
return
null
;
}
}
/**
/**
*
*
*/
*/
public
IMainFrame
getMainFrame
()
public
IMainFrame
getMainFrame
()
{
{
return
mainControl
.
getMainFrame
();
return
mainControl
.
getMainFrame
();
}
}
/**
/**
*
*
*/
*/
public
Activity
getActivity
()
public
Activity
getActivity
()
{
{
return
getMainFrame
().
getActivity
();
return
getMainFrame
().
getActivity
();
}
}
/**
/**
*
*
*/
*/
public
IFind
getFind
()
public
IFind
getFind
()
{
{
return
wpView
.
getFind
();
return
wpView
.
getFind
();
}
}
/**
/**
*
*
*/
*/
public
boolean
isAutoTest
()
public
boolean
isAutoTest
()
{
{
return
mainControl
.
isAutoTest
();
return
mainControl
.
isAutoTest
();
}
}
/**
/**
*
*
*
*/
*/
public
IOfficeToPicture
getOfficeToPicture
()
public
IOfficeToPicture
getOfficeToPicture
()
{
{
return
mainControl
.
getOfficeToPicture
();
return
mainControl
.
getOfficeToPicture
();
}
}
/**
/**
*
*
*/
*/
public
ICustomDialog
getCustomDialog
()
public
ICustomDialog
getCustomDialog
()
{
{
return
mainControl
.
getCustomDialog
();
return
mainControl
.
getCustomDialog
();
}
}
/**
/**
*
*
*
*/
*/
public
int
getApplicationType
()
public
int
getApplicationType
()
{
{
return
MainConstant
.
APPLICATION_TYPE_WP
;
return
MainConstant
.
APPLICATION_TYPE_WP
;
}
}
/**
/**
*
*
*/
*/
public
SysKit
getSysKit
()
public
SysKit
getSysKit
()
{
{
return
mainControl
.
getSysKit
();
return
mainControl
.
getSysKit
();
}
}
/**
/**
*
*
*
*/
*/
public
void
dispose
()
public
void
dispose
()
{
{
isDispose
=
true
;
isDispose
=
true
;
wpView
.
dispose
();
wpView
.
dispose
();
wpView
=
null
;
wpView
=
null
;
mainControl
=
null
;
mainControl
=
null
;
}
}
private
boolean
isDispose
;
private
boolean
isDispose
;
//
//
private
IControl
mainControl
;
private
IControl
mainControl
;
//
//
public
Word
wpView
;
public
Word
wpView
;
}
}
library/src/main/java/com/cherry/lib/doc/office/wp/control/Word.java
View file @
2327df15
...
@@ -40,6 +40,7 @@ import com.cherry.lib.doc.office.system.IControl;
...
@@ -40,6 +40,7 @@ import com.cherry.lib.doc.office.system.IControl;
import
com.cherry.lib.doc.office.system.IDialogAction
;
import
com.cherry.lib.doc.office.system.IDialogAction
;
import
com.cherry.lib.doc.office.system.SysKit
;
import
com.cherry.lib.doc.office.system.SysKit
;
import
com.cherry.lib.doc.office.system.beans.pagelist.APageListView
;
import
com.cherry.lib.doc.office.system.beans.pagelist.APageListView
;
import
com.cherry.lib.doc.office.thirdpart.emf.io.Tag
;
import
com.cherry.lib.doc.office.wp.view.LayoutKit
;
import
com.cherry.lib.doc.office.wp.view.LayoutKit
;
import
com.cherry.lib.doc.office.wp.view.NormalRoot
;
import
com.cherry.lib.doc.office.wp.view.NormalRoot
;
import
com.cherry.lib.doc.office.wp.view.PageRoot
;
import
com.cherry.lib.doc.office.wp.view.PageRoot
;
...
@@ -112,6 +113,7 @@ public class Word extends LinearLayout implements IWord {
...
@@ -112,6 +113,7 @@ public class Word extends LinearLayout implements IWord {
if
(
normalRoot
!=
null
)
{
if
(
normalRoot
!=
null
)
{
normalRoot
.
doLayout
(
0
,
0
,
mWidth
,
mHeight
,
Integer
.
MAX_VALUE
,
0
);
normalRoot
.
doLayout
(
0
,
0
,
mWidth
,
mHeight
,
Integer
.
MAX_VALUE
,
0
);
}
else
{
}
else
{
Log
.
e
(
"Word"
,
"init"
);
pageRoot
.
doLayout
(
0
,
0
,
mWidth
,
mHeight
,
Integer
.
MAX_VALUE
,
0
);
pageRoot
.
doLayout
(
0
,
0
,
mWidth
,
mHeight
,
Integer
.
MAX_VALUE
,
0
);
}
}
initFinish
=
true
;
initFinish
=
true
;
...
@@ -140,6 +142,7 @@ public class Word extends LinearLayout implements IWord {
...
@@ -140,6 +142,7 @@ public class Word extends LinearLayout implements IWord {
}
}
try
{
try
{
if
(
getCurrentRootType
()
==
WPViewConstant
.
PAGE_ROOT
)
{
if
(
getCurrentRootType
()
==
WPViewConstant
.
PAGE_ROOT
)
{
Log
.
e
(
"Wod"
,
"onDraw zoom="
+
zoom
);
pageRoot
.
draw
(
canvas
,
0
,
0
,
zoom
);
pageRoot
.
draw
(
canvas
,
0
,
0
,
zoom
);
drawPageNubmer
(
canvas
,
zoom
);
drawPageNubmer
(
canvas
,
zoom
);
}
else
if
(
getCurrentRootType
()
==
WPViewConstant
.
NORMAL_ROOT
)
{
}
else
if
(
getCurrentRootType
()
==
WPViewConstant
.
NORMAL_ROOT
)
{
...
@@ -172,7 +175,9 @@ public class Word extends LinearLayout implements IWord {
...
@@ -172,7 +175,9 @@ public class Word extends LinearLayout implements IWord {
*
*
*/
*/
private
void
toPicture
(
IOfficeToPicture
otp
)
{
private
void
toPicture
(
IOfficeToPicture
otp
)
{
Log
.
e
(
"Word"
,
"toPicture1"
);
if
(
getCurrentRootType
()
==
WPViewConstant
.
PRINT_ROOT
)
{
if
(
getCurrentRootType
()
==
WPViewConstant
.
PRINT_ROOT
)
{
Log
.
e
(
"Word"
,
"toPicture2"
);
WPPageListItem
item
=
(
WPPageListItem
)
printWord
.
getListView
().
getCurrentPageView
();
WPPageListItem
item
=
(
WPPageListItem
)
printWord
.
getListView
().
getCurrentPageView
();
item
.
addRepaintImageView
(
null
);
item
.
addRepaintImageView
(
null
);
return
;
return
;
...
@@ -181,12 +186,15 @@ public class Word extends LinearLayout implements IWord {
...
@@ -181,12 +186,15 @@ public class Word extends LinearLayout implements IWord {
PictureKit
.
instance
().
setDrawPictrue
(
true
);
PictureKit
.
instance
().
setDrawPictrue
(
true
);
Bitmap
bitmap
=
otp
.
getBitmap
(
getWidth
(),
getHeight
());
Bitmap
bitmap
=
otp
.
getBitmap
(
getWidth
(),
getHeight
());
if
(
bitmap
==
null
)
{
if
(
bitmap
==
null
)
{
Log
.
e
(
"Word"
,
"toPicture3"
);
return
;
return
;
}
}
float
paintZoom
=
getZoom
();
float
paintZoom
=
getZoom
();
Log
.
e
(
"Word"
,
"paintZoom="
+
paintZoom
);
float
tX
=
-
getScrollX
();
float
tX
=
-
getScrollX
();
float
tY
=
-
getScrollY
();
float
tY
=
-
getScrollY
();
if
(
bitmap
.
getWidth
()
!=
getWidth
()
||
bitmap
.
getHeight
()
!=
getHeight
())
{
if
(
bitmap
.
getWidth
()
!=
getWidth
()
||
bitmap
.
getHeight
()
!=
getHeight
())
{
Log
.
e
(
"Word"
,
"toPicture4"
);
float
newZoom
=
Math
.
min
((
float
)
bitmap
.
getWidth
()
/
getWidth
(),
float
newZoom
=
Math
.
min
((
float
)
bitmap
.
getWidth
()
/
getWidth
(),
(
float
)
bitmap
.
getHeight
()
/
getHeight
())
(
float
)
bitmap
.
getHeight
()
/
getHeight
())
*
getZoom
();
*
getZoom
();
...
@@ -275,7 +283,7 @@ public class Word extends LinearLayout implements IWord {
...
@@ -275,7 +283,7 @@ public class Word extends LinearLayout implements IWord {
return
;
return
;
}
}
eventManage
.
stopFling
();
eventManage
.
stopFling
();
LayoutKit
.
instance
().
layoutAllPage
(
pageRoot
,
zoom
);
LayoutKit
.
instance
().
layoutAllPage
(
pageRoot
,
zoom
,
1
);
if
(
currentRootType
==
WPViewConstant
.
PAGE_ROOT
)
{
if
(
currentRootType
==
WPViewConstant
.
PAGE_ROOT
)
{
Rectangle
r
=
getVisibleRect
();
Rectangle
r
=
getVisibleRect
();
int
sX
=
r
.
x
;
int
sX
=
r
.
x
;
...
@@ -374,9 +382,10 @@ public class Word extends LinearLayout implements IWord {
...
@@ -374,9 +382,10 @@ public class Word extends LinearLayout implements IWord {
}
else
if
(
getCurrentRootType
()
==
WPViewConstant
.
PAGE_ROOT
)
{
}
else
if
(
getCurrentRootType
()
==
WPViewConstant
.
PAGE_ROOT
)
{
if
(
pageRoot
==
null
)
{
if
(
pageRoot
==
null
)
{
pageRoot
=
new
PageRoot
(
this
);
pageRoot
=
new
PageRoot
(
this
);
Log
.
e
(
"Word"
,
"switchView1"
);
pageRoot
.
doLayout
(
0
,
0
,
mWidth
,
mHeight
,
Integer
.
MAX_VALUE
,
0
);
pageRoot
.
doLayout
(
0
,
0
,
mWidth
,
mHeight
,
Integer
.
MAX_VALUE
,
0
);
}
else
{
}
else
{
LayoutKit
.
instance
().
layoutAllPage
(
pageRoot
,
zoom
);
LayoutKit
.
instance
().
layoutAllPage
(
pageRoot
,
zoom
,
2
);
}
}
setOnTouchListener
(
eventManage
);
setOnTouchListener
(
eventManage
);
if
(
printWord
!=
null
)
{
if
(
printWord
!=
null
)
{
...
@@ -385,6 +394,7 @@ public class Word extends LinearLayout implements IWord {
...
@@ -385,6 +394,7 @@ public class Word extends LinearLayout implements IWord {
}
else
if
(
getCurrentRootType
()
==
WPViewConstant
.
PRINT_ROOT
)
{
}
else
if
(
getCurrentRootType
()
==
WPViewConstant
.
PRINT_ROOT
)
{
if
(
pageRoot
==
null
)
{
if
(
pageRoot
==
null
)
{
pageRoot
=
new
PageRoot
(
this
);
pageRoot
=
new
PageRoot
(
this
);
Log
.
e
(
"Word"
,
"switchView2"
);
pageRoot
.
doLayout
(
0
,
0
,
mWidth
,
mHeight
,
Integer
.
MAX_VALUE
,
0
);
pageRoot
.
doLayout
(
0
,
0
,
mWidth
,
mHeight
,
Integer
.
MAX_VALUE
,
0
);
}
}
if
(
printWord
==
null
)
{
if
(
printWord
==
null
)
{
...
@@ -438,11 +448,13 @@ public class Word extends LinearLayout implements IWord {
...
@@ -438,11 +448,13 @@ public class Word extends LinearLayout implements IWord {
* @param zoom The zoom to set.
* @param zoom The zoom to set.
*/
*/
public
void
setZoom
(
float
zoom
,
int
pointX
,
int
pointY
)
{
public
void
setZoom
(
float
zoom
,
int
pointX
,
int
pointY
)
{
Log
.
e
(
"Word"
,
"setZoom "
+
"zoom="
+
zoom
+
" pointX="
+
pointX
+
" pointY="
+
pointY
);
float
oldZoom
=
1.0f
;
float
oldZoom
=
1.0f
;
if
(
currentRootType
==
WPViewConstant
.
PAGE_ROOT
)
{
if
(
currentRootType
==
WPViewConstant
.
PAGE_ROOT
)
{
oldZoom
=
this
.
zoom
;
oldZoom
=
this
.
zoom
;
this
.
zoom
=
zoom
;
this
.
zoom
=
zoom
;
LayoutKit
.
instance
().
layoutAllPage
(
pageRoot
,
zoom
);
Log
.
e
(
"Word"
,
"setZoom zoom="
+
this
.
zoom
);
LayoutKit
.
instance
().
layoutAllPage
(
pageRoot
,
zoom
,
3
);
}
else
if
(
currentRootType
==
WPViewConstant
.
PRINT_ROOT
)
{
}
else
if
(
currentRootType
==
WPViewConstant
.
PRINT_ROOT
)
{
printWord
.
setZoom
(
zoom
,
pointX
,
pointY
);
printWord
.
setZoom
(
zoom
,
pointX
,
pointY
);
return
;
return
;
...
@@ -889,9 +901,11 @@ public class Word extends LinearLayout implements IWord {
...
@@ -889,9 +901,11 @@ public class Word extends LinearLayout implements IWord {
* @return Returns the zoom.
* @return Returns the zoom.
*/
*/
public
float
getZoom
()
{
public
float
getZoom
()
{
Log
.
e
(
"Word"
,
"getZoom currentRootType="
+
currentRootType
);
if
(
currentRootType
==
WPViewConstant
.
NORMAL_ROOT
)
{
if
(
currentRootType
==
WPViewConstant
.
NORMAL_ROOT
)
{
return
normalZoom
;
return
normalZoom
;
}
else
if
(
currentRootType
==
WPViewConstant
.
PAGE_ROOT
)
{
}
else
if
(
currentRootType
==
WPViewConstant
.
PAGE_ROOT
)
{
Log
.
e
(
"Word"
,
"getZoom zoom="
+
zoom
);
return
zoom
;
return
zoom
;
}
else
if
(
currentRootType
==
WPViewConstant
.
PRINT_ROOT
)
{
}
else
if
(
currentRootType
==
WPViewConstant
.
PRINT_ROOT
)
{
if
(
printWord
!=
null
)
{
if
(
printWord
!=
null
)
{
...
...
library/src/main/java/com/cherry/lib/doc/office/wp/view/LayoutKit.java
View file @
2327df15
...
@@ -64,12 +64,18 @@ public class LayoutKit {
...
@@ -64,12 +64,18 @@ public class LayoutKit {
* @param root
* @param root
* @param zoom
* @param zoom
*/
*/
public
void
layoutAllPage
(
PageRoot
root
,
float
zoom
)
{
public
void
layoutAllPage
(
PageRoot
root
,
float
zoom
,
int
where
)
{
Log
.
e
(
"LayoutKit"
,
"layoutAllPage zoom="
+
zoom
+
" where="
+
where
);
if
(
root
==
null
||
root
.
getChildView
()
==
null
)
{
if
(
root
==
null
||
root
.
getChildView
()
==
null
)
{
Log
.
e
(
"LayoutKit"
,
"中断1"
);
return
;
return
;
}
}
Word
word
=
(
Word
)
root
.
getContainer
();
Word
word
=
(
Word
)
root
.
getContainer
();
if
(
word
.
getContext
()
!=
null
&&
(
screenWidthPixels
==
0
||
screenHeightPixels
==
0
))
{
// if (word.getContext() != null && (screenWidthPixels == 0 || screenHeightPixels == 0)) {
if
(
screenWidthPixels
==
0
)
{
}
if
(
word
.
getContext
()
!=
null
)
{
// 获取资源对象
// 获取资源对象
Resources
resources
=
word
.
getContext
().
getResources
();
Resources
resources
=
word
.
getContext
().
getResources
();
boolean
isLandscape
=
resources
.
getConfiguration
().
orientation
==
Configuration
.
ORIENTATION_LANDSCAPE
;
boolean
isLandscape
=
resources
.
getConfiguration
().
orientation
==
Configuration
.
ORIENTATION_LANDSCAPE
;
...
@@ -89,14 +95,17 @@ public class LayoutKit {
...
@@ -89,14 +95,17 @@ public class LayoutKit {
IView
pv
=
root
.
getChildView
();
IView
pv
=
root
.
getChildView
();
int
pvWidth
=
pv
.
getWidth
();
int
pvWidth
=
pv
.
getWidth
();
float
scale
=
1
;
float
scale
=
1
;
Log
.
e
(
TAG
,
"layoutAllPage screenWidthPixels="
+
screenWidthPixels
+
" pvWidth"
+
pvWidth
);
if
(
screenWidthPixels
!=
0
&&
pvWidth
!=
0
)
{
if
(
screenWidthPixels
!=
0
&&
pvWidth
!=
0
)
{
scale
=
screenWidthPixels
*
1
f
/
pvWidth
;
scale
=
screenWidthPixels
*
1
f
/
pvWidth
;
if
(
zoom
==
1
f
)
{
if
(
zoom
==
1
f
)
{
Log
.
e
(
TAG
,
"layoutAllPage scale="
+
scale
);
word
.
setZoom
(
scale
,
0
,
0
);
word
.
setZoom
(
scale
,
0
,
0
);
}
}
}
}
Log
.
d
(
TAG
,
"layoutAllPage screenWidthPixels = "
+
screenWidthPixels
+
"; isLandscape "
+
isLandscape
+
", pvWidth = "
+
pvWidth
+
"; scale = "
+
scale
);
Log
.
d
(
TAG
,
"layoutAllPage screenWidthPixels = "
+
screenWidthPixels
+
"; isLandscape "
+
isLandscape
+
", pvWidth = "
+
pvWidth
+
"; scale = "
+
scale
);
}
}
Log
.
e
(
"LayoutKit"
,
"中断2"
);
int
dx
=
WPViewConstant
.
PAGE_SPACE
;
int
dx
=
WPViewConstant
.
PAGE_SPACE
;
int
dy
=
WPViewConstant
.
PAGE_SPACE
;
int
dy
=
WPViewConstant
.
PAGE_SPACE
;
IView
pv
=
root
.
getChildView
();
IView
pv
=
root
.
getChildView
();
...
...
library/src/main/java/com/cherry/lib/doc/office/wp/view/PageRoot.java
View file @
2327df15
/*
/*
* 文件名称: PageRoot.java
* 文件名称: PageRoot.java
*
*
* 编译器: android2.2
* 编译器: android2.2
* 时间: 下午9:21:56
* 时间: 下午9:21:56
*/
*/
...
@@ -24,6 +24,7 @@ import com.cherry.lib.doc.office.system.IControl;
...
@@ -24,6 +24,7 @@ import com.cherry.lib.doc.office.system.IControl;
import
com.cherry.lib.doc.office.wp.control.Word
;
import
com.cherry.lib.doc.office.wp.control.Word
;
import
android.graphics.Canvas
;
import
android.graphics.Canvas
;
import
android.util.Log
;
/**
/**
* 页面视图根视图
* 页面视图根视图
...
@@ -37,93 +38,85 @@ import android.graphics.Canvas;
...
@@ -37,93 +38,85 @@ import android.graphics.Canvas;
* <p>
* <p>
* 负责人: ljj8494
* 负责人: ljj8494
* <p>
* <p>
* 负责小组:
* 负责小组:
* <p>
* <p>
* <p>
* <p>
*/
*/
public
class
PageRoot
extends
AbstractView
implements
IRoot
public
class
PageRoot
extends
AbstractView
implements
IRoot
{
{
public
PageRoot
(
Word
word
)
{
public
PageRoot
(
Word
word
)
{
this
.
word
=
word
;
this
.
word
=
word
;
layoutThread
=
new
LayoutThread
(
this
);
layoutThread
=
new
LayoutThread
(
this
);
wpLayouter
=
new
WPLayouter
(
this
);
wpLayouter
=
new
WPLayouter
(
this
);
viewContainer
=
new
ViewContainer
();
viewContainer
=
new
ViewContainer
();
pages
=
new
ArrayList
<
PageView
>();
pages
=
new
ArrayList
<
PageView
>();
canBackLayout
=
true
;
canBackLayout
=
true
;
}
}
/**
/**
*
*
*/
*/
public
short
getType
()
public
short
getType
()
{
{
return
WPViewConstant
.
PAGE_ROOT
;
return
WPViewConstant
.
PAGE_ROOT
;
}
}
/**
/**
* 视图布局
* 视图布局
*
* @param x
* @param x
* @param y
* @param y
* @param w
* @param w
* @param h
* @param h
* @param maxEnd
* @param maxEnd
* @param flag 布局标记,传递一些布尔值,位操作
* @param flag
布局标记,传递一些布尔值,位操作
*/
*/
public
int
doLayout
(
int
x
,
int
y
,
int
w
,
int
h
,
int
maxEnd
,
int
flag
)
public
int
doLayout
(
int
x
,
int
y
,
int
w
,
int
h
,
int
maxEnd
,
int
flag
)
{
{
Log
.
e
(
"PageRoot"
,
"doLayout1"
);
try
try
{
{
IDocument
doc
=
getDocument
();
IDocument
doc
=
getDocument
();
setParaCount
(
doc
.
getParaCount
(
WPModelConstant
.
MAIN
));
setParaCount
(
doc
.
getParaCount
(
WPModelConstant
.
MAIN
));
wpLayouter
.
doLayout
();
wpLayouter
.
doLayout
();
if
(!
wpLayouter
.
isLayoutFinish
()
&&
!
word
.
getControl
().
getMainFrame
().
isThumbnail
())
if
(!
wpLayouter
.
isLayoutFinish
()
&&
!
word
.
getControl
().
getMainFrame
().
isThumbnail
())
{
{
layoutThread
.
start
();
layoutThread
.
start
();
word
.
getControl
().
actionEvent
(
EventConstant
.
SYS_SET_PROGRESS_BAR_ID
,
true
);
word
.
getControl
().
actionEvent
(
EventConstant
.
SYS_SET_PROGRESS_BAR_ID
,
true
);
//word.getControl().getMainFrame().getActivity().setProgressBarIndeterminateVisibility(true);
//word.getControl().getMainFrame().getActivity().setProgressBarIndeterminateVisibility(true);
}
}
// auto test code
// auto test code
else
else
{
{
word
.
getControl
().
actionEvent
(
EventConstant
.
WP_LAYOUT_COMPLETED
,
true
);
word
.
getControl
().
actionEvent
(
EventConstant
.
WP_LAYOUT_COMPLETED
,
true
);
word
.
getControl
().
actionEvent
(
EventConstant
.
SYS_AUTO_TEST_FINISH_ID
,
true
);
word
.
getControl
().
actionEvent
(
EventConstant
.
SYS_AUTO_TEST_FINISH_ID
,
true
);
}
}
}
}
catch
(
Exception
e
)
{
catch
(
Exception
e
)
{
word
.
getControl
().
getSysKit
().
getErrorKit
().
writerLog
(
e
);
word
.
getControl
().
getSysKit
().
getErrorKit
().
writerLog
(
e
);
Log
.
e
(
"PageRoot"
,
"doLayout2"
);
}
}
return
WPViewConstant
.
BREAK_NO
;
return
WPViewConstant
.
BREAK_NO
;
}
}
/**
/**
*
* @param canvas
* @param canvas
* @param zoom
* @param zoom
*/
*/
public
synchronized
void
draw
(
Canvas
canvas
,
int
originX
,
int
originY
,
float
zoom
)
public
synchronized
void
draw
(
Canvas
canvas
,
int
originX
,
int
originY
,
float
zoom
)
{
{
super
.
draw
(
canvas
,
originX
,
originY
,
zoom
);
super
.
draw
(
canvas
,
originX
,
originY
,
zoom
);
}
}
/**
/**
* model到视图
* model到视图
*
* @param offset 指定的offset
* @param offset 指定的offset
* @param isBack 是否向后取,是为在视图上,上一行的结束位置与下一行开始位置相同
* @param isBack 是否向后取,是为在视图上,上一行的结束位置与下一行开始位置相同
*/
*/
public
Rectangle
modelToView
(
long
offset
,
Rectangle
rect
,
boolean
isBack
)
public
Rectangle
modelToView
(
long
offset
,
Rectangle
rect
,
boolean
isBack
)
{
{
//IView view = getView(offset, WPViewConstant.PAGE_VIEW, isBack);
//IView view = getView(offset, WPViewConstant.PAGE_VIEW, isBack);
IView
view
=
viewContainer
.
getParagraph
(
offset
,
isBack
);
IView
view
=
viewContainer
.
getParagraph
(
offset
,
isBack
);
if
(
view
!=
null
)
if
(
view
!=
null
)
{
{
view
.
modelToView
(
offset
,
rect
,
isBack
);
view
.
modelToView
(
offset
,
rect
,
isBack
);
IView
p
=
view
.
getParentView
();
IView
p
=
view
.
getParentView
();
while
(
p
!=
null
&&
p
.
getType
()
!=
WPViewConstant
.
PAGE_ROOT
)
while
(
p
!=
null
&&
p
.
getType
()
!=
WPViewConstant
.
PAGE_ROOT
)
{
{
/*if (p.getType() == WPViewConstant.TABLE_CELL_VIEW)
/*if (p.getType() == WPViewConstant.TABLE_CELL_VIEW)
{
{
rect.x += p.getX() + p.getLeftIndent();
rect.x += p.getX() + p.getLeftIndent();
...
@@ -140,88 +133,76 @@ public class PageRoot extends AbstractView implements IRoot
...
@@ -140,88 +133,76 @@ public class PageRoot extends AbstractView implements IRoot
rect
.
x
+=
getX
();
rect
.
x
+=
getX
();
rect
.
y
+=
getY
();
rect
.
y
+=
getY
();
return
rect
;
return
rect
;
}
}
/**
/**
* @param x
* @param x
* @param y
* @param y
* @param isBack 是否向后取,是为在视图上,上一行的结束位置与下一行开始位置相同
* @param isBack 是否向后取,是为在视图上,上一行的结束位置与下一行开始位置相同
*/
*/
public
long
viewToModel
(
int
x
,
int
y
,
boolean
isBack
)
public
long
viewToModel
(
int
x
,
int
y
,
boolean
isBack
)
{
{
x
-=
getX
();
x
-=
getX
();
y
-=
getY
();
y
-=
getY
();
IView
view
=
getChildView
();
IView
view
=
getChildView
();
if
(
view
!=
null
&&
y
>
view
.
getY
())
if
(
view
!=
null
&&
y
>
view
.
getY
())
{
{
while
(
view
!=
null
)
{
while
(
view
!=
null
)
if
(
y
>=
view
.
getY
()
&&
y
<=
view
.
getY
()
+
view
.
getHeight
()
+
MainConstant
.
GAP
/
2
)
{
{
if
(
y
>=
view
.
getY
()
&&
y
<=
view
.
getY
()
+
view
.
getHeight
()
+
MainConstant
.
GAP
/
2
)
{
break
;
break
;
}
}
view
=
view
.
getNextView
();
view
=
view
.
getNextView
();
}
}
}
}
view
=
view
==
null
?
getChildView
()
:
view
;
view
=
view
==
null
?
getChildView
()
:
view
;
if
(
view
!=
null
)
if
(
view
!=
null
)
{
{
return
view
.
viewToModel
(
x
,
y
,
isBack
);
return
view
.
viewToModel
(
x
,
y
,
isBack
);
}
}
return
-
1
;
return
-
1
;
}
}
/**
/**
* 得到model
* 得到model
*/
*/
public
IDocument
getDocument
()
public
IDocument
getDocument
()
{
{
return
word
.
getDocument
();
return
word
.
getDocument
();
}
}
/**
/**
*
*
*/
*/
public
IWord
getContainer
()
public
IWord
getContainer
()
{
{
return
word
;
return
word
;
}
}
/**
/**
*
*
*/
*/
public
IControl
getControl
()
public
IControl
getControl
()
{
{
return
word
.
getControl
();
return
word
.
getControl
();
}
}
/**
/**
*
*
*
*/
*/
public
boolean
canBackLayout
()
public
boolean
canBackLayout
()
{
{
return
canBackLayout
&&
!
wpLayouter
.
isLayoutFinish
();
return
canBackLayout
&&
!
wpLayouter
.
isLayoutFinish
();
}
}
/**
/**
*
*
*/
*/
public
synchronized
void
backLayout
()
public
synchronized
void
backLayout
()
{
{
wpLayouter
.
backLayout
();
wpLayouter
.
backLayout
();
word
.
postInvalidate
();
word
.
postInvalidate
();
// auto test code
// auto test code
if
(
wpLayouter
.
isLayoutFinish
())
if
(
wpLayouter
.
isLayoutFinish
())
{
{
word
.
getControl
().
actionEvent
(
EventConstant
.
SYS_AUTO_TEST_FINISH_ID
,
true
);
word
.
getControl
().
actionEvent
(
EventConstant
.
SYS_AUTO_TEST_FINISH_ID
,
true
);
word
.
getControl
().
actionEvent
(
EventConstant
.
WP_LAYOUT_COMPLETED
,
true
);
word
.
getControl
().
actionEvent
(
EventConstant
.
WP_LAYOUT_COMPLETED
,
true
);
}
}
word
.
getControl
().
actionEvent
(
EventConstant
.
SYS_UPDATE_TOOLSBAR_BUTTON_STATUS
,
null
);
word
.
getControl
().
actionEvent
(
EventConstant
.
SYS_UPDATE_TOOLSBAR_BUTTON_STATUS
,
null
);
//
//
LayoutKit
.
instance
().
layoutAllPage
(
this
,
word
.
getZoom
());
LayoutKit
.
instance
().
layoutAllPage
(
this
,
word
.
getZoom
()
,
4
);
//
//
word
.
layoutPrintMode
();
word
.
layoutPrintMode
();
}
}
...
@@ -229,113 +210,96 @@ public class PageRoot extends AbstractView implements IRoot
...
@@ -229,113 +210,96 @@ public class PageRoot extends AbstractView implements IRoot
/**
/**
* @return Returns the paraCount.
* @return Returns the paraCount.
*/
*/
public
int
getParaCount
()
public
int
getParaCount
()
{
{
return
paraCount
;
return
paraCount
;
}
}
/**
/**
* @param paraCount The paraCount to set.
* @param paraCount The paraCount to set.
*/
*/
public
void
setParaCount
(
int
paraCount
)
public
void
setParaCount
(
int
paraCount
)
{
{
this
.
paraCount
=
paraCount
;
this
.
paraCount
=
paraCount
;
}
}
/**
/**
* @return Returns the pageCount.
* @return Returns the pageCount.
*/
*/
public
int
getPageCount
()
public
int
getPageCount
()
{
{
return
getChildCount
();
return
getChildCount
();
}
}
/**
/**
*
*
*/
*/
public
int
getChildCount
()
public
int
getChildCount
()
{
{
if
(
pages
!=
null
)
{
if
(
pages
!=
null
)
{
return
pages
.
size
();
return
pages
.
size
();
}
}
return
1
;
return
1
;
}
}
/**
/**
*
*
*/
*/
public
ViewContainer
getViewContainer
()
public
ViewContainer
getViewContainer
()
{
{
return
this
.
viewContainer
;
return
this
.
viewContainer
;
}
}
/**
/**
*
*
*/
*/
public
void
addPageView
(
PageView
pv
)
public
void
addPageView
(
PageView
pv
)
{
{
pages
.
add
(
pv
);
pages
.
add
(
pv
);
}
}
/**
/**
*
*
*/
*/
public
PageView
getPageView
(
int
pageIndex
)
public
PageView
getPageView
(
int
pageIndex
)
{
{
if
(
pageIndex
<
0
||
pageIndex
>=
pages
.
size
())
{
if
(
pageIndex
<
0
||
pageIndex
>=
pages
.
size
())
return
null
;
{
return
null
;
}
}
return
pages
.
get
(
pageIndex
);
return
pages
.
get
(
pageIndex
);
}
}
/**
/**
* update total pages after layout completed
* update total pages after layout completed
*/
*/
public
boolean
checkUpdateHeaderFooterFieldText
()
public
boolean
checkUpdateHeaderFooterFieldText
()
{
{
boolean
hasTotalPageCode
=
false
;
boolean
hasTotalPageCode
=
false
;
for
(
PageView
page
:
pages
)
{
for
(
PageView
page
:
pages
)
hasTotalPageCode
=
hasTotalPageCode
||
page
.
checkUpdateHeaderFooterFieldText
(
pages
.
size
());
{
}
hasTotalPageCode
=
hasTotalPageCode
||
page
.
checkUpdateHeaderFooterFieldText
(
pages
.
size
());
}
return
hasTotalPageCode
;
return
hasTotalPageCode
;
}
}
/**
/**
*
*
*
*/
*/
public
synchronized
void
dispose
()
public
synchronized
void
dispose
()
{
{
super
.
dispose
();
super
.
dispose
();
canBackLayout
=
false
;
canBackLayout
=
false
;
if
(
layoutThread
!=
null
)
if
(
layoutThread
!=
null
)
{
{
layoutThread
.
dispose
();
layoutThread
.
dispose
();
layoutThread
=
null
;
layoutThread
=
null
;
}
}
if
(
wpLayouter
!=
null
)
if
(
wpLayouter
!=
null
)
{
{
wpLayouter
.
dispose
();
wpLayouter
.
dispose
();
wpLayouter
=
null
;
wpLayouter
=
null
;
}
}
if
(
viewContainer
!=
null
)
if
(
viewContainer
!=
null
)
{
{
viewContainer
.
dispose
();
viewContainer
.
dispose
();
viewContainer
=
null
;
viewContainer
=
null
;
}
}
if
(
pages
!=
null
)
if
(
pages
!=
null
)
{
{
pages
.
clear
();
pages
.
clear
();
pages
=
null
;
pages
=
null
;
}
}
word
=
null
;
word
=
null
;
}
}
// 文档的段落总数
// 文档的段落总数
private
int
paraCount
;
private
int
paraCount
;
// 是否可后台布局
// 是否可后台布局
...
...
library/src/main/java/com/cherry/lib/doc/office/wp/view/WPLayouter.java
View file @
2327df15
...
@@ -72,7 +72,7 @@ public class WPLayouter
...
@@ -72,7 +72,7 @@ public class WPLayouter
PageView
pv
=
(
PageView
)
ViewFactory
.
createView
(
root
.
getControl
(),
section
,
null
,
WPViewConstant
.
PAGE_VIEW
);
PageView
pv
=
(
PageView
)
ViewFactory
.
createView
(
root
.
getControl
(),
section
,
null
,
WPViewConstant
.
PAGE_VIEW
);
root
.
appendChlidView
(
pv
);
root
.
appendChlidView
(
pv
);
layoutPage
(
pv
);
layoutPage
(
pv
);
LayoutKit
.
instance
().
layoutAllPage
(
root
,
1.0f
);
LayoutKit
.
instance
().
layoutAllPage
(
root
,
1.0f
,
5
);
}
}
/**
/**
...
...
library/src/main/java/com/cherry/lib/doc/widget/DocView.kt
View file @
2327df15
...
@@ -113,10 +113,9 @@ class DocView : FrameLayout {
...
@@ -113,10 +113,9 @@ class DocView : FrameLayout {
fun
openDoc
(
fun
openDoc
(
activity
:
Activity
,
docUrl
:
String
?,
docSourceType
:
Int
,
activity
:
Activity
,
docUrl
:
String
?,
docSourceType
:
Int
,
engine
:
DocEngine
=
this
.
engine
)
{
)
{
mActivity
=
activity
mActivity
=
activity
openDoc
(
activity
,
docUrl
,
docSourceType
,
-
1
,
false
,
engine
)
openDoc
(
activity
,
docUrl
,
docSourceType
,
-
1
,
false
)
}
}
@SuppressLint
(
"ObsoleteSdkInt"
)
@SuppressLint
(
"ObsoleteSdkInt"
)
...
@@ -126,7 +125,6 @@ class DocView : FrameLayout {
...
@@ -126,7 +125,6 @@ class DocView : FrameLayout {
docSourceType
:
Int
,
docSourceType
:
Int
,
fileType
:
Int
,
fileType
:
Int
,
viewPdfInPage
:
Boolean
=
false
,
viewPdfInPage
:
Boolean
=
false
,
engine
:
DocEngine
=
this
.
engine
)
{
)
{
var
fileType
=
fileType
var
fileType
=
fileType
var
docUrl
=
docUrl
var
docUrl
=
docUrl
...
...
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