Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
P
PDF Viewer Scanner White
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
wanglei
PDF Viewer Scanner White
Commits
7096a17f
Commit
7096a17f
authored
Sep 25, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
c7a1e38b
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
1575 additions
and
1399 deletions
+1575
-1399
build.gradle.kts
app/build.gradle.kts
+1
-0
ExcelActivity.kt
.../pdfviewerscannerwhite/ui/document/excel/ExcelActivity.kt
+97
-8
PptActivity.kt
...base/pdfviewerscannerwhite/ui/document/ppt/PptActivity.kt
+75
-3
MainActivity.kt
...va/com/base/pdfviewerscannerwhite/ui/main/MainActivity.kt
+1
-1
DialogView.kt
...java/com/base/pdfviewerscannerwhite/ui/view/DialogView.kt
+21
-0
activity_excel.xml
app/src/main/res/layout/activity_excel.xml
+109
-6
activity_main.xml
app/src/main/res/layout/activity_main.xml
+0
-1
activity_ppt.xml
app/src/main/res/layout/activity_ppt.xml
+126
-3
dialog_document_more.xml
app/src/main/res/layout/dialog_document_more.xml
+173
-0
IOffice.java
library/src/main/java/com/cherry/lib/doc/office/IOffice.java
+6
-2
TouchEventListener.java
...a/com/cherry/lib/doc/office/macro/TouchEventListener.java
+0
-1
PGControl.java
.../java/com/cherry/lib/doc/office/pg/control/PGControl.java
+215
-301
PGEventManage.java
...a/com/cherry/lib/doc/office/pg/control/PGEventManage.java
+0
-2
PGPrintMode.java
...ava/com/cherry/lib/doc/office/pg/control/PGPrintMode.java
+258
-347
AbstractControl.kt
.../java/com/cherry/lib/doc/office/system/AbstractControl.kt
+1
-1
IMainFrame.java
...ain/java/com/cherry/lib/doc/office/system/IMainFrame.java
+110
-110
MainControl.java
...in/java/com/cherry/lib/doc/office/system/MainControl.java
+2
-1
AEventManage.java
.../com/cherry/lib/doc/office/system/beans/AEventManage.java
+115
-172
PrintWord.java
.../java/com/cherry/lib/doc/office/wp/control/PrintWord.java
+234
-337
Word.java
.../main/java/com/cherry/lib/doc/office/wp/control/Word.java
+2
-0
DocView.kt
library/src/main/java/com/cherry/lib/doc/widget/DocView.kt
+29
-59
doc_view.xml
library/src/main/res/layout/doc_view.xml
+0
-44
No files found.
app/build.gradle.kts
View file @
7096a17f
...
...
@@ -60,6 +60,7 @@ dependencies {
implementation
(
"io.github.cymchad:BaseRecyclerViewAdapterHelper4:4.1.4"
)
implementation
(
"com.h6ah4i.android.widget.verticalseekbar:verticalseekbar:1.0.0"
)
implementation
(
"com.github.angcyo.DslTablayout:TabLayout:3.5.5"
)
implementation
(
"com.github.angcyo.DslTablayout:ViewPager2Delegate:3.5.5"
)
//mlkit
implementation
(
"com.google.android.gms:play-services-mlkit-document-scanner:16.0.0-beta1"
)
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/ui/document/excel/ExcelActivity.kt
View file @
7096a17f
package
com.base.pdfviewerscannerwhite.ui.document.excel
import
android.annotation.SuppressLint
import
android.app.Activity
import
android.content.Intent
import
android.content.pm.ActivityInfo
import
android.view.View
import
android.view.animation.Animation
import
android.view.animation.TranslateAnimation
import
androidx.activity.addCallback
import
com.base.pdfviewerscannerwhite.bean.DocumentBean
import
com.base.pdfviewerscannerwhite.databinding.ActivityExcelBinding
import
com.base.pdfviewerscannerwhite.helper.BaseActivity
import
com.base.pdfviewerscannerwhite.ui.view.DialogView.showDocumentMore
import
com.base.pdfviewerscannerwhite.utils.KeyBoardUtils.hideKeyboard
import
com.base.pdfviewerscannerwhite.utils.LogEx
import
com.cherry.lib.doc.bean.DocEngine
import
com.cherry.lib.doc.util.Constant
import
java.io.File
class
ExcelActivity
:
BaseActivity
<
ActivityExcelBinding
>()
{
...
...
@@ -20,13 +30,13 @@ class ExcelActivity : BaseActivity<ActivityExcelBinding>() {
fun
launchDocViewer
(
activity
:
Activity
,
docSourceType
:
Int
,
path
:
String
?,
path
OrUri
:
String
?,
fileType
:
Int
?
=
null
,
engine
:
Int
?
=
null
)
{
val
intent
=
Intent
(
activity
,
ExcelActivity
::
class
.
java
)
intent
.
putExtra
(
Constant
.
INTENT_SOURCE_KEY
,
docSourceType
)
intent
.
putExtra
(
Constant
.
INTENT_DATA_KEY
,
path
)
intent
.
putExtra
(
Constant
.
INTENT_DATA_KEY
,
path
OrUri
)
intent
.
putExtra
(
Constant
.
INTENT_TYPE_KEY
,
fileType
)
intent
.
putExtra
(
Constant
.
INTENT_ENGINE_KEY
,
engine
)
activity
.
startActivity
(
intent
)
...
...
@@ -34,21 +44,100 @@ class ExcelActivity : BaseActivity<ActivityExcelBinding>() {
}
override
fun
initView
()
{
initData
(
intent
)
initSpData
(
intent
)
val
file
=
File
(
pathOrUri
?:
""
)
if
(
file
.
exists
())
{
binding
.
tvName
.
text
=
file
.
name
}
}
@SuppressLint
(
"ClickableViewAccessibility"
)
override
fun
initListener
()
{
super
.
initListener
()
onBackPressedDispatcher
.
addCallback
{
finishToMain
()
}
binding
.
flFanhui
.
setOnClickListener
{
onBackPressedDispatcher
.
onBackPressed
()
}
binding
.
ivXuanzhuan
.
setOnClickListener
{
switchOrientation
()
}
binding
.
ivMore
.
setOnClickListener
{
showDocumentMore
(
DocumentBean
.
TYPE_EXCEL
)
}
binding
.
mDocView
.
singleTapAction
=
{
LogEx
.
logDebug
(
TAG
,
"actionDownCallBack"
)
if
(
isShowTopLayout
)
{
LogEx
.
logDebug
(
TAG
,
"hide"
)
hideTopLayout
()
}
else
{
showTopLayout
()
LogEx
.
logDebug
(
TAG
,
"show"
)
}
}
}
private
fun
switchOrientation
()
{
requestedOrientation
=
if
(
requestedOrientation
==
ActivityInfo
.
SCREEN_ORIENTATION_PORTRAIT
)
{
ActivityInfo
.
SCREEN_ORIENTATION_LANDSCAPE
}
else
{
ActivityInfo
.
SCREEN_ORIENTATION_PORTRAIT
}
}
private
var
isShowTopLayout
=
true
private
fun
showTopLayout
()
{
if
(!
isShowTopLayout
)
{
isShowTopLayout
=
true
val
topAnim
:
Animation
=
TranslateAnimation
(
0f
,
0f
,
-
binding
.
vAnimatorTop
.
height
.
toFloat
(),
0f
)
topAnim
.
setDuration
(
200
)
topAnim
.
setAnimationListener
(
object
:
Animation
.
AnimationListener
{
override
fun
onAnimationStart
(
animation
:
Animation
)
{
binding
.
vAnimatorTop
.
visibility
=
View
.
VISIBLE
}
override
fun
onAnimationRepeat
(
animation
:
Animation
)
{}
override
fun
onAnimationEnd
(
animation
:
Animation
)
{
}
})
binding
.
vAnimatorTop
.
startAnimation
(
topAnim
)
}
}
private
fun
hideTopLayout
()
{
if
(
isShowTopLayout
)
{
isShowTopLayout
=
false
hideKeyboard
(
binding
.
editSearch
)
val
topAnim
:
Animation
=
TranslateAnimation
(
0f
,
0f
,
0f
,
-
binding
.
vAnimatorTop
.
height
.
toFloat
())
topAnim
.
setDuration
(
200
)
topAnim
.
setAnimationListener
(
object
:
Animation
.
AnimationListener
{
override
fun
onAnimationStart
(
animation
:
Animation
)
{}
override
fun
onAnimationRepeat
(
animation
:
Animation
)
{}
override
fun
onAnimationEnd
(
animation
:
Animation
)
{
binding
.
vAnimatorTop
.
visibility
=
View
.
GONE
}
})
binding
.
vAnimatorTop
.
startAnimation
(
topAnim
)
}
}
private
var
docSourceType
=
0
private
var
fileType
=
-
1
private
var
engine
:
Int
=
DocEngine
.
INTERNAL
.
value
private
var
docUrl
:
String
?
=
null
// 文件地址
fun
init
Data
(
intent
:
Intent
?)
{
docUrl
=
intent
?.
getStringExtra
(
Constant
.
INTENT_DATA_KEY
)
private
var
pathOrUri
:
String
?
=
null
// 文件地址
private
fun
initSp
Data
(
intent
:
Intent
?)
{
pathOrUri
=
intent
?.
getStringExtra
(
Constant
.
INTENT_DATA_KEY
)
docSourceType
=
intent
?.
getIntExtra
(
Constant
.
INTENT_SOURCE_KEY
,
0
)
?:
0
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
,
docUrl
,
docSourceType
,
fileType
,
false
,
DocEngine
.
values
().
first
{
it
.
value
==
engine
})
LogEx
.
logDebug
(
TAG
,
"initData-
docUrl = $docUrl
"
)
binding
.
mDocView
.
openDoc
(
this
,
pathOrUri
,
docSourceType
,
fileType
,
false
,
DocEngine
.
values
().
first
{
it
.
value
==
engine
})
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 @
7096a17f
package
com.base.pdfviewerscannerwhite.ui.document.ppt
import
android.annotation.SuppressLint
import
android.app.Activity
import
android.content.Intent
import
android.view.View
import
android.view.animation.Animation
import
android.view.animation.TranslateAnimation
import
androidx.activity.addCallback
import
androidx.core.view.isVisible
import
com.base.pdfviewerscannerwhite.databinding.ActivityPptBinding
import
com.base.pdfviewerscannerwhite.helper.BaseActivity
import
com.base.pdfviewerscannerwhite.utils.KeyBoardUtils.hideKeyboard
import
com.base.pdfviewerscannerwhite.utils.LogEx
import
com.cherry.lib.doc.bean.DocEngine
import
com.cherry.lib.doc.util.Constant
...
...
@@ -31,18 +38,45 @@ class PptActivity : BaseActivity<ActivityPptBinding>() {
intent
.
putExtra
(
Constant
.
INTENT_ENGINE_KEY
,
engine
)
activity
.
startActivity
(
intent
)
}
}
@SuppressLint
(
"SetTextI18n"
)
override
fun
initView
()
{
initData
(
intent
)
binding
.
mDocView
initSpData
(
intent
)
binding
.
mDocView
.
getPageNumberAction
=
{
current
,
total
->
if
(!
binding
.
tvPageCount
.
isVisible
)
{
binding
.
tvPageCount
.
isVisible
=
true
}
binding
.
tvPageCount
.
text
=
"$current/$total"
}
binding
.
mDocView
.
singleTapAction
=
{
LogEx
.
logDebug
(
TAG
,
"actionDownCallBack"
)
if
(
isShowTopLayout
)
{
LogEx
.
logDebug
(
TAG
,
"hide"
)
hideTopLayout
()
}
else
{
showTopLayout
()
LogEx
.
logDebug
(
TAG
,
"show"
)
}
}
}
override
fun
initListener
()
{
super
.
initListener
()
onBackPressedDispatcher
.
addCallback
{
finishToMain
()
}
binding
.
flFanhui
.
setOnClickListener
{
onBackPressedDispatcher
.
onBackPressed
()
}
}
private
var
docSourceType
=
0
private
var
fileType
=
-
1
private
var
engine
:
Int
=
DocEngine
.
INTERNAL
.
value
private
var
docUrl
:
String
?
=
null
// 文件地址
fun
init
Data
(
intent
:
Intent
?)
{
private
fun
initSp
Data
(
intent
:
Intent
?)
{
docUrl
=
intent
?.
getStringExtra
(
Constant
.
INTENT_DATA_KEY
)
docSourceType
=
intent
?.
getIntExtra
(
Constant
.
INTENT_SOURCE_KEY
,
0
)
?:
0
fileType
=
intent
?.
getIntExtra
(
Constant
.
INTENT_TYPE_KEY
,
-
1
)
?:
-
1
...
...
@@ -54,4 +88,42 @@ class PptActivity : BaseActivity<ActivityPptBinding>() {
LogEx
.
logDebug
(
TAG
,
"initData-fileType = $fileType"
)
LogEx
.
logDebug
(
TAG
,
"initData-engine = $engine"
)
}
private
fun
showTopLayout
()
{
if
(!
isShowTopLayout
)
{
isShowTopLayout
=
true
val
topAnim
:
Animation
=
TranslateAnimation
(
0f
,
0f
,
-
binding
.
vAnimatorTop
.
height
.
toFloat
(),
0f
)
topAnim
.
setDuration
(
200
)
topAnim
.
setAnimationListener
(
object
:
Animation
.
AnimationListener
{
override
fun
onAnimationStart
(
animation
:
Animation
)
{
binding
.
vAnimatorTop
.
visibility
=
View
.
VISIBLE
}
override
fun
onAnimationRepeat
(
animation
:
Animation
)
{}
override
fun
onAnimationEnd
(
animation
:
Animation
)
{
}
})
binding
.
vAnimatorTop
.
startAnimation
(
topAnim
)
}
}
private
var
isShowTopLayout
=
true
private
fun
hideTopLayout
()
{
if
(
isShowTopLayout
)
{
isShowTopLayout
=
false
hideKeyboard
(
binding
.
editSearch
)
val
topAnim
:
Animation
=
TranslateAnimation
(
0f
,
0f
,
0f
,
-
binding
.
vAnimatorTop
.
height
.
toFloat
())
topAnim
.
setDuration
(
200
)
topAnim
.
setAnimationListener
(
object
:
Animation
.
AnimationListener
{
override
fun
onAnimationStart
(
animation
:
Animation
)
{}
override
fun
onAnimationRepeat
(
animation
:
Animation
)
{}
override
fun
onAnimationEnd
(
animation
:
Animation
)
{
binding
.
vAnimatorTop
.
visibility
=
View
.
GONE
}
})
binding
.
vAnimatorTop
.
startAnimation
(
topAnim
)
}
}
}
\ No newline at end of file
app/src/main/java/com/base/pdfviewerscannerwhite/ui/main/MainActivity.kt
View file @
7096a17f
...
...
@@ -61,7 +61,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), MainView {
binding
.
viewPager2
.
offscreenPageLimit
=
4
binding
.
viewPager2
.
run
{
isUserInputEnabled
=
fals
e
isUserInputEnabled
=
tru
e
adapter
=
object
:
FragmentStateAdapter
(
this
@MainActivity
)
{
override
fun
getItemCount
():
Int
{
return
fragments
.
size
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/ui/view/DialogView.kt
View file @
7096a17f
...
...
@@ -12,9 +12,11 @@ import androidx.core.content.FileProvider
import
androidx.core.widget.addTextChangedListener
import
com.base.pdfviewerscannerwhite.R
import
com.base.pdfviewerscannerwhite.bean.DocumentBean
import
com.base.pdfviewerscannerwhite.bean.DocumentBean.Companion.TYPE_EXCEL
import
com.base.pdfviewerscannerwhite.databinding.DialogCommonTipBinding
import
com.base.pdfviewerscannerwhite.databinding.DialogDeleteBinding
import
com.base.pdfviewerscannerwhite.databinding.DialogDocumentDetailBinding
import
com.base.pdfviewerscannerwhite.databinding.DialogDocumentMoreBinding
import
com.base.pdfviewerscannerwhite.databinding.DialogDocumentRenameBinding
import
com.base.pdfviewerscannerwhite.databinding.DialogPageNumberBinding
import
com.base.pdfviewerscannerwhite.databinding.DialogPdfDetailBinding
...
...
@@ -25,6 +27,7 @@ import com.base.pdfviewerscannerwhite.ui.adapter.DocumentAdapter
import
com.base.pdfviewerscannerwhite.ui.document.pdf.PdfBoxUtils
import
com.base.pdfviewerscannerwhite.ui.main.DocumentView
import
com.base.pdfviewerscannerwhite.ui.document.pdf.PdfView
import
com.base.pdfviewerscannerwhite.ui.view.DialogView.showPdfMoreDialog
import
com.base.pdfviewerscannerwhite.utils.ActivityLauncher
import
com.base.pdfviewerscannerwhite.utils.IntentShareUtils.sharePdfIntent
import
com.base.pdfviewerscannerwhite.utils.IntentShareUtils.sharePdfPrintIntent
...
...
@@ -228,6 +231,24 @@ object DialogView {
}
fun
Activity
.
showDocumentMore
(
type
:
String
)
{
val
dialog
=
BottomSheetDialog
(
this
,
R
.
style
.
BottomSheetDialog
)
val
binding
=
DialogDocumentMoreBinding
.
inflate
(
LayoutInflater
.
from
(
this
))
dialog
.
setContentView
(
binding
.
root
)
dialog
.
setCanceledOnTouchOutside
(
false
)
dialog
.
show
()
val
parentView
=
binding
.
root
.
parent
as
View
val
behavior
=
BottomSheetBehavior
.
from
(
parentView
)
//展开
behavior
.
state
=
BottomSheetBehavior
.
STATE_EXPANDED
if
(
type
==
TYPE_EXCEL
)
{
binding
.
llJump
.
visibility
=
View
.
GONE
}
}
@SuppressLint
(
"SetTextI18n"
)
fun
Context
.
showPdfPwdDialog
(
...
...
app/src/main/res/layout/activity_excel.xml
View file @
7096a17f
...
...
@@ -7,16 +7,119 @@
android:layout_height=
"match_parent"
tools:context=
".ui.document.excel.ExcelActivity"
>
<ViewAnimator
android:id=
"@+id/v_animator_top"
android:layout_width=
"match_parent"
android:layout_height=
"60dp"
android:background=
"@color/white"
app:layout_constraintTop_toTopOf=
"parent"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:id=
"@+id/cl_top"
android:layout_width=
"match_parent"
android:layout_height=
"60dp"
app:layout_constraintTop_toTopOf=
"parent"
>
<FrameLayout
android:id=
"@+id/fl_fanhui"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@id/tv_name"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:padding=
"15dp"
android:src=
"@mipmap/fanhui_b"
tools:ignore=
"ContentDescription"
/>
</FrameLayout>
<TextView
android:id=
"@+id/tv_name"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:ellipsize=
"end"
android:singleLine=
"true"
android:textColor=
"@color/black"
android:textSize=
"19sp"
android:textStyle=
"bold"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@+id/iv_xuanzhuan"
app:layout_constraintStart_toEndOf=
"@id/fl_fanhui"
app:layout_constraintTop_toTopOf=
"parent"
tools:ignore=
"HardcodedText"
tools:text=
"DEMO.xlsx"
/>
<ImageView
android:id=
"@+id/iv_xuanzhuan"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"16dp"
android:src=
"@mipmap/hengping"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@id/iv_search"
app:layout_constraintTop_toTopOf=
"parent"
tools:ignore=
"ContentDescription"
/>
<ImageView
android:id=
"@+id/iv_search"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"16dp"
android:src=
"@mipmap/h_sousuo"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@id/iv_more"
app:layout_constraintTop_toTopOf=
"parent"
tools:ignore=
"ContentDescription"
/>
<ImageView
android:id=
"@+id/iv_more"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"16dp"
android:src=
"@mipmap/x_genduo"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
tools:ignore=
"ContentDescription"
/>
<EditText
android:id=
"@+id/edit_search"
android:layout_width=
"0dp"
android:layout_height=
"40dp"
android:layout_marginStart=
"5dp"
android:layout_marginEnd=
"20dp"
android:background=
"@drawable/bg_f8f9fe_10"
android:hint=
"input..."
android:paddingHorizontal=
"18dp"
android:singleLine=
"true"
android:textColor=
"@color/black"
android:textColorHint=
"#B8B9BD"
android:visibility=
"gone"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@id/iv_search"
app:layout_constraintStart_toEndOf=
"@id/fl_fanhui"
app:layout_constraintTop_toTopOf=
"parent"
tools:ignore=
"Autofill,HardcodedText,TextFields"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</ViewAnimator>
<com.cherry.lib.doc.widget.DocView
android:id=
"@+id/mDocView"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
app:dv_engine=
"internal"
android:layout_height=
"0dp"
app:dv_moving_orientation=
"vertical"
app:dv_page_pb_color=
"@color/yellow"
app:dv_page_pb_height=
"2dp"
app:dv_quality=
"normal"
app:dv_show_page_num=
"false"
/>
app:dv_show_page_num=
"false"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/v_animator_top"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/activity_main.xml
View file @
7096a17f
...
...
@@ -166,7 +166,6 @@
</com.angcyo.tablayout.DslTabLayout>
</FrameLayout>
<androidx.viewpager2.widget.ViewPager2
android:id=
"@+id/viewPager2"
android:layout_width=
"match_parent"
...
...
app/src/main/res/layout/activity_ppt.xml
View file @
7096a17f
...
...
@@ -7,15 +7,138 @@
android:layout_height=
"match_parent"
tools:context=
".ui.document.ppt.PptActivity"
>
<ViewAnimator
android:id=
"@+id/v_animator_top"
android:layout_width=
"match_parent"
android:layout_height=
"60dp"
android:background=
"@color/white"
app:layout_constraintTop_toTopOf=
"parent"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:id=
"@+id/cl_top"
android:layout_width=
"match_parent"
android:layout_height=
"60dp"
app:layout_constraintTop_toTopOf=
"parent"
>
<FrameLayout
android:id=
"@+id/fl_fanhui"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@id/tv_name"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:padding=
"15dp"
android:src=
"@mipmap/fanhui_b"
tools:ignore=
"ContentDescription"
/>
</FrameLayout>
<TextView
android:id=
"@+id/tv_name"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:ellipsize=
"end"
android:singleLine=
"true"
android:textColor=
"@color/black"
android:textSize=
"19sp"
android:textStyle=
"bold"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@+id/iv_xuanzhuan"
app:layout_constraintStart_toEndOf=
"@id/fl_fanhui"
app:layout_constraintTop_toTopOf=
"parent"
tools:ignore=
"HardcodedText"
tools:text=
"DEMO.ppt"
/>
<ImageView
android:id=
"@+id/iv_xuanzhuan"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"16dp"
android:src=
"@mipmap/hengping"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@id/iv_search"
app:layout_constraintTop_toTopOf=
"parent"
tools:ignore=
"ContentDescription"
/>
<ImageView
android:id=
"@+id/iv_search"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"16dp"
android:src=
"@mipmap/h_sousuo"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@id/iv_more"
app:layout_constraintTop_toTopOf=
"parent"
tools:ignore=
"ContentDescription"
/>
<ImageView
android:id=
"@+id/iv_more"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"16dp"
android:src=
"@mipmap/x_genduo"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
tools:ignore=
"ContentDescription"
/>
<EditText
android:id=
"@+id/edit_search"
android:layout_width=
"0dp"
android:layout_height=
"40dp"
android:layout_marginStart=
"5dp"
android:layout_marginEnd=
"20dp"
android:background=
"@drawable/bg_f8f9fe_10"
android:hint=
"input..."
android:paddingHorizontal=
"18dp"
android:singleLine=
"true"
android:textColor=
"@color/black"
android:textColorHint=
"#B8B9BD"
android:visibility=
"gone"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@id/iv_search"
app:layout_constraintStart_toEndOf=
"@id/fl_fanhui"
app:layout_constraintTop_toTopOf=
"parent"
tools:ignore=
"Autofill,HardcodedText,TextFields"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</ViewAnimator>
<com.cherry.lib.doc.widget.DocView
android:id=
"@+id/mDocView"
android:layout_width=
"match_parent"
android:layout_height=
"
match_parent
"
android:layout_height=
"
0dp
"
app:dv_engine=
"internal"
app:dv_moving_orientation=
"vertical"
app:dv_page_pb_color=
"@color/yellow"
app:dv_page_pb_height=
"2dp"
app:dv_quality=
"normal"
app:dv_show_page_num=
"false"
/>
app:dv_show_page_num=
"true"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/v_animator_top"
/>
<TextView
android:visibility=
"gone"
android:id=
"@+id/tv_pageCount"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"28dp"
android:layout_marginTop=
"28dp"
android:background=
"@drawable/bg_54585b_5"
android:includeFontPadding=
"false"
android:paddingHorizontal=
"2dp"
android:paddingVertical=
"2dp"
android:textColor=
"@color/white"
android:textSize=
"12sp"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/v_animator_top"
tools:text=
"1/3"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/dialog_document_more.xml
0 → 100644
View file @
7096a17f
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"@drawable/bg_f1f1f1_tlr25"
android:orientation=
"vertical"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:id=
"@+id/cl"
android:layout_width=
"match_parent"
android:layout_height=
"65dp"
app:layout_constraintTop_toTopOf=
"parent"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"15dp"
android:text=
"More"
android:textColor=
"#333333"
android:textStyle=
"bold"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
tools:ignore=
"HardcodedText"
/>
<ImageView
android:id=
"@+id/iv_bookmark"
android:layout_width=
"24dp"
android:layout_height=
"32dp"
android:layout_marginEnd=
"27dp"
android:src=
"@mipmap/h_soucang_n"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
tools:ignore=
"ContentDescription"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"@color/white"
android:orientation=
"vertical"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/cl"
>
<LinearLayout
android:id=
"@+id/ll_jump"
android:layout_width=
"match_parent"
android:layout_height=
"60dp"
android:background=
"?android:selectableItemBackground"
android:orientation=
"horizontal"
>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_marginStart=
"13dp"
android:src=
"@mipmap/jump"
tools:ignore=
"ContentDescription"
/>
<TextView
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_marginHorizontal=
"13dp"
android:layout_weight=
"1"
android:ellipsize=
"end"
android:includeFontPadding=
"false"
android:singleLine=
"true"
android:text=
"Jump to the specified page"
android:textColor=
"#333333"
android:textSize=
"16sp"
tools:ignore=
"HardcodedText"
/>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_marginEnd=
"20dp"
android:src=
"@mipmap/jianotou"
tools:ignore=
"ContentDescription"
/>
</LinearLayout>
<LinearLayout
android:id=
"@+id/ll_detail"
android:layout_width=
"match_parent"
android:layout_height=
"60dp"
android:background=
"?android:selectableItemBackground"
android:orientation=
"horizontal"
>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_marginStart=
"13dp"
android:src=
"@mipmap/particulars"
tools:ignore=
"ContentDescription"
/>
<TextView
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_marginHorizontal=
"13dp"
android:layout_weight=
"1"
android:ellipsize=
"end"
android:includeFontPadding=
"false"
android:singleLine=
"true"
android:text=
"Detail"
android:textColor=
"#333333"
android:textSize=
"16sp"
tools:ignore=
"HardcodedText"
/>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_marginEnd=
"20dp"
android:src=
"@mipmap/jianotou"
tools:ignore=
"ContentDescription"
/>
</LinearLayout>
<LinearLayout
android:id=
"@+id/ll_share"
android:layout_width=
"match_parent"
android:layout_height=
"60dp"
android:layout_marginBottom=
"20dp"
android:background=
"?android:selectableItemBackground"
android:orientation=
"horizontal"
>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_marginStart=
"13dp"
android:src=
"@mipmap/share"
tools:ignore=
"ContentDescription"
/>
<TextView
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_marginHorizontal=
"13dp"
android:layout_weight=
"1"
android:ellipsize=
"end"
android:includeFontPadding=
"false"
android:singleLine=
"true"
android:text=
"Share"
android:textColor=
"#333333"
android:textSize=
"16sp"
tools:ignore=
"HardcodedText"
/>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_marginEnd=
"20dp"
android:src=
"@mipmap/jianotou"
tools:ignore=
"ContentDescription"
/>
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
library/src/main/java/com/cherry/lib/doc/office/IOffice.java
View file @
7096a17f
...
...
@@ -3,8 +3,10 @@ package com.cherry.lib.doc.office;
import
android.app.Activity
;
import
android.graphics.Bitmap
;
import
android.graphics.Color
;
import
android.util.Log
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
com.blankj.utilcode.util.AppUtils
;
import
com.cherry.lib.doc.office.common.IOfficeToPicture
;
import
com.cherry.lib.doc.office.constant.EventConstant
;
...
...
@@ -12,6 +14,7 @@ import com.cherry.lib.doc.office.constant.wp.WPViewConstant;
import
com.cherry.lib.doc.office.res.ResKit
;
import
com.cherry.lib.doc.office.system.IMainFrame
;
import
com.cherry.lib.doc.office.system.MainControl
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
...
...
@@ -22,6 +25,7 @@ import java.util.List;
*/
public
abstract
class
IOffice
implements
IMainFrame
{
private
String
TAG
=
"IOffice"
;
private
MainControl
control
;
private
boolean
writeLog
=
true
;
//view background
...
...
@@ -148,6 +152,7 @@ public abstract class IOffice implements IMainFrame {
* @return True if the listener has consumed the event, false otherwise.
*/
public
boolean
doActionEvent
(
int
actionID
,
Object
obj
)
{
Log
.
e
(
TAG
,
"doActionEvent actionID"
+
actionID
);
try
{
switch
(
actionID
)
{
case
EventConstant
.
SYS_UPDATE_TOOLSBAR_BUTTON_STATUS
:
//update toolsbar state
...
...
@@ -192,8 +197,7 @@ public abstract class IOffice implements IMainFrame {
return
0
;
}
public
boolean
onEventMethod
(
View
v
,
MotionEvent
e1
,
MotionEvent
e2
,
float
xValue
,
float
yValue
,
byte
eventMethodType
)
{
public
boolean
onEventMethod
(
View
v
,
MotionEvent
e1
,
MotionEvent
e2
,
float
xValue
,
float
yValue
,
byte
eventMethodType
)
{
return
false
;
}
...
...
library/src/main/java/com/cherry/lib/doc/office/macro/TouchEventListener.java
View file @
7096a17f
...
...
@@ -39,7 +39,6 @@ public interface TouchEventListener
* @param e2 MotionEvent instance
* @param velocityX x axis velocity
* @param velocityY y axis velocity
* @param eventNethodType event method
* @see TouchEventListener#EVENT_CLICK
* @see TouchEventListener#EVENT_DOUBLE_TAP
* @see TouchEventListener#EVENT_DOUBLE_TAP_EVENT
...
...
library/src/main/java/com/cherry/lib/doc/office/pg/control/PGControl.java
View file @
7096a17f
/*
* 文件名称: PGControl.java
*
*
* 编译器: android2.2
* 时间: 下午3:39:55
*/
...
...
@@ -39,6 +39,8 @@ import android.view.View;
import
org.jetbrains.annotations.Nullable
;
/**
* ppt 控制器
* <p>
* 文件注释
* <p>
* <p>
...
...
@@ -50,332 +52,275 @@ import org.jetbrains.annotations.Nullable;
* <p>
* 负责人: ljj8494
* <p>
* 负责小组:
* 负责小组:
* <p>
* <p>
*/
public
class
PGControl
extends
AbstractControl
{
public
class
PGControl
extends
AbstractControl
{
/**
*
*
*/
public
PGControl
(
IControl
mainControl
,
PGModel
pgModel
,
String
filePath
)
{
public
PGControl
(
IControl
mainControl
,
PGModel
pgModel
,
String
filePath
)
{
this
.
mainControl
=
mainControl
;
pgView
=
new
Presentation
(
getMainFrame
().
getActivity
(),
pgModel
,
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
*
* @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
.
SYS_SET_PROGRESS_BAR_ID
:
if
(
pgView
.
getParent
()
!=
null
)
{
pgView
.
post
(
new
Runnable
()
{
if
(
pgView
.
getParent
()
!=
null
)
{
pgView
.
post
(
new
Runnable
()
{
/**
*
*/
public
void
run
()
{
if
(!
isDispose
)
{
//getActivity().setProgressBarIndeterminateVisibility((Boolean)obj);
mainControl
.
getMainFrame
().
showProgressBar
((
Boolean
)
obj
);
public
void
run
()
{
if
(!
isDispose
)
{
//getActivity().setProgressBarIndeterminateVisibility((Boolean)obj);
mainControl
.
getMainFrame
().
showProgressBar
((
Boolean
)
obj
);
}
}
});
}
}
break
;
case
EventConstant
.
SYS_VECTORGRAPH_PROGRESS
:
if
(
pgView
.
getParent
()
!=
null
)
{
pgView
.
post
(
new
Runnable
()
{
if
(
pgView
.
getParent
()
!=
null
)
{
pgView
.
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
()
{
/**
*
*/
public
void
run
()
{
if
(!
isDispose
)
{
mainControl
.
getMainFrame
().
updateViewImages
((
List
<
Integer
>)
obj
);
}
}
}.
start
();
}
break
;
}
else
{
new
Thread
()
{
/**
*
*/
public
void
run
()
{
if
(!
isDispose
)
{
mainControl
.
getMainFrame
().
updateViewImages
((
List
<
Integer
>)
obj
);
}
}
}.
start
();
}
break
;
case
EventConstant
.
SYS_INIT_ID
:
pgView
.
init
();
break
;
case
EventConstant
.
TEST_REPAINT_ID
:
case
EventConstant
.
PG_REPAINT_ID
:
pgView
.
postInvalidate
();
pgView
.
postInvalidate
();
break
;
case
EventConstant
.
SYS_UPDATE_TOOLSBAR_BUTTON_STATUS
:
// 更新toolsbar button状态
pgView
.
post
(
new
Runnable
()
{
@
Override
public
void
run
()
{
if
(!
isDispose
)
{
if
(
getMainFrame
()
!=
null
)
{
pgView
.
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(!
isDispose
)
{
if
(
getMainFrame
()
!=
null
)
{
getMainFrame
().
updateToolsbarStatus
();
}
}
}
});
break
;
case
EventConstant
.
APP_PAGE_UP_ID
:
if
(
pgView
.
isSlideShow
())
{
if
(
pgView
.
isSlideShow
())
{
pgView
.
slideShow
(
ISlideShow
.
SlideShow_PreviousSlide
);
}
else
{
if
(
pgView
.
getCurrentIndex
()
>
0
)
{
}
else
{
if
(
pgView
.
getCurrentIndex
()
>
0
)
{
pgView
.
showSlide
(
pgView
.
getCurrentIndex
()
-
1
,
false
);
}
}
}
break
;
case
EventConstant
.
APP_PAGE_DOWN_ID
:
if
(
pgView
.
isSlideShow
())
{
if
(
pgView
.
isSlideShow
())
{
pgView
.
slideShow
(
ISlideShow
.
SlideShow_NextSlide
);
}
else
{
if
(
pgView
.
getCurrentIndex
()
<
pgView
.
getRealSlideCount
()
-
1
)
{
}
else
{
if
(
pgView
.
getCurrentIndex
()
<
pgView
.
getRealSlideCount
()
-
1
)
{
pgView
.
showSlide
(
pgView
.
getCurrentIndex
()
+
1
,
false
);
}
}
break
;
case
EventConstant
.
PG_SHOW_SLIDE_ID
:
if
(!
pgView
.
isSlideShow
())
{
showSlide
((
Integer
)
obj
);
}
if
(!
pgView
.
isSlideShow
())
{
showSlide
((
Integer
)
obj
);
}
break
;
case
EventConstant
.
APP_ZOOM_ID
:
if
(!
pgView
.
isSlideShow
())
{
int
[]
params
=
(
int
[])
obj
;
pgView
.
setZoom
(
params
[
0
]
/
(
float
)
MainConstant
.
STANDARD_RATE
,
params
[
1
],
params
[
2
]);
pgView
.
post
(
new
Runnable
()
{
@
Override
public
void
run
()
{
if
(!
isDispose
)
{
if
(!
pgView
.
isSlideShow
())
{
int
[]
params
=
(
int
[])
obj
;
pgView
.
setZoom
(
params
[
0
]
/
(
float
)
MainConstant
.
STANDARD_RATE
,
params
[
1
],
params
[
2
]);
pgView
.
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(!
isDispose
)
{
getMainFrame
().
changeZoom
();
}
}
});
}
});
}
break
;
case
EventConstant
.
PG_NOTE_ID
:
//show notes
String
text
=
pgView
.
getCurrentSlide
().
getNotes
().
getNotes
();
Vector
<
Object
>
vector
=
new
Vector
<
Object
>();
vector
.
add
(
text
);
new
com
.
cherry
.
lib
.
doc
.
office
.
pg
.
dialog
.
NotesDialog
(
this
,
getMainFrame
().
getActivity
(),
null
,
vector
,
DialogConstant
.
SHOW_PG_NOTE_ID
).
show
();
DialogConstant
.
SHOW_PG_NOTE_ID
).
show
();
break
;
case
EventConstant
.
FILE_COPY_ID
:
//copy
ClipboardManager
clip
=
(
ClipboardManager
)
getMainFrame
().
getActivity
().
getSystemService
(
Context
.
CLIPBOARD_SERVICE
);
ClipboardManager
clip
=
(
ClipboardManager
)
getMainFrame
().
getActivity
().
getSystemService
(
Context
.
CLIPBOARD_SERVICE
);
clip
.
setText
(
pgView
.
getSelectedText
());
break
;
case
EventConstant
.
APP_HYPERLINK
:
//hyperlink
String
addr
=
((
Hyperlink
)
obj
).
getAddress
();
if
(
addr
!=
null
)
{
try
{
Intent
hyIntent
=
new
Intent
(
Intent
.
ACTION_VIEW
,
Uri
.
parse
(
addr
));
String
addr
=
((
Hyperlink
)
obj
).
getAddress
();
if
(
addr
!=
null
)
{
try
{
Intent
hyIntent
=
new
Intent
(
Intent
.
ACTION_VIEW
,
Uri
.
parse
(
addr
));
getMainFrame
().
getActivity
().
startActivity
(
hyIntent
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
}
}
}
break
;
case
EventConstant
.
SYS_AUTO_TEST_FINISH_ID
:
// 布局完成
if
(
isAutoTest
())
{
if
(
isAutoTest
())
{
getMainFrame
().
getActivity
().
onBackPressed
();
}
break
;
case
EventConstant
.
APP_GENERATED_PICTURE_ID
:
pgView
.
post
(
new
Runnable
()
{
@
Override
public
void
run
()
{
if
(!
isDispose
)
{
pgView
.
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(!
isDispose
)
{
pgView
.
createPicture
();
}
}
});
break
;
case
EventConstant
.
PG_SLIDESHOW_DURATION
:
pgView
.
setAnimationDuration
((
Integer
)
obj
);
pgView
.
setAnimationDuration
((
Integer
)
obj
);
break
;
case
EventConstant
.
PG_SLIDESHOW_GEGIN
:
//first, it'll throw an event of onSizeChanged
getMainFrame
().
fullScreen
(
true
);
//then
this
.
pgView
.
beginSlideShow
(
obj
==
null
?
pgView
.
getCurrentIndex
()
+
1
:
(
Integer
)
obj
);
this
.
pgView
.
beginSlideShow
(
obj
==
null
?
pgView
.
getCurrentIndex
()
+
1
:
(
Integer
)
obj
);
break
;
case
EventConstant
.
PG_SLIDESHOW_END
:
pgView
.
endSlideShow
();
break
;
case
EventConstant
.
PG_SLIDESHOW_PREVIOUS
:
pgView
.
slideShow
(
ISlideShow
.
SlideShow_PreviousStep
);
break
;
case
EventConstant
.
PG_SLIDESHOW_NEXT
:
pgView
.
slideShow
(
ISlideShow
.
SlideShow_NextStep
);
break
;
case
EventConstant
.
APP_COUNT_PAGES_CHANGE_ID
:
pagesCountChanged
();
break
;
break
;
case
EventConstant
.
APP_SET_FIT_SIZE_ID
:
pgView
.
setFitSize
((
Integer
)
obj
);
pgView
.
setFitSize
((
Integer
)
obj
);
break
;
case
EventConstant
.
APP_INIT_CALLOUTVIEW_ID
:
pgView
.
initCalloutView
();
break
;
pgView
.
initCalloutView
();
break
;
default
:
break
;
}
}
private
void
pagesCountChanged
()
{
if
(
isShowingProgressDlg
&&
pgView
.
showLoadingSlide
())
{
private
void
pagesCountChanged
()
{
if
(
isShowingProgressDlg
&&
pgView
.
showLoadingSlide
())
{
isShowingProgressDlg
=
false
;
pgView
.
post
(
new
Runnable
()
{
pgView
.
post
(
new
Runnable
()
{
/**
*
*/
public
void
run
()
{
if
(
getMainFrame
().
isShowProgressBar
())
{
if
(
progressDialog
!=
null
)
{
public
void
run
()
{
if
(
getMainFrame
().
isShowProgressBar
())
{
if
(
progressDialog
!=
null
)
{
progressDialog
.
dismiss
();
progressDialog
=
null
;
}
}
else
{
}
else
{
ICustomDialog
dlgListener
=
mainControl
.
getCustomDialog
();
if
(
dlgListener
!=
null
)
{
if
(
dlgListener
!=
null
)
{
dlgListener
.
dismissDialog
(
ICustomDialog
.
DIALOGTYPE_LOADING
);
}
}
}
});
}
}
}
/**
*
*
*/
private
void
showSlide
(
final
int
slideIndex
)
{
if
(
slideIndex
<
0
||
slideIndex
>=
pgView
.
getSlideCount
())
{
private
void
showSlide
(
final
int
slideIndex
)
{
if
(
slideIndex
<
0
||
slideIndex
>=
pgView
.
getSlideCount
())
{
return
;
}
isShowingProgressDlg
=
false
;
if
(
slideIndex
>=
pgView
.
getRealSlideCount
())
{
if
(
slideIndex
>=
pgView
.
getRealSlideCount
())
{
isShowingProgressDlg
=
true
;
if
(
Objects
.
requireNonNull
(
getMainFrame
()).
isShowProgressBar
())
{
if
(
Objects
.
requireNonNull
(
getMainFrame
()).
isShowProgressBar
())
{
final
PGControl
own
=
this
;
pgView
.
postDelayed
(()
->
{
if
(
isShowingProgressDlg
)
{
progressDialog
=
ProgressDialog
.
show
(
getActivity
(),
own
.
getMainFrame
().
getAppName
(),
own
.
getMainFrame
().
getLocalString
(
"DIALOG_LOADING"
),
false
,
false
,
null
);
progressDialog
.
show
();
own
.
getMainFrame
().
getAppName
(),
own
.
getMainFrame
().
getLocalString
(
"DIALOG_LOADING"
),
false
,
false
,
null
);
progressDialog
.
show
();
}
},
200
);
}
else
{
}
else
{
ICustomDialog
dlgListener
=
mainControl
.
getCustomDialog
();
if
(
dlgListener
!=
null
)
{
if
(
dlgListener
!=
null
)
{
dlgListener
.
showDialog
(
ICustomDialog
.
DIALOGTYPE_LOADING
);
}
}
...
...
@@ -385,248 +330,217 @@ public class PGControl extends AbstractControl
pgView
.
showSlide
(
slideIndex
,
false
);
}
}
/**
* 得到action的状态
*
*
* @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
pgView
.
getZoom
();
case
EventConstant
.
APP_COUNT_PAGES_ID
:
return
pgView
.
getSlideCount
();
case
EventConstant
.
APP_GET_REAL_PAGE_COUNT_ID
:
return
pgView
.
getRealSlideCount
();
case
EventConstant
.
APP_CURRENT_PAGE_NUMBER_ID
:
return
pgView
.
getCurrentIndex
()
+
1
;
case
EventConstant
.
APP_FIT_ZOOM_ID
:
return
pgView
.
getFitZoom
();
case
EventConstant
.
PG_SLIDE_TO_IMAGE
:
return
pgView
.
slideToImage
((
Integer
)
obj
);
return
pgView
.
slideToImage
((
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
pgView
.
slideAreaToImage
(
paraArr
[
0
],
paraArr
[
1
],
paraArr
[
2
],
paraArr
[
3
],
paraArr
[
4
],
paraArr
[
5
],
paraArr
[
6
]);
}
}
break
;
case
EventConstant
.
PG_GET_SLIDE_NOTE
:
return
pgView
.
getSldieNote
((
Integer
)
obj
);
return
pgView
.
getSldieNote
((
Integer
)
obj
);
case
EventConstant
.
PG_GET_SLIDE_SIZE
:
int
index
=
(
Integer
)
obj
;
if
(
index
<=
0
||
index
>
pgView
.
getSlideCount
())
{
int
index
=
(
Integer
)
obj
;
if
(
index
<=
0
||
index
>
pgView
.
getSlideCount
())
{
return
null
;
}
Dimension
d
=
pgView
.
getPageSize
();
return
new
Rectangle
(
0
,
0
,
(
int
)
d
.
width
,
(
int
)
d
.
height
);
return
new
Rectangle
(
0
,
0
,
(
int
)
d
.
width
,
(
int
)
d
.
height
);
case
EventConstant
.
PG_SLIDESHOW
:
return
pgView
.
isSlideShow
();
case
EventConstant
.
APP_PAGE_UP_ID
:
return
pgView
.
hasPreviousSlide_Slideshow
();
case
EventConstant
.
APP_PAGE_DOWN_ID
:
return
pgView
.
hasNextSlide_Slideshow
();
case
EventConstant
.
PG_SLIDESHOW_HASPREVIOUSACTION
:
return
pgView
.
hasPreviousAction_Slideshow
();
case
EventConstant
.
PG_SLIDESHOW_HASNEXTACTION
:
return
pgView
.
hasNextAction_Slideshow
();
case
EventConstant
.
APP_THUMBNAIL_ID
:
if
(
obj
instanceof
int
[])
{
int
[]
a
=
(
int
[])
obj
;
if
(
a
.
length
<
2
||
a
[
1
]
<=
0
)
{
if
(
obj
instanceof
int
[])
{
int
[]
a
=
(
int
[])
obj
;
if
(
a
.
length
<
2
||
a
[
1
]
<=
0
)
{
return
null
;
}
return
pgView
.
getThumbnail
(
a
[
0
],
a
[
1
]
/
(
float
)
MainConstant
.
STANDARD_RATE
);
return
pgView
.
getThumbnail
(
a
[
0
],
a
[
1
]
/
(
float
)
MainConstant
.
STANDARD_RATE
);
}
break
;
case
EventConstant
.
PG_SLIDESHOW_SLIDEEXIST
:
return
((
Integer
)
obj
).
intValue
()
<=
pgView
.
getRealSlideCount
();
return
((
Integer
)
obj
).
intValue
()
<=
pgView
.
getRealSlideCount
();
case
EventConstant
.
PG_SLIDESHOW_ANIMATIONSTEPS
:
return
pgView
.
getSlideAnimationSteps
((
Integer
)
obj
);
return
pgView
.
getSlideAnimationSteps
((
Integer
)
obj
);
case
EventConstant
.
PG_SLIDESHOW_SLIDESHOWTOIMAGE
:
if
(
obj
instanceof
int
[])
{
int
[]
a
=
(
int
[])
obj
;
if
(
a
.
length
<
2
||
a
[
1
]
<=
0
)
{
if
(
obj
instanceof
int
[])
{
int
[]
a
=
(
int
[])
obj
;
if
(
a
.
length
<
2
||
a
[
1
]
<=
0
)
{
return
null
;
}
return
pgView
.
getSlideshowToImage
(
a
[
0
],
a
[
1
]);
}
break
;
case
EventConstant
.
APP_GET_FIT_SIZE_STATE_ID
:
if
(
pgView
!=
null
)
{
if
(
pgView
!=
null
)
{
return
pgView
.
getFitSizeState
();
}
break
;
case
EventConstant
.
APP_GET_SNAPSHOT_ID
:
if
(
pgView
!=
null
)
{
return
pgView
.
getSnapshot
((
Bitmap
)
obj
);
if
(
pgView
!=
null
)
{
return
pgView
.
getSnapshot
((
Bitmap
)
obj
);
}
break
;
default
:
break
;
}
return
null
;
}
/**
* current view index
*
* @return
*/
public
int
getCurrentViewIndex
()
{
return
pgView
.
getCurrentIndex
()
+
1
;
public
int
getCurrentViewIndex
()
{
return
pgView
.
getCurrentIndex
()
+
1
;
}
/**
*
*
*/
public
View
getView
()
{
public
View
getView
()
{
return
pgView
;
}
/**
*
*
*/
public
Dialog
getDialog
(
Activity
activity
,
int
id
)
{
public
Dialog
getDialog
(
Activity
activity
,
int
id
)
{
return
null
;
}
/**
*
*
*/
public
IMainFrame
getMainFrame
()
{
public
IMainFrame
getMainFrame
()
{
return
mainControl
.
getMainFrame
();
}
/**
*
*(non-Javadoc)
* @see com.cherry.lib.doc.office.system.AbstractControl#getActivity()
* (non-Javadoc)
*
* @see com.cherry.lib.doc.office.system.AbstractControl#getActivity()
*/
public
Activity
getActivity
()
{
public
Activity
getActivity
()
{
return
mainControl
.
getMainFrame
().
getActivity
();
}
/**
*
*
*/
public
IFind
getFind
()
{
public
IFind
getFind
()
{
return
pgView
.
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
boolean
isSlideShow
()
{
public
boolean
isSlideShow
()
{
return
pgView
.
isSlideShow
();
}
/**
*
* @return
*/
public
ISlideShow
getSlideShow
()
{
public
ISlideShow
getSlideShow
()
{
return
mainControl
.
getSlideShow
();
}
/**
*
*
*/
public
int
getApplicationType
()
{
return
MainConstant
.
APPLICATION_TYPE_PPT
;
public
int
getApplicationType
()
{
return
MainConstant
.
APPLICATION_TYPE_PPT
;
}
/**
*
*
*/
public
SysKit
getSysKit
()
{
public
SysKit
getSysKit
()
{
return
mainControl
.
getSysKit
();
}
/**
*
*
*/
public
void
dispose
()
{
public
void
dispose
()
{
isDispose
=
true
;
pgView
.
dispose
();
pgView
=
null
;
mainControl
=
null
;
}
//
private
boolean
isDispose
;
//
...
...
library/src/main/java/com/cherry/lib/doc/office/pg/control/PGEventManage.java
View file @
7096a17f
...
...
@@ -9,8 +9,6 @@ package com.cherry.lib.doc.office.pg.control;
import
com.cherry.lib.doc.office.common.ISlideShow
;
import
com.cherry.lib.doc.office.system.IControl
;
import
com.cherry.lib.doc.office.system.beans.AEventManage
;
import
com.cherry.lib.doc.office.system.beans.ATimer
;
import
android.graphics.Rect
;
import
android.view.MotionEvent
;
import
android.view.View
;
...
...
library/src/main/java/com/cherry/lib/doc/office/pg/control/PGPrintMode.java
View file @
7096a17f
/*
* 文件名称: PrintWord.java
*
*
* 编译器: android2.2
* 时间: 上午10:53:24
*/
...
...
@@ -29,6 +29,7 @@ import com.cherry.lib.doc.office.system.SysKit;
import
com.cherry.lib.doc.office.system.beans.pagelist.APageListItem
;
import
com.cherry.lib.doc.office.system.beans.pagelist.APageListView
;
import
com.cherry.lib.doc.office.system.beans.pagelist.IPageListViewListener
;
import
android.content.Context
;
import
android.graphics.Bitmap
;
import
android.graphics.Canvas
;
...
...
@@ -37,6 +38,7 @@ import android.graphics.Paint;
import
android.graphics.Rect
;
import
android.graphics.Typeface
;
import
android.graphics.drawable.Drawable
;
import
android.util.Log
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.view.ViewGroup
;
...
...
@@ -54,32 +56,27 @@ import android.widget.FrameLayout;
* <p>
* 负责人: ljj8494
* <p>
* 负责小组:
* 负责小组:
* <p>
* <p>
*/
public
class
PGPrintMode
extends
FrameLayout
implements
IPageListViewListener
{
public
class
PGPrintMode
extends
FrameLayout
implements
IPageListViewListener
{
/**
*
* @param context
*/
public
PGPrintMode
(
Context
context
)
{
public
PGPrintMode
(
Context
context
)
{
super
(
context
);
}
/**
*
*
*/
public
PGPrintMode
(
Context
context
,
IControl
control
,
PGModel
pgModel
,
PGEditor
editor
)
{
public
PGPrintMode
(
Context
context
,
IControl
control
,
PGModel
pgModel
,
PGEditor
editor
)
{
super
(
context
);
this
.
control
=
control
;
this
.
pgModel
=
pgModel
;
this
.
editor
=
editor
;
listView
=
new
APageListView
(
context
,
this
);
addView
(
listView
,
new
LayoutParams
(
LayoutParams
.
MATCH_PARENT
,
LayoutParams
.
MATCH_PARENT
));
//修改缩放,避免打开ppt时PPT展示不全或者太小
...
...
@@ -88,229 +85,198 @@ public class PGPrintMode extends FrameLayout implements IPageListViewListener
paint
.
setAntiAlias
(
true
);
paint
.
setTypeface
(
Typeface
.
SANS_SERIF
);
paint
.
setTextSize
(
36
);
}
public
void
setVisible
(
boolean
visible
)
{
if
(
visible
)
{
}
public
void
setVisible
(
boolean
visible
)
{
if
(
visible
)
{
listView
.
setVisibility
(
View
.
VISIBLE
);
}
else
{
}
else
{
listView
.
setVisibility
(
View
.
GONE
);
}
}
/**
*
*
*/
public
void
setBackgroundColor
(
int
color
)
{
public
void
setBackgroundColor
(
int
color
)
{
super
.
setBackgroundColor
(
color
);
if
(
listView
!=
null
)
{
if
(
listView
!=
null
)
{
listView
.
setBackgroundColor
(
color
);
}
}
/**
*
*
*/
public
void
setBackgroundResource
(
int
resid
)
{
public
void
setBackgroundResource
(
int
resid
)
{
super
.
setBackgroundResource
(
resid
);
if
(
listView
!=
null
)
{
if
(
listView
!=
null
)
{
listView
.
setBackgroundResource
(
resid
);
}
}
/**
*
*
*/
public
void
setBackgroundDrawable
(
Drawable
d
)
{
super
.
setBackgroundDrawable
(
d
);
if
(
listView
!=
null
)
{
listView
.
setBackgroundDrawable
(
d
);
}
public
void
setBackgroundDrawable
(
Drawable
d
)
{
super
.
setBackgroundDrawable
(
d
);
if
(
listView
!=
null
)
{
listView
.
setBackgroundDrawable
(
d
);
}
}
/**
*
*
*/
public
void
setVisibility
(
int
visibility
)
{
public
void
setVisibility
(
int
visibility
)
{
super
.
setVisibility
(
visibility
);
if
(
visibility
==
VISIBLE
);
if
(
visibility
==
VISIBLE
)
;
{
exportImage
(
listView
.
getCurrentPageView
(),
null
);
}
}
/**
*
*(non-Javadoc)
* @see android.view.ViewGroup#dispatchDraw(android.graphics.Canvas)
* (non-Javadoc)
*
* @see android.view.ViewGroup#dispatchDraw(android.graphics.Canvas)
*/
protected
void
dispatchDraw
(
Canvas
canvas
)
{
protected
void
dispatchDraw
(
Canvas
canvas
)
{
super
.
dispatchDraw
(
canvas
);
drawPageNubmer
(
canvas
);
}
/**
*
*
*/
public
void
init
()
{
public
void
init
()
{
//view.setBackgroundColor(color)
if
((
int
)(
getZoom
()
*
100
)
==
100
)
{
if
((
int
)
(
getZoom
()
*
100
)
==
100
)
{
setZoom
(
getFitZoom
(),
Integer
.
MIN_VALUE
,
Integer
.
MIN_VALUE
);
}
}
/**
*
*
*/
public
void
setZoom
(
float
zoom
,
int
pointX
,
int
pointY
)
{
public
void
setZoom
(
float
zoom
,
int
pointX
,
int
pointY
)
{
listView
.
setZoom
(
zoom
,
pointX
,
pointY
);
}
/**
* set fit size for PPT,Word view mode, PDf
*
* @param value fit size mode
* = 0, fit size of get minimum value of pageWidth / viewWidth and pageHeight / viewHeight;
* = 1, fit size of pageWidth
* = 2, fit size of PageHeight
*/
public
void
setFitSize
(
int
value
)
{
*
* @param value fit size mode
* = 0, fit size of get minimum value of pageWidth / viewWidth and pageHeight / viewHeight;
* = 1, fit size of pageWidth
* = 2, fit size of PageHeight
*/
public
void
setFitSize
(
int
value
)
{
listView
.
setFitSize
(
value
);
}
/**
* get fit size statue
*
*
* @return fit size statue
* = 0, left/right and top/bottom don't alignment
* = 1, top/bottom alignment
* = 2, left/right alignment
* = 3, left/right and top/bottom alignment
*/
public
int
getFitSizeState
()
{
* = 0, left/right and top/bottom don't alignment
* = 1, top/bottom alignment
* = 2, left/right alignment
* = 3, left/right and top/bottom alignment
*/
public
int
getFitSizeState
()
{
return
listView
.
getFitSizeState
();
}
/**
*
*
*/
public
float
getZoom
()
{
public
float
getZoom
()
{
return
listView
.
getZoom
();
}
/**
*
*
*/
public
float
getFitZoom
()
{
public
float
getFitZoom
()
{
return
listView
.
getFitZoom
();
}
/**
* get current display page number (base 1)
*
*
* @return page number (base 1)
*/
public
int
getCurrentPageNumber
()
{
public
int
getCurrentPageNumber
()
{
return
listView
.
getCurrentPageNumber
();
}
/**
*
*
*/
public
APageListView
getListView
()
{
public
APageListView
getListView
()
{
return
this
.
listView
;
}
/**
*
*
*/
public
void
nextPageView
()
{
public
void
nextPageView
()
{
listView
.
nextPageView
();
}
/**
*
*
*/
public
void
previousPageview
()
{
public
void
previousPageview
()
{
listView
.
previousPageview
();
}
/**
* switch page for page index (base 0)
*
*
* @param index
*/
public
void
showSlideForIndex
(
int
index
)
{
public
void
showSlideForIndex
(
int
index
)
{
listView
.
showPDFPageForIndex
(
index
);
}
/**
* /
public long viewToModel(int x, int y, boolean isBack)
{
int pageIndex = listView.getCurrentPageNumber() - 1;
if (pageIndex < 0 || pageIndex >= getPageCount())
{
return 0;
}
return pageRoot.viewToModel(x, y, isBack);
}
/**
*
* /
public Rectangle modelToView(long offset, Rectangle rect, boolean isBack)
{
int pageIndex = listView.getCurrentPageNumber() - 1;
if (pageIndex < 0 || pageIndex >= getPageCount())
{
return rect;
}
return pageRoot.modelToView(offset, rect, isBack);
}
/**
*
*/
public
int
getPageCount
()
{
* public long viewToModel(int x, int y, boolean isBack)
* {
* int pageIndex = listView.getCurrentPageNumber() - 1;
* if (pageIndex < 0 || pageIndex >= getPageCount())
* {
* return 0;
* }
* return pageRoot.viewToModel(x, y, isBack);
* }
* <p>
* /**
* <p>
* /
* public Rectangle modelToView(long offset, Rectangle rect, boolean isBack)
* {
* int pageIndex = listView.getCurrentPageNumber() - 1;
* if (pageIndex < 0 || pageIndex >= getPageCount())
* {
* return rect;
* }
* return pageRoot.modelToView(offset, rect, isBack);
* }
* <p>
* /**
*/
public
int
getPageCount
()
{
return
Math
.
max
(
pgModel
.
getSlideCount
(),
1
);
}
/**
*
*
*/
public
APageListItem
getPageListItem
(
int
position
,
View
convertView
,
ViewGroup
parent
)
{
public
APageListItem
getPageListItem
(
int
position
,
View
convertView
,
ViewGroup
parent
)
{
Rect
rect
=
getPageSize
(
position
);
return
new
PGPageListItem
(
listView
,
control
,
editor
,
rect
.
width
(),
rect
.
height
());
}
...
...
@@ -329,51 +295,39 @@ public class PGPrintMode extends FrameLayout implements IPageListViewListener
}
/**
*
*
*/
public
void
exportImage
(
final
APageListItem
pageItem
,
final
Bitmap
srcBitmap
)
{
if
(
getControl
()
==
null
||
!(
getParent
()
instanceof
Presentation
))
{
public
void
exportImage
(
final
APageListItem
pageItem
,
final
Bitmap
srcBitmap
)
{
if
(
getControl
()
==
null
||
!(
getParent
()
instanceof
Presentation
))
{
return
;
}
PGFind
find
=
(
PGFind
)
control
.
getFind
();
if
(
find
.
isSetPointToVisible
())
{
PGFind
find
=
(
PGFind
)
control
.
getFind
();
if
(
find
.
isSetPointToVisible
())
{
find
.
setSetPointToVisible
(
false
);
Rectangle
rect
=
editor
.
modelToView
(
editor
.
getHighlight
().
getSelectStart
(),
new
Rectangle
(),
false
);
if
(!
listView
.
isPointVisibleOnScreen
(
rect
.
x
,
rect
.
y
))
{
if
(!
listView
.
isPointVisibleOnScreen
(
rect
.
x
,
rect
.
y
))
{
listView
.
setItemPointVisibleOnScreen
(
rect
.
x
,
rect
.
y
);
return
;
}
}
post
(
new
Runnable
()
{
@
Override
public
void
run
()
{
try
{
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
PGSlide
slide
=
pgModel
.
getSlide
(
pageItem
.
getPageIndex
());
if
(
slide
!=
null
)
{
if
(
slide
!=
null
)
{
IOfficeToPicture
otp
=
getControl
().
getOfficeToPicture
();
if
(
otp
!=
null
&&
otp
.
getModeType
()
==
IOfficeToPicture
.
VIEW_CHANGE_END
)
{
if
(
otp
!=
null
&&
otp
.
getModeType
()
==
IOfficeToPicture
.
VIEW_CHANGE_END
)
{
int
rW
=
Math
.
min
(
getWidth
(),
pageItem
.
getWidth
());
int
rH
=
Math
.
min
(
getHeight
(),
pageItem
.
getHeight
());
Bitmap
dstBitmap
=
otp
.
getBitmap
(
rW
,
rH
);
if
(
dstBitmap
==
null
)
{
if
(
dstBitmap
==
null
)
{
return
;
}
//editor.getHighlight().setPaintHighlight(false);
// don't zoom
if
(
dstBitmap
.
getWidth
()
==
rW
&&
dstBitmap
.
getHeight
()
==
rH
)
{
if
(
dstBitmap
.
getWidth
()
==
rW
&&
dstBitmap
.
getHeight
()
==
rH
)
{
Canvas
canvas
=
new
Canvas
(
dstBitmap
);
canvas
.
drawColor
(
Color
.
WHITE
);
float
zoom
=
listView
.
getZoom
();
...
...
@@ -384,12 +338,11 @@ public class PGPrintMode extends FrameLayout implements IPageListViewListener
control
.
getSysKit
().
getCalloutManager
().
drawPath
(
canvas
,
pageItem
.
getPageIndex
(),
zoom
);
}
// zoom
else
{
float
paintZoom
=
Math
.
min
(
dstBitmap
.
getWidth
()
/
(
float
)
rW
,
dstBitmap
.
getHeight
()
/
(
float
)
rH
);
else
{
float
paintZoom
=
Math
.
min
(
dstBitmap
.
getWidth
()
/
(
float
)
rW
,
dstBitmap
.
getHeight
()
/
(
float
)
rH
);
float
zoom
=
listView
.
getZoom
()
*
paintZoom
;
int
left
=
(
int
)(
pageItem
.
getLeft
()
*
paintZoom
);
int
top
=
(
int
)(
pageItem
.
getTop
()
*
paintZoom
);
int
left
=
(
int
)
(
pageItem
.
getLeft
()
*
paintZoom
);
int
top
=
(
int
)
(
pageItem
.
getTop
()
*
paintZoom
);
Canvas
canvas
=
new
Canvas
(
dstBitmap
);
canvas
.
drawColor
(
Color
.
WHITE
);
canvas
.
translate
(-(
Math
.
max
(
left
,
0
)
-
left
),
-(
Math
.
max
(
top
,
0
)
-
top
));
...
...
@@ -400,163 +353,139 @@ public class PGPrintMode extends FrameLayout implements IPageListViewListener
otp
.
callBack
(
dstBitmap
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
}
}
});
}
/**
* get snap shot
*
* @param dstBitmap
* @return
*/
public
Bitmap
getSnapshot
(
final
Bitmap
dstBitmap
)
{
if
(
getControl
()
==
null
||
!(
getParent
()
instanceof
Presentation
))
{
public
Bitmap
getSnapshot
(
final
Bitmap
dstBitmap
)
{
if
(
getControl
()
==
null
||
!(
getParent
()
instanceof
Presentation
))
{
return
null
;
}
PGPageListItem
pageItem
=
(
PGPageListItem
)
getListView
().
getCurrentPageView
();
if
(
pageItem
==
null
)
{
PGPageListItem
pageItem
=
(
PGPageListItem
)
getListView
().
getCurrentPageView
();
if
(
pageItem
==
null
)
{
return
null
;
}
PGSlide
slide
=
pgModel
.
getSlide
(
pageItem
.
getPageIndex
());
if
(
slide
!=
null
)
{
int
rW
=
Math
.
min
(
getWidth
(),
pageItem
.
getWidth
());
int
rH
=
Math
.
min
(
getHeight
(),
pageItem
.
getHeight
());
// don't zoom
if
(
dstBitmap
.
getWidth
()
==
rW
&&
dstBitmap
.
getHeight
()
==
rH
)
{
Canvas
canvas
=
new
Canvas
(
dstBitmap
);
canvas
.
drawColor
(
Color
.
WHITE
);
float
zoom
=
listView
.
getZoom
();
int
left
=
pageItem
.
getLeft
();
int
top
=
pageItem
.
getTop
();
canvas
.
translate
(-(
Math
.
max
(
left
,
0
)
-
left
),
-(
Math
.
max
(
top
,
0
)
-
top
));
SlideDrawKit
.
instance
().
drawSlide
(
canvas
,
pgModel
,
editor
,
slide
,
zoom
);
}
// zoom
else
{
float
paintZoom
=
Math
.
min
(
dstBitmap
.
getWidth
()
/
(
float
)
rW
,
dstBitmap
.
getHeight
()
/
(
float
)
rH
);
float
zoom
=
listView
.
getZoom
()
*
paintZoom
;
int
left
=
(
int
)(
pageItem
.
getLeft
()
*
paintZoom
);
int
top
=
(
int
)(
pageItem
.
getTop
()
*
paintZoom
);
Canvas
canvas
=
new
Canvas
(
dstBitmap
);
canvas
.
drawColor
(
Color
.
WHITE
);
canvas
.
translate
(-(
Math
.
max
(
left
,
0
)
-
left
),
-(
Math
.
max
(
top
,
0
)
-
top
));
SlideDrawKit
.
instance
().
drawSlide
(
canvas
,
pgModel
,
editor
,
slide
,
zoom
);
}
PGSlide
slide
=
pgModel
.
getSlide
(
pageItem
.
getPageIndex
());
if
(
slide
!=
null
)
{
int
rW
=
Math
.
min
(
getWidth
(),
pageItem
.
getWidth
());
int
rH
=
Math
.
min
(
getHeight
(),
pageItem
.
getHeight
());
// don't zoom
if
(
dstBitmap
.
getWidth
()
==
rW
&&
dstBitmap
.
getHeight
()
==
rH
)
{
Canvas
canvas
=
new
Canvas
(
dstBitmap
);
canvas
.
drawColor
(
Color
.
WHITE
);
float
zoom
=
listView
.
getZoom
();
int
left
=
pageItem
.
getLeft
();
int
top
=
pageItem
.
getTop
();
canvas
.
translate
(-(
Math
.
max
(
left
,
0
)
-
left
),
-(
Math
.
max
(
top
,
0
)
-
top
));
SlideDrawKit
.
instance
().
drawSlide
(
canvas
,
pgModel
,
editor
,
slide
,
zoom
);
}
// zoom
else
{
float
paintZoom
=
Math
.
min
(
dstBitmap
.
getWidth
()
/
(
float
)
rW
,
dstBitmap
.
getHeight
()
/
(
float
)
rH
);
float
zoom
=
listView
.
getZoom
()
*
paintZoom
;
int
left
=
(
int
)
(
pageItem
.
getLeft
()
*
paintZoom
);
int
top
=
(
int
)
(
pageItem
.
getTop
()
*
paintZoom
);
Canvas
canvas
=
new
Canvas
(
dstBitmap
);
canvas
.
drawColor
(
Color
.
WHITE
);
canvas
.
translate
(-(
Math
.
max
(
left
,
0
)
-
left
),
-(
Math
.
max
(
top
,
0
)
-
top
));
SlideDrawKit
.
instance
().
drawSlide
(
canvas
,
pgModel
,
editor
,
slide
,
zoom
);
}
}
return
dstBitmap
;
}
/**
*
*
*/
public
boolean
isInit
()
{
public
boolean
isInit
()
{
return
true
;
}
/**
*
* @return
* true fitzoom may be larger than 100% but smaller than the max zoom
* @return true fitzoom may be larger than 100% but smaller than the max zoom
* false fitzoom can not larger than 100%
*/
public
boolean
isIgnoreOriginalSize
()
{
return
control
.
getMainFrame
().
isIgnoreOriginalSize
();
public
boolean
isIgnoreOriginalSize
()
{
return
control
.
getMainFrame
().
isIgnoreOriginalSize
();
}
/**
* page list view moving position
*/
public
int
getPageListViewMovingPosition
()
{
return
control
.
getMainFrame
().
getPageListViewMovingPosition
();
public
int
getPageListViewMovingPosition
()
{
return
control
.
getMainFrame
().
getPageListViewMovingPosition
();
}
/**
*
*
*/
public
Object
getModel
()
{
public
Object
getModel
()
{
return
pgModel
;
}
/**
*
*
*/
public
IControl
getControl
()
{
public
IControl
getControl
()
{
return
this
.
control
;
}
/**
* event method, office engine dispatch
*
* @param v event source
* @param e1 MotionEvent instance
* @param e2 MotionEvent instance
* @param velocityX x axis velocity
* @param velocityY y axis velocity
* @see IMainFrame#ON_CLICK
* @see IMainFrame#ON_DOUBLE_TAP
* @see IMainFrame#ON_DOUBLE_TAP_EVENT
* @see IMainFrame#ON_DOWN
* @see IMainFrame#ON_FLING
* @see IMainFrame#ON_LONG_PRESS
* @see IMainFrame#ON_SCROLL
* @see IMainFrame#ON_SHOW_PRESS
* @see IMainFrame#ON_SINGLE_TAP_CONFIRMED
* @see IMainFrame#ON_SINGLE_TAP_UP
* @see IMainFrame#ON_TOUCH
*/
public
boolean
onEventMethod
(
View
v
,
MotionEvent
e1
,
MotionEvent
e2
,
float
velocityX
,
float
velocityY
,
byte
eventMethodType
)
{
/**
* event method, office engine dispatch
*
* @param v event source
* @param e1 MotionEvent instance
* @param e2 MotionEvent instance
* @param velocityX x axis velocity
* @param velocityY y axis velocity
* @see IMainFrame#ON_CLICK
* @see IMainFrame#ON_DOUBLE_TAP
* @see IMainFrame#ON_DOUBLE_TAP_EVENT
* @see IMainFrame#ON_DOWN
* @see IMainFrame#ON_FLING
* @see IMainFrame#ON_LONG_PRESS
* @see IMainFrame#ON_SCROLL
* @see IMainFrame#ON_SHOW_PRESS
* @see IMainFrame#ON_SINGLE_TAP_CONFIRMED
* @see IMainFrame#ON_SINGLE_TAP_UP
* @see IMainFrame#ON_TOUCH
*/
public
boolean
onEventMethod
(
View
v
,
MotionEvent
e1
,
MotionEvent
e2
,
float
velocityX
,
float
velocityY
,
byte
eventMethodType
)
{
if
(
eventMethodType
==
ON_SINGLE_TAP_UP
&&
e1
!=
null
&&
e1
.
getAction
()
==
MotionEvent
.
ACTION_UP
)
{
&&
e1
.
getAction
()
==
MotionEvent
.
ACTION_UP
)
{
APageListItem
item
=
listView
.
getCurrentPageView
();
if
(
item
!=
null
)
{
if
(
item
!=
null
)
{
float
zoom
=
listView
.
getZoom
();
int
x
=
(
int
)((
e1
.
getX
()
-
item
.
getLeft
())
/
zoom
);
int
y
=
(
int
)
((
e1
.
getY
()
-
item
.
getTop
())
/
zoom
);
int
x
=
(
int
)
((
e1
.
getX
()
-
item
.
getLeft
())
/
zoom
);
int
y
=
(
int
)
((
e1
.
getY
()
-
item
.
getTop
())
/
zoom
);
IShape
shape
=
pgModel
.
getSlide
(
item
.
getPageIndex
()).
getTextboxShape
(
x
,
y
);
if
(
shape
!=
null
&&
shape
.
getType
()
==
AbstractShape
.
SHAPE_TEXTBOX
)
{
TextBox
textBox
=
(
TextBox
)
shape
;
if
(
shape
!=
null
&&
shape
.
getType
()
==
AbstractShape
.
SHAPE_TEXTBOX
)
{
TextBox
textBox
=
(
TextBox
)
shape
;
STRoot
root
=
textBox
.
getRootView
();
if
(
root
!=
null
)
{
if
(
root
!=
null
)
{
long
offset
=
root
.
viewToModel
(
x
-
shape
.
getBounds
().
x
,
y
-
shape
.
getBounds
().
y
,
false
);
if
(
offset
>=
0
)
{
ParagraphElement
paraElem
=
(
ParagraphElement
)
textBox
.
getElement
().
getElement
(
offset
);
if
(
paraElem
!=
null
)
{
if
(
offset
>=
0
)
{
ParagraphElement
paraElem
=
(
ParagraphElement
)
textBox
.
getElement
().
getElement
(
offset
);
if
(
paraElem
!=
null
)
{
IElement
leaf
=
paraElem
.
getLeaf
(
offset
);
if
(
leaf
!=
null
)
{
if
(
leaf
!=
null
)
{
int
hyID
=
AttrManage
.
instance
().
getHperlinkID
(
leaf
.
getAttribute
());
if
(
hyID
>=
0
)
{
if
(
hyID
>=
0
)
{
Hyperlink
hylink
=
control
.
getSysKit
().
getHyperlinkManage
().
getHyperlink
(
hyID
);
if
(
hylink
!=
null
)
{
if
(
hylink
!=
null
)
{
control
.
actionEvent
(
EventConstant
.
APP_HYPERLINK
,
hylink
);
return
true
;
}
...
...
@@ -572,140 +501,122 @@ public class PGPrintMode extends FrameLayout implements IPageListViewListener
}
/**
*
*
*/
public
void
updateStutus
(
Object
obj
)
{
control
.
actionEvent
(
EventConstant
.
SYS_UPDATE_TOOLSBAR_BUTTON_STATUS
,
obj
);
public
void
updateStutus
(
Object
obj
)
{
control
.
actionEvent
(
EventConstant
.
SYS_UPDATE_TOOLSBAR_BUTTON_STATUS
,
obj
);
}
/**
*
*
*/
public
void
resetSearchResult
(
APageListItem
pageItem
)
{
if
(
getParent
()
instanceof
Presentation
)
{
Presentation
pg
=
(
Presentation
)
getParent
();
if
(
pg
.
getFind
().
getPageIndex
()
!=
pageItem
.
getPageIndex
())
{
public
void
resetSearchResult
(
APageListItem
pageItem
)
{
if
(
getParent
()
instanceof
Presentation
)
{
Presentation
pg
=
(
Presentation
)
getParent
();
if
(
pg
.
getFind
().
getPageIndex
()
!=
pageItem
.
getPageIndex
())
{
pg
.
getEditor
().
getHighlight
().
removeHighlight
();
}
}
}
/**
*
*
*/
public
boolean
isTouchZoom
()
{
public
boolean
isTouchZoom
()
{
return
control
.
getMainFrame
().
isTouchZoom
();
}
/**
*
*
*/
public
boolean
isShowZoomingMsg
()
{
public
boolean
isShowZoomingMsg
()
{
return
control
.
getMainFrame
().
isShowZoomingMsg
();
}
/**
*
*
*/
public
void
changeZoom
()
{
public
void
changeZoom
()
{
control
.
getMainFrame
().
changeZoom
();
}
/**
* @param isDrawPictrue The isDrawPictrue to set.
*/
public
void
setDrawPictrue
(
boolean
isDrawPictrue
)
{
public
void
setDrawPictrue
(
boolean
isDrawPictrue
)
{
PictureKit
.
instance
().
setDrawPictrue
(
isDrawPictrue
);
}
/**
*
* @return
*/
public
PGSlide
getCurrentPGSlide
()
{
APageListItem
item
=
listView
.
getCurrentPageView
();
if
(
item
!=
null
)
{
public
PGSlide
getCurrentPGSlide
()
{
APageListItem
item
=
listView
.
getCurrentPageView
();
if
(
item
!=
null
)
{
return
pgModel
.
getSlide
(
item
.
getPageIndex
());
}
else
{
}
else
{
return
pgModel
.
getSlide
(
0
);
}
}
/**
* 绘制页信息
*
* @param canvas
*/
private
void
drawPageNubmer
(
Canvas
canvas
)
{
if
(
control
.
getMainFrame
().
isDrawPageNumber
())
{
private
void
drawPageNubmer
(
Canvas
canvas
)
{
Log
.
e
(
"PGPrintMode"
,
"drawPageNubmer"
);
control
.
getMainFrame
().
getPageNumber
(
listView
.
getCurrentPageNumber
(),
pgModel
.
getSlideCount
());
if
(
control
.
getMainFrame
().
isDrawPageNumber
())
{
String
pn
=
String
.
valueOf
((
listView
.
getCurrentPageNumber
())
+
" / "
+
pgModel
.
getSlideCount
());
int
w
=
(
int
)
paint
.
measureText
(
pn
);
int
h
=
(
int
)
(
paint
.
descent
()
-
paint
.
ascent
());
int
x
=
(
int
)((
getWidth
()
-
w
)
/
2
);
int
y
=
(
int
)((
getHeight
()
-
h
)
-
50
);
int
w
=
(
int
)
paint
.
measureText
(
pn
);
int
h
=
(
int
)
(
paint
.
descent
()
-
paint
.
ascent
());
int
x
=
(
int
)
((
getWidth
()
-
w
)
/
2
);
int
y
=
(
int
)
((
getHeight
()
-
h
)
-
50
);
Drawable
drawable
=
SysKit
.
getPageNubmerDrawable
();
drawable
.
setBounds
((
int
)(
x
-
20
),
y
-
10
,
x
+
w
+
20
,
y
+
h
+
10
);
drawable
.
setBounds
((
int
)
(
x
-
20
),
y
-
10
,
x
+
w
+
20
,
y
+
h
+
10
);
drawable
.
draw
(
canvas
);
y
-=
paint
.
ascent
();
canvas
.
drawText
(
pn
,
x
,
y
,
paint
);
}
if
(
preShowPageIndex
!=
listView
.
getCurrentPageNumber
())
{
if
(
preShowPageIndex
!=
listView
.
getCurrentPageNumber
())
{
changePage
();
preShowPageIndex
=
listView
.
getCurrentPageNumber
();
}
}
/**
*
*/
public
void
changePage
()
{
public
void
changePage
()
{
control
.
getMainFrame
().
changePage
();
}
/**
* set change page flag, Only when effectively the PageSize greater than ViewSize.
* (for PPT, word print mode, PDF)
*
* set change page flag, Only when effectively the PageSize greater than ViewSize.
* (for PPT, word print mode, PDF)
*/
public
boolean
isChangePage
()
{
return
control
.
getMainFrame
().
isChangePage
();
public
boolean
isChangePage
()
{
return
control
.
getMainFrame
().
isChangePage
();
}
/**
*
*
*/
public
void
dispose
()
{
public
void
dispose
()
{
control
=
null
;
if
(
listView
!=
null
)
{
if
(
listView
!=
null
)
{
listView
.
dispose
();
}
pgModel
=
null
;
pageSize
=
null
;
}
private
int
preShowPageIndex
=
-
1
;
//
private
IControl
control
;
...
...
library/src/main/java/com/cherry/lib/doc/office/system/AbstractControl.kt
View file @
7096a17f
...
...
@@ -38,7 +38,7 @@ import com.cherry.lib.doc.office.common.ISlideShow
*
*
*/
abstract
class
AbstractControl
:
IControl
{
abstract
class
AbstractControl
:
IControl
{
override
fun
layoutView
(
x
:
Int
,
y
:
Int
,
w
:
Int
,
h
:
Int
)
{}
override
fun
actionEvent
(
actionID
:
Int
,
obj
:
Any
?)
{}
override
fun
getActionValue
(
actionID
:
Int
,
obj
:
Any
?):
Any
?
{
...
...
library/src/main/java/com/cherry/lib/doc/office/system/IMainFrame.java
View file @
7096a17f
/*
* 文件名称: IActivity.java
*
*
* 编译器: android2.2
* 时间: 下午5:24:10
*/
...
...
@@ -25,12 +25,11 @@ import android.view.View;
* <p>
* 负责人: ljj8494
* <p>
* 负责小组:
* 负责小组:
* <p>
* <p>
*/
public
interface
IMainFrame
{
public
interface
IMainFrame
{
// onTouch
public
final
static
byte
ON_TOUCH
=
0
;
// onDown
...
...
@@ -56,280 +55,281 @@ public interface IMainFrame
/**
* get activity instance
*
* @return activity instance
*/
public
Activity
getActivity
();
/**
* do action
* do action
*
* @param actionID action ID
*
* @param obj acValue
*
* @return True if the listener has consumed the event, false otherwise.
* @param actionID action ID
* @param obj acValue
* @return True if the listener has consumed the event, false otherwise.
*/
public
boolean
doActionEvent
(
int
actionID
,
Object
obj
);
/**
* reader file finish call this method
*/
public
void
openFileFinish
();
public
void
openFileFailed
();
/**
* update tool bar status
*/
*/
public
void
updateToolsbarStatus
();
/**
* set the find back button and find forward button state
*
*
* @param state
*/
public
void
setFindBackForwardState
(
boolean
state
);
/**
* get bottom bar height
*
* @return bottom bar height
*/
public
int
getBottomBarHeight
();
/**
* get top bar height
*
* @return top bar height
*/
public
int
getTopBarHeight
();
/**
* get application name;
*
* @return application name
*/
public
String
getAppName
();
/**
*
* @return
*/
public
File
getTemporaryDirectory
();
/**
* event method, office engine dispatch
*
* @param v event source
* @param e1 MotionEvent instance
* @param e2 MotionEvent instance
* @param xValue eventNethodType is ON_SCROLL, this is value distanceX
* eventNethodType is ON_FLING, this is value velocityY
* eventNethodType is other type, this is value -1
*
* @param yValue eventNethodType is ON_SCROLL, this is value distanceY
* eventNethodType is ON_FLING, this is value velocityY
* eventNethodType is other type, this is value -1
* @param eventNethodType event method
* @see IMainFrame#ON_CLICK
* @see IMainFrame#ON_DOUBLE_TAP
* @see IMainFrame#ON_DOUBLE_TAP_EVENT
* @see IMainFrame#ON_DOWN
* @see IMainFrame#ON_FLING
* @see IMainFrame#ON_LONG_PRESS
* @see IMainFrame#ON_SCROLL
* @see IMainFrame#ON_SHOW_PRESS
* @see IMainFrame#ON_SINGLE_TAP_CONFIRMED
* @see IMainFrame#ON_SINGLE_TAP_UP
* @see IMainFrame#ON_TOUCH
/**
* event method, office engine dispatch
*
* @param v event source
* @param e1 MotionEvent instance
* @param e2 MotionEvent instance
* @param xValue eventNethodType is ON_SCROLL, this is value distanceX
* eventNethodType is ON_FLING, this is value velocityY
* eventNethodType is other type, this is value -1
* @param yValue eventNethodType is ON_SCROLL, this is value distanceY
* eventNethodType is ON_FLING, this is value velocityY
* eventNethodType is other type, this is value -1
* @see IMainFrame#ON_CLICK
* @see IMainFrame#ON_DOUBLE_TAP
* @see IMainFrame#ON_DOUBLE_TAP_EVENT
* @see IMainFrame#ON_DOWN
* @see IMainFrame#ON_FLING
* @see IMainFrame#ON_LONG_PRESS
* @see IMainFrame#ON_SCROLL
* @see IMainFrame#ON_SHOW_PRESS
* @see IMainFrame#ON_SINGLE_TAP_CONFIRMED
* @see IMainFrame#ON_SINGLE_TAP_UP
* @see IMainFrame#ON_TOUCH
*/
public
boolean
onEventMethod
(
View
v
,
MotionEvent
e1
,
MotionEvent
e2
,
float
xValue
,
float
yValue
,
byte
eventMethodType
);
//单次点击
public
void
singleTap
();
//获取页码
public
void
getPageNumber
(
int
current
,
int
total
);
/**
* is support draw page number
* @return true draw page number
* false don’t draw page number
*
* @return true draw page number
* false don’t draw page number
*/
public
boolean
isDrawPageNumber
();
/**
* true: show message when zooming
* false: not show message when zooming
*
* @return
*/
public
boolean
isShowZoomingMsg
();
/**
* true: pop up dialog when throw err
* false: not pop up dialog when throw err
*
* @return
*/
public
boolean
isPopUpErrorDlg
();
/**
* show password dialog when parse file with password
*
* @return
*/
public
boolean
isShowPasswordDlg
();
public
boolean
isShowPasswordDlg
();
/**
* show progress bar or not when parsing document
*
* @return
*/
public
boolean
isShowProgressBar
();
/**
*
*
*/
public
boolean
isShowFindDlg
();
/**
* show txt encode dialog when parse txt file
*
* @return
*/
public
boolean
isShowTXTEncodeDlg
();
/**
* get txt default encode when not showing txt encode dialog
*
* @return null if showing txt encode dialog
*/
public
String
getTXTDefaultEncode
();
/**
* is support zoom in / zoom out
*
* @return
true touch zoom
*
false don’t touch zoom
*
* @return true touch zoom
* false don’t touch zoom
*/
public
boolean
isTouchZoom
();
/**
* normal view, changed after zoom bend, you need to re-layout
*
*
@return
true re-layout
*
false don't re-layout
*
*
@return
true re-layout
*
false don't re-layout
*/
public
boolean
isZoomAfterLayoutForWord
();
/**
* Word application default view (Normal or Page)
*
*
* @return 0, page view
* 1,normal view;
*
* 1,normal view;
*/
public
byte
getWordDefaultView
();
/**
* get Internationalization resource
*
*
* @param resName Internationalization resource name
*/
public
String
getLocalString
(
String
resName
);
/**
* callback this method after zoom change
*/
public
void
changeZoom
();
/**
*
*
*/
public
void
changePage
();
/**
*
*
*/
public
void
completeLayout
();
/**
* when engine error occurred callback this method
*/
public
void
error
(
int
errorCode
);
/**
* full screen, not show top tool bar
*/
public
void
fullScreen
(
boolean
fullscreen
);
/**
*
* @param visible
*/
public
void
showProgressBar
(
boolean
visible
);
/**
*
* @param viewList
*/
public
void
updateViewImages
(
List
<
Integer
>
viewList
);
public
void
updateViewImages
(
List
<
Integer
>
viewList
);
/**
* set change page flag, Only when effectively the PageSize greater than ViewSize.
* (for PPT, word print mode, PDF)
*
* @param b = true, change page
* = false, don't change page
* set change page flag, Only when effectively the PageSize greater than ViewSize.
* (for PPT, word print mode, PDF)
*/
public
boolean
isChangePage
();
/**
* when need destroy office engine instance callback this method
*/
//public void destroyEngine();
/**
*
* @param saveLog
*/
public
void
setWriteLog
(
boolean
saveLog
);
/**
*
* @return
*/
public
boolean
isWriteLog
();
/**
*
* @param isThumbnail
*/
public
void
setThumbnail
(
boolean
isThumbnail
);
/**
*
* @return
*/
public
boolean
isThumbnail
();
/**
* get view backgrouond
*
* @return
*/
public
Object
getViewBackground
();
/**
* set flag whether fitzoom can be larger than 100% but smaller than the max zoom
*
* @param ignoreOriginalSize
*/
public
void
setIgnoreOriginalSize
(
boolean
ignoreOriginalSize
);
/**
*
* @return
* true fitzoom may be larger than 100% but smaller than the max zoom
* @return true fitzoom may be larger than 100% but smaller than the max zoom
* false fitzoom can not larger than 100%
*/
public
boolean
isIgnoreOriginalSize
();
/**
* page list view moving position
* @param position horizontal or vertical
*/
public
int
getPageListViewMovingPosition
();
/**
*
*
*/
public
void
dispose
();
}
library/src/main/java/com/cherry/lib/doc/office/system/MainControl.java
View file @
7096a17f
...
...
@@ -140,7 +140,7 @@ public class MainControl extends AbstractControl {
*/
public
void
dismissProgressDialog
()
{
if
(
progressDialog
!=
null
)
{
if
(
progressDialog
.
getWindow
()
!=
null
)
{
if
(
progressDialog
.
getWindow
()
!=
null
)
{
progressDialog
.
dismiss
();
}
progressDialog
=
null
;
...
...
@@ -316,6 +316,7 @@ public class MainControl extends AbstractControl {
* @param obj 动作ID的Value
*/
public
void
actionEvent
(
int
actionID
,
final
Object
obj
)
{
Log
.
e
(
"MainControl"
,
"actionEvent "
+
actionID
);
if
(
actionID
==
EventConstant
.
SYS_READER_FINSH_ID
)
{
if
(
reader
!=
null
)
{
if
(
appControl
!=
null
)
{
...
...
library/src/main/java/com/cherry/lib/doc/office/system/beans/AEventManage.java
View file @
7096a17f
/*
* 文件名称: AEventManage.java
*
*
* 编译器: android2.2
* 时间: 下午8:02:22
*/
...
...
@@ -8,12 +8,10 @@ package com.cherry.lib.doc.office.system.beans;
import
com.cherry.lib.doc.office.constant.EventConstant
;
import
com.cherry.lib.doc.office.constant.MainConstant
;
import
com.cherry.lib.doc.office.system.ErrorUtil
;
import
com.cherry.lib.doc.office.system.IControl
;
import
com.cherry.lib.doc.office.system.IMainFrame
;
import
com.cherry.lib.doc.office.system.MainControl
;
import
android.content.Context
;
import
android.util.Log
;
import
android.view.GestureDetector
;
import
android.view.GestureDetector.OnDoubleTapListener
;
import
android.view.GestureDetector.OnGestureListener
;
...
...
@@ -38,18 +36,16 @@ import android.widget.Toast;
* <p>
* 负责人: ljj8494
* <p>
* 负责小组:
* 负责小组:
* <p>
* <p>
*/
public
abstract
class
AEventManage
implements
OnTouchListener
,
OnGestureListener
,
OnDoubleTapListener
,
OnClickListener
{
public
abstract
class
AEventManage
implements
OnTouchListener
,
OnGestureListener
,
OnDoubleTapListener
,
OnClickListener
{
/**
*
*
*/
public
AEventManage
(
Context
context
,
IControl
control
)
{
public
AEventManage
(
Context
context
,
IControl
control
)
{
this
.
control
=
control
;
gesture
=
new
GestureDetector
(
context
,
this
,
null
,
true
);
mScroller
=
new
Scroller
(
context
);
...
...
@@ -58,62 +54,52 @@ public abstract class AEventManage implements OnTouchListener,
mMaximumVelocity
=
configuration
.
getScaledMaximumFlingVelocity
();
toast
=
Toast
.
makeText
(
context
,
""
,
Toast
.
LENGTH_SHORT
);
}
/**
* 触摸事件
*
*/
public
boolean
onTouch
(
View
v
,
MotionEvent
event
)
{
public
boolean
onTouch
(
View
v
,
MotionEvent
event
)
{
Log
.
e
(
"AEventManage"
,
"onTouch "
+
event
.
getAction
());
boolean
ret
=
false
;
try
{
if
(
gesture
==
null
)
{
try
{
if
(
gesture
==
null
)
{
return
false
;
}
control
.
getMainFrame
().
onEventMethod
(
v
,
event
,
null
,
-
1.0f
,
-
1.0f
,
IMainFrame
.
ON_TOUCH
);
if
(
event
.
getPointerCount
()
==
2
)
{
if
(
event
.
getPointerCount
()
==
2
)
{
//view zoom
return
zoom
(
event
);
}
// 交给手型处理
gesture
.
onTouchEvent
(
event
);
if
(
mVelocityTracker
==
null
)
{
if
(
mVelocityTracker
==
null
)
{
mVelocityTracker
=
VelocityTracker
.
obtain
();
}
}
mVelocityTracker
.
addMovement
(
event
);
int
action
=
event
.
getAction
();
switch
(
action
)
{
switch
(
action
)
{
case
MotionEvent
.
ACTION_DOWN
:
stopFling
();
mActivePointerId
=
event
.
getPointerId
(
0
);
break
;
case
MotionEvent
.
ACTION_MOVE
:
break
;
case
MotionEvent
.
ACTION_UP
:
if
(!
singleTabup
)
{
final
VelocityTracker
velocityTracker
=
mVelocityTracker
;
if
(!
singleTabup
)
{
final
VelocityTracker
velocityTracker
=
mVelocityTracker
;
velocityTracker
.
computeCurrentVelocity
(
1000
,
mMaximumVelocity
);
int
initialYVelocity
=
(
int
)
velocityTracker
.
getYVelocity
(
mActivePointerId
);
int
initialXVelocity
=
(
int
)
velocityTracker
.
getXVelocity
(
mActivePointerId
);
int
initialYVelocity
=
(
int
)
velocityTracker
.
getYVelocity
(
mActivePointerId
);
int
initialXVelocity
=
(
int
)
velocityTracker
.
getXVelocity
(
mActivePointerId
);
if
(
Math
.
abs
(
initialYVelocity
)
>
mMinimumVelocity
||
Math
.
abs
(
initialXVelocity
)
>
mMinimumVelocity
)
{
if
(!
isScroll
)
{
isScroll
=
control
.
getApplicationType
()
==
MainConstant
.
APPLICATION_TYPE_PPT
;
}
if
(!
zoomChange
)
{
||
Math
.
abs
(
initialXVelocity
)
>
mMinimumVelocity
)
{
if
(!
isScroll
)
{
isScroll
=
control
.
getApplicationType
()
==
MainConstant
.
APPLICATION_TYPE_PPT
;
}
if
(!
zoomChange
)
{
fling
(-
initialXVelocity
,
-
initialYVelocity
);
}
ret
=
true
;
...
...
@@ -121,100 +107,88 @@ public abstract class AEventManage implements OnTouchListener,
midXDoublePoint
=
-
1
;
midYDoublePoint
=
-
1
;
mActivePointerId
=
-
1
;
if
(
mVelocityTracker
!=
null
)
{
if
(
mVelocityTracker
!=
null
)
{
mVelocityTracker
.
recycle
();
mVelocityTracker
=
null
;
}
toast
.
cancel
();
if
(
isScroll
)
{
if
(
isScroll
)
{
isScroll
=
false
;
if
(
control
.
getApplicationType
()
==
MainConstant
.
APPLICATION_TYPE_WP
&&
zoomChange
)
{
if
(!
control
.
getMainFrame
().
isZoomAfterLayoutForWord
())
{
if
(
control
.
getApplicationType
()
==
MainConstant
.
APPLICATION_TYPE_WP
&&
zoomChange
)
{
if
(!
control
.
getMainFrame
().
isZoomAfterLayoutForWord
())
{
control
.
actionEvent
(
EventConstant
.
APP_GENERATED_PICTURE_ID
,
null
);
}
}
if
(
control
.
getApplicationType
()
==
MainConstant
.
APPLICATION_TYPE_PPT
)
{
if
(!
control
.
isSlideShow
())
{
if
(
control
.
getApplicationType
()
==
MainConstant
.
APPLICATION_TYPE_PPT
)
{
if
(!
control
.
isSlideShow
())
{
control
.
actionEvent
(
EventConstant
.
APP_GENERATED_PICTURE_ID
,
null
);
}
}
else
{
}
else
{
control
.
actionEvent
(
EventConstant
.
APP_GENERATED_PICTURE_ID
,
null
);
}
control
.
actionEvent
(
EventConstant
.
SYS_UPDATE_TOOLSBAR_BUTTON_STATUS
,
null
);
}
if
(
control
.
getApplicationType
()
!=
MainConstant
.
APPLICATION_TYPE_WP
)
{
if
(
control
.
getApplicationType
()
!=
MainConstant
.
APPLICATION_TYPE_WP
)
{
zoomChange
=
false
;
}
}
singleTabup
=
false
;
}
else
{
control
.
getMainFrame
().
singleTap
();
}
singleTabup
=
false
;
break
;
case
MotionEvent
.
ACTION_CANCEL
:
mActivePointerId
=
-
1
;
if
(
mVelocityTracker
!=
null
)
{
if
(
mVelocityTracker
!=
null
)
{
mVelocityTracker
.
recycle
();
mVelocityTracker
=
null
;
}
default
:
break
;
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
control
.
getSysKit
().
getErrorKit
().
writerLog
(
e
);
}
return
ret
;
}
/**
* action when zooming
*
* @param event
* @return
*/
protected
boolean
zoom
(
MotionEvent
event
)
{
if
(!
control
.
getMainFrame
().
isTouchZoom
())
{
protected
boolean
zoom
(
MotionEvent
event
)
{
if
(!
control
.
getMainFrame
().
isTouchZoom
())
{
return
true
;
}
float
zoom
=
((
Float
)
control
.
getActionValue
(
EventConstant
.
APP_ZOOM_ID
,
null
)).
floatValue
();
float
fitZoom
=
((
Float
)
control
.
getActionValue
(
EventConstant
.
APP_FIT_ZOOM_ID
,
null
)).
floatValue
();
boolean
isMinZoom
=
(
int
)
(
zoom
*
MainConstant
.
STANDARD_RATE
)
==
(
int
)
(
fitZoom
*
MainConstant
.
STANDARD_RATE
);
boolean
zoomRateChanged
=
false
;
float
zoom
=
((
Float
)
control
.
getActionValue
(
EventConstant
.
APP_ZOOM_ID
,
null
)).
floatValue
();
float
fitZoom
=
((
Float
)
control
.
getActionValue
(
EventConstant
.
APP_FIT_ZOOM_ID
,
null
)).
floatValue
();
boolean
isMinZoom
=
(
int
)
(
zoom
*
MainConstant
.
STANDARD_RATE
)
==
(
int
)
(
fitZoom
*
MainConstant
.
STANDARD_RATE
);
boolean
zoomRateChanged
=
false
;
float
dist
=
distance
;
int
action
=
event
.
getActionMasked
();
switch
(
action
)
{
switch
(
action
)
{
case
MotionEvent
.
ACTION_POINTER_1_DOWN
:
float
x1
=
event
.
getX
(
0
);
float
y1
=
event
.
getY
(
0
);
float
y1
=
event
.
getY
(
0
);
float
x2
=
event
.
getX
(
1
);
float
y2
=
event
.
getY
(
1
);
float
y2
=
event
.
getY
(
1
);
float
min
=
Math
.
min
(
x1
,
x2
);
midXDoublePoint
=
(
int
)(
min
+
Math
.
abs
(
x1
-
x2
)
/
2
);
midXDoublePoint
=
(
int
)
(
min
+
Math
.
abs
(
x1
-
x2
)
/
2
);
min
=
Math
.
min
(
y1
,
y2
);
midYDoublePoint
=
(
int
)(
min
+
Math
.
abs
(
y1
-
y2
)
/
2
);
distance
=
(
float
)(
Math
.
sqrt
((
x1
-
x2
)
*
(
x1
-
x2
)
+
(
y1
-
y2
)
*
(
y1
-
y2
))
/
2
);
midYDoublePoint
=
(
int
)
(
min
+
Math
.
abs
(
y1
-
y2
)
/
2
);
distance
=
(
float
)
(
Math
.
sqrt
((
x1
-
x2
)
*
(
x1
-
x2
)
+
(
y1
-
y2
)
*
(
y1
-
y2
))
/
2
);
break
;
case
MotionEvent
.
ACTION_POINTER_1_UP
:
case
MotionEvent
.
ACTION_POINTER_1_UP
:
//zoomRateChanged = true;
break
;
case
MotionEvent
.
ACTION_MOVE
:
float
tx1
=
event
.
getX
(
0
);
float
ty1
=
event
.
getY
(
0
);
...
...
@@ -252,24 +226,21 @@ public abstract class AEventManage implements OnTouchListener,
default
:
break
;
}
//zoom rate changed, update view
if
(
zoomRateChanged
)
{
if
(
zoomRateChanged
)
{
isScroll
=
true
;
zoomChange
=
true
;
control
.
actionEvent
(
EventConstant
.
APP_ZOOM_ID
,
new
int
[]{(
int
)(
zoom
*
MainConstant
.
STANDARD_RATE
),
midXDoublePoint
,
midYDoublePoint
});
zoomChange
=
true
;
control
.
actionEvent
(
EventConstant
.
APP_ZOOM_ID
,
new
int
[]{(
int
)
(
zoom
*
MainConstant
.
STANDARD_RATE
),
midXDoublePoint
,
midYDoublePoint
});
control
.
getView
().
postInvalidate
();
// 提示
if
(
control
.
getMainFrame
().
isShowZoomingMsg
())
{
if
(
control
.
getApplicationType
()
==
MainConstant
.
APPLICATION_TYPE_PPT
&&
control
.
isSlideShow
())
{
if
(
control
.
getMainFrame
().
isShowZoomingMsg
())
{
if
(
control
.
getApplicationType
()
==
MainConstant
.
APPLICATION_TYPE_PPT
&&
control
.
isSlideShow
())
{
return
true
;
}
toast
.
setText
((
int
)
Math
.
round
(
zoom
*
100
)
+
"%"
);
toast
.
setText
((
int
)
Math
.
round
(
zoom
*
100
)
+
"%"
);
toast
.
show
();
}
}
...
...
@@ -277,168 +248,140 @@ public abstract class AEventManage implements OnTouchListener,
}
/**
*
*
*/
public
boolean
onDown
(
MotionEvent
e
)
{
return
control
.
getMainFrame
().
onEventMethod
(
control
.
getView
(),
e
,
null
,
-
1.0f
,
-
1.0f
,
IMainFrame
.
ON_DOWN
);
public
boolean
onDown
(
MotionEvent
e
)
{
Log
.
e
(
"AEventManage"
,
"onDown"
);
return
control
.
getMainFrame
().
onEventMethod
(
control
.
getView
(),
e
,
null
,
-
1.0f
,
-
1.0f
,
IMainFrame
.
ON_DOWN
);
}
/**
*
*
*/
public
void
onShowPress
(
MotionEvent
e
)
{
public
void
onShowPress
(
MotionEvent
e
)
{
control
.
getMainFrame
().
onEventMethod
(
control
.
getView
(),
e
,
null
,
-
1.0f
,
-
1.0f
,
IMainFrame
.
ON_SHOW_PRESS
);
}
/**
*
*
*/
public
boolean
onSingleTapUp
(
MotionEvent
e
)
{
if
(!
isScroll
)
{
singleTabup
=
true
;
}
public
boolean
onSingleTapUp
(
MotionEvent
e
)
{
if
(!
isScroll
)
{
singleTabup
=
true
;
}
return
control
.
getMainFrame
().
onEventMethod
(
control
.
getView
(),
e
,
null
,
-
1.0f
,
-
1.0f
,
IMainFrame
.
ON_SINGLE_TAP_UP
);
}
/**
*
*
*/
public
boolean
onScroll
(
MotionEvent
e1
,
MotionEvent
e2
,
float
distanceX
,
float
distanceY
)
{
public
boolean
onScroll
(
MotionEvent
e1
,
MotionEvent
e2
,
float
distanceX
,
float
distanceY
)
{
isScroll
=
true
;
return
control
.
getMainFrame
().
onEventMethod
(
control
.
getView
(),
e1
,
e2
,
distanceX
,
distanceY
,
IMainFrame
.
ON_SCROLL
);
}
/**
*
*
*/
public
void
onLongPress
(
MotionEvent
e
)
{
public
void
onLongPress
(
MotionEvent
e
)
{
control
.
getMainFrame
().
onEventMethod
(
control
.
getView
(),
e
,
null
,
-
1.0f
,
-
1.0f
,
IMainFrame
.
ON_LONG_PRESS
);
}
/**
*
*
*/
public
boolean
onFling
(
MotionEvent
e1
,
MotionEvent
e2
,
float
velocityX
,
float
velocityY
)
{
public
boolean
onFling
(
MotionEvent
e1
,
MotionEvent
e2
,
float
velocityX
,
float
velocityY
)
{
return
control
.
getMainFrame
().
onEventMethod
(
control
.
getView
(),
e1
,
e2
,
velocityX
,
velocityY
,
IMainFrame
.
ON_FLING
);
}
/**
*
*
*/
public
boolean
onSingleTapConfirmed
(
MotionEvent
e
)
{
public
boolean
onSingleTapConfirmed
(
MotionEvent
e
)
{
return
control
.
getMainFrame
().
onEventMethod
(
control
.
getView
(),
e
,
null
,
-
1.0f
,
-
1.0f
,
IMainFrame
.
ON_SINGLE_TAP_CONFIRMED
);
}
/**
*
*
*/
public
boolean
onDoubleTap
(
MotionEvent
e
)
{
public
boolean
onDoubleTap
(
MotionEvent
e
)
{
return
control
.
getMainFrame
().
onEventMethod
(
control
.
getView
(),
e
,
null
,
-
1.0f
,
-
1.0f
,
IMainFrame
.
ON_DOUBLE_TAP
);
}
/**
*
*
*/
public
boolean
onDoubleTapEvent
(
MotionEvent
e
)
{
public
boolean
onDoubleTapEvent
(
MotionEvent
e
)
{
return
control
.
getMainFrame
().
onEventMethod
(
control
.
getView
(),
e
,
null
,
-
1.0f
,
-
1.0f
,
IMainFrame
.
ON_DOUBLE_TAP_EVENT
);
}
/**
*
*
*/
public
void
onClick
(
View
v
)
{
public
void
onClick
(
View
v
)
{
Log
.
e
(
"AEventManage"
,
"onClick"
);
control
.
getMainFrame
().
onEventMethod
(
control
.
getView
(),
null
,
null
,
-
1.0f
,
-
1.0f
,
IMainFrame
.
ON_CLICK
);
}
/**
*
*
*/
public
void
computeScroll
()
{
if
(
isFling
&&
mScroller
.
isFinished
())
{
public
void
computeScroll
()
{
if
(
isFling
&&
mScroller
.
isFinished
())
{
isFling
=
false
;
control
.
actionEvent
(
EventConstant
.
APP_GENERATED_PICTURE_ID
,
null
);
control
.
actionEvent
(
EventConstant
.
SYS_UPDATE_TOOLSBAR_BUTTON_STATUS
,
null
);
}
}
/**
* Fling the scroll view
*
* @param velocityX
X方向速率
* @param velocityY
Y方向速率
* @param velocityX X方向速率
* @param velocityY
Y方向速率
*/
public
void
fling
(
int
velocityX
,
int
velocityY
)
{
public
void
fling
(
int
velocityX
,
int
velocityY
)
{
}
/**
*
*
*/
public
void
stopFling
()
{
if
(
mScroller
!=
null
&&
!
mScroller
.
isFinished
())
{
public
void
stopFling
()
{
if
(
mScroller
!=
null
&&
!
mScroller
.
isFinished
())
{
isFling
=
true
;
mScroller
.
abortAnimation
();
}
}
/**
* get middle X axis of double point
*/
public
int
getMiddleXOfDoublePoint
()
{
public
int
getMiddleXOfDoublePoint
()
{
return
this
.
midXDoublePoint
;
}
/**
* get middle Y axis of double point
*/
public
int
getMiddleYOfDoublePoint
()
{
public
int
getMiddleYOfDoublePoint
()
{
return
this
.
midYDoublePoint
;
}
/**
*
*
*/
public
void
dispose
()
{
public
void
dispose
()
{
control
=
null
;
gesture
=
null
;
mVelocityTracker
=
null
;
toast
=
null
;
if
(
mScroller
!=
null
&&
!
mScroller
.
isFinished
())
{
if
(
mScroller
!=
null
&&
!
mScroller
.
isFinished
())
{
mScroller
.
abortAnimation
();
}
}
mScroller
=
null
;
}
//
protected
boolean
isFling
;
//
...
...
@@ -469,5 +412,5 @@ public abstract class AEventManage implements OnTouchListener,
protected
Scroller
mScroller
;
//toast
protected
Toast
toast
=
null
;
}
library/src/main/java/com/cherry/lib/doc/office/wp/control/PrintWord.java
View file @
7096a17f
/*
* 文件名称: PrintWord.java
*
*
* 编译器: android2.2
* 时间: 上午10:53:24
*/
...
...
@@ -32,6 +32,7 @@ import android.graphics.Paint;
import
android.graphics.Rect
;
import
android.graphics.Typeface
;
import
android.graphics.drawable.Drawable
;
import
android.util.Log
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.view.ViewGroup
;
...
...
@@ -49,334 +50,282 @@ import android.widget.FrameLayout;
* <p>
* 负责人: ljj8494
* <p>
* 负责小组:
* 负责小组:
* <p>
* <p>
*/
public
class
PrintWord
extends
FrameLayout
implements
IPageListViewListener
{
public
class
PrintWord
extends
FrameLayout
implements
IPageListViewListener
{
/**
*
* @param context
*/
public
PrintWord
(
Context
context
)
{
public
PrintWord
(
Context
context
)
{
super
(
context
);
}
/**
*
*
*/
public
PrintWord
(
Context
context
,
IControl
control
,
PageRoot
pageRoot
)
{
public
PrintWord
(
Context
context
,
IControl
control
,
PageRoot
pageRoot
)
{
super
(
context
);
this
.
control
=
control
;
this
.
pageRoot
=
pageRoot
;
listView
=
new
APageListView
(
context
,
this
);
addView
(
listView
,
new
LayoutParams
(
LayoutParams
.
MATCH_PARENT
,
LayoutParams
.
MATCH_PARENT
));
paint
=
new
Paint
();
paint
.
setAntiAlias
(
true
);
paint
.
setTypeface
(
Typeface
.
SANS_SERIF
);
paint
.
setTextSize
(
36
);
}
}
/**
*
*
*/
public
void
setBackgroundColor
(
int
color
)
{
public
void
setBackgroundColor
(
int
color
)
{
super
.
setBackgroundColor
(
color
);
if
(
listView
!=
null
)
{
if
(
listView
!=
null
)
{
listView
.
setBackgroundColor
(
color
);
}
}
/**
*
*
*/
public
void
setBackgroundResource
(
int
resid
)
{
public
void
setBackgroundResource
(
int
resid
)
{
super
.
setBackgroundResource
(
resid
);
if
(
listView
!=
null
)
{
if
(
listView
!=
null
)
{
listView
.
setBackgroundResource
(
resid
);
}
}
/**
*
*
*/
public
void
setBackgroundDrawable
(
Drawable
d
)
{
super
.
setBackgroundDrawable
(
d
);
if
(
listView
!=
null
)
{
listView
.
setBackgroundDrawable
(
d
);
}
public
void
setBackgroundDrawable
(
Drawable
d
)
{
super
.
setBackgroundDrawable
(
d
);
if
(
listView
!=
null
)
{
listView
.
setBackgroundDrawable
(
d
);
}
}
/**
*
*
*/
public
void
setVisibility
(
int
visibility
)
{
public
void
setVisibility
(
int
visibility
)
{
super
.
setVisibility
(
visibility
);
if
(
visibility
==
VISIBLE
);
if
(
visibility
==
VISIBLE
)
;
{
exportImage
(
listView
.
getCurrentPageView
(),
null
);
}
}
/**
*
*(non-Javadoc)
* @see android.view.ViewGroup#dispatchDraw(android.graphics.Canvas)
* (non-Javadoc)
*
* @see android.view.ViewGroup#dispatchDraw(android.graphics.Canvas)
*/
protected
void
dispatchDraw
(
Canvas
canvas
)
{
protected
void
dispatchDraw
(
Canvas
canvas
)
{
super
.
dispatchDraw
(
canvas
);
drawPageNubmer
(
canvas
);
}
/**
*
*
*/
public
void
init
()
{
public
void
init
()
{
}
/**
*
*
*/
public
void
setZoom
(
float
zoom
,
int
pointX
,
int
pointY
)
{
public
void
setZoom
(
float
zoom
,
int
pointX
,
int
pointY
)
{
listView
.
setZoom
(
zoom
,
pointX
,
pointY
);
}
/**
* set fit size for PPT,Word view mode, PDf
*
* @param value fit size mode
* = 0, fit size of get minimum value of pageWidth / viewWidth and pageHeight / viewHeight;
* = 1, fit size of pageWidth
* = 2, fit size of PageHeight
*/
public
void
setFitSize
(
int
value
)
{
*
* @param value fit size mode
* = 0, fit size of get minimum value of pageWidth / viewWidth and pageHeight / viewHeight;
* = 1, fit size of pageWidth
* = 2, fit size of PageHeight
*/
public
void
setFitSize
(
int
value
)
{
listView
.
setFitSize
(
value
);
}
/**
* get fit size statue
*
*
* @return fit size statue
* = 0, left/right and top/bottom don't alignment
* = 1, top/bottom alignment
* = 2, left/right alignment
* = 3, left/right and top/bottom alignment
*/
public
int
getFitSizeState
()
{
* = 0, left/right and top/bottom don't alignment
* = 1, top/bottom alignment
* = 2, left/right alignment
* = 3, left/right and top/bottom alignment
*/
public
int
getFitSizeState
()
{
return
listView
.
getFitSizeState
();
}
/**
*
*
*/
public
float
getZoom
()
{
public
float
getZoom
()
{
return
listView
.
getZoom
();
}
/**
*
*
*/
public
float
getFitZoom
()
{
public
float
getFitZoom
()
{
return
listView
.
getFitZoom
();
}
/**
* get current display page number (base 1)
*
*
* @return page number (base 1)
*/
public
int
getCurrentPageNumber
()
{
public
int
getCurrentPageNumber
()
{
return
listView
.
getCurrentPageNumber
();
}
/**
*
*
*/
public
APageListView
getListView
()
{
public
APageListView
getListView
()
{
return
this
.
listView
;
}
/**
*
*
*/
public
void
nextPageView
()
{
public
void
nextPageView
()
{
listView
.
nextPageView
();
}
/**
*
*
*/
public
void
previousPageview
()
{
public
void
previousPageview
()
{
listView
.
previousPageview
();
}
/**
* switch page for page index (base 0)
*
*
* @param index
*/
public
void
showPDFPageForIndex
(
int
index
)
{
public
void
showPDFPageForIndex
(
int
index
)
{
listView
.
showPDFPageForIndex
(
index
);
}
/**
* @param x 为100%的值
* @param y 为100%的值
*/
public
long
viewToModel
(
int
x
,
int
y
,
boolean
isBack
)
{
public
long
viewToModel
(
int
x
,
int
y
,
boolean
isBack
)
{
int
pageIndex
=
listView
.
getCurrentPageNumber
()
-
1
;
if
(
pageIndex
<
0
||
pageIndex
>=
getPageCount
())
{
if
(
pageIndex
<
0
||
pageIndex
>=
getPageCount
())
{
return
0
;
}
return
pageRoot
.
viewToModel
(
x
,
y
,
isBack
);
}
/**
*
*
*/
public
Rectangle
modelToView
(
long
offset
,
Rectangle
rect
,
boolean
isBack
)
{
public
Rectangle
modelToView
(
long
offset
,
Rectangle
rect
,
boolean
isBack
)
{
int
pageIndex
=
listView
.
getCurrentPageNumber
()
-
1
;
if
(
pageIndex
<
0
||
pageIndex
>=
getPageCount
())
{
if
(
pageIndex
<
0
||
pageIndex
>=
getPageCount
())
{
return
rect
;
}
return
pageRoot
.
modelToView
(
offset
,
rect
,
isBack
);
}
/**
*
*
*/
public
int
getPageCount
()
{
public
int
getPageCount
()
{
return
Math
.
max
(
pageRoot
.
getChildCount
(),
1
);
}
/**
*
*
*/
public
APageListItem
getPageListItem
(
int
position
,
View
convertView
,
ViewGroup
parent
)
{
public
APageListItem
getPageListItem
(
int
position
,
View
convertView
,
ViewGroup
parent
)
{
Rect
rect
=
getPageSize
(
position
);
return
new
WPPageListItem
(
listView
,
control
,
rect
.
width
(),
rect
.
height
());
}
/**
*
*
*/
public
Rect
getPageSize
(
int
pageIndex
)
{
public
Rect
getPageSize
(
int
pageIndex
)
{
PageView
view
=
pageRoot
.
getPageView
(
pageIndex
);
if
(
view
!=
null
)
{
if
(
view
!=
null
)
{
pageSize
.
set
(
0
,
0
,
view
.
getWidth
(),
view
.
getHeight
());
}
else
{
}
else
{
IAttributeSet
attr
=
pageRoot
.
getDocument
().
getSection
(
0
).
getAttribute
();
int
pageWidth
=
(
int
)(
AttrManage
.
instance
().
getPageWidth
(
attr
)
*
MainConstant
.
TWIPS_TO_PIXEL
);
int
pageHeight
=
(
int
)(
AttrManage
.
instance
().
getPageHeight
(
attr
)
*
MainConstant
.
TWIPS_TO_PIXEL
);
int
pageWidth
=
(
int
)
(
AttrManage
.
instance
().
getPageWidth
(
attr
)
*
MainConstant
.
TWIPS_TO_PIXEL
);
int
pageHeight
=
(
int
)
(
AttrManage
.
instance
().
getPageHeight
(
attr
)
*
MainConstant
.
TWIPS_TO_PIXEL
);
pageSize
.
set
(
0
,
0
,
pageWidth
,
pageHeight
);
}
return
pageSize
;
}
/**
*
*
*/
public
void
exportImage
(
final
APageListItem
pageItem
,
final
Bitmap
srcBitmap
)
{
if
(
getControl
()
==
null
||
!(
getParent
()
instanceof
Word
))
{
public
void
exportImage
(
final
APageListItem
pageItem
,
final
Bitmap
srcBitmap
)
{
if
(
getControl
()
==
null
||
!(
getParent
()
instanceof
Word
))
{
return
;
}
WPFind
find
=
(
WPFind
)
control
.
getFind
();
if
(
find
.
isSetPointToVisible
())
{
WPFind
find
=
(
WPFind
)
control
.
getFind
();
if
(
find
.
isSetPointToVisible
())
{
find
.
setSetPointToVisible
(
false
);
PageView
pv
=
pageRoot
.
getPageView
(
pageItem
.
getPageIndex
());
if
(
pv
==
null
)
{
if
(
pv
==
null
)
{
return
;
}
Rectangle
rect
=
modelToView
(((
Word
)
getParent
()).
getHighlight
().
getSelectStart
(),
new
Rectangle
(),
false
);
Rectangle
rect
=
modelToView
(((
Word
)
getParent
()).
getHighlight
().
getSelectStart
(),
new
Rectangle
(),
false
);
rect
.
x
-=
pv
.
getX
();
rect
.
y
-=
pv
.
getY
();
if
(!
listView
.
isPointVisibleOnScreen
(
rect
.
x
,
rect
.
y
))
{
if
(!
listView
.
isPointVisibleOnScreen
(
rect
.
x
,
rect
.
y
))
{
listView
.
setItemPointVisibleOnScreen
(
rect
.
x
,
rect
.
y
);
return
;
}
}
post
(
new
Runnable
()
{
@
Override
public
void
run
()
{
try
{
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
IOfficeToPicture
otp
=
getControl
().
getOfficeToPicture
();
if
(
otp
!=
null
&&
otp
.
getModeType
()
==
IOfficeToPicture
.
VIEW_CHANGE_END
)
{
if
(
otp
!=
null
&&
otp
.
getModeType
()
==
IOfficeToPicture
.
VIEW_CHANGE_END
)
{
int
rW
=
Math
.
min
(
getWidth
(),
pageItem
.
getWidth
());
int
rH
=
Math
.
min
(
getHeight
(),
pageItem
.
getHeight
());
Bitmap
dstBitmap
=
otp
.
getBitmap
(
rW
,
rH
);
if
(
dstBitmap
==
null
)
{
if
(
dstBitmap
==
null
)
{
return
;
}
if
(
getParent
()
instanceof
Word
)
{
((
Word
)
getParent
()).
getHighlight
().
setPaintHighlight
(
false
);
if
(
getParent
()
instanceof
Word
)
{
((
Word
)
getParent
()).
getHighlight
().
setPaintHighlight
(
false
);
}
// don't zoom
if
(
dstBitmap
.
getWidth
()
==
rW
&&
dstBitmap
.
getHeight
()
==
rH
)
{
if
(
dstBitmap
.
getWidth
()
==
rW
&&
dstBitmap
.
getHeight
()
==
rH
)
{
Canvas
canvas
=
new
Canvas
(
dstBitmap
);
canvas
.
drawColor
(
Color
.
WHITE
);
float
zoom
=
listView
.
getZoom
();
PageView
pv
=
pageRoot
.
getPageView
(
pageItem
.
getPageIndex
());
if
(
pv
!=
null
)
{
canvas
.
save
();
if
(
pv
!=
null
)
{
canvas
.
save
();
canvas
.
translate
(-
pv
.
getX
()
*
zoom
,
-
pv
.
getY
()
*
zoom
);
int
left
=
(
int
)(
pageItem
.
getLeft
());
int
top
=
(
int
)(
pageItem
.
getTop
());
int
left
=
(
int
)
(
pageItem
.
getLeft
());
int
top
=
(
int
)
(
pageItem
.
getTop
());
pv
.
drawForPrintMode
(
canvas
,
-(
Math
.
max
(
left
,
0
)
-
left
),
-(
Math
.
max
(
top
,
0
)
-
top
),
zoom
);
canvas
.
restore
();
canvas
.
translate
(-(
Math
.
max
(
left
,
0
)
-
left
),
-(
Math
.
max
(
top
,
0
)
-
top
));
...
...
@@ -384,15 +333,13 @@ public class PrintWord extends FrameLayout implements IPageListViewListener
}
}
// zoom
else
{
else
{
PageView
pv
=
pageRoot
.
getPageView
(
pageItem
.
getPageIndex
());
if
(
pv
!=
null
)
{
float
paintZoom
=
Math
.
min
(
dstBitmap
.
getWidth
()
/
(
float
)
rW
,
dstBitmap
.
getHeight
()
/
(
float
)
rH
);
if
(
pv
!=
null
)
{
float
paintZoom
=
Math
.
min
(
dstBitmap
.
getWidth
()
/
(
float
)
rW
,
dstBitmap
.
getHeight
()
/
(
float
)
rH
);
float
zoom
=
listView
.
getZoom
()
*
paintZoom
;
int
left
=
(
int
)(
pageItem
.
getLeft
()
*
paintZoom
);
int
top
=
(
int
)(
pageItem
.
getTop
()
*
paintZoom
);
int
left
=
(
int
)
(
pageItem
.
getLeft
()
*
paintZoom
);
int
top
=
(
int
)
(
pageItem
.
getTop
()
*
paintZoom
);
Canvas
canvas
=
new
Canvas
(
dstBitmap
);
canvas
.
save
();
canvas
.
drawColor
(
Color
.
WHITE
);
...
...
@@ -403,172 +350,142 @@ public class PrintWord extends FrameLayout implements IPageListViewListener
control
.
getSysKit
().
getCalloutManager
().
drawPath
(
canvas
,
pageItem
.
getPageIndex
(),
zoom
);
}
}
if
(
getParent
()
instanceof
Word
)
{
((
Word
)
getParent
()).
getHighlight
().
setPaintHighlight
(
true
);
if
(
getParent
()
instanceof
Word
)
{
((
Word
)
getParent
()).
getHighlight
().
setPaintHighlight
(
true
);
}
otp
.
callBack
(
dstBitmap
);
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
}
}
});
}
/**
*
* @param dstBitmap
* @return
*/
public
Bitmap
getSnapshot
(
Bitmap
dstBitmap
)
{
APageListItem
pageItem
=
getListView
().
getCurrentPageView
();
if
(
pageItem
==
null
)
{
return
null
;
}
int
rW
=
Math
.
min
(
getWidth
(),
pageItem
.
getWidth
());
public
Bitmap
getSnapshot
(
Bitmap
dstBitmap
)
{
APageListItem
pageItem
=
getListView
().
getCurrentPageView
();
if
(
pageItem
==
null
)
{
return
null
;
}
int
rW
=
Math
.
min
(
getWidth
(),
pageItem
.
getWidth
());
int
rH
=
Math
.
min
(
getHeight
(),
pageItem
.
getHeight
());
if
(
getParent
()
instanceof
Word
)
{
((
Word
)
getParent
()).
getHighlight
().
setPaintHighlight
(
false
);
if
(
getParent
()
instanceof
Word
)
{
((
Word
)
getParent
()).
getHighlight
().
setPaintHighlight
(
false
);
}
// don't zoom
if
(
dstBitmap
.
getWidth
()
==
rW
&&
dstBitmap
.
getHeight
()
==
rH
)
{
if
(
dstBitmap
.
getWidth
()
==
rW
&&
dstBitmap
.
getHeight
()
==
rH
)
{
Canvas
canvas
=
new
Canvas
(
dstBitmap
);
canvas
.
drawColor
(
Color
.
WHITE
);
float
zoom
=
listView
.
getZoom
();
PageView
pv
=
pageRoot
.
getPageView
(
pageItem
.
getPageIndex
());
if
(
pv
!=
null
)
{
if
(
pv
!=
null
)
{
canvas
.
translate
(-
pv
.
getX
()
*
zoom
,
-
pv
.
getY
()
*
zoom
);
int
left
=
(
int
)(
pageItem
.
getLeft
());
int
top
=
(
int
)(
pageItem
.
getTop
());
int
left
=
(
int
)
(
pageItem
.
getLeft
());
int
top
=
(
int
)
(
pageItem
.
getTop
());
pv
.
drawForPrintMode
(
canvas
,
-(
Math
.
max
(
left
,
0
)
-
left
),
-(
Math
.
max
(
top
,
0
)
-
top
),
zoom
);
}
}
// zoom
else
{
else
{
PageView
pv
=
pageRoot
.
getPageView
(
pageItem
.
getPageIndex
());
if
(
pv
!=
null
)
{
float
paintZoom
=
Math
.
min
(
dstBitmap
.
getWidth
()
/
(
float
)
rW
,
dstBitmap
.
getHeight
()
/
(
float
)
rH
);
if
(
pv
!=
null
)
{
float
paintZoom
=
Math
.
min
(
dstBitmap
.
getWidth
()
/
(
float
)
rW
,
dstBitmap
.
getHeight
()
/
(
float
)
rH
);
float
zoom
=
listView
.
getZoom
()
*
paintZoom
;
int
left
=
(
int
)(
pageItem
.
getLeft
()
*
paintZoom
);
int
top
=
(
int
)(
pageItem
.
getTop
()
*
paintZoom
);
int
left
=
(
int
)
(
pageItem
.
getLeft
()
*
paintZoom
);
int
top
=
(
int
)
(
pageItem
.
getTop
()
*
paintZoom
);
Canvas
canvas
=
new
Canvas
(
dstBitmap
);
canvas
.
drawColor
(
Color
.
WHITE
);
canvas
.
translate
(-
pv
.
getX
()
*
zoom
,
-
pv
.
getY
()
*
zoom
);
pv
.
drawForPrintMode
(
canvas
,
-(
Math
.
max
(
left
,
0
)
-
left
),
-(
Math
.
max
(
top
,
0
)
-
top
),
zoom
);
}
}
if
(
getParent
()
instanceof
Word
)
{
((
Word
)
getParent
()).
getHighlight
().
setPaintHighlight
(
true
);
if
(
getParent
()
instanceof
Word
)
{
((
Word
)
getParent
()).
getHighlight
().
setPaintHighlight
(
true
);
}
return
dstBitmap
;
}
/**
*
*
*/
public
boolean
isInit
()
{
public
boolean
isInit
()
{
return
true
;
}
/**
*
* @return
* true fitzoom may be larger than 100% but smaller than the max zoom
* @return true fitzoom may be larger than 100% but smaller than the max zoom
* false fitzoom can not larger than 100%
*/
public
boolean
isIgnoreOriginalSize
()
{
return
control
.
getMainFrame
().
isIgnoreOriginalSize
();
public
boolean
isIgnoreOriginalSize
()
{
return
control
.
getMainFrame
().
isIgnoreOriginalSize
();
}
/**
* page list view moving position
* @param position horizontal or vertical
*/
public
int
getPageListViewMovingPosition
()
{
return
control
.
getMainFrame
().
getPageListViewMovingPosition
();
public
int
getPageListViewMovingPosition
()
{
return
control
.
getMainFrame
().
getPageListViewMovingPosition
();
}
/**
*
*
*/
public
Object
getModel
()
{
public
Object
getModel
()
{
return
pageRoot
;
}
/**
*
*
*/
public
IControl
getControl
()
{
public
IControl
getControl
()
{
return
this
.
control
;
}
/**
* event method, office engine dispatch
*
* @param v event source
* @param e1 MotionEvent instance
* @param e2 MotionEvent instance
* @param velocityX x axis velocity
* @param velocityY y axis velocity
* @param eventNethodType event method
* @see TouchEventListener#EVENT_CLICK
* @see TouchEventListener#EVENT_DOUBLE_TAP
* @see TouchEventListener#EVENT_DOUBLE_TAP_EVENT
* @see TouchEventListener#EVENT_DOWN
* @see TouchEventListener#EVENT_FLING
* @see TouchEventListener#EVENT_LONG_PRESS
* @see TouchEventListener#EVENT_SCROLL
* @see TouchEventListener#EVENT_SHOW_PRESS
* @see TouchEventListener#EVENT_SINGLE_TAP_CONFIRMED
* @see TouchEventListener#EVENT_SINGLE_TAP_UP
* @see TouchEventListener#EVENT_TOUCH
*/
public
boolean
onEventMethod
(
View
v
,
MotionEvent
e1
,
MotionEvent
e2
,
float
velocityX
,
float
velocityY
,
byte
eventMethodType
)
{
/**
* event method, office engine dispatch
*
* @param v event source
* @param e1 MotionEvent instance
* @param e2 MotionEvent instance
* @param velocityX x axis velocity
* @param velocityY y axis velocity
* @see TouchEventListener#EVENT_CLICK
* @see TouchEventListener#EVENT_DOUBLE_TAP
* @see TouchEventListener#EVENT_DOUBLE_TAP_EVENT
* @see TouchEventListener#EVENT_DOWN
* @see TouchEventListener#EVENT_FLING
* @see TouchEventListener#EVENT_LONG_PRESS
* @see TouchEventListener#EVENT_SCROLL
* @see TouchEventListener#EVENT_SHOW_PRESS
* @see TouchEventListener#EVENT_SINGLE_TAP_CONFIRMED
* @see TouchEventListener#EVENT_SINGLE_TAP_UP
* @see TouchEventListener#EVENT_TOUCH
*/
public
boolean
onEventMethod
(
View
v
,
MotionEvent
e1
,
MotionEvent
e2
,
float
velocityX
,
float
velocityY
,
byte
eventMethodType
)
{
if
(
eventMethodType
==
ON_SINGLE_TAP_UP
&&
e1
!=
null
&&
e1
.
getAction
()
==
MotionEvent
.
ACTION_UP
)
{
&&
e1
.
getAction
()
==
MotionEvent
.
ACTION_UP
)
{
APageListItem
item
=
listView
.
getCurrentPageView
();
if
(
item
!=
null
)
{
if
(
item
!=
null
)
{
PageView
pv
=
pageRoot
.
getPageView
(
item
.
getPageIndex
());
if
(
pv
!=
null
)
{
if
(
pv
!=
null
)
{
float
zoom
=
listView
.
getZoom
();
int
x
=
(
int
)((
e1
.
getX
()
-
item
.
getLeft
())
/
zoom
)
+
pv
.
getX
();
int
y
=
(
int
)((
e1
.
getY
()
-
item
.
getTop
())
/
zoom
)
+
pv
.
getY
();
int
x
=
(
int
)
((
e1
.
getX
()
-
item
.
getLeft
())
/
zoom
)
+
pv
.
getX
();
int
y
=
(
int
)
((
e1
.
getY
()
-
item
.
getTop
())
/
zoom
)
+
pv
.
getY
();
long
offset
=
pv
.
viewToModel
(
x
,
y
,
false
);
if
(
offset
>=
0
)
{
if
(
offset
>=
0
)
{
IElement
leaf
=
pv
.
getDocument
().
getLeaf
(
offset
);
if
(
leaf
!=
null
)
{
if
(
leaf
!=
null
)
{
int
hyID
=
AttrManage
.
instance
().
getHperlinkID
(
leaf
.
getAttribute
());
if
(
hyID
>=
0
)
{
if
(
hyID
>=
0
)
{
Hyperlink
hylink
=
control
.
getSysKit
().
getHyperlinkManage
().
getHyperlink
(
hyID
);
if
(
hylink
!=
null
)
{
if
(
hylink
!=
null
)
{
control
.
actionEvent
(
EventConstant
.
APP_HYPERLINK
,
hylink
);
}
}
...
...
@@ -581,142 +498,122 @@ public class PrintWord extends FrameLayout implements IPageListViewListener
}
/**
*
*
*/
public
void
updateStutus
(
Object
obj
)
{
control
.
actionEvent
(
EventConstant
.
SYS_UPDATE_TOOLSBAR_BUTTON_STATUS
,
obj
);
public
void
updateStutus
(
Object
obj
)
{
control
.
actionEvent
(
EventConstant
.
SYS_UPDATE_TOOLSBAR_BUTTON_STATUS
,
obj
);
}
/**
*
*
*/
public
void
resetSearchResult
(
APageListItem
pageItem
)
{
if
(
getParent
()
instanceof
Word
)
{
Word
word
=
(
Word
)
getParent
();
if
(
word
.
getFind
().
getPageIndex
()
!=
pageItem
.
getPageIndex
())
{
public
void
resetSearchResult
(
APageListItem
pageItem
)
{
if
(
getParent
()
instanceof
Word
)
{
Word
word
=
(
Word
)
getParent
();
if
(
word
.
getFind
().
getPageIndex
()
!=
pageItem
.
getPageIndex
())
{
word
.
getHighlight
().
removeHighlight
();
}
}
}
/**
*
*
*/
public
boolean
isTouchZoom
()
{
public
boolean
isTouchZoom
()
{
return
control
.
getMainFrame
().
isTouchZoom
();
}
/**
*
*
*/
public
boolean
isShowZoomingMsg
()
{
public
boolean
isShowZoomingMsg
()
{
return
control
.
getMainFrame
().
isShowZoomingMsg
();
}
/**
*
*
*/
public
void
changeZoom
()
{
public
void
changeZoom
()
{
control
.
getMainFrame
().
changeZoom
();
}
/**
* @param isDrawPictrue The isDrawPictrue to set.
*/
public
void
setDrawPictrue
(
boolean
isDrawPictrue
)
{
public
void
setDrawPictrue
(
boolean
isDrawPictrue
)
{
PictureKit
.
instance
().
setDrawPictrue
(
isDrawPictrue
);
}
/**
*
* @return
*/
public
PageView
getCurrentPageView
()
{
APageListItem
item
=
listView
.
getCurrentPageView
();
if
(
item
!=
null
)
{
public
PageView
getCurrentPageView
()
{
APageListItem
item
=
listView
.
getCurrentPageView
();
if
(
item
!=
null
)
{
return
pageRoot
.
getPageView
(
item
.
getPageIndex
());
}
return
null
;
}
/**
* 绘制页信息
*
* @param canvas
* @param zoom
*/
private
void
drawPageNubmer
(
Canvas
canvas
)
{
if
(
control
.
getMainFrame
().
isDrawPageNumber
())
{
private
void
drawPageNubmer
(
Canvas
canvas
)
{
Log
.
e
(
"PrintWord"
,
"drawPageNubmer"
);
if
(
control
.
getMainFrame
().
isDrawPageNumber
())
{
String
pn
=
String
.
valueOf
((
listView
.
getCurrentPageNumber
())
+
" / "
+
pageRoot
.
getChildCount
());
int
w
=
(
int
)
paint
.
measureText
(
pn
);
int
h
=
(
int
)
(
paint
.
descent
()
-
paint
.
ascent
());
int
x
=
(
int
)((
getWidth
()
-
w
)
/
2
);
int
y
=
(
int
)((
getHeight
()
-
h
)
-
50
);
int
w
=
(
int
)
paint
.
measureText
(
pn
);
int
h
=
(
int
)
(
paint
.
descent
()
-
paint
.
ascent
());
int
x
=
(
int
)
((
getWidth
()
-
w
)
/
2
);
int
y
=
(
int
)
((
getHeight
()
-
h
)
-
50
);
Drawable
drawable
=
SysKit
.
getPageNubmerDrawable
();
drawable
.
setBounds
((
int
)(
x
-
20
),
y
-
10
,
x
+
w
+
20
,
y
+
h
+
10
);
drawable
.
setBounds
((
int
)
(
x
-
20
),
y
-
10
,
x
+
w
+
20
,
y
+
h
+
10
);
drawable
.
draw
(
canvas
);
y
-=
paint
.
ascent
();
canvas
.
drawText
(
pn
,
x
,
y
,
paint
);
}
if
(
preShowPageIndex
!=
listView
.
getCurrentPageNumber
()
||
prePageCount
!=
getPageCount
())
{
||
prePageCount
!=
getPageCount
())
{
changePage
();
preShowPageIndex
=
listView
.
getCurrentPageNumber
();
prePageCount
=
getPageCount
();
}
}
/**
*
*/
public
void
changePage
()
{
public
void
changePage
()
{
control
.
getMainFrame
().
changePage
();
}
/**
* set change page flag, Only when effectively the PageSize greater than ViewSize.
* (for PPT, word print mode, PDF)
*
* @param b = true, change page
* = false, don't change page
* set change page flag, Only when effectively the PageSize greater than ViewSize.
* (for PPT, word print mode, PDF)
*/
public
boolean
isChangePage
()
{
return
control
.
getMainFrame
().
isChangePage
();
public
boolean
isChangePage
()
{
return
control
.
getMainFrame
().
isChangePage
();
}
/**
*
*
*/
public
void
dispose
()
{
public
void
dispose
()
{
control
=
null
;
if
(
listView
!=
null
)
{
if
(
listView
!=
null
)
{
listView
.
dispose
();
}
pageRoot
=
null
;
pageSize
=
null
;
}
private
int
preShowPageIndex
=
-
1
;
//
private
int
prePageCount
=
-
1
;
...
...
library/src/main/java/com/cherry/lib/doc/office/wp/control/Word.java
View file @
7096a17f
...
...
@@ -17,6 +17,7 @@ import android.graphics.Rect;
import
android.graphics.Typeface
;
import
android.graphics.drawable.Drawable
;
import
android.util.AttributeSet
;
import
android.util.Log
;
import
android.view.View
;
import
android.widget.LinearLayout
;
...
...
@@ -569,6 +570,7 @@ public class Word extends LinearLayout implements IWord {
* @param zoom
*/
private
void
drawPageNubmer
(
Canvas
canvas
,
float
zoom
)
{
Log
.
e
(
"Word"
,
"drawPageNubmer"
);
int
currentNumber
=
getCurrentPageNumber
();
if
(
control
.
getMainFrame
().
isDrawPageNumber
()
&&
pageRoot
!=
null
)
{
Rect
rect
=
canvas
.
getClipBounds
();
...
...
library/src/main/java/com/cherry/lib/doc/widget/DocView.kt
View file @
7096a17f
...
...
@@ -9,6 +9,7 @@ import android.graphics.Rect
import
android.graphics.drawable.Drawable
import
android.util.AttributeSet
import
android.util.Log
import
android.view.MotionEvent
import
android.view.View
import
android.view.ViewGroup
import
android.widget.FrameLayout
...
...
@@ -52,27 +53,19 @@ class DocView : FrameLayout {
private
val
TAG
=
"DocView"
var
mActivity
:
Activity
?
=
null
var
lifecycleScope
:
LifecycleCoroutineScope
=
(
context
as
AppCompatActivity
).
lifecycleScope
private
var
mPoiViewer
:
PoiViewer
?
=
null
private
var
mMovingOrientation
=
DocMovingOrientation
.
HORIZONTAL
private
var
engine
=
DocEngine
.
INTERNAL
private
var
showDivider
=
true
private
var
showPageNum
=
true
private
var
divider
:
Drawable
?
=
null
private
var
runnable
=
Runnable
{}
var
enableLoadingForPages
:
Boolean
=
true
var
pbDefaultHeight
=
2
var
pbHeight
:
Int
=
pbDefaultHeight
var
pbDefaultColor
=
Color
.
RED
var
pbColor
:
Int
=
pbDefaultColor
private
var
pdfRendererCoreInitialised
=
false
var
pageMargin
:
Rect
=
Rect
(
0
,
0
,
0
,
0
)
var
totalPageCount
=
0
var
mOnDocPageChangeListener
:
OnDocPageChangeListener
?
=
null
var
sourceFilePath
:
String
?
=
null
var
mViewPdfInPage
:
Boolean
=
true
...
...
@@ -87,9 +80,6 @@ class DocView : FrameLayout {
fun
initView
(
attrs
:
AttributeSet
?,
defStyle
:
Int
)
{
inflate
(
context
,
R
.
layout
.
doc_view
,
this
)
binding
=
DocViewBinding
.
bind
(
this
)
binding
.
mIvPdf
.
setOnClickListener
{
binding
.
mLlBigPdfImage
.
hide
()
}
val
typedArray
=
context
.
obtainStyledAttributes
(
attrs
,
R
.
styleable
.
DocView
,
defStyle
,
0
)
...
...
@@ -114,7 +104,6 @@ class DocView : FrameLayout {
bottom
=
typedArray
.
getDimensionPixelSize
(
R
.
styleable
.
DocView_dv_page_marginBottom
,
bottom
)
}
binding
.
mPdfPageNo
.
isVisible
=
showPageNum
val
layoutParams
=
binding
.
mPlLoadProgress
.
layoutParams
layoutParams
.
height
=
pbHeight
...
...
@@ -125,7 +114,6 @@ class DocView : FrameLayout {
typedArray
.
recycle
()
}
fun
openDoc
(
activity
:
Activity
,
docUrl
:
String
?,
docSourceType
:
Int
,
engine
:
DocEngine
=
this
.
engine
...
...
@@ -136,8 +124,10 @@ class DocView : FrameLayout {
@SuppressLint
(
"ObsoleteSdkInt"
)
fun
openDoc
(
activity
:
Activity
?,
docUrl
:
String
?,
docSourceType
:
Int
,
fileType
:
Int
,
activity
:
Activity
?,
docUrl
:
String
?,
docSourceType
:
Int
,
fileType
:
Int
,
viewPdfInPage
:
Boolean
=
false
,
engine
:
DocEngine
=
this
.
engine
)
{
...
...
@@ -180,7 +170,6 @@ class DocView : FrameLayout {
when
(
type
)
{
FileType
.
PDF
->
{
Log
.
e
(
TAG
,
"openDoc()......PDF"
)
// binding.mDocWeb.hide()
binding
.
mFlDocContainer
.
hide
()
binding
.
mIvImage
.
hide
()
...
...
@@ -191,7 +180,6 @@ class DocView : FrameLayout {
showPageNum
=
false
}
Log
.
e
(
TAG
,
"openDoc()......"
)
// binding.mDocWeb.hide()
binding
.
mFlDocContainer
.
hide
()
binding
.
mIvImage
.
show
()
if
(
docSourceType
==
DocSourceType
.
PATH
)
{
...
...
@@ -218,9 +206,33 @@ class DocView : FrameLayout {
}
}
var
singleTapAction
:
(()
->
Unit
)?
=
null
var
getPageNumberAction
:
((
current
:
Int
,
total
:
Int
)
->
Unit
)?
=
null
fun
showDoc
(
activity
:
Activity
,
mDocContainer
:
ViewGroup
?,
url
:
String
?,
docSourceType
:
Int
,
fileType
:
Int
)
{
Log
.
e
(
TAG
,
"showDoc()......"
)
val
iOffice
:
IOffice
=
object
:
IOffice
()
{
override
fun
onEventMethod
(
v
:
View
?,
e1
:
MotionEvent
?,
e2
:
MotionEvent
?,
xValue
:
Float
,
yValue
:
Float
,
eventMethodType
:
Byte
):
Boolean
{
Log
.
e
(
TAG
,
"onEventMethod ${e1?.action} ${MotionEvent.ACTION_DOWN}"
)
return
super
.
onEventMethod
(
v
,
e1
,
e2
,
xValue
,
yValue
,
eventMethodType
)
}
override
fun
singleTap
()
{
Log
.
e
(
TAG
,
"singleTap"
)
singleTapAction
?.
invoke
()
}
override
fun
getPageNumber
(
current
:
Int
,
total
:
Int
)
{
getPageNumberAction
?.
invoke
(
current
,
total
)
}
override
fun
getActivity
():
Activity
{
return
activity
}
...
...
@@ -269,52 +281,10 @@ class DocView : FrameLayout {
}
}
//是否绘制页码
iOffice
.
isDrawPageNumber
iOffice
.
openFile
(
url
,
docSourceType
,
fileType
.
toString
())
}
private
val
scrollListener
=
object
:
RecyclerView
.
OnScrollListener
()
{
override
fun
onScrolled
(
recyclerView
:
RecyclerView
,
dx
:
Int
,
dy
:
Int
)
{
super
.
onScrolled
(
recyclerView
,
dx
,
dy
)
(
recyclerView
.
layoutManager
as
LinearLayoutManager
).
run
{
var
foundPosition
:
Int
=
findLastCompletelyVisibleItemPosition
()
if
(
foundPosition
!=
RecyclerView
.
NO_POSITION
)
binding
.
mPdfPageNo
.
text
=
context
.
getString
(
R
.
string
.
pdfView_page_no
,
foundPosition
+
1
,
totalPageCount
)
if
(
showPageNum
)
{
binding
.
mPdfPageNo
.
visibility
=
View
.
VISIBLE
}
if
(
foundPosition
==
0
&&
!
mViewPdfInPage
)
binding
.
mPdfPageNo
.
postDelayed
({
binding
.
mPdfPageNo
.
visibility
=
GONE
},
3000
)
if
(
foundPosition
!=
RecyclerView
.
NO_POSITION
)
{
mOnDocPageChangeListener
?.
OnPageChanged
(
foundPosition
,
totalPageCount
)
return
@run
}
foundPosition
=
findFirstVisibleItemPosition
()
if
(
foundPosition
!=
RecyclerView
.
NO_POSITION
)
{
mOnDocPageChangeListener
?.
OnPageChanged
(
foundPosition
,
totalPageCount
)
return
@run
}
}
}
override
fun
onScrollStateChanged
(
recyclerView
:
RecyclerView
,
newState
:
Int
)
{
super
.
onScrollStateChanged
(
recyclerView
,
newState
)
if
(
newState
==
RecyclerView
.
SCROLL_STATE_IDLE
&&
!
mViewPdfInPage
)
{
binding
.
mPdfPageNo
.
postDelayed
(
runnable
,
3000
)
}
else
{
binding
.
mPdfPageNo
.
removeCallbacks
(
runnable
)
}
}
}
override
fun
onDetachedFromWindow
()
{
super
.
onDetachedFromWindow
()
onDestroy
()
...
...
library/src/main/res/layout/doc_view.xml
View file @
7096a17f
...
...
@@ -4,38 +4,6 @@
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<FrameLayout
android:id=
"@+id/mLlBigPdfImage"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@color/white"
android:visibility=
"gone"
>
<com.cherry.lib.doc.widget.PinchImageView
android:id=
"@+id/mIvPdf"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
<ProgressBar
android:id=
"@+id/mPbBigLoading"
android:layout_width=
"40dp"
android:layout_height=
"40dp"
android:layout_gravity=
"center"
android:visibility=
"gone"
tools:visibility=
"visible"
/>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"end"
android:layout_marginTop=
"50dp"
android:layout_marginEnd=
"30dp"
android:scaleType=
"fitCenter"
android:src=
"@mipmap/ic_big_close"
tools:ignore=
"ContentDescription"
/>
</FrameLayout>
<FrameLayout
android:id=
"@+id/mFlDocContainer"
android:layout_width=
"match_parent"
...
...
@@ -55,17 +23,5 @@
android:progressDrawable=
"@drawable/pb_webview_layer"
android:visibility=
"visible"
/>
<TextView
android:id=
"@+id/mPdfPageNo"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_margin=
"18dp"
android:background=
"@drawable/page_counter"
android:paddingStart=
"12dp"
android:paddingTop=
"4dp"
android:paddingEnd=
"12dp"
android:paddingBottom=
"4dp"
android:textColor=
"#A19D9D"
android:textSize=
"16sp"
/>
</FrameLayout>
\ No newline at end of file
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