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
Show 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 @@
<activity
android:name=
".ui.document.word.WordActivity"
android:exported=
"false"
android:launchMode=
"singleTop"
android:screenOrientation=
"portrait"
android:theme=
"@style/Theme.PDFViewerScannerWhite"
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>() {
fileType
=
intent
?.
getIntExtra
(
Constant
.
INTENT_TYPE_KEY
,
-
1
)
?:
-
1
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-docSourceType = $docSourceType"
)
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>() {
fileType
=
intent
?.
getIntExtra
(
Constant
.
INTENT_TYPE_KEY
,
-
1
)
?:
-
1
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-docSourceType = $docSourceType"
)
LogEx
.
logDebug
(
TAG
,
"initData-fileType = $fileType"
)
LogEx
.
logDebug
(
TAG
,
"initData-engine = $engine"
)
}
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>() {
LogEx
.
logDebug
(
TAG
,
"show"
)
}
}
}
private
fun
setVerticalSeekbar
(
current
:
Int
,
max
:
Int
)
{
binding
.
verticalSeekbar
.
showThumb
=
true
binding
.
verticalSeekbar
.
thumbContainerColor
=
Color
.
TRANSPARENT
binding
.
verticalSeekbar
.
thumbContainerColor
=
Color
.
TRANSPARENT
binding
.
verticalSeekbar
.
thumbPlaceholderDrawable
=
ContextCompat
.
getDrawable
(
this
,
R
.
mipmap
.
fanye
)
if
(
binding
.
verticalSeekbar
.
maxValue
!=
max
-
1
)
{
...
...
@@ -93,6 +91,7 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
cancelSearchUI
()
return
@addCallback
}
LogEx
.
logDebug
(
TAG
,
"finishToMain"
)
finishToMain
()
}
binding
.
flFanhui
.
setOnClickListener
{
...
...
@@ -103,11 +102,11 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
}
binding
.
ivMore
.
setOnClickListener
{
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
)
{
wpControl
.
wpView
.
showPage
(
pageIndex
,
APP_PAGE_DOWN_ID
)
wpControl
?.
wpView
?
.
showPage
(
pageIndex
,
APP_PAGE_DOWN_ID
)
}
else
{
wpControl
.
wpView
.
showPage
(
pageIndex
,
APP_PAGE_UP_ID
)
wpControl
?.
wpView
?
.
showPage
(
pageIndex
,
APP_PAGE_UP_ID
)
}
// wpControl.actionEvent(APP_PAGE_UP_ID, null)
}
...
...
@@ -120,8 +119,8 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
binding
.
tvPageCount
.
visibility
=
View
.
VISIBLE
haveSearchResult
=
false
hideBottomLayout
()
val
wpControl
:
WPControl
=
(
binding
.
mDocView
.
iOffice
?.
control
?.
appControl
as
WPControl
)
(
wpControl
.
find
as
WPFind
)
.
resetSearchResult
()
val
wpControl
:
WPControl
?
=
(
binding
.
mDocView
.
iOffice
?.
control
?.
appControl
as
WPControl
?
)
(
wpControl
?.
find
as
WPFind
?)
?
.
resetSearchResult
()
}
binding
.
editSearch
.
setOnEditorActionListener
{
v
,
actionId
,
event
->
...
...
@@ -133,23 +132,23 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
false
}
binding
.
flPre
.
setOnClickListener
{
val
wpControl
:
WPControl
=
(
binding
.
mDocView
.
iOffice
?.
control
?.
appControl
as
WPControl
)
(
wpControl
.
find
as
WPFind
)
.
findBackward
()
val
wpControl
:
WPControl
?
=
(
binding
.
mDocView
.
iOffice
?.
control
?.
appControl
as
WPControl
?
)
(
wpControl
?.
find
as
WPFind
?)
?
.
findBackward
()
}
binding
.
flNext
.
setOnClickListener
{
val
wpControl
:
WPControl
=
(
binding
.
mDocView
.
iOffice
?.
control
?.
appControl
as
WPControl
)
(
wpControl
.
find
as
WPFind
).
findForward
()
val
wpControl
:
WPControl
?
=
(
binding
.
mDocView
.
iOffice
?.
control
?.
appControl
as
WPControl
?
)
(
wpControl
?
.
find
as
WPFind
).
findForward
()
}
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"
)
val
pageIndex
=
totalPageNumber
-
1
-
progress
if
(
progress
>
currentPageNumber
)
{
wpControl
.
wpView
.
showPage
(
pageIndex
,
APP_PAGE_DOWN_ID
)
wpControl
?.
wpView
?
.
showPage
(
pageIndex
,
APP_PAGE_DOWN_ID
)
}
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>() {
if
(
text
.
isNullOrEmpty
())
{
return
}
val
wpControl
:
WPControl
=
(
binding
.
mDocView
.
iOffice
?.
control
?.
appControl
as
WPControl
)
val
flag
=
(
wpControl
.
find
as
WPFind
)
.
find
(
text
.
toString
())
haveSearchResult
=
flag
if
(
flag
)
{
val
wpControl
:
WPControl
?
=
(
binding
.
mDocView
.
iOffice
?.
control
?.
appControl
as
WPControl
?
)
val
flag
=
(
wpControl
?.
find
as
WPFind
?)
?
.
find
(
text
.
toString
())
haveSearchResult
=
flag
?:
false
if
(
flag
==
true
)
{
hideKeyboard
(
binding
.
editSearch
)
showBottomLayout
()
}
else
{
...
...
@@ -291,7 +290,7 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
fileType
=
intent
?.
getIntExtra
(
Constant
.
INTENT_TYPE_KEY
,
-
1
)
?:
-
1
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-docSourceType = $docSourceType"
)
LogEx
.
logDebug
(
TAG
,
"initData-fileType = $fileType"
)
...
...
@@ -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
import
android.app.Activity
import
android.content.Intent
import
android.net.Uri
import
android.os.Bundle
import
android.view.View
import
androidx.activity.OnBackPressedCallback
import
androidx.fragment.app.Fragment
...
...
@@ -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.PdfDialog.showPdfPwdDialog
import
com.base.pdfviewerscannerwhite.utils.IntentShareUtils.shareMutDocuments
import
com.base.pdfviewerscannerwhite.utils.LogEx
import
com.base.pdfviewerscannerwhite.utils.PermissionUtils.checkStorePermission
class
MainActivity
:
BaseActivity
<
ActivityMain2Binding
>(),
MainView
{
private
val
TAG
=
"MainActivity"
lateinit
var
mainPresenter
:
MainPresenter
override
val
binding
:
ActivityMain2Binding
by
lazy
{
ActivityMain2Binding
.
inflate
(
layoutInflater
)
...
...
@@ -46,6 +49,7 @@ class MainActivity : BaseActivity<ActivityMain2Binding>(), MainView {
private
var
currentFragment
:
Fragment
=
documentFragment
override
fun
initView
()
{
LogEx
.
logDebug
(
TAG
,
"initView"
)
mainPresenter
=
MainPresenter
(
this
,
this
,
lifecycleScope
)
}
...
...
@@ -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
isRecentAdd
:
Boolean
=
false
var
isBookmarkAdd
:
Boolean
=
false
...
...
@@ -92,6 +101,7 @@ class MainActivity : BaseActivity<ActivityMain2Binding>(), MainView {
changeTabSelect
(
it
)
supportFragmentManager
.
beginTransaction
().
apply
{
if
(!
isDocumentAdd
)
{
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() {
this
,
docUrl
,
docSourceType
,
fileType
,
false
,
DocEngine
.
values
().
first
{
it
.
value
==
engine
})
fileType
,
false
)
Log
.
e
(
TAG
,
"initData-docUrl = $docUrl"
)
Log
.
e
(
TAG
,
"initData-docSourceType = $docSourceType"
)
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 {
if
(
componentWidth
==
0
||
componentHeight
==
0
)
{
return
null
;
}
if
(
bitmap
==
null
||
bitmap
.
getWidth
()
!=
componentWidth
||
bitmap
.
getHeight
()
!=
componentHeight
)
{
if
(
bitmap
==
null
||
bitmap
.
getWidth
()
!=
componentWidth
||
bitmap
.
getHeight
()
!=
componentHeight
)
{
// custom picture size
if
(
bitmap
!=
null
)
{
bitmap
.
recycle
();
...
...
@@ -82,10 +80,13 @@ public abstract class IOffice implements IMainFrame {
}
private
void
saveBitmapToFile
(
Bitmap
bitmap
)
{
Log
.
e
(
TAG
,
"saveBitmapToFile1"
);
if
(
bitmap
==
null
)
{
Log
.
e
(
TAG
,
"saveBitmapToFile2"
);
return
;
}
if
(
tempFilePath
==
null
)
{
Log
.
e
(
TAG
,
"saveBitmapToFile3"
);
// 存在外部目录相册中会显示
// String state = Environment.getExternalStorageState();
// if (Environment.MEDIA_MOUNTED.equals(state)) {
...
...
@@ -101,6 +102,7 @@ public abstract class IOffice implements IMainFrame {
File
file
=
new
File
(
tempFilePath
+
File
.
separatorChar
+
"export_image.jpg"
);
try
{
if
(
file
.
exists
())
{
Log
.
e
(
TAG
,
"saveBitmapToFile4"
);
file
.
delete
();
}
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> {
}
/**
*
*/
...
...
@@ -721,6 +720,7 @@ public class APageListView extends AdapterView<Adapter> {
*
*/
public
float
getZoom
()
{
Log
.
e
(
"APageListView"
,
"getZoom"
);
return
zoom
;
}
...
...
@@ -728,6 +728,7 @@ public class APageListView extends AdapterView<Adapter> {
*
*/
public
float
getFitZoom
()
{
Log
.
e
(
"APageListView"
,
"getFitZoom"
);
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 {
*
*/
public
float
getZoom
()
{
Log
.
e
(
"PrintWord"
,
"getZoom"
);
return
listView
.
getZoom
();
}
...
...
@@ -181,6 +182,7 @@ public class PrintWord extends FrameLayout implements IPageListViewListener {
*
*/
public
float
getFitZoom
()
{
Log
.
e
(
"PrintWord"
,
"getFitZoom"
);
return
listView
.
getFitZoom
();
}
...
...
library/src/main/java/com/cherry/lib/doc/office/wp/control/WPControl.java
View file @
2327df15
...
...
@@ -32,6 +32,7 @@ import android.content.Intent;
import
android.graphics.Bitmap
;
import
android.net.Uri
;
import
android.text.ClipboardManager
;
import
android.util.Log
;
import
android.view.View
;
import
org.jetbrains.annotations.Nullable
;
...
...
@@ -53,44 +54,39 @@ import org.jetbrains.annotations.Nullable;
* <p>
* <p>
*/
public
class
WPControl
extends
AbstractControl
{
public
class
WPControl
extends
AbstractControl
{
/**
*
* @param doc
* @param filePath
*/
public
WPControl
(
IControl
mainControl
,
IDocument
doc
,
String
filePath
)
{
public
WPControl
(
IControl
mainControl
,
IDocument
doc
,
String
filePath
)
{
this
.
mainControl
=
mainControl
;
wpView
=
new
Word
(
mainControl
.
getMainFrame
().
getActivity
().
getApplicationContext
(),
doc
,
filePath
,
this
);
}
/**
* 布局视图
*
* @param x
* @param y
* @param w
* @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派发
*
* @param actionID 动作ID
* @param obj 动作ID的Value
*/
public
void
actionEvent
(
int
actionID
,
final
@Nullable
Object
obj
)
{
switch
(
actionID
)
{
public
void
actionEvent
(
int
actionID
,
final
@Nullable
Object
obj
)
{
switch
(
actionID
)
{
case
EventConstant
.
WP_SHOW_PAGE
:
wpView
.
showPage
((
Integer
)
obj
,
EventConstant
.
WP_SHOW_PAGE
);
if
(
wpView
.
getCurrentRootType
()
==
WPViewConstant
.
PRINT_ROOT
)
{
wpView
.
showPage
((
Integer
)
obj
,
EventConstant
.
WP_SHOW_PAGE
);
if
(
wpView
.
getCurrentRootType
()
==
WPViewConstant
.
PRINT_ROOT
)
{
return
;
}
//
...
...
@@ -99,19 +95,15 @@ public class WPControl extends AbstractControl
exportImage
();
break
;
case
EventConstant
.
SYS_SET_PROGRESS_BAR_ID
:
if
(
wpView
.
getParent
()
!=
null
)
{
wpView
.
post
(
new
Runnable
()
{
if
(
wpView
.
getParent
()
!=
null
)
{
wpView
.
post
(
new
Runnable
()
{
/**
*
*/
public
void
run
()
{
if
(!
isDispose
)
{
public
void
run
()
{
if
(!
isDispose
)
{
//getActivity().setProgressBarIndeterminateVisibility((Boolean)obj);
mainControl
.
getMainFrame
().
showProgressBar
((
Boolean
)
obj
);
mainControl
.
getMainFrame
().
showProgressBar
((
Boolean
)
obj
);
}
}
});
...
...
@@ -119,34 +111,25 @@ public class WPControl extends AbstractControl
break
;
case
EventConstant
.
SYS_VECTORGRAPH_PROGRESS
:
if
(
wpView
.
getParent
()
!=
null
)
{
wpView
.
post
(
new
Runnable
()
{
if
(
wpView
.
getParent
()
!=
null
)
{
wpView
.
post
(
new
Runnable
()
{
/**
*
*/
public
void
run
()
{
if
(!
isDispose
)
{
mainControl
.
getMainFrame
().
updateViewImages
((
List
<
Integer
>)
obj
);
public
void
run
()
{
if
(!
isDispose
)
{
mainControl
.
getMainFrame
().
updateViewImages
((
List
<
Integer
>)
obj
);
}
}
});
}
else
{
new
Thread
()
{
}
else
{
new
Thread
()
{
/**
*
*/
public
void
run
()
{
if
(!
isDispose
)
{
mainControl
.
getMainFrame
().
updateViewImages
((
List
<
Integer
>)
obj
);
public
void
run
()
{
if
(!
isDispose
)
{
mainControl
.
getMainFrame
().
updateViewImages
((
List
<
Integer
>)
obj
);
}
}
}.
start
();
...
...
@@ -162,8 +145,7 @@ public class WPControl extends AbstractControl
break
;
case
EventConstant
.
WP_PRINT_MODE
:
if
(
wpView
.
getCurrentRootType
()
==
WPViewConstant
.
PRINT_ROOT
)
{
if
(
wpView
.
getCurrentRootType
()
==
WPViewConstant
.
PRINT_ROOT
)
{
return
;
}
wpView
.
switchView
(
WPViewConstant
.
PRINT_ROOT
);
...
...
@@ -172,43 +154,33 @@ public class WPControl extends AbstractControl
case
EventConstant
.
WP_SWITCH_VIEW
:
int
rootType
;
if
(
obj
!=
null
)
{
rootType
=
(
Integer
)
obj
;
}
else
{
if
(
obj
!=
null
)
{
rootType
=
(
Integer
)
obj
;
}
else
{
rootType
=
wpView
.
getCurrentRootType
();
if
(
rootType
==
WPViewConstant
.
PAGE_ROOT
)
{
if
(
rootType
==
WPViewConstant
.
PAGE_ROOT
)
{
rootType
=
WPViewConstant
.
NORMAL_ROOT
;
}
else
{
}
else
{
rootType
=
WPViewConstant
.
PAGE_ROOT
;
}
}
wpView
.
switchView
(
rootType
);
//
updateStatus
();
if
(
rootType
!=
WPViewConstant
.
PRINT_ROOT
)
{
if
(
rootType
!=
WPViewConstant
.
PRINT_ROOT
)
{
exportImage
();
}
break
;
case
EventConstant
.
APP_ZOOM_ID
:
int
[]
params
=
(
int
[])
obj
;
wpView
.
setZoom
(
params
[
0
]
/
(
float
)
MainConstant
.
STANDARD_RATE
,
params
[
1
],
params
[
2
]);
wpView
.
post
(
new
Runnable
()
{
@
Override
public
void
run
()
{
if
(!
isDispose
)
{
int
[]
params
=
(
int
[])
obj
;
Log
.
e
(
"WPControl"
,
"actionEvent EventConstant.APP_ZOOM_ID"
);
wpView
.
setZoom
(
params
[
0
]
/
(
float
)
MainConstant
.
STANDARD_RATE
,
params
[
1
],
params
[
2
]);
wpView
.
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(!
isDispose
)
{
getMainFrame
().
changeZoom
();
}
}
...
...
@@ -229,28 +201,24 @@ public class WPControl extends AbstractControl
break
;
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
());
break
;
case
EventConstant
.
SYS_AUTO_TEST_FINISH_ID
:
// 布局完成
wpView
.
post
(
new
Runnable
()
{
wpView
.
post
(
new
Runnable
()
{
/**
*
*/
public
void
run
()
{
if
(!
isDispose
)
{
public
void
run
()
{
if
(!
isDispose
)
{
//getMainFrame().getActivity().setProgressBarIndeterminateVisibility(false);
mainControl
.
getMainFrame
().
showProgressBar
(
false
);
}
}
});
if
(
isAutoTest
())
{
if
(
isAutoTest
())
{
getMainFrame
().
getActivity
().
onBackPressed
();
}
break
;
...
...
@@ -260,19 +228,14 @@ public class WPControl extends AbstractControl
break
;
case
EventConstant
.
APP_PAGE_UP_ID
:
if
(
wpView
.
getCurrentRootType
()
==
WPViewConstant
.
NORMAL_ROOT
)
{
if
(
wpView
.
getEventManage
()
!=
null
)
{
if
(
wpView
.
getCurrentRootType
()
==
WPViewConstant
.
NORMAL_ROOT
)
{
if
(
wpView
.
getEventManage
()
!=
null
)
{
wpView
.
getEventManage
().
onScroll
(
null
,
null
,
0
,
-
wpView
.
getHeight
()
+
10
);
}
}
else
{
}
else
{
wpView
.
showPage
(
wpView
.
getCurrentPageNumber
()
-
2
,
EventConstant
.
APP_PAGE_UP_ID
);
}
if
(
wpView
.
getCurrentRootType
()
==
WPViewConstant
.
PRINT_ROOT
)
{
if
(
wpView
.
getCurrentRootType
()
==
WPViewConstant
.
PRINT_ROOT
)
{
return
;
}
//
...
...
@@ -282,19 +245,14 @@ public class WPControl extends AbstractControl
break
;
case
EventConstant
.
APP_PAGE_DOWN_ID
:
if
(
wpView
.
getCurrentRootType
()
==
WPViewConstant
.
NORMAL_ROOT
)
{
if
(
wpView
.
getEventManage
()
!=
null
)
{
if
(
wpView
.
getCurrentRootType
()
==
WPViewConstant
.
NORMAL_ROOT
)
{
if
(
wpView
.
getEventManage
()
!=
null
)
{
wpView
.
getEventManage
().
onScroll
(
null
,
null
,
0
,
wpView
.
getHeight
()
+
10
);
}
}
else
{
}
else
{
wpView
.
showPage
(
wpView
.
getCurrentPageNumber
(),
EventConstant
.
APP_PAGE_DOWN_ID
);
}
if
(
wpView
.
getCurrentRootType
()
==
WPViewConstant
.
PRINT_ROOT
)
{
if
(
wpView
.
getCurrentRootType
()
==
WPViewConstant
.
PRINT_ROOT
)
{
return
;
}
//
...
...
@@ -304,54 +262,41 @@ public class WPControl extends AbstractControl
break
;
case
EventConstant
.
APP_HYPERLINK
:
//hyperlink
Hyperlink
link
=
((
Hyperlink
)
obj
);
if
(
link
!=
null
)
{
try
{
if
(
link
.
getLinkType
()
==
Hyperlink
.
LINK_BOOKMARK
)
{
Hyperlink
link
=
((
Hyperlink
)
obj
);
if
(
link
!=
null
)
{
try
{
if
(
link
.
getLinkType
()
==
Hyperlink
.
LINK_BOOKMARK
)
{
Bookmark
bm
=
getSysKit
().
getBookmarkManage
().
getBookmark
(
link
.
getAddress
());
if
(
bm
!=
null
)
{
if
(
bm
!=
null
)
{
ControlKit
.
instance
().
gotoOffset
(
wpView
,
bm
.
getStart
());
}
}
else
{
}
else
{
Intent
intent
=
new
Intent
(
Intent
.
ACTION_VIEW
,
Uri
.
parse
(
link
.
getAddress
()));
getMainFrame
().
getActivity
().
startActivity
(
intent
);
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
}
}
break
;
case
EventConstant
.
WP_LAYOUT_NORMAL_VIEW
:
if
(
wpView
.
getCurrentRootType
()
==
WPViewConstant
.
NORMAL_ROOT
)
{
if
(
wpView
.
getCurrentRootType
()
==
WPViewConstant
.
NORMAL_ROOT
)
{
wpView
.
setExportImageAfterZoom
(
true
);
wpView
.
layoutNormal
();
}
break
;
case
EventConstant
.
WP_LAYOUT_COMPLETED
:
if
(
wpView
!=
null
)
{
if
(
wpView
!=
null
)
{
wpView
.
updateFieldText
();
if
(
wpView
.
getParent
()
==
null
)
{
if
(
wpView
.
getParent
()
==
null
)
{
getMainFrame
().
completeLayout
();
break
;
}
wpView
.
post
(
new
Runnable
()
{
@
Override
public
void
run
()
{
wpView
.
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
getMainFrame
().
completeLayout
();
}
});
...
...
@@ -360,7 +305,7 @@ public class WPControl extends AbstractControl
break
;
case
EventConstant
.
APP_SET_FIT_SIZE_ID
:
wpView
.
setFitSize
((
Integer
)
obj
);
wpView
.
setFitSize
((
Integer
)
obj
);
break
;
case
EventConstant
.
APP_INIT_CALLOUTVIEW_ID
:
...
...
@@ -377,15 +322,13 @@ public class WPControl extends AbstractControl
*
* @return obj
*/
public
@Nullable
Object
getActionValue
(
int
actionID
,
@Nullable
Object
obj
)
{
switch
(
actionID
)
{
public
@Nullable
Object
getActionValue
(
int
actionID
,
@Nullable
Object
obj
)
{
switch
(
actionID
)
{
case
EventConstant
.
APP_ZOOM_ID
:
return
wpView
.
getZoom
();
case
EventConstant
.
WP_SELECT_TEXT_ID
:
return
((
Word
)
wpView
).
getStatus
().
isSelectTextStatus
();
return
((
Word
)
wpView
).
getStatus
().
isSelectTextStatus
();
case
EventConstant
.
APP_FIT_ZOOM_ID
:
return
wpView
.
getFitZoom
();
...
...
@@ -397,42 +340,37 @@ public class WPControl extends AbstractControl
return
wpView
.
getCurrentPageNumber
();
case
EventConstant
.
WP_PAGE_TO_IMAGE
:
return
wpView
.
pageToImage
((
Integer
)
obj
);
return
wpView
.
pageToImage
((
Integer
)
obj
);
case
EventConstant
.
APP_PAGEAREA_TO_IMAGE
:
if
(
obj
instanceof
int
[])
{
int
[]
paraArr
=
(
int
[])
obj
;
if
(
paraArr
!=
null
&&
paraArr
.
length
==
7
)
{
if
(
obj
instanceof
int
[])
{
int
[]
paraArr
=
(
int
[])
obj
;
if
(
paraArr
!=
null
&&
paraArr
.
length
==
7
)
{
return
wpView
.
pageAreaToImage
(
paraArr
[
0
],
paraArr
[
1
],
paraArr
[
2
],
paraArr
[
3
],
paraArr
[
4
],
paraArr
[
5
],
paraArr
[
6
]);
}
}
break
;
case
EventConstant
.
APP_THUMBNAIL_ID
:
if
(
obj
instanceof
Integer
)
{
return
wpView
.
getThumbnail
((
Integer
)
obj
/
(
float
)
MainConstant
.
STANDARD_RATE
);
if
(
obj
instanceof
Integer
)
{
return
wpView
.
getThumbnail
((
Integer
)
obj
/
(
float
)
MainConstant
.
STANDARD_RATE
);
}
break
;
case
EventConstant
.
WP_GET_PAGE_SIZE
:
return
wpView
.
getPageSize
((
Integer
)
obj
-
1
);
return
wpView
.
getPageSize
((
Integer
)
obj
-
1
);
case
EventConstant
.
WP_GET_VIEW_MODE
:
return
wpView
.
getCurrentRootType
();
case
EventConstant
.
APP_GET_FIT_SIZE_STATE_ID
:
if
(
wpView
!=
null
)
{
if
(
wpView
!=
null
)
{
return
wpView
.
getFitSizeState
();
}
break
;
case
EventConstant
.
APP_GET_SNAPSHOT_ID
:
if
(
wpView
!=
null
)
{
return
wpView
.
getSnapshot
((
Bitmap
)
obj
);
if
(
wpView
!=
null
)
{
return
wpView
.
getSnapshot
((
Bitmap
)
obj
);
}
break
;
...
...
@@ -445,15 +383,11 @@ public class WPControl extends AbstractControl
/**
*
*/
private
void
exportImage
()
{
wpView
.
post
(
new
Runnable
()
{
@
Override
public
void
run
()
{
if
(!
isDispose
)
{
private
void
exportImage
()
{
wpView
.
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(!
isDispose
)
{
wpView
.
createPicture
();
}
}
...
...
@@ -463,15 +397,11 @@ public class WPControl extends AbstractControl
/**
*
*/
private
void
updateStatus
()
{
wpView
.
post
(
new
Runnable
()
{
@
Override
public
void
run
()
{
if
(!
isDispose
)
{
private
void
updateStatus
()
{
wpView
.
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(!
isDispose
)
{
getMainFrame
().
updateToolsbarStatus
();
}
}
...
...
@@ -480,29 +410,26 @@ public class WPControl extends AbstractControl
/**
* current view index
*
* @return
*/
public
int
getCurrentViewIndex
()
{
public
int
getCurrentViewIndex
()
{
return
wpView
.
getCurrentPageNumber
();
}
/**
*
*/
public
View
getView
()
{
public
View
getView
()
{
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
:
// 文本文本编码格式对话框
Vector
<
Object
>
vector
=
new
Vector
<
Object
>();
vector
.
add
(
wpView
.
getFilePath
());
...
...
@@ -518,75 +445,63 @@ public class WPControl extends AbstractControl
/**
*
*/
public
IMainFrame
getMainFrame
()
{
public
IMainFrame
getMainFrame
()
{
return
mainControl
.
getMainFrame
();
}
/**
*
*/
public
Activity
getActivity
()
{
public
Activity
getActivity
()
{
return
getMainFrame
().
getActivity
();
}
/**
*
*/
public
IFind
getFind
()
{
public
IFind
getFind
()
{
return
wpView
.
getFind
();
}
/**
*
*/
public
boolean
isAutoTest
()
{
public
boolean
isAutoTest
()
{
return
mainControl
.
isAutoTest
();
}
/**
*
*
*/
public
IOfficeToPicture
getOfficeToPicture
()
{
public
IOfficeToPicture
getOfficeToPicture
()
{
return
mainControl
.
getOfficeToPicture
();
}
/**
*
*/
public
ICustomDialog
getCustomDialog
()
{
public
ICustomDialog
getCustomDialog
()
{
return
mainControl
.
getCustomDialog
();
}
/**
*
*
*/
public
int
getApplicationType
()
{
public
int
getApplicationType
()
{
return
MainConstant
.
APPLICATION_TYPE_WP
;
}
/**
*
*/
public
SysKit
getSysKit
()
{
public
SysKit
getSysKit
()
{
return
mainControl
.
getSysKit
();
}
/**
*
*
*/
public
void
dispose
()
{
public
void
dispose
()
{
isDispose
=
true
;
wpView
.
dispose
();
wpView
=
null
;
...
...
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;
import
com.cherry.lib.doc.office.system.IDialogAction
;
import
com.cherry.lib.doc.office.system.SysKit
;
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.NormalRoot
;
import
com.cherry.lib.doc.office.wp.view.PageRoot
;
...
...
@@ -112,6 +113,7 @@ public class Word extends LinearLayout implements IWord {
if
(
normalRoot
!=
null
)
{
normalRoot
.
doLayout
(
0
,
0
,
mWidth
,
mHeight
,
Integer
.
MAX_VALUE
,
0
);
}
else
{
Log
.
e
(
"Word"
,
"init"
);
pageRoot
.
doLayout
(
0
,
0
,
mWidth
,
mHeight
,
Integer
.
MAX_VALUE
,
0
);
}
initFinish
=
true
;
...
...
@@ -140,6 +142,7 @@ public class Word extends LinearLayout implements IWord {
}
try
{
if
(
getCurrentRootType
()
==
WPViewConstant
.
PAGE_ROOT
)
{
Log
.
e
(
"Wod"
,
"onDraw zoom="
+
zoom
);
pageRoot
.
draw
(
canvas
,
0
,
0
,
zoom
);
drawPageNubmer
(
canvas
,
zoom
);
}
else
if
(
getCurrentRootType
()
==
WPViewConstant
.
NORMAL_ROOT
)
{
...
...
@@ -172,7 +175,9 @@ public class Word extends LinearLayout implements IWord {
*
*/
private
void
toPicture
(
IOfficeToPicture
otp
)
{
Log
.
e
(
"Word"
,
"toPicture1"
);
if
(
getCurrentRootType
()
==
WPViewConstant
.
PRINT_ROOT
)
{
Log
.
e
(
"Word"
,
"toPicture2"
);
WPPageListItem
item
=
(
WPPageListItem
)
printWord
.
getListView
().
getCurrentPageView
();
item
.
addRepaintImageView
(
null
);
return
;
...
...
@@ -181,12 +186,15 @@ public class Word extends LinearLayout implements IWord {
PictureKit
.
instance
().
setDrawPictrue
(
true
);
Bitmap
bitmap
=
otp
.
getBitmap
(
getWidth
(),
getHeight
());
if
(
bitmap
==
null
)
{
Log
.
e
(
"Word"
,
"toPicture3"
);
return
;
}
float
paintZoom
=
getZoom
();
Log
.
e
(
"Word"
,
"paintZoom="
+
paintZoom
);
float
tX
=
-
getScrollX
();
float
tY
=
-
getScrollY
();
if
(
bitmap
.
getWidth
()
!=
getWidth
()
||
bitmap
.
getHeight
()
!=
getHeight
())
{
Log
.
e
(
"Word"
,
"toPicture4"
);
float
newZoom
=
Math
.
min
((
float
)
bitmap
.
getWidth
()
/
getWidth
(),
(
float
)
bitmap
.
getHeight
()
/
getHeight
())
*
getZoom
();
...
...
@@ -275,7 +283,7 @@ public class Word extends LinearLayout implements IWord {
return
;
}
eventManage
.
stopFling
();
LayoutKit
.
instance
().
layoutAllPage
(
pageRoot
,
zoom
);
LayoutKit
.
instance
().
layoutAllPage
(
pageRoot
,
zoom
,
1
);
if
(
currentRootType
==
WPViewConstant
.
PAGE_ROOT
)
{
Rectangle
r
=
getVisibleRect
();
int
sX
=
r
.
x
;
...
...
@@ -374,9 +382,10 @@ public class Word extends LinearLayout implements IWord {
}
else
if
(
getCurrentRootType
()
==
WPViewConstant
.
PAGE_ROOT
)
{
if
(
pageRoot
==
null
)
{
pageRoot
=
new
PageRoot
(
this
);
Log
.
e
(
"Word"
,
"switchView1"
);
pageRoot
.
doLayout
(
0
,
0
,
mWidth
,
mHeight
,
Integer
.
MAX_VALUE
,
0
);
}
else
{
LayoutKit
.
instance
().
layoutAllPage
(
pageRoot
,
zoom
);
LayoutKit
.
instance
().
layoutAllPage
(
pageRoot
,
zoom
,
2
);
}
setOnTouchListener
(
eventManage
);
if
(
printWord
!=
null
)
{
...
...
@@ -385,6 +394,7 @@ public class Word extends LinearLayout implements IWord {
}
else
if
(
getCurrentRootType
()
==
WPViewConstant
.
PRINT_ROOT
)
{
if
(
pageRoot
==
null
)
{
pageRoot
=
new
PageRoot
(
this
);
Log
.
e
(
"Word"
,
"switchView2"
);
pageRoot
.
doLayout
(
0
,
0
,
mWidth
,
mHeight
,
Integer
.
MAX_VALUE
,
0
);
}
if
(
printWord
==
null
)
{
...
...
@@ -438,11 +448,13 @@ public class Word extends LinearLayout implements IWord {
* @param zoom The zoom to set.
*/
public
void
setZoom
(
float
zoom
,
int
pointX
,
int
pointY
)
{
Log
.
e
(
"Word"
,
"setZoom "
+
"zoom="
+
zoom
+
" pointX="
+
pointX
+
" pointY="
+
pointY
);
float
oldZoom
=
1.0f
;
if
(
currentRootType
==
WPViewConstant
.
PAGE_ROOT
)
{
oldZoom
=
this
.
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
)
{
printWord
.
setZoom
(
zoom
,
pointX
,
pointY
);
return
;
...
...
@@ -889,9 +901,11 @@ public class Word extends LinearLayout implements IWord {
* @return Returns the zoom.
*/
public
float
getZoom
()
{
Log
.
e
(
"Word"
,
"getZoom currentRootType="
+
currentRootType
);
if
(
currentRootType
==
WPViewConstant
.
NORMAL_ROOT
)
{
return
normalZoom
;
}
else
if
(
currentRootType
==
WPViewConstant
.
PAGE_ROOT
)
{
Log
.
e
(
"Word"
,
"getZoom zoom="
+
zoom
);
return
zoom
;
}
else
if
(
currentRootType
==
WPViewConstant
.
PRINT_ROOT
)
{
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 {
* @param root
* @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
)
{
Log
.
e
(
"LayoutKit"
,
"中断1"
);
return
;
}
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
();
boolean
isLandscape
=
resources
.
getConfiguration
().
orientation
==
Configuration
.
ORIENTATION_LANDSCAPE
;
...
...
@@ -89,14 +95,17 @@ public class LayoutKit {
IView
pv
=
root
.
getChildView
();
int
pvWidth
=
pv
.
getWidth
();
float
scale
=
1
;
Log
.
e
(
TAG
,
"layoutAllPage screenWidthPixels="
+
screenWidthPixels
+
" pvWidth"
+
pvWidth
);
if
(
screenWidthPixels
!=
0
&&
pvWidth
!=
0
)
{
scale
=
screenWidthPixels
*
1
f
/
pvWidth
;
if
(
zoom
==
1
f
)
{
Log
.
e
(
TAG
,
"layoutAllPage scale="
+
scale
);
word
.
setZoom
(
scale
,
0
,
0
);
}
}
Log
.
d
(
TAG
,
"layoutAllPage screenWidthPixels = "
+
screenWidthPixels
+
"; isLandscape "
+
isLandscape
+
", pvWidth = "
+
pvWidth
+
"; scale = "
+
scale
);
}
Log
.
e
(
"LayoutKit"
,
"中断2"
);
int
dx
=
WPViewConstant
.
PAGE_SPACE
;
int
dy
=
WPViewConstant
.
PAGE_SPACE
;
IView
pv
=
root
.
getChildView
();
...
...
library/src/main/java/com/cherry/lib/doc/office/wp/view/PageRoot.java
View file @
2327df15
...
...
@@ -24,6 +24,7 @@ import com.cherry.lib.doc.office.system.IControl;
import
com.cherry.lib.doc.office.wp.control.Word
;
import
android.graphics.Canvas
;
import
android.util.Log
;
/**
* 页面视图根视图
...
...
@@ -41,11 +42,9 @@ import android.graphics.Canvas;
* <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
;
layoutThread
=
new
LayoutThread
(
this
);
wpLayouter
=
new
WPLayouter
(
this
);
...
...
@@ -58,12 +57,13 @@ public class PageRoot extends AbstractView implements IRoot
/**
*
*/
public
short
getType
()
{
public
short
getType
()
{
return
WPViewConstant
.
PAGE_ROOT
;
}
/**
* 视图布局
*
* @param x
* @param y
* @param w
...
...
@@ -71,59 +71,52 @@ public class PageRoot extends AbstractView implements IRoot
* @param maxEnd
* @param flag 布局标记,传递一些布尔值,位操作
*/
public
int
doLayout
(
int
x
,
int
y
,
int
w
,
int
h
,
int
maxEnd
,
int
flag
)
{
try
{
public
int
doLayout
(
int
x
,
int
y
,
int
w
,
int
h
,
int
maxEnd
,
int
flag
)
{
Log
.
e
(
"PageRoot"
,
"doLayout1"
);
try
{
IDocument
doc
=
getDocument
();
setParaCount
(
doc
.
getParaCount
(
WPModelConstant
.
MAIN
));
wpLayouter
.
doLayout
();
if
(!
wpLayouter
.
isLayoutFinish
()
&&
!
word
.
getControl
().
getMainFrame
().
isThumbnail
())
{
if
(!
wpLayouter
.
isLayoutFinish
()
&&
!
word
.
getControl
().
getMainFrame
().
isThumbnail
())
{
layoutThread
.
start
();
word
.
getControl
().
actionEvent
(
EventConstant
.
SYS_SET_PROGRESS_BAR_ID
,
true
);
//word.getControl().getMainFrame().getActivity().setProgressBarIndeterminateVisibility(true);
}
// auto test code
else
{
else
{
word
.
getControl
().
actionEvent
(
EventConstant
.
WP_LAYOUT_COMPLETED
,
true
);
word
.
getControl
().
actionEvent
(
EventConstant
.
SYS_AUTO_TEST_FINISH_ID
,
true
);
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
word
.
getControl
().
getSysKit
().
getErrorKit
().
writerLog
(
e
);
Log
.
e
(
"PageRoot"
,
"doLayout2"
);
}
return
WPViewConstant
.
BREAK_NO
;
}
/**
*
* @param canvas
* @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
);
}
/**
* model到视图
*
* @param offset 指定的offset
* @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
=
viewContainer
.
getParagraph
(
offset
,
isBack
);
if
(
view
!=
null
)
{
if
(
view
!=
null
)
{
view
.
modelToView
(
offset
,
rect
,
isBack
);
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)
{
rect.x += p.getX() + p.getLeftIndent();
...
...
@@ -149,25 +142,20 @@ public class PageRoot extends AbstractView implements IRoot
* @param y
* @param isBack 是否向后取,是为在视图上,上一行的结束位置与下一行开始位置相同
*/
public
long
viewToModel
(
int
x
,
int
y
,
boolean
isBack
)
{
public
long
viewToModel
(
int
x
,
int
y
,
boolean
isBack
)
{
x
-=
getX
();
y
-=
getY
();
IView
view
=
getChildView
();
if
(
view
!=
null
&&
y
>
view
.
getY
())
{
while
(
view
!=
null
)
{
if
(
y
>=
view
.
getY
()
&&
y
<=
view
.
getY
()
+
view
.
getHeight
()
+
MainConstant
.
GAP
/
2
)
{
if
(
view
!=
null
&&
y
>
view
.
getY
())
{
while
(
view
!=
null
)
{
if
(
y
>=
view
.
getY
()
&&
y
<=
view
.
getY
()
+
view
.
getHeight
()
+
MainConstant
.
GAP
/
2
)
{
break
;
}
view
=
view
.
getNextView
();
}
}
view
=
view
==
null
?
getChildView
()
:
view
;
if
(
view
!=
null
)
{
if
(
view
!=
null
)
{
return
view
.
viewToModel
(
x
,
y
,
isBack
);
}
return
-
1
;
...
...
@@ -176,52 +164,45 @@ public class PageRoot extends AbstractView implements IRoot
/**
* 得到model
*/
public
IDocument
getDocument
()
{
public
IDocument
getDocument
()
{
return
word
.
getDocument
();
}
/**
*
*/
public
IWord
getContainer
()
{
public
IWord
getContainer
()
{
return
word
;
}
/**
*
*/
public
IControl
getControl
()
{
public
IControl
getControl
()
{
return
word
.
getControl
();
}
/**
*
*
*/
public
boolean
canBackLayout
()
{
public
boolean
canBackLayout
()
{
return
canBackLayout
&&
!
wpLayouter
.
isLayoutFinish
();
}
/**
*
*/
public
synchronized
void
backLayout
()
{
public
synchronized
void
backLayout
()
{
wpLayouter
.
backLayout
();
word
.
postInvalidate
();
// auto test code
if
(
wpLayouter
.
isLayoutFinish
())
{
if
(
wpLayouter
.
isLayoutFinish
())
{
word
.
getControl
().
actionEvent
(
EventConstant
.
SYS_AUTO_TEST_FINISH_ID
,
true
);
word
.
getControl
().
actionEvent
(
EventConstant
.
WP_LAYOUT_COMPLETED
,
true
);
}
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
();
}
...
...
@@ -229,16 +210,14 @@ public class PageRoot extends AbstractView implements IRoot
/**
* @return Returns the paraCount.
*/
public
int
getParaCount
()
{
public
int
getParaCount
()
{
return
paraCount
;
}
/**
* @param paraCount The paraCount to set.
*/
public
void
setParaCount
(
int
paraCount
)
{
public
void
setParaCount
(
int
paraCount
)
{
this
.
paraCount
=
paraCount
;
}
...
...
@@ -246,18 +225,15 @@ public class PageRoot extends AbstractView implements IRoot
/**
* @return Returns the pageCount.
*/
public
int
getPageCount
()
{
public
int
getPageCount
()
{
return
getChildCount
();
}
/**
*
*/
public
int
getChildCount
()
{
if
(
pages
!=
null
)
{
public
int
getChildCount
()
{
if
(
pages
!=
null
)
{
return
pages
.
size
();
}
return
1
;
...
...
@@ -266,26 +242,22 @@ public class PageRoot extends AbstractView implements IRoot
/**
*
*/
public
ViewContainer
getViewContainer
()
{
public
ViewContainer
getViewContainer
()
{
return
this
.
viewContainer
;
}
/**
*
*/
public
void
addPageView
(
PageView
pv
)
{
public
void
addPageView
(
PageView
pv
)
{
pages
.
add
(
pv
);
}
/**
*
*/
public
PageView
getPageView
(
int
pageIndex
)
{
if
(
pageIndex
<
0
||
pageIndex
>=
pages
.
size
())
{
public
PageView
getPageView
(
int
pageIndex
)
{
if
(
pageIndex
<
0
||
pageIndex
>=
pages
.
size
())
{
return
null
;
}
return
pages
.
get
(
pageIndex
);
...
...
@@ -294,11 +266,9 @@ public class PageRoot extends AbstractView implements IRoot
/**
* update total pages after layout completed
*/
public
boolean
checkUpdateHeaderFooterFieldText
()
{
public
boolean
checkUpdateHeaderFooterFieldText
()
{
boolean
hasTotalPageCode
=
false
;
for
(
PageView
page
:
pages
)
{
for
(
PageView
page
:
pages
)
{
hasTotalPageCode
=
hasTotalPageCode
||
page
.
checkUpdateHeaderFooterFieldText
(
pages
.
size
());
}
...
...
@@ -306,30 +276,24 @@ public class PageRoot extends AbstractView implements IRoot
}
/**
*
*
*/
public
synchronized
void
dispose
()
{
public
synchronized
void
dispose
()
{
super
.
dispose
();
canBackLayout
=
false
;
if
(
layoutThread
!=
null
)
{
if
(
layoutThread
!=
null
)
{
layoutThread
.
dispose
();
layoutThread
=
null
;
}
if
(
wpLayouter
!=
null
)
{
if
(
wpLayouter
!=
null
)
{
wpLayouter
.
dispose
();
wpLayouter
=
null
;
}
if
(
viewContainer
!=
null
)
{
if
(
viewContainer
!=
null
)
{
viewContainer
.
dispose
();
viewContainer
=
null
;
}
if
(
pages
!=
null
)
{
if
(
pages
!=
null
)
{
pages
.
clear
();
pages
=
null
;
}
...
...
library/src/main/java/com/cherry/lib/doc/office/wp/view/WPLayouter.java
View file @
2327df15
...
...
@@ -72,7 +72,7 @@ public class WPLayouter
PageView
pv
=
(
PageView
)
ViewFactory
.
createView
(
root
.
getControl
(),
section
,
null
,
WPViewConstant
.
PAGE_VIEW
);
root
.
appendChlidView
(
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 {
fun
openDoc
(
activity
:
Activity
,
docUrl
:
String
?,
docSourceType
:
Int
,
engine
:
DocEngine
=
this
.
engine
)
{
mActivity
=
activity
openDoc
(
activity
,
docUrl
,
docSourceType
,
-
1
,
false
,
engine
)
openDoc
(
activity
,
docUrl
,
docSourceType
,
-
1
,
false
)
}
@SuppressLint
(
"ObsoleteSdkInt"
)
...
...
@@ -126,7 +125,6 @@ class DocView : FrameLayout {
docSourceType
:
Int
,
fileType
:
Int
,
viewPdfInPage
:
Boolean
=
false
,
engine
:
DocEngine
=
this
.
engine
)
{
var
fileType
=
fileType
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